Update to 1.13.2

This commit is contained in:
Marcel Konrad
2019-04-02 18:17:54 +02:00
parent eafef4ae54
commit e86d4f5c0c
204 changed files with 10130 additions and 9348 deletions

View File

@@ -9,16 +9,19 @@ import javax.annotation.Nullable;
import exopandora.worldhandler.WorldHandler;
import exopandora.worldhandler.builder.Syntax.SyntaxEntry;
import exopandora.worldhandler.builder.types.Coordinate;
import exopandora.worldhandler.builder.types.Level;
import exopandora.worldhandler.builder.types.BlockResourceLocation;
import exopandora.worldhandler.builder.types.CoordinateDouble;
import exopandora.worldhandler.builder.types.CoordinateInt;
import exopandora.worldhandler.builder.types.GreedyString;
import exopandora.worldhandler.builder.types.ItemResourceLocation;
import exopandora.worldhandler.builder.types.TargetSelector;
import exopandora.worldhandler.builder.types.Type;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public abstract class CommandBuilder implements ICommandBuilderSyntax
{
private List<Entry<SyntaxEntry, String>> command;
@@ -33,6 +36,11 @@ public abstract class CommandBuilder implements ICommandBuilderSyntax
this.set(index, node != null ? (node.isEmpty() ? null : node) : null, Type.STRING);
}
protected void setNode(int index, GreedyString node)
{
this.set(index, node != null ? (node.isEmpty() ? null : node) : null, Type.GREEDY_STRING);
}
protected void setNode(int index, boolean node)
{
this.set(index, node, Type.BOOLEAN);
@@ -73,14 +81,14 @@ public abstract class CommandBuilder implements ICommandBuilderSyntax
this.set(index, node, Type.RESOURCE_LOCATION);
}
protected void setNode(int index, NBTTagCompound nbt)
protected void setNode(int index, CoordinateInt coordinate)
{
this.set(index, nbt, Type.NBT);
this.set(index, coordinate, Type.COORDINATE_INT);
}
protected void setNode(int index, Coordinate coordinate)
protected void setNode(int index, CoordinateDouble coordinate)
{
this.set(index, coordinate, Type.COORDINATE);
this.set(index, coordinate, Type.COORDINATE_DOUBLE);
}
protected void setNode(int index, TargetSelector target)
@@ -88,9 +96,19 @@ public abstract class CommandBuilder implements ICommandBuilderSyntax
this.set(index, target, Type.TARGET_SELECTOR);
}
protected void setNode(int index, Level level)
protected void setNode(int index, ItemResourceLocation resource)
{
this.set(index, level, Type.LEVEL);
this.set(index, resource != null ? resource.get() : null, Type.ITEM_RESOURCE_LOCATION);
}
protected void setNode(int index, BlockResourceLocation resource)
{
this.set(index, resource != null ? resource.get() : null, Type.BLOCK_RESOURCE_LOCATION);
}
protected void setNode(int index, NBTTagCompound nbt)
{
this.set(index, nbt, Type.NBT);
}
private void set(int index, Object value, Type type)
@@ -127,6 +145,12 @@ public abstract class CommandBuilder implements ICommandBuilderSyntax
return this.get(index, Type.STRING);
}
@Nullable
protected String getNodeAsGreedyString(int index)
{
return this.get(index, Type.GREEDY_STRING);
}
protected boolean getNodeAsBoolean(int index)
{
return this.get(index, Type.BOOLEAN);
@@ -162,9 +186,14 @@ public abstract class CommandBuilder implements ICommandBuilderSyntax
return this.get(index, Type.LONG);
}
protected Coordinate getNodeAsCoordinate(int index)
protected CoordinateInt getNodeAsCoordinateInt(int index)
{
return this.get(index, Type.COORDINATE);
return this.get(index, Type.COORDINATE_INT);
}
protected CoordinateDouble getNodeAsCoordinateDouble(int index)
{
return this.get(index, Type.COORDINATE_DOUBLE);
}
@Nullable
@@ -179,9 +208,15 @@ public abstract class CommandBuilder implements ICommandBuilderSyntax
}
@Nullable
protected Level getNodeAsLevel(int index)
protected ItemResourceLocation getNodeAsItemResourceLocation(int index)
{
return this.get(index, Type.LEVEL);
return this.get(index, Type.ITEM_RESOURCE_LOCATION);
}
@Nullable
protected BlockResourceLocation getNodeAsBlockResourceLocation(int index)
{
return this.get(index, Type.BLOCK_RESOURCE_LOCATION);
}
@Nullable

View File

@@ -4,12 +4,12 @@ import java.util.ArrayList;
import java.util.List;
import exopandora.worldhandler.builder.component.IBuilderComponent;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.INBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public abstract class CommandBuilderNBT extends CommandBuilder implements ICommandBuilderNBT
{
private final List<IBuilderComponent> TAG_TO_COMPONENT = new ArrayList<IBuilderComponent>();
@@ -17,14 +17,32 @@ public abstract class CommandBuilderNBT extends CommandBuilder implements IComma
@Override
public String toCommand()
{
this.setNBT(this.buildNBT());
return this.toCommand(true);
}
public String toCommand(boolean rebuildNBT)
{
if(rebuildNBT)
{
this.setNBT(this.buildNBT());
}
return super.toCommand();
}
@Override
public String toActualCommand()
{
this.setNBT(this.buildNBT());
return this.toActualCommand(true);
}
public String toActualCommand(boolean rebuildNBT)
{
if(rebuildNBT)
{
this.setNBT(this.buildNBT());
}
return super.toActualCommand();
}
@@ -34,7 +52,7 @@ public abstract class CommandBuilderNBT extends CommandBuilder implements IComma
for(IBuilderComponent component : this.TAG_TO_COMPONENT)
{
NBTBase serialized = component.serialize();
INBTBase serialized = component.serialize();
if(serialized != null)
{
@@ -45,7 +63,7 @@ public abstract class CommandBuilderNBT extends CommandBuilder implements IComma
}
}
if(nbt.hasNoTags())
if(nbt.isEmpty())
{
return null;
}

View File

@@ -2,10 +2,10 @@ package exopandora.worldhandler.builder;
import com.mojang.realmsclient.gui.ChatFormatting;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public class CommandString
{
private final StringBuilder command = new StringBuilder("/");

View File

@@ -1,9 +1,9 @@
package exopandora.worldhandler.builder;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public interface ICommandBuilder
{
static final int MAX_COMMAND_LENGTH = 256;

View File

@@ -1,10 +1,10 @@
package exopandora.worldhandler.builder;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public interface ICommandBuilderNBT extends ICommandBuilder
{
void setNBT(NBTTagCompound nbt);

View File

@@ -1,9 +1,9 @@
package exopandora.worldhandler.builder;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public interface ICommandBuilderSyntax extends ICommandBuilder
{
String getCommandName();

View File

@@ -4,10 +4,10 @@ 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;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public class Syntax
{
private List<SyntaxEntry> syntax = new ArrayList<SyntaxEntry>();
@@ -41,7 +41,7 @@ public class Syntax
return this.syntax;
}
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public static class SyntaxEntry
{
private final String key;

View File

@@ -2,14 +2,14 @@ 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;
import net.minecraft.nbt.INBTBase;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public interface IBuilderComponent
{
@Nullable
NBTBase serialize();
INBTBase serialize();
String getTag();
}

View File

@@ -7,10 +7,10 @@ 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;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public abstract class ComponentAttribute implements IBuilderComponent
{
protected Map<EnumAttributes, Double> attributes = new HashMap<EnumAttributes, Double>();

View File

@@ -1,28 +1,28 @@
package exopandora.worldhandler.builder.component.abstr;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
import exopandora.worldhandler.builder.component.IBuilderComponent;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.INBTBase;
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;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.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()));
protected final Map<Potion, PotionMetadata> potions = new HashMap<Potion, PotionMetadata>();
@Override
@Nullable
public NBTBase serialize()
public INBTBase serialize()
{
NBTTagList list = new NBTTagList();
@@ -36,138 +36,95 @@ public abstract class ComponentPotion implements IBuilderComponent
compound.setByte("Id", (byte) Potion.getIdFromPotion(entry.getKey()));
compound.setByte("Amplifier", (byte) (potion.getAmplifier() - 1));
compound.setInteger("Duration", potion.getDurationTicks() > 0 ? Math.min(potion.getDurationTicks(), 1000000) : 1000000);
compound.setInt("Duration", Math.min(potion.toTicks(), 1000000));
compound.setBoolean("Ambient", potion.getAmbient());
compound.setBoolean("ShowParticles", potion.getShowParticles());
list.appendTag(compound);
list.add(compound);
}
}
if(!list.hasNoTags())
if(list.isEmpty())
{
return list;
return null;
}
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));
return list;
}
public void setAmplifier(Potion potion, byte amplifier)
{
if(this.potions.containsKey(potion))
{
this.potions.get(potion).setAmplifier(amplifier);
}
this.getMetadata(potion).setAmplifier(amplifier);
}
public byte getAmplifier(Potion potion)
{
if(this.potions.containsKey(potion))
{
return this.potions.get(potion).getAmplifier();
}
return 0;
return this.getMetadata(potion).getAmplifier();
}
public void setSeconds(Potion potion, int seconds)
{
if(this.potions.containsKey(potion))
{
this.potions.get(potion).setSeconds(seconds);;
}
this.getMetadata(potion).setSeconds(seconds);
}
public int getSeconds(Potion potion)
{
if(this.potions.containsKey(potion))
{
return this.potions.get(potion).getSeconds();
}
return 0;
return this.getMetadata(potion).getSeconds();
}
public void setMinutes(Potion potion, int minutes)
{
if(this.potions.containsKey(potion))
{
this.potions.get(potion).setSeconds(minutes);;
}
this.getMetadata(potion).setMinutes(minutes);
}
public int getMinutes(Potion potion)
{
if(this.potions.containsKey(potion))
{
return this.potions.get(potion).getMinutes();
}
return 0;
return this.getMetadata(potion).getMinutes();
}
public void setHours(Potion potion, int hours)
{
if(this.potions.containsKey(potion))
{
this.potions.get(potion).setSeconds(hours);;
}
this.getMetadata(potion).setHours(hours);
}
public int getHours(Potion potion)
{
if(this.potions.containsKey(potion))
{
return this.potions.get(potion).getHours();
}
return 0;
return this.getMetadata(potion).getHours();
}
public void setShowParticles(Potion potion, boolean showParticles)
{
if(this.potions.containsKey(potion))
{
this.potions.get(potion).setShowParticles(showParticles);
}
this.getMetadata(potion).setShowParticles(showParticles);
}
public boolean getShowParticles(Potion potion)
{
if(this.potions.containsKey(potion))
{
return this.potions.get(potion).getShowParticles();
}
return true;
return this.getMetadata(potion).getShowParticles();
}
public void setAmbient(Potion potion, boolean ambient)
{
if(this.potions.containsKey(potion))
{
this.potions.get(potion).setAmbient(ambient);
}
this.getMetadata(potion).setAmbient(ambient);
}
public boolean getAmbient(Potion potion)
{
if(this.potions.containsKey(potion))
return this.getMetadata(potion).getAmbient();
}
private PotionMetadata getMetadata(Potion potion)
{
return this.potions.get(this.validate(potion));
}
private Potion validate(Potion potion)
{
if(!this.potions.containsKey(potion))
{
return this.potions.get(potion).getAmbient();
this.potions.put(potion, new PotionMetadata());
}
return false;
return potion;
}
public Set<Potion> getPotions()
@@ -175,12 +132,6 @@ public abstract class ComponentPotion implements IBuilderComponent
return this.potions.keySet();
}
@Nullable
public PotionMetadata get(Potion potion)
{
return this.potions.get(potion);
}
public void remove(Potion potion)
{
this.potions.remove(potion);

View File

@@ -1,9 +1,9 @@
package exopandora.worldhandler.builder.component.abstr;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public class PotionMetadata
{
private byte amplifier;
@@ -88,22 +88,22 @@ public class PotionMetadata
this.ambient = ambient;
}
public int getDurationTicks()
public int toTicks()
{
return PotionMetadata.getDurationTicks(this.seconds, this.minutes, this.hours);
return PotionMetadata.toTicks(this.seconds, this.minutes, this.hours);
}
public int getDurationSeconds()
public int toSeconds()
{
return PotionMetadata.getDurationSeconds(this.seconds, this.minutes, this.hours);
return PotionMetadata.toSeconds(this.seconds, this.minutes, this.hours);
}
public static int getDurationTicks(int seconds, int minutes, int hours)
public static int toTicks(int seconds, int minutes, int hours)
{
return seconds * 20 + minutes * 1200 + hours * 72000;
}
public static int getDurationSeconds(int seconds, int minutes, int hours)
public static int toSeconds(int seconds, int minutes, int hours)
{
return seconds + minutes * 60 + hours * 3600;
}
@@ -143,5 +143,11 @@ public class PotionMetadata
this.ambient = ambient;
return this;
}
@Override
public String toString()
{
return "PotionMetadata [amplifier=" + amplifier + ", seconds=" + seconds + ", minutes=" + minutes + ", hours=" + hours + ", showParticles=" + showParticles + ", ambient=" + ambient + "]";
}
}

View File

@@ -8,13 +8,13 @@ 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.INBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public class ComponentAttributeItem extends ComponentAttribute
{
public ComponentAttributeItem(Function<EnumAttributes, Boolean> applyable)
@@ -24,7 +24,7 @@ public class ComponentAttributeItem extends ComponentAttribute
@Override
@Nullable
public NBTBase serialize()
public INBTBase serialize()
{
NBTTagList attributes = new NBTTagList();
@@ -37,20 +37,20 @@ public class ComponentAttributeItem extends ComponentAttribute
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.setInt("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);
attributes.add(attribute);
}
}
if(!attributes.hasNoTags())
if(attributes.isEmpty())
{
return attributes;
return null;
}
return null;
return attributes;
}
@Override

View File

@@ -7,13 +7,13 @@ 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.INBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public class ComponentAttributeMob extends ComponentAttribute
{
public ComponentAttributeMob(Function<EnumAttributes, Boolean> applyable)
@@ -23,7 +23,7 @@ public class ComponentAttributeMob extends ComponentAttribute
@Override
@Nullable
public NBTBase serialize()
public INBTBase serialize()
{
NBTTagList attributes = new NBTTagList();
@@ -36,16 +36,16 @@ public class ComponentAttributeMob extends ComponentAttribute
attribute.setString("Name", entry.getKey().getAttribute());
attribute.setDouble("Base", entry.getKey().calculate(entry.getValue()));
attributes.appendTag(attribute);
attributes.add(attribute);
}
}
if(!attributes.hasNoTags())
if(attributes.isEmpty())
{
return attributes;
return null;
}
return null;
return attributes;
}
@Override

View File

@@ -2,21 +2,23 @@ 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.INBTBase;
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;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentString;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public class ComponentDisplay implements IBuilderComponent
{
private ColoredString name = new ColoredString();
private String[] lore = new String[2];
@Override
public NBTBase serialize()
public INBTBase serialize()
{
NBTTagCompound display = new NBTTagCompound();
@@ -24,7 +26,7 @@ public class ComponentDisplay implements IBuilderComponent
if(name != null && !name.isEmpty())
{
display.setString("Name", this.name.toString());
display.setString("Name", ITextComponent.Serializer.toJson(new TextComponentString(this.name.toString())));
}
NBTTagList lore = new NBTTagList();
@@ -33,16 +35,16 @@ public class ComponentDisplay implements IBuilderComponent
{
if(this.lore[x] != null && !this.lore[x].isEmpty())
{
lore.appendTag(new NBTTagString(this.lore[x]));
lore.add(new NBTTagString(this.lore[x]));
}
}
if(!lore.hasNoTags())
if(!lore.isEmpty())
{
display.setTag("Lore", lore);
}
if(!display.hasNoTags())
if(!display.isEmpty())
{
return display;
}

View File

@@ -1,28 +1,29 @@
package exopandora.worldhandler.builder.component.impl;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
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.INBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.registries.ForgeRegistries;
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public class ComponentEnchantment implements IBuilderComponent
{
private Map<Enchantment, Short> enchantments = Enchantment.REGISTRY.getKeys().stream().collect(Collectors.toMap(Enchantment.REGISTRY::getObject, key -> (short) 0));
private Map<Enchantment, Short> enchantments = new HashMap<Enchantment, Short>();
@Override
@Nullable
public NBTBase serialize()
public INBTBase serialize()
{
NBTTagList enchantments = new NBTTagList();
@@ -32,24 +33,31 @@ public class ComponentEnchantment implements IBuilderComponent
{
NBTTagCompound enchantment = new NBTTagCompound();
enchantment.setShort("id", (short) Enchantment.getEnchantmentID(entry.getKey()));
enchantment.setString("id", ForgeRegistries.ENCHANTMENTS.getKey(entry.getKey()).toString());
enchantment.setShort("lvl", entry.getValue());
enchantments.appendTag(enchantment);
enchantments.add(enchantment);
}
}
if(!enchantments.hasNoTags())
if(enchantments.isEmpty())
{
return enchantments;
return null;
}
return null;
return enchantments;
}
public void setLevel(Enchantment enchantment, short level)
{
this.enchantments.put(enchantment, level);
if(level == 0)
{
this.enchantments.remove(enchantment);
}
else
{
this.enchantments.put(enchantment, level);
}
}
public short getLevel(Enchantment enchantment)
@@ -65,6 +73,6 @@ public class ComponentEnchantment implements IBuilderComponent
@Override
public String getTag()
{
return "ench";
return "Enchantments";
}
}

View File

@@ -1,10 +1,10 @@
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;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public class ComponentPotionItem extends ComponentPotion
{
@Override

View File

@@ -1,10 +1,10 @@
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;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public class ComponentPotionMob extends ComponentPotion
{
@Override

View File

@@ -7,45 +7,20 @@ import javax.annotation.Nullable;
import org.apache.commons.lang3.StringUtils;
import exopandora.worldhandler.builder.component.IBuilderComponent;
import exopandora.worldhandler.helper.EntityHelper;
import exopandora.worldhandler.helper.ResourceHelper;
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.entity.EntityType;
import net.minecraft.nbt.INBTBase;
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;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.registries.ForgeRegistries;
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public class ComponentSummon implements IBuilderComponent
{
private final Random random = new Random();
@@ -86,7 +61,7 @@ public class ComponentSummon implements IBuilderComponent
}
@Override
public NBTBase serialize()
public INBTBase serialize()
{
if(this.name != null)
{
@@ -128,7 +103,7 @@ public class ComponentSummon implements IBuilderComponent
if(this.entity != null)
{
if(this.entity.equals(EntityHelper.getResourceLocation(EntityZombie.class)))
if(this.entity.equals(EntityType.ZOMBIE.getRegistryName()))
{
if(StringUtils.containsIgnoreCase(this.name, "Baby"))
{
@@ -136,30 +111,30 @@ public class ComponentSummon implements IBuilderComponent
return new NBTTagByte((byte) 1);
}
}
else if(this.entity.equals(EntityHelper.getResourceLocation(EntityChicken.class)))
else if(this.entity.equals(EntityType.CHICKEN.getRegistryName()))
{
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.setString("id", EntityType.ZOMBIE.getRegistryName().toString());
passenger.setBoolean("IsBaby", true);
list.appendTag(passenger);
list.add(passenger);
this.tag = "Passengers";
return list;
}
}
else if(this.entity.equals(EntityHelper.getResourceLocation(EntitySpider.class)))
else if(this.entity.equals(EntityType.SPIDER.getRegistryName()))
{
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);
passenger.setString("id", EntityType.SKELETON.getRegistryName().toString());
list.add(passenger);
this.tag = "Passengers";
return list;
@@ -180,116 +155,117 @@ public class ComponentSummon implements IBuilderComponent
@Nullable
public static ResourceLocation resolve(String entityName)
{
String entity = entityName.replaceAll("_| ", "");
String name = ResourceHelper.stripToResourceLocation(entityName);
for(ResourceLocation location : EntityList.ENTITY_EGGS.keySet())
for(EntityType<?> type : ForgeRegistries.ENTITIES.getValues())
{
if(entityName.equalsIgnoreCase(I18n.format("entity." + EntityHelper.getEntityName(location) + ".name")))
if(type.isSummonable() && entityName.equalsIgnoreCase(I18n.format(type.getTranslationKey())))
{
entity = location.getResourcePath();
break;
return type.getRegistryName();
}
}
String entity = name.replaceAll("_", "");
if(entity.equalsIgnoreCase("RedCow"))
{
return EntityHelper.getResourceLocation(EntityMooshroom.class);
return EntityType.MOOSHROOM.getRegistryName();
}
else if(entity.equalsIgnoreCase("ChickenJockey"))
{
return EntityHelper.getResourceLocation(EntityChicken.class);
return EntityType.CHICKEN.getRegistryName();
}
else if(entity.equalsIgnoreCase("Pigman") || entity.equalsIgnoreCase("ZombiePig") || entity.equalsIgnoreCase("ZombiePigman"))
{
return EntityHelper.getResourceLocation(EntityPigZombie.class);
return EntityType.ZOMBIE_PIGMAN.getRegistryName();
}
else if(entity.equalsIgnoreCase("Wither"))
{
return EntityHelper.getResourceLocation(EntityWither.class);
return EntityType.WITHER.getRegistryName();
}
else if(entity.equalsIgnoreCase("Dog"))
{
return EntityHelper.getResourceLocation(EntityWolf.class);
return EntityType.WOLF.getRegistryName();
}
else if(entity.equalsIgnoreCase("Dragon"))
{
return EntityHelper.getResourceLocation(EntityDragon.class);
return EntityType.ENDER_DRAGON.getRegistryName();
}
else if(entity.equalsIgnoreCase("minecraft:SnowGolem"))
{
return EntityHelper.getResourceLocation(EntitySnowman.class);
return EntityType.SNOW_GOLEM.getRegistryName();
}
else if(entity.equalsIgnoreCase("Horse") || entity.equalsIgnoreCase("ZombieHorse") || entity.equalsIgnoreCase("SkeletonHorse"))
{
return EntityHelper.getResourceLocation(EntityHorse.class);
return EntityType.HORSE.getRegistryName();
}
else if(entity.equalsIgnoreCase("LavaCube")|| entity.equalsIgnoreCase("MagmaSlime") || entity.equalsIgnoreCase("MagmaCube"))
{
return EntityHelper.getResourceLocation(EntityMagmaCube.class);
return EntityType.MAGMA_CUBE.getRegistryName();
}
else if(entity.equalsIgnoreCase("SpiderJockey"))
{
return EntityHelper.getResourceLocation(EntitySpider.class);
return EntityType.SPIDER.getRegistryName();
}
else if(entity.equalsIgnoreCase("IronGolem"))
{
return EntityHelper.getResourceLocation(EntityIronGolem.class);
return EntityType.IRON_GOLEM.getRegistryName();
}
else if(entity.equalsIgnoreCase("Ozelot") || entity.equals("Ocelot") || entity.equalsIgnoreCase("Cat") || entity.equalsIgnoreCase("Kitty") || entity.equalsIgnoreCase("Kitten"))
{
return EntityHelper.getResourceLocation(EntityOcelot.class);
return EntityType.OCELOT.getRegistryName();
}
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);
return EntityType.VILLAGER.getRegistryName();
}
else if(entity.equalsIgnoreCase("Octopus") || entity.equalsIgnoreCase("Kraken"))
{
return EntityHelper.getResourceLocation(EntitySquid.class);
return EntityType.SQUID.getRegistryName();
}
else if(entity.equalsIgnoreCase("Exwife"))
{
return EntityHelper.getResourceLocation(EntityGhast.class);
return EntityType.GHAST.getRegistryName();
}
else if(entity.equalsIgnoreCase("TNTMinecart"))
{
return EntityHelper.getResourceLocation(EntityMinecartTNT.class);
return EntityType.TNT_MINECART.getRegistryName();
}
else if(entity.equalsIgnoreCase("Minecart"))
{
return EntityHelper.getResourceLocation(EntityMinecart.class);
return EntityType.MINECART.getRegistryName();
}
else if(entity.equalsIgnoreCase("HopperMinecart"))
{
return EntityHelper.getResourceLocation(EntityMinecartHopper.class);
return EntityType.HOPPER_MINECART.getRegistryName();
}
else if(entity.equalsIgnoreCase("ChestMinecart"))
{
return EntityHelper.getResourceLocation(EntityMinecartChest.class);
return EntityType.CHEST_MINECART.getRegistryName();
}
else if(entity.equalsIgnoreCase("SpawnerMinecart"))
{
return EntityHelper.getResourceLocation(EntityMinecartMobSpawner.class);
return EntityType.SPAWNER_MINECART.getRegistryName();
}
else if(entity.equalsIgnoreCase("FurnaceMinecart"))
{
return EntityHelper.getResourceLocation(EntityMinecartFurnace.class);
return EntityType.FURNACE_MINECART.getRegistryName();
}
else if(entity.equalsIgnoreCase("CommandBlockMinecart") || entity.equalsIgnoreCase("MinecartCommand") || entity.equalsIgnoreCase("CommandMinecart"))
{
return EntityHelper.getResourceLocation(EntityMinecartCommandBlock.class);
return EntityType.COMMAND_BLOCK_MINECART.getRegistryName();
}
else if(entity.equalsIgnoreCase("Wizard"))
{
return EntityHelper.getResourceLocation(EntityEvoker.class);
return EntityType.EVOKER.getRegistryName();
}
else if(entity.equalsIgnoreCase("Johnny"))
{
return EntityHelper.getResourceLocation(EntityVindicator.class);
return EntityType.VINDICATOR.getRegistryName();
}
else if(entity.equalsIgnoreCase("BabyZombie"))
{
return EntityHelper.getResourceLocation(EntityZombie.class);
return EntityType.ZOMBIE.getRegistryName();
}
if(entity == null || entity.isEmpty())
@@ -297,6 +273,6 @@ public class ComponentSummon implements IBuilderComponent
return null;
}
return new ResourceLocation(entity);
return ResourceHelper.stringToResourceLocation(name);
}
}

View File

@@ -1,12 +1,13 @@
package exopandora.worldhandler.builder.component.impl;
import java.util.Collection;
import java.util.function.Function;
import javax.annotation.Nullable;
import exopandora.worldhandler.WorldHandler;
import exopandora.worldhandler.builder.component.IBuilderComponent;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.INBTBase;
import net.minecraft.nbt.NBTTagByte;
import net.minecraft.nbt.NBTTagByteArray;
import net.minecraft.nbt.NBTTagDouble;
@@ -16,24 +17,24 @@ 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;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public class ComponentTag<T> implements IBuilderComponent
{
private final Function<T, NBTBase> serializer;
private final Function<T, INBTBase> serializer;
private final String tag;
private T value;
public ComponentTag(String tag, T value, Function<T, NBTBase> serializer)
public ComponentTag(String tag, T value, Function<T, INBTBase> serializer)
{
this.tag = tag;
this.value = value;
this.serializer = serializer;
}
public ComponentTag(String tag, Function<T, NBTBase> serializer)
public ComponentTag(String tag, Function<T, INBTBase> serializer)
{
this(tag, null, serializer);
}
@@ -61,7 +62,7 @@ public class ComponentTag<T> implements IBuilderComponent
@Override
@Nullable
public NBTBase serialize()
public INBTBase serialize()
{
if(this.value != null)
{
@@ -80,16 +81,19 @@ public class ComponentTag<T> implements IBuilderComponent
return new NBTTagString(string);
}
else if(this.value instanceof NBTBase)
else if(this.value instanceof INBTBase)
{
NBTBase base = (NBTBase) this.value;
if(base.hasNoTags())
if(this.value instanceof Collection<?>)
{
return null;
Collection<?> collection = (Collection<?>) this.value;
if(collection.isEmpty())
{
return null;
}
}
return (NBTBase) this.value;
return (INBTBase) this.value;
}
else if(this.value instanceof Integer)
{

View File

@@ -7,10 +7,10 @@ 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;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public class BuilderAdvancement extends CommandBuilder
{
public BuilderAdvancement(EnumMode mode)
@@ -34,7 +34,7 @@ public class BuilderAdvancement extends CommandBuilder
@Nullable
public EnumActionType getActionType()
{
return EnumHelper.valueOf(EnumActionType.class, this.getNodeAsString(1));
return EnumHelper.valueOf(this.getNodeAsString(1), EnumActionType.class);
}
public void setPlayer(String player)
@@ -56,14 +56,14 @@ public class BuilderAdvancement extends CommandBuilder
@Nullable
public EnumMode getMode()
{
return EnumHelper.valueOf(EnumMode.class, this.getNodeAsString(2));
return EnumHelper.valueOf(this.getNodeAsString(2), EnumMode.class);
}
public void setAdvancement(ResourceLocation advancement)
{
this.setNode(3, advancement);
}
@Nullable
public ResourceLocation getAdvancement()
{
@@ -98,8 +98,8 @@ public class BuilderAdvancement extends CommandBuilder
return syntax;
}
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public static enum EnumActionType
{
GRANT,
@@ -112,7 +112,7 @@ public class BuilderAdvancement extends CommandBuilder
}
}
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public static enum EnumMode
{
ONLY,

View File

@@ -1,37 +0,0 @@
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;
}
}

View File

@@ -1,49 +1,60 @@
package exopandora.worldhandler.builder.impl;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
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;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public class BuilderButcher extends CommandBuilder
{
private final TargetSelector targetSelector;
private final TargetSelector targetSelector = new TargetSelector();
public BuilderButcher()
{
this(new ResourceLocation("<entity_name>"), 0);
this("<entity_name>", 0);
}
public BuilderButcher(ResourceLocation entity, int radius)
public BuilderButcher(ResourceLocation entity, int distance)
{
this(entity.toString(), distance);
}
private BuilderButcher(String entity, int distance)
{
this.targetSelector = new TargetSelector();
this.setEntity(entity);
this.setRadius(radius);
this.setDistance(distance);
}
public void setRadius(int radius)
public void setDistance(int distance)
{
this.targetSelector.set("r", radius);
this.targetSelector.set("distance", "0.." + distance);
this.setNode(0, this.targetSelector);
}
@Nonnull
public int getRadius()
public int getDistance()
{
return this.targetSelector.<Integer>get("r");
return Integer.parseInt(this.targetSelector.<String>get("distance").substring(3));
}
private void setEntity(String entity)
{
if(entity != null)
{
this.targetSelector.set("type", entity);
}
this.setNode(0, this.targetSelector);
}
public void setEntity(ResourceLocation entity)
{
this.targetSelector.set("type", entity.toString());
this.setNode(0, this.targetSelector);
this.setEntity(entity.toString());
}
@Nonnull

View File

@@ -2,21 +2,22 @@ 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.Coordinate.CoordinateType;
import exopandora.worldhandler.builder.types.CoordinateInt;
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;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public class BuilderClone extends BuilderDoubleBlockPos
{
public BuilderClone()
{
this.setX(new Coordinate());
this.setY(new Coordinate());
this.setZ(new Coordinate());
this.setX(new CoordinateInt(CoordinateType.GLOBAL));
this.setY(new CoordinateInt(CoordinateType.GLOBAL));
this.setZ(new CoordinateInt(CoordinateType.GLOBAL));
this.setMask(EnumMask.values()[0]);
this.setNode(10, "force");
}
@@ -28,49 +29,49 @@ public class BuilderClone extends BuilderDoubleBlockPos
this.setZ(pos.getZ());
}
public void setX(float x)
public void setX(int x)
{
this.setX(new Coordinate(x));
this.setX(new CoordinateInt(x));
}
public void setY(float y)
public void setY(int y)
{
this.setY(new Coordinate(y));
this.setY(new CoordinateInt(y));
}
public void setZ(float z)
public void setZ(int z)
{
this.setZ(new Coordinate(z));
this.setZ(new CoordinateInt(z));
}
public void setX(Coordinate x)
public void setX(CoordinateInt x)
{
this.setNode(6, x);
}
public void setY(Coordinate y)
public void setY(CoordinateInt y)
{
this.setNode(7, y);
}
public void setZ(Coordinate z)
public void setZ(CoordinateInt z)
{
this.setNode(8, z);
}
public Coordinate getXCoordiante()
public CoordinateInt getXCoordiante()
{
return this.getNodeAsCoordinate(6);
return this.getNodeAsCoordinateInt(6);
}
public Coordinate getYCoordiante()
public CoordinateInt getYCoordiante()
{
return this.getNodeAsCoordinate(7);
return this.getNodeAsCoordinateInt(7);
}
public Coordinate getZCoordiante()
public CoordinateInt getZCoordiante()
{
return this.getNodeAsCoordinate(8);
return this.getNodeAsCoordinateInt(8);
}
public double getX()
@@ -100,7 +101,7 @@ public class BuilderClone extends BuilderDoubleBlockPos
public EnumMask getMask()
{
return EnumHelper.valueOf(EnumMask.class, this.getNodeAsString(9));
return EnumHelper.valueOf(this.getNodeAsString(9), EnumMask.class);
}
@Override
@@ -114,22 +115,22 @@ public class BuilderClone extends BuilderDoubleBlockPos
{
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);
syntax.addRequired("x1", Type.COORDINATE_INT);
syntax.addRequired("y1", Type.COORDINATE_INT);
syntax.addRequired("z1", Type.COORDINATE_INT);
syntax.addRequired("x2", Type.COORDINATE_INT);
syntax.addRequired("y2", Type.COORDINATE_INT);
syntax.addRequired("z2", Type.COORDINATE_INT);
syntax.addRequired("x", Type.COORDINATE_INT);
syntax.addRequired("y", Type.COORDINATE_INT);
syntax.addRequired("z", Type.COORDINATE_INT);
syntax.addOptional("mask", Type.STRING);
syntax.addOptional("filter", Type.STRING);
return syntax;
}
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public static enum EnumMask
{
REPLACE,

View File

@@ -10,10 +10,10 @@ 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;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public class BuilderCustomItem extends BuilderGive
{
private final ComponentAttributeItem attribute;

View File

@@ -0,0 +1,323 @@
package exopandora.worldhandler.builder.impl;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import exopandora.worldhandler.builder.Syntax;
import exopandora.worldhandler.builder.impl.abstr.BuilderBlockPos;
import exopandora.worldhandler.builder.types.CoordinateInt;
import exopandora.worldhandler.builder.types.TargetSelector;
import exopandora.worldhandler.builder.types.Type;
import exopandora.worldhandler.helper.EnumHelper;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public class BuilderData extends BuilderBlockPos
{
private final TargetSelector targetSelector = new TargetSelector();
public BuilderData()
{
super(2);
}
public BuilderData(EnumMode mode, ResourceLocation entity, NBTTagCompound nbt)
{
this();
this.setMode(mode);
this.setEntity(entity);
this.setNBT(nbt);
}
public BuilderData(EnumMode mode, BlockPos pos, NBTTagCompound nbt)
{
this();
this.setMode(mode);
this.setPosition(pos);
this.setNBT(nbt);
}
public void setMode(EnumMode mode)
{
EnumTarget target = this.getTarget();
this.updateSyntax(this.getSyntax(mode, target));
this.setMode0(mode);
this.setTarget0(target);
}
private void setMode0(EnumMode mode)
{
if(mode != null)
{
this.setNode(0, mode.toString());
}
}
public EnumMode getMode()
{
return EnumHelper.valueOf(this.getNodeAsString(0), EnumMode.class);
}
public void setTarget(EnumTarget target)
{
EnumMode mode = this.getMode();
this.updateSyntax(this.getSyntax(mode, target));
this.setMode0(mode);
this.setTarget0(target);
}
private void setTarget0(EnumTarget target)
{
if(target != null)
{
this.setNode(1, target.toString());
}
}
public EnumTarget getTarget()
{
return EnumHelper.valueOf(this.getNodeAsString(1), EnumTarget.class);
}
private void setEntity(String entity)
{
this.ensureTarget(EnumTarget.ENTITY);
if(entity != null)
{
this.targetSelector.set("type", entity);
}
this.setNode(2, this.targetSelector);
}
public void setEntity(ResourceLocation entity)
{
this.setEntity(entity.toString());
}
@Nonnull
public ResourceLocation getEntity()
{
return this.targetSelector.<ResourceLocation>get("type");
}
public void setPath(String path)
{
if(this.getMode() == null || !this.getMode().equals(EnumMode.REMOVE))
{
this.setMode(EnumMode.REMOVE);
}
switch(this.getTarget())
{
case BLOCK:
this.setNode(5, path);
break;
case ENTITY:
this.setNode(3, path);
break;
default:
break;
}
}
@Override
public void setNBT(NBTTagCompound nbt)
{
if(this.getMode() == null || !this.getMode().equals(EnumMode.MERGE))
{
this.setMode(EnumMode.MERGE);
}
EnumTarget target = this.getTarget();
if(target != null)
{
switch(target)
{
case BLOCK:
this.setNode(5, nbt);
break;
case ENTITY:
this.setNode(3, nbt);
break;
default:
break;
}
}
}
@Nullable
public NBTTagCompound getNBT()
{
if(this.getMode() != null && this.getMode().equals(EnumMode.MERGE))
{
switch(this.getTarget())
{
case BLOCK:
return this.getNodeAsNBT(5);
case ENTITY:
return this.getNodeAsNBT(3);
default:
break;
}
}
return null;
}
@Override
public String getCommandName()
{
return "data";
}
@Nullable
private final Syntax getSyntax(EnumMode mode, EnumTarget target)
{
Syntax syntax = new Syntax();
syntax.addRequired(mode != null ? mode.toString() : "mode", Type.STRING);
syntax.addRequired(target != null ? target.toString() : "target", Type.STRING);
if(target != null)
{
switch(target)
{
case BLOCK:
syntax.addRequired("x", Type.COORDINATE_INT);
syntax.addRequired("y", Type.COORDINATE_INT);
syntax.addRequired("z", Type.COORDINATE_INT);
break;
case ENTITY:
syntax.addRequired("entity", Type.TARGET_SELECTOR);
break;
default:
break;
}
switch(mode)
{
case GET:
break;
case MERGE:
syntax.addRequired("nbt", Type.NBT);
break;
case REMOVE:
syntax.addRequired("path", Type.STRING);
break;
default:
break;
}
}
else
{
syntax.addOptional("...", Type.STRING);
}
return syntax;
}
private void ensureTarget(EnumTarget target)
{
if(this.getTarget() == null || !target.equals(this.getTarget()))
{
this.setTarget(target);
}
}
@Override
public void setX(CoordinateInt x)
{
this.ensureTarget(EnumTarget.BLOCK);
super.setX(x);
}
@Override
public void setY(CoordinateInt y)
{
this.ensureTarget(EnumTarget.BLOCK);
super.setY(y);
}
@Override
public void setZ(CoordinateInt z)
{
this.ensureTarget(EnumTarget.BLOCK);
super.setZ(z);
}
@Override
public CoordinateInt getXCoordinate()
{
this.ensureTarget(EnumTarget.BLOCK);
return super.getXCoordinate();
}
@Override
public CoordinateInt getYCoordinate()
{
this.ensureTarget(EnumTarget.BLOCK);
return super.getYCoordinate();
}
@Override
public CoordinateInt getZCoordinate()
{
this.ensureTarget(EnumTarget.BLOCK);
return super.getZCoordinate();
}
@Override
public BlockPos getBlockPos()
{
this.ensureTarget(EnumTarget.BLOCK);
return super.getBlockPos();
}
@Override
public final Syntax getSyntax()
{
Syntax syntax = new Syntax();
syntax.addRequired("get|merge|remove", Type.STRING);
syntax.addRequired("block|entity", Type.STRING);
syntax.addOptional("...", Type.STRING);
return syntax;
}
@OnlyIn(Dist.CLIENT)
public static enum EnumMode
{
GET,
MERGE,
REMOVE;
@Override
public String toString()
{
return this.name().toLowerCase();
}
}
@OnlyIn(Dist.CLIENT)
public static enum EnumTarget
{
BLOCK,
ENTITY;
@Override
public String toString()
{
return this.name().toLowerCase();
}
}
}

View File

@@ -3,10 +3,10 @@ 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;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public class BuilderDifficulty extends CommandBuilder
{
public BuilderDifficulty()
@@ -21,7 +21,10 @@ public class BuilderDifficulty extends CommandBuilder
public void setDifficulty(EnumDifficulty difficulty)
{
this.setNode(0, difficulty.toString());
if(difficulty != null)
{
this.setNode(0, difficulty.toString());
}
}
@Override
@@ -29,7 +32,7 @@ public class BuilderDifficulty extends CommandBuilder
{
return "difficulty";
}
@Override
public final Syntax getSyntax()
{
@@ -41,7 +44,7 @@ public class BuilderDifficulty extends CommandBuilder
}
@Deprecated
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public static enum EnumDifficulty
{
PEACEFUL,

View File

@@ -3,11 +3,12 @@ package exopandora.worldhandler.builder.impl;
import exopandora.worldhandler.builder.CommandBuilder;
import exopandora.worldhandler.builder.Syntax;
import exopandora.worldhandler.builder.types.Type;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public class BuilderEnchantment extends CommandBuilder
{
public void getPlayer(String player)
@@ -25,6 +26,11 @@ public class BuilderEnchantment extends CommandBuilder
return this.getNodeAsResourceLocation(1);
}
public void setEnchantment(Enchantment enchantment)
{
this.setEnchantment(enchantment.getRegistryName());
}
public void setEnchantment(ResourceLocation enchantment)
{
this.setNode(1, enchantment);

View File

@@ -1,41 +1,39 @@
package exopandora.worldhandler.builder.impl;
import javax.annotation.Nullable;
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;
import exopandora.worldhandler.helper.EnumHelper;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public class BuilderExperience extends CommandBuilder
{
public BuilderExperience()
{
this.setLevel(0);
}
public BuilderExperience(int level, String player)
public BuilderExperience(EnumMode mode, int level, String player, EnumUnit unit)
{
this.setMode(mode);
this.setLevel(level);
this.setPlayer(player);
this.setUnit(unit);
}
public void setLevel(int level)
public void setMode(EnumMode mode)
{
this.setNode(0, new Level(level));
this.setNode(0, mode.toString());
}
public int getLevel()
@Nullable
public EnumMode getMode()
{
Level level = this.getNodeAsLevel(0);
if(level != null)
{
return level.getLevel();
}
return 0;
return EnumHelper.valueOf(this.getNodeAsString(0), EnumMode.class);
}
public void setPlayer(String player)
@@ -48,10 +46,31 @@ public class BuilderExperience extends CommandBuilder
return this.getNodeAsString(1);
}
public void setLevel(int level)
{
this.setNode(2, level);
}
public int getLevel()
{
return this.getNodeAsInt(2);
}
public void setUnit(EnumUnit unit)
{
this.setNode(3, unit.toString());
}
@Nullable
public EnumUnit getUnit()
{
return EnumHelper.valueOf(this.getNodeAsString(3), EnumUnit.class);
}
@Override
public String getCommandName()
{
return "xp";
return "experience";
}
@Override
@@ -59,9 +78,53 @@ public class BuilderExperience extends CommandBuilder
{
Syntax syntax = new Syntax();
syntax.addRequired("amount", Type.LEVEL, new Level(0));
syntax.addOptional("player", Type.STRING);
syntax.addRequired("add|set|query", Type.STRING);
syntax.addRequired("player", Type.STRING);
syntax.addRequired("amount", Type.INT);
syntax.addOptional("levels|points", Type.STRING);
return syntax;
}
public BuilderExperience getBuilderForAddLevels()
{
return new BuilderExperience(EnumMode.ADD, this.getLevel(), this.getPlayer(), EnumUnit.LEVELS);
}
public BuilderExperience getBuilderForRemoveLevels()
{
return new BuilderExperience(EnumMode.ADD, -this.getLevel(), this.getPlayer(), EnumUnit.LEVELS);
}
public BuilderExperience getBuilderForResetLevels()
{
return new BuilderExperience(EnumMode.SET, 0, this.getPlayer(), EnumUnit.LEVELS);
}
@OnlyIn(Dist.CLIENT)
public static enum EnumMode
{
ADD,
SET,
QUERY;
@Override
public String toString()
{
return this.name().toLowerCase();
}
}
@OnlyIn(Dist.CLIENT)
public static enum EnumUnit
{
LEVELS,
POINTS;
@Override
public String toString()
{
return this.name().toLowerCase();
}
}
}

View File

@@ -4,112 +4,89 @@ import javax.annotation.Nullable;
import exopandora.worldhandler.builder.Syntax;
import exopandora.worldhandler.builder.impl.abstr.BuilderDoubleBlockPos;
import exopandora.worldhandler.builder.types.BlockResourceLocation;
import exopandora.worldhandler.builder.types.CoordinateInt;
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;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public class BuilderFill extends BuilderDoubleBlockPos
{
public BuilderFill(ResourceLocation block1, EnumBlockHandling handling, ResourceLocation block2)
public BuilderFill()
{
this.setPosition1(BlockHelper.getPos1());
this.setPosition2(BlockHelper.getPos2());
}
public BuilderFill(BlockResourceLocation block1, EnumBlockFilter filter, BlockResourceLocation block2)
{
this(BlockHelper.getPos1(), BlockHelper.getPos2(), block1, filter, block2);
}
public BuilderFill(BlockPos pos1, BlockPos pos2, BlockResourceLocation block1, EnumBlockFilter handling, BlockResourceLocation block2)
{
this.setPosition1(pos1);
this.setPosition2(pos2);
this.setBlock1(block1);
this.setMeta1(0);
this.setBlockHandling(handling);
this.setBlock2(block2);
}
public BuilderFill()
public BuilderFill(CoordinateInt x1, CoordinateInt y1, CoordinateInt z1, CoordinateInt x2, CoordinateInt y2, CoordinateInt z2, BlockResourceLocation block1)
{
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);
this.setX1(x1);
this.setY1(y1);
this.setZ1(z1);
this.setX2(x2);
this.setY2(y2);
this.setZ2(z2);
this.setBlock1(block1);
}
public void setBlock1(String block)
{
this.setBlock1(ResourceHelper.stringToResourceLocationNullable(block, ResourceHelper::isRegisteredBlock));
this.setBlock1(BlockResourceLocation.valueOf(block));
}
public void setBlock1(ResourceLocation location)
public void setBlock1(BlockResourceLocation resource)
{
this.setNode(6, location);
this.setNode(6, resource);
}
public ResourceLocation getBlock1()
@Nullable
public BlockResourceLocation getBlock1()
{
return this.getNodeAsResourceLocation(6);
return this.getNodeAsBlockResourceLocation(6);
}
public String getBlock1String()
public void setBlockHandling(EnumBlockFilter filter)
{
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);
this.setNode(7, filter != null ? filter.toString() : null);
}
public void setBlock2(String block)
{
this.setBlock2(ResourceHelper.stringToResourceLocationNullable(block, ResourceHelper::isRegisteredBlock));
this.setBlock2(BlockResourceLocation.valueOf(block));
}
public void setBlock2(ResourceLocation location)
public void setBlock2(BlockResourceLocation resource)
{
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);
this.setNode(8, resource);
}
@Nullable
public EnumBlockHandling getBlockHandling()
public BlockResourceLocation getBlock2()
{
return EnumHelper.valueOf(EnumBlockHandling.class, this.getNodeAsString(8));
return this.getNodeAsBlockResourceLocation(8);
}
@Nullable
public EnumBlockFilter getBlockFilter()
{
return EnumHelper.valueOf(this.getNodeAsString(7), EnumBlockFilter.class);
}
public BuilderFill getBuilderForFill()
@@ -119,7 +96,7 @@ public class BuilderFill extends BuilderDoubleBlockPos
public BuilderFill getBuilderForReplace()
{
return new BuilderFill(this.getBlock2(), EnumBlockHandling.REPLACE, this.getBlock1());
return new BuilderFill(this.getBlock2(), EnumBlockFilter.REPLACE, this.getBlock1());
}
@Override
@@ -133,23 +110,21 @@ public class BuilderFill extends BuilderDoubleBlockPos
{
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");
syntax.addRequired("x1", Type.COORDINATE_INT);
syntax.addRequired("y1", Type.COORDINATE_INT);
syntax.addRequired("z1", Type.COORDINATE_INT);
syntax.addRequired("x2", Type.COORDINATE_INT);
syntax.addRequired("y2", Type.COORDINATE_INT);
syntax.addRequired("z2", Type.COORDINATE_INT);
syntax.addRequired("block", Type.BLOCK_RESOURCE_LOCATION);
syntax.addOptional("filter", Type.STRING);
syntax.addOptional("block", Type.BLOCK_RESOURCE_LOCATION, "block");
return syntax;
}
@SideOnly(Side.CLIENT)
public static enum EnumBlockHandling
@OnlyIn(Dist.CLIENT)
public static enum EnumBlockFilter
{
REPLACE,
DESTROY,

View File

@@ -3,9 +3,10 @@ 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;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public class BuilderGamemode extends CommandBuilder
{
public BuilderGamemode()
@@ -51,7 +52,7 @@ public class BuilderGamemode extends CommandBuilder
return syntax;
}
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public static enum EnumGamemode
{
SURVIVAL,

View File

@@ -3,10 +3,10 @@ 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;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public class BuilderGamerule extends CommandBuilder
{
public BuilderGamerule()

View File

@@ -2,10 +2,10 @@ package exopandora.worldhandler.builder.impl;
import exopandora.worldhandler.builder.CommandString;
import exopandora.worldhandler.builder.ICommandBuilder;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public class BuilderGeneric implements ICommandBuilder
{
private final String command;

View File

@@ -1,30 +1,35 @@
package exopandora.worldhandler.builder.impl;
import javax.annotation.Nullable;
import exopandora.worldhandler.builder.CommandBuilderNBT;
import exopandora.worldhandler.builder.Syntax;
import exopandora.worldhandler.builder.types.ItemResourceLocation;
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;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.registries.ForgeRegistries;
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public class BuilderGive extends CommandBuilderNBT
{
public BuilderGive(String player, ResourceLocation item)
{
this.setPlayer(player);
this.setItem(item);
this.setAmount(1);
this.setMetadata(0);
}
private final ItemResourceLocation itemResourceLocation = new ItemResourceLocation();
public BuilderGive()
{
this(null, null);
}
public BuilderGive(String player, ResourceLocation item)
{
this.setPlayer(player);
this.setItem(item);
this.setCount(1);
}
public void setPlayer(String username)
{
this.setNode(0, username);
@@ -37,50 +42,41 @@ public class BuilderGive extends CommandBuilderNBT
public void setItem(String item)
{
this.setItem(ResourceHelper.stringToResourceLocationNullable(item, ResourceHelper::isRegisteredItem));
this.setItem(ResourceHelper.assertRegistered(ResourceHelper.stringToResourceLocation(item), ForgeRegistries.ITEMS));
}
public void setItem(ResourceLocation item)
{
this.setNode(1, item);
this.itemResourceLocation.setResourceLocation(item);
this.setNode(1, this.itemResourceLocation);
}
public ResourceLocation getItem()
@Nullable
public ItemResourceLocation getItem()
{
return this.getNodeAsResourceLocation(1);
return this.getNodeAsItemResourceLocation(1);
}
public void setAmount(int ammount)
public void setCount(int count)
{
this.setNode(2, ammount);
this.setNode(2, count);
}
public int getAmount()
public int getCount()
{
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);
this.itemResourceLocation.setNBT(nbt);
this.setNode(1, this.itemResourceLocation);
}
public NBTTagCompound getNBT()
{
return this.getNodeAsNBT(4);
return this.getNodeAsItemResourceLocation(1).getNBT();
}
@Override
@@ -95,10 +91,8 @@ public class BuilderGive extends CommandBuilderNBT
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);
syntax.addRequired("item", Type.ITEM_RESOURCE_LOCATION);
syntax.addRequired("count", Type.INT);
return syntax;
}

View File

@@ -3,10 +3,10 @@ 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;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public class BuilderMultiCommand implements ICommandBuilder
{
private final ICommandBuilder[] builders;

View File

@@ -1,38 +1,41 @@
package exopandora.worldhandler.builder.impl;
import exopandora.worldhandler.builder.component.impl.ComponentTag;
import net.minecraft.client.Minecraft;
import net.minecraft.init.Blocks;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.state.properties.NoteBlockInstrument;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT)
public class BuilderNoteEditor extends BuilderBlockdata
@OnlyIn(Dist.CLIENT)
public class BuilderNoteEditor extends BuilderSetBlock
{
private final ComponentTag<Byte> note;
public BuilderNoteEditor()
{
this.note = this.registerNBTComponent(new ComponentTag<Byte>("note"));
this.setBlock(Blocks.NOTE_BLOCK.getRegistryName());
this.setMode("replace");
}
public BuilderNoteEditor(byte note)
public BuilderNoteEditor(int note)
{
this();
this.setNote(note);
}
public BuilderNoteEditor(byte note, BlockPos pos)
public BuilderNoteEditor(int note, BlockPos pos)
{
this(note);
this.setPosition(pos);
this.withState(BlockStateProperties.NOTE_BLOCK_INSTRUMENT, NoteBlockInstrument.byState(Minecraft.getInstance().world.getBlockState(pos)));
}
public void setNote(byte note)
public void setNote(int note)
{
this.note.setValue(note);
this.withState(BlockStateProperties.NOTE_0_24, note);
}
public BuilderNoteEditor getBuilderForNote(byte note)
public BuilderNoteEditor getBuilderForNote(int note)
{
return new BuilderNoteEditor(note, this.getBlockPos());
}

View File

@@ -3,10 +3,10 @@ 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;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public class BuilderPlayer extends CommandBuilder
{
private final String command;

View File

@@ -3,10 +3,10 @@ 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;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public class BuilderPlayerReason extends CommandBuilder
{
private final String command;

View File

@@ -8,10 +8,11 @@ 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;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.registries.ForgeRegistries;
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public class BuilderPotionEffect extends CommandBuilder
{
private int seconds;
@@ -20,16 +21,17 @@ public class BuilderPotionEffect extends CommandBuilder
public BuilderPotionEffect()
{
this(null, null);
this(null, null, null);
}
public BuilderPotionEffect(String player, ResourceLocation effect)
public BuilderPotionEffect(EnumMode mode, String player, ResourceLocation effect)
{
this(player, effect, 0, (byte) 0, false);
this(mode, player, effect, 0, (byte) 0, false);
}
public BuilderPotionEffect(String player, ResourceLocation effect, int duration, byte amplifier, boolean hideParticles)
public BuilderPotionEffect(EnumMode mode, String player, ResourceLocation effect, int duration, byte amplifier, boolean hideParticles)
{
this.setMode(mode);
this.setPlayer(player);
this.setEffect(effect);
this.setDuration(duration);
@@ -37,29 +39,42 @@ public class BuilderPotionEffect extends CommandBuilder
this.setHideParticles(hideParticles);
}
public void setMode(EnumMode mode)
{
if(mode != null)
{
this.setNode(0, mode.toString());
}
}
public void setPlayer(String player)
{
this.setNode(0, player);
this.setNode(1, player);
}
public String getPlayer()
{
return this.getNodeAsString(0);
return this.getNodeAsString(1);
}
public void setEffect(Potion effect)
{
this.setEffect(effect.getRegistryName());
}
public void setEffect(ResourceLocation effect)
{
this.setNode(1, effect);
this.setNode(2, effect);
}
@Nullable
public Potion getEffectAsPotion()
{
ResourceLocation location = this.getNodeAsResourceLocation(1);
ResourceLocation location = this.getNodeAsResourceLocation(2);
if(location != null)
{
return Potion.getPotionFromResourceLocation(location.toString());
return ForgeRegistries.POTIONS.getValue(location);
}
return null;
@@ -67,37 +82,37 @@ public class BuilderPotionEffect extends CommandBuilder
public ResourceLocation getEffect()
{
return this.getNodeAsResourceLocation(1);
return this.getNodeAsResourceLocation(2);
}
public void setDuration(int duration)
{
this.setNode(2, Math.min(duration, 1000000));
this.setNode(3, Math.min(duration, 1000000));
}
public int getDuration()
{
return this.getNodeAsInt(2);
return this.getNodeAsInt(3);
}
public void setAmplifier(byte amplifier)
{
this.setNode(3, (byte) (amplifier - 1));
this.setNode(4, (byte) (amplifier - 1));
}
public int getAmplifier()
{
return this.getNodeAsByte(3);
return this.getNodeAsByte(4);
}
public void setHideParticles(boolean hideParticles)
{
this.setNode(4, hideParticles);
this.setNode(5, hideParticles);
}
public boolean getHideParticles()
{
return this.getNodeAsBoolean(4);
return this.getNodeAsBoolean(5);
}
public int getSeconds()
@@ -108,7 +123,7 @@ public class BuilderPotionEffect extends CommandBuilder
public void setSeconds(int seconds)
{
this.seconds = seconds;
this.setDuration(PotionMetadata.getDurationSeconds(this.seconds, this.minutes, this.hours));
this.setDuration(PotionMetadata.toSeconds(this.seconds, this.minutes, this.hours));
}
public int getMinutes()
@@ -119,7 +134,7 @@ public class BuilderPotionEffect extends CommandBuilder
public void setMinutes(int minutes)
{
this.minutes = minutes;
this.setDuration(PotionMetadata.getDurationSeconds(this.seconds, this.minutes, this.hours));
this.setDuration(PotionMetadata.toSeconds(this.seconds, this.minutes, this.hours));
}
public int getHours()
@@ -130,17 +145,22 @@ public class BuilderPotionEffect extends CommandBuilder
public void setHours(int hours)
{
this.hours = hours;
this.setDuration(PotionMetadata.getDurationSeconds(this.seconds, this.minutes, this.hours));
this.setDuration(PotionMetadata.toSeconds(this.seconds, this.minutes, this.hours));
}
public BuilderGeneric getGiveCommand()
{
return new BuilderGeneric(this.getCommandName(), EnumMode.GIVE.toString(), this.getPlayer(), this.getEffect().toString(), String.valueOf(this.getDuration()), String.valueOf(this.getAmplifier()), String.valueOf(this.getHideParticles()));
}
public BuilderGeneric getRemoveCommand()
{
return new BuilderGeneric(this.getCommandName(), this.getPlayer(), this.getEffect().toString(), "0");
return new BuilderGeneric(this.getCommandName(), EnumMode.CLEAR.toString(), this.getPlayer(), this.getEffect().toString());
}
public BuilderGeneric getClearCommand()
{
return new BuilderGeneric(this.getCommandName(), this.getPlayer(), "clear");
return new BuilderGeneric(this.getCommandName(), EnumMode.CLEAR.toString(), this.getPlayer());
}
@Override
@@ -154,6 +174,7 @@ public class BuilderPotionEffect extends CommandBuilder
{
Syntax syntax = new Syntax();
syntax.addRequired("give|clear", Type.STRING);
syntax.addRequired("player", Type.STRING);
syntax.addRequired("effect", Type.RESOURCE_LOCATION);
syntax.addOptional("seconds", Type.INT, 0);
@@ -162,4 +183,17 @@ public class BuilderPotionEffect extends CommandBuilder
return syntax;
}
@OnlyIn(Dist.CLIENT)
public static enum EnumMode
{
GIVE,
CLEAR;
@Override
public String toString()
{
return this.name().toLowerCase();
}
}
}

View File

@@ -6,10 +6,10 @@ 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;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public class BuilderPotionItem extends BuilderGive
{
private final ComponentPotionItem potion;
@@ -27,62 +27,62 @@ public class BuilderPotionItem extends BuilderGive
public void setAmplifier(Potion potion, byte amplifier)
{
this.potion.get(potion).setAmplifier(amplifier);
this.potion.setAmplifier(potion, amplifier);
}
public void setSeconds(Potion potion, int seconds)
{
this.potion.get(potion).setSeconds(seconds);
this.potion.setSeconds(potion, seconds);
}
public void setMinutes(Potion potion, int minutes)
{
this.potion.get(potion).setMinutes(minutes);
this.potion.setMinutes(potion, minutes);
}
public void setHours(Potion potion, int hours)
{
this.potion.get(potion).setHours(hours);
this.potion.setHours(potion, hours);
}
public void setShowParticles(Potion potion, boolean showParticles)
{
this.potion.get(potion).setShowParticles(showParticles);
this.potion.setShowParticles(potion, showParticles);
}
public void setAmbient(Potion potion, boolean ambient)
{
this.potion.get(potion).setAmbient(ambient);
this.potion.setAmbient(potion, ambient);
}
public byte getAmplifier(Potion potion)
{
return this.potion.get(potion).getAmplifier();
return this.potion.getAmplifier(potion);
}
public int getSeconds(Potion potion)
{
return this.potion.get(potion).getSeconds();
return this.potion.getSeconds(potion);
}
public int getMinutes(Potion potion)
{
return this.potion.get(potion).getMinutes();
return this.potion.getMinutes(potion);
}
public int getHours(Potion potion)
{
return this.potion.get(potion).getHours();
return this.potion.getHours(potion);
}
public boolean getShowParticles(Potion potion)
{
return this.potion.get(potion).getShowParticles();
return this.potion.getShowParticles(potion);
}
public boolean getAmbient(Potion potion)
{
return this.potion.get(potion).getAmbient();
return this.potion.getAmbient(potion);
}
public Set<Potion> getPotions()

View File

@@ -4,14 +4,14 @@ import javax.annotation.Nullable;
import exopandora.worldhandler.builder.CommandBuilder;
import exopandora.worldhandler.builder.Syntax;
import exopandora.worldhandler.builder.impl.BuilderAdvancement.EnumActionType;
import exopandora.worldhandler.builder.types.Type;
import exopandora.worldhandler.helper.EnumHelper;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public class BuilderRecipe extends CommandBuilder
{
public BuilderRecipe()
@@ -34,7 +34,7 @@ public class BuilderRecipe extends CommandBuilder
@Nullable
public EnumMode getMode()
{
return EnumHelper.valueOf(EnumMode.class, this.getNodeAsString(0));
return EnumHelper.valueOf(this.getNodeAsString(0), EnumMode.class);
}
public void setPlayer(String player)
@@ -48,6 +48,11 @@ public class BuilderRecipe extends CommandBuilder
return this.getNodeAsString(1);
}
public void setRecipe(IRecipe recipe)
{
this.setRecipe(recipe.getId());
}
public void setRecipe(ResourceLocation recipe)
{
this.setNode(2, recipe);
@@ -82,7 +87,7 @@ public class BuilderRecipe extends CommandBuilder
return syntax;
}
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public static enum EnumMode
{
GIVE,

View File

@@ -4,11 +4,13 @@ import javax.annotation.Nullable;
import exopandora.worldhandler.builder.Syntax;
import exopandora.worldhandler.builder.impl.abstr.BuilderScoreboard;
import exopandora.worldhandler.builder.types.GreedyString;
import exopandora.worldhandler.builder.types.Type;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import exopandora.worldhandler.helper.EnumHelper;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public class BuilderScoreboardObjectives extends BuilderScoreboard
{
public BuilderScoreboardObjectives()
@@ -21,74 +23,74 @@ public class BuilderScoreboardObjectives extends BuilderScoreboard
this.setNode(0, "objectives");
}
public void setMode(String mode)
public void setMode(EnumMode mode)
{
String objective = this.getObjective();
if(mode.equals("add") || mode.equals("remove") || mode.equals("setdisplay"))
this.updateSyntax(this.getSyntax(mode));
this.setNode(1, mode.toString());
if(objective != null)
{
this.updateSyntax(this.getSyntax(mode));
this.setNode(1, mode);
if(objective != null)
{
this.setObjective(objective);
}
this.init();
this.setObjective(objective);
}
this.init();
}
public String getMode()
public EnumMode getMode()
{
return this.getNodeAsString(1);
return EnumHelper.valueOf(this.getNodeAsString(1), EnumMode.class);
}
public void setObjective(String name)
{
String mode = this.getMode();
String objective = name != null ? name.replaceAll(" ", "_") : null;
EnumMode mode = this.getMode();
if(mode != null)
{
if(mode.equals("add") || mode.equals("remove"))
switch(mode)
{
this.setNode(2, objective);
if(mode.equals("add"))
{
this.setNode(4, name);
}
}
else if(mode.equals("setdisplay"))
{
this.setNode(3, objective);
case ADD:
this.setNode(4, new GreedyString(name));
case REMOVE:
this.setNode(2, objective);
break;
case SETDISPLAY:
this.setNode(3, objective);
break;
default:
break;
}
}
}
public void setCriteria(String criteria)
{
if(this.getMode() == null || !this.getMode().equals("add"))
if(this.getMode() == null || !this.getMode().equals(EnumMode.ADD))
{
this.setMode("add");
this.setMode(EnumMode.ADD);
}
this.setNode(3, criteria.replaceAll("[:]", "."));
this.setNode(3, criteria);
}
public void setSlot(String slot)
{
if(this.getMode() == null || !this.getMode().equals("setdisplay"))
if(this.getMode() == null || !this.getMode().equals(EnumMode.SETDISPLAY))
{
this.setMode("setdisplay");
this.setMode(EnumMode.SETDISPLAY);
}
this.setNode(2, slot);
}
@Nullable
public String getSlot()
{
if(this.getMode() != null && this.getMode().equals("setdisplay"))
if(this.getMode() != null && this.getMode().equals(EnumMode.SETDISPLAY))
{
return this.getNodeAsString(2);
}
@@ -99,17 +101,18 @@ public class BuilderScoreboardObjectives extends BuilderScoreboard
@Nullable
public String getObjective()
{
String mode = this.getMode();
EnumMode mode = this.getMode();
if(mode != null)
{
if(mode.equals("add") || mode.equals("remove"))
switch(mode)
{
return this.getNodeAsString(2);
}
else if(mode.equals("setdisplay"))
{
return this.getNodeAsString(3);
case ADD: case REMOVE:
return this.getNodeAsString(2);
case SETDISPLAY:
return this.getNodeAsString(3);
default:
break;
}
}
@@ -117,43 +120,33 @@ public class BuilderScoreboardObjectives extends BuilderScoreboard
}
@Nullable
private Syntax getSyntax(String mode)
private Syntax getSyntax(EnumMode 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;
}
Syntax syntax = new Syntax();
return null;
switch(mode)
{
case ADD:
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.GREEDY_STRING);
return syntax;
case REMOVE:
syntax.addRequired("objectives", Type.STRING);
syntax.addRequired("remove", Type.STRING);
syntax.addRequired("name", Type.STRING);
return syntax;
case SETDISPLAY:
syntax.addRequired("objectives", Type.STRING);
syntax.addRequired("setdisplay", Type.STRING);
syntax.addRequired("slot", Type.STRING);
syntax.addOptional("objective", Type.STRING);
return syntax;
default:
return null;
}
}
@Override
@@ -167,4 +160,18 @@ public class BuilderScoreboardObjectives extends BuilderScoreboard
return syntax;
}
@OnlyIn(Dist.CLIENT)
public static enum EnumMode
{
ADD,
REMOVE,
SETDISPLAY;
@Override
public String toString()
{
return this.name().toLowerCase();
}
}
}

View File

@@ -3,10 +3,10 @@ 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;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public class BuilderScoreboardPlayers extends BuilderScoreboard
{
public BuilderScoreboardPlayers()
@@ -14,6 +14,11 @@ public class BuilderScoreboardPlayers extends BuilderScoreboard
this.init();
}
private void init()
{
this.setNode(0, "players");
}
public String getMode()
{
return this.getNodeAsString(1);
@@ -23,36 +28,19 @@ public class BuilderScoreboardPlayers extends BuilderScoreboard
{
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);
this.setObjective(objective);
if(!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();
this.setPoints(points);
}
}
private void init()
{
this.setNode(0, "players");
this.init();
}
public void setPlayer(String player)
@@ -72,10 +60,7 @@ public class BuilderScoreboardPlayers extends BuilderScoreboard
if(mode != null)
{
if(mode.equals("add|set|remove") || mode.equals("enable"))
{
this.setNode(3, objective);
}
this.setNode(3, objective);
}
}
@@ -85,10 +70,7 @@ public class BuilderScoreboardPlayers extends BuilderScoreboard
if(mode != null)
{
if(mode.equals("add|set|remove") || mode.equals("enable"))
{
return this.getNodeAsString(3);
}
return this.getNodeAsString(3);
}
return null;
@@ -96,16 +78,12 @@ public class BuilderScoreboardPlayers extends BuilderScoreboard
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"))
if(this.getMode() != null && !this.getMode().equals("enable"))
{
return this.getNodeAsInt(4);
}
@@ -113,83 +91,56 @@ public class BuilderScoreboardPlayers extends BuilderScoreboard
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();
if(mode.equals("enable"))
{
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);
syntax.addRequired("objective", Type.STRING);
return syntax;
}
return null;
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("score", Type.INT, 0);
return syntax;
}
public BuilderGeneric getBuilderForTag(EnumTag tag)
{
return new BuilderGeneric(this.getCommandName(), "players", this.getMode(), this.getPlayer(), tag.toString(), this.getTag());
}
public BuilderGeneric getBuilderForPoints(EnumPoints mode)
public BuilderScoreboardPlayers getBuilderForPoints(EnumMode mode)
{
return this.getBuilderForPoints(mode, this.getPoints());
}
public BuilderGeneric getBuilderForPoints(EnumPoints mode, int points)
public BuilderScoreboardPlayers getBuilderForPoints(EnumMode mode, int points)
{
return new BuilderGeneric(this.getCommandName(), "players", mode.toString(), this.getPlayer(), this.getObjective(), String.valueOf(points));
BuilderScoreboardPlayers builder = new BuilderScoreboardPlayers();
builder.setMode(mode.toString());
builder.setPlayer(this.getPlayer());
builder.setObjective(this.getObjective());
builder.setPoints(points);
return builder;
}
public BuilderScoreboardPlayers getBuilderForEnable()
{
BuilderScoreboardPlayers builder = new BuilderScoreboardPlayers();
builder.setMode(EnumMode.ENABLE.toString());
builder.setPlayer(this.getPlayer());
builder.setObjective(this.getObjective());
return builder;
}
@Override
@@ -198,30 +149,18 @@ public class BuilderScoreboardPlayers extends BuilderScoreboard
Syntax syntax = new Syntax();
syntax.addRequired("players", Type.STRING);
syntax.addRequired("add|enable|list|operation|remove|reset|set|tag|test", Type.STRING);
syntax.addRequired("add|enable|get|list|operation|remove|reset|set", Type.STRING);
syntax.addOptional("...", Type.STRING);
return syntax;
}
@SideOnly(Side.CLIENT)
public static enum EnumTag
{
ADD,
REMOVE;
@Override
public String toString()
{
return this.name().toLowerCase();
}
}
@SideOnly(Side.CLIENT)
public static enum EnumPoints
@OnlyIn(Dist.CLIENT)
public static enum EnumMode
{
ADD,
REMOVE,
ENABLE,
SET;
@Override

View File

@@ -2,59 +2,66 @@ 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.BlockResourceLocation;
import exopandora.worldhandler.builder.types.CoordinateInt;
import exopandora.worldhandler.builder.types.Type;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.state.IProperty;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
public class BuilderSetblock extends BuilderBlockPos
@OnlyIn(Dist.CLIENT)
public class BuilderSetBlock extends BuilderBlockPos
{
@Deprecated
public BuilderSetblock(BlockPos pos, ResourceLocation block, int meta, String mode)
private final BlockResourceLocation blockResourceLocation = new BlockResourceLocation();
public BuilderSetBlock()
{
super(0);
}
public BuilderSetBlock(BlockPos pos, ResourceLocation block, String mode)
{
this();
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)
public BuilderSetBlock(CoordinateInt x, CoordinateInt y, CoordinateInt z, ResourceLocation block, String mode)
{
this();
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)
public <T extends Comparable<T>> BuilderSetBlock withState(IProperty<T> property, T value)
{
this(x, y, z, block, 0, mode);
this.blockResourceLocation.withState(property, value);
return this;
}
public void setBlock(ResourceLocation block)
{
this.setNode(3, block);
}
@Deprecated
public void setMetadata(int meta)
{
this.setNode(4, meta);
this.blockResourceLocation.setResourceLocation(block);
this.setNode(3, this.blockResourceLocation);
}
public void setMode(String mode)
{
this.setNode(5, mode);
this.setNode(4, mode);
}
@Override
public void setNBT(NBTTagCompound nbt)
{
this.setNode(6, nbt);
this.blockResourceLocation.setNBT(nbt);
this.setNode(3, this.blockResourceLocation);
}
@Override
@@ -68,13 +75,11 @@ public class BuilderSetblock extends BuilderBlockPos
{
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.addRequired("x", Type.COORDINATE_INT);
syntax.addRequired("y", Type.COORDINATE_INT);
syntax.addRequired("z", Type.COORDINATE_INT);
syntax.addRequired("block", Type.BLOCK_RESOURCE_LOCATION);
syntax.addOptional("mode", Type.STRING);
syntax.addOptional("nbt", Type.NBT);
return syntax;
}

View File

@@ -6,16 +6,21 @@ 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;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT)
public class BuilderSignEditor extends BuilderBlockdata
@OnlyIn(Dist.CLIENT)
public class BuilderSignEditor extends BuilderData
{
@SuppressWarnings("unchecked")
private final ComponentTag<SignText>[] sign = new ComponentTag[4];
public BuilderSignEditor()
{
super();
this.setMode(EnumMode.MERGE);
this.setTarget(EnumTarget.BLOCK);
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())));

View File

@@ -2,19 +2,20 @@ 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.Coordinate.CoordinateType;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import exopandora.worldhandler.builder.types.CoordinateInt;
import exopandora.worldhandler.builder.types.Type;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.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));
this.setX(new CoordinateInt(CoordinateType.LOCAL));
this.setY(new CoordinateInt(CoordinateType.LOCAL));
this.setZ(new CoordinateInt(CoordinateType.LOCAL));
}
@Override
@@ -28,17 +29,17 @@ public class BuilderSpawnpoint extends CommandBuilder
this.setNode(0, player);
}
public void setX(Coordinate x)
public void setX(CoordinateInt x)
{
this.setNode(1, x);
}
public void setY(Coordinate y)
public void setY(CoordinateInt y)
{
this.setNode(2, y);
}
public void setZ(Coordinate z)
public void setZ(CoordinateInt z)
{
this.setNode(3, z);
}
@@ -49,9 +50,9 @@ public class BuilderSpawnpoint extends CommandBuilder
Syntax syntax = new Syntax();
syntax.addRequired("player", Type.STRING);
syntax.addRequired("x", Type.COORDINATE);
syntax.addRequired("y", Type.COORDINATE);
syntax.addRequired("z", Type.COORDINATE);
syntax.addRequired("x", Type.COORDINATE_INT);
syntax.addRequired("y", Type.COORDINATE_INT);
syntax.addRequired("z", Type.COORDINATE_INT);
return syntax;
}

View File

@@ -14,22 +14,25 @@ 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.Coordinate.CoordinateType;
import exopandora.worldhandler.builder.types.CoordinateDouble;
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.INBTBase;
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;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentString;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public class BuilderSummon extends CommandBuilderNBT
{
private final ComponentAttributeMob attribute;
@@ -51,45 +54,14 @@ public class BuilderSummon extends CommandBuilderNBT
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));
}
this.setX(new CoordinateDouble(0.0, CoordinateType.LOCAL));
this.setY(new CoordinateDouble(0.0, CoordinateType.LOCAL));
this.setZ(new CoordinateDouble(2.0, CoordinateType.LOCAL));
}
public void setEntity(String entityName)
{
ResourceLocation location = this.summon.resolve(entityName);
ResourceLocation location = ComponentSummon.resolve(entityName);
this.summon.setName(entityName);
this.summon.setEntity(location);
@@ -102,34 +74,34 @@ public class BuilderSummon extends CommandBuilderNBT
return this.getNodeAsResourceLocation(0);
}
public void setX(Coordinate x)
public void setX(CoordinateDouble x)
{
this.setNode(1, x);
}
public Coordinate getX()
public CoordinateDouble getX()
{
return this.getNodeAsCoordinate(1);
return this.getNodeAsCoordinateDouble(1);
}
public void setY(Coordinate y)
public void setY(CoordinateDouble y)
{
this.setNode(2, y);
}
public Coordinate getY()
public CoordinateDouble getY()
{
return this.getNodeAsCoordinate(2);
return this.getNodeAsCoordinateDouble(2);
}
public void setZ(Coordinate z)
public void setZ(CoordinateDouble z)
{
this.setNode(3, z);
}
public Coordinate getZ()
public CoordinateDouble getZ()
{
return this.getNodeAsCoordinate(3);
return this.getNodeAsCoordinateDouble(3);
}
public void setAttribute(EnumAttributes attribute, double ammount)
@@ -175,7 +147,7 @@ public class BuilderSummon extends CommandBuilderNBT
public void setPassenger(String entityName)
{
this.setPassenger(this.summon.resolve(entityName));
this.setPassenger(ComponentSummon.resolve(entityName));
}
public void setPassenger(ResourceLocation entityName)
@@ -186,7 +158,7 @@ public class BuilderSummon extends CommandBuilderNBT
passenger.setString("id", entityName.toString());
NBTTagList list = new NBTTagList();
list.appendTag(passenger);
list.add(passenger);
this.passengers.setValue(list);
}
@@ -201,9 +173,9 @@ public class BuilderSummon extends CommandBuilderNBT
{
NBTTagList list = this.passengers.getValue();
if(list != null && !list.hasNoTags())
if(list != null && !list.isEmpty())
{
return new ResourceLocation(list.getCompoundTagAt(0).getString("id"));
return new ResourceLocation(list.getCompound(0).getString("id"));
}
return null;
@@ -232,8 +204,8 @@ public class BuilderSummon extends CommandBuilderNBT
{
NBTTagCompound compound = new NBTTagCompound();
compound.setString("id", item.toString());
compound.setInteger("Count", 1);
list.appendTag(compound);
compound.setInt("Count", 1);
list.add(compound);
}
this.armorItems.setValue(list);
@@ -281,8 +253,8 @@ public class BuilderSummon extends CommandBuilderNBT
{
NBTTagCompound compound = new NBTTagCompound();
compound.setString("id", item.toString());
compound.setInteger("Count", 1);
list.appendTag(compound);
compound.setInt("Count", 1);
list.add(compound);
}
this.handItems.setValue(list);
@@ -300,62 +272,62 @@ public class BuilderSummon extends CommandBuilderNBT
public void setAmplifier(Potion potion, byte amplifier)
{
this.potion.get(potion).setAmplifier(amplifier);
this.potion.setAmplifier(potion, amplifier);
}
public void setSeconds(Potion potion, int seconds)
{
this.potion.get(potion).setSeconds(seconds);
this.potion.setSeconds(potion, seconds);
}
public void setMinutes(Potion potion, int minutes)
{
this.potion.get(potion).setMinutes(minutes);
this.potion.setMinutes(potion, minutes);
}
public void setHours(Potion potion, int hours)
{
this.potion.get(potion).setHours(hours);
this.potion.setHours(potion, hours);
}
public void setShowParticles(Potion potion, boolean showParticles)
{
this.potion.get(potion).setShowParticles(showParticles);
this.potion.setShowParticles(potion, showParticles);
}
public void setAmbient(Potion potion, boolean ambient)
{
this.potion.get(potion).setAmbient(ambient);
this.potion.setAmbient(potion, ambient);
}
public byte getAmplifier(Potion potion)
{
return this.potion.get(potion).getAmplifier();
return this.potion.getAmplifier(potion);
}
public int getSeconds(Potion potion)
{
return this.potion.get(potion).getSeconds();
return this.potion.getSeconds(potion);
}
public int getMinutes(Potion potion)
{
return this.potion.get(potion).getMinutes();
return this.potion.getMinutes(potion);
}
public int getHours(Potion potion)
{
return this.potion.get(potion).getHours();
return this.potion.getHours(potion);
}
public boolean getShowParticles(Potion potion)
{
return this.potion.get(potion).getShowParticles();
return this.potion.getShowParticles(potion);
}
public boolean getAmbient(Potion potion)
{
return this.potion.get(potion).getAmbient();
return this.potion.getAmbient(potion);
}
public Set<Potion> getPotions()
@@ -363,11 +335,11 @@ public class BuilderSummon extends CommandBuilderNBT
return this.potion.getPotions();
}
private NBTBase itemListSerializer(NBTTagList list)
private INBTBase itemListSerializer(NBTTagList list)
{
for(int x = 0; x < list.tagCount(); x++)
for(int x = 0; x < list.size(); x++)
{
if(!list.getCompoundTagAt(x).getString("id").equals(Blocks.AIR.getRegistryName().toString()))
if(!list.getCompound(x).getString("id").equals(Blocks.AIR.getRegistryName().toString()))
{
return list;
}
@@ -376,11 +348,11 @@ public class BuilderSummon extends CommandBuilderNBT
return null;
}
private NBTBase colorStringSerializer(ColoredString string)
private INBTBase colorStringSerializer(ColoredString string)
{
if(string.getText() != null && !string.getText().isEmpty())
{
return new NBTTagString(string.toString());
return new NBTTagString(ITextComponent.Serializer.toJson(new TextComponentString(string.toString())));
}
return null;
@@ -404,9 +376,9 @@ public class BuilderSummon extends CommandBuilderNBT
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("x", Type.COORDINATE_DOUBLE);
syntax.addOptional("y", Type.COORDINATE_DOUBLE);
syntax.addOptional("z", Type.COORDINATE_DOUBLE);
syntax.addOptional("nbt", Type.NBT);
return syntax;

View File

@@ -0,0 +1,88 @@
package exopandora.worldhandler.builder.impl;
import exopandora.worldhandler.builder.CommandBuilder;
import exopandora.worldhandler.builder.Syntax;
import exopandora.worldhandler.builder.types.Type;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public class BuilderTag extends CommandBuilder
{
public BuilderTag()
{
}
public BuilderTag(String player, EnumMode mode, String name)
{
this.setPlayer(player);
this.setMode(mode);
this.setName(name);
}
public void setPlayer(String player)
{
this.setNode(0, player);
}
public String getPlayer()
{
return this.getNodeAsString(0);
}
public void setMode(EnumMode mode)
{
if(mode != null)
{
this.setNode(1, mode.toString());
}
}
public void setName(String name)
{
this.setNode(2, name);
}
public String getName()
{
return this.getNodeAsString(2);
}
@Override
public String getCommandName()
{
return "tag";
}
@Override
public Syntax getSyntax()
{
Syntax syntax = new Syntax();
syntax.addRequired("player", Type.STRING);
syntax.addRequired("add|list|remove", Type.STRING);
syntax.addRequired("name", Type.STRING);
return syntax;
}
public BuilderTag getBuilderForMode(EnumMode mode)
{
return new BuilderTag(this.getPlayer(), mode, this.getName());
}
@OnlyIn(Dist.CLIENT)
public static enum EnumMode
{
ADD,
LIST,
REMOVE;
@Override
public String toString()
{
return this.name().toLowerCase();
}
}
}

View File

@@ -2,25 +2,16 @@ package exopandora.worldhandler.builder.impl;
import javax.annotation.Nullable;
import exopandora.worldhandler.builder.CommandBuilder;
import exopandora.worldhandler.builder.Syntax;
import exopandora.worldhandler.builder.impl.abstr.BuilderScoreboard;
import exopandora.worldhandler.builder.types.GreedyString;
import exopandora.worldhandler.builder.types.Type;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT)
public class BuilderScoreboardTeams extends BuilderScoreboard
@OnlyIn(Dist.CLIENT)
public class BuilderTeams extends CommandBuilder
{
public BuilderScoreboardTeams()
{
this.init();
}
private void init()
{
this.setNode(0, "teams");
}
public void setTeam(String name)
{
String mode = this.getMode();
@@ -30,22 +21,22 @@ public class BuilderScoreboardTeams extends BuilderScoreboard
{
if(mode.equals("add"))
{
this.setNode(3, name);
this.setNode(2, new GreedyString(name));
}
}
this.setNode(2, team);
this.setNode(1, team);
}
public String getMode()
{
return this.getNodeAsString(1);
return this.getNodeAsString(0);
}
@Nullable
public String getTeam()
{
return this.getNodeAsString(2);
return this.getNodeAsString(1);
}
public void setMode(String mode)
@@ -53,10 +44,10 @@ public class BuilderScoreboardTeams extends BuilderScoreboard
String team = this.getTeam();
String player = this.getPlayer();
if(mode.equals("add") || mode.equals("remove|empty") || mode.equals("join|leave") || mode.equals("option"))
if(mode.equals("add") || mode.equals("remove|empty") || mode.equals("join|leave") || mode.equals("modify"))
{
this.updateSyntax(this.getSyntax(mode));
this.setNode(1, mode);
this.setNode(0, mode);
if(team != null)
{
@@ -67,8 +58,6 @@ public class BuilderScoreboardTeams extends BuilderScoreboard
{
this.setPlayer(player);
}
this.init();
}
}
@@ -80,7 +69,7 @@ public class BuilderScoreboardTeams extends BuilderScoreboard
{
if(mode.equals("join|leave"))
{
this.setNode(3, player);
this.setNode(2, player);
}
}
}
@@ -94,7 +83,7 @@ public class BuilderScoreboardTeams extends BuilderScoreboard
{
if(mode.equals("join|leave"))
{
return this.getNodeAsString(3);
return this.getNodeAsString(2);
}
}
@@ -103,19 +92,19 @@ public class BuilderScoreboardTeams extends BuilderScoreboard
public void setRule(String rule)
{
if(this.getMode() == null || !this.getMode().equals("option"))
if(this.getMode() == null || !this.getMode().equals("modify"))
{
this.setMode("option");
this.setMode("modify");
}
this.setNode(3, rule);
this.setNode(2, rule);
}
public String getRule()
{
if(this.getMode() == null || this.getMode().equals("option"))
if(this.getMode() == null || this.getMode().equals("modify"))
{
return this.getNodeAsString(3);
return this.getNodeAsString(2);
}
return null;
@@ -123,19 +112,19 @@ public class BuilderScoreboardTeams extends BuilderScoreboard
public void setValue(String value)
{
if(this.getMode() == null || !this.getMode().equals("option"))
if(this.getMode() == null || !this.getMode().equals("modify"))
{
this.setMode("option");
this.setMode("modify");
}
this.setNode(4, value);
this.setNode(3, value);
}
public String getValue()
{
if(this.getMode() == null || this.getMode().equals("option"))
if(this.getMode() == null || this.getMode().equals("modify"))
{
return this.getNodeAsString(4);
return this.getNodeAsString(3);
}
return null;
@@ -148,10 +137,9 @@ public class BuilderScoreboardTeams extends BuilderScoreboard
{
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);
syntax.addOptional("display_name...", Type.GREEDY_STRING);
return syntax;
}
@@ -159,7 +147,6 @@ public class BuilderScoreboardTeams extends BuilderScoreboard
{
Syntax syntax = new Syntax();
syntax.addRequired("teams", Type.STRING);
syntax.addRequired("remove|empty", Type.STRING, "remove|empty");
syntax.addRequired("name", Type.STRING);
@@ -169,19 +156,17 @@ public class BuilderScoreboardTeams extends BuilderScoreboard
{
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"))
else if(mode.equals("modify"))
{
Syntax syntax = new Syntax();
syntax.addRequired("teams", Type.STRING);
syntax.addRequired("option", Type.STRING);
syntax.addRequired("modify", Type.STRING);
syntax.addRequired("team", Type.STRING);
syntax.addRequired("friendlyfire|color|seeFriendlyInvisibles|nametagVisibility|deathMessageVisibility|collisionRule", Type.STRING);
syntax.addRequired("value", Type.STRING);
@@ -192,28 +177,28 @@ public class BuilderScoreboardTeams extends BuilderScoreboard
return null;
}
public BuilderScoreboardTeams getBuilderForMode(EnumMode mode)
public BuilderTeams getBuilderForMode(EnumMode mode)
{
BuilderScoreboardTeams builder = new BuilderScoreboardTeams();
BuilderTeams builder = new BuilderTeams();
switch(mode)
{
case JOIN:
case LEAVE:
builder.setNode(1, mode.toString());
builder.setNode(0, mode.toString());
builder.setTeam(this.getTeam());
builder.setPlayer(this.getPlayer());
break;
case REMOVE:
case EMPTY:
builder.setNode(1, mode.toString());
builder.setNode(0, mode.toString());
builder.setTeam(this.getTeam());
break;
case ADD:
builder.setMode(mode.toString());
builder.setTeam(this.getTeam());
break;
case OPTION:
case MODIFY:
builder.setMode(mode.toString());
builder.setTeam(this.getTeam());
builder.setRule(this.getRule());
@@ -231,14 +216,19 @@ public class BuilderScoreboardTeams extends BuilderScoreboard
{
Syntax syntax = new Syntax();
syntax.addRequired("teams", Type.STRING);
syntax.addRequired("list|add|remove|empty|join|leave|option", Type.STRING);
syntax.addRequired("list|add|remove|empty|join|leave|modify", Type.STRING);
syntax.addOptional("...", Type.STRING);
return syntax;
}
@SideOnly(Side.CLIENT)
@Override
public String getCommandName()
{
return "team";
}
@OnlyIn(Dist.CLIENT)
public static enum EnumMode
{
JOIN,
@@ -246,7 +236,7 @@ public class BuilderScoreboardTeams extends BuilderScoreboard
REMOVE,
EMPTY,
ADD,
OPTION;
MODIFY;
@Override
public String toString()

View File

@@ -3,9 +3,10 @@ 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;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public class BuilderTime extends CommandBuilder
{
public BuilderTime()
@@ -51,7 +52,7 @@ public class BuilderTime extends CommandBuilder
return syntax;
}
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public static enum EnumMode
{
ADD,

View File

@@ -0,0 +1,93 @@
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.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public class BuilderTrigger extends CommandBuilder
{
public BuilderTrigger()
{
this.setValue(0);
}
public BuilderTrigger(String objective, EnumMode mode, int value)
{
this.setObjective(objective);
this.setMode(mode);
this.setValue(value);
}
public void setObjective(String name)
{
this.setNode(0, name != null ? name.replaceAll(" ", "_") : null);
}
public String getObjective()
{
return this.getNodeAsString(0);
}
public void setMode(EnumMode mode)
{
if(mode != null)
{
this.setNode(1, mode.toString());
}
}
public EnumMode getMode()
{
return EnumHelper.valueOf(this.getNodeAsString(1), EnumMode.class);
}
public void setValue(int value)
{
this.setNode(2, value);
}
public int getValue()
{
return this.getNodeAsInt(2);
}
@Override
public String getCommandName()
{
return "trigger";
}
@Override
public Syntax getSyntax()
{
Syntax syntax = new Syntax();
syntax.addRequired("objective", Type.STRING);
syntax.addRequired("add|set", Type.STRING);
syntax.addRequired("value", Type.INT);
return syntax;
}
public BuilderTrigger getBuilderForMode(EnumMode mode)
{
return new BuilderTrigger(this.getObjective(), mode, this.getValue());
}
@OnlyIn(Dist.CLIENT)
public static enum EnumMode
{
ADD,
SET;
@Override
public String toString()
{
return this.name().toLowerCase();
}
}
}

View File

@@ -3,10 +3,10 @@ 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;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public class BuilderWH extends CommandBuilder
{
@Override

View File

@@ -3,9 +3,10 @@ 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;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public class BuilderWeather extends CommandBuilder
{
public BuilderWeather()
@@ -51,7 +52,7 @@ public class BuilderWeather extends CommandBuilder
return syntax;
}
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public static enum EnumWeather
{
CLEAR,

View File

@@ -5,10 +5,10 @@ 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;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public class BuilderWhitelist extends CommandBuilder
{
public BuilderWhitelist()
@@ -76,7 +76,7 @@ public class BuilderWhitelist extends CommandBuilder
return syntax;
}
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public static enum EnumMode
{
ADD,

View File

@@ -3,10 +3,10 @@ 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;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public class BuilderWorldHandler extends CommandBuilder
{
@Override

View File

@@ -1,11 +1,21 @@
package exopandora.worldhandler.builder.impl.abstr;
import exopandora.worldhandler.builder.CommandBuilderNBT;
import exopandora.worldhandler.builder.types.Coordinate;
import exopandora.worldhandler.builder.types.CoordinateInt;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public abstract class BuilderBlockPos extends CommandBuilderNBT
{
private final int offset;
public BuilderBlockPos(int offset)
{
this.offset = offset;
}
public void setPosition(BlockPos pos)
{
this.setX(pos.getX());
@@ -13,64 +23,64 @@ public abstract class BuilderBlockPos extends CommandBuilderNBT
this.setZ(pos.getZ());
}
public void setX(float x)
public void setX(int x)
{
this.setX(new Coordinate(x));
this.setX(new CoordinateInt(x));
}
public void setY(float y)
public void setY(int y)
{
this.setY(new Coordinate(y));
this.setY(new CoordinateInt(y));
}
public void setZ(float z)
public void setZ(int z)
{
this.setZ(new Coordinate(z));
this.setZ(new CoordinateInt(z));
}
public void setX(Coordinate x)
public void setX(CoordinateInt x)
{
this.setNode(0, x);
this.setNode(this.offset, x);
}
public void setY(Coordinate y)
public void setY(CoordinateInt y)
{
this.setNode(1, y);
this.setNode(this.offset + 1, y);
}
public void setZ(Coordinate z)
public void setZ(CoordinateInt z)
{
this.setNode(2, z);
this.setNode(this.offset + 2, z);
}
public Coordinate getXCoordiante()
public CoordinateInt getXCoordinate()
{
return this.getNodeAsCoordinate(0);
return this.getNodeAsCoordinateInt(this.offset);
}
public Coordinate getYCoordiante()
public CoordinateInt getYCoordinate()
{
return this.getNodeAsCoordinate(1);
return this.getNodeAsCoordinateInt(this.offset + 1);
}
public Coordinate getZCoordiante()
public CoordinateInt getZCoordinate()
{
return this.getNodeAsCoordinate(2);
return this.getNodeAsCoordinateInt(this.offset + 2);
}
public double getX()
public int getX()
{
return this.getXCoordiante().getValue();
return this.getXCoordinate().getValue();
}
public double getY()
public int getY()
{
return this.getYCoordiante().getValue();
return this.getYCoordinate().getValue();
}
public double getZ()
public int getZ()
{
return this.getZCoordiante().getValue();
return this.getZCoordinate().getValue();
}
public BlockPos getBlockPos()

View File

@@ -1,13 +1,13 @@
package exopandora.worldhandler.builder.impl.abstr;
import exopandora.worldhandler.builder.CommandBuilder;
import exopandora.worldhandler.builder.types.Coordinate;
import exopandora.worldhandler.builder.types.CoordinateInt;
import exopandora.worldhandler.helper.BlockHelper;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public abstract class BuilderDoubleBlockPos extends CommandBuilder
{
public BuilderDoubleBlockPos()
@@ -23,52 +23,49 @@ public abstract class BuilderDoubleBlockPos extends CommandBuilder
this.setZ1(pos.getZ());
}
public void setX1(float x)
public void setX1(int x)
{
this.setX1(new Coordinate(x));
this.setX1(new CoordinateInt(x));
}
public void setY1(float y)
public void setY1(int y)
{
this.setY1(new Coordinate(y));
this.setY1(new CoordinateInt(y));
}
public void setZ1(float z)
public void setZ1(int z)
{
this.setZ1(new Coordinate(z));
this.setZ1(new CoordinateInt(z));
}
public void setX1(Coordinate x)
public void setX1(CoordinateInt x)
{
this.setNode(0, x);
BlockHelper.setPos1(BlockHelper.setX(BlockHelper.getPos1(), x.getValue()));
}
public void setY1(Coordinate y)
public void setY1(CoordinateInt y)
{
this.setNode(1, y);
BlockHelper.setPos1(BlockHelper.setY(BlockHelper.getPos1(), y.getValue()));
}
public void setZ1(Coordinate z)
public void setZ1(CoordinateInt z)
{
this.setNode(2, z);
BlockHelper.setPos1(BlockHelper.setZ(BlockHelper.getPos1(), z.getValue()));
}
public Coordinate getX1Coordiante()
public CoordinateInt getX1Coordiante()
{
return this.getNodeAsCoordinate(0);
return this.getNodeAsCoordinateInt(0);
}
public Coordinate getY1Coordiante()
public CoordinateInt getY1Coordiante()
{
return this.getNodeAsCoordinate(1);
return this.getNodeAsCoordinateInt(1);
}
public Coordinate getZ1Coordiante()
public CoordinateInt getZ1Coordiante()
{
return this.getNodeAsCoordinate(2);
return this.getNodeAsCoordinateInt(2);
}
public double getX1()
@@ -98,52 +95,49 @@ public abstract class BuilderDoubleBlockPos extends CommandBuilder
this.setZ2(pos.getZ());
}
public void setX2(float x)
public void setX2(int x)
{
this.setX2(new Coordinate(x));
this.setX2(new CoordinateInt(x));
}
public void setY2(float y)
public void setY2(int y)
{
this.setY2(new Coordinate(y));
this.setY2(new CoordinateInt(y));
}
public void setZ2(float z)
public void setZ2(int z)
{
this.setZ2(new Coordinate(z));
this.setZ2(new CoordinateInt(z));
}
public void setX2(Coordinate x)
public void setX2(CoordinateInt x)
{
this.setNode(3, x);
BlockHelper.setPos2(BlockHelper.setX(BlockHelper.getPos2(), x.getValue()));
}
public void setY2(Coordinate y)
public void setY2(CoordinateInt y)
{
this.setNode(4, y);
BlockHelper.setPos2(BlockHelper.setY(BlockHelper.getPos2(), y.getValue()));
}
public void setZ2(Coordinate z)
public void setZ2(CoordinateInt z)
{
this.setNode(5, z);
BlockHelper.setPos2(BlockHelper.setZ(BlockHelper.getPos2(), z.getValue()));
}
public Coordinate getX2Coordiante()
public CoordinateInt getX2Coordiante()
{
return this.getNodeAsCoordinate(3);
return this.getNodeAsCoordinateInt(3);
}
public Coordinate getY2Coordiante()
public CoordinateInt getY2Coordiante()
{
return this.getNodeAsCoordinate(4);
return this.getNodeAsCoordinateInt(4);
}
public Coordinate getZ2Coordiante()
public CoordinateInt getZ2Coordiante()
{
return this.getNodeAsCoordinate(5);
return this.getNodeAsCoordinateInt(5);
}
public double getX2()
@@ -165,12 +159,4 @@ public abstract class BuilderDoubleBlockPos extends CommandBuilder
{
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;
}
}

View File

@@ -1,10 +1,10 @@
package exopandora.worldhandler.builder.impl.abstr;
import exopandora.worldhandler.builder.CommandBuilder;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public abstract class BuilderScoreboard extends CommandBuilder
{
@Override

View File

@@ -6,10 +6,10 @@ 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;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public enum EnumAttributes
{
MAX_HEALTH("generic.maxHealth", EnumOperation.ADDITIVE, Applyable.BOTH),
@@ -27,8 +27,9 @@ public enum EnumAttributes
private String attribute;
private EnumOperation operation;
private Applyable applyable;
public enum Applyable
@OnlyIn(Dist.CLIENT)
public static enum Applyable
{
BOTH,
PLAYER,
@@ -72,7 +73,8 @@ public enum EnumAttributes
return this.operation.getOperation().apply(value);
}
public enum EnumOperation
@OnlyIn(Dist.CLIENT)
public static enum EnumOperation
{
ADDITIVE(value -> value, "(+)"),
PERCENTAGE(value -> value / 100, "%");

View File

@@ -0,0 +1,133 @@
package exopandora.worldhandler.builder.types;
import javax.annotation.Nullable;
import com.mojang.brigadier.StringReader;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.block.state.IBlockState;
import net.minecraft.command.arguments.BlockStateParser;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.state.IProperty;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.registries.ForgeRegistries;
@OnlyIn(Dist.CLIENT)
public class BlockResourceLocation extends ItemResourceLocation
{
private IBlockState state;
public BlockResourceLocation()
{
this(null);
}
public BlockResourceLocation(ResourceLocation resource)
{
this(resource, null, null);
}
public BlockResourceLocation(ResourceLocation resource, IBlockState state, NBTTagCompound nbt)
{
super(resource, nbt);
this.state = this.findState(state, resource);
}
private IBlockState findState(IBlockState state, ResourceLocation resource)
{
boolean matchOld = this.state != null && this.state.getBlock().getRegistryName().equals(resource);
boolean matchNew = state != null && state.getBlock().getRegistryName().equals(resource);
if(matchNew)
{
return state;
}
if(matchOld)
{
return this.state;
}
if(resource != null && ForgeRegistries.BLOCKS.containsKey(resource))
{
return ForgeRegistries.BLOCKS.getValue(resource).getDefaultState();
}
return null;
}
@Override
public void setResourceLocation(ResourceLocation resource)
{
super.setResourceLocation(resource);
this.state = this.findState(null, resource);
}
public IBlockState getState()
{
return this.state;
}
public <T extends Comparable<T>> void withState(IProperty<T> property, T value)
{
if(this.state != null && this.state.has(property))
{
this.state = this.state.with(property, value);
}
}
@Nullable
public static BlockResourceLocation valueOf(String input)
{
if(input != null)
{
BlockStateParser parser = new BlockStateParser(new StringReader(input), false);
try
{
parser.parse(true);
}
catch(CommandSyntaxException e)
{
return null;
}
IBlockState state = parser.getState();
if(state != null)
{
return new BlockResourceLocation(state.getBlock().getRegistryName(), state, parser.getNbt());
}
}
return null;
}
@Override
public BlockResourceLocation get()
{
return (BlockResourceLocation) super.get();
}
@Override
public String toString()
{
if(this.resource != null && this.state != null)
{
StringBuilder builder = new StringBuilder(this.state.toString());
String block = this.state.getBlock().toString();
builder.replace(0, block.length(), this.resource.toString());
if(this.nbt != null)
{
builder.append(this.nbt.toString());
}
return builder.toString();
}
return null;
}
}

View File

@@ -1,63 +1,104 @@
package exopandora.worldhandler.builder.types;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.function.Function;
@SideOnly(Side.CLIENT)
public class Coordinate
import javax.annotation.Nullable;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public abstract class Coordinate<T extends Number> implements ICoordinate<T>
{
private double value;
private boolean relative;
protected T value;
protected CoordinateType type;
public Coordinate()
public Coordinate(T value)
{
this(0, true);
this(value, CoordinateType.ABSOLUTE);
}
public Coordinate(double value)
public Coordinate(T value, CoordinateType type)
{
this(value, false);
}
public Coordinate(double value, boolean relative)
{
this.relative = relative;
this.value = value;
this.type = type;
}
public void setValue(double value)
public void setValue(T value)
{
this.value = value;
}
public double getValue()
public T getValue()
{
return this.value;
}
public void setRelative(boolean relative)
public void setType(CoordinateType type)
{
this.relative = relative;
this.type = type;
}
public boolean isRelative()
public CoordinateType getType()
{
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);
return this.type;
}
@Override
public String toString()
{
return String.valueOf(this.relative ? (this.value != 0 ? "~" + this.value : "~") : this.value);
return this.type.format(this.value, this.zero());
}
@Nullable
public static <S extends Number, U extends Coordinate<S>> U parse(U coordiante, String input, Function<String, S> parser)
{
for(CoordinateType type : CoordinateType.values())
{
if(!type.prefix.isEmpty() && input.startsWith(type.prefix))
{
String numbers = input.substring(type.prefix.length());
coordiante.setType(type);
coordiante.setValue(numbers.isEmpty() ? coordiante.zero() : parser.apply(numbers));
return coordiante;
}
}
coordiante.setType(CoordinateType.ABSOLUTE);
coordiante.setValue(parser.apply(input));
return coordiante;
}
@OnlyIn(Dist.CLIENT)
public static enum CoordinateType
{
ABSOLUTE(""),
GLOBAL("~"),
LOCAL("^");
private final String prefix;
private CoordinateType(String prefix)
{
this.prefix = prefix;
}
public <T extends Number> String format(T value, T zero)
{
if(value == null || value.equals(zero))
{
if(this.prefix.isEmpty())
{
return zero.toString();
}
return this.prefix;
}
return this.prefix + value;
}
}
}

View File

@@ -0,0 +1,39 @@
package exopandora.worldhandler.builder.types;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public class CoordinateDouble extends Coordinate<Double>
{
public CoordinateDouble()
{
super(0.0);
}
public CoordinateDouble(Double value)
{
super(value);
}
public CoordinateDouble(CoordinateType type)
{
super(0.0, type);
}
public CoordinateDouble(Double value, CoordinateType type)
{
super(value, type);
}
public static CoordinateDouble valueOf(String value)
{
return Coordinate.parse(new CoordinateDouble(), value, Double::parseDouble);
}
@Override
public Double zero()
{
return 0.0;
}
}

View File

@@ -0,0 +1,39 @@
package exopandora.worldhandler.builder.types;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public class CoordinateInt extends Coordinate<Integer>
{
public CoordinateInt()
{
super(0);
}
public CoordinateInt(Integer value)
{
super(value);
}
public CoordinateInt(CoordinateType type)
{
super(0, type);
}
public CoordinateInt(Integer value, CoordinateType type)
{
super(value, type);
}
public static CoordinateInt valueOf(String value)
{
return Coordinate.parse(new CoordinateInt(), value, Integer::parseInt);
}
@Override
public Integer zero()
{
return 0;
}
}

View File

@@ -0,0 +1,54 @@
package exopandora.worldhandler.builder.types;
import javax.annotation.Nullable;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public class GreedyString
{
private String string;
public GreedyString(String string)
{
this.string = string;
}
public String getString()
{
return this.string;
}
public void setString(String string)
{
this.string = string;
}
public boolean isEmpty()
{
if(this.string == null)
{
return true;
}
return this.string.isEmpty();
}
@Nullable
public static GreedyString valueOf(String string)
{
if(string != null && string.matches("\"(.*)\""))
{
return new GreedyString(string.substring(1, string.length() - 1));
}
return null;
}
@Override
public String toString()
{
return "\"" + this.string + "\"";
}
}

View File

@@ -0,0 +1,10 @@
package exopandora.worldhandler.builder.types;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public interface ICoordinate<T extends Number>
{
T zero();
}

View File

@@ -0,0 +1,104 @@
package exopandora.worldhandler.builder.types;
import javax.annotation.Nullable;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.nbt.JsonToNBT;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public class ItemResourceLocation
{
protected ResourceLocation resource;
protected NBTTagCompound nbt;
public ItemResourceLocation()
{
this(null, null);
}
public ItemResourceLocation(ResourceLocation resource)
{
this(resource, null);
}
public ItemResourceLocation(ResourceLocation resource, NBTTagCompound nbt)
{
this.resource = resource;
this.nbt = nbt;
}
public ResourceLocation getResourceLocation()
{
return this.resource;
}
public void setResourceLocation(ResourceLocation resource)
{
this.resource = resource;
}
public NBTTagCompound getNBT()
{
return this.nbt;
}
public void setNBT(NBTTagCompound nbt)
{
this.nbt = nbt;
}
public ItemResourceLocation get()
{
if(this.resource != null)
{
return this;
}
return null;
}
@Nullable
public static ItemResourceLocation valueOf(String input)
{
int start = input.indexOf("{");
ResourceLocation resource = new ResourceLocation(input.substring(0, start));
NBTTagCompound nbt = null;
if(start > 0)
{
try
{
nbt = JsonToNBT.getTagFromJson(input.substring(start, input.lastIndexOf("}") + 1));
}
catch(CommandSyntaxException e)
{
return null;
}
}
return new ItemResourceLocation(resource, nbt);
}
@Override
public String toString()
{
if(this.resource != null)
{
StringBuilder builder = new StringBuilder(this.resource.toString());
if(this.nbt != null)
{
builder.append(this.nbt.toString());
}
return builder.toString();
}
return null;
}
}

View File

@@ -1,52 +0,0 @@
package exopandora.worldhandler.builder.types;
import javax.annotation.Nullable;
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;
}
@Nullable
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";
}
}

View File

@@ -7,10 +7,10 @@ import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public class TargetSelector
{
private final Map<String, Object> values = new HashMap<String, Object>();
@@ -20,8 +20,9 @@ public class TargetSelector
{
this.values.put(id.toLowerCase(), value);
}
@Nullable
@SuppressWarnings("unchecked")
public <T> T get(String id)
{
return (T) this.values.get(id);

View File

@@ -4,14 +4,15 @@ import java.util.function.Function;
import javax.annotation.Nullable;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
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;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public enum Type
{
SHORT(Short::valueOf),
@@ -22,11 +23,14 @@ public enum Type
LONG(Long::valueOf),
BOOLEAN(Boolean::valueOf),
STRING(String::valueOf),
GREEDY_STRING(GreedyString::valueOf),
RESOURCE_LOCATION(Type::parseResourceLocation),
ITEM_RESOURCE_LOCATION(ItemResourceLocation::valueOf),
BLOCK_RESOURCE_LOCATION(BlockResourceLocation::valueOf),
NBT(Type::parseNBTTagCompound),
COORDINATE(Coordinate::valueOf),
TARGET_SELECTOR(TargetSelector::valueOf),
LEVEL(Level::valueOf);
COORDINATE_INT(CoordinateInt::valueOf),
COORDINATE_DOUBLE(CoordinateDouble::valueOf),
TARGET_SELECTOR(TargetSelector::valueOf);
private final Function<String, Object> parser;
@@ -36,6 +40,7 @@ public enum Type
}
@Nullable
@SuppressWarnings("unchecked")
public <T> T parse(String object)
{
return (T) this.parser.apply(object);
@@ -56,7 +61,7 @@ public enum Type
{
return JsonToNBT.getTagFromJson(value);
}
catch(NBTException nbtexception)
catch(CommandSyntaxException e)
{
return null;
}