2.0
This commit is contained in:
@@ -0,0 +1,262 @@
|
||||
package exopandora.worldhandler.builder;
|
||||
|
||||
import java.util.AbstractMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.builder.Syntax.SyntaxEntry;
|
||||
import exopandora.worldhandler.builder.types.Coordinate;
|
||||
import exopandora.worldhandler.builder.types.Level;
|
||||
import exopandora.worldhandler.builder.types.TargetSelector;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
import exopandora.worldhandler.main.WorldHandler;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public abstract class CommandBuilder implements ICommandBuilderSyntax
|
||||
{
|
||||
private List<Entry<SyntaxEntry, String>> command;
|
||||
|
||||
public CommandBuilder()
|
||||
{
|
||||
this.updateSyntax(this.getSyntax());
|
||||
}
|
||||
|
||||
protected void setNode(int index, String node)
|
||||
{
|
||||
this.set(index, node != null ? (node.isEmpty() ? null : node) : null, Type.STRING);
|
||||
}
|
||||
|
||||
protected void setNode(int index, boolean node)
|
||||
{
|
||||
this.set(index, node, Type.BOOLEAN);
|
||||
}
|
||||
|
||||
protected void setNode(int index, short node)
|
||||
{
|
||||
this.set(index, node, Type.SHORT);
|
||||
}
|
||||
|
||||
protected void setNode(int index, byte node)
|
||||
{
|
||||
this.set(index, node, Type.BYTE);
|
||||
}
|
||||
|
||||
protected void setNode(int index, int node)
|
||||
{
|
||||
this.set(index, node, Type.INT);
|
||||
}
|
||||
|
||||
protected void setNode(int index, float node)
|
||||
{
|
||||
this.set(index, node, Type.FLOAT);
|
||||
}
|
||||
|
||||
protected void setNode(int index, double node)
|
||||
{
|
||||
this.set(index, node, Type.DOUBLE);
|
||||
}
|
||||
|
||||
protected void setNode(int index, long node)
|
||||
{
|
||||
this.set(index, node, Type.LONG);
|
||||
}
|
||||
|
||||
protected void setNode(int index, ResourceLocation node)
|
||||
{
|
||||
this.set(index, node, Type.RESOURCE_LOCATION);
|
||||
}
|
||||
|
||||
protected void setNode(int index, NBTTagCompound nbt)
|
||||
{
|
||||
this.set(index, nbt, Type.NBT);
|
||||
}
|
||||
|
||||
protected void setNode(int index, Coordinate coordinate)
|
||||
{
|
||||
this.set(index, coordinate, Type.COORDINATE);
|
||||
}
|
||||
|
||||
protected void setNode(int index, TargetSelector target)
|
||||
{
|
||||
this.set(index, target, Type.TARGET_SELECTOR);
|
||||
}
|
||||
|
||||
protected void setNode(int index, Level level)
|
||||
{
|
||||
this.set(index, level, Type.LEVEL);
|
||||
}
|
||||
|
||||
private void set(int index, Object value, Type type)
|
||||
{
|
||||
if(index < this.command.size())
|
||||
{
|
||||
SyntaxEntry entry = this.command.get(index).getKey();
|
||||
Type expected = entry.getType();
|
||||
boolean flag = expected.equals(type);
|
||||
|
||||
if(value != null && flag)
|
||||
{
|
||||
this.command.get(index).setValue(value.toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
this.command.get(index).setValue(entry.toString());
|
||||
|
||||
if(!flag)
|
||||
{
|
||||
this.warn("set", expected, type, index);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
WorldHandler.LOGGER.warn("Tried to set invalid index \"" + index + "\" for command \"" + this.getCommandName() + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected String getNodeAsString(int index)
|
||||
{
|
||||
return this.get(index, Type.STRING);
|
||||
}
|
||||
|
||||
protected boolean getNodeAsBoolean(int index)
|
||||
{
|
||||
return this.get(index, Type.BOOLEAN);
|
||||
}
|
||||
|
||||
protected short getNodeAsShort(int index)
|
||||
{
|
||||
return this.get(index, Type.SHORT);
|
||||
}
|
||||
|
||||
protected byte getNodeAsByte(int index)
|
||||
{
|
||||
return this.get(index, Type.BYTE);
|
||||
}
|
||||
|
||||
protected int getNodeAsInt(int index)
|
||||
{
|
||||
return this.get(index, Type.INT);
|
||||
}
|
||||
|
||||
protected float getNodeAsFloat(int index)
|
||||
{
|
||||
return this.get(index, Type.FLOAT);
|
||||
}
|
||||
|
||||
protected double getNodeAsDouble(int index)
|
||||
{
|
||||
return this.get(index, Type.DOUBLE);
|
||||
}
|
||||
|
||||
protected long getNodeAsLong(int index)
|
||||
{
|
||||
return this.get(index, Type.LONG);
|
||||
}
|
||||
|
||||
protected Coordinate getNodeAsCoordinate(int index)
|
||||
{
|
||||
return this.get(index, Type.COORDINATE);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected ResourceLocation getNodeAsResourceLocation(int index)
|
||||
{
|
||||
return this.get(index, Type.RESOURCE_LOCATION);
|
||||
}
|
||||
|
||||
protected TargetSelector getNodeAsTargetSelector(int index)
|
||||
{
|
||||
return this.get(index, Type.TARGET_SELECTOR);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected Level getNodeAsLevel(int index)
|
||||
{
|
||||
return this.get(index, Type.LEVEL);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected NBTTagCompound getNodeAsNBT(int index)
|
||||
{
|
||||
return this.get(index, Type.NBT);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private <T> T get(int index, Type type)
|
||||
{
|
||||
if(index < this.command.size())
|
||||
{
|
||||
Entry<SyntaxEntry, String> entry = this.command.get(index);
|
||||
Type expected = entry.getKey().getType();
|
||||
String value = entry.getValue();
|
||||
|
||||
if(expected.equals(type))
|
||||
{
|
||||
if(value.equals(entry.getKey().toString()))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return expected.<T>parse(value);
|
||||
}
|
||||
|
||||
this.warn("get", expected, type, index);
|
||||
|
||||
return type.<T>parse(value);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void warn(String function, Type expected, Type type, int index)
|
||||
{
|
||||
WorldHandler.LOGGER.warn("[" + function.toUpperCase() + "] Expected \"" + expected + "\" instead of \"" + type + "\" at index \"" + index + "\" for command \"" + this.getCommandName() + "\"");
|
||||
}
|
||||
|
||||
private boolean isDefaultEntry(Entry<SyntaxEntry, String> entry)
|
||||
{
|
||||
return entry.getKey().getDefault() != null ? entry.getValue().equals(entry.getKey().getDefault().toString()) : false;
|
||||
}
|
||||
|
||||
protected void updateSyntax(Syntax syntax)
|
||||
{
|
||||
if(syntax != null)
|
||||
{
|
||||
this.command = syntax.getSyntaxEntries().stream().map(entry -> new AbstractMap.SimpleEntry<SyntaxEntry, String>(entry, entry.toString())).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toCommand()
|
||||
{
|
||||
return "/" + this.getCommandName() + " " + String.join(" ", this.command.stream().map(entry -> this.isDefaultEntry(entry) ? entry.getKey().toString() : entry.getValue()).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toActualCommand()
|
||||
{
|
||||
List<String> command = new ArrayList<String>();
|
||||
|
||||
for(Entry<SyntaxEntry, String> entry : this.command)
|
||||
{
|
||||
if(!entry.getKey().isRequired() && (entry.getKey().toString().equals(entry.getValue()) || this.isDefaultEntry(entry)))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
command.add(entry.getValue());
|
||||
}
|
||||
|
||||
return "/" + this.getCommandName() + " " + String.join(" ", command);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package exopandora.worldhandler.builder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import exopandora.worldhandler.builder.component.IBuilderComponent;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public abstract class CommandBuilderNBT extends CommandBuilder implements ICommandBuilderNBT
|
||||
{
|
||||
private final List<IBuilderComponent> TAG_TO_COMPONENT = new ArrayList<IBuilderComponent>();
|
||||
|
||||
@Override
|
||||
public String toCommand()
|
||||
{
|
||||
this.setNBT(this.buildNBT());
|
||||
return super.toCommand();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toActualCommand()
|
||||
{
|
||||
this.setNBT(this.buildNBT());
|
||||
return super.toActualCommand();
|
||||
}
|
||||
|
||||
private NBTTagCompound buildNBT()
|
||||
{
|
||||
NBTTagCompound nbt = new NBTTagCompound();
|
||||
|
||||
for(IBuilderComponent component : this.TAG_TO_COMPONENT)
|
||||
{
|
||||
NBTBase serialized = component.serialize();
|
||||
|
||||
if(serialized != null)
|
||||
{
|
||||
if(!nbt.hasKey(component.getTag()))
|
||||
{
|
||||
nbt.setTag(component.getTag(), serialized);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(nbt.hasNoTags())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return nbt;
|
||||
}
|
||||
|
||||
protected <T extends IBuilderComponent> T registerNBTComponent(T component, String id)
|
||||
{
|
||||
this.TAG_TO_COMPONENT.add(component);
|
||||
return component;
|
||||
}
|
||||
|
||||
protected <T extends IBuilderComponent> T registerNBTComponent(T component)
|
||||
{
|
||||
return this.registerNBTComponent(component, component.getTag());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package exopandora.worldhandler.builder;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public interface ICommandBuilder
|
||||
{
|
||||
static final int MAX_COMMAND_LENGTH = 256;
|
||||
|
||||
String toCommand();
|
||||
|
||||
default boolean needsCommandBlock()
|
||||
{
|
||||
return this.toCommand().length() > MAX_COMMAND_LENGTH;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package exopandora.worldhandler.builder;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public interface ICommandBuilderNBT extends ICommandBuilder
|
||||
{
|
||||
void setNBT(NBTTagCompound nbt);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package exopandora.worldhandler.builder;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public interface ICommandBuilderSyntax extends ICommandBuilder
|
||||
{
|
||||
String getCommandName();
|
||||
String toActualCommand();
|
||||
Syntax getSyntax();
|
||||
|
||||
@Override
|
||||
default boolean needsCommandBlock()
|
||||
{
|
||||
return this.toActualCommand().length() > MAX_COMMAND_LENGTH;
|
||||
}
|
||||
}
|
||||
93
src/main/java/exopandora/worldhandler/builder/Syntax.java
Normal file
93
src/main/java/exopandora/worldhandler/builder/Syntax.java
Normal file
@@ -0,0 +1,93 @@
|
||||
package exopandora.worldhandler.builder;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class Syntax
|
||||
{
|
||||
private List<SyntaxEntry> syntax = new ArrayList<SyntaxEntry>();
|
||||
|
||||
public Syntax addRequired(String key, Type type)
|
||||
{
|
||||
this.syntax.add(new SyntaxEntry(key, type, true, null));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Syntax addRequired(String key, Type type, Object def)
|
||||
{
|
||||
this.syntax.add(new SyntaxEntry(key, type, true, def));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Syntax addOptional(String key, Type type)
|
||||
{
|
||||
this.syntax.add(new SyntaxEntry(key, type, false, null));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Syntax addOptional(String key, Type type, Object def)
|
||||
{
|
||||
this.syntax.add(new SyntaxEntry(key, type, false, def));
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<SyntaxEntry> getSyntaxEntries()
|
||||
{
|
||||
return this.syntax;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public static class SyntaxEntry
|
||||
{
|
||||
private final String key;
|
||||
private final Type type;
|
||||
private final boolean required;
|
||||
private final Object def;
|
||||
|
||||
public SyntaxEntry(String key, Type type, boolean required, Object def)
|
||||
{
|
||||
this.key = key;
|
||||
this.type = type;
|
||||
this.required = required;
|
||||
this.def = def;
|
||||
}
|
||||
|
||||
public String getKey()
|
||||
{
|
||||
return this.key;
|
||||
}
|
||||
|
||||
public Type getType()
|
||||
{
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public boolean isRequired()
|
||||
{
|
||||
return this.required;
|
||||
}
|
||||
|
||||
public Object getDefault()
|
||||
{
|
||||
return this.def;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
if(this.required)
|
||||
{
|
||||
return "<" + this.key + ">";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "[" + this.key + "]";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package exopandora.worldhandler.builder.component;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public interface IBuilderComponent
|
||||
{
|
||||
@Nullable
|
||||
NBTBase serialize();
|
||||
String getTag();
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package exopandora.worldhandler.builder.component.abstr;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
import exopandora.worldhandler.builder.component.IBuilderComponent;
|
||||
import exopandora.worldhandler.builder.impl.abstr.EnumAttributes;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public abstract class ComponentAttribute implements IBuilderComponent
|
||||
{
|
||||
protected Map<EnumAttributes, Float> attributes = new HashMap<EnumAttributes, Float>();
|
||||
protected Function<EnumAttributes, Boolean> applyable;
|
||||
|
||||
public ComponentAttribute(Function<EnumAttributes, Boolean> applyable)
|
||||
{
|
||||
this.applyable = applyable;
|
||||
}
|
||||
|
||||
public void set(EnumAttributes attribute, float ammount)
|
||||
{
|
||||
this.attributes.put(attribute, ammount);
|
||||
}
|
||||
|
||||
public void remove(EnumAttributes attribute)
|
||||
{
|
||||
this.attributes.remove(attribute);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,182 @@
|
||||
package exopandora.worldhandler.builder.component.abstr;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.builder.component.IBuilderComponent;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public abstract class ComponentPotion implements IBuilderComponent
|
||||
{
|
||||
protected final Map<Potion, PotionMetadata> potions = Potion.REGISTRY.getKeys().stream().collect(Collectors.toMap(Potion.REGISTRY::getObject, key -> new PotionMetadata()));
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public NBTBase serialize()
|
||||
{
|
||||
NBTTagList list = new NBTTagList();
|
||||
|
||||
for(Entry<Potion, PotionMetadata> entry : this.potions.entrySet())
|
||||
{
|
||||
PotionMetadata potion = entry.getValue();
|
||||
|
||||
if(potion.getAmplifier() > 0)
|
||||
{
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
|
||||
compound.setByte("Id", (byte) Potion.getIdFromPotion(entry.getKey()));
|
||||
compound.setByte("Amplifier", (byte) (potion.getAmplifier() - 1));
|
||||
compound.setInteger("Duration", potion.getDuration() > 0 ? Math.min(potion.getDuration(), 1000000) : 1000000);
|
||||
compound.setBoolean("Ambient", potion.getAmbient());
|
||||
compound.setBoolean("ShowParticles", potion.getShowParticles());
|
||||
|
||||
list.appendTag(compound);
|
||||
}
|
||||
}
|
||||
|
||||
if(!list.hasNoTags())
|
||||
{
|
||||
return list;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void set(Potion potion, PotionMetadata metadata)
|
||||
{
|
||||
this.potions.put(potion, metadata);
|
||||
}
|
||||
|
||||
public void set(Potion potion, byte amplifier, int seconds, int minutes, int hours, boolean showParticles, boolean ambient)
|
||||
{
|
||||
this.set(potion, new PotionMetadata(amplifier, seconds, minutes, hours, showParticles, ambient));
|
||||
}
|
||||
|
||||
public void setAmplifier(Potion potion, byte amplifier)
|
||||
{
|
||||
if(this.potions.containsKey(potion))
|
||||
{
|
||||
this.potions.get(potion).setAmplifier(amplifier);
|
||||
}
|
||||
}
|
||||
|
||||
public byte getAmplifier(Potion potion)
|
||||
{
|
||||
if(this.potions.containsKey(potion))
|
||||
{
|
||||
return this.potions.get(potion).getAmplifier();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setSeconds(Potion potion, int seconds)
|
||||
{
|
||||
if(this.potions.containsKey(potion))
|
||||
{
|
||||
this.potions.get(potion).setSeconds(seconds);;
|
||||
}
|
||||
}
|
||||
|
||||
public int getSeconds(Potion potion)
|
||||
{
|
||||
if(this.potions.containsKey(potion))
|
||||
{
|
||||
return this.potions.get(potion).getSeconds();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setMinutes(Potion potion, int minutes)
|
||||
{
|
||||
if(this.potions.containsKey(potion))
|
||||
{
|
||||
this.potions.get(potion).setSeconds(minutes);;
|
||||
}
|
||||
}
|
||||
|
||||
public int getMinutes(Potion potion)
|
||||
{
|
||||
if(this.potions.containsKey(potion))
|
||||
{
|
||||
return this.potions.get(potion).getMinutes();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setHours(Potion potion, int hours)
|
||||
{
|
||||
if(this.potions.containsKey(potion))
|
||||
{
|
||||
this.potions.get(potion).setSeconds(hours);;
|
||||
}
|
||||
}
|
||||
|
||||
public int getHours(Potion potion)
|
||||
{
|
||||
if(this.potions.containsKey(potion))
|
||||
{
|
||||
return this.potions.get(potion).getHours();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setShowParticles(Potion potion, boolean showParticles)
|
||||
{
|
||||
if(this.potions.containsKey(potion))
|
||||
{
|
||||
this.potions.get(potion).setShowParticles(showParticles);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getShowParticles(Potion potion)
|
||||
{
|
||||
if(this.potions.containsKey(potion))
|
||||
{
|
||||
return this.potions.get(potion).getShowParticles();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setAmbient(Potion potion, boolean ambient)
|
||||
{
|
||||
if(this.potions.containsKey(potion))
|
||||
{
|
||||
this.potions.get(potion).setAmbient(ambient);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getAmbient(Potion potion)
|
||||
{
|
||||
if(this.potions.containsKey(potion))
|
||||
{
|
||||
return this.potions.get(potion).getAmbient();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public PotionMetadata get(Potion potion)
|
||||
{
|
||||
return this.potions.get(potion);
|
||||
}
|
||||
|
||||
public void remove(Potion potion)
|
||||
{
|
||||
this.potions.remove(potion);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
package exopandora.worldhandler.builder.component.abstr;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class PotionMetadata
|
||||
{
|
||||
private byte amplifier;
|
||||
private int seconds;
|
||||
private int minutes;
|
||||
private int hours;
|
||||
private boolean showParticles;
|
||||
private boolean ambient;
|
||||
|
||||
public PotionMetadata()
|
||||
{
|
||||
this((byte) 0, 0, 0, 0, true, false);
|
||||
}
|
||||
|
||||
public PotionMetadata(byte amplifier, int seconds, int minutes, int hours, boolean showParticles, boolean ambient)
|
||||
{
|
||||
this.amplifier = amplifier;
|
||||
this.seconds = seconds;
|
||||
this.minutes = minutes;
|
||||
this.hours = hours;
|
||||
this.showParticles = showParticles;
|
||||
this.ambient = ambient;
|
||||
}
|
||||
|
||||
public byte getAmplifier()
|
||||
{
|
||||
return this.amplifier;
|
||||
}
|
||||
|
||||
public void setAmplifier(byte amplifier)
|
||||
{
|
||||
this.amplifier = amplifier;
|
||||
}
|
||||
|
||||
public int getSeconds()
|
||||
{
|
||||
return this.seconds;
|
||||
}
|
||||
|
||||
public void setSeconds(int seconds)
|
||||
{
|
||||
this.seconds = seconds;
|
||||
}
|
||||
|
||||
public int getMinutes()
|
||||
{
|
||||
return this.minutes;
|
||||
}
|
||||
|
||||
public void setMinutes(int minutes)
|
||||
{
|
||||
this.minutes = minutes;
|
||||
}
|
||||
|
||||
public int getHours()
|
||||
{
|
||||
return this.hours;
|
||||
}
|
||||
|
||||
public void setHours(int hours)
|
||||
{
|
||||
this.hours = hours;
|
||||
}
|
||||
|
||||
public boolean getShowParticles()
|
||||
{
|
||||
return this.showParticles;
|
||||
}
|
||||
|
||||
public void setShowParticles(boolean showParticles)
|
||||
{
|
||||
this.showParticles = showParticles;
|
||||
}
|
||||
|
||||
public boolean getAmbient()
|
||||
{
|
||||
return this.ambient;
|
||||
}
|
||||
|
||||
public void setAmbient(boolean ambient)
|
||||
{
|
||||
this.ambient = ambient;
|
||||
}
|
||||
|
||||
public int getDuration()
|
||||
{
|
||||
return PotionMetadata.getDuration(this.seconds, this.minutes, this.hours);
|
||||
}
|
||||
|
||||
public static int getDuration(int seconds, int minutes, int hours)
|
||||
{
|
||||
return seconds * 20 + minutes * 1200 + hours * 72000;
|
||||
}
|
||||
|
||||
public PotionMetadata withAmplifier(byte amplifier)
|
||||
{
|
||||
this.amplifier = amplifier;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PotionMetadata withShowParticles(boolean showParticles)
|
||||
{
|
||||
this.showParticles = showParticles;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PotionMetadata withSeconds(int seconds)
|
||||
{
|
||||
this.seconds = seconds;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PotionMetadata withMinutes(int minutes)
|
||||
{
|
||||
this.minutes = minutes;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PotionMetadata withHours(int hours)
|
||||
{
|
||||
this.hours = hours;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PotionMetadata withAmbient(boolean ambient)
|
||||
{
|
||||
this.ambient = ambient;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package exopandora.worldhandler.builder.component.impl;
|
||||
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Function;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.builder.component.abstr.ComponentAttribute;
|
||||
import exopandora.worldhandler.builder.impl.abstr.EnumAttributes;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ComponentAttributeItem extends ComponentAttribute
|
||||
{
|
||||
public ComponentAttributeItem(Function<EnumAttributes, Boolean> applyable)
|
||||
{
|
||||
super(applyable);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public NBTBase serialize()
|
||||
{
|
||||
NBTTagList attributes = new NBTTagList();
|
||||
|
||||
for(Entry<EnumAttributes, Float> entry : this.attributes.entrySet())
|
||||
{
|
||||
if(this.applyable.apply(entry.getKey()) && entry.getValue() != 0)
|
||||
{
|
||||
NBTTagCompound attribute = new NBTTagCompound();
|
||||
|
||||
attribute.setString("AttributeName", entry.getKey().getAttribute());
|
||||
attribute.setString("Name", entry.getKey().getAttribute());
|
||||
attribute.setDouble("Amount", entry.getKey().calculate(entry.getValue()));
|
||||
attribute.setInteger("Operation", entry.getKey().getOperation().ordinal());
|
||||
attribute.setLong("UUIDLeast", UUID.nameUUIDFromBytes(entry.getKey().getAttribute().getBytes()).getLeastSignificantBits());
|
||||
attribute.setLong("UUIDMost", UUID.nameUUIDFromBytes(entry.getKey().getAttribute().getBytes()).getMostSignificantBits());
|
||||
|
||||
attributes.appendTag(attribute);
|
||||
}
|
||||
}
|
||||
|
||||
if(!attributes.hasNoTags())
|
||||
{
|
||||
return attributes;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag()
|
||||
{
|
||||
return "AttributeModifiers";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package exopandora.worldhandler.builder.component.impl;
|
||||
|
||||
import java.util.Map.Entry;
|
||||
import java.util.function.Function;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.builder.component.abstr.ComponentAttribute;
|
||||
import exopandora.worldhandler.builder.impl.abstr.EnumAttributes;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ComponentAttributeMob extends ComponentAttribute
|
||||
{
|
||||
public ComponentAttributeMob(Function<EnumAttributes, Boolean> applyable)
|
||||
{
|
||||
super(applyable);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public NBTBase serialize()
|
||||
{
|
||||
NBTTagList attributes = new NBTTagList();
|
||||
|
||||
for(Entry<EnumAttributes, Float> entry : this.attributes.entrySet())
|
||||
{
|
||||
if(this.applyable.apply(entry.getKey()) && entry.getValue() != 0)
|
||||
{
|
||||
NBTTagCompound attribute = new NBTTagCompound();
|
||||
|
||||
attribute.setString("Name", entry.getKey().getAttribute());
|
||||
attribute.setDouble("Base", entry.getKey().calculate(entry.getValue()));
|
||||
|
||||
attributes.appendTag(attribute);
|
||||
}
|
||||
}
|
||||
|
||||
if(!attributes.hasNoTags())
|
||||
{
|
||||
return attributes;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag()
|
||||
{
|
||||
return "Attributes";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package exopandora.worldhandler.builder.component.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.component.IBuilderComponent;
|
||||
import exopandora.worldhandler.format.text.ColoredString;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ComponentDisplay implements IBuilderComponent
|
||||
{
|
||||
private ColoredString name = new ColoredString();
|
||||
private String[] lore = new String[2];
|
||||
|
||||
@Override
|
||||
public NBTBase serialize()
|
||||
{
|
||||
NBTTagCompound display = new NBTTagCompound();
|
||||
|
||||
String name = this.name.getText();
|
||||
|
||||
if(name != null && !name.isEmpty())
|
||||
{
|
||||
display.setString("Name", this.name.toString());
|
||||
}
|
||||
|
||||
NBTTagList lore = new NBTTagList();
|
||||
|
||||
for(int x = 0; x < this.lore.length; x++)
|
||||
{
|
||||
if(this.lore[x] != null && !this.lore[x].isEmpty())
|
||||
{
|
||||
lore.appendTag(new NBTTagString(this.lore[x]));
|
||||
}
|
||||
}
|
||||
|
||||
if(!lore.hasNoTags())
|
||||
{
|
||||
display.setTag("Lore", lore);
|
||||
}
|
||||
|
||||
if(!display.hasNoTags())
|
||||
{
|
||||
return display;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setName(ColoredString name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public ColoredString getName()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setLore(String[] lore)
|
||||
{
|
||||
this.lore = lore;
|
||||
}
|
||||
|
||||
public String[] getLore()
|
||||
{
|
||||
return this.lore;
|
||||
}
|
||||
|
||||
public void setLore1(String lore)
|
||||
{
|
||||
this.lore[0] = lore;
|
||||
}
|
||||
|
||||
public String getLore1()
|
||||
{
|
||||
return this.lore[0];
|
||||
}
|
||||
|
||||
public void setLore2(String lore)
|
||||
{
|
||||
this.lore[1] = lore;
|
||||
}
|
||||
|
||||
public String getLore2()
|
||||
{
|
||||
return this.lore[1];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag()
|
||||
{
|
||||
return "display";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package exopandora.worldhandler.builder.component.impl;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.builder.component.IBuilderComponent;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ComponentEnchantment implements IBuilderComponent
|
||||
{
|
||||
private Map<Enchantment, Short> enchantments = Enchantment.REGISTRY.getKeys().stream().collect(Collectors.toMap(Enchantment.REGISTRY::getObject, key -> (short) 0));
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public NBTBase serialize()
|
||||
{
|
||||
NBTTagList enchantments = new NBTTagList();
|
||||
|
||||
for(Entry<Enchantment, Short> entry : this.enchantments.entrySet())
|
||||
{
|
||||
if(entry.getValue() > 0)
|
||||
{
|
||||
NBTTagCompound enchantment = new NBTTagCompound();
|
||||
|
||||
enchantment.setShort("id", (short) Enchantment.getEnchantmentID(entry.getKey()));
|
||||
enchantment.setShort("lvl", entry.getValue());
|
||||
|
||||
enchantments.appendTag(enchantment);
|
||||
}
|
||||
}
|
||||
|
||||
if(!enchantments.hasNoTags())
|
||||
{
|
||||
return enchantments;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setLevel(Enchantment enchantment, short level)
|
||||
{
|
||||
this.enchantments.put(enchantment, level);
|
||||
}
|
||||
|
||||
public int getLevel(Enchantment enchantment)
|
||||
{
|
||||
return this.enchantments.get(enchantment);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag()
|
||||
{
|
||||
return "ench";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package exopandora.worldhandler.builder.component.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.component.abstr.ComponentPotion;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ComponentPotionItem extends ComponentPotion
|
||||
{
|
||||
@Override
|
||||
public String getTag()
|
||||
{
|
||||
return "CustomPotionEffects";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package exopandora.worldhandler.builder.component.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.component.abstr.ComponentPotion;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ComponentPotionMob extends ComponentPotion
|
||||
{
|
||||
@Override
|
||||
public String getTag()
|
||||
{
|
||||
return "ActiveEffects";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,302 @@
|
||||
package exopandora.worldhandler.builder.component.impl;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import exopandora.worldhandler.builder.component.IBuilderComponent;
|
||||
import exopandora.worldhandler.helper.EntityHelper;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.EntityList;
|
||||
import net.minecraft.entity.boss.EntityDragon;
|
||||
import net.minecraft.entity.boss.EntityWither;
|
||||
import net.minecraft.entity.item.EntityMinecart;
|
||||
import net.minecraft.entity.item.EntityMinecartChest;
|
||||
import net.minecraft.entity.item.EntityMinecartCommandBlock;
|
||||
import net.minecraft.entity.item.EntityMinecartFurnace;
|
||||
import net.minecraft.entity.item.EntityMinecartHopper;
|
||||
import net.minecraft.entity.item.EntityMinecartMobSpawner;
|
||||
import net.minecraft.entity.item.EntityMinecartTNT;
|
||||
import net.minecraft.entity.monster.EntityEvoker;
|
||||
import net.minecraft.entity.monster.EntityGhast;
|
||||
import net.minecraft.entity.monster.EntityIronGolem;
|
||||
import net.minecraft.entity.monster.EntityMagmaCube;
|
||||
import net.minecraft.entity.monster.EntityPigZombie;
|
||||
import net.minecraft.entity.monster.EntitySkeleton;
|
||||
import net.minecraft.entity.monster.EntitySnowman;
|
||||
import net.minecraft.entity.monster.EntitySpider;
|
||||
import net.minecraft.entity.monster.EntityVindicator;
|
||||
import net.minecraft.entity.monster.EntityZombie;
|
||||
import net.minecraft.entity.passive.EntityChicken;
|
||||
import net.minecraft.entity.passive.EntityHorse;
|
||||
import net.minecraft.entity.passive.EntityMooshroom;
|
||||
import net.minecraft.entity.passive.EntityOcelot;
|
||||
import net.minecraft.entity.passive.EntitySquid;
|
||||
import net.minecraft.entity.passive.EntityVillager;
|
||||
import net.minecraft.entity.passive.EntityWolf;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagByte;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagInt;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ComponentSummon implements IBuilderComponent
|
||||
{
|
||||
private final Random random = new Random();
|
||||
|
||||
private String tag;
|
||||
private String name;
|
||||
private ResourceLocation entity;
|
||||
private boolean hasPassenger;
|
||||
|
||||
public void setEntity(ResourceLocation entityName)
|
||||
{
|
||||
this.entity = entityName;
|
||||
}
|
||||
|
||||
public ResourceLocation getEntity()
|
||||
{
|
||||
return this.entity;
|
||||
}
|
||||
|
||||
public void setHasPassenger(boolean hasPassenger)
|
||||
{
|
||||
this.hasPassenger = hasPassenger;
|
||||
}
|
||||
|
||||
public boolean hasPassenger()
|
||||
{
|
||||
return this.hasPassenger;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTBase serialize()
|
||||
{
|
||||
if(this.name != null)
|
||||
{
|
||||
if(this.name.equalsIgnoreCase("Cat"))
|
||||
{
|
||||
this.tag = "CatType";
|
||||
return new NBTTagInt(this.random.nextInt(3) + 1);
|
||||
}
|
||||
else if(this.name.equalsIgnoreCase("Farmer") || this.name.equalsIgnoreCase("Fisherman") || this.name.equalsIgnoreCase("Shepherd") || this.name.equalsIgnoreCase("Fletcher"))
|
||||
{
|
||||
this.tag = "Profession";
|
||||
return new NBTTagInt(0);
|
||||
}
|
||||
else if(this.name.equalsIgnoreCase("Librarian") || this.name.equalsIgnoreCase("Carthographer"))
|
||||
{
|
||||
this.tag = "Profession";
|
||||
return new NBTTagInt(1);
|
||||
}
|
||||
else if(this.name.equalsIgnoreCase("Cleric") || this.name.equalsIgnoreCase("Priest"))
|
||||
{
|
||||
this.tag = "Profession";
|
||||
return new NBTTagInt(2);
|
||||
}
|
||||
else if(this.name.equalsIgnoreCase("Armorer") || this.name.equalsIgnoreCase("Blacksmith") || this.name.equalsIgnoreCase("WeaponSmith") || this.name.equalsIgnoreCase("ToolSmith"))
|
||||
{
|
||||
this.tag = "Profession";
|
||||
return new NBTTagInt(3);
|
||||
}
|
||||
else if(this.name.equalsIgnoreCase("Butcher") || this.name.equalsIgnoreCase("Leatherworker"))
|
||||
{
|
||||
this.tag = "Profession";
|
||||
return new NBTTagInt(4);
|
||||
}
|
||||
else if(this.name.equalsIgnoreCase("Nitwit"))
|
||||
{
|
||||
this.tag = "Profession";
|
||||
return new NBTTagInt(5);
|
||||
}
|
||||
|
||||
if(this.entity != null)
|
||||
{
|
||||
if(this.entity.equals(EntityHelper.getResourceLocation(EntityZombie.class)))
|
||||
{
|
||||
if(StringUtils.containsIgnoreCase(this.name, "Baby"))
|
||||
{
|
||||
this.tag = "IsBaby";
|
||||
return new NBTTagByte((byte) 1);
|
||||
}
|
||||
}
|
||||
else if(this.entity.equals(EntityHelper.getResourceLocation(EntityChicken.class)))
|
||||
{
|
||||
if(StringUtils.containsIgnoreCase(this.name, "Jockey") && !this.hasPassenger)
|
||||
{
|
||||
NBTTagCompound passenger = new NBTTagCompound();
|
||||
NBTTagList list = new NBTTagList();
|
||||
|
||||
passenger.setString("id", EntityHelper.getResourceLocation(EntityZombie.class).toString());
|
||||
passenger.setBoolean("IsBaby", true);
|
||||
list.appendTag(passenger);
|
||||
|
||||
this.tag = "Passengers";
|
||||
return list;
|
||||
}
|
||||
}
|
||||
else if(this.entity.equals(EntityHelper.getResourceLocation(EntitySpider.class)))
|
||||
{
|
||||
if(StringUtils.containsIgnoreCase(this.name, "Jockey") && !this.hasPassenger)
|
||||
{
|
||||
NBTTagCompound passenger = new NBTTagCompound();
|
||||
NBTTagList list = new NBTTagList();
|
||||
|
||||
passenger.setString("id", EntityHelper.getResourceLocation(EntitySkeleton.class).toString());
|
||||
list.appendTag(passenger);
|
||||
|
||||
this.tag = "Passengers";
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag()
|
||||
{
|
||||
return this.tag;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static ResourceLocation resolve(String entityName)
|
||||
{
|
||||
String entity = entityName.replaceAll("_| ", "");
|
||||
|
||||
for(ResourceLocation location : EntityList.ENTITY_EGGS.keySet())
|
||||
{
|
||||
if(entityName.equalsIgnoreCase(I18n.format("entity." + EntityHelper.getEntityName(location) + ".name")))
|
||||
{
|
||||
entity = location.getResourcePath();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(entity.equalsIgnoreCase("RedCow"))
|
||||
{
|
||||
return EntityHelper.getResourceLocation(EntityMooshroom.class);
|
||||
}
|
||||
else if(entity.equalsIgnoreCase("ChickenJockey"))
|
||||
{
|
||||
return EntityHelper.getResourceLocation(EntityChicken.class);
|
||||
}
|
||||
else if(entity.equalsIgnoreCase("Pigman") || entity.equalsIgnoreCase("ZombiePig") || entity.equalsIgnoreCase("ZombiePigman"))
|
||||
{
|
||||
return EntityHelper.getResourceLocation(EntityPigZombie.class);
|
||||
}
|
||||
else if(entity.equalsIgnoreCase("Wither"))
|
||||
{
|
||||
return EntityHelper.getResourceLocation(EntityWither.class);
|
||||
}
|
||||
else if(entity.equalsIgnoreCase("Dog"))
|
||||
{
|
||||
return EntityHelper.getResourceLocation(EntityWolf.class);
|
||||
}
|
||||
else if(entity.equalsIgnoreCase("Dragon"))
|
||||
{
|
||||
return EntityHelper.getResourceLocation(EntityDragon.class);
|
||||
}
|
||||
else if(entity.equalsIgnoreCase("minecraft:SnowGolem"))
|
||||
{
|
||||
return EntityHelper.getResourceLocation(EntitySnowman.class);
|
||||
}
|
||||
else if(entity.equalsIgnoreCase("Horse") || entity.equalsIgnoreCase("ZombieHorse") || entity.equalsIgnoreCase("SkeletonHorse"))
|
||||
{
|
||||
return EntityHelper.getResourceLocation(EntityHorse.class);
|
||||
}
|
||||
else if(entity.equalsIgnoreCase("LavaCube")|| entity.equalsIgnoreCase("MagmaSlime") || entity.equalsIgnoreCase("MagmaCube"))
|
||||
{
|
||||
return EntityHelper.getResourceLocation(EntityMagmaCube.class);
|
||||
}
|
||||
else if(entity.equalsIgnoreCase("SpiderJockey"))
|
||||
{
|
||||
return EntityHelper.getResourceLocation(EntitySpider.class);
|
||||
}
|
||||
else if(entity.equalsIgnoreCase("IronGolem"))
|
||||
{
|
||||
return EntityHelper.getResourceLocation(EntityIronGolem.class);
|
||||
}
|
||||
else if(entity.equalsIgnoreCase("Ozelot") || entity.equals("Ocelot") || entity.equalsIgnoreCase("Cat") || entity.equalsIgnoreCase("Kitty") || entity.equalsIgnoreCase("Kitten"))
|
||||
{
|
||||
return EntityHelper.getResourceLocation(EntityOcelot.class);
|
||||
}
|
||||
else if(entity.equalsIgnoreCase("TESTIFICATE") || entity.equalsIgnoreCase("Blacksmith") || entity.equalsIgnoreCase("Farmer") || entity.equalsIgnoreCase("Fisherman") || entity.equalsIgnoreCase("Shepherd") || entity.equalsIgnoreCase("Fletcher") || entity.equalsIgnoreCase("Librarian") || entity.equalsIgnoreCase("Cleric") || entity.equalsIgnoreCase("Priest") || entity.equalsIgnoreCase("Armorer") || entity.equalsIgnoreCase("WeaponSmith") || entity.equalsIgnoreCase("ToolSmith") || entity.equalsIgnoreCase("Butcher") || entity.equalsIgnoreCase("Leatherworker") || entity.equalsIgnoreCase("Carthographer") || entity.equalsIgnoreCase("Nitwit"))
|
||||
{
|
||||
return EntityHelper.getResourceLocation(EntityVillager.class);
|
||||
}
|
||||
else if(entity.equalsIgnoreCase("Octopus") || entity.equalsIgnoreCase("Kraken"))
|
||||
{
|
||||
return EntityHelper.getResourceLocation(EntitySquid.class);
|
||||
}
|
||||
else if(entity.equalsIgnoreCase("Exwife"))
|
||||
{
|
||||
return EntityHelper.getResourceLocation(EntityGhast.class);
|
||||
}
|
||||
else if(entity.equalsIgnoreCase("TNTMinecart"))
|
||||
{
|
||||
return EntityHelper.getResourceLocation(EntityMinecartTNT.class);
|
||||
}
|
||||
else if(entity.equalsIgnoreCase("Minecart"))
|
||||
{
|
||||
return EntityHelper.getResourceLocation(EntityMinecart.class);
|
||||
}
|
||||
else if(entity.equalsIgnoreCase("HopperMinecart"))
|
||||
{
|
||||
return EntityHelper.getResourceLocation(EntityMinecartHopper.class);
|
||||
}
|
||||
else if(entity.equalsIgnoreCase("ChestMinecart"))
|
||||
{
|
||||
return EntityHelper.getResourceLocation(EntityMinecartChest.class);
|
||||
}
|
||||
else if(entity.equalsIgnoreCase("SpawnerMinecart"))
|
||||
{
|
||||
return EntityHelper.getResourceLocation(EntityMinecartMobSpawner.class);
|
||||
}
|
||||
else if(entity.equalsIgnoreCase("FurnaceMinecart"))
|
||||
{
|
||||
return EntityHelper.getResourceLocation(EntityMinecartFurnace.class);
|
||||
}
|
||||
else if(entity.equalsIgnoreCase("CommandBlockMinecart") || entity.equalsIgnoreCase("MinecartCommand") || entity.equalsIgnoreCase("CommandMinecart"))
|
||||
{
|
||||
return EntityHelper.getResourceLocation(EntityMinecartCommandBlock.class);
|
||||
}
|
||||
else if(entity.equalsIgnoreCase("Wizard"))
|
||||
{
|
||||
return EntityHelper.getResourceLocation(EntityEvoker.class);
|
||||
}
|
||||
else if(entity.equalsIgnoreCase("Johnny"))
|
||||
{
|
||||
return EntityHelper.getResourceLocation(EntityVindicator.class);
|
||||
}
|
||||
else if(entity.equalsIgnoreCase("BabyZombie"))
|
||||
{
|
||||
return EntityHelper.getResourceLocation(EntityZombie.class);
|
||||
}
|
||||
|
||||
if(entity == null || entity.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new ResourceLocation(entity);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
package exopandora.worldhandler.builder.component.impl;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.builder.component.IBuilderComponent;
|
||||
import exopandora.worldhandler.main.WorldHandler;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagByte;
|
||||
import net.minecraft.nbt.NBTTagByteArray;
|
||||
import net.minecraft.nbt.NBTTagDouble;
|
||||
import net.minecraft.nbt.NBTTagFloat;
|
||||
import net.minecraft.nbt.NBTTagInt;
|
||||
import net.minecraft.nbt.NBTTagIntArray;
|
||||
import net.minecraft.nbt.NBTTagLong;
|
||||
import net.minecraft.nbt.NBTTagLongArray;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ComponentTag<T> implements IBuilderComponent
|
||||
{
|
||||
private final Function<T, NBTBase> serializer;
|
||||
private final String tag;
|
||||
private T value;
|
||||
|
||||
public ComponentTag(String tag, T value, Function<T, NBTBase> serializer)
|
||||
{
|
||||
this.tag = tag;
|
||||
this.value = value;
|
||||
this.serializer = serializer;
|
||||
}
|
||||
|
||||
public ComponentTag(String tag, Function<T, NBTBase> serializer)
|
||||
{
|
||||
this(tag, null, serializer);
|
||||
}
|
||||
|
||||
public ComponentTag(String tag, T value)
|
||||
{
|
||||
this(tag, value, null);
|
||||
}
|
||||
|
||||
public ComponentTag(String tag)
|
||||
{
|
||||
this(tag, null, null);
|
||||
}
|
||||
|
||||
public void setValue(T value)
|
||||
{
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public T getValue()
|
||||
{
|
||||
return this.value;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public NBTBase serialize()
|
||||
{
|
||||
if(this.value != null)
|
||||
{
|
||||
if(this.serializer != null)
|
||||
{
|
||||
return this.serializer.apply(this.value);
|
||||
}
|
||||
else if(this.value instanceof String)
|
||||
{
|
||||
String string = (String) this.value;
|
||||
|
||||
if(string.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new NBTTagString(string);
|
||||
}
|
||||
else if(this.value instanceof NBTBase)
|
||||
{
|
||||
NBTBase base = (NBTBase) this.value;
|
||||
|
||||
if(base.hasNoTags())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return (NBTBase) this.value;
|
||||
}
|
||||
else if(this.value instanceof Integer)
|
||||
{
|
||||
return new NBTTagInt((Integer) this.value);
|
||||
}
|
||||
else if(this.value instanceof Byte)
|
||||
{
|
||||
return new NBTTagByte((Byte) this.value);
|
||||
}
|
||||
else if(this.value instanceof Float)
|
||||
{
|
||||
return new NBTTagFloat((Float) this.value);
|
||||
}
|
||||
else if(this.value instanceof Double)
|
||||
{
|
||||
return new NBTTagDouble((Double) this.value);
|
||||
}
|
||||
else if(this.value instanceof Long)
|
||||
{
|
||||
return new NBTTagLong((Long) this.value);
|
||||
}
|
||||
else if(this.value instanceof Short)
|
||||
{
|
||||
return new NBTTagLong((Short) this.value);
|
||||
}
|
||||
else if(this.value instanceof Byte[])
|
||||
{
|
||||
return new NBTTagByteArray((byte[]) this.value);
|
||||
}
|
||||
else if(this.value instanceof Integer[])
|
||||
{
|
||||
return new NBTTagIntArray((int[]) this.value);
|
||||
}
|
||||
else if(this.value instanceof Long[])
|
||||
{
|
||||
return new NBTTagLongArray((long[]) this.value);
|
||||
}
|
||||
else
|
||||
{
|
||||
WorldHandler.LOGGER.warn("Tag \"" + this.tag + "\" has no serializer");
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag()
|
||||
{
|
||||
return this.tag;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.Syntax;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
import exopandora.worldhandler.helper.EnumHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BuilderAdvancement extends CommandBuilder
|
||||
{
|
||||
public BuilderAdvancement(EnumMode mode)
|
||||
{
|
||||
this.setMode(mode);
|
||||
}
|
||||
|
||||
public BuilderAdvancement(EnumActionType action, String player, EnumMode mode, ResourceLocation advancement)
|
||||
{
|
||||
this(mode);
|
||||
this.setActionType(action);
|
||||
this.setPlayer(player);
|
||||
this.setAdvancement(advancement);
|
||||
}
|
||||
|
||||
public void setActionType(EnumActionType action)
|
||||
{
|
||||
this.setNode(0, action != null ? action.toString() : null);
|
||||
}
|
||||
|
||||
public EnumActionType getActionType()
|
||||
{
|
||||
return EnumHelper.valueOf(EnumActionType.class, this.getNodeAsString(1));
|
||||
}
|
||||
|
||||
public void setPlayer(String player)
|
||||
{
|
||||
this.setNode(1, player);
|
||||
}
|
||||
|
||||
public String getPlayer()
|
||||
{
|
||||
return this.getNodeAsString(1);
|
||||
}
|
||||
|
||||
public void setMode(EnumMode mode)
|
||||
{
|
||||
this.setNode(2, mode != null ? mode.toString() : null);
|
||||
}
|
||||
|
||||
public EnumMode getMode()
|
||||
{
|
||||
return EnumHelper.valueOf(EnumMode.class, this.getNodeAsString(2));
|
||||
}
|
||||
|
||||
public void setAdvancement(ResourceLocation advancement)
|
||||
{
|
||||
this.setNode(3, advancement);
|
||||
}
|
||||
|
||||
public ResourceLocation getAdvancement()
|
||||
{
|
||||
return this.getNodeAsResourceLocation(3);
|
||||
}
|
||||
|
||||
public BuilderAdvancement getBuilderForAction(EnumActionType action)
|
||||
{
|
||||
return this.getBuilder(action, this.getMode());
|
||||
}
|
||||
|
||||
public BuilderAdvancement getBuilder(EnumActionType action, EnumMode mode)
|
||||
{
|
||||
return new BuilderAdvancement(action, this.getPlayer(), mode, (mode != null && !mode.equals(EnumMode.EVERYTHING)) ? this.getAdvancement() : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "advancement";
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Syntax getSyntax()
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("grant|revoke|test", Type.STRING);
|
||||
syntax.addRequired("player", Type.STRING);
|
||||
syntax.addRequired("only|until|from|through|everything", Type.STRING);
|
||||
syntax.addOptional("advancement", Type.RESOURCE_LOCATION);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
|
||||
public static enum EnumActionType
|
||||
{
|
||||
GRANT,
|
||||
REVOKE;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
|
||||
public static enum EnumMode
|
||||
{
|
||||
ONLY,
|
||||
UNTIL,
|
||||
FROM,
|
||||
THROUGH,
|
||||
EVERYTHING;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.Syntax;
|
||||
import exopandora.worldhandler.builder.impl.abstr.BuilderBlockPos;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BuilderBlockdata extends BuilderBlockPos
|
||||
{
|
||||
@Override
|
||||
public void setNBT(NBTTagCompound nbt)
|
||||
{
|
||||
this.setNode(3, nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "blockdata";
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Syntax getSyntax()
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("x", Type.COORDINATE);
|
||||
syntax.addRequired("y", Type.COORDINATE);
|
||||
syntax.addRequired("z", Type.COORDINATE);
|
||||
syntax.addRequired("nbt", Type.NBT);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.Syntax;
|
||||
import exopandora.worldhandler.builder.types.TargetSelector;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BuilderButcher extends CommandBuilder
|
||||
{
|
||||
private final TargetSelector targetSelector;
|
||||
|
||||
public BuilderButcher()
|
||||
{
|
||||
this(new ResourceLocation("<entity_name>"), 0);
|
||||
}
|
||||
|
||||
public BuilderButcher(ResourceLocation entity, int radius)
|
||||
{
|
||||
this.targetSelector = new TargetSelector();
|
||||
this.setEntity(entity);
|
||||
this.setRadius(radius);
|
||||
}
|
||||
|
||||
public void setRadius(int radius)
|
||||
{
|
||||
this.targetSelector.set("r", radius);
|
||||
this.setNode(0, this.targetSelector);
|
||||
}
|
||||
|
||||
public int getRadius()
|
||||
{
|
||||
return this.targetSelector.<Integer>get("r");
|
||||
}
|
||||
|
||||
public void setEntity(ResourceLocation entity)
|
||||
{
|
||||
this.targetSelector.set("type", entity.toString());
|
||||
this.setNode(0, this.targetSelector);
|
||||
}
|
||||
|
||||
public ResourceLocation getEntity()
|
||||
{
|
||||
return this.targetSelector.<ResourceLocation>get("type");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "kill";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Syntax getSyntax()
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("entity_name", Type.TARGET_SELECTOR);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.Syntax;
|
||||
import exopandora.worldhandler.builder.impl.abstr.BuilderDoubleBlockPos;
|
||||
import exopandora.worldhandler.builder.types.Coordinate;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
import exopandora.worldhandler.helper.EnumHelper;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BuilderClone extends BuilderDoubleBlockPos
|
||||
{
|
||||
public BuilderClone()
|
||||
{
|
||||
this.setX(new Coordinate());
|
||||
this.setY(new Coordinate());
|
||||
this.setZ(new Coordinate());
|
||||
this.setMask(EnumMask.values()[0]);
|
||||
this.setNode(10, "force");
|
||||
}
|
||||
|
||||
public void setPosition(BlockPos pos)
|
||||
{
|
||||
this.setX(pos.getX());
|
||||
this.setY(pos.getY());
|
||||
this.setZ(pos.getZ());
|
||||
}
|
||||
|
||||
public void setX(float x)
|
||||
{
|
||||
this.setX(new Coordinate(x));
|
||||
}
|
||||
|
||||
public void setY(float y)
|
||||
{
|
||||
this.setY(new Coordinate(y));
|
||||
}
|
||||
|
||||
public void setZ(float z)
|
||||
{
|
||||
this.setZ(new Coordinate(z));
|
||||
}
|
||||
|
||||
public void setX(Coordinate x)
|
||||
{
|
||||
this.setNode(6, x);
|
||||
}
|
||||
|
||||
public void setY(Coordinate y)
|
||||
{
|
||||
this.setNode(7, y);
|
||||
}
|
||||
|
||||
public void setZ(Coordinate z)
|
||||
{
|
||||
this.setNode(8, z);
|
||||
}
|
||||
|
||||
public Coordinate getXCoordiante()
|
||||
{
|
||||
return this.getNodeAsCoordinate(6);
|
||||
}
|
||||
|
||||
public Coordinate getYCoordiante()
|
||||
{
|
||||
return this.getNodeAsCoordinate(7);
|
||||
}
|
||||
|
||||
public Coordinate getZCoordiante()
|
||||
{
|
||||
return this.getNodeAsCoordinate(8);
|
||||
}
|
||||
|
||||
public double getX()
|
||||
{
|
||||
return this.getXCoordiante().getValue();
|
||||
}
|
||||
|
||||
public double getY()
|
||||
{
|
||||
return this.getYCoordiante().getValue();
|
||||
}
|
||||
|
||||
public double getZ()
|
||||
{
|
||||
return this.getZCoordiante().getValue();
|
||||
}
|
||||
|
||||
public BlockPos getBlockPos()
|
||||
{
|
||||
return new BlockPos(this.getX(), this.getY(), this.getZ());
|
||||
}
|
||||
|
||||
public void setMask(EnumMask mask)
|
||||
{
|
||||
this.setNode(9, mask != null ? mask.toString() : null);
|
||||
}
|
||||
|
||||
public EnumMask getMask()
|
||||
{
|
||||
return EnumHelper.valueOf(EnumMask.class, this.getNodeAsString(9));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "clone";
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Syntax getSyntax()
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("x1", Type.COORDINATE);
|
||||
syntax.addRequired("y1", Type.COORDINATE);
|
||||
syntax.addRequired("z1", Type.COORDINATE);
|
||||
syntax.addRequired("x2", Type.COORDINATE);
|
||||
syntax.addRequired("y2", Type.COORDINATE);
|
||||
syntax.addRequired("z2", Type.COORDINATE);
|
||||
syntax.addRequired("x", Type.COORDINATE);
|
||||
syntax.addRequired("y", Type.COORDINATE);
|
||||
syntax.addRequired("z", Type.COORDINATE);
|
||||
syntax.addOptional("mask_mode", Type.STRING);
|
||||
syntax.addOptional("clone_mode", Type.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
|
||||
public static enum EnumMask
|
||||
{
|
||||
REPLACE,
|
||||
MASKED,
|
||||
FILTERED;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.component.impl.ComponentAttributeItem;
|
||||
import exopandora.worldhandler.builder.component.impl.ComponentDisplay;
|
||||
import exopandora.worldhandler.builder.component.impl.ComponentEnchantment;
|
||||
import exopandora.worldhandler.builder.impl.abstr.EnumAttributes;
|
||||
import exopandora.worldhandler.builder.impl.abstr.EnumAttributes.Applyable;
|
||||
import exopandora.worldhandler.format.text.ColoredString;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BuilderCustomItem extends BuilderGive
|
||||
{
|
||||
private final ComponentAttributeItem attribute;
|
||||
private final ComponentDisplay display;
|
||||
private final ComponentEnchantment enchantment;
|
||||
|
||||
public BuilderCustomItem()
|
||||
{
|
||||
this(null, null);
|
||||
}
|
||||
|
||||
public BuilderCustomItem(String username, ResourceLocation item)
|
||||
{
|
||||
this.setPlayer(username);
|
||||
this.setItem(item);
|
||||
this.setAmount(1);
|
||||
this.setMetadata(0);
|
||||
this.attribute = this.registerNBTComponent(new ComponentAttributeItem(attribute -> attribute.getApplyable().equals(Applyable.BOTH) || attribute.getApplyable().equals(Applyable.PLAYER)));
|
||||
this.display = this.registerNBTComponent(new ComponentDisplay());
|
||||
this.enchantment = this.registerNBTComponent(new ComponentEnchantment());
|
||||
}
|
||||
|
||||
public void setEnchantment(Enchantment enchantment, short level)
|
||||
{
|
||||
this.enchantment.setLevel(enchantment, level);
|
||||
}
|
||||
|
||||
public void setAttribute(EnumAttributes attribute, float ammount)
|
||||
{
|
||||
this.attribute.set(attribute, ammount);
|
||||
}
|
||||
|
||||
public void removeAttribute(EnumAttributes attribute)
|
||||
{
|
||||
this.attribute.remove(attribute);
|
||||
}
|
||||
|
||||
public void setName(ColoredString name)
|
||||
{
|
||||
this.display.setName(name);
|
||||
}
|
||||
|
||||
public ColoredString getName()
|
||||
{
|
||||
return this.display.getName();
|
||||
}
|
||||
|
||||
public void setLore1(String lore)
|
||||
{
|
||||
this.display.setLore1(lore);
|
||||
}
|
||||
|
||||
public String getLore1()
|
||||
{
|
||||
return this.display.getLore1();
|
||||
}
|
||||
|
||||
public void setLore2(String lore)
|
||||
{
|
||||
this.display.setLore2(lore);
|
||||
}
|
||||
|
||||
public String getLore2()
|
||||
{
|
||||
return this.display.getLore2();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.Syntax;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
|
||||
public class BuilderDifficulty extends CommandBuilder
|
||||
{
|
||||
public BuilderDifficulty()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public BuilderDifficulty(EnumDifficulty difficulty)
|
||||
{
|
||||
this.setDifficulty(difficulty);
|
||||
}
|
||||
|
||||
public void setDifficulty(EnumDifficulty difficulty)
|
||||
{
|
||||
this.setNode(0, difficulty.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "difficulty";
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Syntax getSyntax()
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("peaceful|easy|normal|hard", Type.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
|
||||
public static enum EnumDifficulty
|
||||
{
|
||||
PEACEFUL,
|
||||
EASY,
|
||||
NORMAL,
|
||||
HARD;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.Syntax;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BuilderEnchantment extends CommandBuilder
|
||||
{
|
||||
public void getPlayer(String player)
|
||||
{
|
||||
this.getNodeAsString(0);
|
||||
}
|
||||
|
||||
public void setPlayer(String player)
|
||||
{
|
||||
this.setNode(0, player);
|
||||
}
|
||||
|
||||
public ResourceLocation getEnchantment()
|
||||
{
|
||||
return this.getNodeAsResourceLocation(1);
|
||||
}
|
||||
|
||||
public void setEnchantment(ResourceLocation enchantment)
|
||||
{
|
||||
this.setNode(1, enchantment);
|
||||
}
|
||||
|
||||
public void setLevel(int level)
|
||||
{
|
||||
this.setNode(2, level);
|
||||
}
|
||||
|
||||
public int getLevel()
|
||||
{
|
||||
return this.getNodeAsInt(2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "enchant";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Syntax getSyntax()
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("player", Type.STRING);
|
||||
syntax.addRequired("enchantment", Type.RESOURCE_LOCATION);
|
||||
syntax.addOptional("level", Type.INT, 1);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.Syntax;
|
||||
import exopandora.worldhandler.builder.types.Level;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BuilderExperience extends CommandBuilder
|
||||
{
|
||||
public BuilderExperience()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public BuilderExperience(int level, String player)
|
||||
{
|
||||
this.setLevel(level);
|
||||
this.setPlayer(player);
|
||||
}
|
||||
|
||||
public void setLevel(int level)
|
||||
{
|
||||
this.setNode(0, new Level(level));
|
||||
}
|
||||
|
||||
public int getLevel()
|
||||
{
|
||||
Level level = this.getNodeAsLevel(0);
|
||||
|
||||
if(level != null)
|
||||
{
|
||||
return level.getLevel();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setPlayer(String player)
|
||||
{
|
||||
this.setNode(1, player);
|
||||
}
|
||||
|
||||
public String getPlayer()
|
||||
{
|
||||
return this.getNodeAsString(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "xp";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Syntax getSyntax()
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("amount", Type.LEVEL, new Level(0));
|
||||
syntax.addOptional("player", Type.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.builder.Syntax;
|
||||
import exopandora.worldhandler.builder.impl.abstr.BuilderDoubleBlockPos;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
import exopandora.worldhandler.helper.BlockHelper;
|
||||
import exopandora.worldhandler.helper.EnumHelper;
|
||||
import exopandora.worldhandler.helper.ResourceHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BuilderFill extends BuilderDoubleBlockPos
|
||||
{
|
||||
public BuilderFill(ResourceLocation block1, EnumBlockHandling handling, ResourceLocation block2)
|
||||
{
|
||||
this.setPosition1(BlockHelper.getPos1());
|
||||
this.setPosition2(BlockHelper.getPos2());
|
||||
this.setBlock1(block1);
|
||||
this.setMeta1(0);
|
||||
this.setBlockHandling(handling);
|
||||
this.setBlock2(block2);
|
||||
}
|
||||
|
||||
public BuilderFill()
|
||||
{
|
||||
this.init();
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
this.setMeta1(0);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setMeta1(int meta)
|
||||
{
|
||||
this.setNode(7, meta);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setMeta2(int meta)
|
||||
{
|
||||
this.setNode(10, meta);
|
||||
}
|
||||
|
||||
public void setBlock1(String block)
|
||||
{
|
||||
this.setBlock1(ResourceHelper.stringToResourceLocationNullable(block, ResourceHelper::isRegisteredBlock));
|
||||
}
|
||||
|
||||
public void setBlock1(ResourceLocation location)
|
||||
{
|
||||
this.setNode(6, location);
|
||||
}
|
||||
|
||||
public ResourceLocation getBlock1()
|
||||
{
|
||||
return this.getNodeAsResourceLocation(6);
|
||||
}
|
||||
|
||||
public String getBlock1String()
|
||||
{
|
||||
ResourceLocation location = this.getBlock1();
|
||||
|
||||
if(location != null)
|
||||
{
|
||||
return location.toString();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setBlockHandling(EnumBlockHandling blockHandling)
|
||||
{
|
||||
this.setNode(8, blockHandling != null ? blockHandling.toString() : null);
|
||||
}
|
||||
|
||||
public void setBlock2(String block)
|
||||
{
|
||||
this.setBlock2(ResourceHelper.stringToResourceLocationNullable(block, ResourceHelper::isRegisteredBlock));
|
||||
}
|
||||
|
||||
public void setBlock2(ResourceLocation location)
|
||||
{
|
||||
this.setNode(9, location);
|
||||
}
|
||||
|
||||
public String getBlock2String()
|
||||
{
|
||||
ResourceLocation location = this.getBlock2();
|
||||
|
||||
if(location != null)
|
||||
{
|
||||
return location.toString();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public ResourceLocation getBlock2()
|
||||
{
|
||||
return this.getNodeAsResourceLocation(9);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public EnumBlockHandling getBlockHandling()
|
||||
{
|
||||
return EnumHelper.valueOf(EnumBlockHandling.class, this.getNodeAsString(8));
|
||||
}
|
||||
|
||||
public BuilderFill getBuilderForFill()
|
||||
{
|
||||
return new BuilderFill(this.getBlock1(), null, null);
|
||||
}
|
||||
|
||||
public BuilderFill getBuilderForReplace()
|
||||
{
|
||||
return new BuilderFill(this.getBlock2(), EnumBlockHandling.REPLACE, this.getBlock1());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "fill";
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Syntax getSyntax()
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("x1", Type.COORDINATE);
|
||||
syntax.addRequired("y1", Type.COORDINATE);
|
||||
syntax.addRequired("z1", Type.COORDINATE);
|
||||
syntax.addRequired("x2", Type.COORDINATE);
|
||||
syntax.addRequired("y2", Type.COORDINATE);
|
||||
syntax.addRequired("z2", Type.COORDINATE);
|
||||
syntax.addRequired("block", Type.RESOURCE_LOCATION);
|
||||
syntax.addOptional("data_value", Type.INT);
|
||||
syntax.addOptional("old_block_handling", Type.STRING);
|
||||
syntax.addOptional("block_2|nbt", Type.RESOURCE_LOCATION, "block_2|nbt");
|
||||
syntax.addOptional("data_value", Type.INT, "data_value");
|
||||
|
||||
return syntax;
|
||||
}
|
||||
|
||||
public static enum EnumBlockHandling
|
||||
{
|
||||
REPLACE,
|
||||
DESTROY,
|
||||
KEEP,
|
||||
HOLLOW,
|
||||
OUTLINE;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.Syntax;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
|
||||
public class BuilderGamemode extends CommandBuilder
|
||||
{
|
||||
public BuilderGamemode()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public BuilderGamemode(EnumGamemode mode)
|
||||
{
|
||||
this.setMode(mode);
|
||||
}
|
||||
|
||||
public BuilderGamemode(EnumGamemode mode, String player)
|
||||
{
|
||||
this(mode);
|
||||
this.setPlayer(player);
|
||||
}
|
||||
|
||||
public void setMode(EnumGamemode mode)
|
||||
{
|
||||
this.setNode(0, mode.toString());
|
||||
}
|
||||
|
||||
public void setPlayer(String player)
|
||||
{
|
||||
this.setNode(1, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "gamemode";
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Syntax getSyntax()
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("mode", Type.STRING);
|
||||
syntax.addOptional("player", Type.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
|
||||
public static enum EnumGamemode
|
||||
{
|
||||
SURVIVAL,
|
||||
CREATIVE,
|
||||
ADVENTURE,
|
||||
SPECTATOR;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.Syntax;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BuilderGamerule extends CommandBuilder
|
||||
{
|
||||
public BuilderGamerule()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public BuilderGamerule(String rule, String value)
|
||||
{
|
||||
this.setRule(rule);
|
||||
this.setValue(value);
|
||||
}
|
||||
|
||||
public void setRule(String rule)
|
||||
{
|
||||
this.setNode(0, rule);
|
||||
}
|
||||
|
||||
public String getRule()
|
||||
{
|
||||
return this.getNodeAsString(0);
|
||||
}
|
||||
|
||||
public void setValue(String value)
|
||||
{
|
||||
this.setNode(1, value);
|
||||
}
|
||||
|
||||
public String getValue()
|
||||
{
|
||||
return this.getNodeAsString(1);
|
||||
}
|
||||
|
||||
public BuilderGamerule getBuilderForValue(String value)
|
||||
{
|
||||
return new BuilderGamerule(this.getRule(), value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "gamerule";
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Syntax getSyntax()
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addOptional("rule", Type.STRING);
|
||||
syntax.addOptional("true|false|value", Type.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BuilderGeneric implements ICommandBuilder
|
||||
{
|
||||
private final String command;
|
||||
private final String[] arguments;
|
||||
|
||||
public BuilderGeneric(String command, String... arguments)
|
||||
{
|
||||
this.command = command;
|
||||
this.arguments = arguments;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toCommand()
|
||||
{
|
||||
return "/" + this.command + " " + String.join(" ", this.arguments);
|
||||
}
|
||||
|
||||
public String toActualCommand()
|
||||
{
|
||||
return this.toCommand();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilderNBT;
|
||||
import exopandora.worldhandler.builder.Syntax;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
import exopandora.worldhandler.helper.ResourceHelper;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BuilderGive extends CommandBuilderNBT
|
||||
{
|
||||
public BuilderGive(String player, ResourceLocation item)
|
||||
{
|
||||
this.setPlayer(player);
|
||||
this.setItem(item);
|
||||
this.setMetadata(0);
|
||||
}
|
||||
|
||||
public BuilderGive()
|
||||
{
|
||||
this(null, null);
|
||||
}
|
||||
|
||||
public void setPlayer(String username)
|
||||
{
|
||||
this.setNode(0, username);
|
||||
}
|
||||
|
||||
public String getPlayer()
|
||||
{
|
||||
return this.getNodeAsString(0);
|
||||
}
|
||||
|
||||
public void setItem(String item)
|
||||
{
|
||||
this.setItem(ResourceHelper.stringToResourceLocationNullable(item, ResourceHelper::isRegisteredItem));
|
||||
}
|
||||
|
||||
public void setItem(ResourceLocation item)
|
||||
{
|
||||
this.setNode(1, item);
|
||||
}
|
||||
|
||||
public ResourceLocation getItem()
|
||||
{
|
||||
return this.getNodeAsResourceLocation(1);
|
||||
}
|
||||
|
||||
public void setAmount(int ammount)
|
||||
{
|
||||
this.setNode(2, ammount);
|
||||
}
|
||||
|
||||
public int getAmount()
|
||||
{
|
||||
return this.getNodeAsInt(2);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setMetadata(int metadata)
|
||||
{
|
||||
this.setNode(3, metadata);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public int getMetadata()
|
||||
{
|
||||
return this.getNodeAsInt(3);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNBT(NBTTagCompound nbt)
|
||||
{
|
||||
this.setNode(4, nbt);
|
||||
}
|
||||
|
||||
public NBTTagCompound getNBT()
|
||||
{
|
||||
return this.getNodeAsNBT(4);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "give";
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Syntax getSyntax()
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("player", Type.STRING);
|
||||
syntax.addRequired("item", Type.RESOURCE_LOCATION);
|
||||
syntax.addRequired("amount", Type.INT);
|
||||
syntax.addRequired("data_value", Type.INT);
|
||||
syntax.addOptional("nbt", Type.NBT);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import exopandora.worldhandler.builder.ICommandBuilder;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BuilderMultiCommand implements ICommandBuilder
|
||||
{
|
||||
private final ICommandBuilder[] builders;
|
||||
|
||||
public BuilderMultiCommand(ICommandBuilder... builder)
|
||||
{
|
||||
this.builders = builder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toCommand()
|
||||
{
|
||||
return String.join(" | ", Arrays.stream(this.builders).map(ICommandBuilder::toCommand).toArray(String[]::new));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.component.impl.ComponentTag;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BuilderNoteEditor extends BuilderBlockdata
|
||||
{
|
||||
private final ComponentTag<Byte> note;
|
||||
|
||||
public BuilderNoteEditor()
|
||||
{
|
||||
this.note = this.registerNBTComponent(new ComponentTag<Byte>("note"));
|
||||
}
|
||||
|
||||
public BuilderNoteEditor(byte note)
|
||||
{
|
||||
this();
|
||||
this.setNote(note);
|
||||
}
|
||||
|
||||
public BuilderNoteEditor(byte note, BlockPos pos)
|
||||
{
|
||||
this(note);
|
||||
this.setPosition(pos);
|
||||
}
|
||||
|
||||
public void setNote(byte note)
|
||||
{
|
||||
this.note.setValue(note);
|
||||
}
|
||||
|
||||
public BuilderNoteEditor getBuilderForNote(byte note)
|
||||
{
|
||||
return new BuilderNoteEditor(note, this.getBlockPos());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.Syntax;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BuilderPlayer extends CommandBuilder
|
||||
{
|
||||
private final String command;
|
||||
|
||||
public BuilderPlayer(String command)
|
||||
{
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
public void setPlayer(String player)
|
||||
{
|
||||
this.setNode(0, player);
|
||||
}
|
||||
|
||||
public String getPlayer()
|
||||
{
|
||||
return this.getNodeAsString(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return this.command;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Syntax getSyntax()
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("player", Type.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.Syntax;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BuilderPlayerReason extends CommandBuilder
|
||||
{
|
||||
private final String command;
|
||||
|
||||
public BuilderPlayerReason(String command)
|
||||
{
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
public void setPlayer(String player)
|
||||
{
|
||||
this.setNode(0, player);
|
||||
}
|
||||
|
||||
public String getPlayer()
|
||||
{
|
||||
return this.getNodeAsString(0);
|
||||
}
|
||||
|
||||
public void setReason(String reason)
|
||||
{
|
||||
this.setNode(1, reason);
|
||||
}
|
||||
|
||||
public String getReason()
|
||||
{
|
||||
return this.getNodeAsString(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return this.command;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Syntax getSyntax()
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("player", Type.STRING);
|
||||
syntax.addOptional("reason", Type.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.Syntax;
|
||||
import exopandora.worldhandler.builder.component.abstr.PotionMetadata;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BuilderPotionEffect extends CommandBuilder
|
||||
{
|
||||
private int seconds;
|
||||
private int minutes;
|
||||
private int hours;
|
||||
|
||||
public BuilderPotionEffect()
|
||||
{
|
||||
this(null, null);
|
||||
}
|
||||
|
||||
public BuilderPotionEffect(String player, ResourceLocation effect)
|
||||
{
|
||||
this(player, effect, 0, (byte) 0, false);
|
||||
}
|
||||
|
||||
public BuilderPotionEffect(String player, ResourceLocation effect, int duration, byte amplifier, boolean hideParticles)
|
||||
{
|
||||
this.setPlayer(player);
|
||||
this.setEffect(effect);
|
||||
this.setDuration(duration);
|
||||
this.setAmplifier(amplifier);
|
||||
this.setHideParticles(hideParticles);
|
||||
}
|
||||
|
||||
public void setPlayer(String player)
|
||||
{
|
||||
this.setNode(0, player);
|
||||
}
|
||||
|
||||
public String getPlayer()
|
||||
{
|
||||
return this.getNodeAsString(0);
|
||||
}
|
||||
|
||||
public void setEffect(ResourceLocation effect)
|
||||
{
|
||||
this.setNode(1, effect);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Potion getEffectAsPotion()
|
||||
{
|
||||
ResourceLocation location = this.getNodeAsResourceLocation(1);
|
||||
|
||||
if(location != null)
|
||||
{
|
||||
return Potion.getPotionFromResourceLocation(location.toString());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public ResourceLocation getEffect()
|
||||
{
|
||||
return this.getNodeAsResourceLocation(1);
|
||||
}
|
||||
|
||||
public void setDuration(int duration)
|
||||
{
|
||||
this.setNode(2, Math.min(duration, 1000000));
|
||||
}
|
||||
|
||||
public int getDuration()
|
||||
{
|
||||
return this.getNodeAsInt(2);
|
||||
}
|
||||
|
||||
public void setAmplifier(byte amplifier)
|
||||
{
|
||||
this.setNode(3, (byte) (amplifier - 1));
|
||||
}
|
||||
|
||||
public int getAmplifier()
|
||||
{
|
||||
return this.getNodeAsByte(3);
|
||||
}
|
||||
|
||||
public void setHideParticles(boolean hideParticles)
|
||||
{
|
||||
this.setNode(4, hideParticles);
|
||||
}
|
||||
|
||||
public boolean getHideParticles()
|
||||
{
|
||||
return this.getNodeAsBoolean(4);
|
||||
}
|
||||
|
||||
public int getSeconds()
|
||||
{
|
||||
return this.seconds;
|
||||
}
|
||||
|
||||
public void setSeconds(int seconds)
|
||||
{
|
||||
this.seconds = seconds;
|
||||
this.setDuration(PotionMetadata.getDuration(this.seconds, this.minutes, this.hours));
|
||||
}
|
||||
|
||||
public int getMinutes()
|
||||
{
|
||||
return this.minutes;
|
||||
}
|
||||
|
||||
public void setMinutes(int minutes)
|
||||
{
|
||||
this.minutes = minutes;
|
||||
this.setDuration(PotionMetadata.getDuration(this.seconds, this.minutes, this.hours));
|
||||
}
|
||||
|
||||
public int getHours()
|
||||
{
|
||||
return this.hours;
|
||||
}
|
||||
|
||||
public void setHours(int hours)
|
||||
{
|
||||
this.hours = hours;
|
||||
this.setDuration(PotionMetadata.getDuration(this.seconds, this.minutes, this.hours));
|
||||
}
|
||||
|
||||
public BuilderGeneric getRemoveCommand()
|
||||
{
|
||||
return new BuilderGeneric(this.getCommandName(), this.getPlayer(), this.getEffect().toString(), "0");
|
||||
}
|
||||
|
||||
public BuilderGeneric getClearCommand()
|
||||
{
|
||||
return new BuilderGeneric(this.getCommandName(), this.getPlayer(), "clear");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "effect";
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Syntax getSyntax()
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("player", Type.STRING);
|
||||
syntax.addRequired("effect", Type.RESOURCE_LOCATION);
|
||||
syntax.addOptional("seconds", Type.INT, 0);
|
||||
syntax.addOptional("amplifier", Type.BYTE, (byte) -1);
|
||||
syntax.addOptional("hideParticles", Type.BOOLEAN, false);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.component.impl.ComponentPotionItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BuilderPotionItem extends BuilderGive
|
||||
{
|
||||
private final ComponentPotionItem potion;
|
||||
|
||||
public BuilderPotionItem()
|
||||
{
|
||||
this(null, null, new ComponentPotionItem());
|
||||
}
|
||||
|
||||
public BuilderPotionItem(ResourceLocation item, String player, ComponentPotionItem potion)
|
||||
{
|
||||
this.setItem(item);
|
||||
this.setPlayer(player);
|
||||
this.setAmount(1);
|
||||
this.potion = this.registerNBTComponent(potion);
|
||||
}
|
||||
|
||||
public void setAmplifier(Potion potion, byte amplifier)
|
||||
{
|
||||
this.potion.get(potion).setAmplifier(amplifier);
|
||||
}
|
||||
|
||||
public void setSeconds(Potion potion, int seconds)
|
||||
{
|
||||
this.potion.get(potion).setSeconds(seconds);
|
||||
}
|
||||
|
||||
public void setMinutes(Potion potion, int minutes)
|
||||
{
|
||||
this.potion.get(potion).setMinutes(minutes);
|
||||
}
|
||||
|
||||
public void setHours(Potion potion, int hours)
|
||||
{
|
||||
this.potion.get(potion).setHours(hours);
|
||||
}
|
||||
|
||||
public void setShowParticles(Potion potion, boolean showParticles)
|
||||
{
|
||||
this.potion.get(potion).setShowParticles(showParticles);
|
||||
}
|
||||
|
||||
public void setAmbient(Potion potion, boolean ambient)
|
||||
{
|
||||
this.potion.get(potion).setAmbient(ambient);
|
||||
}
|
||||
|
||||
public byte getAmplifier(Potion potion)
|
||||
{
|
||||
return this.potion.get(potion).getAmplifier();
|
||||
}
|
||||
|
||||
public int getSeconds(Potion potion)
|
||||
{
|
||||
return this.potion.get(potion).getSeconds();
|
||||
}
|
||||
|
||||
public int getMinutes(Potion potion)
|
||||
{
|
||||
return this.potion.get(potion).getMinutes();
|
||||
}
|
||||
|
||||
public int getHours(Potion potion)
|
||||
{
|
||||
return this.potion.get(potion).getHours();
|
||||
}
|
||||
|
||||
public boolean getShowParticles(Potion potion)
|
||||
{
|
||||
return this.potion.get(potion).getShowParticles();
|
||||
}
|
||||
|
||||
public boolean getAmbient(Potion potion)
|
||||
{
|
||||
return this.potion.get(potion).getAmbient();
|
||||
}
|
||||
|
||||
public BuilderPotionItem getBuilderForPotion(Item item)
|
||||
{
|
||||
return new BuilderPotionItem(item.getRegistryName(), this.getPlayer(), this.potion);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.builder.Syntax;
|
||||
import exopandora.worldhandler.builder.impl.abstr.BuilderScoreboard;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BuilderScoreboardObjectives extends BuilderScoreboard
|
||||
{
|
||||
public BuilderScoreboardObjectives()
|
||||
{
|
||||
this.init();
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
this.setNode(0, "objectives");
|
||||
}
|
||||
|
||||
public void setMode(String mode)
|
||||
{
|
||||
String objective = this.getObjective();
|
||||
|
||||
if(mode.equals("add") || mode.equals("remove") || mode.equals("setdisplay"))
|
||||
{
|
||||
this.updateSyntax(this.getSyntax(mode));
|
||||
this.setNode(1, mode);
|
||||
|
||||
if(objective != null)
|
||||
{
|
||||
this.setObjective(objective);
|
||||
}
|
||||
|
||||
this.init();
|
||||
}
|
||||
}
|
||||
|
||||
public String getMode()
|
||||
{
|
||||
return this.getNodeAsString(1);
|
||||
}
|
||||
|
||||
public void setObjective(String name)
|
||||
{
|
||||
String mode = this.getMode();
|
||||
String objective = name != null ? name.replaceAll(" ", "_") : null;
|
||||
|
||||
if(mode != null)
|
||||
{
|
||||
if(mode.equals("add") || mode.equals("remove"))
|
||||
{
|
||||
this.setNode(2, objective);
|
||||
|
||||
if(mode.equals("add"))
|
||||
{
|
||||
this.setNode(4, name);
|
||||
}
|
||||
}
|
||||
else if(mode.equals("setdisplay"))
|
||||
{
|
||||
this.setNode(3, objective);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setCriteria(String criteria)
|
||||
{
|
||||
if(this.getMode() == null || !this.getMode().equals("add"))
|
||||
{
|
||||
this.setMode("add");
|
||||
}
|
||||
this.setNode(3, criteria.replaceAll("[:]", "."));
|
||||
}
|
||||
|
||||
public void setSlot(String slot)
|
||||
{
|
||||
if(this.getMode() == null || !this.getMode().equals("setdisplay"))
|
||||
{
|
||||
this.setMode("setdisplay");
|
||||
}
|
||||
this.setNode(2, slot);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getSlot()
|
||||
{
|
||||
if(this.getMode() != null && this.getMode().equals("setdisplay"))
|
||||
{
|
||||
return this.getNodeAsString(2);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getObjective()
|
||||
{
|
||||
String mode = this.getMode();
|
||||
|
||||
if(mode != null)
|
||||
{
|
||||
if(mode.equals("add") || mode.equals("remove"))
|
||||
{
|
||||
return this.getNodeAsString(2);
|
||||
}
|
||||
else if(mode.equals("setdisplay"))
|
||||
{
|
||||
return this.getNodeAsString(3);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Syntax getSyntax(String mode)
|
||||
{
|
||||
if(mode.equals("add"))
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("objectives", Type.STRING);
|
||||
syntax.addRequired("add", Type.STRING);
|
||||
syntax.addRequired("name", Type.STRING);
|
||||
syntax.addRequired("criteria_type", Type.STRING);
|
||||
syntax.addOptional("display_name...", Type.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
else if(mode.equals("remove"))
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("objectives", Type.STRING);
|
||||
syntax.addRequired("remove", Type.STRING);
|
||||
syntax.addRequired("name", Type.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
else if(mode.equals("setdisplay"))
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("objectives", Type.STRING);
|
||||
syntax.addRequired("setdisplay", Type.STRING);
|
||||
syntax.addRequired("slot", Type.STRING);
|
||||
syntax.addOptional("objective", Type.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Syntax getSyntax()
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("objectives", Type.STRING);
|
||||
syntax.addRequired("list|add|remove|setdisplay", Type.STRING);
|
||||
syntax.addOptional("...", Type.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,231 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.Syntax;
|
||||
import exopandora.worldhandler.builder.impl.abstr.BuilderScoreboard;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BuilderScoreboardPlayers extends BuilderScoreboard
|
||||
{
|
||||
public BuilderScoreboardPlayers()
|
||||
{
|
||||
this.init();
|
||||
}
|
||||
|
||||
public String getMode()
|
||||
{
|
||||
return this.getNodeAsString(1);
|
||||
}
|
||||
|
||||
public void setMode(String mode)
|
||||
{
|
||||
String objective = this.getObjective();
|
||||
String player = this.getPlayer();
|
||||
String tag = this.getTag();
|
||||
int points = this.getPoints();
|
||||
|
||||
if(mode.equals("add|set|remove") || mode.equals("tag") || mode.equals("enable"))
|
||||
{
|
||||
this.updateSyntax(this.getSyntax(mode));
|
||||
this.setNode(1, mode);
|
||||
this.setNode(2, player);
|
||||
|
||||
if(mode.equals("add|set|remove") || mode.equals("enable"))
|
||||
{
|
||||
this.setObjective(objective);
|
||||
}
|
||||
|
||||
if(mode.equals("add|set|remove"))
|
||||
{
|
||||
this.setPoints(points);
|
||||
}
|
||||
else if(mode.equals("tag"))
|
||||
{
|
||||
this.setTag(tag);
|
||||
}
|
||||
|
||||
this.init();
|
||||
}
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
this.setNode(0, "players");
|
||||
}
|
||||
|
||||
public void setPlayer(String player)
|
||||
{
|
||||
this.setNode(2, player);
|
||||
}
|
||||
|
||||
public String getPlayer()
|
||||
{
|
||||
return this.getNodeAsString(2);
|
||||
}
|
||||
|
||||
public void setObjective(String name)
|
||||
{
|
||||
String mode = this.getMode();
|
||||
String objective = name != null ? name.replaceAll(" ", "_") : null;
|
||||
|
||||
if(mode != null)
|
||||
{
|
||||
if(mode.equals("add|set|remove") || mode.equals("enable"))
|
||||
{
|
||||
this.setNode(3, objective);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getObjective()
|
||||
{
|
||||
String mode = this.getMode();
|
||||
|
||||
if(mode != null)
|
||||
{
|
||||
if(mode.equals("add|set|remove") || mode.equals("enable"))
|
||||
{
|
||||
return this.getNodeAsString(3);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setPoints(int points)
|
||||
{
|
||||
if(this.getMode() == null || !this.getMode().equals("add|set|remove"))
|
||||
{
|
||||
this.setMode("add|set|remove");
|
||||
}
|
||||
this.setNode(4, points);
|
||||
}
|
||||
|
||||
public int getPoints()
|
||||
{
|
||||
if(this.getMode() != null && this.getMode().equals("add|set|remove"))
|
||||
{
|
||||
return this.getNodeAsInt(4);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setTag(String name)
|
||||
{
|
||||
String tag = name != null ? name.replaceAll(" ", "_") : null;
|
||||
|
||||
if(this.getMode() == null || !this.getMode().equals("tag"))
|
||||
{
|
||||
this.setMode("tag");
|
||||
}
|
||||
this.setNode(4, tag);
|
||||
}
|
||||
|
||||
public String getTag()
|
||||
{
|
||||
if(this.getMode() != null && this.getMode().equals("tag"))
|
||||
{
|
||||
return this.getNodeAsString(4);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private Syntax getSyntax(String mode)
|
||||
{
|
||||
if(mode.equals("add|set|remove"))
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("players", Type.STRING);
|
||||
syntax.addRequired("add|set|remove", Type.STRING, "add|set|remove");
|
||||
syntax.addRequired("player", Type.STRING);
|
||||
syntax.addRequired("objective", Type.STRING);
|
||||
syntax.addRequired("count", Type.INT, 0);
|
||||
syntax.addOptional("nbt", Type.NBT);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
else if(mode.equals("tag"))
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("players", Type.STRING);
|
||||
syntax.addRequired("tag", Type.STRING);
|
||||
syntax.addRequired("player", Type.STRING);
|
||||
syntax.addRequired("add|remove|list", Type.STRING);
|
||||
syntax.addRequired("tag_name", Type.STRING);
|
||||
syntax.addOptional("nbt", Type.NBT);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
else if(mode.equals("enable"))
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("players", Type.STRING);
|
||||
syntax.addRequired("enable", Type.STRING);
|
||||
syntax.addRequired("player", Type.STRING);
|
||||
syntax.addRequired("trigger", Type.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public BuilderGeneric getBuilderForTag(EnumTag tag)
|
||||
{
|
||||
return new BuilderGeneric(this.getCommandName(), "players", this.getMode(), this.getPlayer(), tag.toString(), this.getTag());
|
||||
}
|
||||
|
||||
public BuilderGeneric getBuilderForPoints(EnumPoints mode)
|
||||
{
|
||||
return this.getBuilderForPoints(mode, this.getPoints());
|
||||
}
|
||||
|
||||
public BuilderGeneric getBuilderForPoints(EnumPoints mode, int points)
|
||||
{
|
||||
return new BuilderGeneric(this.getCommandName(), "players", mode.toString(), this.getPlayer(), this.getObjective(), String.valueOf(points));
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Syntax getSyntax()
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("players", Type.STRING);
|
||||
syntax.addRequired("add|enable|list|operation|remove|reset|set|tag|test", Type.STRING);
|
||||
syntax.addOptional("...", Type.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
|
||||
public static enum EnumTag
|
||||
{
|
||||
ADD,
|
||||
REMOVE;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
|
||||
public static enum EnumPoints
|
||||
{
|
||||
ADD,
|
||||
REMOVE,
|
||||
SET;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,256 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.builder.Syntax;
|
||||
import exopandora.worldhandler.builder.impl.abstr.BuilderScoreboard;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BuilderScoreboardTeams extends BuilderScoreboard
|
||||
{
|
||||
public BuilderScoreboardTeams()
|
||||
{
|
||||
this.init();
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
this.setNode(0, "teams");
|
||||
}
|
||||
|
||||
public void setTeam(String name)
|
||||
{
|
||||
String mode = this.getMode();
|
||||
String team = name != null ? name.replaceAll(" ", "_") : null;
|
||||
|
||||
if(mode != null)
|
||||
{
|
||||
if(mode.equals("add"))
|
||||
{
|
||||
this.setNode(3, name);
|
||||
}
|
||||
}
|
||||
|
||||
this.setNode(2, team);
|
||||
}
|
||||
|
||||
public String getMode()
|
||||
{
|
||||
return this.getNodeAsString(1);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getTeam()
|
||||
{
|
||||
return this.getNodeAsString(2);
|
||||
}
|
||||
|
||||
public void setMode(String mode)
|
||||
{
|
||||
String team = this.getTeam();
|
||||
String player = this.getPlayer();
|
||||
|
||||
if(mode.equals("add") || mode.equals("remove|empty") || mode.equals("join|leave") || mode.equals("option"))
|
||||
{
|
||||
this.updateSyntax(this.getSyntax(mode));
|
||||
this.setNode(1, mode);
|
||||
|
||||
if(team != null)
|
||||
{
|
||||
this.setTeam(team);
|
||||
}
|
||||
|
||||
if(player != null && (mode.equals("join|leave")))
|
||||
{
|
||||
this.setPlayer(player);
|
||||
}
|
||||
|
||||
this.init();
|
||||
}
|
||||
}
|
||||
|
||||
public void setPlayer(String player)
|
||||
{
|
||||
String mode = this.getMode();
|
||||
|
||||
if(mode != null)
|
||||
{
|
||||
if(mode.equals("join|leave"))
|
||||
{
|
||||
this.setNode(3, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getPlayer()
|
||||
{
|
||||
String mode = this.getMode();
|
||||
|
||||
if(mode != null)
|
||||
{
|
||||
if(mode.equals("join|leave"))
|
||||
{
|
||||
return this.getNodeAsString(3);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setRule(String rule)
|
||||
{
|
||||
if(this.getMode() == null || !this.getMode().equals("option"))
|
||||
{
|
||||
this.setMode("option");
|
||||
}
|
||||
|
||||
this.setNode(3, rule);
|
||||
}
|
||||
|
||||
public String getRule()
|
||||
{
|
||||
if(this.getMode() == null || this.getMode().equals("option"))
|
||||
{
|
||||
return this.getNodeAsString(3);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setValue(String value)
|
||||
{
|
||||
if(this.getMode() == null || !this.getMode().equals("option"))
|
||||
{
|
||||
this.setMode("option");
|
||||
}
|
||||
|
||||
this.setNode(4, value);
|
||||
}
|
||||
|
||||
public String getValue()
|
||||
{
|
||||
if(this.getMode() == null || this.getMode().equals("option"))
|
||||
{
|
||||
return this.getNodeAsString(4);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Syntax getSyntax(String mode)
|
||||
{
|
||||
if(mode.equals("add"))
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("teams", Type.STRING);
|
||||
syntax.addRequired("add", Type.STRING);
|
||||
syntax.addRequired("name", Type.STRING);
|
||||
syntax.addOptional("display_name...", Type.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
else if(mode.equals("remove|empty"))
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("teams", Type.STRING);
|
||||
syntax.addRequired("remove|empty", Type.STRING, "remove|empty");
|
||||
syntax.addRequired("name", Type.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
else if(mode.equals("join|leave"))
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("teams", Type.STRING);
|
||||
syntax.addRequired("join|leave", Type.STRING, "join|leave");
|
||||
syntax.addRequired("name", Type.STRING);
|
||||
syntax.addOptional("player", Type.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
else if(mode.equals("option"))
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("teams", Type.STRING);
|
||||
syntax.addRequired("option", Type.STRING);
|
||||
syntax.addRequired("team", Type.STRING);
|
||||
syntax.addRequired("friendlyfire|color|seeFriendlyInvisibles|nametagVisibility|deathMessageVisibility|collisionRule", Type.STRING);
|
||||
syntax.addRequired("value", Type.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public BuilderScoreboardTeams getBuilderForMode(EnumMode mode)
|
||||
{
|
||||
BuilderScoreboardTeams builder = new BuilderScoreboardTeams();
|
||||
|
||||
switch(mode)
|
||||
{
|
||||
case JOIN:
|
||||
case LEAVE:
|
||||
builder.setNode(1, mode.toString());
|
||||
builder.setTeam(this.getTeam());
|
||||
builder.setPlayer(this.getPlayer());
|
||||
break;
|
||||
case REMOVE:
|
||||
case EMPTY:
|
||||
builder.setNode(1, mode.toString());
|
||||
builder.setTeam(this.getTeam());
|
||||
break;
|
||||
case ADD:
|
||||
builder.setMode(mode.toString());
|
||||
builder.setTeam(this.getTeam());
|
||||
break;
|
||||
case OPTION:
|
||||
builder.setMode(mode.toString());
|
||||
builder.setTeam(this.getTeam());
|
||||
builder.setRule(this.getRule());
|
||||
builder.setValue(this.getValue());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Syntax getSyntax()
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("teams", Type.STRING);
|
||||
syntax.addRequired("list|add|remove|empty|join|leave|option", Type.STRING);
|
||||
syntax.addOptional("...", Type.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
|
||||
public static enum EnumMode
|
||||
{
|
||||
JOIN,
|
||||
LEAVE,
|
||||
REMOVE,
|
||||
EMPTY,
|
||||
ADD,
|
||||
OPTION;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.Syntax;
|
||||
import exopandora.worldhandler.builder.impl.abstr.BuilderBlockPos;
|
||||
import exopandora.worldhandler.builder.types.Coordinate;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public class BuilderSetblock extends BuilderBlockPos
|
||||
{
|
||||
@Deprecated
|
||||
public BuilderSetblock(BlockPos pos, ResourceLocation block, int meta, String mode)
|
||||
{
|
||||
this.setPosition(pos);
|
||||
this.setBlock(block);
|
||||
this.setMetadata(meta);
|
||||
this.setMode(mode);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public BuilderSetblock(Coordinate x, Coordinate y, Coordinate z, ResourceLocation block, int meta, String mode)
|
||||
{
|
||||
this.setX(x);
|
||||
this.setY(y);
|
||||
this.setZ(z);
|
||||
this.setBlock(block);
|
||||
this.setMetadata(meta);
|
||||
this.setMode(mode);
|
||||
}
|
||||
|
||||
public BuilderSetblock(Coordinate x, Coordinate y, Coordinate z, ResourceLocation block, String mode)
|
||||
{
|
||||
this(x, y, z, block, 0, mode);
|
||||
}
|
||||
|
||||
public void setBlock(ResourceLocation block)
|
||||
{
|
||||
this.setNode(3, block);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setMetadata(int meta)
|
||||
{
|
||||
this.setNode(4, meta);
|
||||
}
|
||||
|
||||
public void setMode(String mode)
|
||||
{
|
||||
this.setNode(5, mode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNBT(NBTTagCompound nbt)
|
||||
{
|
||||
this.setNode(6, nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "setblock";
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Syntax getSyntax()
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("x", Type.COORDINATE);
|
||||
syntax.addRequired("y", Type.COORDINATE);
|
||||
syntax.addRequired("z", Type.COORDINATE);
|
||||
syntax.addRequired("block", Type.RESOURCE_LOCATION);
|
||||
syntax.addOptional("data_value", Type.INT);
|
||||
syntax.addOptional("mode", Type.STRING);
|
||||
syntax.addOptional("nbt", Type.NBT);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.builder.component.impl.ComponentTag;
|
||||
import exopandora.worldhandler.format.text.ColoredString;
|
||||
import exopandora.worldhandler.format.text.SignText;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BuilderSignEditor extends BuilderBlockdata
|
||||
{
|
||||
private final ComponentTag<SignText>[] sign = new ComponentTag[4];
|
||||
|
||||
public BuilderSignEditor()
|
||||
{
|
||||
for(int x = 0; x < 4; x++)
|
||||
{
|
||||
this.sign[x] = this.registerNBTComponent(new ComponentTag<SignText>("Text" + (x + 1), new SignText(x), text -> new NBTTagString(text.toString())));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isSpecial()
|
||||
{
|
||||
boolean special = false;
|
||||
|
||||
for(int x = 0; x < this.sign.length; x++)
|
||||
{
|
||||
special = special || this.getColoredString(x).isSpecial();
|
||||
}
|
||||
|
||||
return special;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ColoredString getColoredString(int line)
|
||||
{
|
||||
if(this.checkBounds(line))
|
||||
{
|
||||
return this.sign[line].getValue().getColoredString();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getCommand(int line)
|
||||
{
|
||||
if(this.checkBounds(line))
|
||||
{
|
||||
return this.sign[line].getValue().getCommand();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public void setCommand(int line, String command)
|
||||
{
|
||||
if(this.checkBounds(line))
|
||||
{
|
||||
this.sign[line].getValue().setCommand(command);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkBounds(int line)
|
||||
{
|
||||
return line >= 0 && line < this.sign.length;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.Syntax;
|
||||
import exopandora.worldhandler.builder.types.Coordinate;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BuilderSpawnpoint extends CommandBuilder
|
||||
{
|
||||
public BuilderSpawnpoint(String player)
|
||||
{
|
||||
this.setX(new Coordinate(0, true));
|
||||
this.setY(new Coordinate(0, true));
|
||||
this.setZ(new Coordinate(0, true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "spawnpoint";
|
||||
}
|
||||
|
||||
public void setPlayer(String player)
|
||||
{
|
||||
this.setNode(0, player);
|
||||
}
|
||||
|
||||
public void setX(Coordinate x)
|
||||
{
|
||||
this.setNode(1, x);
|
||||
}
|
||||
|
||||
public void setY(Coordinate y)
|
||||
{
|
||||
this.setNode(2, y);
|
||||
}
|
||||
|
||||
public void setZ(Coordinate z)
|
||||
{
|
||||
this.setNode(3, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Syntax getSyntax()
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("player", Type.STRING);
|
||||
syntax.addRequired("x", Type.COORDINATE);
|
||||
syntax.addRequired("y", Type.COORDINATE);
|
||||
syntax.addRequired("z", Type.COORDINATE);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,407 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilderNBT;
|
||||
import exopandora.worldhandler.builder.Syntax;
|
||||
import exopandora.worldhandler.builder.component.impl.ComponentAttributeMob;
|
||||
import exopandora.worldhandler.builder.component.impl.ComponentPotionMob;
|
||||
import exopandora.worldhandler.builder.component.impl.ComponentSummon;
|
||||
import exopandora.worldhandler.builder.component.impl.ComponentTag;
|
||||
import exopandora.worldhandler.builder.impl.abstr.EnumAttributes;
|
||||
import exopandora.worldhandler.builder.impl.abstr.EnumAttributes.Applyable;
|
||||
import exopandora.worldhandler.builder.types.Coordinate;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
import exopandora.worldhandler.format.text.ColoredString;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BuilderSummon extends CommandBuilderNBT
|
||||
{
|
||||
private final ComponentAttributeMob attribute;
|
||||
private final ComponentTag<ColoredString> customName;
|
||||
private final ComponentTag<NBTTagList> passengers;
|
||||
private final ComponentTag<NBTTagList> armorItems;
|
||||
private final ComponentTag<NBTTagList> handItems;
|
||||
private final ComponentPotionMob potion;
|
||||
private final ComponentSummon summon;
|
||||
private final ResourceLocation[] armorItemsArray = {Blocks.AIR.getRegistryName(), Blocks.AIR.getRegistryName(), Blocks.AIR.getRegistryName(), Blocks.AIR.getRegistryName()};
|
||||
private final ResourceLocation[] handItemsArray = {Blocks.AIR.getRegistryName(), Blocks.AIR.getRegistryName()};
|
||||
|
||||
public BuilderSummon()
|
||||
{
|
||||
this.attribute = this.registerNBTComponent(new ComponentAttributeMob(attribute -> attribute.getApplyable().equals(Applyable.BOTH) || attribute.getApplyable().equals(Applyable.MOB)));
|
||||
this.customName = this.registerNBTComponent(new ComponentTag<ColoredString>("CustomName", new ColoredString(), this::colorStringSerializer));
|
||||
this.passengers = this.registerNBTComponent(new ComponentTag<NBTTagList>("Passengers"));
|
||||
this.armorItems = this.registerNBTComponent(new ComponentTag<NBTTagList>("ArmorItems", this::itemListSerializer));
|
||||
this.handItems = this.registerNBTComponent(new ComponentTag<NBTTagList>("HandItems", this::itemListSerializer));
|
||||
this.summon = this.registerNBTComponent(new ComponentSummon(), "summon");
|
||||
this.potion = this.registerNBTComponent(new ComponentPotionMob());
|
||||
}
|
||||
|
||||
public BuilderSummon(int direction)
|
||||
{
|
||||
this();
|
||||
this.setDirection(direction);
|
||||
}
|
||||
|
||||
public void setDirection(int direction)
|
||||
{
|
||||
if(direction == 0)
|
||||
{
|
||||
this.setX(new Coordinate(0, true));
|
||||
this.setY(new Coordinate(0, true));
|
||||
this.setZ(new Coordinate(2, true));
|
||||
}
|
||||
else if(direction == 1)
|
||||
{
|
||||
this.setX(new Coordinate(-2, true));
|
||||
this.setY(new Coordinate(0, true));
|
||||
this.setZ(new Coordinate(0, true));
|
||||
}
|
||||
else if(direction == 2)
|
||||
{
|
||||
this.setX(new Coordinate(0, true));
|
||||
this.setY(new Coordinate(0, true));
|
||||
this.setZ(new Coordinate(-2, true));
|
||||
}
|
||||
else if(direction == 3)
|
||||
{
|
||||
this.setX(new Coordinate(2, true));
|
||||
this.setY(new Coordinate(0, true));
|
||||
this.setZ(new Coordinate(0, true));
|
||||
}
|
||||
}
|
||||
|
||||
public void setEntity(String entityName)
|
||||
{
|
||||
ResourceLocation location = this.summon.resolve(entityName);
|
||||
|
||||
this.summon.setName(entityName);
|
||||
this.summon.setEntity(location);
|
||||
|
||||
this.setNode(0, location);
|
||||
}
|
||||
|
||||
public ResourceLocation getEntity()
|
||||
{
|
||||
return this.getNodeAsResourceLocation(0);
|
||||
}
|
||||
|
||||
public void setX(Coordinate x)
|
||||
{
|
||||
this.setNode(1, x);
|
||||
}
|
||||
|
||||
public Coordinate getX()
|
||||
{
|
||||
return this.getNodeAsCoordinate(1);
|
||||
}
|
||||
|
||||
public void setY(Coordinate y)
|
||||
{
|
||||
this.setNode(2, y);
|
||||
}
|
||||
|
||||
public Coordinate getY()
|
||||
{
|
||||
return this.getNodeAsCoordinate(2);
|
||||
}
|
||||
|
||||
public void setZ(Coordinate z)
|
||||
{
|
||||
this.setNode(3, z);
|
||||
}
|
||||
|
||||
public Coordinate getZ()
|
||||
{
|
||||
return this.getNodeAsCoordinate(3);
|
||||
}
|
||||
|
||||
public void setAttribute(EnumAttributes attribute, float ammount)
|
||||
{
|
||||
this.attribute.set(attribute, ammount);
|
||||
}
|
||||
|
||||
public void removeAttribute(EnumAttributes attribute)
|
||||
{
|
||||
this.attribute.remove(attribute);
|
||||
}
|
||||
|
||||
public void setCustomName(ColoredString name)
|
||||
{
|
||||
this.customName.setValue(name);
|
||||
}
|
||||
|
||||
public void setCustomName(String name)
|
||||
{
|
||||
this.customName.getValue().setText(name);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public ColoredString getCustomName()
|
||||
{
|
||||
if(this.customName.getValue() != null)
|
||||
{
|
||||
return this.customName.getValue();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setPassenger(String entityName)
|
||||
{
|
||||
this.setPassenger(this.summon.resolve(entityName));
|
||||
}
|
||||
|
||||
public void setPassenger(ResourceLocation entityName)
|
||||
{
|
||||
if(entityName != null)
|
||||
{
|
||||
NBTTagCompound passenger = new NBTTagCompound();
|
||||
passenger.setString("id", entityName.toString());
|
||||
|
||||
NBTTagList list = new NBTTagList();
|
||||
list.appendTag(passenger);
|
||||
|
||||
this.passengers.setValue(list);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.passengers.setValue(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ResourceLocation getPassenger()
|
||||
{
|
||||
NBTTagList list = this.passengers.getValue();
|
||||
|
||||
if(list != null && !list.hasNoTags())
|
||||
{
|
||||
return new ResourceLocation(list.getCompoundTagAt(0).getString("id"));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setArmorItem(int index, Block block)
|
||||
{
|
||||
this.setArmorItem(index, block.getRegistryName());
|
||||
}
|
||||
|
||||
public void setArmorItem(int index, Item item)
|
||||
{
|
||||
this.setArmorItem(index, item.getRegistryName());
|
||||
}
|
||||
|
||||
public void setArmorItem(int index, ResourceLocation location)
|
||||
{
|
||||
this.changeNBTList(index, location, this.armorItemsArray, this::setArmorItems);
|
||||
}
|
||||
|
||||
public void setArmorItems(ResourceLocation[] armor)
|
||||
{
|
||||
NBTTagList list = new NBTTagList();
|
||||
|
||||
for(ResourceLocation item : armor)
|
||||
{
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setString("id", item.toString());
|
||||
compound.setInteger("Count", 1);
|
||||
list.appendTag(compound);
|
||||
}
|
||||
|
||||
this.armorItems.setValue(list);
|
||||
}
|
||||
|
||||
public ResourceLocation getArmorItem(int slot)
|
||||
{
|
||||
if(slot < this.armorItemsArray.length)
|
||||
{
|
||||
return this.armorItemsArray[slot];
|
||||
}
|
||||
|
||||
return Blocks.AIR.getRegistryName();
|
||||
}
|
||||
|
||||
public void setHandItem(int index, Block block)
|
||||
{
|
||||
this.setHandItem(index, block.getRegistryName());
|
||||
}
|
||||
|
||||
public void setHandItem(int index, Item item)
|
||||
{
|
||||
this.setHandItem(index, item.getRegistryName());
|
||||
}
|
||||
|
||||
public void setHandItem(int index, ResourceLocation location)
|
||||
{
|
||||
this.changeNBTList(index, location, this.handItemsArray, this::setHandItems);
|
||||
}
|
||||
|
||||
private void changeNBTList(int index, ResourceLocation location, ResourceLocation[] array, Consumer<ResourceLocation[]> consumer)
|
||||
{
|
||||
if(index < array.length)
|
||||
{
|
||||
array[index] = location;
|
||||
consumer.accept(array);
|
||||
}
|
||||
}
|
||||
|
||||
public void setHandItems(ResourceLocation[] armor)
|
||||
{
|
||||
NBTTagList list = new NBTTagList();
|
||||
|
||||
for(ResourceLocation item : armor)
|
||||
{
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setString("id", item.toString());
|
||||
compound.setInteger("Count", 1);
|
||||
list.appendTag(compound);
|
||||
}
|
||||
|
||||
this.handItems.setValue(list);
|
||||
}
|
||||
|
||||
public ResourceLocation getHandItem(int slot)
|
||||
{
|
||||
if(slot < this.handItemsArray.length)
|
||||
{
|
||||
return this.handItemsArray[slot];
|
||||
}
|
||||
|
||||
return Blocks.AIR.getRegistryName();
|
||||
}
|
||||
|
||||
public void setAmplifier(Potion potion, byte amplifier)
|
||||
{
|
||||
this.potion.get(potion).setAmplifier(amplifier);
|
||||
}
|
||||
|
||||
public void setSeconds(Potion potion, int seconds)
|
||||
{
|
||||
this.potion.get(potion).setSeconds(seconds);
|
||||
}
|
||||
|
||||
public void setMinutes(Potion potion, int minutes)
|
||||
{
|
||||
this.potion.get(potion).setMinutes(minutes);
|
||||
}
|
||||
|
||||
public void setHours(Potion potion, int hours)
|
||||
{
|
||||
this.potion.get(potion).setHours(hours);
|
||||
}
|
||||
|
||||
public void setShowParticles(Potion potion, boolean showParticles)
|
||||
{
|
||||
this.potion.get(potion).setShowParticles(showParticles);
|
||||
}
|
||||
|
||||
public void setAmbient(Potion potion, boolean ambient)
|
||||
{
|
||||
this.potion.get(potion).setAmbient(ambient);
|
||||
}
|
||||
|
||||
public byte getAmplifier(Potion potion)
|
||||
{
|
||||
return this.potion.get(potion).getAmplifier();
|
||||
}
|
||||
|
||||
public int getSeconds(Potion potion)
|
||||
{
|
||||
return this.potion.get(potion).getSeconds();
|
||||
}
|
||||
|
||||
public int getMinutes(Potion potion)
|
||||
{
|
||||
return this.potion.get(potion).getMinutes();
|
||||
}
|
||||
|
||||
public int getHours(Potion potion)
|
||||
{
|
||||
return this.potion.get(potion).getHours();
|
||||
}
|
||||
|
||||
public boolean getShowParticles(Potion potion)
|
||||
{
|
||||
return this.potion.get(potion).getShowParticles();
|
||||
}
|
||||
|
||||
public boolean getAmbient(Potion potion)
|
||||
{
|
||||
return this.potion.get(potion).getAmbient();
|
||||
}
|
||||
|
||||
private NBTBase itemListSerializer(NBTTagList list)
|
||||
{
|
||||
for(int x = 0; x < list.tagCount(); x++)
|
||||
{
|
||||
if(!list.getCompoundTagAt(x).getString("id").equals(Blocks.AIR.getRegistryName().toString()))
|
||||
{
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private NBTBase colorStringSerializer(ColoredString string)
|
||||
{
|
||||
if(string.getText() != null && !string.getText().isEmpty())
|
||||
{
|
||||
return new NBTTagString(string.toString());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNBT(NBTTagCompound nbt)
|
||||
{
|
||||
this.setNode(4, nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "summon";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Syntax getSyntax()
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("entity_name", Type.RESOURCE_LOCATION);
|
||||
syntax.addOptional("x", Type.COORDINATE);
|
||||
syntax.addOptional("y", Type.COORDINATE);
|
||||
syntax.addOptional("z", Type.COORDINATE);
|
||||
syntax.addOptional("nbt", Type.NBT);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toCommand()
|
||||
{
|
||||
this.summon.setEntity(this.getEntity());
|
||||
this.summon.setHasPassenger(this.getPassenger() != null);
|
||||
|
||||
return super.toCommand();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.Syntax;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
|
||||
public class BuilderTime extends CommandBuilder
|
||||
{
|
||||
public BuilderTime()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public BuilderTime(EnumMode mode)
|
||||
{
|
||||
this.setMode(mode);
|
||||
}
|
||||
|
||||
public BuilderTime(EnumMode mode, int value)
|
||||
{
|
||||
this(mode);
|
||||
this.setValue(value);
|
||||
}
|
||||
|
||||
public void setMode(EnumMode mode)
|
||||
{
|
||||
this.setNode(0, mode.toString());
|
||||
}
|
||||
|
||||
public void setValue(int value)
|
||||
{
|
||||
this.setNode(1, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "time";
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Syntax getSyntax()
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("set|add|query", Type.STRING);
|
||||
syntax.addOptional("value", Type.INT);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
|
||||
public static enum EnumMode
|
||||
{
|
||||
ADD,
|
||||
SET,
|
||||
QUERY;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.Syntax;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BuilderWH extends CommandBuilder
|
||||
{
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "wh";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Syntax getSyntax()
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("pos1|pos2|fill|replace", Type.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.Syntax;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
|
||||
public class BuilderWeather extends CommandBuilder
|
||||
{
|
||||
public BuilderWeather()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public BuilderWeather(EnumWeather weather)
|
||||
{
|
||||
this.setWeather(weather);
|
||||
}
|
||||
|
||||
public BuilderWeather(EnumWeather weather, int value)
|
||||
{
|
||||
this(weather);
|
||||
this.setValue(value);
|
||||
}
|
||||
|
||||
public void setWeather(EnumWeather weather)
|
||||
{
|
||||
this.setNode(0, weather.toString());
|
||||
}
|
||||
|
||||
public void setValue(int value)
|
||||
{
|
||||
this.setNode(1, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "weather";
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Syntax getSyntax()
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("clear|rain|thunde", Type.STRING);
|
||||
syntax.addOptional("duration", Type.INT);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
|
||||
public static enum EnumWeather
|
||||
{
|
||||
CLEAR,
|
||||
RAIN,
|
||||
THUNDER;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.Syntax;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BuilderWhitelist extends CommandBuilder
|
||||
{
|
||||
public BuilderWhitelist()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public BuilderWhitelist(EnumMode mode)
|
||||
{
|
||||
this.setMode(mode);
|
||||
}
|
||||
|
||||
public BuilderWhitelist(EnumMode mode, String player)
|
||||
{
|
||||
this(mode);
|
||||
this.setPlayer(player);
|
||||
}
|
||||
|
||||
public void setMode(EnumMode mode)
|
||||
{
|
||||
this.setNode(0, mode.toString());
|
||||
}
|
||||
|
||||
public void setPlayer(String player)
|
||||
{
|
||||
this.setNode(1, player);
|
||||
}
|
||||
|
||||
public String getPlayer()
|
||||
{
|
||||
return this.getNodeAsString(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "whitelist";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public BuilderWhitelist getBuilder(EnumMode mode)
|
||||
{
|
||||
switch(mode)
|
||||
{
|
||||
case ADD:
|
||||
case REMOVE:
|
||||
return new BuilderWhitelist(mode, this.getPlayer());
|
||||
case RELOAD:
|
||||
case ON:
|
||||
case OFF:
|
||||
return new BuilderWhitelist(mode);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Syntax getSyntax()
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("add|remove|reload|on|off", Type.STRING);
|
||||
syntax.addOptional("player", Type.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
|
||||
public static enum EnumMode
|
||||
{
|
||||
ADD,
|
||||
REMOVE,
|
||||
RELOAD,
|
||||
ON,
|
||||
OFF;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package exopandora.worldhandler.builder.impl;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.Syntax;
|
||||
import exopandora.worldhandler.builder.types.Type;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class BuilderWorldHandler extends CommandBuilder
|
||||
{
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "worldhandler";
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Syntax getSyntax()
|
||||
{
|
||||
Syntax syntax = new Syntax();
|
||||
|
||||
syntax.addRequired("help|display|version", Type.STRING);
|
||||
|
||||
return syntax;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package exopandora.worldhandler.builder.impl.abstr;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilderNBT;
|
||||
import exopandora.worldhandler.builder.types.Coordinate;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public abstract class BuilderBlockPos extends CommandBuilderNBT
|
||||
{
|
||||
public void setPosition(BlockPos pos)
|
||||
{
|
||||
this.setX(pos.getX());
|
||||
this.setY(pos.getY());
|
||||
this.setZ(pos.getZ());
|
||||
}
|
||||
|
||||
public void setX(float x)
|
||||
{
|
||||
this.setX(new Coordinate(x));
|
||||
}
|
||||
|
||||
public void setY(float y)
|
||||
{
|
||||
this.setY(new Coordinate(y));
|
||||
}
|
||||
|
||||
public void setZ(float z)
|
||||
{
|
||||
this.setZ(new Coordinate(z));
|
||||
}
|
||||
|
||||
public void setX(Coordinate x)
|
||||
{
|
||||
this.setNode(0, x);
|
||||
}
|
||||
|
||||
public void setY(Coordinate y)
|
||||
{
|
||||
this.setNode(1, y);
|
||||
}
|
||||
|
||||
public void setZ(Coordinate z)
|
||||
{
|
||||
this.setNode(2, z);
|
||||
}
|
||||
|
||||
public Coordinate getXCoordiante()
|
||||
{
|
||||
return this.getNodeAsCoordinate(0);
|
||||
}
|
||||
|
||||
public Coordinate getYCoordiante()
|
||||
{
|
||||
return this.getNodeAsCoordinate(1);
|
||||
}
|
||||
|
||||
public Coordinate getZCoordiante()
|
||||
{
|
||||
return this.getNodeAsCoordinate(2);
|
||||
}
|
||||
|
||||
public double getX()
|
||||
{
|
||||
return this.getXCoordiante().getValue();
|
||||
}
|
||||
|
||||
public double getY()
|
||||
{
|
||||
return this.getYCoordiante().getValue();
|
||||
}
|
||||
|
||||
public double getZ()
|
||||
{
|
||||
return this.getZCoordiante().getValue();
|
||||
}
|
||||
|
||||
public BlockPos getBlockPos()
|
||||
{
|
||||
return new BlockPos(this.getX(), this.getY(), this.getZ());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
package exopandora.worldhandler.builder.impl.abstr;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import exopandora.worldhandler.builder.types.Coordinate;
|
||||
import exopandora.worldhandler.helper.BlockHelper;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public abstract class BuilderDoubleBlockPos extends CommandBuilder
|
||||
{
|
||||
public BuilderDoubleBlockPos()
|
||||
{
|
||||
this.setPosition1(BlockHelper.getPos1());
|
||||
this.setPosition2(BlockHelper.getPos2());
|
||||
}
|
||||
|
||||
public void setPosition1(BlockPos pos)
|
||||
{
|
||||
this.setX1(pos.getX());
|
||||
this.setY1(pos.getY());
|
||||
this.setZ1(pos.getZ());
|
||||
}
|
||||
|
||||
public void setX1(float x)
|
||||
{
|
||||
this.setX1(new Coordinate(x));
|
||||
}
|
||||
|
||||
public void setY1(float y)
|
||||
{
|
||||
this.setY1(new Coordinate(y));
|
||||
}
|
||||
|
||||
public void setZ1(float z)
|
||||
{
|
||||
this.setZ1(new Coordinate(z));
|
||||
}
|
||||
|
||||
public void setX1(Coordinate x)
|
||||
{
|
||||
this.setNode(0, x);
|
||||
BlockHelper.setPos1(BlockHelper.setX(BlockHelper.getPos1(), x.getValue()));
|
||||
}
|
||||
|
||||
public void setY1(Coordinate y)
|
||||
{
|
||||
this.setNode(1, y);
|
||||
BlockHelper.setPos1(BlockHelper.setY(BlockHelper.getPos1(), y.getValue()));
|
||||
}
|
||||
|
||||
public void setZ1(Coordinate z)
|
||||
{
|
||||
this.setNode(2, z);
|
||||
BlockHelper.setPos1(BlockHelper.setZ(BlockHelper.getPos1(), z.getValue()));
|
||||
}
|
||||
|
||||
public Coordinate getX1Coordiante()
|
||||
{
|
||||
return this.getNodeAsCoordinate(0);
|
||||
}
|
||||
|
||||
public Coordinate getY1Coordiante()
|
||||
{
|
||||
return this.getNodeAsCoordinate(1);
|
||||
}
|
||||
|
||||
public Coordinate getZ1Coordiante()
|
||||
{
|
||||
return this.getNodeAsCoordinate(2);
|
||||
}
|
||||
|
||||
public double getX1()
|
||||
{
|
||||
return this.getX1Coordiante().getValue();
|
||||
}
|
||||
|
||||
public double getY1()
|
||||
{
|
||||
return this.getY1Coordiante().getValue();
|
||||
}
|
||||
|
||||
public double getZ1()
|
||||
{
|
||||
return this.getZ1Coordiante().getValue();
|
||||
}
|
||||
|
||||
public BlockPos getBlockPos1()
|
||||
{
|
||||
return new BlockPos(this.getX1(), this.getY1(), this.getZ1());
|
||||
}
|
||||
|
||||
public void setPosition2(BlockPos pos)
|
||||
{
|
||||
this.setX2(pos.getX());
|
||||
this.setY2(pos.getY());
|
||||
this.setZ2(pos.getZ());
|
||||
}
|
||||
|
||||
public void setX2(float x)
|
||||
{
|
||||
this.setX2(new Coordinate(x));
|
||||
}
|
||||
|
||||
public void setY2(float y)
|
||||
{
|
||||
this.setY2(new Coordinate(y));
|
||||
}
|
||||
|
||||
public void setZ2(float z)
|
||||
{
|
||||
this.setZ2(new Coordinate(z));
|
||||
}
|
||||
|
||||
public void setX2(Coordinate x)
|
||||
{
|
||||
this.setNode(3, x);
|
||||
BlockHelper.setPos2(BlockHelper.setX(BlockHelper.getPos2(), x.getValue()));
|
||||
}
|
||||
|
||||
public void setY2(Coordinate y)
|
||||
{
|
||||
this.setNode(4, y);
|
||||
BlockHelper.setPos2(BlockHelper.setY(BlockHelper.getPos2(), y.getValue()));
|
||||
}
|
||||
|
||||
public void setZ2(Coordinate z)
|
||||
{
|
||||
this.setNode(5, z);
|
||||
BlockHelper.setPos2(BlockHelper.setZ(BlockHelper.getPos2(), z.getValue()));
|
||||
}
|
||||
|
||||
public Coordinate getX2Coordiante()
|
||||
{
|
||||
return this.getNodeAsCoordinate(3);
|
||||
}
|
||||
|
||||
public Coordinate getY2Coordiante()
|
||||
{
|
||||
return this.getNodeAsCoordinate(4);
|
||||
}
|
||||
|
||||
public Coordinate getZ2Coordiante()
|
||||
{
|
||||
return this.getNodeAsCoordinate(5);
|
||||
}
|
||||
|
||||
public double getX2()
|
||||
{
|
||||
return this.getX2Coordiante().getValue();
|
||||
}
|
||||
|
||||
public double getY2()
|
||||
{
|
||||
return this.getY2Coordiante().getValue();
|
||||
}
|
||||
|
||||
public double getZ2()
|
||||
{
|
||||
return this.getZ2Coordiante().getValue();
|
||||
}
|
||||
|
||||
public BlockPos getBlockPos2()
|
||||
{
|
||||
return new BlockPos(this.getX2(), this.getY2(), this.getZ2());
|
||||
}
|
||||
|
||||
public <T extends BuilderDoubleBlockPos> T addPositionObservers()
|
||||
{
|
||||
BlockHelper.addPos1Observer(this::setPosition1);
|
||||
BlockHelper.addPos2Observer(this::setPosition2);
|
||||
|
||||
return (T) this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package exopandora.worldhandler.builder.impl.abstr;
|
||||
|
||||
import exopandora.worldhandler.builder.CommandBuilder;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public abstract class BuilderScoreboard extends CommandBuilder
|
||||
{
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "scoreboard";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
package exopandora.worldhandler.builder.impl.abstr;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public enum EnumAttributes
|
||||
{
|
||||
MAX_HEALTH("generic.maxHealth", EnumOperation.ADDITIVE, 0, 100, 0, Applyable.BOTH),
|
||||
FOLLOW_RANGE("generic.followRange", EnumOperation.ADDITIVE, 0, 100, 0, Applyable.MOB),
|
||||
KNOCKBACK_RESISTANCE("generic.knockbackResistance", EnumOperation.PERCENTAGE, 0, 100, 0, Applyable.BOTH),
|
||||
MOVEMENT_SPEED("generic.movementSpeed", EnumOperation.PERCENTAGE, 0, 100, 0, Applyable.BOTH),
|
||||
ATTACK_DAMAGE("generic.attackDamage", EnumOperation.ADDITIVE, 0, 100, 0, Applyable.BOTH),
|
||||
ARMOR("generic.armor", EnumOperation.ADDITIVE, 0, 100, 0, Applyable.BOTH),
|
||||
ARMOR_TOUGHNESS("generic.armorToughness", EnumOperation.ADDITIVE, 0, 100, 0, Applyable.BOTH),
|
||||
ATTACK_SPEED("generic.attackSpeed", EnumOperation.PERCENTAGE, 0, 100, 0, Applyable.BOTH),
|
||||
LUCK("generic.luck", EnumOperation.PERCENTAGE, -100, 100, 0, Applyable.PLAYER),
|
||||
HORSE_JUMP_STRENGTH("horse.jumpStrength", EnumOperation.PERCENTAGE, 0, 100, 0, Applyable.MOB),
|
||||
ZOMBIE_SPAWN_REINFORCEMENTS("zombie.spawnReinforcements", EnumOperation.PERCENTAGE, 0, 100, 0, Applyable.MOB);
|
||||
|
||||
private String attribute;
|
||||
private EnumOperation operation;
|
||||
private float min;
|
||||
private float max;
|
||||
private float start;
|
||||
private Applyable applyable;
|
||||
|
||||
public enum Applyable
|
||||
{
|
||||
BOTH,
|
||||
PLAYER,
|
||||
MOB
|
||||
}
|
||||
|
||||
private EnumAttributes(String attribute, EnumOperation operation, float min, float max, float start, Applyable applyable)
|
||||
{
|
||||
this.attribute = attribute;
|
||||
this.operation = operation;
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
this.start = start;
|
||||
this.applyable = applyable;
|
||||
}
|
||||
|
||||
public String getAttribute()
|
||||
{
|
||||
return this.attribute;
|
||||
}
|
||||
|
||||
public String getTranslationKey()
|
||||
{
|
||||
return "attribute.name." + this.attribute;
|
||||
}
|
||||
|
||||
public String getTranslation()
|
||||
{
|
||||
return I18n.format(this.getTranslationKey(), new Object[0]);
|
||||
}
|
||||
|
||||
public EnumOperation getOperation()
|
||||
{
|
||||
return this.operation;
|
||||
}
|
||||
|
||||
public float getMin()
|
||||
{
|
||||
return this.min;
|
||||
}
|
||||
|
||||
public float getMax()
|
||||
{
|
||||
return this.max;
|
||||
}
|
||||
|
||||
public float getStart()
|
||||
{
|
||||
return this.start;
|
||||
}
|
||||
|
||||
public Applyable getApplyable()
|
||||
{
|
||||
return this.applyable;
|
||||
}
|
||||
|
||||
public double calculate(Float value)
|
||||
{
|
||||
return this.operation.getOperation().apply(value.doubleValue());
|
||||
}
|
||||
|
||||
public enum EnumOperation
|
||||
{
|
||||
ADDITIVE(value -> value, "(+)"),
|
||||
PERCENTAGE(value -> value / 100, "%");
|
||||
|
||||
private final Function<Double, Double> operation;
|
||||
private final String declaration;
|
||||
|
||||
private EnumOperation(Function<Double, Double> operation, String declaration)
|
||||
{
|
||||
this.operation = operation;
|
||||
this.declaration = declaration;
|
||||
}
|
||||
|
||||
public Function<Double, Double> getOperation()
|
||||
{
|
||||
return this.operation;
|
||||
}
|
||||
|
||||
public String getDeclaration()
|
||||
{
|
||||
return this.declaration;
|
||||
}
|
||||
}
|
||||
|
||||
public static List<EnumAttributes> getAttributesFor(Applyable applyable)
|
||||
{
|
||||
return Arrays.stream(EnumAttributes.values()).filter(attribute -> attribute.getApplyable().equals(applyable)).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package exopandora.worldhandler.builder.types;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class Coordinate
|
||||
{
|
||||
private double value;
|
||||
private boolean relative;
|
||||
|
||||
public Coordinate()
|
||||
{
|
||||
this(0, true);
|
||||
}
|
||||
|
||||
public Coordinate(double value)
|
||||
{
|
||||
this(value, false);
|
||||
}
|
||||
|
||||
public Coordinate(double value, boolean relative)
|
||||
{
|
||||
this.relative = relative;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public void setValue(double value)
|
||||
{
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public double getValue()
|
||||
{
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public void setRelative(boolean relative)
|
||||
{
|
||||
this.relative = relative;
|
||||
}
|
||||
|
||||
public boolean isRelative()
|
||||
{
|
||||
return this.relative;
|
||||
}
|
||||
|
||||
public static Coordinate valueOf(String value)
|
||||
{
|
||||
if(value.startsWith("~"))
|
||||
{
|
||||
return new Coordinate(Double.parseDouble(value.substring(1)), true);
|
||||
}
|
||||
|
||||
return new Coordinate(Double.parseDouble(value), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return String.valueOf(this.relative ? (this.value != 0 ? "~" + this.value : "~") : this.value);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package exopandora.worldhandler.builder.types;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class Level
|
||||
{
|
||||
private int level;
|
||||
|
||||
public Level()
|
||||
{
|
||||
this(0);
|
||||
}
|
||||
|
||||
public Level(int level)
|
||||
{
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public int getLevel()
|
||||
{
|
||||
return this.level;
|
||||
}
|
||||
|
||||
public void setLevel(int level)
|
||||
{
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public static Level valueOf(String value)
|
||||
{
|
||||
if(value != null)
|
||||
{
|
||||
if(value.matches("[-]?[0-9]+[Ll]?"))
|
||||
{
|
||||
return new Level(Integer.valueOf(value.replaceAll("[lL]$", "")));
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return this.level + "L";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package exopandora.worldhandler.builder.types;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class TargetSelector
|
||||
{
|
||||
private final Map<String, Object> values = new HashMap<String, Object>();
|
||||
private static final String REGEX = "@e\\[(.*)\\]";
|
||||
|
||||
public void set(String id, Object value)
|
||||
{
|
||||
this.values.put(id.toLowerCase(), value);
|
||||
}
|
||||
|
||||
public <T> T get(String id)
|
||||
{
|
||||
return (T) this.values.get(id);
|
||||
}
|
||||
|
||||
public Object remove(String id)
|
||||
{
|
||||
return this.values.remove(id.toLowerCase());
|
||||
}
|
||||
|
||||
public static TargetSelector valueOf(String input)
|
||||
{
|
||||
if(input.matches(REGEX));
|
||||
{
|
||||
TargetSelector result = new TargetSelector();
|
||||
|
||||
for(String keys : input.replaceFirst(REGEX, "$1").split(","))
|
||||
{
|
||||
String[] pair = keys.split("=");
|
||||
|
||||
if(pair.length > 1)
|
||||
{
|
||||
result.set(pair[0], pair[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new TargetSelector();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "@e[" + String.join(",", this.values.entrySet().stream().map(entry -> entry.getKey() + "=" + entry.getValue().toString()).collect(Collectors.toList())) + "]";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package exopandora.worldhandler.builder.types;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.nbt.JsonToNBT;
|
||||
import net.minecraft.nbt.NBTException;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public enum Type
|
||||
{
|
||||
SHORT(Short::valueOf),
|
||||
BYTE(Byte::valueOf),
|
||||
INT(Integer::valueOf),
|
||||
FLOAT(Float::valueOf),
|
||||
DOUBLE(Double::valueOf),
|
||||
LONG(Long::valueOf),
|
||||
BOOLEAN(Boolean::valueOf),
|
||||
STRING(String::valueOf),
|
||||
RESOURCE_LOCATION(Type::parseResourceLocation),
|
||||
NBT(Type::parseNBTTagCompound),
|
||||
COORDINATE(Coordinate::valueOf),
|
||||
TARGET_SELECTOR(TargetSelector::valueOf),
|
||||
LEVEL(Level::valueOf);
|
||||
|
||||
private final Function<String, Object> parser;
|
||||
|
||||
private Type(Function<String, Object> parser)
|
||||
{
|
||||
this.parser = parser;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public <T> T parse(String object)
|
||||
{
|
||||
return (T) this.parser.apply(object);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static ResourceLocation parseResourceLocation(String value)
|
||||
{
|
||||
return value != null ? new ResourceLocation(value) : null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static NBTTagCompound parseNBTTagCompound(String value)
|
||||
{
|
||||
if(value != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
return JsonToNBT.getTagFromJson(value);
|
||||
}
|
||||
catch(NBTException nbtexception)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user