diff --git a/api/buildcraft/api/gates/ActionParameter.java b/api/buildcraft/api/gates/ActionParameter.java new file mode 100755 index 00000000..a339a9e0 --- /dev/null +++ b/api/buildcraft/api/gates/ActionParameter.java @@ -0,0 +1,73 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ +package buildcraft.api.gates; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +public class ActionParameter implements IActionParameter { + + protected ItemStack stack; + + /* + * (non-Javadoc) + * + * @see net.minecraft.src.buildcraft.api.gates.ITriggerParameter#getItemStack() + */ + @Override + public ItemStack getItemStack() { + return stack; + } + + /* + * (non-Javadoc) + * + * @see net.minecraft.src.buildcraft.api.gates.ITriggerParameter#set(net.minecraft.src.ItemStack) + */ + @Override + public void set(ItemStack stack) { + if (stack != null) { + this.stack = stack.copy(); + this.stack.stackSize = 1; + } + } + + /* + * (non-Javadoc) + * + * @see net.minecraft.src.buildcraft.api.gates.ITriggerParameter#writeToNBT(net.minecraft.src.NBTTagCompound) + */ + @Override + public void writeToNBT(NBTTagCompound compound) { + if (stack != null) { + NBTTagCompound tagCompound = new NBTTagCompound(); + stack.writeToNBT(tagCompound); + compound.setTag("stack", tagCompound); + } + } + + /* + * (non-Javadoc) + * + * @see net.minecraft.src.buildcraft.api.gates.ITriggerParameter#readFromNBT(net.minecraft.src.NBTTagCompound) + */ + @Override + public void readFromNBT(NBTTagCompound compound) { + // Legacy code to prevent existing gates from losing their contents + int itemID = compound.getInteger("itemID"); + if (itemID != 0) { + stack = new ItemStack((Item) Item.itemRegistry.getObject(itemID), 1, compound.getInteger("itemDMG")); + return; + } + + stack = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("stack")); + } + +} diff --git a/api/buildcraft/api/gates/IAction.java b/api/buildcraft/api/gates/IAction.java old mode 100644 new mode 100755 index 503c645f..a02c4486 --- a/api/buildcraft/api/gates/IAction.java +++ b/api/buildcraft/api/gates/IAction.java @@ -8,24 +8,6 @@ */ package buildcraft.api.gates; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.util.IIcon; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; +public interface IAction extends IStatement { -public interface IAction { - - String getUniqueTag(); - - @SideOnly(Side.CLIENT) - IIcon getIcon(); - - @SideOnly(Side.CLIENT) - void registerIcons(IIconRegister iconRegister); - - boolean hasParameter(); - - String getDescription(); - - IAction rotateLeft(); } diff --git a/api/buildcraft/api/gates/IActionParameter.java b/api/buildcraft/api/gates/IActionParameter.java new file mode 100755 index 00000000..da49412e --- /dev/null +++ b/api/buildcraft/api/gates/IActionParameter.java @@ -0,0 +1,13 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ +package buildcraft.api.gates; + +public interface IActionParameter extends IStatementParameter { + +} diff --git a/api/buildcraft/api/gates/IStatement.java b/api/buildcraft/api/gates/IStatement.java new file mode 100644 index 00000000..14bcdde2 --- /dev/null +++ b/api/buildcraft/api/gates/IStatement.java @@ -0,0 +1,59 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ +package buildcraft.api.gates; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +public interface IStatement { + + /** + * Every trigger needs a unique tag, it should be in the format of + * ":". + * + * @return the unique id + */ + String getUniqueTag(); + + @SideOnly(Side.CLIENT) + IIcon getIcon(); + + @SideOnly(Side.CLIENT) + void registerIcons(IIconRegister iconRegister); + + /** + * Return the maximum number of parameter this trigger can have, 0 if none. + */ + int maxParameters(); + + /** + * Return the minimum number of parameter this trigger can have, 0 if none. + */ + int minParameters(); + + /** + * Return the trigger description in the UI + */ + String getDescription(); + + /** + * Create parameters for the trigger. As for now, there is only one kind of + * trigger parameter available so this subprogram is final. + */ + IStatementParameter createParameter(int index); + + /** + * This returns the trigger after a left rotation. Used in particular in + * blueprints orientation. + */ + IStatement rotateLeft(); +} diff --git a/api/buildcraft/api/gates/IStatementParameter.java b/api/buildcraft/api/gates/IStatementParameter.java new file mode 100755 index 00000000..81c22291 --- /dev/null +++ b/api/buildcraft/api/gates/IStatementParameter.java @@ -0,0 +1,24 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ +package buildcraft.api.gates; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +public interface IStatementParameter { + + ItemStack getItemStack(); + + void set(ItemStack stack); + + void writeToNBT(NBTTagCompound compound); + + void readFromNBT(NBTTagCompound compound); + +} diff --git a/api/buildcraft/api/gates/ITrigger.java b/api/buildcraft/api/gates/ITrigger.java old mode 100644 new mode 100755 index ea2c3ab0..58a09b0c --- a/api/buildcraft/api/gates/ITrigger.java +++ b/api/buildcraft/api/gates/ITrigger.java @@ -8,51 +8,6 @@ */ package buildcraft.api.gates; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.util.IIcon; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; +public interface ITrigger extends IStatement { -public interface ITrigger { - - /** - * Every trigger needs a unique tag, it should be in the format of - * ":". - * - * @return the unique id - */ - String getUniqueTag(); - - @SideOnly(Side.CLIENT) - IIcon getIcon(); - - @SideOnly(Side.CLIENT) - void registerIcons(IIconRegister iconRegister); - - /** - * Return true if this trigger can accept parameters - */ - boolean hasParameter(); - - /** - * Return true if this trigger requires a parameter - */ - boolean requiresParameter(); - - /** - * Return the trigger description in the UI - */ - String getDescription(); - - /** - * Create parameters for the trigger. As for now, there is only one kind of - * trigger parameter available so this subprogram is final. - */ - ITriggerParameter createParameter(); - - /** - * This returns the trigger after a left rotation. Used in particular in - * blueprints orientation. - */ - ITrigger rotateLeft(); } diff --git a/api/buildcraft/api/gates/ITriggerParameter.java b/api/buildcraft/api/gates/ITriggerParameter.java index d5f4d886..68c7d6af 100644 --- a/api/buildcraft/api/gates/ITriggerParameter.java +++ b/api/buildcraft/api/gates/ITriggerParameter.java @@ -8,20 +8,6 @@ */ package buildcraft.api.gates; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - -public interface ITriggerParameter { - - ItemStack getItemStack(); - - void set(ItemStack stack); - - void writeToNBT(NBTTagCompound compound); - - void readFromNBT(NBTTagCompound compound); - - @Deprecated - ItemStack getItem(); +public interface ITriggerParameter extends IStatementParameter { } diff --git a/api/buildcraft/api/gates/ActionManager.java b/api/buildcraft/api/gates/StatementManager.java similarity index 84% rename from api/buildcraft/api/gates/ActionManager.java rename to api/buildcraft/api/gates/StatementManager.java index 2b5ddda0..f2223b34 100644 --- a/api/buildcraft/api/gates/ActionManager.java +++ b/api/buildcraft/api/gates/StatementManager.java @@ -18,17 +18,16 @@ import net.minecraft.tileentity.TileEntity; import buildcraft.api.transport.IPipeTile; -public final class ActionManager { +public final class StatementManager { - public static Map triggers = new HashMap(); - public static Map actions = new HashMap(); + public static Map statements = new HashMap(); private static List triggerProviders = new LinkedList(); private static List actionProviders = new LinkedList(); /** * Deactivate constructor */ - private ActionManager() { + private StatementManager() { } public static void registerTriggerProvider(ITriggerProvider provider) { @@ -37,12 +36,8 @@ public final class ActionManager { } } - public static void registerTrigger(ITrigger trigger) { - triggers.put(trigger.getUniqueTag(), trigger); - } - - public static void registerAction(IAction action) { - actions.put(action.getUniqueTag(), action); + public static void registerStatement(IStatement statement) { + statements.put(statement.getUniqueTag(), statement); } public static List getNeighborTriggers(Block block, TileEntity entity) { diff --git a/api/buildcraft/api/gates/TriggerParameter.java b/api/buildcraft/api/gates/TriggerParameter.java index 46336c15..d86f00b3 100644 --- a/api/buildcraft/api/gates/TriggerParameter.java +++ b/api/buildcraft/api/gates/TriggerParameter.java @@ -70,10 +70,4 @@ public class TriggerParameter implements ITriggerParameter { stack = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("stack")); } - @Override - @Deprecated - public ItemStack getItem() { - return stack; - } - } diff --git a/buildcraft_resources/assets/buildcraft/textures/blocks/gates/gate_material_emerald.png b/buildcraft_resources/assets/buildcraft/textures/blocks/gates/gate_material_emerald.png new file mode 100755 index 00000000..935b152d Binary files /dev/null and b/buildcraft_resources/assets/buildcraft/textures/blocks/gates/gate_material_emerald.png differ diff --git a/buildcraft_resources/assets/buildcraft/textures/blocks/pipeRobotStationParked.png b/buildcraft_resources/assets/buildcraft/textures/blocks/pipeRobotStationParked.png new file mode 100755 index 00000000..ce81e847 Binary files /dev/null and b/buildcraft_resources/assets/buildcraft/textures/blocks/pipeRobotStationParked.png differ diff --git a/buildcraft_resources/assets/buildcraft/textures/blocks/pipeRobotStationReserved.png b/buildcraft_resources/assets/buildcraft/textures/blocks/pipeRobotStationReserved.png new file mode 100755 index 00000000..84182a83 Binary files /dev/null and b/buildcraft_resources/assets/buildcraft/textures/blocks/pipeRobotStationReserved.png differ diff --git a/buildcraft_resources/assets/buildcraft/textures/gui/gate_interface_5.png b/buildcraft_resources/assets/buildcraft/textures/gui/gate_interface_5.png new file mode 100755 index 00000000..abf8373a Binary files /dev/null and b/buildcraft_resources/assets/buildcraft/textures/gui/gate_interface_5.png differ diff --git a/buildcraft_resources/assets/buildcraft/textures/items/gates/gate_material_emerald.png b/buildcraft_resources/assets/buildcraft/textures/items/gates/gate_material_emerald.png new file mode 100755 index 00000000..459bfab9 Binary files /dev/null and b/buildcraft_resources/assets/buildcraft/textures/items/gates/gate_material_emerald.png differ diff --git a/buildcraft_resources/assets/buildcraft/textures/items/redstone_emerald_chipset.png b/buildcraft_resources/assets/buildcraft/textures/items/redstone_emerald_chipset.png new file mode 100755 index 00000000..592f213b Binary files /dev/null and b/buildcraft_resources/assets/buildcraft/textures/items/redstone_emerald_chipset.png differ diff --git a/common/buildcraft/BuildCraftBuilders.java b/common/buildcraft/BuildCraftBuilders.java index d3cf7a09..1f5f1b73 100644 --- a/common/buildcraft/BuildCraftBuilders.java +++ b/common/buildcraft/BuildCraftBuilders.java @@ -49,7 +49,7 @@ import buildcraft.api.core.BCLog; import buildcraft.api.core.JavaTools; import buildcraft.api.filler.FillerManager; import buildcraft.api.filler.IFillerPattern; -import buildcraft.api.gates.ActionManager; +import buildcraft.api.gates.StatementManager; import buildcraft.builders.BlockArchitect; import buildcraft.builders.BlockBlueprintLibrary; import buildcraft.builders.BlockBuildTool; @@ -477,7 +477,7 @@ public class BuildCraftBuilders extends BuildCraftMod { throw error; } - ActionManager.registerActionProvider(new BuildersActionProvider()); + StatementManager.registerActionProvider(new BuildersActionProvider()); } public static void loadRecipes() { diff --git a/common/buildcraft/BuildCraftCore.java b/common/buildcraft/BuildCraftCore.java index dce200eb..0bdadfc6 100644 --- a/common/buildcraft/BuildCraftCore.java +++ b/common/buildcraft/BuildCraftCore.java @@ -62,7 +62,7 @@ import buildcraft.api.core.BCLog; import buildcraft.api.core.BuildCraftAPI; import buildcraft.api.core.IIconProvider; import buildcraft.api.core.JavaTools; -import buildcraft.api.gates.ActionManager; +import buildcraft.api.gates.StatementManager; import buildcraft.api.recipes.BuildcraftRecipeRegistry; import buildcraft.builders.urbanism.EntityRobotUrbanism; import buildcraft.core.BlockIndex; @@ -307,8 +307,8 @@ public class BuildCraftCore extends BuildCraftMod { channels = NetworkRegistry.INSTANCE.newChannel (DefaultProps.NET_CHANNEL_NAME + "-CORE", new BuildCraftChannelHandler(), new PacketHandler()); - ActionManager.registerTriggerProvider(new DefaultTriggerProvider()); - ActionManager.registerActionProvider(new DefaultActionProvider()); + StatementManager.registerTriggerProvider(new DefaultTriggerProvider()); + StatementManager.registerActionProvider(new DefaultActionProvider()); if (BuildCraftCore.modifyWorld) { MinecraftForge.EVENT_BUS.register(new SpringPopulate()); diff --git a/common/buildcraft/BuildCraftSilicon.java b/common/buildcraft/BuildCraftSilicon.java index ba227a2d..aa161661 100644 --- a/common/buildcraft/BuildCraftSilicon.java +++ b/common/buildcraft/BuildCraftSilicon.java @@ -199,6 +199,8 @@ public class BuildCraftSilicon extends BuildCraftMod { Items.redstone, Items.quartz); BuildcraftRecipeRegistry.assemblyTable.addRecipe("buildcraft:compChipset", 60000, Chipset.COMP.getStack(), Items.redstone, Items.comparator); + BuildcraftRecipeRegistry.assemblyTable.addRecipe("buildcraft:emeraldChipset", 120000, + Chipset.EMERALD.getStack(), Items.redstone, Items.emerald); // GATES BuildcraftRecipeRegistry.assemblyTable.addRecipe("buildcraft:simpleGate", 10000, @@ -209,6 +211,8 @@ public class BuildCraftSilicon extends BuildCraftMod { addGateRecipe("Gold", 40000, GateMaterial.GOLD, Chipset.GOLD, PipeWire.RED, PipeWire.BLUE, PipeWire.GREEN); addGateRecipe("Diamond", 80000, GateMaterial.DIAMOND, Chipset.DIAMOND, PipeWire.RED, PipeWire.BLUE, PipeWire.GREEN, PipeWire.YELLOW); + addGateRecipe("Emerald", 120000, GateMaterial.EMERALD, Chipset.DIAMOND, PipeWire.RED, PipeWire.BLUE, + PipeWire.GREEN, PipeWire.YELLOW); // ROBOTS AND BOARDS BuildcraftRecipeRegistry.assemblyTable.addRecipe("buildcraft:redstoneCrystal", 1000000, new ItemStack( diff --git a/common/buildcraft/BuildCraftTransport.java b/common/buildcraft/BuildCraftTransport.java index 4e7a7f49..46c209a1 100644 --- a/common/buildcraft/BuildCraftTransport.java +++ b/common/buildcraft/BuildCraftTransport.java @@ -35,8 +35,8 @@ import net.minecraftforge.oredict.RecipeSorter; import buildcraft.api.blueprints.SchematicRegistry; import buildcraft.api.core.IIconProvider; import buildcraft.api.core.JavaTools; -import buildcraft.api.gates.ActionManager; import buildcraft.api.gates.GateExpansions; +import buildcraft.api.gates.StatementManager; import buildcraft.api.recipes.BuildcraftRecipeRegistry; import buildcraft.api.transport.IExtractionHandler; import buildcraft.api.transport.PipeManager; @@ -443,7 +443,7 @@ public class BuildCraftTransport extends BuildCraftMod { new BptItemPipeFilters(pipeItemsDiamond); - ActionManager.registerTriggerProvider(new PipeTriggerProvider()); + StatementManager.registerTriggerProvider(new PipeTriggerProvider()); if (BuildCraftCore.loadDefaultRecipes) { loadRecipes(); diff --git a/common/buildcraft/builders/triggers/ActionFiller.java b/common/buildcraft/builders/triggers/ActionFiller.java index 2cbce2d4..89b18ef8 100644 --- a/common/buildcraft/builders/triggers/ActionFiller.java +++ b/common/buildcraft/builders/triggers/ActionFiller.java @@ -9,6 +9,7 @@ package buildcraft.builders.triggers; import net.minecraft.util.IIcon; + import buildcraft.api.gates.IAction; import buildcraft.builders.filler.pattern.FillerPattern; import buildcraft.core.triggers.BCAction; @@ -32,11 +33,6 @@ public class ActionFiller extends BCAction { return pattern.getIcon(); } - @Override - public int getTextureMap() { - return 0; - } - @Override public IAction rotateLeft() { return this; diff --git a/common/buildcraft/core/triggers/BCAction.java b/common/buildcraft/core/triggers/BCAction.java index cb8ef8ee..98883b5f 100644 --- a/common/buildcraft/core/triggers/BCAction.java +++ b/common/buildcraft/core/triggers/BCAction.java @@ -8,59 +8,12 @@ */ package buildcraft.core.triggers; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.util.IIcon; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -import buildcraft.api.gates.ActionManager; import buildcraft.api.gates.IAction; -public abstract class BCAction implements IAction { +public abstract class BCAction extends BCStatement implements IAction { - protected final String uniqueTag; - - /** - * UniqueTag accepts multiple possible tags, use this feature to migrate to - * more standardized tags if needed, otherwise just pass a single string. - * The first passed string will be the one used when saved to disk. - * - * @param uniqueTag - */ public BCAction(String... uniqueTag) { - this.uniqueTag = uniqueTag[0]; - for (String tag : uniqueTag) { - ActionManager.actions.put(tag, this); - } + super(uniqueTag); } - @Override - public String getUniqueTag() { - return uniqueTag; - } - - public int getIconIndex() { - return 0; - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon() { - return ActionTriggerIconProvider.INSTANCE.getIcon(getIconIndex()); - } - - public int getTextureMap() { - return 1; - } - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister iconRegister) { - } - - @Override - public boolean hasParameter() { - return false; - } } diff --git a/common/buildcraft/core/triggers/BCStatement.java b/common/buildcraft/core/triggers/BCStatement.java new file mode 100755 index 00000000..f693ae32 --- /dev/null +++ b/common/buildcraft/core/triggers/BCStatement.java @@ -0,0 +1,80 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ +package buildcraft.core.triggers; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +import buildcraft.api.gates.IStatement; +import buildcraft.api.gates.ITriggerParameter; +import buildcraft.api.gates.StatementManager; +import buildcraft.api.gates.TriggerParameter; + +public abstract class BCStatement implements IStatement { + + protected final String uniqueTag; + + /** + * UniqueTag accepts multiple possible tags, use this feature to migrate to + * more standardized tags if needed, otherwise just pass a single string. + * The first passed string will be the one used when saved to disk. + * + * @param uniqueTag + */ + public BCStatement(String... uniqueTag) { + this.uniqueTag = uniqueTag[0]; + for (String tag : uniqueTag) { + StatementManager.statements.put(tag, this); + } + } + + @Override + public String getUniqueTag() { + return uniqueTag; + } + + public int getIconIndex() { + return 0; + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon() { + return ActionTriggerIconProvider.INSTANCE.getIcon(getIconIndex()); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconRegister) { + } + + @Override + public int maxParameters() { + return 0; + } + + @Override + public int minParameters() { + return 0; + } + + @Override + public String getDescription() { + return ""; + } + + @Override + public final ITriggerParameter createParameter(int index) { + return new TriggerParameter(); + } + +} diff --git a/common/buildcraft/core/triggers/BCTrigger.java b/common/buildcraft/core/triggers/BCTrigger.java index 8cd707a8..b641ce22 100644 --- a/common/buildcraft/core/triggers/BCTrigger.java +++ b/common/buildcraft/core/triggers/BCTrigger.java @@ -8,77 +8,17 @@ */ package buildcraft.core.triggers; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.util.IIcon; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -import buildcraft.api.gates.ActionManager; import buildcraft.api.gates.ITrigger; -import buildcraft.api.gates.ITriggerParameter; -import buildcraft.api.gates.TriggerParameter; /** * This class has to be implemented to create new triggers kinds to BuildCraft * gates. There is an instance per kind, which will get called wherever the * trigger can be active. */ -public abstract class BCTrigger implements ITrigger { +public abstract class BCTrigger extends BCStatement implements ITrigger { - protected final String uniqueTag; - - /** - * UniqueTag accepts multiple possible tags, use this feature to migrate to - * more standardized tags if needed, otherwise just pass a single string. - * The first passed string will be the one used when saved to disk. - * - * @param uniqueTag - */ public BCTrigger(String... uniqueTag) { - this.uniqueTag = uniqueTag[0]; - for (String tag : uniqueTag) { - ActionManager.triggers.put(tag, this); - } + super(uniqueTag); } - @Override - public String getUniqueTag() { - return uniqueTag; - } - - public int getIconIndex() { - return 0; - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon() { - return ActionTriggerIconProvider.INSTANCE.getIcon(getIconIndex()); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister iconRegister) { - } - - @Override - public boolean hasParameter() { - return false; - } - - @Override - public boolean requiresParameter() { - return false; - } - - @Override - public String getDescription() { - return ""; - } - - @Override - public final ITriggerParameter createParameter() { - return new TriggerParameter(); - } } diff --git a/common/buildcraft/core/triggers/TriggerFluidContainer.java b/common/buildcraft/core/triggers/TriggerFluidContainer.java index 1d1ead6c..1824e362 100644 --- a/common/buildcraft/core/triggers/TriggerFluidContainer.java +++ b/common/buildcraft/core/triggers/TriggerFluidContainer.java @@ -37,8 +37,8 @@ public class TriggerFluidContainer extends BCTrigger implements ITileTrigger { } @Override - public boolean hasParameter() { - return state == State.Contains || state == State.Space; + public int maxParameters() { + return state == State.Contains || state == State.Space ? 1 : 0; } @Override diff --git a/common/buildcraft/core/triggers/TriggerFluidContainerLevel.java b/common/buildcraft/core/triggers/TriggerFluidContainerLevel.java index f16fa97e..7e62b906 100644 --- a/common/buildcraft/core/triggers/TriggerFluidContainerLevel.java +++ b/common/buildcraft/core/triggers/TriggerFluidContainerLevel.java @@ -44,8 +44,8 @@ public class TriggerFluidContainerLevel extends BCTrigger implements ITileTrigge } @Override - public boolean hasParameter() { - return true; + public int maxParameters() { + return 1; } @Override diff --git a/common/buildcraft/core/triggers/TriggerInventory.java b/common/buildcraft/core/triggers/TriggerInventory.java index 0ff8fe9d..c25096af 100644 --- a/common/buildcraft/core/triggers/TriggerInventory.java +++ b/common/buildcraft/core/triggers/TriggerInventory.java @@ -39,8 +39,8 @@ public class TriggerInventory extends BCTrigger implements ITileTrigger { } @Override - public boolean hasParameter() { - return state == State.Contains || state == State.Space; + public int maxParameters() { + return state == State.Contains || state == State.Space ? 1 : 0; } @Override diff --git a/common/buildcraft/core/triggers/TriggerInventoryLevel.java b/common/buildcraft/core/triggers/TriggerInventoryLevel.java index f92d5a07..4720697b 100644 --- a/common/buildcraft/core/triggers/TriggerInventoryLevel.java +++ b/common/buildcraft/core/triggers/TriggerInventoryLevel.java @@ -45,13 +45,13 @@ public class TriggerInventoryLevel extends BCTrigger implements ITileTrigger { } @Override - public boolean hasParameter() { - return true; + public int maxParameters() { + return 1; } @Override - public boolean requiresParameter() { - return true; + public int minParameters() { + return 1; } @Override diff --git a/common/buildcraft/silicon/ItemRedstoneChipset.java b/common/buildcraft/silicon/ItemRedstoneChipset.java index 7d735596..5b0b3118 100644 --- a/common/buildcraft/silicon/ItemRedstoneChipset.java +++ b/common/buildcraft/silicon/ItemRedstoneChipset.java @@ -34,7 +34,8 @@ public class ItemRedstoneChipset extends ItemBuildCraft { DIAMOND, PULSATING, QUARTZ, - COMP; + COMP, + EMERALD; public static final Chipset[] VALUES = values(); private IIcon icon; diff --git a/common/buildcraft/transport/Gate.java b/common/buildcraft/transport/Gate.java index c2381e48..9bbcede9 100644 --- a/common/buildcraft/transport/Gate.java +++ b/common/buildcraft/transport/Gate.java @@ -27,14 +27,15 @@ import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; import buildcraft.BuildCraftTransport; -import buildcraft.api.gates.ActionManager; import buildcraft.api.gates.GateExpansionController; import buildcraft.api.gates.IAction; +import buildcraft.api.gates.IActionParameter; import buildcraft.api.gates.IActionReceptor; import buildcraft.api.gates.IGateExpansion; import buildcraft.api.gates.ITileTrigger; import buildcraft.api.gates.ITrigger; import buildcraft.api.gates.ITriggerParameter; +import buildcraft.api.gates.StatementManager; import buildcraft.api.gates.TriggerParameter; import buildcraft.api.transport.PipeWire; import buildcraft.core.GuiIds; @@ -52,7 +53,8 @@ public final class Gate { public final GateLogic logic; public final BiMap expansions = HashBiMap.create(); public ITrigger[] triggers = new ITrigger[8]; - public ITriggerParameter[] triggerParameters = new ITriggerParameter[8]; + public ITriggerParameter[] triggerParameters = new ITriggerParameter[12]; + public IActionParameter[] actionParameters = new IActionParameter[12]; public IAction[] actions = new IAction[8]; public ActionState[] actionsState = new ActionState[8]; @@ -103,6 +105,10 @@ public final class Gate { return triggerParameters[position]; } + public IActionParameter getActionParameter(int position) { + return actionParameters[position]; + } + public void addGateExpansion(IGateExpansion expansion) { if (!expansions.containsKey(expansion)) { expansions.put(expansion, expansion.makeController(pipe.container)); @@ -147,10 +153,10 @@ public final class Gate { public void readFromNBT(NBTTagCompound data) { for (int i = 0; i < 8; ++i) { if (data.hasKey("trigger[" + i + "]")) { - triggers[i] = ActionManager.triggers.get(data.getString("trigger[" + i + "]")); + triggers[i] = (ITrigger) StatementManager.statements.get(data.getString("trigger[" + i + "]")); } if (data.hasKey("action[" + i + "]")) { - actions[i] = ActionManager.actions.get(data.getString("action[" + i + "]")); + actions[i] = (IAction) StatementManager.statements.get(data.getString("action[" + i + "]")); } if (data.hasKey("triggerParameters[" + i + "]")) { triggerParameters[i] = new TriggerParameter(); diff --git a/common/buildcraft/transport/gates/GateDefinition.java b/common/buildcraft/transport/gates/GateDefinition.java index b365c0c9..e0a97dd7 100644 --- a/common/buildcraft/transport/gates/GateDefinition.java +++ b/common/buildcraft/transport/gates/GateDefinition.java @@ -36,22 +36,29 @@ public final class GateDefinition { public static enum GateMaterial { - REDSTONE("gate_interface_1.png", 146, 1, false), IRON("gate_interface_2.png", 164, 2, false), GOLD("gate_interface_3.png", 200, 4, true), DIAMOND("gate_interface_4.png", 200, 8, true); + REDSTONE("gate_interface_1.png", 146, 1, 0, 0), + IRON("gate_interface_2.png", 164, 2, 0, 0), + GOLD("gate_interface_3.png", 200, 4, 1, 0), + DIAMOND("gate_interface_4.png", 200, 8, 1, 0), + EMERALD("gate_interface_5.png", 200, 4, 3, 3); public static final GateMaterial[] VALUES = values(); public final ResourceLocation guiFile; public final int guiHeight; public final int numSlots; - public final boolean hasParameterSlot; + public final int numTriggerParameters; + public final int numActionParameters; @SideOnly(Side.CLIENT) private IIcon iconBlock; @SideOnly(Side.CLIENT) private IIcon iconItem; - private GateMaterial(String guiFile, int guiHeight, int numSlots, boolean hasParamterSlot) { + private GateMaterial(String guiFile, int guiHeight, int numSlots, int triggerParameterSlots, + int actionParameterSlots) { this.guiFile = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/" + guiFile); this.guiHeight = guiHeight; this.numSlots = numSlots; - this.hasParameterSlot = hasParamterSlot; + this.numTriggerParameters = triggerParameterSlots; + this.numActionParameters = actionParameterSlots; } @SideOnly(Side.CLIENT) diff --git a/common/buildcraft/transport/gates/ItemGate.java b/common/buildcraft/transport/gates/ItemGate.java index 5450c71e..45023398 100644 --- a/common/buildcraft/transport/gates/ItemGate.java +++ b/common/buildcraft/transport/gates/ItemGate.java @@ -30,11 +30,10 @@ import cpw.mods.fml.relauncher.SideOnly; import net.minecraftforge.common.util.Constants; import buildcraft.BuildCraftTransport; -import buildcraft.api.gates.ActionManager; import buildcraft.api.gates.GateExpansions; -import buildcraft.api.gates.IAction; import buildcraft.api.gates.IGateExpansion; -import buildcraft.api.gates.ITrigger; +import buildcraft.api.gates.IStatement; +import buildcraft.api.gates.StatementManager; import buildcraft.core.ItemBuildCraft; import buildcraft.core.inventory.InvUtils; import buildcraft.core.utils.StringUtils; @@ -257,12 +256,8 @@ public class ItemGate extends ItemBuildCraft { expansion.registerItemOverlay(iconRegister); } - for (IAction action : ActionManager.actions.values()) { - action.registerIcons(iconRegister); - } - - for (ITrigger trigger : ActionManager.triggers.values()) { - trigger.registerIcons(iconRegister); + for (IStatement statement : StatementManager.statements.values()) { + statement.registerIcons(iconRegister); } } } diff --git a/common/buildcraft/transport/gui/ContainerGateInterface.java b/common/buildcraft/transport/gui/ContainerGateInterface.java index c0291055..f60d50ff 100644 --- a/common/buildcraft/transport/gui/ContainerGateInterface.java +++ b/common/buildcraft/transport/gui/ContainerGateInterface.java @@ -27,11 +27,11 @@ import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.util.ForgeDirection; import buildcraft.BuildCraftTransport; -import buildcraft.api.gates.ActionManager; import buildcraft.api.gates.IAction; import buildcraft.api.gates.IOverrideDefaultTriggers; import buildcraft.api.gates.ITrigger; import buildcraft.api.gates.ITriggerParameter; +import buildcraft.api.gates.StatementManager; import buildcraft.api.gates.TriggerParameter; import buildcraft.core.gui.BuildCraftContainer; import buildcraft.core.network.PacketCoordinates; @@ -92,7 +92,7 @@ public class ContainerGateInterface extends BuildCraftContainer { // the client. if (!pipe.container.getWorldObj().isRemote) { potentialActions.addAll(pipe.getActions()); - potentialTriggers.addAll(ActionManager.getPipeTriggers(pipe.container)); + potentialTriggers.addAll(StatementManager.getPipeTriggers(pipe.container)); if (pipe.container instanceof IOverrideDefaultTriggers) { potentialTriggers.addAll(((IOverrideDefaultTriggers) pipe.container).getTriggers()); @@ -102,18 +102,30 @@ public class ContainerGateInterface extends BuildCraftContainer { if (pipe.hasGate(o)) { TileEntity tile = pipe.container.getTile(o); Block block = pipe.container.getBlock(o); - potentialTriggers.addAll(ActionManager.getNeighborTriggers(block, tile)); - potentialActions.addAll(ActionManager.getNeighborActions(block, tile)); + potentialTriggers.addAll(StatementManager.getNeighborTriggers(block, tile)); + potentialActions.addAll(StatementManager.getNeighborActions(block, tile)); } } - if (!pipe.gate.material.hasParameterSlot) { + if (pipe.gate.material.numTriggerParameters == 0) { Iterator it = potentialTriggers.iterator(); while (it.hasNext()) { ITrigger trigger = it.next(); - if (trigger.requiresParameter()) { + if (trigger.minParameters() > 0) { + it.remove(); + } + } + } + + if (pipe.gate.material.numActionParameters == 0) { + Iterator it = potentialActions.iterator(); + + while (it.hasNext()) { + IAction action = it.next(); + + if (action.minParameters() > 0) { it.remove(); } } @@ -148,7 +160,7 @@ public class ContainerGateInterface extends BuildCraftContainer { int length = payload.stream.readInt(); for (int i = 0; i < length; i++) { - potentialActions.add(ActionManager.actions.get(Utils.readUTF(payload.stream))); + potentialActions.add((IAction) StatementManager.statements.get(Utils.readUTF(payload.stream))); } } @@ -165,7 +177,7 @@ public class ContainerGateInterface extends BuildCraftContainer { for (int i = 0; i < length; i++) { String trigger = Utils.readUTF(payload.stream); - potentialTriggers.add(ActionManager.triggers.get(trigger)); + potentialTriggers.add((ITrigger) StatementManager.statements.get(trigger)); } } @@ -180,8 +192,8 @@ public class ContainerGateInterface extends BuildCraftContainer { int position = data.readInt(); - setTrigger(position, ActionManager.triggers.get(Utils.readUTF(data)), notify); - setAction(position, ActionManager.actions.get(Utils.readUTF(data)), notify); + setTrigger(position, (ITrigger) StatementManager.statements.get(Utils.readUTF(data)), notify); + setAction(position, (IAction) StatementManager.statements.get(Utils.readUTF(data)), notify); ItemStack parameter = Utils.readStack(data); diff --git a/common/buildcraft/transport/gui/GuiGateInterface.java b/common/buildcraft/transport/gui/GuiGateInterface.java index f8456faa..0c128ff5 100644 --- a/common/buildcraft/transport/gui/GuiGateInterface.java +++ b/common/buildcraft/transport/gui/GuiGateInterface.java @@ -8,11 +8,11 @@ */ package buildcraft.transport.gui; +import java.util.ArrayList; import java.util.Iterator; import org.lwjgl.opengl.GL11; -import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; @@ -22,14 +22,16 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import buildcraft.api.gates.IAction; +import buildcraft.api.gates.IStatement; +import buildcraft.api.gates.IStatementParameter; import buildcraft.api.gates.ITrigger; import buildcraft.api.gates.ITriggerParameter; import buildcraft.core.gui.AdvancedSlot; import buildcraft.core.gui.GuiAdvancedInterface; -import buildcraft.core.triggers.BCAction; import buildcraft.core.utils.StringUtils; import buildcraft.transport.ActionState; import buildcraft.transport.Pipe; +import buildcraft.transport.gates.GateDefinition.GateMaterial; public class GuiGateInterface extends GuiAdvancedInterface { @@ -38,12 +40,13 @@ public class GuiGateInterface extends GuiAdvancedInterface { private final Pipe pipe; private int numSlots; - class TriggerSlot extends AdvancedSlot { + private abstract class StatementSlot extends AdvancedSlot { - Pipe pipe; - int slot; + public Pipe pipe; + public int slot; + public ArrayList parameters = new ArrayList(); - public TriggerSlot(int x, int y, Pipe pipe, int slot) { + public StatementSlot(int x, int y, Pipe pipe, int slot) { super(GuiGateInterface.this, x, y); this.pipe = pipe; @@ -78,80 +81,47 @@ public class GuiGateInterface extends GuiAdvancedInterface { return pipe.gate.getTrigger(slot) != null; } - public ITrigger getTrigger() { + public abstract IStatement getStatement(); + } + + private class TriggerSlot extends StatementSlot { + public TriggerSlot(int x, int y, Pipe pipe, int slot) { + super(x, y, pipe, slot); + } + + @Override + public IStatement getStatement() { return pipe.gate.getTrigger(slot); } } - class ActionSlot extends AdvancedSlot { - - Pipe pipe; - int slot; - + private class ActionSlot extends StatementSlot { public ActionSlot(int x, int y, Pipe pipe, int slot) { - super(GuiGateInterface.this, x, y); - - this.pipe = pipe; - this.slot = slot; + super(x, y, pipe, slot); } @Override - public String getDescription() { - IAction action = pipe.gate.getAction(slot); - if (action != null) { - return action.getDescription(); - } else { - return ""; - } - } - - @SideOnly(Side.CLIENT) - @Override - public IIcon getIcon() { - IAction action = pipe.gate.getAction(slot); - - if (action != null) { - return action.getIcon(); - } else { - return null; - } - } - - @Override - public ResourceLocation getTexture() { - IAction action = pipe.gate.getAction(slot); - - if (action instanceof BCAction) { - BCAction bcAction = (BCAction) action; - - if (bcAction.getTextureMap() == 0) { - return TextureMap.locationBlocksTexture; - } - } - - return super.getTexture(); - } - - @Override - public boolean isDefined() { - return pipe.gate.getAction(slot) != null; - } - - public IAction getAction() { + public IStatement getStatement() { return pipe.gate.getAction(slot); } } - class TriggerParameterSlot extends AdvancedSlot { + private abstract class StatementParameterSlot extends AdvancedSlot { - Pipe pipe; - int slot; + public Pipe pipe; + public int slot; + public StatementSlot statementSlot; + public int indexInStatement; - public TriggerParameterSlot(int x, int y, Pipe pipe, int slot) { + public StatementParameterSlot(int x, int y, Pipe pipe, int slot, StatementSlot iStatementSlot, + int iIIndexInStatement) { super(GuiGateInterface.this, x, y); this.pipe = pipe; this.slot = slot; + this.statementSlot = iStatementSlot; + statementSlot.parameters.add(this); + indexInStatement = iIIndexInStatement; } @Override @@ -170,11 +140,41 @@ public class GuiGateInterface extends GuiAdvancedInterface { } } - public ITriggerParameter getTriggerParameter() { + public abstract IStatementParameter getParameter(); + + public boolean isAllowed() { + return indexInStatement < statementSlot.getStatement().maxParameters(); + } + + public boolean isRequired() { + return indexInStatement < statementSlot.getStatement().minParameters(); + } + } + + class TriggerParameterSlot extends StatementParameterSlot { + public TriggerParameterSlot(int x, int y, Pipe pipe, int slot, StatementSlot iStatementSlot, + int iIIndexInStatement) { + super(x, y, pipe, slot, iStatementSlot, iIIndexInStatement); + } + + @Override + public IStatementParameter getParameter() { return pipe.gate.getTriggerParameter(slot); } } + class ActionParameterSlot extends StatementParameterSlot { + public ActionParameterSlot(int x, int y, Pipe pipe, int slot, StatementSlot iStatementSlot, + int iIIndexInStatement) { + super(x, y, pipe, slot, iStatementSlot, iIIndexInStatement); + } + + @Override + public IStatementParameter getParameter() { + return pipe.gate.getActionParameter(slot); + } + } + public GuiGateInterface(IInventory playerInventory, Pipe pipe) { super(new ContainerGateInterface(playerInventory, pipe), null, null); @@ -188,19 +188,19 @@ public class GuiGateInterface extends GuiAdvancedInterface { int position = 0; numSlots = pipe.gate.material.numSlots; - if (numSlots == 1) { + if (pipe.gate.material == GateMaterial.REDSTONE) { slots = new AdvancedSlot[2]; slots[0] = new TriggerSlot(62, 26, pipe, 0); slots[1] = new ActionSlot(98, 26, pipe, 0); - } else if (numSlots == 2) { + } else if (pipe.gate.material == GateMaterial.IRON) { slots = new AdvancedSlot[4]; slots[0] = new TriggerSlot(62, 26, pipe, 0); slots[1] = new TriggerSlot(62, 44, pipe, 1); slots[2] = new ActionSlot(98, 26, pipe, 0); slots[3] = new ActionSlot(98, 44, pipe, 1); - } else if (numSlots == 4) { + } else if (pipe.gate.material == GateMaterial.GOLD) { slots = new AdvancedSlot[12]; for (int k = 0; k < 4; ++k) { @@ -214,11 +214,12 @@ public class GuiGateInterface extends GuiAdvancedInterface { } for (int k = 0; k < 4; ++k) { - slots[position] = new TriggerParameterSlot(71, 26 + 18 * k, pipe, position - 8); + slots[position] = new TriggerParameterSlot(71, 26 + 18 * k, pipe, position - 8, (TriggerSlot) slots[k], + k); position++; } - } else if (numSlots == 8) { + } else if (pipe.gate.material == GateMaterial.DIAMOND) { slots = new AdvancedSlot[24]; for (int k = 0; k < 4; ++k) { @@ -236,11 +237,38 @@ public class GuiGateInterface extends GuiAdvancedInterface { } for (int k = 0; k < 4; ++k) { - slots[position] = new TriggerParameterSlot(26, 26 + 18 * k, pipe, position - 16); + slots[position] = new TriggerParameterSlot(26, 26 + 18 * k, pipe, position - 16, + (TriggerSlot) slots[k], k); position++; - slots[position] = new TriggerParameterSlot(116, 26 + 18 * k, pipe, position - 16); + slots[position] = new TriggerParameterSlot(116, 26 + 18 * k, pipe, position - 16, + (TriggerSlot) slots[k + 4], k); position++; } + } else if (pipe.gate.material == GateMaterial.EMERALD) { + slots = new AdvancedSlot[32]; + int lastPos; + + for (int y = 0; y < 4; ++y) { + slots[position] = new TriggerSlot(8, 26 + 18 * y, pipe, y); + lastPos = position; + position++; + + for (int x = 0; x < 3; ++x) { + slots[position] = new TriggerParameterSlot(8 + 18 * (x + 1), 26 + 18 * y, pipe, y * 3 + x, + (TriggerSlot) slots[lastPos], x); + position++; + } + + slots[position] = new ActionSlot(98, 26 + 18 * y, pipe, y); + lastPos = position; + position++; + + for (int x = 0; x < 3; ++x) { + slots[position] = new ActionParameterSlot(98 + 18 * (x + 1), 26 + 18 * y, pipe, y * 3 + x, + (ActionSlot) slots[lastPos], x); + position++; + } + } } } @@ -257,7 +285,6 @@ public class GuiGateInterface extends GuiAdvancedInterface { @Override protected void drawGuiContainerBackgroundLayer(float f, int x, int y) { - container.synchronize(); ResourceLocation texture = container.getGateGuiFile(); @@ -272,25 +299,17 @@ public class GuiGateInterface extends GuiAdvancedInterface { int actionTracker = 0; actionTracker = 0; - for (int s = 0; s < slots.length; ++s) { - AdvancedSlot slot = slots[s]; - + for (AdvancedSlot slot : slots) { if (slot instanceof TriggerSlot) { - ITrigger trigger = ((TriggerSlot) slot).getTrigger(); + ITrigger trigger = (ITrigger) ((TriggerSlot) slot).getStatement(); boolean halfWidth = container.actionsState[actionTracker] == ActionState.Partial; - if (pipe.gate.material.hasParameterSlot) { + if (pipe.gate.material.numTriggerParameters > 0) { if (container.actionsState[actionTracker] != ActionState.Deactivated) { mc.renderEngine.bindTexture(texture); drawTexturedModalRect(cornerX + slot.x + 35, cornerY + slot.y + 6, 176, 18, halfWidth ? 9 : 18, 4); } - - if (trigger == null || !trigger.hasParameter()) { - mc.renderEngine.bindTexture(texture); - - drawTexturedModalRect(cornerX + slot.x + 17, cornerY + slot.y - 1, 176, 0, 18, 18); - } } else if (container.actionsState[actionTracker] != ActionState.Deactivated) { mc.renderEngine.bindTexture(texture); @@ -298,16 +317,20 @@ public class GuiGateInterface extends GuiAdvancedInterface { } actionTracker++; - } else if (slot instanceof TriggerParameterSlot) { - TriggerParameterSlot paramSlot = (TriggerParameterSlot) slot; - TriggerSlot trigger = (TriggerSlot) slots[s - numSlots * 2]; + } else if (slot instanceof StatementParameterSlot) { + StatementParameterSlot paramSlot = (StatementParameterSlot) slot; + StatementSlot trigger = paramSlot.statementSlot; - if (trigger.isDefined() && trigger.getTrigger().requiresParameter()) { - if (paramSlot.getItemStack() == null) { - mc.renderEngine.bindTexture(texture); + mc.renderEngine.bindTexture(texture); + if (trigger.isDefined()) { + if (!paramSlot.isAllowed()) { + drawTexturedModalRect(cornerX + slot.x - 1, cornerY + slot.y - 1, 176, 0, 18, 18); + } else if (paramSlot.isRequired() && paramSlot.getItemStack() == null) { drawTexturedModalRect(cornerX + slot.x - 1, cornerY + slot.y - 1, 176, 22, 18, 18); } + } else { + drawTexturedModalRect(cornerX + slot.x - 1, cornerY + slot.y - 1, 176, 0, 18, 18); } } } @@ -336,7 +359,7 @@ public class GuiGateInterface extends GuiAdvancedInterface { TriggerSlot triggerSlot = (TriggerSlot) slot; ITrigger changed = null; - if (triggerSlot.getTrigger() == null) { + if (triggerSlot.getStatement() == null) { if (k == 0) { changed = container.getFirstTrigger(); @@ -355,23 +378,23 @@ public class GuiGateInterface extends GuiAdvancedInterface { break; } - if (trigger == triggerSlot.getTrigger()) { + if (trigger == triggerSlot.getStatement()) { changed = it.next(); break; } } } - container.setTrigger(position, changed, true); + container.setTrigger(triggerSlot.slot, changed, true); - if (pipe.gate.material.hasParameterSlot) { - container.setTriggerParameter(position, null, true); + for (StatementParameterSlot p : triggerSlot.parameters) { + container.setTriggerParameter(p.slot, null, true); } } else if (slot instanceof ActionSlot) { ActionSlot actionSlot = (ActionSlot) slot; IAction changed = null; - if (actionSlot.getAction() == null) { + if (actionSlot.getStatement() == null) { if (k == 0) { changed = container.getFirstAction(); @@ -390,23 +413,25 @@ public class GuiGateInterface extends GuiAdvancedInterface { break; } - if (action == actionSlot.getAction()) { + if (action == actionSlot.getStatement()) { changed = it.next(); break; } } } - container.setAction(position - numSlots, changed, true); + container.setAction(actionSlot.slot, changed, true); } else if (slot instanceof TriggerParameterSlot) { - TriggerSlot trigger = (TriggerSlot) slots[position - numSlots * 2]; + TriggerParameterSlot paramSlot = (TriggerParameterSlot) slot; + TriggerSlot trigger = (TriggerSlot) paramSlot.statementSlot; - if (trigger.isDefined() && trigger.getTrigger().hasParameter()) { - ITriggerParameter param = trigger.getTrigger().createParameter(); + if (trigger.isDefined() && trigger.getStatement().maxParameters() != 0) { + ITriggerParameter param = (ITriggerParameter) trigger.getStatement().createParameter( + paramSlot.indexInStatement); if (param != null) { param.set(mc.thePlayer.inventory.getItemStack()); - container.setTriggerParameter(position - numSlots * 2, param, true); + container.setTriggerParameter(((TriggerParameterSlot) slot).slot, param, true); } } } diff --git a/common/buildcraft/transport/schematics/SchematicPipe.java b/common/buildcraft/transport/schematics/SchematicPipe.java index a686729d..f0ab1d6f 100644 --- a/common/buildcraft/transport/schematics/SchematicPipe.java +++ b/common/buildcraft/transport/schematics/SchematicPipe.java @@ -23,9 +23,8 @@ import buildcraft.api.blueprints.IBuilderContext; import buildcraft.api.blueprints.MappingNotFoundException; import buildcraft.api.blueprints.MappingRegistry; import buildcraft.api.blueprints.SchematicTile; -import buildcraft.api.gates.ActionManager; -import buildcraft.api.gates.IAction; -import buildcraft.api.gates.ITrigger; +import buildcraft.api.gates.IStatement; +import buildcraft.api.gates.StatementManager; import buildcraft.transport.BlockGenericPipe; import buildcraft.transport.Pipe; import buildcraft.transport.TileGenericPipe.SideProperties; @@ -63,13 +62,13 @@ public class SchematicPipe extends SchematicTile { for (int i = 0; i < 8; ++i) { if (gateNBT.hasKey("trigger[" + i + "]")) { - ITrigger t = ActionManager.triggers.get(gateNBT.getString("trigger[" + i + "]")); + IStatement t = StatementManager.statements.get(gateNBT.getString("trigger[" + i + "]")); t = t.rotateLeft (); gateNBT.setString("trigger[" + i + "]", t.getUniqueTag()); } if (gateNBT.hasKey("action[" + i + "]")) { - IAction a = ActionManager.actions.get(gateNBT.getString("action[" + i + "]")); + IStatement a = StatementManager.statements.get(gateNBT.getString("action[" + i + "]")); a = a.rotateLeft (); gateNBT.setString("action[" + i + "]", a.getUniqueTag()); } diff --git a/common/buildcraft/transport/triggers/ActionEnergyPulsar.java b/common/buildcraft/transport/triggers/ActionEnergyPulsar.java index 26755e42..4dd44fc4 100644 --- a/common/buildcraft/transport/triggers/ActionEnergyPulsar.java +++ b/common/buildcraft/transport/triggers/ActionEnergyPulsar.java @@ -10,6 +10,7 @@ package buildcraft.transport.triggers; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.util.IIcon; + import buildcraft.api.gates.IAction; import buildcraft.core.triggers.BCAction; import buildcraft.core.utils.StringUtils; @@ -41,5 +42,4 @@ public class ActionEnergyPulsar extends BCAction { public IAction rotateLeft() { return this; } - } diff --git a/common/buildcraft/transport/triggers/ActionSingleEnergyPulse.java b/common/buildcraft/transport/triggers/ActionSingleEnergyPulse.java index d43ef0b0..321239a2 100644 --- a/common/buildcraft/transport/triggers/ActionSingleEnergyPulse.java +++ b/common/buildcraft/transport/triggers/ActionSingleEnergyPulse.java @@ -10,6 +10,7 @@ package buildcraft.transport.triggers; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.util.IIcon; + import buildcraft.api.gates.IAction; import buildcraft.core.triggers.BCAction; import buildcraft.core.utils.StringUtils; diff --git a/common/buildcraft/transport/triggers/TriggerParameterSignal.java b/common/buildcraft/transport/triggers/TriggerParameterSignal.java new file mode 100755 index 00000000..0493bd08 --- /dev/null +++ b/common/buildcraft/transport/triggers/TriggerParameterSignal.java @@ -0,0 +1,75 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ +package buildcraft.transport.triggers; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +import buildcraft.api.gates.ITriggerParameter; + +public class TriggerParameterSignal implements ITriggerParameter { + + protected ItemStack stack; + + /* + * (non-Javadoc) + * + * @see net.minecraft.src.buildcraft.api.gates.ITriggerParameter#getItemStack() + */ + @Override + public ItemStack getItemStack() { + return stack; + } + + /* + * (non-Javadoc) + * + * @see net.minecraft.src.buildcraft.api.gates.ITriggerParameter#set(net.minecraft.src.ItemStack) + */ + @Override + public void set(ItemStack stack) { + if (stack != null) { + this.stack = stack.copy(); + this.stack.stackSize = 1; + } + } + + /* + * (non-Javadoc) + * + * @see net.minecraft.src.buildcraft.api.gates.ITriggerParameter#writeToNBT(net.minecraft.src.NBTTagCompound) + */ + @Override + public void writeToNBT(NBTTagCompound compound) { + if (stack != null) { + NBTTagCompound tagCompound = new NBTTagCompound(); + stack.writeToNBT(tagCompound); + compound.setTag("stack", tagCompound); + } + } + + /* + * (non-Javadoc) + * + * @see net.minecraft.src.buildcraft.api.gates.ITriggerParameter#readFromNBT(net.minecraft.src.NBTTagCompound) + */ + @Override + public void readFromNBT(NBTTagCompound compound) { + // Legacy code to prevent existing gates from losing their contents + int itemID = compound.getInteger("itemID"); + if (itemID != 0) { + stack = new ItemStack((Item) Item.itemRegistry.getObject(itemID), 1, compound.getInteger("itemDMG")); + return; + } + + stack = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("stack")); + } + +} diff --git a/common/buildcraft/transport/triggers/TriggerPipeContents.java b/common/buildcraft/transport/triggers/TriggerPipeContents.java index 6c7cd89e..f313d9b0 100644 --- a/common/buildcraft/transport/triggers/TriggerPipeContents.java +++ b/common/buildcraft/transport/triggers/TriggerPipeContents.java @@ -55,13 +55,13 @@ public class TriggerPipeContents extends BCTrigger implements IPipeTrigger { } @Override - public boolean hasParameter() { + public int maxParameters() { switch (kind) { - case containsItems: - case containsFluids: - return true; - default: - return false; + case containsItems: + case containsFluids: + return 1; + default: + return 0; } } diff --git a/common/buildcraft/transport/triggers/TriggerPipeSignal.java b/common/buildcraft/transport/triggers/TriggerPipeSignal.java index 690b8531..c427f6dd 100644 --- a/common/buildcraft/transport/triggers/TriggerPipeSignal.java +++ b/common/buildcraft/transport/triggers/TriggerPipeSignal.java @@ -33,8 +33,8 @@ public class TriggerPipeSignal extends BCTrigger implements IPipeTrigger { } @Override - public boolean hasParameter() { - return false; + public int maxParameters() { + return 3; } @Override