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

@@ -7,14 +7,14 @@ import java.util.Locale;
import javax.swing.UIManager;
import exopandora.worldhandler.installer.Window;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class Main
{
public static final String NAME = "World Handler";
public static final String MODID = "worldhandler";
public static final String MC_VERSION = "1.13.2";
public static final String MOD_VERSION = "2.3";
public static final String URL = "https://minecraft.curseforge.com/projects/world-handler-command-gui";
public static void main(String[] args)
{

View File

@@ -1,195 +1,75 @@
package exopandora.worldhandler;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.lwjgl.input.Keyboard;
import org.lwjgl.glfw.GLFW;
import exopandora.worldhandler.builder.ICommandBuilder;
import exopandora.worldhandler.builder.ICommandBuilderSyntax;
import exopandora.worldhandler.command.CommandWH;
import exopandora.worldhandler.command.CommandWorldHandler;
import exopandora.worldhandler.config.ConfigButcher;
import exopandora.worldhandler.config.ConfigSettings;
import exopandora.worldhandler.config.ConfigSkin;
import exopandora.worldhandler.config.ConfigSliders;
import exopandora.worldhandler.event.EventListener;
import exopandora.worldhandler.config.Config;
import exopandora.worldhandler.gui.category.Category;
import exopandora.worldhandler.gui.content.Content;
import exopandora.worldhandler.helper.BlockHelper;
import exopandora.worldhandler.helper.CommandHelper;
import exopandora.worldhandler.proxy.ClientProxy;
import exopandora.worldhandler.proxy.CommonProxy;
import exopandora.worldhandler.util.UtilKeyBinding;
import net.minecraft.client.Minecraft;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.command.ICommand;
import net.minecraft.util.text.ChatType;
import net.minecraft.util.text.Style;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.util.text.event.ClickEvent;
import net.minecraft.util.text.event.ClickEvent.Action;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.Mod.Instance;
import net.minecraftforge.fml.common.ProgressManager;
import net.minecraftforge.fml.common.ProgressManager.ProgressBar;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLLoadCompleteEvent;
import net.minecraftforge.fml.common.event.FMLModDisabledEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.fml.config.ModConfig.Type;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent;
import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
@SideOnly(Side.CLIENT)
@Mod(modid = Main.MODID, name = Main.NAME, acceptedMinecraftVersions = "[$compatible,)", version = "$version", canBeDeactivated = true, guiFactory = "exopandora.worldhandler.gui.config.GuiFactoryWorldHandler", updateJSON = "$update_url", clientSideOnly = true, certificateFingerprint = "$certificate")
@Mod(Main.MODID)
public class WorldHandler
{
@Instance(Main.MODID)
private static WorldHandler INSTANCE;
public static final Logger LOGGER = LogManager.getLogger();
public static KeyBinding KEY_WORLD_HANDLER = new KeyBinding(Main.NAME, Keyboard.KEY_V, "key.categories.misc");
public static KeyBinding KEY_WORLD_HANDLER_POS1 = new KeyBinding(Main.NAME + " Pos1", Keyboard.KEY_O, "key.categories.misc");
public static KeyBinding KEY_WORLD_HANDLER_POS2 = new KeyBinding(Main.NAME + " Pos2", Keyboard.KEY_P, "key.categories.misc");
public static final KeyBinding KEY_WORLD_HANDLER = new KeyBinding(Main.NAME, GLFW.GLFW_KEY_V, "key.categories.misc");
public static final KeyBinding KEY_WORLD_HANDLER_POS1 = new KeyBinding(Main.NAME + " Pos1", GLFW.GLFW_KEY_O, "key.categories.misc");
public static final KeyBinding KEY_WORLD_HANDLER_POS2 = new KeyBinding(Main.NAME + " Pos2", GLFW.GLFW_KEY_P, "key.categories.misc");
public static final ICommand COMMAND_WORLD_HANDLER = new CommandWorldHandler();
public static final ICommand COMMAND_WH = new CommandWH();
public static Configuration CONFIG;
public static Logger LOGGER;
public static String USERNAME = null;
@SidedProxy(clientSide = "exopandora.worldhandler.proxy.ClientProxy", serverSide = "exopandora.worldhandler.proxy.CommonProxy")
private static CommonProxy PROXY;
private EventListener eventListener = new EventListener();
private static CommonProxy SIDEPROXY;
@EventHandler
public void preInit(FMLPreInitializationEvent event)
public WorldHandler()
{
LOGGER = event.getModLog();
LOGGER.info("Pre-Initialization");
LOGGER.info("First Release on March 28 2013 - 02:29 PM CET by Exopandora");
LOGGER.info("Latest Version: $url");
CONFIG = new Configuration(event.getSuggestedConfigurationFile());
SIDEPROXY = DistExecutor.runForDist(() -> ClientProxy::new, () -> CommonProxy::new);
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::commonSetup);
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::clientSetup);
FMLJavaModLoadingContext.get().getModEventBus().addListener(this::loadComplete);
FMLJavaModLoadingContext.get().getModEventBus().addListener(Config::configLoad);
FMLJavaModLoadingContext.get().getModEventBus().addListener(Config::configReload);
ModLoadingContext.get().registerConfig(Type.CLIENT, Config.CLIENT_SPEC, Main.MODID + ".toml");
MinecraftForge.EVENT_BUS.addListener(this::serverStarting);
}
@EventHandler
public void init(FMLInitializationEvent event)
private void commonSetup(FMLCommonSetupEvent event)
{
LOGGER.info("Initialization");
USERNAME = Minecraft.getMinecraft().getSession().getUsername();
MinecraftForge.EVENT_BUS.register(this.eventListener);
SIDEPROXY.setup();
}
private void clientSetup(FMLClientSetupEvent event)
{
USERNAME = Minecraft.getInstance().getSession().getUsername();
ClientRegistry.registerKeyBinding(KEY_WORLD_HANDLER);
UtilKeyBinding.updatePosKeys();
}
@EventHandler
public void postInit(FMLPostInitializationEvent event)
private void loadComplete(FMLLoadCompleteEvent event)
{
LOGGER.info("Post-Initialization");
}
@EventHandler
public void loadComplete(FMLLoadCompleteEvent event)
{
LOGGER.info("Load-Complete");
ProgressBar bar = ProgressManager.push(Main.NAME, 2);
bar.step("Loading Configuration Files");
ConfigSettings.load(CONFIG);
ConfigSkin.load(CONFIG);
ConfigSliders.load(CONFIG);
ConfigButcher.load(CONFIG);
bar.step("Initializing User Interface");
Content.registerContents();
Category.registerCategories();
ProgressManager.pop(bar);
}
@EventHandler
public void serverLoad(FMLServerStartingEvent event)
private void serverStarting(FMLServerStartingEvent event)
{
event.registerServerCommand(COMMAND_WORLD_HANDLER);
event.registerServerCommand(COMMAND_WH);
}
@EventHandler
public void disable(FMLModDisabledEvent event)
{
MinecraftForge.EVENT_BUS.register(this.eventListener);
Minecraft.getMinecraft().gameSettings.keyBindings = ArrayUtils.removeElement(Minecraft.getMinecraft().gameSettings.keyBindings, KEY_WORLD_HANDLER);
if(UtilKeyBinding.arePosKeysRegistered() && ConfigSettings.arePosShortcutsEnabled())
{
UtilKeyBinding.removePosKeys();
}
}
public static void updateConfig()
{
ConfigSettings.load(CONFIG);
ConfigSkin.load(CONFIG);
ConfigButcher.load(CONFIG);
ConfigSliders.load(CONFIG);
UtilKeyBinding.updatePosKeys();
}
public static void sendCommand(ICommandBuilder builder)
{
sendCommand(builder, false);
}
public static void sendCommand(ICommandBuilder builder, boolean special)
{
if(builder != null)
{
String command;
if(builder instanceof ICommandBuilderSyntax)
{
command = ((ICommandBuilderSyntax) builder).toActualCommand();
}
else
{
command = builder.toCommand();
}
LOGGER.info("Command: " + command);
if(builder.needsCommandBlock() || special)
{
BlockHelper.setCommandBlockNearPlayer(command);
}
else
{
Minecraft.getMinecraft().player.sendChatMessage(command);
}
}
}
public static void throwError(Exception exception)
{
if(!Minecraft.getMinecraft().inGameHasFocus)
{
Minecraft.getMinecraft().displayGuiScreen(null);
Minecraft.getMinecraft().setIngameFocus();
}
TextComponentString name = new TextComponentString(Main.NAME);
name.setStyle(new Style().setUnderlined(true).setClickEvent(new ClickEvent(Action.OPEN_URL, "$url")));
TextComponentTranslation message = new TextComponentTranslation("worldhandler.error.gui", name);
message.setStyle(new Style().setColor(net.minecraft.util.text.TextFormatting.RED));
Minecraft.getMinecraft().ingameGUI.addChatMessage(ChatType.SYSTEM, message);
exception.printStackTrace();
CommandHelper.registerCommands(event.getCommandDispatcher());
}
}

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;
}

View File

@@ -1,231 +1,89 @@
package exopandora.worldhandler.command;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import exopandora.worldhandler.WorldHandler;
import exopandora.worldhandler.builder.impl.BuilderClone;
import exopandora.worldhandler.builder.impl.BuilderClone.EnumMask;
import exopandora.worldhandler.builder.impl.BuilderFill;
import exopandora.worldhandler.builder.impl.BuilderWH;
import exopandora.worldhandler.helper.BlockHelper;
import exopandora.worldhandler.helper.EnumHelper;
import exopandora.worldhandler.helper.ResourceHelper;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.command.NumberInvalidException;
import net.minecraft.command.WrongUsageException;
import net.minecraft.server.MinecraftServer;
import exopandora.worldhandler.helper.CommandHelper;
import net.minecraft.command.CommandSource;
import net.minecraft.command.Commands;
import net.minecraft.command.arguments.BlockStateArgument;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextComponentString;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.registries.ForgeRegistries;
@SideOnly(Side.CLIENT)
public class CommandWH extends CommandBase
public class CommandWH
{
@Override
public String getName()
public static void register(CommandDispatcher<CommandSource> dispatcher)
{
return "wh";
dispatcher.register(Commands.literal("wh")
.then(Commands.literal("pos1")
.executes(context -> pos1(context.getSource())))
.then(Commands.literal("pos2")
.executes(context -> pos2(context.getSource())))
.then(Commands.literal("fill")
.then(Commands.argument("block", BlockStateArgument.blockState())
.executes(context -> fill(context.getSource(), StringArgumentType.getString(context, "block")))))
.then(Commands.literal("replace")
.then(Commands.argument("block", BlockStateArgument.blockState())
.then(Commands.argument("replace", BlockStateArgument.blockState())
.executes(context -> replace(context.getSource(), StringArgumentType.getString(context, "block"), StringArgumentType.getString(context, "replace"))))))
.then(Commands.literal("clone")
.then(Commands.literal("replace")
.executes(context -> clone(context.getSource(), EnumMask.REPLACE)))
.then(Commands.literal("masked")
.executes(context -> clone(context.getSource(), EnumMask.MASKED)))
.then(Commands.literal("filtered")
.executes(context -> clone(context.getSource(), EnumMask.FILTERED)))));
}
@Override
public int getRequiredPermissionLevel()
private static int pos1(CommandSource source) throws CommandSyntaxException
{
return 0;
BlockHelper.setPos1(BlockHelper.getFocusedBlockPos());
BlockPos pos = BlockHelper.getPos1();
ResourceLocation block = ForgeRegistries.BLOCKS.getKey(BlockHelper.getBlock(pos));
CommandHelper.sendFeedback(source, "Set first position to " + pos.getX() + ", " + pos.getY() + ", " + pos.getZ() + " (" + block + ")");
return 1;
}
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
private static int pos2(CommandSource source) throws CommandSyntaxException
{
if(args.length > 0)
{
if(args[0].equals("pos1"))
{
BlockHelper.setPos1(BlockHelper.getFocusedBlockPos());
sender.sendMessage(new TextComponentString("Set first position to " + BlockHelper.getPos1().getX() + ", " + BlockHelper.getPos1().getY() + ", " + BlockHelper.getPos1().getZ() + " (" + Block.REGISTRY.getNameForObject(BlockHelper.getFocusedBlock()) + ")"));
}
else if(args[0].equals("pos2"))
{
BlockHelper.setPos2(BlockHelper.getFocusedBlockPos());
sender.sendMessage(new TextComponentString("Set second position to " + BlockHelper.getPos2().getX() + ", " + BlockHelper.getPos2().getY() + ", " + BlockHelper.getPos2().getZ() + " (" + Block.REGISTRY.getNameForObject(BlockHelper.getFocusedBlock()) + ")"));
}
else if(args[0].equals("fill"))
{
final String usage = "/wh fill <block> [meta]";
if(args.length > 1)
{
ResourceLocation id = new ResourceLocation(args[1]);
int meta = 0;
if(args.length > 2)
{
try
{
meta = Integer.parseInt(args[2]);
}
catch(Exception e)
{
throw new WrongUsageException(usage);
}
}
if(!ResourceHelper.isRegisteredBlock(id.toString()))
{
throw new NumberInvalidException(usage);
}
BuilderFill builder = new BuilderFill();
builder.setBlock1(id);
builder.setMeta1(meta);
WorldHandler.sendCommand(builder);
}
else
{
throw new WrongUsageException(usage);
}
}
else if(args[0].equals("replace"))
{
final String usage = "/wh replace <block1> <meta1> <block2> [meta2]";
if(args.length > 1)
{
ResourceLocation id1 = new ResourceLocation(args[1]);
if(args.length > 2)
{
ResourceLocation id2 = new ResourceLocation(args[3]);
int meta1 = 0;
int meta2 = 0;
try
{
meta1 = Integer.parseInt(args[2]);
}
catch(Exception e)
{
throw new WrongUsageException(usage);
}
if(args.length > 4)
{
try
{
meta2 = Integer.parseInt(args[4]);
}
catch(Exception e)
{
throw new WrongUsageException(usage);
}
}
if(!ResourceHelper.isRegisteredBlock(id1.toString()) || !ResourceHelper.isRegisteredBlock(id2.toString()))
{
throw new WrongUsageException(usage);
}
BuilderFill builder = new BuilderFill();
builder.setPosition1(BlockHelper.getPos1());
builder.setPosition2(BlockHelper.getPos2());
builder.setBlock1(id1);
builder.setMeta1(meta1);
builder.setBlock2(id2);
builder.setMeta2(meta2);
Minecraft.getMinecraft().player.sendChatMessage(builder.getBuilderForReplace().toActualCommand());
}
else
{
throw new WrongUsageException(usage);
}
}
else
{
throw new WrongUsageException(usage);
}
}
else if(args[0].equals("clone"))
{
final String usage = "/wh clone [" + String.join("|", Arrays.stream(EnumMask.MASKED.values()).map(EnumMask::toString).collect(Collectors.toList())) + "]";
EnumMask mask = EnumMask.MASKED;
if(args.length > 1)
{
mask = EnumHelper.valueOf(EnumMask.class, args[1]);
}
if(mask == null)
{
throw new WrongUsageException(usage);
}
BuilderClone builder = new BuilderClone();
builder.setPosition1(BlockHelper.getPos1());
builder.setPosition2(BlockHelper.getPos2());
builder.setMask(mask);
Minecraft.getMinecraft().player.sendChatMessage(builder.toActualCommand());
}
else
{
throw new WrongUsageException(new BuilderWH().toCommand());
}
}
else
{
throw new WrongUsageException(new BuilderWH().toCommand());
}
}
@Override
public List<String> getTabCompletions(MinecraftServer server, ICommandSender sender, String[] args, BlockPos pos)
{
if(args.length == 1)
{
return this.getListOfStringsMatchingLastWord(args, new String[]{"pos1", "pos2", "fill", "replace", "clone"});
}
else if(args.length == 2)
{
if(args[0].equals("fill") || args[0].equals("replace"))
{
return this.getListOfStringsMatchingLastWord(args, Block.REGISTRY.getKeys());
}
else if(args[0].equals("clone"))
{
return this.getListOfStringsMatchingLastWord(args, new String[]{"replace", "masked", "filtered"});
}
}
else if(args.length == 3)
{
if(args[0].equals("fill") || args[0].equals("replace"))
{
return this.getListOfStringsMatchingLastWord(args, new String[] {"0"});
}
}
else if(args.length == 4)
{
if(args[0].equals("replace"))
{
return this.getListOfStringsMatchingLastWord(args, Block.REGISTRY.getKeys());
}
}
return Collections.<String>emptyList();
BlockHelper.setPos2(BlockHelper.getFocusedBlockPos());
BlockPos pos = BlockHelper.getPos2();
ResourceLocation block = ForgeRegistries.BLOCKS.getKey(BlockHelper.getBlock(pos));
CommandHelper.sendFeedback(source, "Set second position to " + pos.getX() + ", " + pos.getY() + ", " + pos.getZ() + " (" + block + ")");
return 1;
}
@Override
public String getUsage(ICommandSender sender)
private static int fill(CommandSource source, String block)
{
return new BuilderWH().toCommand();
BuilderFill builder = new BuilderFill();
builder.setBlock1(block);
CommandHelper.sendCommand(builder);
return 1;
}
}
private static int replace(CommandSource source, String block, String replace)
{
BuilderFill builder = new BuilderFill();
builder.setPosition1(BlockHelper.getPos1());
builder.setPosition2(BlockHelper.getPos2());
builder.setBlock1(block);
builder.setBlock2(replace);
CommandHelper.sendCommand(builder);
return 1;
}
private static int clone(CommandSource source, EnumMask mask)
{
BuilderClone builder = new BuilderClone();
builder.setPosition1(BlockHelper.getPos1());
builder.setPosition2(BlockHelper.getPos2());
builder.setMask(mask);
return 1;
}
}

View File

@@ -1,100 +1,51 @@
package exopandora.worldhandler.command;
import java.util.Collections;
import java.util.List;
import org.apache.maven.artifact.versioning.ComparableVersion;
import com.mojang.realmsclient.gui.ChatFormatting;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import exopandora.worldhandler.Main;
import exopandora.worldhandler.WorldHandler;
import exopandora.worldhandler.builder.impl.BuilderWorldHandler;
import exopandora.worldhandler.event.EventListener;
import exopandora.worldhandler.helper.ActionHelper;
import exopandora.worldhandler.helper.CommandHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.command.WrongUsageException;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextComponentString;
import net.minecraftforge.common.ForgeVersion;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.versioning.ComparableVersion;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraft.command.CommandSource;
import net.minecraft.command.Commands;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.fml.VersionChecker;
@SideOnly(Side.CLIENT)
public class CommandWorldHandler extends CommandBase
public class CommandWorldHandler
{
@Override
public String getName()
public static void register(CommandDispatcher<CommandSource> dispatcher)
{
return "worldhandler";
dispatcher.register(Commands.literal("worldhandler")
.then(Commands.literal("help")
.executes(context -> help(context.getSource())))
.then(Commands.literal("display")
.executes(context -> display()))
.then(Commands.literal("version")
.executes(context -> version(context.getSource()))));
}
@Override
public int getRequiredPermissionLevel()
private static int help(CommandSource source) throws CommandSyntaxException
{
return 0;
CommandHelper.sendFeedback(source, "/worldhandler help");
CommandHelper.sendFeedback(source, "/worldhandler display");
CommandHelper.sendFeedback(source, "/worldhandler version");
return 1;
}
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
private static int display() throws CommandSyntaxException
{
if(args.length > 0)
{
if(args[0].equalsIgnoreCase("help"))
{
this.printHelp(sender);
}
else if(args[0].equalsIgnoreCase("display"))
{
Minecraft.getMinecraft().addScheduledTask(EventListener::displayGui);
}
else if(args[0].equalsIgnoreCase("version"))
{
sender.sendMessage(new TextComponentString("Installed: $mcversion-$version"));
ComparableVersion target = ForgeVersion.getResult(Loader.instance().getIndexedModList().get(Main.MODID)).target;
sender.sendMessage(new TextComponentString("Latest: $mcversion-" + (target != null ? target : "$version")));
}
else
{
throw new WrongUsageException(this.getUsage(sender));
}
}
else if(args.length == 0)
{
this.printHelp(sender);
}
else
{
throw new WrongUsageException(this.getUsage(sender));
}
Minecraft.getInstance().addScheduledTask(ActionHelper::displayGui);
return 1;
}
private void printHelp(ICommandSender player)
private static int version(CommandSource source) throws CommandSyntaxException
{
player.sendMessage(new TextComponentString(ChatFormatting.DARK_GREEN + "--- Showing help page 1 of 1 (/worldhandler help) ---"));
player.sendMessage(new TextComponentString("/worldhandler help"));
player.sendMessage(new TextComponentString("/worldhandler display"));
player.sendMessage(new TextComponentString("/worldhandler version"));
player.sendMessage(new TextComponentString(ChatFormatting.GREEN + "Tip: Press '" + WorldHandler.KEY_WORLD_HANDLER.getDisplayName() + "' to open the World Handler"));
CommandHelper.sendFeedback(source, "Installed: $mcversion-$version");
ComparableVersion target = VersionChecker.getResult(ModList.get().getModContainerById(Main.MODID).get().getModInfo()).target;
CommandHelper.sendFeedback(source, "Latest: " + Main.MC_VERSION + "-" + (target != null ? target : Main.MOD_VERSION));
return 1;
}
@Override
public List<String> getTabCompletions(MinecraftServer server, ICommandSender sender, String[] args, BlockPos pos)
{
if(args.length == 1)
{
return this.getListOfStringsMatchingLastWord(args, new String[]{"help", "display", "version"});
}
return Collections.<String>emptyList();
}
@Override
public String getUsage(ICommandSender sender)
{
return new BuilderWorldHandler().toCommand();
}
}
}

View File

@@ -1,45 +0,0 @@
package exopandora.worldhandler.command;
import net.minecraft.client.Minecraft;
import net.minecraft.command.CommandHandler;
import net.minecraft.command.ICommand;
import net.minecraft.server.MinecraftServer;
import net.minecraftforge.client.event.ClientChatEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class FakeCommandHandler extends CommandHandler
{
@Override
protected MinecraftServer getServer()
{
return null;
}
private void fakeCommand(ICommand command, ClientChatEvent event)
{
Minecraft.getMinecraft().ingameGUI.getChatGUI().addToSentMessages(event.getMessage());
this.tryExecute(Minecraft.getMinecraft().player, dropFirstString(event.getMessage().split(" ")), command, event.getMessage());
if(event != null && event.isCancelable())
{
event.setCanceled(true);
}
}
private static String[] dropFirstString(String[] input)
{
String[] string = new String[input.length - 1];
System.arraycopy(input, 1, string, 0, input.length - 1);
return string;
}
public void tryCommand(ICommand command, ClientChatEvent event)
{
if(event.getMessage().equals("/" + command.getName()) || event.getMessage().startsWith("/" + command.getName() + " "))
{
this.fakeCommand(command, event);
}
}
}

View File

@@ -0,0 +1,124 @@
package exopandora.worldhandler.config;
import java.util.List;
import org.apache.commons.lang3.tuple.Pair;
import com.electronwill.nightconfig.core.file.CommentedFileConfig;
import exopandora.worldhandler.util.UtilKeyBinding;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.fml.config.ModConfig;
import net.minecraftforge.fml.config.ModConfig.Type;
public class Config
{
public static final ForgeConfigSpec CLIENT_SPEC;
public static final ClientConfig CLIENT;
private static ModConfig MOD_CONFIG;
private static CommentedFileConfig CONFIG_DATA;
static
{
Pair<ClientConfig, ForgeConfigSpec> pair = new ForgeConfigSpec.Builder().configure(ClientConfig::new);
CLIENT_SPEC = pair.getRight();
CLIENT = pair.getLeft();
}
@OnlyIn(Dist.CLIENT)
public static class ClientConfig
{
private final ConfigCategorySettings settings;
private final ConfigCategoryButcher butcher;
private final ConfigCategorySkin skin;
private final ConfigCategorySliders sliders;
public ClientConfig(ForgeConfigSpec.Builder builder)
{
this.settings = new ConfigCategorySettings(builder);
this.butcher = new ConfigCategoryButcher(builder);
this.skin = new ConfigCategorySkin(builder);
this.sliders = new ConfigCategorySliders(builder);
}
public void read()
{
this.getSettings().read();
this.getButcher().read();
this.getSkin().read();
this.getSliders().read();
}
public ConfigCategorySettings getSettings()
{
return this.settings;
}
public ConfigCategoryButcher getButcher()
{
return this.butcher;
}
public ConfigCategorySkin getSkin()
{
return this.skin;
}
public ConfigCategorySliders getSliders()
{
return this.sliders;
}
}
public static ConfigCategorySettings getSettings()
{
return Config.CLIENT.getSettings();
}
public static ConfigCategoryButcher getButcher()
{
return Config.CLIENT.getButcher();
}
public static ConfigCategorySkin getSkin()
{
return Config.CLIENT.getSkin();
}
public static ConfigCategorySliders getSliders()
{
return Config.CLIENT.getSliders();
}
protected static <T> void set(ForgeConfigSpec.ConfigValue<T> configValue, T value)
{
if(configValue != null && value != null && (!value.equals(configValue.get()) || configValue.get() instanceof List<?>))
{
Config.CONFIG_DATA.set(configValue.getPath(), value);
}
}
public static void configLoad(ModConfig.Loading event)
{
if(event.getConfig().getType().equals(Type.CLIENT))
{
Config.MOD_CONFIG = event.getConfig();
Config.CONFIG_DATA = (CommentedFileConfig) Config.MOD_CONFIG.getConfigData();
Config.CLIENT.read();
}
}
public static void configReload(ModConfig.ConfigReloading event)
{
if(event.getConfig().getType().equals(Type.CLIENT) && Config.CONFIG_DATA != null)
{
Config.CONFIG_DATA.load();
Config.CLIENT.read();
UtilKeyBinding.updatePosKeys();
}
}
}

View File

@@ -1,45 +0,0 @@
package exopandora.worldhandler.config;
import java.util.HashMap;
import java.util.Map;
import exopandora.worldhandler.helper.EntityHelper;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.EntityList;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class ConfigButcher
{
private static Map<String, Boolean> ENTITIES = new HashMap<String, Boolean>();
public static final String CATEGORY = "butcher";
public static void load(Configuration config)
{
for(ResourceLocation location : EntityList.ENTITY_EGGS.keySet())
{
String entity = EntityHelper.getEntityName(location);
String translationKey = "entity." + entity + ".name";
String translation = I18n.format(translationKey);
if(!translation.equals(translationKey))
{
ENTITIES.put(entity, config.getBoolean(entity, CATEGORY, false, I18n.format("gui.worldhandler.config.comment.butcher", translation), translationKey));
}
}
if(config.hasChanged())
{
config.save();
}
}
public static Map<String, Boolean> getEntitiyMap()
{
return ENTITIES;
}
}

View File

@@ -0,0 +1,93 @@
package exopandora.worldhandler.config;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.common.ForgeConfigSpec.ConfigValue;
import net.minecraftforge.registries.ForgeRegistries;
@OnlyIn(Dist.CLIENT)
public class ConfigCategoryButcher
{
private final List<String> entities = new ArrayList<String>();
private final ConfigValue<List<? extends String>> valueEntities;
public ConfigCategoryButcher(ForgeConfigSpec.Builder builder)
{
builder.push("butcher");
this.valueEntities = builder.defineList("entities", Collections.<String>emptyList(), this::isValid);
builder.pop();
}
public void read()
{
this.entities.clear();
this.entities.addAll(this.valueEntities.get());
}
private void write()
{
Config.set(this.valueEntities, this.entities);
}
public List<ResourceLocation> getEntities()
{
List<ResourceLocation> list = new ArrayList<ResourceLocation>();
for(String entity : this.entities)
{
ResourceLocation resource = ResourceLocation.makeResourceLocation(entity);
if(resource != null)
{
list.add(resource);
}
}
return list;
}
public boolean containsEntity(ResourceLocation entity)
{
return this.entities.contains(entity.toString());
}
public void addEntity(ResourceLocation entity)
{
if(this.isValid(entity))
{
this.entities.add(entity.toString());
this.write();
}
}
public boolean removeEntity(ResourceLocation entity)
{
boolean removed = this.entities.remove(entity.toString());
if(removed)
{
this.write();
}
return removed;
}
private boolean isValid(Object string)
{
if(string != null)
{
return ForgeRegistries.ENTITIES.containsKey(ResourceLocation.makeResourceLocation(string.toString()));
}
return false;
}
}

View File

@@ -0,0 +1,320 @@
package exopandora.worldhandler.config;
import java.util.Arrays;
import net.minecraft.client.resources.I18n;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.common.ForgeConfigSpec.BooleanValue;
import net.minecraftforge.common.ForgeConfigSpec.ConfigValue;
import net.minecraftforge.common.ForgeConfigSpec.IntValue;
@OnlyIn(Dist.CLIENT)
public class ConfigCategorySettings
{
private boolean commandSyntax;
private boolean shortcuts;
private boolean shortcutKeys;
private boolean tooltips;
private boolean watch;
private boolean smoothWatch;
private boolean pause;
private boolean customTimes;
private boolean permissionQuery;
private boolean highlightBlocks;
private int dawn;
private int noon;
private int sunset;
private int midnight;
private String blockPlacingMode;
private final BooleanValue valueCommandSyntax;
private final BooleanValue valueShortcuts;
private final BooleanValue valueShortcutKeys;
private final BooleanValue valueTooltips;
private final BooleanValue valueWatch;
private final BooleanValue valueSmoothWatch;
private final BooleanValue valuePause;
private final BooleanValue valueCustomTimes;
private final BooleanValue valuePermissionQuery;
private final BooleanValue valueHighlightBlocks;
private final IntValue valueDawn;
private final IntValue valueNoon;
private final IntValue valueSunset;
private final IntValue valueMidnight;
private final ConfigValue<String> valueBlockPlacingMode;
public ConfigCategorySettings(ForgeConfigSpec.Builder builder)
{
builder.push("settings");
this.valueCommandSyntax = builder
.comment(I18n.format("gui.worldhandler.config.comment.settings.command_syntax"))
.translation("gui.worldhandler.config.key.settings.command_syntax")
.define("command_syntax", false);
this.valueShortcuts = builder
.comment(I18n.format("gui.worldhandler.config.comment.settings.shortcuts"))
.translation("gui.worldhandler.config.key.settings.shortcuts")
.define("shortcuts", false);
this.valueShortcutKeys = builder
.comment(I18n.format("gui.worldhandler.config.comment.settings.key_shortcuts"))
.translation("gui.worldhandler.config.key.settings.key_shortcuts")
.define("key_shortcuts", false);
this.valueTooltips = builder
.comment(I18n.format("gui.worldhandler.config.comment.settings.tooltips"))
.translation("gui.worldhandler.config.key.settings.tooltips")
.define("tooltips", true);
this.valueWatch = builder
.comment(I18n.format("gui.worldhandler.config.comment.settings.watch"))
.translation("gui.worldhandler.config.key.settings.watch")
.define("watch", true);
this.valueSmoothWatch = builder
.comment(I18n.format("gui.worldhandler.config.comment.settings.smooth_watch"))
.translation("gui.worldhandler.config.key.settings.smooth_watch")
.define("smooth_watch", true);
this.valuePause = builder
.comment(I18n.format("gui.worldhandler.config.comment.settings.pause_game"))
.translation("gui.worldhandler.config.key.settings.pause_game")
.define("pause_game", false);
this.valueCustomTimes = builder
.comment(I18n.format("gui.worldhandler.config.comment.settings.custom_times"))
.translation("gui.worldhandler.config.key.settings.custom_times")
.define("custom_times", false);
this.valuePermissionQuery = builder
.comment(I18n.format("gui.worldhandler.config.comment.settings.permission_query"))
.translation("gui.worldhandler.config.key.settings.permission_query")
.define("permission_query", true);
this.valueHighlightBlocks = builder
.comment(I18n.format("gui.worldhandler.config.comment.settings.highlight_blocks"))
.translation("gui.worldhandler.config.key.settings.highlight_blocks")
.define("highlight_blocks", true);
this.valueDawn = builder
.comment(I18n.format("gui.worldhandler.config.comment.settings.custom_time_dawn"))
.translation("gui.worldhandler.config.key.settings.custom_time_dawn")
.defineInRange("custom_time_dawn", 1000, 0, 24000);
this.valueNoon = builder
.comment(I18n.format("gui.worldhandler.config.comment.settings.custom_time_noon"))
.translation("gui.worldhandler.config.key.settings.custom_time_noon")
.defineInRange("custom_time_noon", 6000, 0, 24000);
this.valueSunset = builder
.comment(I18n.format("gui.worldhandler.config.comment.settings.custom_time_sunset"))
.translation("gui.worldhandler.config.key.settings.custom_time_sunset")
.defineInRange("custom_time_sunset", 12500, 0, 24000);
this.valueMidnight = builder
.comment(I18n.format("gui.worldhandler.config.comment.settings.custom_time_midnight"))
.translation("gui.worldhandler.config.key.settings.custom_time_midnight")
.defineInRange("custom_time_midnight", 18000, 0, 24000);
this.valueBlockPlacingMode = builder
.comment(I18n.format("gui.worldhandler.config.comment.settings.block_placing_mode"))
.translation("gui.worldhandler.config.key.settings.block_placing_mode")
.defineInList("block_placing_mode", "keep", Arrays.asList("keep", "replace", "destroy"));
builder.pop();
}
public void read()
{
this.commandSyntax = this.valueCommandSyntax.get();
this.shortcuts = this.valueShortcuts.get();
this.shortcutKeys = this.valueShortcutKeys.get();
this.tooltips = this.valueTooltips.get();
this.watch = this.valueWatch.get();
this.smoothWatch = this.valueSmoothWatch.get();
this.pause = this.valuePause.get();
this.customTimes = this.valueCustomTimes.get();
this.permissionQuery = this.valuePermissionQuery.get();
this.highlightBlocks = this.valueHighlightBlocks.get();
this.dawn = this.valueDawn.get();
this.noon = this.valueNoon.get();
this.sunset = this.valueSunset.get();
this.midnight = this.valueMidnight.get();
this.blockPlacingMode = this.valueBlockPlacingMode.get();
}
private void write()
{
Config.set(this.valueCommandSyntax, this.commandSyntax);
Config.set(this.valueShortcuts, this.shortcuts);
Config.set(this.valueShortcutKeys, this.shortcutKeys);
Config.set(this.valueTooltips, this.tooltips);
Config.set(this.valueWatch, this.watch);
Config.set(this.valueSmoothWatch, this.smoothWatch);
Config.set(this.valuePause, this.pause);
Config.set(this.valueCustomTimes, this.customTimes);
Config.set(this.valuePermissionQuery, this.permissionQuery);
Config.set(this.valueHighlightBlocks, this.highlightBlocks);
Config.set(this.valueDawn, this.dawn);
Config.set(this.valueNoon, this.noon);
Config.set(this.valueSunset, this.sunset);
Config.set(this.valueMidnight, this.midnight);
Config.set(this.valueBlockPlacingMode, this.blockPlacingMode);
}
public boolean commandSyntax()
{
return this.commandSyntax;
}
public void setCommandSyntax(boolean enabled)
{
this.commandSyntax = enabled;
this.write();
}
public boolean shortcuts()
{
return this.shortcuts;
}
public void setShortcuts(boolean enabled)
{
this.shortcuts = enabled;
this.write();
}
public boolean shortcutKeys()
{
return this.shortcutKeys;
}
public void setShortcutKeys(boolean enabled)
{
this.shortcutKeys = enabled;
this.write();
}
public boolean tooltips()
{
return this.tooltips;
}
public void setTooltips(boolean enabled)
{
this.tooltips = enabled;
this.write();
}
public boolean watch()
{
return this.watch;
}
public void setWatch(boolean enabled)
{
this.watch = enabled;
this.write();
}
public boolean smoothWatch()
{
return this.smoothWatch;
}
public void setSmoothWatch(boolean enabled)
{
this.smoothWatch = enabled;
this.write();
}
public boolean pause()
{
return this.pause;
}
public void setPause(boolean enabled)
{
this.pause = enabled;
this.write();
}
public boolean customTimes()
{
return this.customTimes;
}
public void setCustomTimes(boolean enabled)
{
this.customTimes = enabled;
this.write();
}
public boolean permissionQuery()
{
return this.permissionQuery;
}
public void setPermissionQuery(boolean enabled)
{
this.permissionQuery = enabled;
this.write();
}
public boolean highlightBlocks()
{
return this.highlightBlocks;
}
public void setHighlightBlocks(boolean enabled)
{
this.highlightBlocks = enabled;
this.write();
}
public int getDawn()
{
return this.dawn;
}
public void setDawn(int ticks)
{
this.dawn = ticks;
this.write();
}
public int getNoon()
{
return this.noon;
}
public void setNoon(int ticks)
{
this.noon = ticks;
this.write();
}
public int getSunset()
{
return this.sunset;
}
public void setSunset(int ticks)
{
this.sunset = ticks;
this.write();
}
public int getMidnight()
{
return this.midnight;
}
public void setMidnight(int ticks)
{
this.midnight = ticks;
this.write();
}
public String getBlockPlacingMode()
{
return this.blockPlacingMode;
}
public void setBlockPlacingMode(String mode)
{
this.blockPlacingMode = mode;
this.write();
}
}

View File

@@ -0,0 +1,343 @@
package exopandora.worldhandler.config;
import java.util.Arrays;
import net.minecraft.client.resources.I18n;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.common.ForgeConfigSpec.BooleanValue;
import net.minecraftforge.common.ForgeConfigSpec.ConfigValue;
import net.minecraftforge.common.ForgeConfigSpec.IntValue;
@OnlyIn(Dist.CLIENT)
public class ConfigCategorySkin
{
private int iconSize;
private int labelColor;
private int headlineColor;
private int backgroundRed;
private int backgroundGreen;
private int backgroundBlue;
private int backgroundAlpha;
private int buttonRed;
private int buttonGreen;
private int buttonBlue;
private int buttonAlpha;
private String type;
private boolean sharpEdges;
private boolean drawBackground;
private final ConfigValue<Integer> valueIconSize;
private final IntValue valueLabelColor;
private final IntValue valueHeadlineColor;
private final IntValue valueBackgroundRed;
private final IntValue valueBackgroundGreen;
private final IntValue valueBackgroundBlue;
private final IntValue valueBackgroundAlpha;
private final IntValue valueButtonRed;
private final IntValue valueButtonGreen;
private final IntValue valueButtonBlue;
private final IntValue valueButtonAlpha;
private final ConfigValue<String> valueType;
private final BooleanValue valueSharpEdges;
private final BooleanValue valueDrawBackground;
public ConfigCategorySkin(ForgeConfigSpec.Builder builder)
{
builder.push("skin");
this.valueIconSize = builder
.comment(I18n.format("gui.worldhandler.config.comment.skin.icon_size"))
.translation("gui.worldhandler.config.key.skin.icon_size")
.defineInList("icon_size", 16, Arrays.asList(16, 32, 64));
this.valueLabelColor = builder
.comment(I18n.format("gui.worldhandler.config.comment.skin.label_color"))
.translation("gui.worldhandler.config.key.skin.label_color")
.defineInRange("label_color", 0x1F1F1F, 0x80000000, 0x7FFFFFFF);
this.valueHeadlineColor = builder
.comment(I18n.format("gui.worldhandler.config.comment.skin.headline_color"))
.translation("gui.worldhandler.config.key.skin.headline_color")
.defineInRange("headline_color", 0x4F4F4F, 0x80000000, 0x7FFFFFFF);
this.valueBackgroundRed = builder
.comment(I18n.format("gui.worldhandler.config.comment.skin.background_red"))
.translation("gui.worldhandler.config.key.skin.background_red")
.defineInRange("background_red", 255, 0, 255);
this.valueBackgroundGreen = builder
.comment(I18n.format("gui.worldhandler.config.comment.skin.background_green"))
.translation("gui.worldhandler.config.key.skin.background_green")
.defineInRange("background_green", 255, 0, 255);
this.valueBackgroundBlue = builder
.comment(I18n.format("gui.worldhandler.config.comment.skin.background_blue"))
.translation("gui.worldhandler.config.key.skin.background_blue")
.defineInRange("background_blue", 255, 0, 255);
this.valueBackgroundAlpha = builder
.comment(I18n.format("gui.worldhandler.config.comment.skin.background_alpha"))
.translation("gui.worldhandler.config.key.skin.background_alpha")
.defineInRange("background_alpha", 255, 0, 255);
this.valueButtonRed = builder
.comment(I18n.format("gui.worldhandler.config.comment.skin.button_red"))
.translation("gui.worldhandler.config.key.skin.button_red")
.defineInRange("button_red", 255, 0, 255);
this.valueButtonGreen = builder
.comment(I18n.format("gui.worldhandler.config.comment.skin.button_green"))
.translation("gui.worldhandler.config.key.skin.button_green")
.defineInRange("button_green", 255, 0, 255);
this.valueButtonBlue = builder
.comment(I18n.format("gui.worldhandler.config.comment.skin.button_blue"))
.translation("gui.worldhandler.config.key.skin.button_blue")
.defineInRange("button_blue", 255, 0, 255);
this.valueButtonAlpha = builder
.comment(I18n.format("gui.worldhandler.config.comment.skin.button_alpha"))
.translation("gui.worldhandler.config.key.skin.button_alpha")
.defineInRange("button_alpha", 255, 0, 255);
this.valueType = builder
.comment(I18n.format("gui.worldhandler.config.comment.skin.textures"))
.translation("gui.worldhandler.config.key.skin.textures")
.defineInList("textures", "resourcepack", Arrays.asList("resourcepack", "vanilla"));
this.valueSharpEdges = builder
.comment(I18n.format("gui.worldhandler.config.comment.settings.sharp_tab_edges"))
.translation("gui.worldhandler.config.key.settings.sharp_tab_edges")
.define("sharp_tab_edges", false);
this.valueDrawBackground = builder
.comment(I18n.format("gui.worldhandler.config.comment.settings.draw_background"))
.translation("gui.worldhandler.config.key.settings.draw_background")
.define("draw_background", true);
builder.pop();
}
public void read()
{
this.iconSize = this.valueIconSize.get();
this.labelColor = this.valueLabelColor.get();
this.headlineColor = this.valueHeadlineColor.get();
this.backgroundRed = this.valueBackgroundRed.get();
this.backgroundGreen = this.valueBackgroundGreen.get();
this.backgroundBlue = this.valueBackgroundBlue.get();
this.backgroundAlpha = this.valueBackgroundAlpha.get();
this.buttonRed = this.valueButtonRed.get();
this.buttonGreen = this.valueButtonGreen.get();
this.buttonBlue = this.valueButtonBlue.get();
this.buttonAlpha = this.valueButtonAlpha.get();
this.type = this.valueType.get();
this.sharpEdges = this.valueSharpEdges.get();
this.drawBackground = this.valueDrawBackground.get();
}
private void write()
{
Config.set(this.valueIconSize, this.iconSize);
Config.set(this.valueLabelColor, this.labelColor);
Config.set(this.valueHeadlineColor, this.headlineColor);
Config.set(this.valueBackgroundRed, this.backgroundRed);
Config.set(this.valueBackgroundGreen, this.backgroundGreen);
Config.set(this.valueBackgroundBlue, this.backgroundBlue);
Config.set(this.valueBackgroundAlpha, this.backgroundAlpha);
Config.set(this.valueButtonRed, this.buttonRed);
Config.set(this.valueButtonGreen, this.buttonGreen);
Config.set(this.valueButtonBlue, this.buttonBlue);
Config.set(this.valueButtonAlpha, this.buttonAlpha);
Config.set(this.valueType, this.type);
Config.set(this.valueSharpEdges, this.sharpEdges);
Config.set(this.valueDrawBackground, this.drawBackground);
}
public int getIconSize()
{
return this.iconSize;
}
public void setIconSize(int size)
{
this.iconSize = size;
this.write();
}
public int getLabelColor()
{
return this.labelColor;
}
public void setLabelColor(int color)
{
this.labelColor = color;
this.write();
}
public int getHeadlineColor()
{
return this.headlineColor;
}
public void setHeadlineColor(int color)
{
this.headlineColor = color;
this.write();
}
private int getBackgroundRed()
{
return this.backgroundRed;
}
public float getBackgroundRedF()
{
return this.getBackgroundRed() / 255F;
}
public void setBackgroundRed(int red)
{
this.backgroundRed = red;
this.write();
}
private int getBackgroundGreen()
{
return this.backgroundGreen;
}
public float getBackgroundGreenF()
{
return this.getBackgroundGreen() / 255F;
}
public void setBackgroundGreen(int green)
{
this.backgroundGreen = green;
this.write();
}
private int getBackgroundBlue()
{
return this.backgroundBlue;
}
public float getBackgroundBlueF()
{
return this.getBackgroundBlue() / 255F;
}
public void setBackgroundBlue(int blue)
{
this.backgroundBlue = blue;
this.write();
}
private int getButtonRed()
{
return this.buttonRed;
}
public float getButtonRedF()
{
return this.getButtonRed() / 255F;
}
public void setButtonRed(int red)
{
this.backgroundRed = red;
this.write();
}
private int getButtonGreen()
{
return this.buttonGreen;
}
public float getButtonGreenF()
{
return this.getButtonGreen() / 255F;
}
public void setButtonGreen(int green)
{
this.buttonGreen = green;
this.write();
}
private int getButtonBlue()
{
return this.buttonBlue;
}
public float getButtonBlueF()
{
return this.getButtonBlue() / 255F;
}
public void setButtonBlue(int blue)
{
this.buttonBlue = blue;
this.write();
}
public String getTextureType()
{
return this.type;
}
public void setTextureType(String type)
{
this.type = type;
this.write();
}
public boolean sharpEdges()
{
return this.sharpEdges;
}
public void setSharpEdges(boolean enabled)
{
this.sharpEdges = enabled;
this.write();
}
public boolean drawBackground()
{
return this.drawBackground;
}
public void setDrawBackground(boolean enabled)
{
this.drawBackground = enabled;
this.write();
}
private int getBackgroundAlpha()
{
return this.backgroundAlpha;
}
public float getBackgroundAlphaF()
{
return this.getBackgroundAlpha() / 255F;
}
public void setBackgroundAlpha(int alpha)
{
this.backgroundAlpha = alpha;
this.write();
}
private int getButtonAlpha()
{
return this.buttonAlpha;
}
public float getButtonAlphaF()
{
return this.getButtonAlpha() / 255F;
}
public void setButtonAlpha(int alpha)
{
this.buttonAlpha = alpha;
this.write();
}
}

View File

@@ -0,0 +1,203 @@
package exopandora.worldhandler.config;
import net.minecraft.client.resources.I18n;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.common.ForgeConfigSpec.DoubleValue;
@OnlyIn(Dist.CLIENT)
public class ConfigCategorySliders
{
private double maxPotionAmplifier;
private double maxItemEnchantment;
private double maxItemAttributes;
private double maxSummonPotionAmplifier;
private double maxSummonPotionMinutes;
private double maxSummonAttributes;
private double maxExperience;
private double maxPlayerPoints;
private double maxTriggerValue;
private final DoubleValue valueMaxPotionAmplifier;
private final DoubleValue valueMaxItemEnchantment;
private final DoubleValue valueMaxItemAttributes;
private final DoubleValue valueMaxSummonPotionAmplifier;
private final DoubleValue valueMaxSummonPotionMinutes;
private final DoubleValue valueMaxSummonAttributes;
private final DoubleValue valueMaxExperience;
private final DoubleValue valueMaxPlayerPoints;
private final DoubleValue valueMaxTriggerValue;
public ConfigCategorySliders(ForgeConfigSpec.Builder builder)
{
builder.push("sliders");
this.valueMaxPotionAmplifier = builder
.comment(I18n.format("gui.worldhandler.config.comment.sliders.max_potion_amplifier"))
.translation("gui.worldhandler.config.key.sliders.max_potion_amplifier")
.defineInRange("max_potion_amplifier", 100D, 0D, Byte.MAX_VALUE);
this.valueMaxItemEnchantment = builder
.comment(I18n.format("gui.worldhandler.config.comment.sliders.max_item_enchantment"))
.translation("gui.worldhandler.config.key.sliders.max_item_enchantment")
.defineInRange("max_item_enchantment", 100D, 0D, Integer.MAX_VALUE);
this.valueMaxItemAttributes = builder
.comment(I18n.format("gui.worldhandler.config.comment.sliders.max_item_attributes"))
.translation("gui.worldhandler.config.key.sliders.max_item_attributes")
.defineInRange("max_item_attributes", 100D, 0D, Double.MAX_VALUE);
this.valueMaxSummonPotionAmplifier = builder
.comment(I18n.format("gui.worldhandler.config.comment.sliders.max_summon_potion_amplifier"))
.translation("gui.worldhandler.config.key.sliders.max_summon_potion_amplifier")
.defineInRange("max_summon_potion_amplifier", 100D, 0D, Byte.MAX_VALUE);
this.valueMaxSummonPotionMinutes = builder
.comment(I18n.format("gui.worldhandler.config.comment.sliders.max_summon_potion_minutes"))
.translation("gui.worldhandler.config.key.sliders.max_summon_potion_minutes")
.defineInRange("max_summon_potion_minutes", 100D, 0D, 16000);
this.valueMaxSummonAttributes = builder
.comment(I18n.format("gui.worldhandler.config.comment.sliders.max_summon_attributes"))
.translation("gui.worldhandler.config.key.sliders.max_summon_attributes")
.defineInRange("max_summon_attributes", 100D, 0D, Double.MAX_VALUE);
this.valueMaxExperience = builder
.comment(I18n.format("gui.worldhandler.config.comment.sliders.max_experience"))
.translation("gui.worldhandler.config.key.sliders.max_experience")
.defineInRange("max_experience", 100D, 0D, 100000D);
this.valueMaxPlayerPoints = builder
.comment(I18n.format("gui.worldhandler.config.comment.sliders.max_player_points"))
.translation("gui.worldhandler.config.key.sliders.max_player_points")
.defineInRange("max_player_points", 100D, 0D, 100000D);
this.valueMaxTriggerValue = builder
.comment(I18n.format("gui.worldhandler.config.comment.sliders.max_trigger_value"))
.translation("gui.worldhandler.config.key.sliders.max_trigger_value")
.defineInRange("max_trigger_value", 100D, 0D, 100000D);
builder.pop();
}
public void read()
{
this.maxPotionAmplifier = this.valueMaxPotionAmplifier.get();
this.maxItemEnchantment = this.valueMaxItemEnchantment.get();
this.maxItemAttributes = this.valueMaxItemAttributes.get();
this.maxSummonPotionAmplifier = this.valueMaxSummonPotionAmplifier.get();
this.maxSummonPotionMinutes = this.valueMaxSummonPotionMinutes.get();
this.maxSummonAttributes = this.valueMaxSummonAttributes.get();
this.maxExperience = this.valueMaxExperience.get();
this.maxPlayerPoints = this.valueMaxPlayerPoints.get();
this.maxTriggerValue = this.valueMaxTriggerValue.get();
}
private void write()
{
Config.set(this.valueMaxPotionAmplifier, this.maxPotionAmplifier);
Config.set(this.valueMaxItemEnchantment, this.maxItemEnchantment);
Config.set(this.valueMaxItemAttributes, this.maxItemAttributes);
Config.set(this.valueMaxSummonPotionAmplifier, this.maxSummonPotionAmplifier);
Config.set(this.valueMaxSummonPotionMinutes, this.maxSummonPotionMinutes);
Config.set(this.valueMaxSummonAttributes, this.maxSummonAttributes);
Config.set(this.valueMaxExperience, this.maxExperience);
Config.set(this.valueMaxPlayerPoints, this.maxPlayerPoints);
Config.set(this.valueMaxTriggerValue, this.maxTriggerValue);
}
public double getMaxPotionAmplifier()
{
return this.maxPotionAmplifier;
}
public void setMaxPotionAmplifier(double max)
{
this.maxPotionAmplifier = max;
this.write();
}
public double getMaxItemEnchantment()
{
return this.maxItemEnchantment;
}
public void setMaxItemEnchantment(double max)
{
this.maxItemEnchantment = max;
this.write();
}
public double getMaxItemAttributes()
{
return this.maxItemAttributes;
}
public void setMaxItemAttributes(double max)
{
this.maxItemAttributes = max;
this.write();
}
public double getMaxSummonPotionAmplifier()
{
return this.maxSummonPotionAmplifier;
}
public void setMaxSummonPotionAmplifier(double max)
{
this.maxSummonPotionAmplifier = max;
this.write();
}
public double getMaxSummonPotionMinutes()
{
return this.maxSummonPotionMinutes;
}
public void setMaxSummonPotionMinutes(double max)
{
this.maxSummonPotionMinutes = max;
this.write();
}
public double getMaxSummonAttributes()
{
return this.maxSummonAttributes;
}
public void setMaxSummonAttributes(double max)
{
this.maxSummonAttributes = max;
this.write();
}
public double getMaxExperience()
{
return this.maxExperience;
}
public void setMaxExperience(double max)
{
this.maxExperience = max;
this.write();
}
public double getMaxPlayerPoints()
{
return this.maxPlayerPoints;
}
public void setMaxPlayerPoints(double max)
{
this.maxPlayerPoints = max;
this.write();
}
public double getMaxTriggerValue()
{
return this.maxTriggerValue;
}
public void setMaxTriggerValue(double max)
{
this.maxTriggerValue = max;
this.write();
}
}

View File

@@ -1,136 +0,0 @@
package exopandora.worldhandler.config;
import net.minecraft.client.resources.I18n;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class ConfigSettings
{
private static boolean BIOME_INDICATOR;
private static boolean COMMAND_SYNTAX;
private static boolean SHORTCUTS;
private static boolean SHORTCUT_KEYS;
private static boolean TOOLTIPS;
private static boolean WATCH;
private static boolean SMOOTH_WATCH;
private static boolean PAUSE;
private static boolean CUSTOM_TIMES;
private static boolean PERMISSION_QUERY;
private static boolean HIGHLIGHT_BLOCKS;
private static int DAWN;
private static int NOON;
private static int SUNSET;
private static int MIDNIGHT;
private static String BLOCK_PLACING_MODE;
public static final String CATEGORY = "settings";
public static void load(Configuration config)
{
BIOME_INDICATOR = config.getBoolean("biome_indicator", CATEGORY, false, I18n.format("gui.worldhandler.config.comment.settings.biome_indicator"), "gui.worldhandler.config.key.settings.biome_indicator");
COMMAND_SYNTAX = config.getBoolean("command_syntax", CATEGORY, false, I18n.format("gui.worldhandler.config.comment.settings.command_syntax"), "gui.worldhandler.config.key.settings.command_syntax");
SHORTCUTS = config.getBoolean("shortcuts", CATEGORY, false, I18n.format("gui.worldhandler.config.comment.settings.shortcuts"), "gui.worldhandler.config.key.settings.shortcuts");
SHORTCUT_KEYS = config.getBoolean("key_shortcuts", CATEGORY, false, I18n.format("gui.worldhandler.config.comment.settings.key_shortcuts"), "gui.worldhandler.config.key.settings.key_shortcuts");
TOOLTIPS = config.getBoolean("tooltips", CATEGORY, true, I18n.format("gui.worldhandler.config.comment.settings.tooltips"), "gui.worldhandler.config.key.settings.tooltips");
WATCH = config.getBoolean("watch", CATEGORY, true, I18n.format("gui.worldhandler.config.comment.settings.watch"), "gui.worldhandler.config.key.settings.watch");
SMOOTH_WATCH = config.getBoolean("smooth_watch", CATEGORY, true, I18n.format("gui.worldhandler.config.comment.settings.smooth_watch"), "gui.worldhandler.config.key.settings.smooth_watch");
PAUSE = config.getBoolean("pause_game", CATEGORY, false, I18n.format("gui.worldhandler.config.comment.settings.pause_game"), "gui.worldhandler.config.key.settings.pause_game");
CUSTOM_TIMES = config.getBoolean("custom_times", CATEGORY, false, I18n.format("gui.worldhandler.config.comment.settings.custom_times"), "gui.worldhandler.config.key.settings.custom_times");
PERMISSION_QUERY = config.getBoolean("permission_query", CATEGORY, true, I18n.format("gui.worldhandler.config.comment.settings.permission_query"), "gui.worldhandler.config.key.settings.permission_query");
HIGHLIGHT_BLOCKS = config.getBoolean("highlight_blocks", CATEGORY, true, I18n.format("gui.worldhandler.config.comment.settings.highlight_blocks"), "gui.worldhandler.config.key.settings.highlight_blocks");
DAWN = config.getInt("custom_time_dawn", CATEGORY, 1000, 0, 24000, I18n.format("gui.worldhandler.config.comment.settings.custom_time_dawn"), "gui.worldhandler.config.key.settings.custom_time_dawn");
NOON = config.getInt("custom_time_noon", CATEGORY, 6000, 0, 24000, I18n.format("gui.worldhandler.config.comment.settings.custom_time_noon"), "gui.worldhandler.config.key.settings.custom_time_noon");
SUNSET = config.getInt("custom_time_sunset", CATEGORY, 12500, 0, 24000, I18n.format("gui.worldhandler.config.comment.settings.custom_time_sunset"), "gui.worldhandler.config.key.settings.custom_time_sunset");
MIDNIGHT = config.getInt("custom_time_midnight", CATEGORY, 18000, 0, 24000, I18n.format("gui.worldhandler.config.comment.settings.custom_time_midnight"), "gui.worldhandler.config.key.settings.custom_time_midnight");
BLOCK_PLACING_MODE = config.getString("block_placing_mode", CATEGORY, "keep", I18n.format("gui.worldhandler.config.comment.settings.block_placing_mode"), new String[]{"keep", "replace", "destroy"}, "gui.worldhandler.config.key.settings.block_placing_mode");
if(config.hasChanged())
{
config.save();
}
}
public static boolean isBiomeIndicatorEnabled()
{
return BIOME_INDICATOR;
}
public static boolean isCommandSyntaxEnabled()
{
return COMMAND_SYNTAX;
}
public static boolean areShortcutsEnabled()
{
return SHORTCUTS;
}
public static boolean arePosShortcutsEnabled()
{
return SHORTCUT_KEYS;
}
public static boolean areTooltipsEnabled()
{
return TOOLTIPS;
}
public static boolean isWatchEnabled()
{
return WATCH;
}
public static boolean isSmoothWatchEnabled()
{
return SMOOTH_WATCH;
}
public static boolean isPauseEnabled()
{
return PAUSE;
}
public static boolean isCustomTimeEnabled()
{
return CUSTOM_TIMES;
}
public static boolean isPermissionQueryEnabled()
{
return PERMISSION_QUERY;
}
public static boolean isHighlightBlocksEnabled()
{
return HIGHLIGHT_BLOCKS;
}
public static int getDawn()
{
return DAWN;
}
public static int getNoon()
{
return NOON;
}
public static int getSunset()
{
return SUNSET;
}
public static int getMidnight()
{
return MIDNIGHT;
}
public static String getMode()
{
return BLOCK_PLACING_MODE;
}
}

View File

@@ -1,127 +0,0 @@
package exopandora.worldhandler.config;
import net.minecraft.client.resources.I18n;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class ConfigSkin
{
private static int ICON_SIZE;
private static int LABEL_COLOR;
private static int HEADLINE_COLOR;
private static int BACKGROUND_RED;
private static int BACKGROUND_GREEN;
private static int BACKGROUND_BLUE;
private static int BACKGROUND_ALPHA;
private static int BUTTON_RED;
private static int BUTTON_GREEN;
private static int BUTTON_BLUE;
private static int BUTTON_ALPHA;
private static String TYPE;
private static boolean SHARP_EDGES;
private static boolean DRAW_BACKGROUND;
public static final String CATEGORY = "skin";
public static void load(Configuration config)
{
ICON_SIZE = Integer.valueOf(config.getString("icon_size", CATEGORY, "16", I18n.format("gui.worldhandler.config.comment.skin.icons"), new String[]{"16", "32", "64"}, "gui.worldhandler.config.key.skin.icons"));
LABEL_COLOR = config.getInt("label_color", CATEGORY, 0x1F1F1F, 0x80000000, 0x7FFFFFFF, I18n.format("gui.worldhandler.config.comment.skin.label_color"), "gui.worldhandler.config.key.skin.label_color");
HEADLINE_COLOR = config.getInt("headline_color", CATEGORY, 0x4F4F4F, 0x80000000, 0x7FFFFFFF, I18n.format("gui.worldhandler.config.comment.skin.headline_color"), "gui.worldhandler.config.key.skin.headline_color");
BACKGROUND_RED = config.getInt("background_red", CATEGORY, 255, 0, 255, I18n.format("gui.worldhandler.config.comment.skin.background_red"), "gui.worldhandler.config.key.skin.background_red");
BACKGROUND_GREEN = config.getInt("background_green", CATEGORY, 255, 0, 255, I18n.format("gui.worldhandler.config.comment.skin.background_green"), "gui.worldhandler.config.key.skin.background_green");
BACKGROUND_BLUE = config.getInt("background_blue", CATEGORY, 255, 0, 255, I18n.format("gui.worldhandler.config.comment.skin.background_blue"), "gui.worldhandler.config.key.skin.background_blue");
BACKGROUND_ALPHA = config.getInt("background_alpha", CATEGORY, 255, 0, 255, I18n.format("gui.worldhandler.config.comment.skin.background_alpha"), "gui.worldhandler.config.key.skin.background_alpha");
BUTTON_RED = config.getInt("button_red", CATEGORY, 255, 0, 255, I18n.format("gui.worldhandler.config.comment.skin.button_red"), "gui.worldhandler.config.key.skin.button_red");
BUTTON_GREEN = config.getInt("button_green", CATEGORY, 255, 0, 255, I18n.format("gui.worldhandler.config.comment.skin.button_green"), "gui.worldhandler.config.key.skin.button_green");
BUTTON_BLUE = config.getInt("button_blue", CATEGORY, 255, 0, 255, I18n.format("gui.worldhandler.config.comment.skin.button_blue"), "gui.worldhandler.config.key.skin.button_blue");
BUTTON_ALPHA = config.getInt("button_alpha", CATEGORY, 255, 0, 255, I18n.format("gui.worldhandler.config.comment.skin.button_alpha"), "gui.worldhandler.config.key.skin.button_alpha");
TYPE = config.getString("textures", CATEGORY, "resourcepack", I18n.format("gui.worldhandler.config.comment.skin.textures"), new String[]{"resourcepack", "vanilla"}, "gui.worldhandler.config.key.skin.textures");
SHARP_EDGES = config.getBoolean("sharp_tab_edges", CATEGORY, false, I18n.format("gui.worldhandler.config.comment.skin.sharp_tab_edges"), "gui.worldhandler.config.key.skin.sharp_tab_edges");
DRAW_BACKGROUND = config.getBoolean("draw_background", CATEGORY, true, I18n.format("gui.worldhandler.config.comment.skin.draw_background"), "gui.worldhandler.config.key.skin.draw_background");
if(config.hasChanged())
{
config.save();
}
}
public static int getIconSize()
{
return ICON_SIZE;
}
public static int getLabelColor()
{
return LABEL_COLOR;
}
public static int getHeadlineColor()
{
return HEADLINE_COLOR;
}
public static int getBackgroundRed()
{
return BACKGROUND_RED;
}
public static int getBackgroundGreen()
{
return BACKGROUND_GREEN;
}
public static int getBackgroundBlue()
{
return BACKGROUND_BLUE;
}
public static int getButtonRed()
{
return BUTTON_RED;
}
public static int getButtonGreen()
{
return BUTTON_GREEN;
}
public static int getButtonBlue()
{
return BUTTON_BLUE;
}
public static String getTextureType()
{
return TYPE;
}
public static boolean areSharpEdgesEnabled()
{
return SHARP_EDGES;
}
public static boolean isBackgroundDrawingEnabled()
{
return DRAW_BACKGROUND;
}
public static int getBackgroundAlpha()
{
return BACKGROUND_ALPHA;
}
public static int getButtonAlpha()
{
return BUTTON_ALPHA;
}
}

View File

@@ -1,84 +0,0 @@
package exopandora.worldhandler.config;
import net.minecraft.client.resources.I18n;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class ConfigSliders
{
private static double MAX_POTION_AMPLIFIER;
private static double MAX_ITEM_ENCHANTENT;
private static double MAX_ITEM_ATTRIBUTES;
private static double MAX_SUMMON_POTION_AMPLIFIER;
private static double MAX_SUMMON_POTION_MINUTES;
private static double MAX_SUMMON_ATTRIBUTES;
private static double MAX_EXPERIENCE;
private static double MAX_PLAYER_POINTS;
public static final String CATEGORY = "sliders";
public static void load(Configuration config)
{
MAX_POTION_AMPLIFIER = config.get(CATEGORY, "max_potion_amplifier", 100D, I18n.format("gui.worldhandler.config.comment.sliders.max_potion_amplifier"), 0D, Byte.MAX_VALUE).setLanguageKey("gui.worldhandler.config.key.sliders.max_potion_amplifier").getDouble();
MAX_ITEM_ENCHANTENT = config.get(CATEGORY, "max_item_enchantment", 100D, I18n.format("gui.worldhandler.config.comment.sliders.max_item_enchantment"), 0D, Integer.MAX_VALUE).setLanguageKey("gui.worldhandler.config.key.sliders.max_item_enchantment").getDouble();
MAX_ITEM_ATTRIBUTES = config.get(CATEGORY, "max_item_attributes", 100D, I18n.format("gui.worldhandler.config.comment.sliders.max_item_attributes"), 0D, Double.MAX_VALUE).setLanguageKey("gui.worldhandler.config.key.sliders.max_item_attributes").getDouble();
MAX_SUMMON_POTION_AMPLIFIER = config.get(CATEGORY, "max_summon_potion_amplifier", 100D, I18n.format("gui.worldhandler.config.comment.sliders.max_summon_potion_amplifier"), 0D, Byte.MAX_VALUE).setLanguageKey("gui.worldhandler.config.key.sliders.max_summon_potion_amplifier").getDouble();
MAX_SUMMON_POTION_MINUTES = config.get(CATEGORY, "max_summon_potion_minutes", 100D, I18n.format("gui.worldhandler.config.comment.sliders.max_summon_potion_minutes"), 0D, 16000).setLanguageKey("gui.worldhandler.config.key.sliders.max_summon_potion_minutes").getDouble();
MAX_SUMMON_ATTRIBUTES = config.get(CATEGORY, "max_summon_attributes", 100D, I18n.format("gui.worldhandler.config.comment.sliders.max_summon_attributes"), 0D, Double.MAX_VALUE).setLanguageKey("gui.worldhandler.config.key.sliders.max_summon_attributes").getDouble();
MAX_EXPERIENCE = config.get(CATEGORY, "max_experience", 100D, I18n.format("gui.worldhandler.config.comment.sliders.max_experience"), 0D, 100000D).setLanguageKey("gui.worldhandler.config.key.sliders.max_experience").getDouble();
MAX_PLAYER_POINTS = config.get(CATEGORY, "max_player_points", 100D, I18n.format("gui.worldhandler.config.comment.sliders.max_player_points"), 0D, 100000D).setLanguageKey("gui.worldhandler.config.key.sliders.max_player_points").getDouble();
if(config.hasChanged())
{
config.save();
}
}
public static double getMaxPotionAmplifier()
{
return MAX_POTION_AMPLIFIER;
}
public static double getMaxItemEnchantment()
{
return MAX_ITEM_ENCHANTENT;
}
public static double getMaxItemAttributes()
{
return MAX_ITEM_ATTRIBUTES;
}
public static double getMaxSummonPotionAmplifier()
{
return MAX_SUMMON_POTION_AMPLIFIER;
}
public static double getMaxSummonPotionMinutes()
{
return MAX_SUMMON_POTION_MINUTES;
}
public static double getMaxSummonAttributes()
{
return MAX_SUMMON_ATTRIBUTES;
}
public static double getMaxExperience()
{
return MAX_EXPERIENCE;
}
public static double getMaxPlayerPoints()
{
return MAX_PLAYER_POINTS;
}
}

View File

@@ -0,0 +1,121 @@
package exopandora.worldhandler.event;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.ParseResults;
import com.mojang.brigadier.StringReader;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import exopandora.worldhandler.config.Config;
import exopandora.worldhandler.helper.BlockHelper;
import exopandora.worldhandler.helper.CommandHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.command.CommandSource;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.event.ClientChatEvent;
import net.minecraftforge.client.event.RenderWorldLastEvent;
@OnlyIn(Dist.CLIENT)
public class ClientEventHandler
{
public static void renderWorldLastEvent(RenderWorldLastEvent event)
{
if(Config.getSettings().highlightBlocks() && Minecraft.getInstance().world != null)
{
GlStateManager.pushMatrix();
GlStateManager.disableAlphaTest();
GlStateManager.enableBlend();
GlStateManager.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
GlStateManager.lineWidth(2.0F);
GlStateManager.disableTexture2D();
GlStateManager.depthMask(false);
final double constant = 0.0020000000949949026D;
EntityPlayer player = Minecraft.getInstance().player;
double playerX = player.lastTickPosX + (player.posX - player.lastTickPosX) * Minecraft.getInstance().getRenderPartialTicks();
double playerY = player.lastTickPosY + (player.posY - player.lastTickPosY) * Minecraft.getInstance().getRenderPartialTicks();
double playerZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * Minecraft.getInstance().getRenderPartialTicks();
double minX = Math.min(BlockHelper.getPos1().getX(), BlockHelper.getPos2().getX()) - constant - playerX;
double minY = Math.min(BlockHelper.getPos1().getY(), BlockHelper.getPos2().getY()) - constant - playerY;
double minZ = Math.min(BlockHelper.getPos1().getZ(), BlockHelper.getPos2().getZ()) - constant - playerZ;
double maxX = Math.max(BlockHelper.getPos1().getX(), BlockHelper.getPos2().getX()) + constant - playerX + 1;
double maxY = Math.max(BlockHelper.getPos1().getY(), BlockHelper.getPos2().getY()) + constant - playerY + 1;
double maxZ = Math.max(BlockHelper.getPos1().getZ(), BlockHelper.getPos2().getZ()) + constant - playerZ + 1;
Tessellator tesselator = Tessellator.getInstance();
BufferBuilder buffer = tesselator.getBuffer();
final int alpha = 255;
final int color1 = 223;
final int color2 = 127;
GlStateManager.lineWidth(2.0F);
buffer.begin(3, DefaultVertexFormats.POSITION_COLOR);
buffer.pos(minX, minY, minZ).color((float) color1, (float) color1, (float) color1, 0.0F).endVertex();
buffer.pos(minX, minY, minZ).color(color1, color1, color1, alpha).endVertex();
buffer.pos(maxX, minY, minZ).color(color1, color2, color2, alpha).endVertex();
buffer.pos(maxX, minY, maxZ).color(color1, color1, color1, alpha).endVertex();
buffer.pos(minX, minY, maxZ).color(color1, color1, color1, alpha).endVertex();
buffer.pos(minX, minY, minZ).color(color2, color2, color1, alpha).endVertex();
buffer.pos(minX, maxY, minZ).color(color2, color1, color2, alpha).endVertex();
buffer.pos(maxX, maxY, minZ).color(color1, color1, color1, alpha).endVertex();
buffer.pos(maxX, maxY, maxZ).color(color1, color1, color1, alpha).endVertex();
buffer.pos(minX, maxY, maxZ).color(color1, color1, color1, alpha).endVertex();
buffer.pos(minX, maxY, minZ).color(color1, color1, color1, alpha).endVertex();
buffer.pos(minX, maxY, maxZ).color(color1, color1, color1, alpha).endVertex();
buffer.pos(minX, minY, maxZ).color(color1, color1, color1, alpha).endVertex();
buffer.pos(maxX, minY, maxZ).color(color1, color1, color1, alpha).endVertex();
buffer.pos(maxX, maxY, maxZ).color(color1, color1, color1, alpha).endVertex();
buffer.pos(maxX, maxY, minZ).color(color1, color1, color1, alpha).endVertex();
buffer.pos(maxX, minY, minZ).color(color1, color1, color1, alpha).endVertex();
buffer.pos(maxX, minY, minZ).color((float) color1, (float) color1, (float) color1, 0.0F).endVertex();
tesselator.draw();
GlStateManager.lineWidth(1.0F);
GlStateManager.depthMask(true);
GlStateManager.enableTexture2D();
GlStateManager.disableBlend();
GlStateManager.enableAlphaTest();
GlStateManager.popMatrix();
}
}
public static void clientChatEvent(ClientChatEvent event)
{
if(!Minecraft.getInstance().isSingleplayer())
{
CommandDispatcher<CommandSource> dispatcher = new CommandDispatcher<CommandSource>();
CommandHelper.registerCommands(dispatcher);
StringReader command = new StringReader(event.getMessage());
command.skip();
ParseResults<CommandSource> result = dispatcher.parse(command, Minecraft.getInstance().player.getCommandSource());
if(result.getContext().getCommand() != null)
{
try
{
dispatcher.execute(result);
}
catch(CommandSyntaxException e)
{
e.printStackTrace();
}
if(event.isCancelable())
{
event.setCanceled(true);
}
}
}
}
}

View File

@@ -1,172 +0,0 @@
package exopandora.worldhandler.event;
import com.mojang.realmsclient.gui.ChatFormatting;
import exopandora.worldhandler.Main;
import exopandora.worldhandler.WorldHandler;
import exopandora.worldhandler.command.FakeCommandHandler;
import exopandora.worldhandler.config.ConfigSettings;
import exopandora.worldhandler.gui.container.impl.GuiWorldHandlerContainer;
import exopandora.worldhandler.gui.content.Contents;
import exopandora.worldhandler.helper.BlockHelper;
import exopandora.worldhandler.hud.BiomeIndicator;
import exopandora.worldhandler.util.UtilPlayer;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderGlobal;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.util.text.ChatType;
import net.minecraft.util.text.TextComponentString;
import net.minecraftforge.client.event.ClientChatEvent;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import net.minecraftforge.fml.client.event.ConfigChangedEvent.OnConfigChangedEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.InputEvent.KeyInputEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent.Phase;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class EventListener
{
private final FakeCommandHandler commandHandler = new FakeCommandHandler();
private final BiomeIndicator biomeIndicator = new BiomeIndicator();
@SubscribeEvent
public void renderWorldLastEvent(RenderWorldLastEvent event)
{
if(ConfigSettings.isHighlightBlocksEnabled() && Minecraft.getMinecraft().world != null)
{
GlStateManager.pushMatrix();
GlStateManager.disableAlpha();
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
GlStateManager.glLineWidth(2.0F);
GlStateManager.disableTexture2D();
GlStateManager.depthMask(false);
final double constant = 0.0020000000949949026D;
EntityPlayer player = Minecraft.getMinecraft().player;
double playerX = player.lastTickPosX + (player.posX - player.lastTickPosX) * Minecraft.getMinecraft().getRenderPartialTicks();
double playerY = player.lastTickPosY + (player.posY - player.lastTickPosY) * Minecraft.getMinecraft().getRenderPartialTicks();
double playerZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * Minecraft.getMinecraft().getRenderPartialTicks();
double minX = Math.min(BlockHelper.getPos1().getX(), BlockHelper.getPos2().getX()) - constant - playerX;
double minY = Math.min(BlockHelper.getPos1().getY(), BlockHelper.getPos2().getY()) - constant - playerY;
double minZ = Math.min(BlockHelper.getPos1().getZ(), BlockHelper.getPos2().getZ()) - constant - playerZ;
double maxX = Math.max(BlockHelper.getPos1().getX(), BlockHelper.getPos2().getX()) + constant - playerX + 1;
double maxY = Math.max(BlockHelper.getPos1().getY(), BlockHelper.getPos2().getY()) + constant - playerY + 1;
double maxZ = Math.max(BlockHelper.getPos1().getZ(), BlockHelper.getPos2().getZ()) + constant - playerZ + 1;
final float opacity = 0.2F;
for(int x = 1; x < maxX - minX; x++)
{
RenderGlobal.drawBoundingBox(minX, minY, minZ, minX + x + 2 * constant, maxY, maxZ, 0.0F, 0.0F, 0.0F, opacity);
}
for(int y = 1; y < maxY - minY; y++)
{
RenderGlobal.drawBoundingBox(minX, minY, minZ, maxX, minY + y + 2 * constant, maxZ, 0.0F, 0.0F, 0.0F, opacity);
}
for(int z = 1; z < maxZ - minZ; z++)
{
RenderGlobal.drawBoundingBox(minX, minY, minZ, maxX, maxY, minZ + z + 2 * constant, 0.0F, 0.0F, 0.0F, opacity);
}
RenderGlobal.renderFilledBox(minX, minY, minZ, maxX, maxY, maxZ, 0.0F, 0.0F, 0.0F, opacity / 2);
RenderGlobal.renderFilledBox(maxX, maxY, maxZ, minX, minY, minZ, 0.0F, 0.0F, 0.0F, opacity / 2);
GlStateManager.depthMask(true);
GlStateManager.enableTexture2D();
GlStateManager.disableBlend();
GlStateManager.enableAlpha();
GlStateManager.popMatrix();
}
}
@SubscribeEvent
public void clientTickEvent(ClientTickEvent event)
{
if(Minecraft.getMinecraft().inGameHasFocus && event.phase.equals(Phase.START))
{
if(ConfigSettings.isBiomeIndicatorEnabled())
{
this.biomeIndicator.tick();
}
}
}
@SubscribeEvent
public void keyInputEvent(KeyInputEvent event)
{
if(WorldHandler.KEY_WORLD_HANDLER.isPressed())
{
displayGui();
}
else if(WorldHandler.KEY_WORLD_HANDLER_POS1.isPressed() && ConfigSettings.arePosShortcutsEnabled())
{
BlockHelper.setPos1(BlockHelper.getFocusedBlockPos());
}
else if(WorldHandler.KEY_WORLD_HANDLER_POS2.isPressed() && ConfigSettings.arePosShortcutsEnabled())
{
BlockHelper.setPos2(BlockHelper.getFocusedBlockPos());
}
}
@SubscribeEvent
public void onConfigChanged(OnConfigChangedEvent event)
{
if(event.getModID().equals(Main.MODID))
{
WorldHandler.updateConfig();
}
}
@SubscribeEvent
public void clientChatEvent(ClientChatEvent event)
{
if(!Minecraft.getMinecraft().isSingleplayer())
{
this.commandHandler.tryCommand(WorldHandler.COMMAND_WORLD_HANDLER, event);
this.commandHandler.tryCommand(WorldHandler.COMMAND_WH, event);
}
}
public static void displayGui()
{
if(!UtilPlayer.canIssueCommand() && ConfigSettings.isPermissionQueryEnabled())
{
Minecraft.getMinecraft().ingameGUI.addChatMessage(ChatType.GAME_INFO, new TextComponentString(ChatFormatting.RED + I18n.format("worldhandler.permission.refused")));
Minecraft.getMinecraft().ingameGUI.addChatMessage(ChatType.GAME_INFO, new TextComponentString(ChatFormatting.RED + I18n.format("worldhandler.permission.refused.change", I18n.format("gui.worldhandler.config.key.settings.permission_query"))));
}
else
{
try
{
if(BlockHelper.isFocusedBlockEqualTo(Blocks.STANDING_SIGN) || BlockHelper.isFocusedBlockEqualTo(Blocks.WALL_SIGN))
{
Minecraft.getMinecraft().displayGuiScreen(new GuiWorldHandlerContainer(Contents.SIGN_EDITOR));
}
else if(BlockHelper.isFocusedBlockEqualTo(Blocks.NOTEBLOCK))
{
Minecraft.getMinecraft().displayGuiScreen(new GuiWorldHandlerContainer(Contents.NOTE_EDITOR));
}
else
{
Minecraft.getMinecraft().displayGuiScreen(new GuiWorldHandlerContainer(Contents.MAIN));
}
}
catch(Exception e)
{
WorldHandler.throwError(e);
}
}
}
}

View File

@@ -0,0 +1,34 @@
package exopandora.worldhandler.event;
import exopandora.worldhandler.WorldHandler;
import exopandora.worldhandler.config.Config;
import exopandora.worldhandler.helper.ActionHelper;
import exopandora.worldhandler.helper.BlockHelper;
import net.minecraft.client.Minecraft;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent;
@OnlyIn(Dist.CLIENT)
public class KeyHandler
{
//TODO FORGE switch to KeyInputEvent
public static void keyInputEvent(ClientTickEvent event)
{
if(Minecraft.getInstance().isGameFocused())
{
if(WorldHandler.KEY_WORLD_HANDLER.isPressed())
{
ActionHelper.displayGui();
}
else if(WorldHandler.KEY_WORLD_HANDLER_POS1.isPressed() && Config.getSettings().shortcutKeys())
{
BlockHelper.setPos1(BlockHelper.getFocusedBlockPos());
}
else if(WorldHandler.KEY_WORLD_HANDLER_POS2.isPressed() && Config.getSettings().shortcutKeys())
{
BlockHelper.setPos2(BlockHelper.getFocusedBlockPos());
}
}
}
}

View File

@@ -2,11 +2,14 @@ package exopandora.worldhandler.format;
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;
/**
* XXX To be replaced with TextFormatting
*/
@Deprecated
@SideOnly(Side.CLIENT)
@OnlyIn(Dist.CLIENT)
public enum EnumColor
{
DEFAULT("reset", "r"),
@@ -30,7 +33,7 @@ public enum EnumColor
OBFUSCATED("obfuscated", "k"),
BOLD("bold", "l"),
STRIKETHROUGH("strikethrough", "m"),
UNDERLINED("underlined", "n"),
UNDERLINE("underline", "n"),
ITALIC("italic", "o");
private String format;

View File

@@ -2,10 +2,10 @@ package exopandora.worldhandler.format;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.util.math.MathHelper;
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 TextFormatting
{
public static String shortenString(String str, int maxWidth, FontRenderer fontRenderer)
@@ -88,7 +88,7 @@ public class TextFormatting
return minute;
}
public static String getWorldTime(long tick)
public static String formatWorldTime(long tick)
{
int hour = TextFormatting.getHour(tick);
int minute = TextFormatting.getMinute(tick);

View File

@@ -3,10 +3,14 @@ package exopandora.worldhandler.format.text;
import com.mojang.realmsclient.gui.ChatFormatting;
import exopandora.worldhandler.format.EnumColor;
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)
/**
* XXX To be replaced with ITextComponent
*/
@Deprecated
@OnlyIn(Dist.CLIENT)
public class ColoredString extends FormattedString
{
private EnumColor color = EnumColor.DEFAULT;
@@ -92,16 +96,6 @@ public class ColoredString extends FormattedString
return result;
}
public String getTextFieldString()
{
if(this.text != null)
{
return this.getFormattedString(super.getPreformattedString(this.text));
}
return null;
}
@Override
public String toString()
{
@@ -124,4 +118,9 @@ public class ColoredString extends FormattedString
return null;
}
public String textFormatter(String string, Integer integer)
{
return this.getFormattedString(string);
}
}

View File

@@ -1,9 +1,9 @@
package exopandora.worldhandler.format.text;
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 FormattedString
{
protected String text;

View File

@@ -1,9 +1,9 @@
package exopandora.worldhandler.format.text;
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 JsonClickEvent
{
private String action;

View File

@@ -1,9 +1,9 @@
package exopandora.worldhandler.format.text;
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 JsonSignLine extends FormattedString
{
private String color;

View File

@@ -9,10 +9,10 @@ import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import exopandora.worldhandler.format.EnumColor;
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 JsonSignLineSerializer implements JsonSerializer<JsonSignLine>
{
@Override

View File

@@ -3,10 +3,10 @@ package exopandora.worldhandler.format.text;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
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 SignText
{
private static final Gson GSON = new GsonBuilder().registerTypeAdapter(JsonSignLine.class, new JsonSignLineSerializer()).create();

View File

@@ -1,9 +1,13 @@
package exopandora.worldhandler.gui.button;
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)
/**
* XXX To be replaced by a proper registry object
*/
@Deprecated
@OnlyIn(Dist.CLIENT)
public enum EnumIcon
{
WEATHER_SUN(0, 0),

View File

@@ -1,15 +0,0 @@
package exopandora.worldhandler.gui.button;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public enum EnumTooltip
{
TOP_RIGHT,
TOP_LEFT,
BOTTOM_RIGHT,
BOTTOM_LEFT,
RIGHT,
LEFT
}

View File

@@ -0,0 +1,91 @@
package exopandora.worldhandler.gui.button;
import exopandora.worldhandler.config.Config;
import exopandora.worldhandler.helper.ActionHelper;
import exopandora.worldhandler.helper.ResourceHelper;
import exopandora.worldhandler.util.ActionHandler;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public class GuiButtonBase extends GuiButton
{
protected ActionHandler actionHandler;
public GuiButtonBase(int x, int y, int widthIn, int heightIn, String buttonText, ActionHandler actionHandler)
{
this(0, x, y, widthIn, heightIn, buttonText, actionHandler);
}
public GuiButtonBase(int id, int x, int y, int widthIn, int heightIn, String buttonText, ActionHandler actionHandler)
{
super(id, x, y, widthIn, heightIn, buttonText);
this.actionHandler = actionHandler;
}
protected void drawBackground(int mouseX, int mouseY)
{
GlStateManager.enableBlend();
GlStateManager.color4f(Config.getSkin().getButtonRedF(), Config.getSkin().getButtonGreenF(), Config.getSkin().getButtonBlueF(), Config.getSkin().getButtonAlphaF());
this.hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
int hovered = this.getHoverState(this.hovered);
Minecraft.getInstance().getTextureManager().bindTexture(ResourceHelper.getButtonTexture());
if(Config.getSkin().getTextureType().equals("resourcepack"))
{
this.drawTexturedModalRect(this.x, this.y, 0, 46 + hovered * 20, this.width / 2, this.height);
this.drawTexturedModalRect(this.x + this.width / 2, this.y, 200 - this.width / 2, 46 + hovered * 20, this.width / 2, this.height);
}
else
{
this.drawTexturedModalRect(this.x, this.y, 0, hovered * 20, this.width / 2, this.height);
this.drawTexturedModalRect(this.x + this.width / 2, this.y, 200 - this.width / 2, hovered * 20, this.width / 2, this.height);
}
GlStateManager.disableBlend();
GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
}
@Override
public void render(int mouseX, int mouseY, float partialTicks)
{
if(this.visible)
{
this.drawBackground(mouseX, mouseY);
this.renderBg(Minecraft.getInstance(), mouseX, mouseY);
this.drawCenteredString(Minecraft.getInstance().fontRenderer, this.displayString, this.x + this.width / 2, this.y + (this.height - 8) / 2, this.getTextColor());
}
}
@Override
public void onClick(double mouseX, double mouseY)
{
super.onClick(mouseX, mouseY);
if(this.actionHandler != null)
{
ActionHelper.tryRun(this.actionHandler);
}
}
protected int getTextColor()
{
int textColor = 0xE0E0E0;
if(!this.enabled)
{
textColor = 0xA0A0A0;
}
else if(this.hovered)
{
textColor = 0xFFFFA0;
}
return textColor;
}
}

View File

@@ -0,0 +1,59 @@
package exopandora.worldhandler.gui.button;
import exopandora.worldhandler.helper.ResourceHelper;
import exopandora.worldhandler.util.ActionHandler;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public class GuiButtonIcon extends GuiButtonTooltip
{
private EnumIcon icon;
public GuiButtonIcon(int x, int y, int widthIn, int heightIn, EnumIcon icon, String tooltip, ActionHandler actionHandler)
{
this(0, x, y, widthIn, heightIn, icon, tooltip, actionHandler);
}
public GuiButtonIcon(int id, int x, int y, int widthIn, int heightIn, EnumIcon icon, String tooltip, ActionHandler actionHandler)
{
super(id, x, y, widthIn, heightIn, null, tooltip, actionHandler);
this.icon = icon;
}
@Override
public void render(int mouseX, int mouseY, float partialTicks)
{
super.render(mouseX, mouseY, partialTicks);
if(this.icon != null)
{
this.renderIcon();
}
}
private void renderIcon()
{
Minecraft.getInstance().getTextureManager().bindTexture(ResourceHelper.getIconTexture());
if(this.enabled)
{
if(this.hovered)
{
GlStateManager.color4f(1.0F, 1.0F, 0.6F, 1.0F);
}
else
{
GlStateManager.color4f(0.95F, 0.95F, 0.95F, 1.0F);
}
}
else
{
GlStateManager.color4f(0.8F, 0.8F, 0.8F, 1.0F);
}
this.drawTexturedModalRect(this.x + this.width / 2 - 4, this.y + 6, this.icon.getX() * 8, this.icon.getY() * 8, 8, 8);
}
}

View File

@@ -1,46 +1,55 @@
package exopandora.worldhandler.gui.button;
import exopandora.worldhandler.util.ActionHandler;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
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 GuiButtonItem extends GuiButtonWorldHandler
@OnlyIn(Dist.CLIENT)
public class GuiButtonItem extends GuiButtonBase
{
private final ItemStack item;
private final ItemStack stack;
public GuiButtonItem(int id, int x, int y, int width, int height, Item item)
public GuiButtonItem(int x, int y, int width, int height, Item item, ActionHandler actionHandler)
{
this(id, x, y, width, height, new ItemStack(item));
this(0, x, y, width, height, item, actionHandler);
}
public GuiButtonItem(int id, int x, int y, int width, int height, ItemStack item)
public GuiButtonItem(int id, int x, int y, int width, int height, Item item, ActionHandler actionHandler)
{
super(id, x, y, width, height, null);
this.item = item;
this(id, x, y, width, height, new ItemStack(item), actionHandler);
}
public GuiButtonItem(int x, int y, int width, int height, ItemStack stack, ActionHandler actionHandler)
{
this(0, x, y, width, height, stack, actionHandler);
}
public GuiButtonItem(int id, int x, int y, int width, int height, ItemStack stack, ActionHandler actionHandler)
{
super(id, x, y, width, height, null, actionHandler);
this.stack = stack;
}
@Override
public void drawButton(Minecraft minecraft, int mouseX, int mouseY, float partialTicks)
public void render(int mouseX, int mouseY, float partialTicks)
{
if(this.visible)
{
super.drawBackground(minecraft, mouseX, mouseY);
super.drawBackground(mouseX, mouseY);
GlStateManager.enableRescaleNormal();
RenderHelper.enableGUIStandardItemLighting();
Minecraft.getMinecraft().getRenderItem().renderItemIntoGUI(this.item, this.x + this.width / 2 - 8, this.y + 2);
Minecraft.getInstance().getItemRenderer().renderItemIntoGUI(this.stack, this.x + this.width / 2 - 8, this.y + 2);
RenderHelper.disableStandardItemLighting();
GlStateManager.disableRescaleNormal();
GlStateManager.disableBlend();
this.isActive = true;
}
}
}

View File

@@ -1,181 +0,0 @@
package exopandora.worldhandler.gui.button;
import org.lwjgl.input.Mouse;
import exopandora.worldhandler.Main;
import exopandora.worldhandler.WorldHandler;
import exopandora.worldhandler.config.ConfigSkin;
import exopandora.worldhandler.gui.container.Container;
import exopandora.worldhandler.gui.content.Content;
import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.audio.SoundHandler;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundEvent;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiButtonKeyboard extends GuiButtonWorldHandler
{
private static final ResourceLocation NOTE = new ResourceLocation(Main.MODID, "textures/misc/note.png");
private final Orientation orientation;
private final float pitch;
private boolean lastMousePressed;
private final BlockPos pos;
private final SoundEvent sound;
private final Content content;
private final Container container;
public GuiButtonKeyboard(int id, int x, int y, int width, int height, String displayString, Orientation orientation, float pitch, Container container, Content content, BlockPos pos, SoundEvent sound)
{
super(id, x, y, width, height, displayString);
this.orientation = orientation;
this.pitch = pitch;
this.pos = pos;
this.sound = sound;
this.content = content;
this.container = container;
}
@Override
public void drawButton(Minecraft minecraft, int mouseX, int mouseY, float partialTicks)
{
if(this.visible)
{
FontRenderer fontRenderer = minecraft.fontRenderer;
GlStateManager.color(1.0F, 1.0F, 1.0F, (float) ConfigSkin.getButtonAlpha() / 255);
minecraft.renderEngine.bindTexture(NOTE);
switch(this.orientation)
{
case LEFT:
this.hovered = this.isHoveringLeft(mouseX, mouseY);
break;
case NORMAL:
this.hovered = this.isHoveringNormal(mouseX, mouseY);
break;
case RIGHT:
this.hovered = this.isHoveringRight(mouseX, mouseY);
break;
case BLACK:
this.hovered = this.isHoveringBlack(mouseX, mouseY);
break;
default:
break;
}
int hoverstate = this.getHoverState(this.hovered);
switch(this.orientation)
{
case BLACK:
this.drawTexturedModalRect(this.x, this.y, 55 + hoverstate * -9 + 18, 0, 9, 58);
break;
case LEFT:
case NORMAL:
case RIGHT:
default:
int textColor = 0x000000;
if(!this.enabled)
{
textColor = 0xA0A0A0;
}
else if(this.hovered)
{
textColor = 0x8B8B8B;
}
this.drawTexturedModalRect(this.x, this.y, 25 + hoverstate * 15 - 15, 0, 15, 92);
fontRenderer.drawString(this.displayString, this.x + this.width / 2 - fontRenderer.getStringWidth(this.displayString) / 2, this.y + (this.height - 8) / 2 + 36, textColor);
break;
}
}
this.mouseDragged(minecraft, mouseX, mouseY);
}
private boolean isHoveringBlack(int mouseX, int mouseY)
{
return mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
}
private boolean isHoveringLeft(int mouseX, int mouseY)
{
return (mouseX >= this.x && mouseY >= this.y && mouseX < this.x + 10 && mouseY < this.y + 60) || (mouseX >= this.x && mouseY >= this.y + 58 && mouseX < this.x + 14 && mouseY < this.y + 93);
}
private boolean isHoveringNormal(int mouseX, int mouseY)
{
return (mouseX >= this.x + 4 && mouseY >= this.y && mouseX < this.x + 10 && mouseY < this.y + 60) || (mouseX >= this.x && mouseY >= this.y + 58 && mouseX < this.x + 14 && mouseY < this.y + 93);
}
private boolean isHoveringRight(int mouseX, int mouseY)
{
return (mouseX >= this.x + 4 && mouseY >= this.y && mouseX < this.x + 14 && mouseY < this.y + 60) || (mouseX >= this.x && mouseY >= this.y + 58 && mouseX < this.x + 14 && mouseY < this.y + 93);
}
@Override
public boolean mousePressed(Minecraft minecraft, int mouseX, int mouseY)
{
switch(this.orientation)
{
case LEFT:
return this.enabled && this.visible && this.isHoveringLeft(mouseX, mouseY);
case NORMAL:
return this.enabled && this.visible && this.isHoveringNormal(mouseX, mouseY);
case RIGHT:
return this.enabled && this.visible && this.isHoveringRight(mouseX, mouseY);
case BLACK:
return this.enabled && this.visible && this.isHoveringBlack(mouseX, mouseY);
default:
return false;
}
}
@Override
protected void mouseDragged(Minecraft minecraft, int mouseX, int mouseY)
{
if(this.visible)
{
if(this.lastMousePressed != mousePressed(minecraft, mouseX, mouseY))
{
if(mousePressed(minecraft, mouseX, mouseY) && Mouse.isButtonDown(0))
{
this.playPressSound(minecraft.getSoundHandler());
try
{
this.content.actionPerformed(this.container, this);
}
catch(Exception e)
{
WorldHandler.throwError(e);
}
}
this.lastMousePressed = mousePressed(minecraft, mouseX, mouseY);
}
}
}
@Override
public void playPressSound(SoundHandler soundHandlerIn)
{
soundHandlerIn.playSound(PositionedSoundRecord.getMasterRecord(this.sound, this.pitch));
}
public static enum Orientation
{
LEFT,
NORMAL,
RIGHT,
BLACK;
}
}

View File

@@ -1,110 +1,80 @@
package exopandora.worldhandler.gui.button;
import java.util.List;
import com.mojang.realmsclient.gui.ChatFormatting;
import exopandora.worldhandler.format.TextFormatting;
import exopandora.worldhandler.gui.button.logic.IListButtonLogic;
import exopandora.worldhandler.gui.button.persistence.ButtonValue;
import exopandora.worldhandler.gui.container.Container;
import exopandora.worldhandler.gui.content.Content;
import exopandora.worldhandler.gui.logic.ILogicMapped;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
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 GuiButtonList<T> extends GuiButtonWorldHandler
@OnlyIn(Dist.CLIENT)
public class GuiButtonList<T> extends GuiButtonTooltip
{
private final IListButtonLogic<T> logic;
private final ButtonValue<T> persistence;
private int mouseX;
private int mouseY;
private final ILogicMapped<T> logic;
private final Persistence persistence;
private final List<T> items;
public GuiButtonList(int id, int x, int y, int width, int height, Content content, IListButtonLogic<T> logic)
public GuiButtonList(int x, int y, List<T> items, int widthIn, int heightIn, Container container, ILogicMapped<T> logic)
{
this(id, x, y, width, height, null, content, logic);
this(0, x, y, items, widthIn, heightIn, container, logic);
}
public GuiButtonList(int id, int x, int y, int width, int height, EnumTooltip tooltipType, Content content, IListButtonLogic<T> logic)
public GuiButtonList(int id, int x, int y, List<T> items, int widthIn, int heightIn, Container container, ILogicMapped<T> logic)
{
super(id, x, y, width, height, null, null, tooltipType);
super(id, x, y, widthIn, heightIn, null, null, null);
this.items = items;
this.logic = logic;
this.persistence = content.getPersistence(this.logic.getId());
this.updatePersistenceObject();
this.persistence = container.getContent().getPersistence(this.logic.getId(), Persistence::new);
}
@Override
public void drawButton(Minecraft minecraft, int mouseX, int mouseY, float partialTicks)
public void render(int mouseX, int mouseY, float partialTicks)
{
super.drawBackground(minecraft, mouseX, mouseY);
if(this.visible)
{
FontRenderer fontRenderer = minecraft.fontRenderer;
this.drawBackground(mouseX, mouseY);
this.mouseX = mouseX;
this.mouseY = mouseY;
String displayString = this.logic.translate(this.items.get(this.persistence.getIndex()));
FontRenderer fontRenderer = Minecraft.getInstance().fontRenderer;
this.displayString = this.logic.getDisplayString(this.persistence);
if(this.displayString != null && !this.displayString.isEmpty())
if(displayString != null && !displayString.isEmpty())
{
String leftArrow = this.isHoveringLeft(mouseX, mouseY) ? ChatFormatting.BOLD + "<" + ChatFormatting.RESET : "<";
String rightArrow = this.isHoveringRight(mouseX, mouseY) ? ChatFormatting.BOLD + ">" + ChatFormatting.RESET : ">";
int leftArrowWidth = fontRenderer.getStringWidth(leftArrow);
int rightArrowWidth = fontRenderer.getStringWidth(rightArrow);
int maxWidth = Math.max(0, this.width - (fontRenderer.getStringWidth("< >")));
int spaceWidth = fontRenderer.getCharWidth(' ');
int maxWidth = Math.max(0, this.width - fontRenderer.getStringWidth("< >"));
int spaceWidth = fontRenderer.getStringWidth(" ");
String display = TextFormatting.shortenString(this.displayString, maxWidth, fontRenderer);
int displayWidth = fontRenderer.getStringWidth(display);
String display = TextFormatting.shortenString(displayString, maxWidth, fontRenderer);
int yPos = this.y + (this.height - 8) / 2;
this.drawCenteredString(fontRenderer, display, this.x + this.width / 2, yPos, this.getTextColor());
this.drawCenteredString(fontRenderer, leftArrow, this.x + this.width / 2 - maxWidth / 2 - spaceWidth, yPos, this.getTextColor());
this.drawCenteredString(fontRenderer, rightArrow, this.x + this.width / 2 + maxWidth / 2 + spaceWidth, yPos, this.getTextColor());
}
this.isActive = true;
}
}
@Override
public void drawTooltip(int mouseX, int mouseY, int width, int height)
public void renderTooltip(int mouseX, int mouseY)
{
if(this.tooltipType != null)
{
this.displayTooltip = this.logic.getTooltipString(this.persistence);
}
super.drawTooltip(mouseX, mouseY, width, height);
this.tooltip = this.logic.formatTooltip(this.items.get(this.persistence.getIndex()), this.persistence.getIndex() + 1, this.items.size());
super.renderTooltip(mouseX, mouseY);
}
private boolean isHoveringLeft(int mouseX, int mouseY)
@Override
public void onClick(double mouseX, double mouseY)
{
return this.isHoveringVertical(mouseY) && mouseX >= this.x && mouseX < this.x + Math.ceil(this.width / 2);
}
private boolean isHoveringRight(int mouseX, int mouseY)
{
return this.isHoveringVertical(mouseY) && mouseX >= this.x + Math.ceil(this.width / 2) && mouseX < this.x + this.width;
}
private boolean isHoveringVertical(int mouseY)
{
return mouseY >= this.y && mouseY < this.y + this.height;
}
public void actionPerformed(Container container, GuiButton button)
{
int max = this.logic.getMax() - 1;
int max = this.items.size() - 1;
int index = this.persistence.getIndex();
if(this.isHoveringLeft(this.mouseX, this.mouseY))
if(this.isHoveringLeft(mouseX, mouseY))
{
if(GuiScreen.isShiftKeyDown())
{
@@ -129,7 +99,7 @@ public class GuiButtonList<T> extends GuiButtonWorldHandler
}
}
}
else if(this.isHoveringRight(this.mouseX, this.mouseY))
else if(this.isHoveringRight(mouseX, mouseY))
{
if(GuiScreen.isShiftKeyDown())
{
@@ -155,17 +125,67 @@ public class GuiButtonList<T> extends GuiButtonWorldHandler
}
}
this.updatePersistenceObject();
this.logic.actionPerformed(container, button, this.persistence);
this.logic.onClick(this.items.get(this.persistence.getIndex()));
}
private void updatePersistenceObject()
private boolean isHoveringLeft(double mouseX, double mouseY)
{
this.persistence.setObject(this.logic.getObject(this.persistence.getIndex()));
return this.isHoveringVertical(mouseY) && mouseX >= this.x && mouseX < this.x + Math.ceil(this.width / 2);
}
public IListButtonLogic<T> getLogic()
private boolean isHoveringRight(double mouseX, double mouseY)
{
return this.logic;
return this.isHoveringVertical(mouseY) && mouseX >= this.x + Math.ceil(this.width / 2) && mouseX < this.x + this.width;
}
private boolean isHoveringVertical(double mouseY)
{
return mouseY >= this.y && mouseY < this.y + this.height;
}
@OnlyIn(Dist.CLIENT)
public static class Persistence
{
private int index;
public Persistence()
{
this(0);
}
public Persistence(int index)
{
this.index = index;
}
public void setIndex(int index)
{
this.index = index;
}
public int getIndex()
{
return this.index;
}
public void incrementIndex()
{
this.index++;
}
public void incrementIndex(int amount)
{
this.index += amount;
}
public void decrementIndex()
{
this.index--;
}
public void decrementIndex(int amount)
{
this.index -= amount;
}
}
}

Some files were not shown because too many files have changed in this diff Show More