From 4492802f25452fe9649e05851c0a2fd8d9117bb8 Mon Sep 17 00:00:00 2001 From: asiekierka Date: Tue, 28 Oct 2014 16:36:06 +0100 Subject: [PATCH] Further work on refactoring the Gate API for #2107 --- .../api/gates/GateExpansionController.java | 12 +- api/buildcraft/api/gates/IGate.java | 19 +-- api/buildcraft/api/gates/package-info.java | 2 +- .../{gates => statements}/ActionState.java | 2 +- .../api/statements/IActionExternal.java | 10 ++ .../api/statements/IActionInternal.java | 7 ++ .../IActionProvider.java | 9 +- .../IActionReceptor.java | 4 +- .../api/{gates => statements}/IStatement.java | 2 +- .../api/statements/IStatementContainer.java | 11 ++ .../IStatementParameter.java | 3 +- .../api/statements/ITriggerExternal.java | 10 ++ .../ITriggerInternal.java} | 9 +- .../ITriggerProvider.java | 7 +- .../StatementManager.java | 40 ++++--- .../StatementParameterItemStack.java | 5 +- .../package-info.java} | 10 +- api/buildcraft/api/tiles/IHasWork.java | 5 + api/buildcraft/api/transport/IPipe.java | 6 +- api/buildcraft/api/transport/IPipeTile.java | 5 + common/buildcraft/BuildCraftBuilders.java | 2 +- common/buildcraft/BuildCraftCore.java | 65 ++++++----- common/buildcraft/BuildCraftEnergy.java | 12 +- common/buildcraft/BuildCraftSilicon.java | 34 +++--- common/buildcraft/BuildCraftTransport.java | 40 +++---- common/buildcraft/builders/TileBuilder.java | 4 +- common/buildcraft/builders/TileFiller.java | 10 +- .../builders/statements/ActionFiller.java | 15 ++- .../statements/BuildersActionProvider.java | 12 +- common/buildcraft/core/IMachine.java | 4 +- .../StatementParameterStackFilter.java | 6 +- .../core/robots/AIRobotDeliverRequested.java | 6 +- .../robots/AIRobotGotoStationToUnload.java | 8 +- .../robots/AIRobotSearchStackRequest.java | 12 +- .../buildcraft/core/robots/AIRobotSleep.java | 6 +- .../buildcraft/core/robots/AIRobotUnload.java | 8 +- .../buildcraft/core/robots/EntityRobot.java | 6 +- .../boards/BoardRobotGenericBreakBlock.java | 11 +- .../core/robots/boards/BoardRobotPump.java | 12 +- .../core/statements/ActionMachineControl.java | 13 ++- .../core/statements/ActionRedstoneOutput.java | 12 +- .../core/statements/BCActionActive.java | 24 ---- .../core/statements/BCActionPassive.java | 29 ----- .../core/statements/BCStatement.java | 11 +- .../buildcraft/core/statements/BCTrigger.java | 54 --------- .../statements/DefaultActionProvider.java | 22 ++-- .../statements/DefaultTriggerProvider.java | 19 ++- .../StatementParameterDirection.java | 10 +- ...tatementParameterRedstoneGateSideOnly.java | 6 +- .../core/statements/TriggerEnergy.java | 30 ++--- .../statements/TriggerFluidContainer.java | 14 +-- .../TriggerFluidContainerLevel.java | 14 +-- .../core/statements/TriggerInventory.java | 14 +-- .../statements/TriggerInventoryLevel.java | 14 +-- .../core/statements/TriggerMachine.java | 10 +- .../core/statements/TriggerRedstoneInput.java | 16 ++- common/buildcraft/energy/TileEngine.java | 4 - common/buildcraft/energy/TileEngineIron.java | 1 - common/buildcraft/energy/TileEngineStone.java | 3 - .../statements/EnergyStatementProvider.java | 15 +-- .../energy/statements/TriggerEngineHeat.java | 10 +- common/buildcraft/factory/TileMiningWell.java | 6 +- common/buildcraft/factory/TilePump.java | 4 +- common/buildcraft/factory/TileQuarry.java | 4 +- common/buildcraft/factory/TileRefinery.java | 4 +- common/buildcraft/silicon/TileLaser.java | 11 +- .../silicon/TileLaserTableBase.java | 10 +- .../silicon/statements/ActionRobotFilter.java | 30 +++-- .../statements/ActionRobotGotoStation.java | 20 ++-- .../silicon/statements/ActionRobotWakeUp.java | 14 ++- .../statements/ActionRobotWorkInArea.java | 20 +++- .../statements/ActionStationAcceptFluids.java | 16 ++- .../ActionStationAcceptItemsInv.java | 10 +- .../ActionStationAcceptItemsPipe.java | 10 +- .../statements/ActionStationAllowCraft.java | 16 ++- .../statements/ActionStationForbidRobot.java | 24 ++-- .../statements/ActionStationInputItems.java | 17 ++- .../ActionStationProvideFluids.java | 16 ++- .../statements/ActionStationProvideItems.java | 16 ++- .../statements/ActionStationRequestItems.java | 10 +- .../ActionStationRequestItemsMachine.java | 13 ++- .../statements/RobotsActionProvider.java | 16 +-- .../statements/RobotsTriggerProvider.java | 15 +-- .../statements/StateStationProvideItems.java | 3 +- .../statements/StateStationRequestItems.java | 3 +- .../silicon/statements/TriggerRobotSleep.java | 16 ++- common/buildcraft/transport/Gate.java | 110 +++++++++++------- common/buildcraft/transport/Pipe.java | 28 ++--- .../transport/PipeActionProvider.java | 17 +-- .../transport/PipeTransportFluids.java | 7 -- .../transport/PipeTransportItems.java | 7 +- .../transport/PipeTransportPower.java | 5 - .../transport/PipeTriggerProvider.java | 17 +-- .../transport/TileFilteredBuffer.java | 2 - .../buildcraft/transport/TileGenericPipe.java | 11 ++ .../transport/gates/ActionIterator.java | 16 +-- .../gates/GateExpansionBuildcraft.java | 1 - .../transport/gates/GateExpansionPulsar.java | 7 +- .../gates/GateExpansionRedstoneFader.java | 9 +- .../transport/gates/GateExpansionTimer.java | 9 +- .../transport/gates/GateFactory.java | 2 - .../buildcraft/transport/gates/ItemGate.java | 8 +- .../{ActionSlot.java => StatementSlot.java} | 8 +- .../transport/gui/ContainerGateInterface.java | 46 ++++---- .../transport/gui/GuiGateInterface.java | 22 ++-- .../transport/pipes/PipeFluidsIron.java | 17 +-- .../transport/pipes/PipeItemsDaizuli.java | 22 ++-- .../transport/pipes/PipeItemsEmzuli.java | 16 +-- .../transport/pipes/PipeItemsIron.java | 16 +-- .../transport/pipes/PipeItemsLapis.java | 16 +-- .../transport/pipes/PipePowerIron.java | 16 +-- .../recipes/GateExpansionRecipe.java | 1 - .../transport/render/GateItemRenderer.java | 2 - .../transport/render/PipeRendererTESR.java | 2 - .../transport/schematics/SchematicPipe.java | 4 +- .../statements/ActionEnergyPulsar.java | 14 ++- .../statements/ActionExtractionPreset.java | 14 ++- .../statements/ActionParameterSignal.java | 5 +- .../transport/statements/ActionPipeColor.java | 13 ++- .../statements/ActionPipeDirection.java | 20 +++- .../statements/ActionPowerLimiter.java | 13 ++- .../statements/ActionRedstoneFaderOutput.java | 14 ++- .../statements/ActionSignalOutput.java | 16 ++- .../statements/ActionSingleEnergyPulse.java | 13 ++- .../transport/statements/ActionValve.java | 16 ++- .../statements/TriggerClockTimer.java | 13 ++- .../statements/TriggerParameterSignal.java | 5 +- .../statements/TriggerPipeContents.java | 19 ++- .../statements/TriggerPipeSignal.java | 16 ++- .../statements/TriggerRedstoneFaderInput.java | 15 ++- 130 files changed, 969 insertions(+), 801 deletions(-) rename api/buildcraft/api/{gates => statements}/ActionState.java (90%) create mode 100644 api/buildcraft/api/statements/IActionExternal.java create mode 100644 api/buildcraft/api/statements/IActionInternal.java rename api/buildcraft/api/{gates => statements}/IActionProvider.java (67%) rename api/buildcraft/api/{gates => statements}/IActionReceptor.java (74%) rename api/buildcraft/api/{gates => statements}/IStatement.java (97%) create mode 100644 api/buildcraft/api/statements/IStatementContainer.java rename api/buildcraft/api/{gates => statements}/IStatementParameter.java (94%) create mode 100644 api/buildcraft/api/statements/ITriggerExternal.java rename api/buildcraft/api/{gates/ITrigger.java => statements/ITriggerInternal.java} (52%) rename api/buildcraft/api/{gates => statements}/ITriggerProvider.java (76%) rename api/buildcraft/api/{gates => statements}/StatementManager.java (68%) rename api/buildcraft/api/{gates => statements}/StatementParameterItemStack.java (94%) rename api/buildcraft/api/{gates/IAction.java => statements/package-info.java} (65%) mode change 100755 => 100644 create mode 100644 api/buildcraft/api/tiles/IHasWork.java delete mode 100644 common/buildcraft/core/statements/BCActionActive.java delete mode 100755 common/buildcraft/core/statements/BCActionPassive.java mode change 100755 => 100644 common/buildcraft/core/statements/BCStatement.java delete mode 100644 common/buildcraft/core/statements/BCTrigger.java rename common/buildcraft/transport/gates/{ActionSlot.java => StatementSlot.java} (70%) diff --git a/api/buildcraft/api/gates/GateExpansionController.java b/api/buildcraft/api/gates/GateExpansionController.java index dcf65bbb..50b45c3e 100644 --- a/api/buildcraft/api/gates/GateExpansionController.java +++ b/api/buildcraft/api/gates/GateExpansionController.java @@ -10,6 +10,10 @@ package buildcraft.api.gates; import java.util.List; +import buildcraft.api.statements.IActionInternal; +import buildcraft.api.statements.IStatement; +import buildcraft.api.statements.IStatementParameter; +import buildcraft.api.statements.ITriggerInternal; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; @@ -37,18 +41,18 @@ public abstract class GateExpansionController { public void startResolution() { } - public boolean resolveAction(IAction action) { + public boolean resolveAction(IStatement action) { return false; } - public boolean isTriggerActive(ITrigger trigger, IStatementParameter[] parameters) { + public boolean isTriggerActive(IStatement trigger, IStatementParameter[] parameters) { return false; } - public void addTriggers(List list) { + public void addTriggers(List list) { } - public void addActions(List list) { + public void addActions(List list) { } public void writeToNBT(NBTTagCompound nbt) { diff --git a/api/buildcraft/api/gates/IGate.java b/api/buildcraft/api/gates/IGate.java index 2c957777..c0ffb59f 100644 --- a/api/buildcraft/api/gates/IGate.java +++ b/api/buildcraft/api/gates/IGate.java @@ -1,22 +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; +import buildcraft.api.transport.IPipe; import net.minecraftforge.common.util.ForgeDirection; -import buildcraft.api.transport.IPipe; - public interface IGate { - - void setPulsing(boolean pulsing); + @Deprecated + void setPulsing(boolean pulse); + + ForgeDirection getSide(); IPipe getPipe(); - - ForgeDirection getSide(); } diff --git a/api/buildcraft/api/gates/package-info.java b/api/buildcraft/api/gates/package-info.java index dbe7a5cd..067e6edc 100644 --- a/api/buildcraft/api/gates/package-info.java +++ b/api/buildcraft/api/gates/package-info.java @@ -6,7 +6,7 @@ * License 1.0, or MMPL. Please check the contents of the license located in * http://www.mod-buildcraft.com/MMPL-1.0.txt */ -@API(apiVersion = "2.2", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|gates") +@API(apiVersion = "3.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|gates") package buildcraft.api.gates; import cpw.mods.fml.common.API; diff --git a/api/buildcraft/api/gates/ActionState.java b/api/buildcraft/api/statements/ActionState.java similarity index 90% rename from api/buildcraft/api/gates/ActionState.java rename to api/buildcraft/api/statements/ActionState.java index 5befd272..1a30beb4 100755 --- a/api/buildcraft/api/gates/ActionState.java +++ b/api/buildcraft/api/statements/ActionState.java @@ -6,7 +6,7 @@ * 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; +package buildcraft.api.statements; public class ActionState { diff --git a/api/buildcraft/api/statements/IActionExternal.java b/api/buildcraft/api/statements/IActionExternal.java new file mode 100644 index 00000000..02ec3b8d --- /dev/null +++ b/api/buildcraft/api/statements/IActionExternal.java @@ -0,0 +1,10 @@ +package buildcraft.api.statements; + +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; + +public interface IActionExternal extends IStatement { + + void actionActivate(TileEntity target, ForgeDirection side, IStatementContainer source, IStatementParameter[] parameters); + +} diff --git a/api/buildcraft/api/statements/IActionInternal.java b/api/buildcraft/api/statements/IActionInternal.java new file mode 100644 index 00000000..4174f89b --- /dev/null +++ b/api/buildcraft/api/statements/IActionInternal.java @@ -0,0 +1,7 @@ +package buildcraft.api.statements; + +public interface IActionInternal extends IStatement { + + void actionActivate(IStatementContainer source, IStatementParameter[] parameters); + +} diff --git a/api/buildcraft/api/gates/IActionProvider.java b/api/buildcraft/api/statements/IActionProvider.java similarity index 67% rename from api/buildcraft/api/gates/IActionProvider.java rename to api/buildcraft/api/statements/IActionProvider.java index 15356534..a3c25bcc 100644 --- a/api/buildcraft/api/gates/IActionProvider.java +++ b/api/buildcraft/api/statements/IActionProvider.java @@ -6,25 +6,24 @@ * 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; +package buildcraft.api.statements; import java.util.Collection; import net.minecraft.block.Block; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; -import buildcraft.api.transport.IPipeTile; public interface IActionProvider { /** - * Returns the list of actions that are available from the tile holding the + * Returns the list of actions that are available from the statement container holding the * gate. */ - Collection getInternalActions(TileEntity tile); + Collection getInternalActions(IStatementContainer container); /** * Returns the list of actions available to a gate next to the given block. */ - Collection getExternalActions(ForgeDirection side, TileEntity tile); + Collection getExternalActions(ForgeDirection side, TileEntity tile); } diff --git a/api/buildcraft/api/gates/IActionReceptor.java b/api/buildcraft/api/statements/IActionReceptor.java similarity index 74% rename from api/buildcraft/api/gates/IActionReceptor.java rename to api/buildcraft/api/statements/IActionReceptor.java index 89ace346..f4ef4968 100644 --- a/api/buildcraft/api/gates/IActionReceptor.java +++ b/api/buildcraft/api/statements/IActionReceptor.java @@ -6,8 +6,8 @@ * 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; +package buildcraft.api.statements; public interface IActionReceptor { - void actionActivated(IAction action, IStatementParameter[] parameters); + void actionActivated(IStatement statement, IStatementParameter[] parameters); } diff --git a/api/buildcraft/api/gates/IStatement.java b/api/buildcraft/api/statements/IStatement.java similarity index 97% rename from api/buildcraft/api/gates/IStatement.java rename to api/buildcraft/api/statements/IStatement.java index b632aff6..a05824d6 100644 --- a/api/buildcraft/api/gates/IStatement.java +++ b/api/buildcraft/api/statements/IStatement.java @@ -6,7 +6,7 @@ * 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; +package buildcraft.api.statements; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.util.IIcon; diff --git a/api/buildcraft/api/statements/IStatementContainer.java b/api/buildcraft/api/statements/IStatementContainer.java new file mode 100644 index 00000000..1a512694 --- /dev/null +++ b/api/buildcraft/api/statements/IStatementContainer.java @@ -0,0 +1,11 @@ +package buildcraft.api.statements; + +import net.minecraft.tileentity.TileEntity; + +/** + * This is implemented by objects containing Statements, such as + * Gates and TileEntities. + */ +public interface IStatementContainer { + TileEntity getTile(); +} diff --git a/api/buildcraft/api/gates/IStatementParameter.java b/api/buildcraft/api/statements/IStatementParameter.java similarity index 94% rename from api/buildcraft/api/gates/IStatementParameter.java rename to api/buildcraft/api/statements/IStatementParameter.java index a412b305..76175053 100755 --- a/api/buildcraft/api/gates/IStatementParameter.java +++ b/api/buildcraft/api/statements/IStatementParameter.java @@ -6,7 +6,7 @@ * 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; +package buildcraft.api.statements; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -14,7 +14,6 @@ import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.IIcon; -import buildcraft.api.transport.IPipeTile; public interface IStatementParameter { diff --git a/api/buildcraft/api/statements/ITriggerExternal.java b/api/buildcraft/api/statements/ITriggerExternal.java new file mode 100644 index 00000000..5cf0eb11 --- /dev/null +++ b/api/buildcraft/api/statements/ITriggerExternal.java @@ -0,0 +1,10 @@ +package buildcraft.api.statements; + +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; + +public interface ITriggerExternal extends IStatement { + + boolean isTriggerActive(TileEntity target, ForgeDirection side, IStatementContainer source, IStatementParameter[] parameters); + +} diff --git a/api/buildcraft/api/gates/ITrigger.java b/api/buildcraft/api/statements/ITriggerInternal.java similarity index 52% rename from api/buildcraft/api/gates/ITrigger.java rename to api/buildcraft/api/statements/ITriggerInternal.java index 3807fb08..d095fe05 100755 --- a/api/buildcraft/api/gates/ITrigger.java +++ b/api/buildcraft/api/statements/ITriggerInternal.java @@ -6,11 +6,14 @@ * 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; +package buildcraft.api.statements; + +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; -public interface ITrigger extends IStatement { +public interface ITriggerInternal extends IStatement { - boolean isTriggerActive(IGate gate, IStatementParameter[] parameters); + boolean isTriggerActive(IStatementContainer source, IStatementParameter[] parameters); } diff --git a/api/buildcraft/api/gates/ITriggerProvider.java b/api/buildcraft/api/statements/ITriggerProvider.java similarity index 76% rename from api/buildcraft/api/gates/ITriggerProvider.java rename to api/buildcraft/api/statements/ITriggerProvider.java index 80d27e54..b94b6694 100644 --- a/api/buildcraft/api/gates/ITriggerProvider.java +++ b/api/buildcraft/api/statements/ITriggerProvider.java @@ -6,25 +6,24 @@ * 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; +package buildcraft.api.statements; import java.util.Collection; import net.minecraft.block.Block; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; -import buildcraft.api.transport.IPipeTile; public interface ITriggerProvider { /** * Returns the list of triggers that are available from the object holding the gate. */ - Collection getInternalTriggers(TileEntity tile); + Collection getInternalTriggers(IStatementContainer container); /** * Returns the list of triggers available to a gate next to the given block. */ - Collection getExternalTriggers(ForgeDirection side, TileEntity tile); + Collection getExternalTriggers(ForgeDirection side, TileEntity tile); } diff --git a/api/buildcraft/api/gates/StatementManager.java b/api/buildcraft/api/statements/StatementManager.java similarity index 68% rename from api/buildcraft/api/gates/StatementManager.java rename to api/buildcraft/api/statements/StatementManager.java index 42554319..4b266e13 100644 --- a/api/buildcraft/api/gates/StatementManager.java +++ b/api/buildcraft/api/statements/StatementManager.java @@ -6,7 +6,7 @@ * 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; +package buildcraft.api.statements; import java.util.Collection; import java.util.HashMap; @@ -17,7 +17,6 @@ import java.util.Map; import net.minecraft.block.Block; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; -import buildcraft.api.transport.IPipeTile; public final class StatementManager { @@ -51,15 +50,20 @@ public final class StatementManager { public static void registerParameterClass(Class param) { parameters.put(createParameter(param).getUniqueTag(), param); } + + @Deprecated + public static void registerParameterClass(String name, Class param) { + parameters.put(name, param); + } - public static List getExternalTriggers(ForgeDirection side, TileEntity entity) { - List result = new LinkedList(); + public static List getExternalTriggers(ForgeDirection side, TileEntity entity) { + List result = new LinkedList(); for (ITriggerProvider provider : triggerProviders) { - Collection toAdd = provider.getExternalTriggers(side, entity); + Collection toAdd = provider.getExternalTriggers(side, entity); if (toAdd != null) { - for (ITrigger t : toAdd) { + for (ITriggerExternal t : toAdd) { if (!result.contains(t)) { result.add(t); } @@ -70,14 +74,14 @@ public final class StatementManager { return result; } - public static List getExternalActions(ForgeDirection side, TileEntity entity) { - List result = new LinkedList(); + public static List getExternalActions(ForgeDirection side, TileEntity entity) { + List result = new LinkedList(); for (IActionProvider provider : actionProviders) { - Collection toAdd = provider.getExternalActions(side, entity); + Collection toAdd = provider.getExternalActions(side, entity); if (toAdd != null) { - for (IAction t : toAdd) { + for (IActionExternal t : toAdd) { if (!result.contains(t)) { result.add(t); } @@ -88,14 +92,14 @@ public final class StatementManager { return result; } - public static List getInternalTriggers(TileEntity tile) { - List result = new LinkedList(); + public static List getInternalTriggers(IStatementContainer container) { + List result = new LinkedList(); for (ITriggerProvider provider : triggerProviders) { - Collection toAdd = provider.getInternalTriggers(tile); + Collection toAdd = provider.getInternalTriggers(container); if (toAdd != null) { - for (ITrigger t : toAdd) { + for (ITriggerInternal t : toAdd) { if (!result.contains(t)) { result.add(t); } @@ -106,14 +110,14 @@ public final class StatementManager { return result; } - public static List getInternalActions(TileEntity tile) { - List result = new LinkedList(); + public static List getInternalActions(IStatementContainer container) { + List result = new LinkedList(); for (IActionProvider provider : actionProviders) { - Collection toAdd = provider.getInternalActions(tile); + Collection toAdd = provider.getInternalActions(container); if (toAdd != null) { - for (IAction t : toAdd) { + for (IActionInternal t : toAdd) { if (!result.contains(t)) { result.add(t); } diff --git a/api/buildcraft/api/gates/StatementParameterItemStack.java b/api/buildcraft/api/statements/StatementParameterItemStack.java similarity index 94% rename from api/buildcraft/api/gates/StatementParameterItemStack.java rename to api/buildcraft/api/statements/StatementParameterItemStack.java index 7339fa3f..181f599d 100755 --- a/api/buildcraft/api/gates/StatementParameterItemStack.java +++ b/api/buildcraft/api/statements/StatementParameterItemStack.java @@ -6,14 +6,13 @@ * 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; +package buildcraft.api.statements; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.IIcon; import buildcraft.api.core.NetworkData; -import buildcraft.api.transport.IPipeTile; public class StatementParameterItemStack implements IStatementParameter { @NetworkData @@ -74,7 +73,7 @@ public class StatementParameterItemStack implements IStatementParameter { @Override public String getUniqueTag() { - return "buildcraft:stackAction"; + return "buildcraft:stack"; } @Override diff --git a/api/buildcraft/api/gates/IAction.java b/api/buildcraft/api/statements/package-info.java old mode 100755 new mode 100644 similarity index 65% rename from api/buildcraft/api/gates/IAction.java rename to api/buildcraft/api/statements/package-info.java index a56ca07f..94d36f68 --- a/api/buildcraft/api/gates/IAction.java +++ b/api/buildcraft/api/statements/package-info.java @@ -6,11 +6,7 @@ * 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; +@API(apiVersion = "1.0", owner = "BuildCraftAPI|core", provides = "BuildCraftAPI|statements") +package buildcraft.api.statements; +import cpw.mods.fml.common.API; - -public interface IAction extends IStatement { - - void actionActivate(IGate gate, IStatementParameter[] parameters); - -} diff --git a/api/buildcraft/api/tiles/IHasWork.java b/api/buildcraft/api/tiles/IHasWork.java new file mode 100644 index 00000000..5f887d43 --- /dev/null +++ b/api/buildcraft/api/tiles/IHasWork.java @@ -0,0 +1,5 @@ +package buildcraft.api.tiles; + +public interface IHasWork { + boolean hasWork(); +} diff --git a/api/buildcraft/api/transport/IPipe.java b/api/buildcraft/api/transport/IPipe.java index 979f536a..952dd0fe 100755 --- a/api/buildcraft/api/transport/IPipe.java +++ b/api/buildcraft/api/transport/IPipe.java @@ -8,8 +8,9 @@ */ package buildcraft.api.transport; +import buildcraft.api.gates.IGate; import net.minecraft.tileentity.TileEntity; - +import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; public interface IPipe { @@ -22,5 +23,6 @@ public interface IPipe { IPipeTile getTile(); - TileEntity getAdjacentTile(ForgeDirection dir); + IGate getGate(ForgeDirection side); + } diff --git a/api/buildcraft/api/transport/IPipeTile.java b/api/buildcraft/api/transport/IPipeTile.java index fbb1021b..5a09f3d6 100644 --- a/api/buildcraft/api/transport/IPipeTile.java +++ b/api/buildcraft/api/transport/IPipeTile.java @@ -9,6 +9,7 @@ package buildcraft.api.transport; import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; import buildcraft.api.core.EnumColor; @@ -56,4 +57,8 @@ public interface IPipeTile { * @return true if powered */ boolean isWireActive(PipeWire wire); + + TileEntity getAdjacentTile(ForgeDirection dir); + + IPipe getPipe(); } diff --git a/common/buildcraft/BuildCraftBuilders.java b/common/buildcraft/BuildCraftBuilders.java index 080bc8cc..5d17d8f8 100644 --- a/common/buildcraft/BuildCraftBuilders.java +++ b/common/buildcraft/BuildCraftBuilders.java @@ -50,7 +50,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.StatementManager; +import buildcraft.api.statements.StatementManager; import buildcraft.builders.BlockArchitect; import buildcraft.builders.BlockBlueprintLibrary; import buildcraft.builders.BlockBuildTool; diff --git a/common/buildcraft/BuildCraftCore.java b/common/buildcraft/BuildCraftCore.java index c647928a..18cc458a 100644 --- a/common/buildcraft/BuildCraftCore.java +++ b/common/buildcraft/BuildCraftCore.java @@ -63,12 +63,14 @@ import buildcraft.api.core.IIconProvider; import buildcraft.api.core.IWorldProperty; import buildcraft.api.core.JavaTools; import buildcraft.api.fuels.BuildcraftFuelRegistry; -import buildcraft.api.gates.StatementParameterItemStack; -import buildcraft.api.gates.IAction; -import buildcraft.api.gates.ITrigger; -import buildcraft.api.gates.StatementManager; -import buildcraft.api.gates.StatementParameterItemStack; import buildcraft.api.recipes.BuildcraftRecipeRegistry; +import buildcraft.api.statements.IActionExternal; +import buildcraft.api.statements.IActionInternal; +import buildcraft.api.statements.IStatement; +import buildcraft.api.statements.ITriggerExternal; +import buildcraft.api.statements.ITriggerInternal; +import buildcraft.api.statements.StatementManager; +import buildcraft.api.statements.StatementParameterItemStack; import buildcraft.core.BlockSpring; import buildcraft.core.BuildCraftConfiguration; import buildcraft.core.CommandBuildCraft; @@ -173,30 +175,30 @@ public class BuildCraftCore extends BuildCraftMod { public static int blockByEntityModel; public static int legacyPipeModel; public static int markerModel; - public static ITrigger triggerMachineActive = new TriggerMachine(true); - public static ITrigger triggerMachineInactive = new TriggerMachine(false); - public static ITrigger triggerEnergyHigh = new TriggerEnergy(true); - public static ITrigger triggerEnergyLow = new TriggerEnergy(false); - public static ITrigger triggerEmptyInventory = new TriggerInventory(TriggerInventory.State.Empty); - public static ITrigger triggerContainsInventory = new TriggerInventory(TriggerInventory.State.Contains); - public static ITrigger triggerSpaceInventory = new TriggerInventory(TriggerInventory.State.Space); - public static ITrigger triggerFullInventory = new TriggerInventory(TriggerInventory.State.Full); - public static ITrigger triggerEmptyFluid = new TriggerFluidContainer(TriggerFluidContainer.State.Empty); - public static ITrigger triggerContainsFluid = new TriggerFluidContainer(TriggerFluidContainer.State.Contains); - public static ITrigger triggerSpaceFluid = new TriggerFluidContainer(TriggerFluidContainer.State.Space); - public static ITrigger triggerFullFluid = new TriggerFluidContainer(TriggerFluidContainer.State.Full); - public static ITrigger triggerRedstoneActive = new TriggerRedstoneInput(true); - public static ITrigger triggerRedstoneInactive = new TriggerRedstoneInput(false); - public static ITrigger triggerInventoryBelow25 = new TriggerInventoryLevel(TriggerInventoryLevel.TriggerType.BELOW_25); - public static ITrigger triggerInventoryBelow50 = new TriggerInventoryLevel(TriggerInventoryLevel.TriggerType.BELOW_50); - public static ITrigger triggerInventoryBelow75 = new TriggerInventoryLevel(TriggerInventoryLevel.TriggerType.BELOW_75); - public static ITrigger triggerFluidContainerBelow25 = new TriggerFluidContainerLevel(TriggerFluidContainerLevel.TriggerType.BELOW_25); - public static ITrigger triggerFluidContainerBelow50 = new TriggerFluidContainerLevel(TriggerFluidContainerLevel.TriggerType.BELOW_50); - public static ITrigger triggerFluidContainerBelow75 = new TriggerFluidContainerLevel(TriggerFluidContainerLevel.TriggerType.BELOW_75); - public static IAction actionRedstone = new ActionRedstoneOutput(); - public static IAction actionOn = new ActionMachineControl(Mode.On); - public static IAction actionOff = new ActionMachineControl(Mode.Off); - public static IAction actionLoop = new ActionMachineControl(Mode.Loop); + public static ITriggerExternal triggerMachineActive = new TriggerMachine(true); + public static ITriggerExternal triggerMachineInactive = new TriggerMachine(false); + public static IStatement triggerEnergyHigh = new TriggerEnergy(true); + public static IStatement triggerEnergyLow = new TriggerEnergy(false); + public static ITriggerExternal triggerEmptyInventory = new TriggerInventory(TriggerInventory.State.Empty); + public static ITriggerExternal triggerContainsInventory = new TriggerInventory(TriggerInventory.State.Contains); + public static ITriggerExternal triggerSpaceInventory = new TriggerInventory(TriggerInventory.State.Space); + public static ITriggerExternal triggerFullInventory = new TriggerInventory(TriggerInventory.State.Full); + public static ITriggerExternal triggerEmptyFluid = new TriggerFluidContainer(TriggerFluidContainer.State.Empty); + public static ITriggerExternal triggerContainsFluid = new TriggerFluidContainer(TriggerFluidContainer.State.Contains); + public static ITriggerExternal triggerSpaceFluid = new TriggerFluidContainer(TriggerFluidContainer.State.Space); + public static ITriggerExternal triggerFullFluid = new TriggerFluidContainer(TriggerFluidContainer.State.Full); + public static ITriggerInternal triggerRedstoneActive = new TriggerRedstoneInput(true); + public static ITriggerInternal triggerRedstoneInactive = new TriggerRedstoneInput(false); + public static ITriggerExternal triggerInventoryBelow25 = new TriggerInventoryLevel(TriggerInventoryLevel.TriggerType.BELOW_25); + public static ITriggerExternal triggerInventoryBelow50 = new TriggerInventoryLevel(TriggerInventoryLevel.TriggerType.BELOW_50); + public static ITriggerExternal triggerInventoryBelow75 = new TriggerInventoryLevel(TriggerInventoryLevel.TriggerType.BELOW_75); + public static ITriggerExternal triggerFluidContainerBelow25 = new TriggerFluidContainerLevel(TriggerFluidContainerLevel.TriggerType.BELOW_25); + public static ITriggerExternal triggerFluidContainerBelow50 = new TriggerFluidContainerLevel(TriggerFluidContainerLevel.TriggerType.BELOW_50); + public static ITriggerExternal triggerFluidContainerBelow75 = new TriggerFluidContainerLevel(TriggerFluidContainerLevel.TriggerType.BELOW_75); + public static IActionInternal actionRedstone = new ActionRedstoneOutput(); + public static IActionExternal actionOn = new ActionMachineControl(Mode.On); + public static IActionExternal actionOff = new ActionMachineControl(Mode.Off); + public static IActionExternal actionLoop = new ActionMachineControl(Mode.Loop); public static boolean loadDefaultRecipes = true; public static boolean consumeWaterSources = false; @@ -344,7 +346,10 @@ public class BuildCraftCore extends BuildCraftMod { NetworkIdRegistry.instance = new NetworkIdRegistry(); - StatementManager.registerParameterClass(StatementParameterItemStack.class); + // BuildCraft 6.1.4 and below - migration only + StatementManager.registerParameterClass("buildcraft:stackTrigger", StatementParameterItemStack.class); + StatementManager.registerParameterClass("buildcraft:stackAction", StatementParameterItemStack.class); + StatementManager.registerParameterClass(StatementParameterItemStack.class); StatementManager.registerParameterClass(StatementParameterDirection.class); StatementManager.registerParameterClass(StatementParameterRedstoneGateSideOnly.class); diff --git a/common/buildcraft/BuildCraftEnergy.java b/common/buildcraft/BuildCraftEnergy.java index ed81c165..d483517b 100644 --- a/common/buildcraft/BuildCraftEnergy.java +++ b/common/buildcraft/BuildCraftEnergy.java @@ -46,9 +46,9 @@ import buildcraft.api.core.BlockIndex; import buildcraft.api.core.JavaTools; import buildcraft.api.core.StackKey; import buildcraft.api.fuels.BuildcraftFuelRegistry; -import buildcraft.api.gates.ITrigger; -import buildcraft.api.gates.StatementManager; import buildcraft.api.recipes.BuildcraftRecipeRegistry; +import buildcraft.api.statements.ITriggerExternal; +import buildcraft.api.statements.StatementManager; import buildcraft.core.BlockSpring; import buildcraft.core.DefaultProps; import buildcraft.core.InterModComms; @@ -109,10 +109,10 @@ public class BuildCraftEnergy extends BuildCraftMod { public static Set excessiveOilBiomeIDs = new HashSet(); public static Set excludeOilBiomeIDs = new HashSet(); public static TreeMap saturationStored = new TreeMap(); - public static ITrigger triggerBlueEngineHeat = new TriggerEngineHeat(EnergyStage.BLUE); - public static ITrigger triggerGreenEngineHeat = new TriggerEngineHeat(EnergyStage.GREEN); - public static ITrigger triggerYellowEngineHeat = new TriggerEngineHeat(EnergyStage.YELLOW); - public static ITrigger triggerRedEngineHeat = new TriggerEngineHeat(EnergyStage.RED); + public static ITriggerExternal triggerBlueEngineHeat = new TriggerEngineHeat(EnergyStage.BLUE); + public static ITriggerExternal triggerGreenEngineHeat = new TriggerEngineHeat(EnergyStage.GREEN); + public static ITriggerExternal triggerYellowEngineHeat = new TriggerEngineHeat(EnergyStage.YELLOW); + public static ITriggerExternal triggerRedEngineHeat = new TriggerEngineHeat(EnergyStage.RED); private static Fluid buildcraftFluidOil; private static Fluid buildcraftFluidFuel; diff --git a/common/buildcraft/BuildCraftSilicon.java b/common/buildcraft/BuildCraftSilicon.java index 91cb6be2..80938c74 100644 --- a/common/buildcraft/BuildCraftSilicon.java +++ b/common/buildcraft/BuildCraftSilicon.java @@ -22,10 +22,10 @@ import cpw.mods.fml.common.registry.GameRegistry; import net.minecraftforge.oredict.OreDictionary; import buildcraft.api.blueprints.BuilderAPI; import buildcraft.api.boards.RedstoneBoardRegistry; -import buildcraft.api.gates.IAction; -import buildcraft.api.gates.ITrigger; -import buildcraft.api.gates.StatementManager; import buildcraft.api.recipes.BuildcraftRecipeRegistry; +import buildcraft.api.statements.IActionInternal; +import buildcraft.api.statements.ITriggerInternal; +import buildcraft.api.statements.StatementManager; import buildcraft.builders.schematics.SchematicRotateMeta; import buildcraft.commander.BlockRequester; import buildcraft.commander.BlockZonePlan; @@ -103,21 +103,21 @@ public class BuildCraftSilicon extends BuildCraftMod { public static Item redstoneCrystal; public static Item robotItem; - public static ITrigger triggerRobotSleep = new TriggerRobotSleep(); + public static ITriggerInternal triggerRobotSleep = new TriggerRobotSleep(); - public static IAction actionRobotGotoStation = new ActionRobotGotoStation(); - public static IAction actionRobotWakeUp = new ActionRobotWakeUp(); - public static IAction actionRobotWorkInArea = new ActionRobotWorkInArea(); - public static IAction actionRobotFilter = new ActionRobotFilter(); - public static IAction actionRobotAllowCraft = new ActionStationAllowCraft(); - public static IAction actionStationRequestItems = new ActionStationRequestItems(); - public static IAction actionStationAcceptItems = new ActionStationAcceptItemsInv(); - public static IAction actionStationProvideItems = new ActionStationProvideItems(); - public static IAction actionStationAcceptFluids = new ActionStationAcceptFluids(); - public static IAction actionStationProvideFluids = new ActionStationProvideFluids(); - public static IAction actionStationForbidRobot = new ActionStationForbidRobot(); - public static IAction actionStationDropInPipe = new ActionStationAcceptItemsPipe(); - public static IAction actionStationMachineRequestItems = new ActionStationRequestItemsMachine(); + public static IActionInternal actionRobotGotoStation = new ActionRobotGotoStation(); + public static IActionInternal actionRobotWakeUp = new ActionRobotWakeUp(); + public static IActionInternal actionRobotWorkInArea = new ActionRobotWorkInArea(); + public static IActionInternal actionRobotFilter = new ActionRobotFilter(); + public static IActionInternal actionRobotAllowCraft = new ActionStationAllowCraft(); + public static IActionInternal actionStationRequestItems = new ActionStationRequestItems(); + public static IActionInternal actionStationAcceptItems = new ActionStationAcceptItemsInv(); + public static IActionInternal actionStationProvideItems = new ActionStationProvideItems(); + public static IActionInternal actionStationAcceptFluids = new ActionStationAcceptFluids(); + public static IActionInternal actionStationProvideFluids = new ActionStationProvideFluids(); + public static IActionInternal actionStationForbidRobot = new ActionStationForbidRobot(); + public static IActionInternal actionStationDropInPipe = new ActionStationAcceptItemsPipe(); + public static IActionInternal actionStationMachineRequestItems = new ActionStationRequestItemsMachine(); @Mod.EventHandler public void preInit(FMLPreInitializationEvent evt) { diff --git a/common/buildcraft/BuildCraftTransport.java b/common/buildcraft/BuildCraftTransport.java index 9c518cb2..48bb86f2 100644 --- a/common/buildcraft/BuildCraftTransport.java +++ b/common/buildcraft/BuildCraftTransport.java @@ -38,10 +38,10 @@ import buildcraft.api.core.EnumColor; import buildcraft.api.core.IIconProvider; import buildcraft.api.core.JavaTools; import buildcraft.api.gates.GateExpansions; -import buildcraft.api.gates.IAction; -import buildcraft.api.gates.ITrigger; -import buildcraft.api.gates.StatementManager; import buildcraft.api.recipes.BuildcraftRecipeRegistry; +import buildcraft.api.statements.IActionInternal; +import buildcraft.api.statements.ITriggerInternal; +import buildcraft.api.statements.StatementManager; import buildcraft.api.transport.IExtractionHandler; import buildcraft.api.transport.PipeManager; import buildcraft.api.transport.PipeWire; @@ -199,23 +199,23 @@ public class BuildCraftTransport extends BuildCraftMod { public static int groupItemsTrigger; public static String[] facadeBlacklist; - public static ITrigger[] triggerPipe = new ITrigger[PipeContents.values().length]; - public static ITrigger[] triggerPipeWireActive = new ITrigger[PipeWire.values().length]; - public static ITrigger[] triggerPipeWireInactive = new ITrigger[PipeWire.values().length]; - public static ITrigger[] triggerTimer = new ITrigger[TriggerClockTimer.Time.VALUES.length]; - public static ITrigger[] triggerRedstoneLevel = new ITrigger[15]; - public static IAction[] actionPipeWire = new ActionSignalOutput[PipeWire.values().length]; - public static IAction actionEnergyPulser = new ActionEnergyPulsar(); - public static IAction actionSingleEnergyPulse = new ActionSingleEnergyPulse(); - public static IAction[] actionPipeColor = new IAction[16]; - public static IAction[] actionPipeDirection = new IAction[16]; - public static IAction[] actionPowerLimiter = new IAction[7]; - public static IAction[] actionRedstoneLevel = new IAction[15]; - public static IAction actionExtractionPresetRed = new ActionExtractionPreset(EnumColor.RED); - public static IAction actionExtractionPresetBlue = new ActionExtractionPreset(EnumColor.BLUE); - public static IAction actionExtractionPresetGreen = new ActionExtractionPreset(EnumColor.GREEN); - public static IAction actionExtractionPresetYellow = new ActionExtractionPreset(EnumColor.YELLOW); - public static IAction[] actionValve = new IAction[4]; + public static ITriggerInternal[] triggerPipe = new ITriggerInternal[PipeContents.values().length]; + public static ITriggerInternal[] triggerPipeWireActive = new ITriggerInternal[PipeWire.values().length]; + public static ITriggerInternal[] triggerPipeWireInactive = new ITriggerInternal[PipeWire.values().length]; + public static ITriggerInternal[] triggerTimer = new ITriggerInternal[TriggerClockTimer.Time.VALUES.length]; + public static ITriggerInternal[] triggerRedstoneLevel = new ITriggerInternal[15]; + public static IActionInternal[] actionPipeWire = new ActionSignalOutput[PipeWire.values().length]; + public static IActionInternal actionEnergyPulser = new ActionEnergyPulsar(); + public static IActionInternal actionSingleEnergyPulse = new ActionSingleEnergyPulse(); + public static IActionInternal[] actionPipeColor = new IActionInternal[16]; + public static IActionInternal[] actionPipeDirection = new IActionInternal[16]; + public static IActionInternal[] actionPowerLimiter = new IActionInternal[7]; + public static IActionInternal[] actionRedstoneLevel = new IActionInternal[15]; + public static IActionInternal actionExtractionPresetRed = new ActionExtractionPreset(EnumColor.RED); + public static IActionInternal actionExtractionPresetBlue = new ActionExtractionPreset(EnumColor.BLUE); + public static IActionInternal actionExtractionPresetGreen = new ActionExtractionPreset(EnumColor.GREEN); + public static IActionInternal actionExtractionPresetYellow = new ActionExtractionPreset(EnumColor.YELLOW); + public static IActionInternal[] actionValve = new IActionInternal[4]; private static LinkedList pipeRecipes = new LinkedList(); diff --git a/common/buildcraft/builders/TileBuilder.java b/common/buildcraft/builders/TileBuilder.java index 5820569e..a64f5d65 100644 --- a/common/buildcraft/builders/TileBuilder.java +++ b/common/buildcraft/builders/TileBuilder.java @@ -32,10 +32,10 @@ import buildcraft.api.core.BlockIndex; import buildcraft.api.core.IInvSlot; import buildcraft.api.core.NetworkData; import buildcraft.api.core.Position; -import buildcraft.api.gates.IAction; import buildcraft.api.robots.EntityRobotBase; import buildcraft.api.robots.IRequestProvider; import buildcraft.api.robots.StackRequest; +import buildcraft.api.statements.IStatement; import buildcraft.core.Box; import buildcraft.core.Box.Kind; import buildcraft.core.IMachine; @@ -658,7 +658,7 @@ public class TileBuilder extends TileAbstractBuilder implements IMachine, IFluid } @Override - public boolean allowAction(IAction action) { + public boolean allowAction(IStatement action) { return false; } diff --git a/common/buildcraft/builders/TileFiller.java b/common/buildcraft/builders/TileFiller.java index b5db3209..da2cf9f1 100644 --- a/common/buildcraft/builders/TileFiller.java +++ b/common/buildcraft/builders/TileFiller.java @@ -18,9 +18,9 @@ import net.minecraft.util.AxisAlignedBB; import buildcraft.BuildCraftCore; import buildcraft.api.core.IAreaProvider; import buildcraft.api.filler.FillerManager; -import buildcraft.api.gates.IAction; -import buildcraft.api.gates.IStatementParameter; -import buildcraft.api.gates.IActionReceptor; +import buildcraft.api.statements.IActionReceptor; +import buildcraft.api.statements.IStatement; +import buildcraft.api.statements.IStatementParameter; import buildcraft.builders.statements.ActionFiller; import buildcraft.core.Box; import buildcraft.core.Box.Kind; @@ -314,7 +314,7 @@ public class TileFiller extends TileAbstractBuilder implements IMachine, IAction } @Override - public void actionActivated(IAction action, IStatementParameter[] parameters) { + public void actionActivated(IStatement action, IStatementParameter[] parameters) { if (action == BuildCraftCore.actionOn) { lastMode = ActionMachineControl.Mode.On; } else if (action == BuildCraftCore.actionOff) { @@ -328,7 +328,7 @@ public class TileFiller extends TileAbstractBuilder implements IMachine, IAction } @Override - public boolean allowAction(IAction action) { + public boolean allowAction(IStatement action) { return true; } diff --git a/common/buildcraft/builders/statements/ActionFiller.java b/common/buildcraft/builders/statements/ActionFiller.java index 44a230c2..fbbb166b 100644 --- a/common/buildcraft/builders/statements/ActionFiller.java +++ b/common/buildcraft/builders/statements/ActionFiller.java @@ -8,11 +8,16 @@ */ package buildcraft.builders.statements; +import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; +import net.minecraftforge.common.util.ForgeDirection; +import buildcraft.api.statements.IActionExternal; +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; import buildcraft.core.builders.patterns.FillerPattern; -import buildcraft.core.statements.BCActionPassive; +import buildcraft.core.statements.BCStatement; -public class ActionFiller extends BCActionPassive { +public class ActionFiller extends BCStatement implements IActionExternal { public final FillerPattern pattern; @@ -30,4 +35,10 @@ public class ActionFiller extends BCActionPassive { public IIcon getIcon() { return pattern.getIcon(); } + + @Override + public void actionActivate(TileEntity target, ForgeDirection side, + IStatementContainer source, IStatementParameter[] parameters) { + + } } diff --git a/common/buildcraft/builders/statements/BuildersActionProvider.java b/common/buildcraft/builders/statements/BuildersActionProvider.java index f37916cc..057d9fed 100644 --- a/common/buildcraft/builders/statements/BuildersActionProvider.java +++ b/common/buildcraft/builders/statements/BuildersActionProvider.java @@ -17,8 +17,10 @@ import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; import buildcraft.api.filler.FillerManager; import buildcraft.api.filler.IFillerPattern; -import buildcraft.api.gates.IAction; -import buildcraft.api.gates.IActionProvider; +import buildcraft.api.statements.IActionExternal; +import buildcraft.api.statements.IActionInternal; +import buildcraft.api.statements.IActionProvider; +import buildcraft.api.statements.IStatementContainer; import buildcraft.api.transport.IPipeTile; import buildcraft.builders.TileFiller; import buildcraft.core.builders.patterns.FillerPattern; @@ -27,13 +29,13 @@ public class BuildersActionProvider implements IActionProvider { private final HashMap actionMap = new HashMap(); @Override - public Collection getInternalActions(TileEntity tile) { + public Collection getInternalActions(IStatementContainer container) { return null; } @Override - public Collection getExternalActions(ForgeDirection side, TileEntity tile) { - LinkedList actions = new LinkedList(); + public Collection getExternalActions(ForgeDirection side, TileEntity tile) { + LinkedList actions = new LinkedList(); if (tile instanceof TileFiller) { for (IFillerPattern p : FillerManager.registry.getPatterns()) { if (p instanceof FillerPattern) { diff --git a/common/buildcraft/core/IMachine.java b/common/buildcraft/core/IMachine.java index 1a5276ca..00561393 100644 --- a/common/buildcraft/core/IMachine.java +++ b/common/buildcraft/core/IMachine.java @@ -8,7 +8,7 @@ */ package buildcraft.core; -import buildcraft.api.gates.IAction; +import buildcraft.api.statements.IStatement; public interface IMachine { @@ -18,5 +18,5 @@ public interface IMachine { boolean manageSolids(); - boolean allowAction(IAction action); + boolean allowAction(IStatement action); } diff --git a/common/buildcraft/core/inventory/filters/StatementParameterStackFilter.java b/common/buildcraft/core/inventory/filters/StatementParameterStackFilter.java index 25a8b7ff..45f29b0a 100755 --- a/common/buildcraft/core/inventory/filters/StatementParameterStackFilter.java +++ b/common/buildcraft/core/inventory/filters/StatementParameterStackFilter.java @@ -11,10 +11,8 @@ package buildcraft.core.inventory.filters; import java.util.ArrayList; import net.minecraft.item.ItemStack; - -import buildcraft.api.gates.StatementParameterItemStack; -import buildcraft.api.gates.IStatementParameter; -import buildcraft.api.gates.StatementParameterItemStack; +import buildcraft.api.statements.IStatementParameter; +import buildcraft.api.statements.StatementParameterItemStack; /** * Returns true if the stack matches any one one of the filter stacks. diff --git a/common/buildcraft/core/robots/AIRobotDeliverRequested.java b/common/buildcraft/core/robots/AIRobotDeliverRequested.java index c96247a3..cb5ede97 100755 --- a/common/buildcraft/core/robots/AIRobotDeliverRequested.java +++ b/common/buildcraft/core/robots/AIRobotDeliverRequested.java @@ -21,7 +21,7 @@ import buildcraft.core.inventory.filters.ArrayStackOrListFilter; import buildcraft.silicon.statements.ActionStationRequestItemsMachine; import buildcraft.transport.Pipe; import buildcraft.transport.gates.ActionIterator; -import buildcraft.transport.gates.ActionSlot; +import buildcraft.transport.gates.StatementSlot; public class AIRobotDeliverRequested extends AIRobot { @@ -97,8 +97,8 @@ public class AIRobotDeliverRequested extends AIRobot { return false; } - for (ActionSlot s : new ActionIterator(pipe)) { - if (s.action instanceof ActionStationRequestItemsMachine) { + for (StatementSlot s : new ActionIterator(pipe)) { + if (s.statement instanceof ActionStationRequestItemsMachine) { actionFound = true; } } diff --git a/common/buildcraft/core/robots/AIRobotGotoStationToUnload.java b/common/buildcraft/core/robots/AIRobotGotoStationToUnload.java index f8643651..a2b091a4 100755 --- a/common/buildcraft/core/robots/AIRobotGotoStationToUnload.java +++ b/common/buildcraft/core/robots/AIRobotGotoStationToUnload.java @@ -18,7 +18,7 @@ import buildcraft.core.inventory.InventoryIterator; import buildcraft.silicon.statements.ActionStationInputItems; import buildcraft.transport.Pipe; import buildcraft.transport.gates.ActionIterator; -import buildcraft.transport.gates.ActionSlot; +import buildcraft.transport.gates.StatementSlot; public class AIRobotGotoStationToUnload extends AIRobot { @@ -65,9 +65,9 @@ public class AIRobotGotoStationToUnload extends AIRobot { continue; } - for (ActionSlot s : new ActionIterator(pipe)) { - if (s.action instanceof ActionStationInputItems) { - if (((ActionStationInputItems) s.action).insert(station, (EntityRobot) robot, s, robotSlot, false)) { + for (StatementSlot s : new ActionIterator(pipe)) { + if (s.statement instanceof ActionStationInputItems) { + if (((ActionStationInputItems) s.statement).insert(station, (EntityRobot) robot, s, robotSlot, false)) { return true; } } diff --git a/common/buildcraft/core/robots/AIRobotSearchStackRequest.java b/common/buildcraft/core/robots/AIRobotSearchStackRequest.java index 98af130c..06322414 100755 --- a/common/buildcraft/core/robots/AIRobotSearchStackRequest.java +++ b/common/buildcraft/core/robots/AIRobotSearchStackRequest.java @@ -12,15 +12,13 @@ import java.util.Collection; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; - import net.minecraftforge.common.util.ForgeDirection; - -import buildcraft.api.gates.StatementParameterItemStack; -import buildcraft.api.gates.IStatementParameter; import buildcraft.api.robots.AIRobot; import buildcraft.api.robots.EntityRobotBase; import buildcraft.api.robots.IRequestProvider; import buildcraft.api.robots.StackRequest; +import buildcraft.api.statements.IStatementParameter; +import buildcraft.api.statements.StatementParameterItemStack; import buildcraft.core.inventory.StackHelper; import buildcraft.core.inventory.filters.IStackFilter; import buildcraft.silicon.statements.ActionRobotFilter; @@ -28,7 +26,7 @@ import buildcraft.silicon.statements.ActionStationRequestItems; import buildcraft.silicon.statements.ActionStationRequestItemsMachine; import buildcraft.transport.Pipe; import buildcraft.transport.gates.ActionIterator; -import buildcraft.transport.gates.ActionSlot; +import buildcraft.transport.gates.StatementSlot; public class AIRobotSearchStackRequest extends AIRobot { @@ -127,8 +125,8 @@ public class AIRobotSearchStackRequest extends AIRobot { Pipe pipe = station.getPipe().pipe; - for (ActionSlot s : new ActionIterator(pipe)) { - if (s.action instanceof ActionStationRequestItems) { + for (StatementSlot s : new ActionIterator(pipe)) { + if (s.statement instanceof ActionStationRequestItems) { for (IStatementParameter p : s.parameters) { StatementParameterItemStack param = (StatementParameterItemStack) p; diff --git a/common/buildcraft/core/robots/AIRobotSleep.java b/common/buildcraft/core/robots/AIRobotSleep.java index 9e5268cc..36bb477d 100755 --- a/common/buildcraft/core/robots/AIRobotSleep.java +++ b/common/buildcraft/core/robots/AIRobotSleep.java @@ -12,7 +12,7 @@ import buildcraft.api.robots.AIRobot; import buildcraft.api.robots.EntityRobotBase; import buildcraft.silicon.statements.ActionRobotWakeUp; import buildcraft.transport.gates.ActionIterator; -import buildcraft.transport.gates.ActionSlot; +import buildcraft.transport.gates.StatementSlot; public class AIRobotSleep extends AIRobot { @@ -25,8 +25,8 @@ public class AIRobotSleep extends AIRobot { @Override public void preempt(AIRobot ai) { - for (ActionSlot s : new ActionIterator(((DockingStation) robot.getLinkedStation()).getPipe().pipe)) { - if (s.action instanceof ActionRobotWakeUp) { + for (StatementSlot s : new ActionIterator(((DockingStation) robot.getLinkedStation()).getPipe().pipe)) { + if (s.statement instanceof ActionRobotWakeUp) { terminate(); } } diff --git a/common/buildcraft/core/robots/AIRobotUnload.java b/common/buildcraft/core/robots/AIRobotUnload.java index a229ad77..851aafeb 100755 --- a/common/buildcraft/core/robots/AIRobotUnload.java +++ b/common/buildcraft/core/robots/AIRobotUnload.java @@ -17,7 +17,7 @@ import buildcraft.core.inventory.InventoryIterator; import buildcraft.silicon.statements.ActionStationInputItems; import buildcraft.transport.Pipe; import buildcraft.transport.gates.ActionIterator; -import buildcraft.transport.gates.ActionSlot; +import buildcraft.transport.gates.StatementSlot; public class AIRobotUnload extends AIRobot { @@ -55,9 +55,9 @@ public class AIRobotUnload extends AIRobot { continue; } - for (ActionSlot s : new ActionIterator(pipe)) { - if (s.action instanceof ActionStationInputItems) { - if (((ActionStationInputItems) s.action) + for (StatementSlot s : new ActionIterator(pipe)) { + if (s.statement instanceof ActionStationInputItems) { + if (((ActionStationInputItems) s.statement) .insert(station, (EntityRobot) robot, s, robotSlot, true)) { delivered = true; diff --git a/common/buildcraft/core/robots/EntityRobot.java b/common/buildcraft/core/robots/EntityRobot.java index b499b454..4877ac8f 100755 --- a/common/buildcraft/core/robots/EntityRobot.java +++ b/common/buildcraft/core/robots/EntityRobot.java @@ -58,7 +58,7 @@ import buildcraft.core.network.RPCSide; import buildcraft.core.utils.NBTUtils; import buildcraft.silicon.statements.ActionRobotWorkInArea; import buildcraft.transport.gates.ActionIterator; -import buildcraft.transport.gates.ActionSlot; +import buildcraft.transport.gates.StatementSlot; public class EntityRobot extends EntityRobotBase implements IEntityAdditionalSpawnData, IInventory, IFluidHandler { @@ -837,8 +837,8 @@ public class EntityRobot extends EntityRobotBase implements @Override public IZone getZoneToWork() { if (linkedDockingStation instanceof DockingStation) { - for (ActionSlot s : new ActionIterator(((DockingStation) linkedDockingStation).getPipe().pipe)) { - if (s.action instanceof ActionRobotWorkInArea) { + for (StatementSlot s : new ActionIterator(((DockingStation) linkedDockingStation).getPipe().pipe)) { + if (s.statement instanceof ActionRobotWorkInArea) { IZone zone = ActionRobotWorkInArea.getArea(s); if (zone != null) { diff --git a/common/buildcraft/core/robots/boards/BoardRobotGenericBreakBlock.java b/common/buildcraft/core/robots/boards/BoardRobotGenericBreakBlock.java index 90296902..ba36290f 100755 --- a/common/buildcraft/core/robots/boards/BoardRobotGenericBreakBlock.java +++ b/common/buildcraft/core/robots/boards/BoardRobotGenericBreakBlock.java @@ -15,13 +15,12 @@ import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; - import buildcraft.api.boards.RedstoneBoardRobot; import buildcraft.api.core.BlockIndex; -import buildcraft.api.gates.StatementParameterItemStack; -import buildcraft.api.gates.IStatementParameter; import buildcraft.api.robots.AIRobot; import buildcraft.api.robots.EntityRobotBase; +import buildcraft.api.statements.IStatementParameter; +import buildcraft.api.statements.StatementParameterItemStack; import buildcraft.core.TickHandlerCore; import buildcraft.core.inventory.filters.IStackFilter; import buildcraft.core.robots.AIRobotBreak; @@ -34,7 +33,7 @@ import buildcraft.core.robots.IBlockFilter; import buildcraft.core.robots.ResourceIdBlock; import buildcraft.silicon.statements.ActionRobotFilter; import buildcraft.transport.gates.ActionIterator; -import buildcraft.transport.gates.ActionSlot; +import buildcraft.transport.gates.StatementSlot; public abstract class BoardRobotGenericBreakBlock extends RedstoneBoardRobot { @@ -127,8 +126,8 @@ public abstract class BoardRobotGenericBreakBlock extends RedstoneBoardRobot { DockingStation station = (DockingStation) robot.getLinkedStation(); - for (ActionSlot slot : new ActionIterator(station.getPipe().pipe)) { - if (slot.action instanceof ActionRobotFilter) { + for (StatementSlot slot : new ActionIterator(station.getPipe().pipe)) { + if (slot.statement instanceof ActionRobotFilter) { for (IStatementParameter p : slot.parameters) { if (p != null && p instanceof StatementParameterItemStack) { StatementParameterItemStack param = (StatementParameterItemStack) p; diff --git a/common/buildcraft/core/robots/boards/BoardRobotPump.java b/common/buildcraft/core/robots/boards/BoardRobotPump.java index 42c3770d..66265906 100755 --- a/common/buildcraft/core/robots/boards/BoardRobotPump.java +++ b/common/buildcraft/core/robots/boards/BoardRobotPump.java @@ -13,21 +13,19 @@ import java.util.ArrayList; import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraft.world.World; - import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; - import buildcraft.api.boards.RedstoneBoardRobot; import buildcraft.api.boards.RedstoneBoardRobotNBT; import buildcraft.api.core.BlockIndex; import buildcraft.api.core.BuildCraftAPI; -import buildcraft.api.gates.StatementParameterItemStack; -import buildcraft.api.gates.IStatementParameter; import buildcraft.api.robots.AIRobot; import buildcraft.api.robots.EntityRobotBase; +import buildcraft.api.statements.IStatementParameter; +import buildcraft.api.statements.StatementParameterItemStack; import buildcraft.core.TickHandlerCore; import buildcraft.core.robots.AIRobotGotoBlock; import buildcraft.core.robots.AIRobotGotoSleep; @@ -39,7 +37,7 @@ import buildcraft.core.robots.IBlockFilter; import buildcraft.core.robots.ResourceIdBlock; import buildcraft.silicon.statements.ActionRobotFilter; import buildcraft.transport.gates.ActionIterator; -import buildcraft.transport.gates.ActionSlot; +import buildcraft.transport.gates.StatementSlot; public class BoardRobotPump extends RedstoneBoardRobot { @@ -114,8 +112,8 @@ public class BoardRobotPump extends RedstoneBoardRobot { DockingStation station = (DockingStation) robot.getLinkedStation(); - for (ActionSlot slot : new ActionIterator(station.getPipe().pipe)) { - if (slot.action instanceof ActionRobotFilter) { + for (StatementSlot slot : new ActionIterator(station.getPipe().pipe)) { + if (slot.statement instanceof ActionRobotFilter) { for (IStatementParameter p : slot.parameters) { if (p != null && p instanceof StatementParameterItemStack) { StatementParameterItemStack param = (StatementParameterItemStack) p; diff --git a/common/buildcraft/core/statements/ActionMachineControl.java b/common/buildcraft/core/statements/ActionMachineControl.java index 57f6384e..130cea2d 100644 --- a/common/buildcraft/core/statements/ActionMachineControl.java +++ b/common/buildcraft/core/statements/ActionMachineControl.java @@ -10,9 +10,14 @@ package buildcraft.core.statements; import java.util.Locale; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; +import buildcraft.api.statements.IActionExternal; +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; import buildcraft.core.utils.StringUtils; -public class ActionMachineControl extends BCActionPassive { +public class ActionMachineControl extends BCStatement implements IActionExternal { public enum Mode { @@ -43,4 +48,10 @@ public class ActionMachineControl extends BCActionPassive { return StatementIconProvider.Action_MachineControl_Loop; } } + + @Override + public void actionActivate(TileEntity target, ForgeDirection side, + IStatementContainer source, IStatementParameter[] parameters) { + + } } diff --git a/common/buildcraft/core/statements/ActionRedstoneOutput.java b/common/buildcraft/core/statements/ActionRedstoneOutput.java index 4a7fbe93..1fccca0f 100644 --- a/common/buildcraft/core/statements/ActionRedstoneOutput.java +++ b/common/buildcraft/core/statements/ActionRedstoneOutput.java @@ -8,10 +8,12 @@ */ package buildcraft.core.statements; -import buildcraft.api.gates.IStatementParameter; +import buildcraft.api.statements.IActionInternal; +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; import buildcraft.core.utils.StringUtils; -public class ActionRedstoneOutput extends BCActionPassive { +public class ActionRedstoneOutput extends BCStatement implements IActionInternal { public ActionRedstoneOutput() { super("buildcraft:redstone.output", "buildcraft.redstone.output"); @@ -42,4 +44,10 @@ public class ActionRedstoneOutput extends BCActionPassive { public int maxParameters() { return 1; } + + @Override + public void actionActivate(IStatementContainer source, + IStatementParameter[] parameters) { + + } } diff --git a/common/buildcraft/core/statements/BCActionActive.java b/common/buildcraft/core/statements/BCActionActive.java deleted file mode 100644 index f6b1111c..00000000 --- a/common/buildcraft/core/statements/BCActionActive.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * 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.statements; - -import buildcraft.api.gates.IAction; -import buildcraft.api.gates.IStatementParameter; - -public abstract class BCActionActive extends BCStatement implements IAction { - - public BCActionActive(String... uniqueTag) { - super(uniqueTag); - } - - @Override - public IStatementParameter createParameter(int index) { - return null; - } -} diff --git a/common/buildcraft/core/statements/BCActionPassive.java b/common/buildcraft/core/statements/BCActionPassive.java deleted file mode 100755 index 7e8175e9..00000000 --- a/common/buildcraft/core/statements/BCActionPassive.java +++ /dev/null @@ -1,29 +0,0 @@ -/** - * 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.statements; - -import buildcraft.api.gates.IAction; -import buildcraft.api.gates.IGate; -import buildcraft.api.gates.IStatementParameter; - -public abstract class BCActionPassive extends BCStatement implements IAction { - - public BCActionPassive(String... uniqueTag) { - super(uniqueTag); - } - - @Override - public IStatementParameter createParameter(int index) { - return null; - } - - @Override - public final void actionActivate(IGate gate, IStatementParameter[] parameters) { - } -} diff --git a/common/buildcraft/core/statements/BCStatement.java b/common/buildcraft/core/statements/BCStatement.java old mode 100755 new mode 100644 index e786ad59..0cd95ca8 --- a/common/buildcraft/core/statements/BCStatement.java +++ b/common/buildcraft/core/statements/BCStatement.java @@ -10,12 +10,11 @@ package buildcraft.core.statements; 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.StatementManager; +import buildcraft.api.statements.IStatement; +import buildcraft.api.statements.IStatementParameter; +import buildcraft.api.statements.StatementManager; public abstract class BCStatement implements IStatement { @@ -81,4 +80,8 @@ public abstract class BCStatement implements IStatement { return this; } + @Override + public IStatementParameter createParameter(int index) { + return null; + } } diff --git a/common/buildcraft/core/statements/BCTrigger.java b/common/buildcraft/core/statements/BCTrigger.java deleted file mode 100644 index 95af3d62..00000000 --- a/common/buildcraft/core/statements/BCTrigger.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * 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.statements; - -import net.minecraft.tileentity.TileEntity; - -import net.minecraftforge.common.util.ForgeDirection; - -import buildcraft.api.gates.IGate; -import buildcraft.api.gates.ITrigger; -import buildcraft.api.gates.IStatementParameter; -import buildcraft.api.gates.StatementParameterItemStack; -import buildcraft.transport.Pipe; - -/** - * 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 extends BCStatement implements ITrigger { - - public BCTrigger(String... uniqueTag) { - super(uniqueTag); - } - - @Override - public boolean isTriggerActive(IGate gate, IStatementParameter[] parameters) { - IStatementParameter p = parameters[0]; - Pipe pipe = (Pipe) gate.getPipe(); - - for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { - if (isTriggerActive(side, pipe.getAdjacentTile(side), p)) { - return true; - } - } - - return false; - } - - public boolean isTriggerActive(ForgeDirection side, TileEntity tile, IStatementParameter parameter) { - return false; - } - - @Override - public IStatementParameter createParameter(int index) { - return new StatementParameterItemStack(); - } -} diff --git a/common/buildcraft/core/statements/DefaultActionProvider.java b/common/buildcraft/core/statements/DefaultActionProvider.java index 5a4073df..fd34b85a 100644 --- a/common/buildcraft/core/statements/DefaultActionProvider.java +++ b/common/buildcraft/core/statements/DefaultActionProvider.java @@ -18,23 +18,29 @@ import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; import cpw.mods.fml.common.FMLLog; import buildcraft.BuildCraftCore; -import buildcraft.api.gates.IAction; -import buildcraft.api.gates.IActionProvider; +import buildcraft.api.statements.IActionExternal; +import buildcraft.api.statements.IActionInternal; +import buildcraft.api.statements.IActionProvider; +import buildcraft.api.statements.IStatementContainer; import buildcraft.api.transport.IPipeTile; import buildcraft.core.IMachine; public class DefaultActionProvider implements IActionProvider { @Override - public Collection getInternalActions(TileEntity tile) { - return null; + public Collection getInternalActions(IStatementContainer container) { + LinkedList res = new LinkedList(); + + if (container.getTile() instanceof IPipeTile) { + res.add(BuildCraftCore.actionRedstone); + } + + return res; } @Override - public Collection getExternalActions(ForgeDirection side, TileEntity tile) { - LinkedList res = new LinkedList(); - - res.add(BuildCraftCore.actionRedstone); + public Collection getExternalActions(ForgeDirection side, TileEntity tile) { + LinkedList res = new LinkedList(); try { if (tile instanceof IMachine) { diff --git a/common/buildcraft/core/statements/DefaultTriggerProvider.java b/common/buildcraft/core/statements/DefaultTriggerProvider.java index f9690cc3..befc94d3 100644 --- a/common/buildcraft/core/statements/DefaultTriggerProvider.java +++ b/common/buildcraft/core/statements/DefaultTriggerProvider.java @@ -13,24 +13,23 @@ import java.util.LinkedList; import net.minecraft.block.Block; import net.minecraft.inventory.IInventory; import net.minecraft.tileentity.TileEntity; - import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; - import cofh.api.energy.IEnergyHandler; - import buildcraft.BuildCraftCore; -import buildcraft.api.gates.ITrigger; -import buildcraft.api.gates.ITriggerProvider; +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.ITriggerExternal; +import buildcraft.api.statements.ITriggerInternal; +import buildcraft.api.statements.ITriggerProvider; import buildcraft.api.transport.IPipeTile; import buildcraft.core.IMachine; public class DefaultTriggerProvider implements ITriggerProvider { @Override - public LinkedList getExternalTriggers(ForgeDirection side, TileEntity tile) { - LinkedList res = new LinkedList(); + public LinkedList getExternalTriggers(ForgeDirection side, TileEntity tile) { + LinkedList res = new LinkedList(); if (tile instanceof IInventory && ((IInventory) tile).getSizeInventory() > 0) { res.add(BuildCraftCore.triggerEmptyInventory); @@ -61,15 +60,15 @@ public class DefaultTriggerProvider implements ITriggerProvider { } if (tile instanceof IEnergyHandler && ((IEnergyHandler) tile).getMaxEnergyStored(side.getOpposite()) > 0) { - res.add(BuildCraftCore.triggerEnergyHigh); - res.add(BuildCraftCore.triggerEnergyLow); + res.add((ITriggerExternal) BuildCraftCore.triggerEnergyHigh); + res.add((ITriggerExternal) BuildCraftCore.triggerEnergyLow); } return res; } @Override - public LinkedList getInternalTriggers(TileEntity pipe) { + public LinkedList getInternalTriggers(IStatementContainer container) { return null; } } diff --git a/common/buildcraft/core/statements/StatementParameterDirection.java b/common/buildcraft/core/statements/StatementParameterDirection.java index ce32454a..91ff53b3 100644 --- a/common/buildcraft/core/statements/StatementParameterDirection.java +++ b/common/buildcraft/core/statements/StatementParameterDirection.java @@ -14,10 +14,8 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.IIcon; import net.minecraftforge.common.util.ForgeDirection; import buildcraft.api.core.NetworkData; -import buildcraft.api.gates.IStatementParameter; -import buildcraft.api.gates.IStatement; -import buildcraft.api.gates.IStatementParameter; -import buildcraft.api.gates.IStatementParameter; +import buildcraft.api.statements.IStatement; +import buildcraft.api.statements.IStatementParameter; import buildcraft.api.transport.IPipe; import buildcraft.api.transport.IPipeTile; import buildcraft.core.utils.StringUtils; @@ -107,6 +105,8 @@ public class StatementParameterDirection implements IStatementParameter { @Override public IStatementParameter rotateLeft() { - return this; + StatementParameterDirection d = new StatementParameterDirection(); + d.direction = direction.getRotation(ForgeDirection.UP); + return d; } } diff --git a/common/buildcraft/core/statements/StatementParameterRedstoneGateSideOnly.java b/common/buildcraft/core/statements/StatementParameterRedstoneGateSideOnly.java index d5d84e42..2fdcc21b 100644 --- a/common/buildcraft/core/statements/StatementParameterRedstoneGateSideOnly.java +++ b/common/buildcraft/core/statements/StatementParameterRedstoneGateSideOnly.java @@ -5,10 +5,8 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.IIcon; import buildcraft.api.core.NetworkData; -import buildcraft.api.gates.IStatementParameter; -import buildcraft.api.gates.IStatement; -import buildcraft.api.gates.IStatementParameter; -import buildcraft.api.gates.IStatementParameter; +import buildcraft.api.statements.IStatement; +import buildcraft.api.statements.IStatementParameter; import buildcraft.api.transport.IPipeTile; import buildcraft.core.utils.StringUtils; diff --git a/common/buildcraft/core/statements/TriggerEnergy.java b/common/buildcraft/core/statements/TriggerEnergy.java index 0540bca7..c5eb890a 100755 --- a/common/buildcraft/core/statements/TriggerEnergy.java +++ b/common/buildcraft/core/statements/TriggerEnergy.java @@ -11,19 +11,18 @@ package buildcraft.core.statements; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - import net.minecraftforge.common.util.ForgeDirection; - import cofh.api.energy.IEnergyHandler; - import buildcraft.api.gates.IGate; -import buildcraft.api.gates.IStatementParameter; +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; +import buildcraft.api.statements.ITriggerExternal; +import buildcraft.api.statements.ITriggerInternal; import buildcraft.core.utils.StringUtils; -public class TriggerEnergy extends BCTrigger { +public class TriggerEnergy extends BCStatement implements ITriggerInternal, ITriggerExternal { private boolean high; private IIcon iconEnergyLow; @@ -58,21 +57,22 @@ public class TriggerEnergy extends BCTrigger { return false; } @Override - public boolean isTriggerActive(IGate gate, IStatementParameter[] parameters) { - if (gate.getPipe() instanceof IEnergyHandler) { - if (isValidEnergyHandler((IEnergyHandler) gate.getPipe())) { - return isTriggeredEnergyHandler((IEnergyHandler) gate.getPipe()); + public boolean isTriggerActive(IStatementContainer container, IStatementParameter[] parameters) { + if (container instanceof IGate) { + IGate gate = (IGate) container; + if (gate.getPipe() instanceof IEnergyHandler) { + if (isValidEnergyHandler((IEnergyHandler) gate.getPipe())) { + return isTriggeredEnergyHandler((IEnergyHandler) gate.getPipe()); + } } } - - // if the pipe can't set the trigger one way or the other, then look - // around. - return super.isTriggerActive(gate, parameters); + + return false; } @Override - public boolean isTriggerActive(ForgeDirection side, TileEntity tile, IStatementParameter parameter) { + public boolean isTriggerActive(TileEntity tile, ForgeDirection side, IStatementContainer container, IStatementParameter[] parameters) { if (tile instanceof IEnergyHandler) { // Since we return false upon the trigger being invalid anyway, // we can skip the isValidEnergyHandler(...) check. diff --git a/common/buildcraft/core/statements/TriggerFluidContainer.java b/common/buildcraft/core/statements/TriggerFluidContainer.java index ba34a2f9..2d493f32 100644 --- a/common/buildcraft/core/statements/TriggerFluidContainer.java +++ b/common/buildcraft/core/statements/TriggerFluidContainer.java @@ -11,17 +11,17 @@ package buildcraft.core.statements; import java.util.Locale; import net.minecraft.tileentity.TileEntity; - import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; - -import buildcraft.api.gates.IStatementParameter; +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; +import buildcraft.api.statements.ITriggerExternal; import buildcraft.core.utils.StringUtils; -public class TriggerFluidContainer extends BCTrigger { +public class TriggerFluidContainer extends BCStatement implements ITriggerExternal { public enum State { @@ -45,14 +45,14 @@ public class TriggerFluidContainer extends BCTrigger { } @Override - public boolean isTriggerActive(ForgeDirection side, TileEntity tile, IStatementParameter parameter) { + public boolean isTriggerActive(TileEntity tile, ForgeDirection side, IStatementContainer statementContainer, IStatementParameter[] parameters) { if (tile instanceof IFluidHandler) { IFluidHandler container = (IFluidHandler) tile; FluidStack searchedFluid = null; - if (parameter != null && parameter.getItemStack() != null) { - searchedFluid = FluidContainerRegistry.getFluidForFilledItem(parameter.getItemStack()); + if (parameters != null && parameters.length >= 1 && parameters[0].getItemStack() != null) { + searchedFluid = FluidContainerRegistry.getFluidForFilledItem(parameters[0].getItemStack()); } if (searchedFluid != null) { diff --git a/common/buildcraft/core/statements/TriggerFluidContainerLevel.java b/common/buildcraft/core/statements/TriggerFluidContainerLevel.java index 1c068c8e..aff81601 100644 --- a/common/buildcraft/core/statements/TriggerFluidContainerLevel.java +++ b/common/buildcraft/core/statements/TriggerFluidContainerLevel.java @@ -11,17 +11,17 @@ package buildcraft.core.statements; import java.util.Locale; import net.minecraft.tileentity.TileEntity; - import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; - -import buildcraft.api.gates.IStatementParameter; +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; +import buildcraft.api.statements.ITriggerExternal; import buildcraft.core.utils.StringUtils; -public class TriggerFluidContainerLevel extends BCTrigger { +public class TriggerFluidContainerLevel extends BCStatement implements ITriggerExternal { public enum TriggerType { @@ -52,14 +52,14 @@ public class TriggerFluidContainerLevel extends BCTrigger { } @Override - public boolean isTriggerActive(ForgeDirection side, TileEntity tile, IStatementParameter parameter) { + public boolean isTriggerActive(TileEntity tile, ForgeDirection side, IStatementContainer statementContainer, IStatementParameter[] parameters) { if (tile instanceof IFluidHandler) { IFluidHandler container = (IFluidHandler) tile; FluidStack searchedFluid = null; - if (parameter != null && parameter.getItemStack() != null) { - searchedFluid = FluidContainerRegistry.getFluidForFilledItem(parameter.getItemStack()); + if (parameters != null && parameters.length >= 1 && parameters[0].getItemStack() != null) { + searchedFluid = FluidContainerRegistry.getFluidForFilledItem(parameters[0].getItemStack()); } if (searchedFluid != null) { diff --git a/common/buildcraft/core/statements/TriggerInventory.java b/common/buildcraft/core/statements/TriggerInventory.java index aebbfe9a..9f472619 100644 --- a/common/buildcraft/core/statements/TriggerInventory.java +++ b/common/buildcraft/core/statements/TriggerInventory.java @@ -13,17 +13,17 @@ import java.util.Locale; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; - import net.minecraftforge.common.util.ForgeDirection; - import buildcraft.api.core.IInvSlot; -import buildcraft.api.gates.IStatementParameter; +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; +import buildcraft.api.statements.ITriggerExternal; import buildcraft.core.ItemList; import buildcraft.core.inventory.InventoryIterator; import buildcraft.core.inventory.StackHelper; import buildcraft.core.utils.StringUtils; -public class TriggerInventory extends BCTrigger { +public class TriggerInventory extends BCStatement implements ITriggerExternal { public enum State { @@ -48,11 +48,11 @@ public class TriggerInventory extends BCTrigger { } @Override - public boolean isTriggerActive(ForgeDirection side, TileEntity tile, IStatementParameter parameter) { + public boolean isTriggerActive(TileEntity tile, ForgeDirection side, IStatementContainer container, IStatementParameter[] parameters) { ItemStack searchedStack = null; - if (parameter != null) { - searchedStack = parameter.getItemStack(); + if (parameters != null && parameters.length >= 1) { + searchedStack = parameters[0].getItemStack(); } if (tile instanceof IInventory) { diff --git a/common/buildcraft/core/statements/TriggerInventoryLevel.java b/common/buildcraft/core/statements/TriggerInventoryLevel.java index 3b6620bc..d33a98e7 100644 --- a/common/buildcraft/core/statements/TriggerInventoryLevel.java +++ b/common/buildcraft/core/statements/TriggerInventoryLevel.java @@ -13,16 +13,16 @@ import java.util.Locale; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; - import net.minecraftforge.common.util.ForgeDirection; - import buildcraft.api.core.IInvSlot; -import buildcraft.api.gates.IStatementParameter; +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; +import buildcraft.api.statements.ITriggerExternal; import buildcraft.core.inventory.InventoryIterator; import buildcraft.core.inventory.StackHelper; import buildcraft.core.utils.StringUtils; -public class TriggerInventoryLevel extends BCTrigger { +public class TriggerInventoryLevel extends BCStatement implements ITriggerExternal { public enum TriggerType { @@ -58,14 +58,14 @@ public class TriggerInventoryLevel extends BCTrigger { } @Override - public boolean isTriggerActive(ForgeDirection side, TileEntity tile, IStatementParameter parameter) { + public boolean isTriggerActive(TileEntity tile, ForgeDirection side, IStatementContainer container, IStatementParameter[] parameters) { // A parameter is required - if (parameter == null) { + if (parameters == null || parameters.length < 1 || parameters[0] == null) { return false; } if (tile instanceof IInventory) { - ItemStack searchStack = parameter.getItemStack(); + ItemStack searchStack = parameters[0].getItemStack(); if (searchStack == null) { return false; diff --git a/common/buildcraft/core/statements/TriggerMachine.java b/common/buildcraft/core/statements/TriggerMachine.java index 53d308c1..737aa622 100644 --- a/common/buildcraft/core/statements/TriggerMachine.java +++ b/common/buildcraft/core/statements/TriggerMachine.java @@ -9,14 +9,14 @@ package buildcraft.core.statements; import net.minecraft.tileentity.TileEntity; - import net.minecraftforge.common.util.ForgeDirection; - -import buildcraft.api.gates.IStatementParameter; +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; +import buildcraft.api.statements.ITriggerExternal; import buildcraft.core.IMachine; import buildcraft.core.utils.StringUtils; -public class TriggerMachine extends BCTrigger { +public class TriggerMachine extends BCStatement implements ITriggerExternal { boolean active; @@ -32,7 +32,7 @@ public class TriggerMachine extends BCTrigger { } @Override - public boolean isTriggerActive(ForgeDirection side, TileEntity tile, IStatementParameter parameter) { + public boolean isTriggerActive(TileEntity tile, ForgeDirection side, IStatementContainer container, IStatementParameter[] parameters) { if (tile instanceof IMachine) { IMachine machine = (IMachine) tile; diff --git a/common/buildcraft/core/statements/TriggerRedstoneInput.java b/common/buildcraft/core/statements/TriggerRedstoneInput.java index 0509d2fd..af69e078 100644 --- a/common/buildcraft/core/statements/TriggerRedstoneInput.java +++ b/common/buildcraft/core/statements/TriggerRedstoneInput.java @@ -9,11 +9,13 @@ package buildcraft.core.statements; import buildcraft.api.gates.IGate; -import buildcraft.api.gates.IStatementParameter; +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; +import buildcraft.api.statements.ITriggerInternal; import buildcraft.core.utils.StringUtils; import buildcraft.transport.TileGenericPipe; -public class TriggerRedstoneInput extends BCTrigger { +public class TriggerRedstoneInput extends BCStatement implements ITriggerInternal { boolean active; @@ -44,12 +46,16 @@ public class TriggerRedstoneInput extends BCTrigger { } @Override - public boolean isTriggerActive(IGate gate, IStatementParameter[] parameters) { - TileGenericPipe tile = (TileGenericPipe) gate.getPipe().getTile(); + public boolean isTriggerActive(IStatementContainer container, IStatementParameter[] parameters) { + if (!(container.getTile() instanceof TileGenericPipe)) { + return false; + } + + TileGenericPipe tile = (TileGenericPipe) container.getTile(); int level = tile.redstoneInput; if (parameters.length > 0 && parameters[0] instanceof StatementParameterRedstoneGateSideOnly && ((StatementParameterRedstoneGateSideOnly) parameters[0]).isOn) { - level = tile.redstoneInputSide[gate.getSide().ordinal()]; + level = tile.redstoneInputSide[((IGate) container).getSide().ordinal()]; } return active ? level > 0 : level == 0; diff --git a/common/buildcraft/energy/TileEngine.java b/common/buildcraft/energy/TileEngine.java index 346b1bf5..8a41810a 100644 --- a/common/buildcraft/energy/TileEngine.java +++ b/common/buildcraft/energy/TileEngine.java @@ -15,14 +15,10 @@ import net.minecraft.inventory.ICrafting; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; - import net.minecraftforge.common.util.ForgeDirection; - import cofh.api.energy.IEnergyHandler; - import buildcraft.BuildCraftEnergy; import buildcraft.api.core.NetworkData; -import buildcraft.api.gates.ITrigger; import buildcraft.api.power.IPowerEmitter; import buildcraft.api.power.IPowerReceptor; import buildcraft.api.power.PowerHandler; diff --git a/common/buildcraft/energy/TileEngineIron.java b/common/buildcraft/energy/TileEngineIron.java index 5b405f5c..d987c1af 100644 --- a/common/buildcraft/energy/TileEngineIron.java +++ b/common/buildcraft/energy/TileEngineIron.java @@ -29,7 +29,6 @@ import buildcraft.api.fuels.BuildcraftFuelRegistry; import buildcraft.api.fuels.ICoolant; import buildcraft.api.fuels.IFuel; import buildcraft.api.fuels.ISolidCoolant; -import buildcraft.api.gates.ITrigger; import buildcraft.core.GuiIds; import buildcraft.core.IItemPipe; import buildcraft.core.fluids.FluidUtils; diff --git a/common/buildcraft/energy/TileEngineStone.java b/common/buildcraft/energy/TileEngineStone.java index b1db56e3..ebb5892c 100644 --- a/common/buildcraft/energy/TileEngineStone.java +++ b/common/buildcraft/energy/TileEngineStone.java @@ -16,12 +16,9 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntityFurnace; import net.minecraft.util.ResourceLocation; - import net.minecraftforge.common.util.ForgeDirection; - import buildcraft.BuildCraftCore; import buildcraft.BuildCraftEnergy; -import buildcraft.api.gates.ITrigger; import buildcraft.core.GuiIds; import buildcraft.core.inventory.InvUtils; import buildcraft.core.utils.MathUtils; diff --git a/common/buildcraft/energy/statements/EnergyStatementProvider.java b/common/buildcraft/energy/statements/EnergyStatementProvider.java index 88513dcb..82b94bfd 100644 --- a/common/buildcraft/energy/statements/EnergyStatementProvider.java +++ b/common/buildcraft/energy/statements/EnergyStatementProvider.java @@ -7,23 +7,24 @@ import net.minecraft.block.Block; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; import buildcraft.BuildCraftEnergy; -import buildcraft.api.gates.IAction; -import buildcraft.api.gates.IActionProvider; -import buildcraft.api.gates.ITrigger; -import buildcraft.api.gates.ITriggerProvider; +import buildcraft.api.statements.IActionProvider; +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.ITriggerExternal; +import buildcraft.api.statements.ITriggerInternal; +import buildcraft.api.statements.ITriggerProvider; import buildcraft.api.transport.IPipeTile; import buildcraft.energy.TileEngine; public class EnergyStatementProvider implements ITriggerProvider { @Override - public Collection getInternalTriggers(TileEntity pipe) { + public Collection getInternalTriggers(IStatementContainer container) { return null; } @Override - public Collection getExternalTriggers(ForgeDirection side, TileEntity tile) { - LinkedList triggers = new LinkedList(); + public Collection getExternalTriggers(ForgeDirection side, TileEntity tile) { + LinkedList triggers = new LinkedList(); if (tile instanceof TileEngine) { triggers.add(BuildCraftEnergy.triggerBlueEngineHeat); diff --git a/common/buildcraft/energy/statements/TriggerEngineHeat.java b/common/buildcraft/energy/statements/TriggerEngineHeat.java index c652baa8..7974258d 100644 --- a/common/buildcraft/energy/statements/TriggerEngineHeat.java +++ b/common/buildcraft/energy/statements/TriggerEngineHeat.java @@ -15,13 +15,15 @@ import net.minecraft.tileentity.TileEntity; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraftforge.common.util.ForgeDirection; -import buildcraft.api.gates.IStatementParameter; -import buildcraft.core.statements.BCTrigger; +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; +import buildcraft.api.statements.ITriggerExternal; +import buildcraft.core.statements.BCStatement; import buildcraft.core.utils.StringUtils; import buildcraft.energy.TileEngine; import buildcraft.energy.TileEngine.EnergyStage; -public class TriggerEngineHeat extends BCTrigger { +public class TriggerEngineHeat extends BCStatement implements ITriggerExternal { public EnergyStage stage; @@ -37,7 +39,7 @@ public class TriggerEngineHeat extends BCTrigger { } @Override - public boolean isTriggerActive(ForgeDirection side, TileEntity tile, IStatementParameter parameter) { + public boolean isTriggerActive(TileEntity tile, ForgeDirection side, IStatementContainer container, IStatementParameter[] parameters) { if (tile instanceof TileEngine) { TileEngine engine = (TileEngine) tile; diff --git a/common/buildcraft/factory/TileMiningWell.java b/common/buildcraft/factory/TileMiningWell.java index 29ad2e60..3f58574c 100644 --- a/common/buildcraft/factory/TileMiningWell.java +++ b/common/buildcraft/factory/TileMiningWell.java @@ -14,12 +14,10 @@ import net.minecraft.entity.item.EntityItem; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraft.world.WorldServer; - import net.minecraftforge.common.util.ForgeDirection; - import buildcraft.BuildCraftCore; import buildcraft.BuildCraftFactory; -import buildcraft.api.gates.IAction; +import buildcraft.api.statements.IStatement; import buildcraft.core.IMachine; import buildcraft.core.RFBattery; import buildcraft.core.TileBuildCraft; @@ -135,7 +133,7 @@ public class TileMiningWell extends TileBuildCraft implements IMachine { } @Override - public boolean allowAction(IAction action) { + public boolean allowAction(IStatement action) { return false; } } diff --git a/common/buildcraft/factory/TilePump.java b/common/buildcraft/factory/TilePump.java index 421889b6..74bf7d1c 100644 --- a/common/buildcraft/factory/TilePump.java +++ b/common/buildcraft/factory/TilePump.java @@ -31,7 +31,7 @@ import buildcraft.BuildCraftCore; import buildcraft.BuildCraftFactory; import buildcraft.api.core.BlockIndex; import buildcraft.api.core.SafeTimeTracker; -import buildcraft.api.gates.IAction; +import buildcraft.api.statements.IStatement; import buildcraft.core.CoreConstants; import buildcraft.core.EntityBlock; import buildcraft.core.IMachine; @@ -452,7 +452,7 @@ public class TilePump extends TileBuildCraft implements IMachine, IFluidHandler } @Override - public boolean allowAction(IAction action) { + public boolean allowAction(IStatement action) { return false; } diff --git a/common/buildcraft/factory/TileQuarry.java b/common/buildcraft/factory/TileQuarry.java index 7f3def4f..74a30f85 100644 --- a/common/buildcraft/factory/TileQuarry.java +++ b/common/buildcraft/factory/TileQuarry.java @@ -36,7 +36,7 @@ import buildcraft.api.core.IAreaProvider; import buildcraft.api.core.NetworkData; import buildcraft.api.core.SafeTimeTracker; import buildcraft.api.filler.FillerManager; -import buildcraft.api.gates.IAction; +import buildcraft.api.statements.IStatement; import buildcraft.core.Box; import buildcraft.core.Box.Kind; import buildcraft.core.CoreConstants; @@ -742,7 +742,7 @@ public class TileQuarry extends TileAbstractBuilder implements IMachine, ISidedI } @Override - public boolean allowAction(IAction action) { + public boolean allowAction(IStatement action) { return false; } diff --git a/common/buildcraft/factory/TileRefinery.java b/common/buildcraft/factory/TileRefinery.java index 10882deb..412f2906 100644 --- a/common/buildcraft/factory/TileRefinery.java +++ b/common/buildcraft/factory/TileRefinery.java @@ -27,10 +27,10 @@ import net.minecraftforge.fluids.IFluidHandler; import buildcraft.BuildCraftCore; import buildcraft.api.core.NetworkData; import buildcraft.api.core.SafeTimeTracker; -import buildcraft.api.gates.IAction; import buildcraft.api.recipes.CraftingResult; import buildcraft.api.recipes.IFlexibleCrafter; import buildcraft.api.recipes.IFlexibleRecipe; +import buildcraft.api.statements.IStatement; import buildcraft.core.IMachine; import buildcraft.core.RFBattery; import buildcraft.core.TileBuildCraft; @@ -286,7 +286,7 @@ public class TileRefinery extends TileBuildCraft implements IFluidHandler, IInve } @Override - public boolean allowAction(IAction action) { + public boolean allowAction(IStatement action) { return false; } diff --git a/common/buildcraft/silicon/TileLaser.java b/common/buildcraft/silicon/TileLaser.java index df6b39a2..eea952ca 100644 --- a/common/buildcraft/silicon/TileLaser.java +++ b/common/buildcraft/silicon/TileLaser.java @@ -20,11 +20,12 @@ import buildcraft.BuildCraftCore; import buildcraft.api.core.NetworkData; import buildcraft.api.core.Position; import buildcraft.api.core.SafeTimeTracker; -import buildcraft.api.gates.IAction; -import buildcraft.api.gates.IStatementParameter; -import buildcraft.api.gates.IActionReceptor; import buildcraft.api.power.ILaserTarget; import buildcraft.api.power.ILaserTargetBlock; +import buildcraft.api.statements.IActionInternal; +import buildcraft.api.statements.IActionReceptor; +import buildcraft.api.statements.IStatement; +import buildcraft.api.statements.IStatementParameter; import buildcraft.core.Box; import buildcraft.core.EntityLaser; import buildcraft.core.IMachine; @@ -294,12 +295,12 @@ public class TileLaser extends TileBuildCraft implements IActionReceptor, IMachi } @Override - public boolean allowAction(IAction action) { + public boolean allowAction(IStatement action) { return action == BuildCraftCore.actionOn || action == BuildCraftCore.actionOff; } @Override - public void actionActivated(IAction action, IStatementParameter[] parameters) { + public void actionActivated(IStatement action, IStatementParameter[] parameters) { if (action == BuildCraftCore.actionOn) { lastMode = ActionMachineControl.Mode.On; } else if (action == BuildCraftCore.actionOff) { diff --git a/common/buildcraft/silicon/TileLaserTableBase.java b/common/buildcraft/silicon/TileLaserTableBase.java index 27bbfaab..463aaf80 100644 --- a/common/buildcraft/silicon/TileLaserTableBase.java +++ b/common/buildcraft/silicon/TileLaserTableBase.java @@ -15,10 +15,10 @@ import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import buildcraft.BuildCraftCore; -import buildcraft.api.gates.IAction; -import buildcraft.api.gates.IStatementParameter; -import buildcraft.api.gates.IActionReceptor; import buildcraft.api.power.ILaserTarget; +import buildcraft.api.statements.IActionReceptor; +import buildcraft.api.statements.IStatement; +import buildcraft.api.statements.IStatementParameter; import buildcraft.core.IMachine; import buildcraft.core.TileBuildCraft; import buildcraft.core.inventory.SimpleInventory; @@ -215,12 +215,12 @@ public abstract class TileLaserTableBase extends TileBuildCraft implements ILase } @Override - public boolean allowAction(IAction action) { + public boolean allowAction(IStatement action) { return action == BuildCraftCore.actionOn || action == BuildCraftCore.actionOff; } @Override - public void actionActivated(IAction action, IStatementParameter[] parameters) { + public void actionActivated(IStatement action, IStatementParameter[] parameters) { if (action == BuildCraftCore.actionOn) { lastMode = ActionMachineControl.Mode.On; } else if (action == BuildCraftCore.actionOff) { diff --git a/common/buildcraft/silicon/statements/ActionRobotFilter.java b/common/buildcraft/silicon/statements/ActionRobotFilter.java index 023b2644..dc92fcd8 100755 --- a/common/buildcraft/silicon/statements/ActionRobotFilter.java +++ b/common/buildcraft/silicon/statements/ActionRobotFilter.java @@ -15,9 +15,11 @@ import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidStack; -import buildcraft.api.gates.StatementParameterItemStack; -import buildcraft.api.gates.IStatementParameter; import buildcraft.api.robots.IDockingStation; +import buildcraft.api.statements.IActionInternal; +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; +import buildcraft.api.statements.StatementParameterItemStack; import buildcraft.core.inventory.filters.ArrayFluidFilter; import buildcraft.core.inventory.filters.ArrayStackOrListFilter; import buildcraft.core.inventory.filters.IFluidFilter; @@ -26,13 +28,13 @@ import buildcraft.core.inventory.filters.PassThroughFluidFilter; import buildcraft.core.inventory.filters.PassThroughStackFilter; import buildcraft.core.inventory.filters.StatementParameterStackFilter; import buildcraft.core.robots.DockingStation; -import buildcraft.core.statements.BCActionPassive; +import buildcraft.core.statements.BCStatement; import buildcraft.core.utils.StringUtils; import buildcraft.transport.Pipe; import buildcraft.transport.gates.ActionIterator; -import buildcraft.transport.gates.ActionSlot; +import buildcraft.transport.gates.StatementSlot; -public class ActionRobotFilter extends BCActionPassive { +public class ActionRobotFilter extends BCStatement implements IActionInternal { public ActionRobotFilter() { super("buildcraft:robot.work_filter"); @@ -66,8 +68,8 @@ public class ActionRobotFilter extends BCActionPassive { public static Collection getGateFilterStacks(IDockingStation station) { ArrayList result = new ArrayList(); - for (ActionSlot slot : new ActionIterator(((DockingStation) station).getPipe().pipe)) { - if (slot.action instanceof ActionRobotFilter) { + for (StatementSlot slot : new ActionIterator(((DockingStation) station).getPipe().pipe)) { + if (slot.statement instanceof ActionRobotFilter) { for (IStatementParameter p : slot.parameters) { if (p != null && p instanceof StatementParameterItemStack) { StatementParameterItemStack param = (StatementParameterItemStack) p; @@ -109,8 +111,8 @@ public class ActionRobotFilter extends BCActionPassive { Pipe pipe = station.getPipe().pipe; - for (ActionSlot s : new ActionIterator(pipe)) { - if (actionClass.isAssignableFrom(s.action.getClass())) { + for (StatementSlot s : new ActionIterator(pipe)) { + if (actionClass.isAssignableFrom(s.statement.getClass())) { StatementParameterStackFilter param = new StatementParameterStackFilter(s.parameters); if (!param.hasFilter() || param.matches(filter)) { @@ -127,8 +129,8 @@ public class ActionRobotFilter extends BCActionPassive { boolean actionFound = false; Pipe pipe = station.getPipe().pipe; - for (ActionSlot s : new ActionIterator(pipe)) { - if (actionClass.isAssignableFrom(s.action.getClass())) { + for (StatementSlot s : new ActionIterator(pipe)) { + if (actionClass.isAssignableFrom(s.statement.getClass())) { StatementParameterStackFilter param = new StatementParameterStackFilter(s.parameters); if (!param.hasFilter()) { @@ -152,4 +154,10 @@ public class ActionRobotFilter extends BCActionPassive { return actionFound; } + + @Override + public void actionActivate(IStatementContainer source, + IStatementParameter[] parameters) { + + } } diff --git a/common/buildcraft/silicon/statements/ActionRobotGotoStation.java b/common/buildcraft/silicon/statements/ActionRobotGotoStation.java index fbd68a0b..81fc54d1 100755 --- a/common/buildcraft/silicon/statements/ActionRobotGotoStation.java +++ b/common/buildcraft/silicon/statements/ActionRobotGotoStation.java @@ -10,23 +10,26 @@ package buildcraft.silicon.statements; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; import buildcraft.api.core.BlockIndex; -import buildcraft.api.gates.StatementParameterItemStack; -import buildcraft.api.gates.IStatementParameter; -import buildcraft.api.gates.IGate; import buildcraft.api.robots.AIRobot; +import buildcraft.api.statements.IActionInternal; +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; +import buildcraft.api.statements.StatementParameterItemStack; import buildcraft.core.ItemMapLocation; import buildcraft.core.robots.AIRobotGoAndLinkToDock; import buildcraft.core.robots.DockingStation; import buildcraft.core.robots.EntityRobot; import buildcraft.core.robots.RobotRegistry; -import buildcraft.core.statements.BCActionActive; +import buildcraft.core.statements.BCStatement; import buildcraft.core.utils.StringUtils; +import buildcraft.transport.Gate; import buildcraft.transport.Pipe; import buildcraft.transport.TileGenericPipe; -public class ActionRobotGotoStation extends BCActionActive { +public class ActionRobotGotoStation extends BCStatement implements IActionInternal { public ActionRobotGotoStation() { super("buildcraft:robot.goto_station"); @@ -43,13 +46,12 @@ public class ActionRobotGotoStation extends BCActionActive { } @Override - public void actionActivate(IGate gate, IStatementParameter[] parameters) { - Pipe pipe = (Pipe) gate.getPipe(); - TileGenericPipe tile = pipe.container; + public void actionActivate(IStatementContainer container, IStatementParameter[] parameters) { + Pipe pipe = ((Gate) container).pipe; RobotRegistry registry = RobotRegistry.getRegistry(pipe.getWorld()); for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) { - DockingStation station = tile.getStation(d); + DockingStation station = pipe.container.getStation(d); if (station != null && station.robotTaking() != null) { EntityRobot robot = (EntityRobot) station.robotTaking(); diff --git a/common/buildcraft/silicon/statements/ActionRobotWakeUp.java b/common/buildcraft/silicon/statements/ActionRobotWakeUp.java index f3a14789..ddd8a690 100755 --- a/common/buildcraft/silicon/statements/ActionRobotWakeUp.java +++ b/common/buildcraft/silicon/statements/ActionRobotWakeUp.java @@ -9,10 +9,13 @@ package buildcraft.silicon.statements; import net.minecraft.client.renderer.texture.IIconRegister; -import buildcraft.core.statements.BCActionPassive; +import buildcraft.api.statements.IActionInternal; +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; +import buildcraft.core.statements.BCStatement; import buildcraft.core.utils.StringUtils; -public class ActionRobotWakeUp extends BCActionPassive { +public class ActionRobotWakeUp extends BCStatement implements IActionInternal { public ActionRobotWakeUp() { super("buildcraft:robot.wakeup"); @@ -27,4 +30,11 @@ public class ActionRobotWakeUp extends BCActionPassive { public void registerIcons(IIconRegister iconRegister) { icon = iconRegister.registerIcon("buildcraft:triggers/action_robot_wakeup"); } + + @Override + public void actionActivate(IStatementContainer source, + IStatementParameter[] parameters) { + // TODO Auto-generated method stub + + } } diff --git a/common/buildcraft/silicon/statements/ActionRobotWorkInArea.java b/common/buildcraft/silicon/statements/ActionRobotWorkInArea.java index a67ee310..a3a41c29 100755 --- a/common/buildcraft/silicon/statements/ActionRobotWorkInArea.java +++ b/common/buildcraft/silicon/statements/ActionRobotWorkInArea.java @@ -11,14 +11,16 @@ package buildcraft.silicon.statements; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.item.ItemStack; import buildcraft.api.core.IZone; -import buildcraft.api.gates.StatementParameterItemStack; -import buildcraft.api.gates.IStatementParameter; +import buildcraft.api.statements.IActionInternal; +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; +import buildcraft.api.statements.StatementParameterItemStack; import buildcraft.core.ItemMapLocation; -import buildcraft.core.statements.BCActionPassive; +import buildcraft.core.statements.BCStatement; import buildcraft.core.utils.StringUtils; -import buildcraft.transport.gates.ActionSlot; +import buildcraft.transport.gates.StatementSlot; -public class ActionRobotWorkInArea extends BCActionPassive { +public class ActionRobotWorkInArea extends BCStatement implements IActionInternal { public ActionRobotWorkInArea() { super("buildcraft:robot.work_in_area"); @@ -34,7 +36,7 @@ public class ActionRobotWorkInArea extends BCActionPassive { icon = iconRegister.registerIcon("buildcraft:triggers/action_robot_in_area"); } - public static IZone getArea(ActionSlot slot) { + public static IZone getArea(StatementSlot slot) { if (slot.parameters[0] == null) { return null; } @@ -62,4 +64,10 @@ public class ActionRobotWorkInArea extends BCActionPassive { public IStatementParameter createParameter(int index) { return new StatementParameterItemStack(); } + + @Override + public void actionActivate(IStatementContainer source, + IStatementParameter[] parameters) { + + } } diff --git a/common/buildcraft/silicon/statements/ActionStationAcceptFluids.java b/common/buildcraft/silicon/statements/ActionStationAcceptFluids.java index 4a52b9be..ccfe882c 100755 --- a/common/buildcraft/silicon/statements/ActionStationAcceptFluids.java +++ b/common/buildcraft/silicon/statements/ActionStationAcceptFluids.java @@ -9,12 +9,14 @@ package buildcraft.silicon.statements; import net.minecraft.client.renderer.texture.IIconRegister; -import buildcraft.api.gates.StatementParameterItemStack; -import buildcraft.api.gates.IStatementParameter; -import buildcraft.core.statements.BCActionPassive; +import buildcraft.api.statements.IActionInternal; +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; +import buildcraft.api.statements.StatementParameterItemStack; +import buildcraft.core.statements.BCStatement; import buildcraft.core.utils.StringUtils; -public class ActionStationAcceptFluids extends BCActionPassive { +public class ActionStationAcceptFluids extends BCStatement implements IActionInternal { public ActionStationAcceptFluids() { super("buildcraft:station.accept_fluids"); @@ -39,4 +41,10 @@ public class ActionStationAcceptFluids extends BCActionPassive { public IStatementParameter createParameter(int index) { return new StatementParameterItemStack(); } + + @Override + public void actionActivate(IStatementContainer source, + IStatementParameter[] parameters) { + + } } diff --git a/common/buildcraft/silicon/statements/ActionStationAcceptItemsInv.java b/common/buildcraft/silicon/statements/ActionStationAcceptItemsInv.java index d817a4bb..9beb7a0c 100755 --- a/common/buildcraft/silicon/statements/ActionStationAcceptItemsInv.java +++ b/common/buildcraft/silicon/statements/ActionStationAcceptItemsInv.java @@ -12,18 +12,16 @@ import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; - import net.minecraftforge.common.util.ForgeDirection; - import buildcraft.api.core.IInvSlot; -import buildcraft.api.gates.StatementParameterItemStack; -import buildcraft.api.gates.IStatementParameter; +import buildcraft.api.statements.IStatementParameter; +import buildcraft.api.statements.StatementParameterItemStack; import buildcraft.core.inventory.ITransactor; import buildcraft.core.inventory.Transactor; import buildcraft.core.robots.DockingStation; import buildcraft.core.robots.EntityRobot; import buildcraft.core.utils.StringUtils; -import buildcraft.transport.gates.ActionSlot; +import buildcraft.transport.gates.StatementSlot; public class ActionStationAcceptItemsInv extends ActionStationInputItems { @@ -52,7 +50,7 @@ public class ActionStationAcceptItemsInv extends ActionStationInputItems { } @Override - public boolean insert(DockingStation station, EntityRobot robot, ActionSlot actionSlot, IInvSlot invSlot, + public boolean insert(DockingStation station, EntityRobot robot, StatementSlot actionSlot, IInvSlot invSlot, boolean doInsert) { if (!super.insert(station, robot, actionSlot, invSlot, doInsert)) { return false; diff --git a/common/buildcraft/silicon/statements/ActionStationAcceptItemsPipe.java b/common/buildcraft/silicon/statements/ActionStationAcceptItemsPipe.java index b63bf1b3..9227ff35 100755 --- a/common/buildcraft/silicon/statements/ActionStationAcceptItemsPipe.java +++ b/common/buildcraft/silicon/statements/ActionStationAcceptItemsPipe.java @@ -9,16 +9,16 @@ package buildcraft.silicon.statements; import net.minecraft.client.renderer.texture.IIconRegister; - import buildcraft.api.core.IInvSlot; -import buildcraft.api.gates.StatementParameterItemStack; -import buildcraft.api.gates.IStatementParameter; +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; +import buildcraft.api.statements.StatementParameterItemStack; import buildcraft.core.robots.DockingStation; import buildcraft.core.robots.EntityRobot; import buildcraft.core.utils.StringUtils; import buildcraft.transport.PipeTransportItems; import buildcraft.transport.TravelingItem; -import buildcraft.transport.gates.ActionSlot; +import buildcraft.transport.gates.StatementSlot; public class ActionStationAcceptItemsPipe extends ActionStationInputItems { @@ -47,7 +47,7 @@ public class ActionStationAcceptItemsPipe extends ActionStationInputItems { } @Override - public boolean insert(DockingStation station, EntityRobot robot, ActionSlot actionSlot, IInvSlot invSlot, + public boolean insert(DockingStation station, EntityRobot robot, StatementSlot actionSlot, IInvSlot invSlot, boolean doInsert) { if (!super.insert(station, robot, actionSlot, invSlot, doInsert)) { return false; diff --git a/common/buildcraft/silicon/statements/ActionStationAllowCraft.java b/common/buildcraft/silicon/statements/ActionStationAllowCraft.java index d1fca77e..a94d5f45 100755 --- a/common/buildcraft/silicon/statements/ActionStationAllowCraft.java +++ b/common/buildcraft/silicon/statements/ActionStationAllowCraft.java @@ -9,12 +9,14 @@ package buildcraft.silicon.statements; import net.minecraft.client.renderer.texture.IIconRegister; -import buildcraft.api.gates.StatementParameterItemStack; -import buildcraft.api.gates.IStatementParameter; -import buildcraft.core.statements.BCActionPassive; +import buildcraft.api.statements.IActionInternal; +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; +import buildcraft.api.statements.StatementParameterItemStack; +import buildcraft.core.statements.BCStatement; import buildcraft.core.utils.StringUtils; -public class ActionStationAllowCraft extends BCActionPassive { +public class ActionStationAllowCraft extends BCStatement implements IActionInternal { public ActionStationAllowCraft() { super("buildcraft:robot.allow_craft"); @@ -39,4 +41,10 @@ public class ActionStationAllowCraft extends BCActionPassive { public IStatementParameter createParameter(int index) { return new StatementParameterItemStack(); } + + @Override + public void actionActivate(IStatementContainer source, + IStatementParameter[] parameters) { + + } } diff --git a/common/buildcraft/silicon/statements/ActionStationForbidRobot.java b/common/buildcraft/silicon/statements/ActionStationForbidRobot.java index a002b4b7..55d156d9 100755 --- a/common/buildcraft/silicon/statements/ActionStationForbidRobot.java +++ b/common/buildcraft/silicon/statements/ActionStationForbidRobot.java @@ -10,17 +10,19 @@ package buildcraft.silicon.statements; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.item.ItemStack; -import buildcraft.api.gates.StatementParameterItemStack; -import buildcraft.api.gates.IStatementParameter; import buildcraft.api.robots.EntityRobotBase; +import buildcraft.api.statements.IActionInternal; +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; +import buildcraft.api.statements.StatementParameterItemStack; import buildcraft.core.ItemRobot; import buildcraft.core.robots.DockingStation; -import buildcraft.core.statements.BCActionPassive; +import buildcraft.core.statements.BCStatement; import buildcraft.core.utils.StringUtils; import buildcraft.transport.gates.ActionIterator; -import buildcraft.transport.gates.ActionSlot; +import buildcraft.transport.gates.StatementSlot; -public class ActionStationForbidRobot extends BCActionPassive { +public class ActionStationForbidRobot extends BCStatement implements IActionInternal { public ActionStationForbidRobot() { super("buildcraft:station.forbid_robot"); @@ -52,8 +54,8 @@ public class ActionStationForbidRobot extends BCActionPassive { } public static boolean isForbidden(DockingStation station, EntityRobotBase robot) { - for (ActionSlot s : new ActionIterator(station.getPipe().pipe)) { - if (s.action instanceof ActionStationForbidRobot) { + for (StatementSlot s : new ActionIterator(station.getPipe().pipe)) { + if (s.statement instanceof ActionStationForbidRobot) { if (ActionStationForbidRobot.isForbidden(s, robot)) { return true; } @@ -63,7 +65,7 @@ public class ActionStationForbidRobot extends BCActionPassive { return false; } - public static boolean isForbidden(ActionSlot slot, EntityRobotBase robot) { + public static boolean isForbidden(StatementSlot slot, EntityRobotBase robot) { for (IStatementParameter p : slot.parameters) { if (p != null) { StatementParameterItemStack actionStack = (StatementParameterItemStack) p; @@ -77,4 +79,10 @@ public class ActionStationForbidRobot extends BCActionPassive { return false; } + + @Override + public void actionActivate(IStatementContainer source, + IStatementParameter[] parameters) { + + } } diff --git a/common/buildcraft/silicon/statements/ActionStationInputItems.java b/common/buildcraft/silicon/statements/ActionStationInputItems.java index 44ff6ddc..ab2b25ce 100755 --- a/common/buildcraft/silicon/statements/ActionStationInputItems.java +++ b/common/buildcraft/silicon/statements/ActionStationInputItems.java @@ -9,22 +9,31 @@ package buildcraft.silicon.statements; import buildcraft.api.core.IInvSlot; +import buildcraft.api.statements.IActionInternal; +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; import buildcraft.core.inventory.filters.StatementParameterStackFilter; import buildcraft.core.robots.DockingStation; import buildcraft.core.robots.EntityRobot; -import buildcraft.core.statements.BCActionPassive; -import buildcraft.transport.gates.ActionSlot; +import buildcraft.core.statements.BCStatement; +import buildcraft.transport.gates.StatementSlot; -public abstract class ActionStationInputItems extends BCActionPassive { +public abstract class ActionStationInputItems extends BCStatement implements IActionInternal { public ActionStationInputItems(String name) { super(name); } - public boolean insert(DockingStation station, EntityRobot robot, ActionSlot actionSlot, IInvSlot invSlot, + public boolean insert(DockingStation station, EntityRobot robot, StatementSlot actionSlot, IInvSlot invSlot, boolean doInsert) { StatementParameterStackFilter param = new StatementParameterStackFilter(actionSlot.parameters); return !param.hasFilter() || param.matches(invSlot.getStackInSlot()); } + + @Override + public void actionActivate(IStatementContainer source, + IStatementParameter[] parameters) { + + } } diff --git a/common/buildcraft/silicon/statements/ActionStationProvideFluids.java b/common/buildcraft/silicon/statements/ActionStationProvideFluids.java index d8a50762..8e89b0c2 100755 --- a/common/buildcraft/silicon/statements/ActionStationProvideFluids.java +++ b/common/buildcraft/silicon/statements/ActionStationProvideFluids.java @@ -9,12 +9,14 @@ package buildcraft.silicon.statements; import net.minecraft.client.renderer.texture.IIconRegister; -import buildcraft.api.gates.StatementParameterItemStack; -import buildcraft.api.gates.IStatementParameter; -import buildcraft.core.statements.BCActionPassive; +import buildcraft.api.statements.IActionInternal; +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; +import buildcraft.api.statements.StatementParameterItemStack; +import buildcraft.core.statements.BCStatement; import buildcraft.core.utils.StringUtils; -public class ActionStationProvideFluids extends BCActionPassive { +public class ActionStationProvideFluids extends BCStatement implements IActionInternal { public ActionStationProvideFluids() { super("buildcraft:station.provide_fluids"); @@ -39,4 +41,10 @@ public class ActionStationProvideFluids extends BCActionPassive { public IStatementParameter createParameter(int index) { return new StatementParameterItemStack(); } + + @Override + public void actionActivate(IStatementContainer source, + IStatementParameter[] parameters) { + + } } diff --git a/common/buildcraft/silicon/statements/ActionStationProvideItems.java b/common/buildcraft/silicon/statements/ActionStationProvideItems.java index 3c622beb..f0d617b3 100755 --- a/common/buildcraft/silicon/statements/ActionStationProvideItems.java +++ b/common/buildcraft/silicon/statements/ActionStationProvideItems.java @@ -9,12 +9,14 @@ package buildcraft.silicon.statements; import net.minecraft.client.renderer.texture.IIconRegister; -import buildcraft.api.gates.StatementParameterItemStack; -import buildcraft.api.gates.IStatementParameter; -import buildcraft.core.statements.BCActionPassive; +import buildcraft.api.statements.IActionInternal; +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; +import buildcraft.api.statements.StatementParameterItemStack; +import buildcraft.core.statements.BCStatement; import buildcraft.core.utils.StringUtils; -public class ActionStationProvideItems extends BCActionPassive { +public class ActionStationProvideItems extends BCStatement implements IActionInternal { public ActionStationProvideItems() { super("buildcraft:station.provide_items"); @@ -39,4 +41,10 @@ public class ActionStationProvideItems extends BCActionPassive { public IStatementParameter createParameter(int index) { return new StatementParameterItemStack(); } + + @Override + public void actionActivate(IStatementContainer source, + IStatementParameter[] parameters) { + + } } diff --git a/common/buildcraft/silicon/statements/ActionStationRequestItems.java b/common/buildcraft/silicon/statements/ActionStationRequestItems.java index cbf2b4cd..e51e21bb 100755 --- a/common/buildcraft/silicon/statements/ActionStationRequestItems.java +++ b/common/buildcraft/silicon/statements/ActionStationRequestItems.java @@ -12,18 +12,16 @@ import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; - import net.minecraftforge.common.util.ForgeDirection; - import buildcraft.api.core.IInvSlot; -import buildcraft.api.gates.StatementParameterItemStack; -import buildcraft.api.gates.IStatementParameter; +import buildcraft.api.statements.IStatementParameter; +import buildcraft.api.statements.StatementParameterItemStack; import buildcraft.core.inventory.ITransactor; import buildcraft.core.inventory.Transactor; import buildcraft.core.robots.DockingStation; import buildcraft.core.robots.EntityRobot; import buildcraft.core.utils.StringUtils; -import buildcraft.transport.gates.ActionSlot; +import buildcraft.transport.gates.StatementSlot; public class ActionStationRequestItems extends ActionStationInputItems { @@ -57,7 +55,7 @@ public class ActionStationRequestItems extends ActionStationInputItems { } @Override - public boolean insert(DockingStation station, EntityRobot robot, ActionSlot actionSlot, IInvSlot invSlot, + public boolean insert(DockingStation station, EntityRobot robot, StatementSlot actionSlot, IInvSlot invSlot, boolean doInsert) { if (!super.insert(station, robot, actionSlot, invSlot, doInsert)) { return false; diff --git a/common/buildcraft/silicon/statements/ActionStationRequestItemsMachine.java b/common/buildcraft/silicon/statements/ActionStationRequestItemsMachine.java index 9cf78d9d..e4b74c2a 100755 --- a/common/buildcraft/silicon/statements/ActionStationRequestItemsMachine.java +++ b/common/buildcraft/silicon/statements/ActionStationRequestItemsMachine.java @@ -9,10 +9,13 @@ package buildcraft.silicon.statements; import net.minecraft.client.renderer.texture.IIconRegister; -import buildcraft.core.statements.BCActionPassive; +import buildcraft.api.statements.IActionInternal; +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; +import buildcraft.core.statements.BCStatement; import buildcraft.core.utils.StringUtils; -public class ActionStationRequestItemsMachine extends BCActionPassive { +public class ActionStationRequestItemsMachine extends BCStatement implements IActionInternal { public ActionStationRequestItemsMachine() { super("buildcraft:station.provide_machine_request"); @@ -27,4 +30,10 @@ public class ActionStationRequestItemsMachine extends BCActionPassive { public void registerIcons(IIconRegister iconRegister) { icon = iconRegister.registerIcon("buildcraft:triggers/action_station_machine_request"); } + + @Override + public void actionActivate(IStatementContainer source, + IStatementParameter[] parameters) { + + } } diff --git a/common/buildcraft/silicon/statements/RobotsActionProvider.java b/common/buildcraft/silicon/statements/RobotsActionProvider.java index 22819cb4..d5713fe8 100755 --- a/common/buildcraft/silicon/statements/RobotsActionProvider.java +++ b/common/buildcraft/silicon/statements/RobotsActionProvider.java @@ -17,14 +17,14 @@ import net.minecraft.block.BlockWorkbench; import net.minecraft.inventory.IInventory; import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityFurnace; - import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.IFluidHandler; - import buildcraft.BuildCraftSilicon; -import buildcraft.api.gates.IAction; -import buildcraft.api.gates.IActionProvider; import buildcraft.api.robots.IRequestProvider; +import buildcraft.api.statements.IActionExternal; +import buildcraft.api.statements.IActionInternal; +import buildcraft.api.statements.IActionProvider; +import buildcraft.api.statements.IStatementContainer; import buildcraft.api.transport.IPipeTile; import buildcraft.core.robots.DockingStation; import buildcraft.silicon.TileAssemblyTable; @@ -34,12 +34,14 @@ import buildcraft.transport.TileGenericPipe; public class RobotsActionProvider implements IActionProvider { @Override - public Collection getInternalActions(TileEntity tile) { + public Collection getInternalActions(IStatementContainer container) { + TileEntity tile = container.getTile(); + if (!(tile instanceof TileGenericPipe)) { return null; } - LinkedList result = new LinkedList(); + LinkedList result = new LinkedList(); ArrayList stations = new ArrayList(); @@ -93,7 +95,7 @@ public class RobotsActionProvider implements IActionProvider { } @Override - public Collection getExternalActions(ForgeDirection side, TileEntity tile) { + public Collection getExternalActions(ForgeDirection side, TileEntity tile) { return null; } diff --git a/common/buildcraft/silicon/statements/RobotsTriggerProvider.java b/common/buildcraft/silicon/statements/RobotsTriggerProvider.java index 358a35a1..d5b4b882 100755 --- a/common/buildcraft/silicon/statements/RobotsTriggerProvider.java +++ b/common/buildcraft/silicon/statements/RobotsTriggerProvider.java @@ -13,20 +13,21 @@ import java.util.LinkedList; import net.minecraft.block.Block; import net.minecraft.tileentity.TileEntity; - import net.minecraftforge.common.util.ForgeDirection; - import buildcraft.BuildCraftSilicon; -import buildcraft.api.gates.ITrigger; -import buildcraft.api.gates.ITriggerProvider; +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.ITriggerExternal; +import buildcraft.api.statements.ITriggerInternal; +import buildcraft.api.statements.ITriggerProvider; import buildcraft.api.transport.IPipeTile; import buildcraft.transport.TileGenericPipe; public class RobotsTriggerProvider implements ITriggerProvider { @Override - public Collection getInternalTriggers(TileEntity tile) { - LinkedList result = new LinkedList(); + public Collection getInternalTriggers(IStatementContainer container) { + LinkedList result = new LinkedList(); + TileEntity tile = container.getTile(); if (!(tile instanceof TileGenericPipe)) { return result; @@ -51,7 +52,7 @@ public class RobotsTriggerProvider implements ITriggerProvider { } @Override - public Collection getExternalTriggers(ForgeDirection side, TileEntity tile) { + public Collection getExternalTriggers(ForgeDirection side, TileEntity tile) { return null; } diff --git a/common/buildcraft/silicon/statements/StateStationProvideItems.java b/common/buildcraft/silicon/statements/StateStationProvideItems.java index 9fb792ea..a69e1a5b 100755 --- a/common/buildcraft/silicon/statements/StateStationProvideItems.java +++ b/common/buildcraft/silicon/statements/StateStationProvideItems.java @@ -11,8 +11,7 @@ package buildcraft.silicon.statements; import java.util.LinkedList; import net.minecraft.item.ItemStack; - -import buildcraft.api.gates.ActionState; +import buildcraft.api.statements.ActionState; import buildcraft.core.inventory.filters.IStackFilter; public class StateStationProvideItems extends ActionState { diff --git a/common/buildcraft/silicon/statements/StateStationRequestItems.java b/common/buildcraft/silicon/statements/StateStationRequestItems.java index 22573a5e..59f86af8 100755 --- a/common/buildcraft/silicon/statements/StateStationRequestItems.java +++ b/common/buildcraft/silicon/statements/StateStationRequestItems.java @@ -11,8 +11,7 @@ package buildcraft.silicon.statements; import java.util.LinkedList; import net.minecraft.item.ItemStack; - -import buildcraft.api.gates.ActionState; +import buildcraft.api.statements.ActionState; import buildcraft.core.inventory.filters.IStackFilter; public class StateStationRequestItems extends ActionState { diff --git a/common/buildcraft/silicon/statements/TriggerRobotSleep.java b/common/buildcraft/silicon/statements/TriggerRobotSleep.java index eb9f0a6d..1f6b2f33 100755 --- a/common/buildcraft/silicon/statements/TriggerRobotSleep.java +++ b/common/buildcraft/silicon/statements/TriggerRobotSleep.java @@ -11,16 +11,18 @@ package buildcraft.silicon.statements; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraftforge.common.util.ForgeDirection; import buildcraft.api.gates.IGate; -import buildcraft.api.gates.IStatementParameter; +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; +import buildcraft.api.statements.ITriggerInternal; import buildcraft.core.robots.AIRobotSleep; import buildcraft.core.robots.DockingStation; import buildcraft.core.robots.EntityRobot; -import buildcraft.core.statements.BCTrigger; +import buildcraft.core.statements.BCStatement; import buildcraft.core.utils.StringUtils; import buildcraft.transport.Pipe; import buildcraft.transport.TileGenericPipe; -public class TriggerRobotSleep extends BCTrigger { +public class TriggerRobotSleep extends BCStatement implements ITriggerInternal { public TriggerRobotSleep() { super("buildcraft:robot.sleep"); @@ -37,8 +39,12 @@ public class TriggerRobotSleep extends BCTrigger { } @Override - public boolean isTriggerActive(IGate gate, IStatementParameter[] parameters) { - Pipe pipe = (Pipe) gate.getPipe(); + public boolean isTriggerActive(IStatementContainer container, IStatementParameter[] parameters) { + if (!(container instanceof IGate)) { + return false; + } + + Pipe pipe = (Pipe) ((IGate) container).getPipe(); TileGenericPipe tile = pipe.container; for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) { diff --git a/common/buildcraft/transport/Gate.java b/common/buildcraft/transport/Gate.java index afd319ef..2828234a 100644 --- a/common/buildcraft/transport/Gate.java +++ b/common/buildcraft/transport/Gate.java @@ -24,27 +24,31 @@ import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; import buildcraft.BuildCraftTransport; import buildcraft.api.gates.GateExpansionController; -import buildcraft.api.gates.IAction; -import buildcraft.api.gates.IActionReceptor; import buildcraft.api.gates.IGate; import buildcraft.api.gates.IGateExpansion; -import buildcraft.api.gates.IStatementParameter; -import buildcraft.api.gates.ITrigger; -import buildcraft.api.gates.StatementManager; -import buildcraft.api.gates.StatementParameterItemStack; +import buildcraft.api.statements.IActionExternal; +import buildcraft.api.statements.IActionInternal; +import buildcraft.api.statements.IActionReceptor; +import buildcraft.api.statements.IStatement; +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; +import buildcraft.api.statements.ITriggerExternal; +import buildcraft.api.statements.ITriggerInternal; +import buildcraft.api.statements.StatementManager; +import buildcraft.api.statements.StatementParameterItemStack; import buildcraft.api.transport.IPipe; import buildcraft.api.transport.PipeWire; import buildcraft.core.GuiIds; import buildcraft.core.statements.ActionRedstoneOutput; import buildcraft.core.statements.StatementParameterRedstoneGateSideOnly; -import buildcraft.transport.gates.ActionSlot; +import buildcraft.transport.gates.StatementSlot; import buildcraft.transport.gates.GateDefinition.GateLogic; import buildcraft.transport.gates.GateDefinition.GateMaterial; import buildcraft.transport.gates.ItemGate; import buildcraft.transport.gui.ContainerGateInterface; import buildcraft.transport.statements.ActionRedstoneFaderOutput; -public final class Gate implements IGate { +public final class Gate implements IGate, IStatementContainer { public static int MAX_STATEMENTS = 8; public static int MAX_PARAMETERS = 3; @@ -54,14 +58,14 @@ public final class Gate implements IGate { public final GateLogic logic; public final BiMap expansions = HashBiMap.create(); - public ITrigger[] triggers = new ITrigger[MAX_STATEMENTS]; + public IStatement[] triggers = new IStatement[MAX_STATEMENTS]; public IStatementParameter[][] triggerParameters = new IStatementParameter[MAX_STATEMENTS][MAX_PARAMETERS]; - public IAction[] actions = new IAction[MAX_STATEMENTS]; + public IStatement[] actions = new IStatement[MAX_STATEMENTS]; public IStatementParameter[][] actionParameters = new IStatementParameter[MAX_STATEMENTS][MAX_PARAMETERS]; public ActionActiveState[] actionsState = new ActionActiveState[MAX_STATEMENTS]; - public ArrayList activeActions = new ArrayList(); + public ArrayList activeActions = new ArrayList(); public BitSet broadcastSignal = new BitSet(PipeWire.VALUES.length); public BitSet prevBroadcastSignal = new BitSet(PipeWire.VALUES.length); @@ -89,19 +93,19 @@ public final class Gate implements IGate { } } - public void setTrigger(int position, ITrigger trigger) { + public void setTrigger(int position, IStatement trigger) { triggers[position] = trigger; } - public ITrigger getTrigger(int position) { + public IStatement getTrigger(int position) { return triggers[position]; } - public void setAction(int position, IAction action) { + public void setAction(int position, IStatement action) { actions[position] = action; } - public IAction getAction(int position) { + public IStatement getAction(int position) { return actions[position]; } @@ -193,11 +197,11 @@ public final class Gate implements IGate { public void readStatementsFromNBT(NBTTagCompound data) { for (int i = 0; i < material.numSlots; ++i) { if (data.hasKey("trigger[" + i + "]")) { - triggers[i] = (ITrigger) StatementManager.statements.get(data.getString("trigger[" + i + "]")); + triggers[i] = StatementManager.statements.get(data.getString("trigger[" + i + "]")); } if (data.hasKey("action[" + i + "]")) { - actions[i] = (IAction) StatementManager.statements.get(data.getString("action[" + i + "]")); + actions[i] = StatementManager.statements.get(data.getString("action[" + i + "]")); } // This is for legacy trigger loading @@ -225,8 +229,8 @@ public final class Gate implements IGate { } public boolean verifyGateStatements() { - List triggerList = getAllValidTriggers(); - List actionList = getAllValidActions(); + List triggerList = getAllValidTriggers(); + List actionList = getAllValidActions(); boolean warning = false; for (int i = 0; i < MAX_STATEMENTS; ++i) { @@ -392,7 +396,7 @@ public final class Gate implements IGate { for (int it = 0; it < MAX_STATEMENTS; ++it) { actionsState[it] = ActionActiveState.Deactivated; - ITrigger trigger = triggers[it]; + IStatement trigger = triggers[it]; IStatementParameter[] parameter = triggerParameters[it]; if (trigger != null) { @@ -402,7 +406,7 @@ public final class Gate implements IGate { } } - activeActions = new ArrayList(); + activeActions = new ArrayList(); for (int it = 0; it < MAX_STATEMENTS; ++it) { boolean allActive = true; @@ -431,8 +435,8 @@ public final class Gate implements IGate { } } - ActionSlot slot = new ActionSlot(); - slot.action = actions[it]; + StatementSlot slot = new StatementSlot(); + slot.statement = actions[it]; slot.parameters = actionParameters[it]; activeActions.add(slot); } @@ -443,10 +447,21 @@ public final class Gate implements IGate { } // Activate the actions - for (ActionSlot slot : activeActions) { - IAction action = slot.action; - action.actionActivate(this, slot.parameters); - + for (StatementSlot slot : activeActions) { + IStatement action = slot.statement; + if (action instanceof IActionInternal) { + ((IActionInternal) action).actionActivate(this, slot.parameters); + } else if (action instanceof IActionExternal) { + for (ForgeDirection side: ForgeDirection.VALID_DIRECTIONS) { + TileEntity tile = this.getPipe().getTile().getAdjacentTile(side); + if (tile != null) { + ((IActionExternal) action).actionActivate(tile, side, this, slot.parameters); + } + } + } else { + continue; + } + // TODO: A lot of the code below should be removed in favor // of calls to actionActivate @@ -494,7 +509,7 @@ public final class Gate implements IGate { } } - public boolean resolveAction(IAction action) { + public boolean resolveAction(IStatement action) { for (GateExpansionController expansion : expansions.values()) { if (expansion.resolveAction(action)) { return true; @@ -503,13 +518,22 @@ public final class Gate implements IGate { return false; } - public boolean isTriggerActive(ITrigger trigger, IStatementParameter[] parameters) { + public boolean isTriggerActive(IStatement trigger, IStatementParameter[] parameters) { if (trigger == null) { return false; } - if (trigger.isTriggerActive(this, parameters)) { - return true; + if (trigger instanceof ITriggerInternal) { + if (((ITriggerInternal) trigger).isTriggerActive(this, parameters)) { + return true; + } + } else if (trigger instanceof ITriggerExternal) { + for (ForgeDirection side: ForgeDirection.VALID_DIRECTIONS) { + TileEntity tile = this.getPipe().getTile().getAdjacentTile(side); + if (tile != null && ((ITriggerExternal) trigger).isTriggerActive(tile, side, this, parameters)) { + return true; + } + } } // TODO: This can probably be refactored with regular triggers instead @@ -524,7 +548,7 @@ public final class Gate implements IGate { } // TRIGGERS - public void addTriggers(List list) { + public void addTriggers(List list) { for (PipeWire wire : PipeWire.VALUES) { if (pipe.wireSet[wire.ordinal()] && material.ordinal() >= wire.ordinal()) { list.add(BuildCraftTransport.triggerPipeWireActive[wire.ordinal()]); @@ -537,9 +561,9 @@ public final class Gate implements IGate { } } - public List getAllValidTriggers() { - ArrayList allTriggers = new ArrayList(64); - allTriggers.addAll(StatementManager.getInternalTriggers(pipe.container)); + public List getAllValidTriggers() { + ArrayList allTriggers = new ArrayList(64); + allTriggers.addAll(StatementManager.getInternalTriggers(this)); for (ForgeDirection o : ForgeDirection.VALID_DIRECTIONS) { TileEntity tile = pipe.container.getTile(o); @@ -551,7 +575,7 @@ public final class Gate implements IGate { } // ACTIONS - public void addActions(List list) { + public void addActions(List list) { for (PipeWire wire : PipeWire.VALUES) { if (pipe.wireSet[wire.ordinal()] && material.ordinal() >= wire.ordinal()) { list.add(BuildCraftTransport.actionPipeWire[wire.ordinal()]); @@ -563,9 +587,9 @@ public final class Gate implements IGate { } } - public List getAllValidActions() { - ArrayList allActions = new ArrayList(64); - allActions.addAll(StatementManager.getInternalActions(pipe.container)); + public List getAllValidActions() { + ArrayList allActions = new ArrayList(64); + allActions.addAll(StatementManager.getInternalActions(this)); for (ForgeDirection o : ForgeDirection.VALID_DIRECTIONS) { TileEntity tile = pipe.container.getTile(o); @@ -576,7 +600,7 @@ public final class Gate implements IGate { return allActions; } - @Override + //@Override TODO public void setPulsing(boolean pulsing) { if (pulsing != isPulsing) { isPulsing = pulsing; @@ -592,7 +616,6 @@ public final class Gate implements IGate { broadcastSignal.set(color.ordinal()); } - @Override public IPipe getPipe() { return pipe; } @@ -601,4 +624,9 @@ public final class Gate implements IGate { public ForgeDirection getSide() { return direction; } + + @Override + public TileEntity getTile() { + return pipe.container; + } } diff --git a/common/buildcraft/transport/Pipe.java b/common/buildcraft/transport/Pipe.java index 7c956a3b..0e3dd998 100644 --- a/common/buildcraft/transport/Pipe.java +++ b/common/buildcraft/transport/Pipe.java @@ -30,9 +30,9 @@ import cpw.mods.fml.relauncher.SideOnly; import net.minecraftforge.common.util.ForgeDirection; import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; -import buildcraft.api.gates.ActionState; -import buildcraft.api.gates.IAction; -import buildcraft.api.gates.ITrigger; +import buildcraft.api.gates.IGate; +import buildcraft.api.statements.ActionState; +import buildcraft.api.statements.IActionInternal; import buildcraft.api.transport.IPipe; import buildcraft.api.transport.IPipeTile; import buildcraft.api.transport.PipeWire; @@ -40,7 +40,7 @@ import buildcraft.core.IDropControlInventory; import buildcraft.core.inventory.InvUtils; import buildcraft.core.network.TilePacketWrapper; import buildcraft.core.utils.Utils; -import buildcraft.transport.gates.ActionSlot; +import buildcraft.transport.gates.StatementSlot; import buildcraft.transport.gates.GateFactory; import buildcraft.transport.pipes.events.PipeEvent; import buildcraft.transport.statements.ActionValve.ValveState; @@ -525,12 +525,8 @@ public abstract class Pipe implements IDropControlInven return result; } - public boolean isTriggerActive(ITrigger trigger) { - return false; - } - - public LinkedList getActions() { - LinkedList result = new LinkedList(); + public LinkedList getActions() { + LinkedList result = new LinkedList(); for (ValveState state : ValveState.VALUES) { result.add(BuildCraftTransport.actionValve[state.ordinal()]); @@ -552,7 +548,7 @@ public abstract class Pipe implements IDropControlInven container.scheduleRenderUpdate(); } - protected void actionsActivated(Collection actions) { + protected void actionsActivated(Collection actions) { } public TileGenericPipe getContainer() { @@ -659,10 +655,14 @@ public abstract class Pipe implements IDropControlInven public IPipeTile getTile() { return container; } - + @Override - public TileEntity getAdjacentTile(ForgeDirection dir) { - return container.getTile(dir); + public IGate getGate(ForgeDirection side) { + if (side == ForgeDirection.UNKNOWN) { + return null; + } + + return gates[side.ordinal()]; } private void pushActionState(ActionState state) { diff --git a/common/buildcraft/transport/PipeActionProvider.java b/common/buildcraft/transport/PipeActionProvider.java index f3a5dd33..45c18073 100644 --- a/common/buildcraft/transport/PipeActionProvider.java +++ b/common/buildcraft/transport/PipeActionProvider.java @@ -6,18 +6,21 @@ import java.util.LinkedList; import net.minecraft.block.Block; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; -import buildcraft.api.gates.IAction; -import buildcraft.api.gates.IActionProvider; +import buildcraft.api.gates.IGate; +import buildcraft.api.statements.IActionExternal; +import buildcraft.api.statements.IActionInternal; +import buildcraft.api.statements.IActionProvider; +import buildcraft.api.statements.IStatementContainer; import buildcraft.api.transport.IPipeTile; public class PipeActionProvider implements IActionProvider { @Override - public Collection getInternalActions(TileEntity tile) { - LinkedList result = new LinkedList(); + public Collection getInternalActions(IStatementContainer container) { + LinkedList result = new LinkedList(); Pipe pipe = null; - if (tile instanceof TileGenericPipe) { - pipe = ((TileGenericPipe) tile).pipe; + if (container instanceof IGate) { + pipe = (Pipe) ((IGate) container).getPipe(); } if (pipe == null) { @@ -36,7 +39,7 @@ public class PipeActionProvider implements IActionProvider { } @Override - public Collection getExternalActions(ForgeDirection side, TileEntity tile) { + public Collection getExternalActions(ForgeDirection side, TileEntity tile) { return null; } diff --git a/common/buildcraft/transport/PipeTransportFluids.java b/common/buildcraft/transport/PipeTransportFluids.java index 223a4e05..f9561517 100644 --- a/common/buildcraft/transport/PipeTransportFluids.java +++ b/common/buildcraft/transport/PipeTransportFluids.java @@ -12,7 +12,6 @@ import java.util.BitSet; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; - import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidContainerRegistry; @@ -20,11 +19,9 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTank; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; - import buildcraft.BuildCraftCore; import buildcraft.BuildCraftTransport; import buildcraft.api.core.SafeTimeTracker; -import buildcraft.api.gates.ITrigger; import buildcraft.api.transport.IPipeTile.PipeType; import buildcraft.core.DefaultProps; import buildcraft.core.IMachine; @@ -530,10 +527,6 @@ public class PipeTransportFluids extends PipeTransport implements IFluidHandler return tile instanceof TileGenericPipe || (tile instanceof IMachine && ((IMachine) tile).manageFluids()); } - public boolean isTriggerActive(ITrigger trigger) { - return false; - } - /** * ITankContainer implementation * */ diff --git a/common/buildcraft/transport/PipeTransportItems.java b/common/buildcraft/transport/PipeTransportItems.java index 354d1ba6..e7aa139d 100644 --- a/common/buildcraft/transport/PipeTransportItems.java +++ b/common/buildcraft/transport/PipeTransportItems.java @@ -28,7 +28,6 @@ import net.minecraftforge.common.util.ForgeDirection; import buildcraft.BuildCraftTransport; import buildcraft.api.core.BCLog; import buildcraft.api.core.Position; -import buildcraft.api.gates.ITrigger; import buildcraft.api.transport.IPipeTile.PipeType; import buildcraft.core.DefaultProps; import buildcraft.core.IMachine; @@ -491,11 +490,7 @@ public class PipeTransportItems extends PipeTransport { return tile instanceof TileGenericPipe || (tile instanceof IInventory && ((IInventory) tile).getSizeInventory() > 0) || (tile instanceof IMachine && ((IMachine) tile).manageSolids()); } - - public boolean isTriggerActive(ITrigger trigger) { - return false; - } - + /** * Group all items that are similar, that is to say same dmg, same id, same * nbt and no contribution controlling them diff --git a/common/buildcraft/transport/PipeTransportPower.java b/common/buildcraft/transport/PipeTransportPower.java index ecebda16..736ef365 100644 --- a/common/buildcraft/transport/PipeTransportPower.java +++ b/common/buildcraft/transport/PipeTransportPower.java @@ -20,7 +20,6 @@ import cofh.api.energy.IEnergyHandler; import buildcraft.BuildCraftCore; import buildcraft.BuildCraftTransport; import buildcraft.api.core.SafeTimeTracker; -import buildcraft.api.gates.ITrigger; import buildcraft.api.power.IPowerEmitter; import buildcraft.api.power.IPowerReceptor; import buildcraft.api.power.PowerHandler.PowerReceiver; @@ -462,10 +461,6 @@ public class PipeTransportPower extends PipeTransport { } } - public boolean isTriggerActive(ITrigger trigger) { - return false; - } - /** * Client-side handler for receiving power updates from the server; * diff --git a/common/buildcraft/transport/PipeTriggerProvider.java b/common/buildcraft/transport/PipeTriggerProvider.java index 81686527..42de4b28 100644 --- a/common/buildcraft/transport/PipeTriggerProvider.java +++ b/common/buildcraft/transport/PipeTriggerProvider.java @@ -15,17 +15,20 @@ import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; import cofh.api.energy.IEnergyHandler; import buildcraft.BuildCraftCore; -import buildcraft.api.gates.ITrigger; -import buildcraft.api.gates.ITriggerProvider; +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.ITriggerExternal; +import buildcraft.api.statements.ITriggerInternal; +import buildcraft.api.statements.ITriggerProvider; import buildcraft.api.transport.IPipeTile; import buildcraft.transport.statements.TriggerPipeContents; public class PipeTriggerProvider implements ITriggerProvider { @Override - public LinkedList getInternalTriggers(TileEntity tile) { - LinkedList result = new LinkedList(); + public LinkedList getInternalTriggers(IStatementContainer container) { + LinkedList result = new LinkedList(); Pipe pipe = null; + TileEntity tile = container.getTile(); if (tile instanceof TileGenericPipe) { pipe = ((TileGenericPipe) tile).pipe; } @@ -66,15 +69,15 @@ public class PipeTriggerProvider implements ITriggerProvider { } if (tile instanceof IEnergyHandler && ((IEnergyHandler) tile).getMaxEnergyStored(ForgeDirection.UNKNOWN) > 0) { - result.add(BuildCraftCore.triggerEnergyHigh); - result.add(BuildCraftCore.triggerEnergyLow); + result.add((ITriggerInternal) BuildCraftCore.triggerEnergyHigh); + result.add((ITriggerInternal) BuildCraftCore.triggerEnergyLow); } return result; } @Override - public LinkedList getExternalTriggers(ForgeDirection side, TileEntity tile) { + public LinkedList getExternalTriggers(ForgeDirection side, TileEntity tile) { return null; } } diff --git a/common/buildcraft/transport/TileFilteredBuffer.java b/common/buildcraft/transport/TileFilteredBuffer.java index d302db51..153249db 100644 --- a/common/buildcraft/transport/TileFilteredBuffer.java +++ b/common/buildcraft/transport/TileFilteredBuffer.java @@ -14,9 +14,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; - import buildcraft.BuildCraftCore; -import buildcraft.api.gates.ITrigger; import buildcraft.core.TileBuildCraft; import buildcraft.core.inventory.SimpleInventory; diff --git a/common/buildcraft/transport/TileGenericPipe.java b/common/buildcraft/transport/TileGenericPipe.java index fa1b2d24..b3d4fb82 100755 --- a/common/buildcraft/transport/TileGenericPipe.java +++ b/common/buildcraft/transport/TileGenericPipe.java @@ -40,6 +40,7 @@ import buildcraft.api.gates.IGateExpansion; import buildcraft.api.power.IPowerReceptor; import buildcraft.api.power.PowerHandler; import buildcraft.api.power.PowerHandler.PowerReceiver; +import buildcraft.api.transport.IPipe; import buildcraft.api.transport.IPipeConnection; import buildcraft.api.transport.IPipePluggable; import buildcraft.api.transport.IPipeTile; @@ -1190,4 +1191,14 @@ public class TileGenericPipe extends TileEntity implements IPowerReceptor, IFlui return 0; } } + + @Override + public TileEntity getAdjacentTile(ForgeDirection dir) { + return getTile(dir); + } + + @Override + public IPipe getPipe() { + return pipe; + } } diff --git a/common/buildcraft/transport/gates/ActionIterator.java b/common/buildcraft/transport/gates/ActionIterator.java index 22c22197..14de8a3c 100755 --- a/common/buildcraft/transport/gates/ActionIterator.java +++ b/common/buildcraft/transport/gates/ActionIterator.java @@ -15,7 +15,7 @@ import net.minecraftforge.common.util.ForgeDirection; import buildcraft.transport.Gate; import buildcraft.transport.Pipe; -public class ActionIterator implements Iterable { +public class ActionIterator implements Iterable { private Pipe pipe; @@ -24,15 +24,15 @@ public class ActionIterator implements Iterable { } @Override - public Iterator iterator() { + public Iterator iterator() { return new It(); } - private class It implements Iterator { + private class It implements Iterator { private ForgeDirection curDir = ForgeDirection.values()[0]; private int index = 0; - private ActionSlot next; + private StatementSlot next; public It() { while (!isValid()) { @@ -58,8 +58,8 @@ public class ActionIterator implements Iterable { } @Override - public ActionSlot next() { - ActionSlot result = next; + public StatementSlot next() { + StatementSlot result = next; while (true) { if (index < Gate.MAX_STATEMENTS - 1) { @@ -77,8 +77,8 @@ public class ActionIterator implements Iterable { } if (isValid()) { - next = new ActionSlot(); - next.action = pipe.gates[curDir.ordinal()].actions[index]; + next = new StatementSlot(); + next.statement = pipe.gates[curDir.ordinal()].actions[index]; next.parameters = pipe.gates[curDir.ordinal()].actionParameters[index]; } else { next = null; diff --git a/common/buildcraft/transport/gates/GateExpansionBuildcraft.java b/common/buildcraft/transport/gates/GateExpansionBuildcraft.java index 405c4aa7..a51241cc 100644 --- a/common/buildcraft/transport/gates/GateExpansionBuildcraft.java +++ b/common/buildcraft/transport/gates/GateExpansionBuildcraft.java @@ -10,7 +10,6 @@ package buildcraft.transport.gates; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.util.IIcon; - import buildcraft.api.gates.IGateExpansion; import buildcraft.core.utils.StringUtils; diff --git a/common/buildcraft/transport/gates/GateExpansionPulsar.java b/common/buildcraft/transport/gates/GateExpansionPulsar.java index 94fd80d2..512edfd5 100644 --- a/common/buildcraft/transport/gates/GateExpansionPulsar.java +++ b/common/buildcraft/transport/gates/GateExpansionPulsar.java @@ -16,9 +16,10 @@ import net.minecraftforge.common.util.ForgeDirection; import cofh.api.energy.IEnergyHandler; import buildcraft.BuildCraftTransport; import buildcraft.api.gates.GateExpansionController; -import buildcraft.api.gates.IAction; import buildcraft.api.gates.IGate; import buildcraft.api.gates.IGateExpansion; +import buildcraft.api.statements.IActionInternal; +import buildcraft.api.statements.IStatement; import buildcraft.transport.statements.ActionEnergyPulsar; import buildcraft.transport.statements.ActionSingleEnergyPulse; @@ -61,7 +62,7 @@ public final class GateExpansionPulsar extends GateExpansionBuildcraft implement } @Override - public boolean resolveAction(IAction action) { + public boolean resolveAction(IStatement action) { if (action instanceof ActionEnergyPulsar) { enablePulse(); return true; @@ -73,7 +74,7 @@ public final class GateExpansionPulsar extends GateExpansionBuildcraft implement } @Override - public void addActions(List list) { + public void addActions(List list) { super.addActions(list); list.add(BuildCraftTransport.actionEnergyPulser); list.add(BuildCraftTransport.actionSingleEnergyPulse); diff --git a/common/buildcraft/transport/gates/GateExpansionRedstoneFader.java b/common/buildcraft/transport/gates/GateExpansionRedstoneFader.java index 5c17de99..f07a08ce 100644 --- a/common/buildcraft/transport/gates/GateExpansionRedstoneFader.java +++ b/common/buildcraft/transport/gates/GateExpansionRedstoneFader.java @@ -12,12 +12,11 @@ import java.util.Arrays; import java.util.List; import net.minecraft.tileentity.TileEntity; - import buildcraft.BuildCraftTransport; import buildcraft.api.gates.GateExpansionController; -import buildcraft.api.gates.IAction; import buildcraft.api.gates.IGateExpansion; -import buildcraft.api.gates.ITrigger; +import buildcraft.api.statements.IActionInternal; +import buildcraft.api.statements.ITriggerInternal; public final class GateExpansionRedstoneFader extends GateExpansionBuildcraft implements IGateExpansion { @@ -39,13 +38,13 @@ public final class GateExpansionRedstoneFader extends GateExpansionBuildcraft im } @Override - public void addTriggers(List list) { + public void addTriggers(List list) { super.addTriggers(list); list.addAll(Arrays.asList(BuildCraftTransport.triggerRedstoneLevel)); } @Override - public void addActions(List list) { + public void addActions(List list) { super.addActions(list); list.addAll(Arrays.asList(BuildCraftTransport.actionRedstoneLevel)); } diff --git a/common/buildcraft/transport/gates/GateExpansionTimer.java b/common/buildcraft/transport/gates/GateExpansionTimer.java index cd2d04fe..b25eed83 100644 --- a/common/buildcraft/transport/gates/GateExpansionTimer.java +++ b/common/buildcraft/transport/gates/GateExpansionTimer.java @@ -15,8 +15,9 @@ import buildcraft.BuildCraftTransport; import buildcraft.api.gates.GateExpansionController; import buildcraft.api.gates.IGate; import buildcraft.api.gates.IGateExpansion; -import buildcraft.api.gates.IStatementParameter; -import buildcraft.api.gates.ITrigger; +import buildcraft.api.statements.IStatement; +import buildcraft.api.statements.IStatementParameter; +import buildcraft.api.statements.ITriggerInternal; import buildcraft.transport.statements.TriggerClockTimer; import buildcraft.transport.statements.TriggerClockTimer.Time; @@ -67,7 +68,7 @@ public final class GateExpansionTimer extends GateExpansionBuildcraft implements } @Override - public boolean isTriggerActive(ITrigger trigger, IStatementParameter[] parameters) { + public boolean isTriggerActive(IStatement trigger, IStatementParameter[] parameters) { if (trigger instanceof TriggerClockTimer) { TriggerClockTimer timerTrigger = (TriggerClockTimer) trigger; return timers[timerTrigger.time.ordinal()].isActive(); @@ -76,7 +77,7 @@ public final class GateExpansionTimer extends GateExpansionBuildcraft implements } @Override - public void addTriggers(List list) { + public void addTriggers(List list) { super.addTriggers(list); for (Time time : TriggerClockTimer.Time.VALUES) { list.add(BuildCraftTransport.triggerTimer[time.ordinal()]); diff --git a/common/buildcraft/transport/gates/GateFactory.java b/common/buildcraft/transport/gates/GateFactory.java index 45aa1987..531e49fb 100644 --- a/common/buildcraft/transport/gates/GateFactory.java +++ b/common/buildcraft/transport/gates/GateFactory.java @@ -11,10 +11,8 @@ package buildcraft.transport.gates; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; - import net.minecraftforge.common.util.Constants; import net.minecraftforge.common.util.ForgeDirection; - import buildcraft.api.gates.GateExpansionController; import buildcraft.api.gates.GateExpansions; import buildcraft.api.gates.IGateExpansion; diff --git a/common/buildcraft/transport/gates/ItemGate.java b/common/buildcraft/transport/gates/ItemGate.java index ae3e4fbe..6bc4c4ee 100755 --- a/common/buildcraft/transport/gates/ItemGate.java +++ b/common/buildcraft/transport/gates/ItemGate.java @@ -14,7 +14,6 @@ import java.util.List; import java.util.Set; import io.netty.buffer.ByteBuf; - import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; @@ -25,18 +24,15 @@ import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagString; import net.minecraft.util.IIcon; import net.minecraft.util.StatCollector; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - import net.minecraftforge.common.util.Constants; import net.minecraftforge.common.util.ForgeDirection; - import buildcraft.BuildCraftTransport; import buildcraft.api.gates.GateExpansions; import buildcraft.api.gates.IGateExpansion; -import buildcraft.api.gates.IStatement; -import buildcraft.api.gates.StatementManager; +import buildcraft.api.statements.IStatement; +import buildcraft.api.statements.StatementManager; import buildcraft.api.transport.IPipePluggable; import buildcraft.api.transport.IPipeTile; import buildcraft.core.ItemBuildCraft; diff --git a/common/buildcraft/transport/gates/ActionSlot.java b/common/buildcraft/transport/gates/StatementSlot.java similarity index 70% rename from common/buildcraft/transport/gates/ActionSlot.java rename to common/buildcraft/transport/gates/StatementSlot.java index 90c6a049..539d9b4e 100755 --- a/common/buildcraft/transport/gates/ActionSlot.java +++ b/common/buildcraft/transport/gates/StatementSlot.java @@ -8,10 +8,10 @@ */ package buildcraft.transport.gates; -import buildcraft.api.gates.IAction; -import buildcraft.api.gates.IStatementParameter; +import buildcraft.api.statements.IStatement; +import buildcraft.api.statements.IStatementParameter; -public class ActionSlot { - public IAction action; +public class StatementSlot { + public IStatement statement; public IStatementParameter[] parameters; } diff --git a/common/buildcraft/transport/gui/ContainerGateInterface.java b/common/buildcraft/transport/gui/ContainerGateInterface.java index cc68e49e..6dc186e5 100644 --- a/common/buildcraft/transport/gui/ContainerGateInterface.java +++ b/common/buildcraft/transport/gui/ContainerGateInterface.java @@ -19,13 +19,9 @@ import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.util.ResourceLocation; - -import buildcraft.api.gates.IAction; -import buildcraft.api.gates.IStatementParameter; -import buildcraft.api.gates.IStatement; -import buildcraft.api.gates.ITrigger; -import buildcraft.api.gates.IStatementParameter; -import buildcraft.api.gates.StatementManager; +import buildcraft.api.statements.IStatement; +import buildcraft.api.statements.IStatementParameter; +import buildcraft.api.statements.StatementManager; import buildcraft.core.gui.BuildCraftContainer; import buildcraft.core.network.RPC; import buildcraft.core.network.RPCHandler; @@ -44,16 +40,16 @@ public class ContainerGateInterface extends BuildCraftContainer { IInventory playerIInventory; private final Pipe pipe; private Gate gate; - private final NavigableSet potentialTriggers = new TreeSet(new Comparator() { + private final NavigableSet potentialTriggers = new TreeSet(new Comparator() { @Override - public int compare(ITrigger o1, ITrigger o2) { + public int compare(IStatement o1, IStatement o2) { return o1.getUniqueTag().compareTo(o2.getUniqueTag()); } }); - private final NavigableSet potentialActions = new TreeSet(new Comparator() { + private final NavigableSet potentialActions = new TreeSet(new Comparator() { @Override - public int compare(IAction o1, IAction o2) { + public int compare(IStatement o1, IStatement o2) { return o1.getUniqueTag().compareTo(o2.getUniqueTag()); } }); @@ -105,10 +101,10 @@ public class ContainerGateInterface extends BuildCraftContainer { potentialActions.addAll(gate.getAllValidActions()); if (gate.material.numTriggerParameters == 0) { - Iterator it = potentialTriggers.iterator(); + Iterator it = potentialTriggers.iterator(); while (it.hasNext()) { - ITrigger trigger = it.next(); + IStatement trigger = it.next(); if (trigger.minParameters() > 0) { it.remove(); @@ -117,10 +113,10 @@ public class ContainerGateInterface extends BuildCraftContainer { } if (gate.material.numActionParameters == 0) { - Iterator it = potentialActions.iterator(); + Iterator it = potentialActions.iterator(); while (it.hasNext()) { - IAction action = it.next(); + IStatement action = it.next(); if (action.minParameters() > 0) { it.remove(); @@ -254,8 +250,8 @@ public class ContainerGateInterface extends BuildCraftContainer { public void selectionRequest(RPCMessageInfo info) { EntityPlayer player = info.sender; for (int position = 0; position < gate.material.numSlots; position++) { - IAction action = gate.getAction(position); - ITrigger trigger = gate.getTrigger(position); + IStatement action = gate.getAction(position); + IStatement trigger = gate.getTrigger(position); RPCHandler.rpcPlayer(player, this, "setAction", position, action != null ? action.getUniqueTag() : null, false); RPCHandler.rpcPlayer(player, this, "setTrigger", position, trigger != null ? trigger.getUniqueTag() : null, false); for (int p = 0; p < 3; ++p) { @@ -274,7 +270,7 @@ public class ContainerGateInterface extends BuildCraftContainer { return potentialTriggers.size() > 0; } - public ITrigger getFirstTrigger() { + public IStatement getFirstTrigger() { if (potentialTriggers.isEmpty()) { return null; } else { @@ -282,7 +278,7 @@ public class ContainerGateInterface extends BuildCraftContainer { } } - public ITrigger getLastTrigger() { + public IStatement getLastTrigger() { if (potentialTriggers.isEmpty()) { return null; } else { @@ -290,7 +286,7 @@ public class ContainerGateInterface extends BuildCraftContainer { } } - public Iterator getTriggerIterator(boolean descending) { + public Iterator getTriggerIterator(boolean descending) { return descending ? potentialTriggers.descendingIterator() : potentialTriggers.iterator(); } @@ -309,7 +305,7 @@ public class ContainerGateInterface extends BuildCraftContainer { } if (tag != null) { - gate.setTrigger(trigger, (ITrigger) StatementManager.statements.get(tag)); + gate.setTrigger(trigger, (IStatement) StatementManager.statements.get(tag)); } else { gate.setTrigger(trigger, null); } @@ -347,7 +343,7 @@ public class ContainerGateInterface extends BuildCraftContainer { return !potentialActions.isEmpty(); } - public IAction getFirstAction() { + public IStatement getFirstAction() { if (potentialActions.isEmpty()) { return null; } else { @@ -355,7 +351,7 @@ public class ContainerGateInterface extends BuildCraftContainer { } } - public IAction getLastAction() { + public IStatement getLastAction() { if (potentialActions.isEmpty()) { return null; } else { @@ -363,7 +359,7 @@ public class ContainerGateInterface extends BuildCraftContainer { } } - public Iterator getActionIterator(boolean descending) { + public Iterator getActionIterator(boolean descending) { return descending ? potentialActions.descendingIterator() : potentialActions.iterator(); } @@ -374,7 +370,7 @@ public class ContainerGateInterface extends BuildCraftContainer { } if (tag != null) { - gate.setAction(action, (IAction) StatementManager.statements.get(tag)); + gate.setAction(action, (IStatement) StatementManager.statements.get(tag)); } else { gate.setAction(action, null); } diff --git a/common/buildcraft/transport/gui/GuiGateInterface.java b/common/buildcraft/transport/gui/GuiGateInterface.java index defc2334..a7075fa4 100644 --- a/common/buildcraft/transport/gui/GuiGateInterface.java +++ b/common/buildcraft/transport/gui/GuiGateInterface.java @@ -17,16 +17,10 @@ import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; - -import buildcraft.api.gates.IAction; -import buildcraft.api.gates.IStatementParameter; -import buildcraft.api.gates.IStatement; -import buildcraft.api.gates.IStatementParameter; -import buildcraft.api.gates.ITrigger; -import buildcraft.api.gates.IStatementParameter; +import buildcraft.api.statements.IStatement; +import buildcraft.api.statements.IStatementParameter; import buildcraft.core.gui.AdvancedSlot; import buildcraft.core.gui.GuiAdvancedInterface; import buildcraft.core.utils.StringUtils; @@ -386,7 +380,7 @@ public class GuiGateInterface extends GuiAdvancedInterface { if (slot instanceof TriggerSlot && container.hasTriggers()) { TriggerSlot triggerSlot = (TriggerSlot) slot; - ITrigger changed = null; + IStatement changed = null; if (triggerSlot.getStatement() == null) { @@ -397,10 +391,10 @@ public class GuiGateInterface extends GuiAdvancedInterface { } } else { - Iterator it = container.getTriggerIterator(k != 0); + Iterator it = container.getTriggerIterator(k != 0); for (; it.hasNext();) { - ITrigger trigger = it.next(); + IStatement trigger = it.next(); if (!it.hasNext()) { changed = null; @@ -426,7 +420,7 @@ public class GuiGateInterface extends GuiAdvancedInterface { } else if (slot instanceof ActionSlot) { ActionSlot actionSlot = (ActionSlot) slot; - IAction changed = null; + IStatement changed = null; if (actionSlot.getStatement() == null) { if (k == 0) { @@ -436,10 +430,10 @@ public class GuiGateInterface extends GuiAdvancedInterface { } } else { - Iterator it = container.getActionIterator(k != 0); + Iterator it = container.getActionIterator(k != 0); for (; it.hasNext();) { - IAction action = it.next(); + IStatement action = it.next(); if (!it.hasNext()) { changed = null; diff --git a/common/buildcraft/transport/pipes/PipeFluidsIron.java b/common/buildcraft/transport/pipes/PipeFluidsIron.java index b7009188..0b14db9c 100644 --- a/common/buildcraft/transport/pipes/PipeFluidsIron.java +++ b/common/buildcraft/transport/pipes/PipeFluidsIron.java @@ -20,12 +20,13 @@ import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.IFluidHandler; import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; -import buildcraft.api.gates.IAction; +import buildcraft.api.statements.IActionInternal; +import buildcraft.api.statements.IStatement; import buildcraft.transport.Pipe; import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeTransportFluids; import buildcraft.transport.TileGenericPipe; -import buildcraft.transport.gates.ActionSlot; +import buildcraft.transport.gates.StatementSlot; import buildcraft.transport.statements.ActionPipeDirection; public class PipeFluidsIron extends Pipe { @@ -102,20 +103,20 @@ public class PipeFluidsIron extends Pipe { } @Override - protected void actionsActivated(Collection actions) { + protected void actionsActivated(Collection actions) { super.actionsActivated(actions); - for (ActionSlot action : actions) { - if (action.action instanceof ActionPipeDirection) { - logic.setFacing(((ActionPipeDirection) action.action).direction); + for (StatementSlot action : actions) { + if (action.statement instanceof ActionPipeDirection) { + logic.setFacing(((ActionPipeDirection) action.statement).direction); break; } } } @Override - public LinkedList getActions() { - LinkedList action = super.getActions(); + public LinkedList getActions() { + LinkedList action = super.getActions(); for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { if (container.isPipeConnected(direction)) { action.add(BuildCraftTransport.actionPipeDirection[direction.ordinal()]); diff --git a/common/buildcraft/transport/pipes/PipeItemsDaizuli.java b/common/buildcraft/transport/pipes/PipeItemsDaizuli.java index d59734ff..04f1cb2b 100644 --- a/common/buildcraft/transport/pipes/PipeItemsDaizuli.java +++ b/common/buildcraft/transport/pipes/PipeItemsDaizuli.java @@ -24,7 +24,7 @@ import buildcraft.BuildCraftTransport; import buildcraft.api.core.EnumColor; import buildcraft.api.core.IIconProvider; import buildcraft.api.core.NetworkData; -import buildcraft.api.gates.IAction; +import buildcraft.api.statements.IActionInternal; import buildcraft.api.tools.IToolWrench; import buildcraft.transport.Pipe; import buildcraft.transport.PipeIconProvider; @@ -32,7 +32,7 @@ import buildcraft.transport.PipeTransportItems; import buildcraft.transport.TileGenericPipe; import buildcraft.transport.TransportConstants; import buildcraft.transport.TravelingItem; -import buildcraft.transport.gates.ActionSlot; +import buildcraft.transport.gates.StatementSlot; import buildcraft.transport.pipes.events.PipeEventItem; import buildcraft.transport.statements.ActionPipeColor; import buildcraft.transport.statements.ActionPipeDirection; @@ -150,27 +150,27 @@ public class PipeItemsDaizuli extends Pipe { } @Override - protected void actionsActivated(Collection actions) { + protected void actionsActivated(Collection actions) { super.actionsActivated(actions); - for (ActionSlot action : actions) { - if (action.action instanceof ActionPipeColor) { - setColor(((ActionPipeColor) action.action).color); + for (StatementSlot action : actions) { + if (action.statement instanceof ActionPipeColor) { + setColor(((ActionPipeColor) action.statement).color); break; } } - for (ActionSlot action : actions) { - if (action.action instanceof ActionPipeDirection) { - logic.setFacing(((ActionPipeDirection) action.action).direction); + for (StatementSlot action : actions) { + if (action.statement instanceof ActionPipeDirection) { + logic.setFacing(((ActionPipeDirection) action.statement).direction); break; } } } @Override - public LinkedList getActions() { - LinkedList action = super.getActions(); + public LinkedList getActions() { + LinkedList action = super.getActions(); action.addAll(Arrays.asList(BuildCraftTransport.actionPipeColor)); for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { if (container.isPipeConnected(direction)) { diff --git a/common/buildcraft/transport/pipes/PipeItemsEmzuli.java b/common/buildcraft/transport/pipes/PipeItemsEmzuli.java index fa844c81..c98dd303 100644 --- a/common/buildcraft/transport/pipes/PipeItemsEmzuli.java +++ b/common/buildcraft/transport/pipes/PipeItemsEmzuli.java @@ -22,7 +22,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; import buildcraft.BuildCraftTransport; import buildcraft.api.core.EnumColor; -import buildcraft.api.gates.IAction; +import buildcraft.api.statements.IActionInternal; import buildcraft.core.GuiIds; import buildcraft.core.inventory.InvUtils; import buildcraft.core.inventory.SimpleInventory; @@ -30,7 +30,7 @@ import buildcraft.core.network.IGuiReturnHandler; import buildcraft.transport.BlockGenericPipe; import buildcraft.transport.PipeIconProvider; import buildcraft.transport.TravelingItem; -import buildcraft.transport.gates.ActionSlot; +import buildcraft.transport.gates.StatementSlot; import buildcraft.transport.statements.ActionExtractionPreset; public class PipeItemsEmzuli extends PipeItemsWood implements IGuiReturnHandler { @@ -138,14 +138,14 @@ public class PipeItemsEmzuli extends PipeItemsWood implements IGuiReturnHandler } @Override - protected void actionsActivated(Collection actions) { + protected void actionsActivated(Collection actions) { super.actionsActivated(actions); activeFlags.clear(); - for (ActionSlot action : actions) { - if (action.action instanceof ActionExtractionPreset) { - setActivePreset(((ActionExtractionPreset) action.action).color); + for (StatementSlot action : actions) { + if (action.statement instanceof ActionExtractionPreset) { + setActivePreset(((ActionExtractionPreset) action.statement).color); } } } @@ -170,8 +170,8 @@ public class PipeItemsEmzuli extends PipeItemsWood implements IGuiReturnHandler } @Override - public LinkedList getActions() { - LinkedList result = super.getActions(); + public LinkedList getActions() { + LinkedList result = super.getActions(); result.add(BuildCraftTransport.actionExtractionPresetRed); result.add(BuildCraftTransport.actionExtractionPresetBlue); diff --git a/common/buildcraft/transport/pipes/PipeItemsIron.java b/common/buildcraft/transport/pipes/PipeItemsIron.java index 97fb0596..2aa349dc 100644 --- a/common/buildcraft/transport/pipes/PipeItemsIron.java +++ b/common/buildcraft/transport/pipes/PipeItemsIron.java @@ -20,12 +20,12 @@ import cpw.mods.fml.relauncher.SideOnly; import net.minecraftforge.common.util.ForgeDirection; import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; -import buildcraft.api.gates.IAction; +import buildcraft.api.statements.IActionInternal; import buildcraft.transport.Pipe; import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeTransportItems; import buildcraft.transport.TileGenericPipe; -import buildcraft.transport.gates.ActionSlot; +import buildcraft.transport.gates.StatementSlot; import buildcraft.transport.statements.ActionPipeDirection; public class PipeItemsIron extends Pipe { @@ -108,20 +108,20 @@ public class PipeItemsIron extends Pipe { } @Override - protected void actionsActivated(Collection actions) { + protected void actionsActivated(Collection actions) { super.actionsActivated(actions); - for (ActionSlot action : actions) { - if (action.action instanceof ActionPipeDirection) { - logic.setFacing(((ActionPipeDirection) action.action).direction); + for (StatementSlot action : actions) { + if (action.statement instanceof ActionPipeDirection) { + logic.setFacing(((ActionPipeDirection) action.statement).direction); break; } } } @Override - public LinkedList getActions() { - LinkedList action = super.getActions(); + public LinkedList getActions() { + LinkedList action = super.getActions(); for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { if (container.isPipeConnected(direction)) { action.add(BuildCraftTransport.actionPipeDirection[direction.ordinal()]); diff --git a/common/buildcraft/transport/pipes/PipeItemsLapis.java b/common/buildcraft/transport/pipes/PipeItemsLapis.java index 952f5740..8749a563 100644 --- a/common/buildcraft/transport/pipes/PipeItemsLapis.java +++ b/common/buildcraft/transport/pipes/PipeItemsLapis.java @@ -20,14 +20,14 @@ import net.minecraftforge.common.util.ForgeDirection; import buildcraft.BuildCraftTransport; import buildcraft.api.core.EnumColor; import buildcraft.api.core.IIconProvider; -import buildcraft.api.gates.IAction; +import buildcraft.api.statements.IActionInternal; import buildcraft.api.tools.IToolWrench; import buildcraft.transport.Pipe; import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeTransportItems; import buildcraft.transport.TransportConstants; import buildcraft.transport.TravelingItem; -import buildcraft.transport.gates.ActionSlot; +import buildcraft.transport.gates.StatementSlot; import buildcraft.transport.pipes.events.PipeEventItem; import buildcraft.transport.statements.ActionPipeColor; @@ -97,20 +97,20 @@ public class PipeItemsLapis extends Pipe { } @Override - protected void actionsActivated(Collection actions) { + protected void actionsActivated(Collection actions) { super.actionsActivated(actions); - for (ActionSlot action : actions) { - if (action.action instanceof ActionPipeColor) { - setColor(((ActionPipeColor) action.action).color); + for (StatementSlot action : actions) { + if (action.statement instanceof ActionPipeColor) { + setColor(((ActionPipeColor) action.statement).color); break; } } } @Override - public LinkedList getActions() { - LinkedList result = super.getActions(); + public LinkedList getActions() { + LinkedList result = super.getActions(); result.addAll(Arrays.asList(BuildCraftTransport.actionPipeColor)); return result; diff --git a/common/buildcraft/transport/pipes/PipePowerIron.java b/common/buildcraft/transport/pipes/PipePowerIron.java index 42393929..8ea3f679 100644 --- a/common/buildcraft/transport/pipes/PipePowerIron.java +++ b/common/buildcraft/transport/pipes/PipePowerIron.java @@ -19,14 +19,14 @@ import cpw.mods.fml.relauncher.SideOnly; import net.minecraftforge.common.util.ForgeDirection; import buildcraft.BuildCraftTransport; import buildcraft.api.core.IIconProvider; -import buildcraft.api.gates.IAction; +import buildcraft.api.statements.IActionInternal; import buildcraft.api.tools.IToolWrench; import buildcraft.core.PowerMode; import buildcraft.core.utils.StringUtils; import buildcraft.transport.Pipe; import buildcraft.transport.PipeIconProvider; import buildcraft.transport.PipeTransportPower; -import buildcraft.transport.gates.ActionSlot; +import buildcraft.transport.gates.StatementSlot; import buildcraft.transport.statements.ActionPowerLimiter; public class PipePowerIron extends Pipe { @@ -90,20 +90,20 @@ public class PipePowerIron extends Pipe { } @Override - protected void actionsActivated(Collection actions) { + protected void actionsActivated(Collection actions) { super.actionsActivated(actions); - for (ActionSlot action : actions) { - if (action.action instanceof ActionPowerLimiter) { - setMode(((ActionPowerLimiter) action.action).limit); + for (StatementSlot action : actions) { + if (action.statement instanceof ActionPowerLimiter) { + setMode(((ActionPowerLimiter) action.statement).limit); break; } } } @Override - public LinkedList getActions() { - LinkedList action = super.getActions(); + public LinkedList getActions() { + LinkedList action = super.getActions(); for (PowerMode mode : PowerMode.VALUES) { action.add(BuildCraftTransport.actionPowerLimiter[mode.ordinal()]); } diff --git a/common/buildcraft/transport/recipes/GateExpansionRecipe.java b/common/buildcraft/transport/recipes/GateExpansionRecipe.java index 35c1b302..17715795 100644 --- a/common/buildcraft/transport/recipes/GateExpansionRecipe.java +++ b/common/buildcraft/transport/recipes/GateExpansionRecipe.java @@ -9,7 +9,6 @@ package buildcraft.transport.recipes; import net.minecraft.item.ItemStack; - import buildcraft.BuildCraftTransport; import buildcraft.api.gates.IGateExpansion; import buildcraft.api.recipes.CraftingResult; diff --git a/common/buildcraft/transport/render/GateItemRenderer.java b/common/buildcraft/transport/render/GateItemRenderer.java index 2125120d..751d7c70 100644 --- a/common/buildcraft/transport/render/GateItemRenderer.java +++ b/common/buildcraft/transport/render/GateItemRenderer.java @@ -19,9 +19,7 @@ import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.item.EntityItem; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; - import net.minecraftforge.client.IItemRenderer; - import buildcraft.api.gates.IGateExpansion; import buildcraft.transport.gates.ItemGate; diff --git a/common/buildcraft/transport/render/PipeRendererTESR.java b/common/buildcraft/transport/render/PipeRendererTESR.java index 982135e9..01257e3a 100644 --- a/common/buildcraft/transport/render/PipeRendererTESR.java +++ b/common/buildcraft/transport/render/PipeRendererTESR.java @@ -29,12 +29,10 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; - import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; - import buildcraft.BuildCraftCore; import buildcraft.BuildCraftCore.RenderMode; import buildcraft.BuildCraftTransport; diff --git a/common/buildcraft/transport/schematics/SchematicPipe.java b/common/buildcraft/transport/schematics/SchematicPipe.java index 2413db52..ae483b60 100644 --- a/common/buildcraft/transport/schematics/SchematicPipe.java +++ b/common/buildcraft/transport/schematics/SchematicPipe.java @@ -21,8 +21,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.IStatement; -import buildcraft.api.gates.StatementManager; +import buildcraft.api.statements.IStatement; +import buildcraft.api.statements.StatementManager; import buildcraft.transport.BlockGenericPipe; import buildcraft.transport.Gate; import buildcraft.transport.Pipe; diff --git a/common/buildcraft/transport/statements/ActionEnergyPulsar.java b/common/buildcraft/transport/statements/ActionEnergyPulsar.java index 527a5c4e..650f4107 100644 --- a/common/buildcraft/transport/statements/ActionEnergyPulsar.java +++ b/common/buildcraft/transport/statements/ActionEnergyPulsar.java @@ -9,10 +9,13 @@ package buildcraft.transport.statements; import net.minecraft.client.renderer.texture.IIconRegister; -import buildcraft.core.statements.BCActionPassive; +import buildcraft.api.statements.IActionInternal; +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; +import buildcraft.core.statements.BCStatement; import buildcraft.core.utils.StringUtils; -public class ActionEnergyPulsar extends BCActionPassive { +public class ActionEnergyPulsar extends BCStatement implements IActionInternal { public ActionEnergyPulsar() { super("buildcraft:pulsar.constant", "buildcraft.pulser.constant"); @@ -27,4 +30,11 @@ public class ActionEnergyPulsar extends BCActionPassive { public void registerIcons(IIconRegister iconRegister) { icon = iconRegister.registerIcon("buildcraft:triggers/action_pulsar"); } + + @Override + public void actionActivate(IStatementContainer source, + IStatementParameter[] parameters) { + // TODO Auto-generated method stub + + } } diff --git a/common/buildcraft/transport/statements/ActionExtractionPreset.java b/common/buildcraft/transport/statements/ActionExtractionPreset.java index 2a42c79b..c793c0de 100644 --- a/common/buildcraft/transport/statements/ActionExtractionPreset.java +++ b/common/buildcraft/transport/statements/ActionExtractionPreset.java @@ -12,10 +12,14 @@ import java.util.Locale; import net.minecraft.client.renderer.texture.IIconRegister; import buildcraft.api.core.EnumColor; -import buildcraft.core.statements.BCActionPassive; +import buildcraft.api.statements.IActionInternal; +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; +import buildcraft.api.statements.ITriggerInternal; +import buildcraft.core.statements.BCStatement; import buildcraft.core.utils.StringUtils; -public class ActionExtractionPreset extends BCActionPassive { +public class ActionExtractionPreset extends BCStatement implements IActionInternal { public final EnumColor color; @@ -34,4 +38,10 @@ public class ActionExtractionPreset extends BCActionPassive { public void registerIcons(IIconRegister iconRegister) { icon = iconRegister.registerIcon("buildcraft:triggers/extraction_preset_" + color.name().toLowerCase(Locale.ENGLISH)); } + + @Override + public void actionActivate(IStatementContainer source, + IStatementParameter[] parameters) { + + } } diff --git a/common/buildcraft/transport/statements/ActionParameterSignal.java b/common/buildcraft/transport/statements/ActionParameterSignal.java index 198cb0d7..32803d82 100644 --- a/common/buildcraft/transport/statements/ActionParameterSignal.java +++ b/common/buildcraft/transport/statements/ActionParameterSignal.java @@ -15,9 +15,8 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.IIcon; import buildcraft.api.core.NetworkData; -import buildcraft.api.gates.IStatementParameter; -import buildcraft.api.gates.IStatement; -import buildcraft.api.gates.IStatementParameter; +import buildcraft.api.statements.IStatement; +import buildcraft.api.statements.IStatementParameter; import buildcraft.api.transport.IPipe; import buildcraft.api.transport.IPipeTile; import buildcraft.api.transport.PipeWire; diff --git a/common/buildcraft/transport/statements/ActionPipeColor.java b/common/buildcraft/transport/statements/ActionPipeColor.java index 0201b417..7259ec5d 100644 --- a/common/buildcraft/transport/statements/ActionPipeColor.java +++ b/common/buildcraft/transport/statements/ActionPipeColor.java @@ -12,10 +12,13 @@ import java.util.Locale; import net.minecraft.client.renderer.texture.IIconRegister; import buildcraft.api.core.EnumColor; -import buildcraft.core.statements.BCActionPassive; +import buildcraft.api.statements.IActionInternal; +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; +import buildcraft.core.statements.BCStatement; import buildcraft.core.utils.StringUtils; -public class ActionPipeColor extends BCActionPassive { +public class ActionPipeColor extends BCStatement implements IActionInternal { public final EnumColor color; @@ -34,4 +37,10 @@ public class ActionPipeColor extends BCActionPassive { public void registerIcons(IIconRegister iconRegister) { icon = iconRegister.registerIcon("buildcraft:triggers/color_" + color.name().toLowerCase(Locale.ENGLISH)); } + + @Override + public void actionActivate(IStatementContainer source, + IStatementParameter[] parameters) { + + } } diff --git a/common/buildcraft/transport/statements/ActionPipeDirection.java b/common/buildcraft/transport/statements/ActionPipeDirection.java index b4d80f8a..26063102 100644 --- a/common/buildcraft/transport/statements/ActionPipeDirection.java +++ b/common/buildcraft/transport/statements/ActionPipeDirection.java @@ -13,10 +13,13 @@ import java.util.Locale; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraftforge.common.util.ForgeDirection; import buildcraft.BuildCraftTransport; -import buildcraft.api.gates.IAction; -import buildcraft.core.statements.BCActionPassive; +import buildcraft.api.statements.IActionInternal; +import buildcraft.api.statements.IStatement; +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; +import buildcraft.core.statements.BCStatement; -public class ActionPipeDirection extends BCActionPassive { +public class ActionPipeDirection extends BCStatement implements IActionInternal { public final ForgeDirection direction; @@ -37,7 +40,14 @@ public class ActionPipeDirection extends BCActionPassive { } @Override - public IAction rotateLeft() { - return BuildCraftTransport.actionPipeDirection [direction.getRotation(ForgeDirection.UP).ordinal()]; + public IStatement rotateLeft() { + return BuildCraftTransport.actionPipeDirection[direction.getRotation(ForgeDirection.UP).ordinal()]; + } + + @Override + public void actionActivate(IStatementContainer source, + IStatementParameter[] parameters) { + // TODO Auto-generated method stub + } } diff --git a/common/buildcraft/transport/statements/ActionPowerLimiter.java b/common/buildcraft/transport/statements/ActionPowerLimiter.java index 36432bda..e6b82222 100644 --- a/common/buildcraft/transport/statements/ActionPowerLimiter.java +++ b/common/buildcraft/transport/statements/ActionPowerLimiter.java @@ -11,10 +11,13 @@ package buildcraft.transport.statements; import java.util.Locale; import net.minecraft.client.renderer.texture.IIconRegister; +import buildcraft.api.statements.IActionInternal; +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; import buildcraft.core.PowerMode; -import buildcraft.core.statements.BCActionPassive; +import buildcraft.core.statements.BCStatement; -public class ActionPowerLimiter extends BCActionPassive { +public class ActionPowerLimiter extends BCStatement implements IActionInternal { public final PowerMode limit; @@ -33,4 +36,10 @@ public class ActionPowerLimiter extends BCActionPassive { public void registerIcons(IIconRegister iconRegister) { icon = iconRegister.registerIcon("buildcraft:triggers/trigger_limiter_" + limit.name().toLowerCase(Locale.ENGLISH)); } + + @Override + public void actionActivate(IStatementContainer source, + IStatementParameter[] parameters) { + + } } diff --git a/common/buildcraft/transport/statements/ActionRedstoneFaderOutput.java b/common/buildcraft/transport/statements/ActionRedstoneFaderOutput.java index 83b8d44b..09ac0733 100644 --- a/common/buildcraft/transport/statements/ActionRedstoneFaderOutput.java +++ b/common/buildcraft/transport/statements/ActionRedstoneFaderOutput.java @@ -12,12 +12,14 @@ 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.IStatementParameter; -import buildcraft.core.statements.BCActionPassive; +import buildcraft.api.statements.IActionInternal; +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; +import buildcraft.core.statements.BCStatement; import buildcraft.core.statements.StatementParameterRedstoneGateSideOnly; import buildcraft.core.utils.StringUtils; -public class ActionRedstoneFaderOutput extends BCActionPassive { +public class ActionRedstoneFaderOutput extends BCStatement implements IActionInternal { public final int level; @@ -59,4 +61,10 @@ public class ActionRedstoneFaderOutput extends BCActionPassive { public int maxParameters() { return 1; } + + @Override + public void actionActivate(IStatementContainer source, + IStatementParameter[] parameters) { + + } } diff --git a/common/buildcraft/transport/statements/ActionSignalOutput.java b/common/buildcraft/transport/statements/ActionSignalOutput.java index fea3f2c1..85aa6610 100644 --- a/common/buildcraft/transport/statements/ActionSignalOutput.java +++ b/common/buildcraft/transport/statements/ActionSignalOutput.java @@ -10,15 +10,19 @@ package buildcraft.transport.statements; import java.util.Locale; -import buildcraft.api.gates.IStatementParameter; -import buildcraft.api.gates.IGate; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.ForgeDirection; +import buildcraft.api.statements.IActionInternal; +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; +import buildcraft.api.transport.IPipeTile; import buildcraft.api.transport.PipeWire; -import buildcraft.core.statements.BCActionActive; +import buildcraft.core.statements.BCStatement; import buildcraft.core.statements.StatementIconProvider; import buildcraft.core.utils.StringUtils; import buildcraft.transport.Gate; -public class ActionSignalOutput extends BCActionActive { +public class ActionSignalOutput extends BCStatement implements IActionInternal { public PipeWire color; @@ -59,8 +63,8 @@ public class ActionSignalOutput extends BCActionActive { } @Override - public void actionActivate(IGate iGate, IStatementParameter[] parameters) { - Gate gate = (Gate) iGate; + public void actionActivate(IStatementContainer container, IStatementParameter[] parameters) { + Gate gate = (Gate) container; gate.broadcastSignal(color); diff --git a/common/buildcraft/transport/statements/ActionSingleEnergyPulse.java b/common/buildcraft/transport/statements/ActionSingleEnergyPulse.java index 0a438ef0..ace74863 100644 --- a/common/buildcraft/transport/statements/ActionSingleEnergyPulse.java +++ b/common/buildcraft/transport/statements/ActionSingleEnergyPulse.java @@ -9,10 +9,13 @@ package buildcraft.transport.statements; import net.minecraft.client.renderer.texture.IIconRegister; -import buildcraft.core.statements.BCActionPassive; +import buildcraft.api.statements.IActionInternal; +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; +import buildcraft.core.statements.BCStatement; import buildcraft.core.utils.StringUtils; -public class ActionSingleEnergyPulse extends BCActionPassive { +public class ActionSingleEnergyPulse extends BCStatement implements IActionInternal { public ActionSingleEnergyPulse() { super("buildcraft:pulsar.single", "buildcraft.pulser.single"); @@ -27,4 +30,10 @@ public class ActionSingleEnergyPulse extends BCActionPassive { public void registerIcons(IIconRegister iconRegister) { icon = iconRegister.registerIcon("buildcraft:triggers/action_single_pulsar"); } + + @Override + public void actionActivate(IStatementContainer source, + IStatementParameter[] parameters) { + + } } diff --git a/common/buildcraft/transport/statements/ActionValve.java b/common/buildcraft/transport/statements/ActionValve.java index 60675153..3a0409d1 100644 --- a/common/buildcraft/transport/statements/ActionValve.java +++ b/common/buildcraft/transport/statements/ActionValve.java @@ -11,17 +11,21 @@ package buildcraft.transport.statements; import java.util.Locale; import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; -import buildcraft.api.gates.IStatementParameter; -import buildcraft.api.gates.IGate; +import buildcraft.api.statements.IActionInternal; +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; import buildcraft.api.transport.IPipe; -import buildcraft.core.statements.BCActionActive; +import buildcraft.api.transport.IPipeTile; +import buildcraft.core.statements.BCStatement; import buildcraft.core.statements.StatementParameterDirection; import buildcraft.core.utils.StringUtils; +import buildcraft.transport.Gate; import buildcraft.transport.Pipe; import buildcraft.transport.PipeTransport; -public class ActionValve extends BCActionActive { +public class ActionValve extends BCStatement implements IActionInternal { public enum ValveState { OPEN(true, true), @@ -79,8 +83,8 @@ public class ActionValve extends BCActionActive { } @Override - public void actionActivate(IGate gate, IStatementParameter[] parameters) { - IPipe pipe = gate.getPipe(); + public void actionActivate(IStatementContainer container, IStatementParameter[] parameters) { + IPipe pipe = ((Gate) container).getPipe(); if (pipe != null && pipe instanceof Pipe) { PipeTransport transport = ((Pipe) pipe).transport; diff --git a/common/buildcraft/transport/statements/TriggerClockTimer.java b/common/buildcraft/transport/statements/TriggerClockTimer.java index d393f482..9e62f222 100644 --- a/common/buildcraft/transport/statements/TriggerClockTimer.java +++ b/common/buildcraft/transport/statements/TriggerClockTimer.java @@ -11,10 +11,13 @@ package buildcraft.transport.statements; import java.util.Locale; import net.minecraft.client.renderer.texture.IIconRegister; -import buildcraft.core.statements.BCTrigger; +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; +import buildcraft.api.statements.ITriggerInternal; +import buildcraft.core.statements.BCStatement; import buildcraft.core.utils.StringUtils; -public class TriggerClockTimer extends BCTrigger { +public class TriggerClockTimer extends BCStatement implements ITriggerInternal { public enum Time { @@ -43,4 +46,10 @@ public class TriggerClockTimer extends BCTrigger { public void registerIcons(IIconRegister iconRegister) { icon = iconRegister.registerIcon("buildcraft:triggers/trigger_timer_" + time.name().toLowerCase(Locale.ENGLISH)); } + + @Override + public boolean isTriggerActive(IStatementContainer source, + IStatementParameter[] parameters) { + return false; + } } diff --git a/common/buildcraft/transport/statements/TriggerParameterSignal.java b/common/buildcraft/transport/statements/TriggerParameterSignal.java index aefb551b..a2f6f3f5 100644 --- a/common/buildcraft/transport/statements/TriggerParameterSignal.java +++ b/common/buildcraft/transport/statements/TriggerParameterSignal.java @@ -15,9 +15,8 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.IIcon; import buildcraft.api.core.NetworkData; -import buildcraft.api.gates.IStatement; -import buildcraft.api.gates.IStatementParameter; -import buildcraft.api.gates.IStatementParameter; +import buildcraft.api.statements.IStatement; +import buildcraft.api.statements.IStatementParameter; import buildcraft.api.transport.IPipeTile; import buildcraft.api.transport.PipeWire; import buildcraft.core.statements.StatementIconProvider; diff --git a/common/buildcraft/transport/statements/TriggerPipeContents.java b/common/buildcraft/transport/statements/TriggerPipeContents.java index ac5fdfb4..9417dd10 100644 --- a/common/buildcraft/transport/statements/TriggerPipeContents.java +++ b/common/buildcraft/transport/statements/TriggerPipeContents.java @@ -18,9 +18,12 @@ import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; import buildcraft.api.gates.IGate; -import buildcraft.api.gates.IStatementParameter; +import buildcraft.api.statements.IStatement; +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; +import buildcraft.api.statements.ITriggerInternal; import buildcraft.core.inventory.StackHelper; -import buildcraft.core.statements.BCTrigger; +import buildcraft.core.statements.BCStatement; import buildcraft.core.utils.StringUtils; import buildcraft.transport.Pipe; import buildcraft.transport.PipeTransportFluids; @@ -28,7 +31,7 @@ import buildcraft.transport.PipeTransportItems; import buildcraft.transport.PipeTransportPower; import buildcraft.transport.TravelingItem; -public class TriggerPipeContents extends BCTrigger { +public class TriggerPipeContents extends BCStatement implements ITriggerInternal { public enum PipeContents { empty, @@ -37,7 +40,7 @@ public class TriggerPipeContents extends BCTrigger { containsEnergy, requestsEnergy, tooMuchEnergy; - public BCTrigger trigger; + public ITriggerInternal trigger; }; private PipeContents kind; @@ -64,8 +67,12 @@ public class TriggerPipeContents extends BCTrigger { } @Override - public boolean isTriggerActive(IGate gate, IStatementParameter[] parameters) { - Pipe pipe = (Pipe) gate.getPipe(); + public boolean isTriggerActive(IStatementContainer container, IStatementParameter[] parameters) { + if (!(container instanceof IGate)) { + return false; + } + + Pipe pipe = (Pipe) ((IGate) container).getPipe(); IStatementParameter parameter = parameters[0]; if (pipe.transport instanceof PipeTransportItems) { diff --git a/common/buildcraft/transport/statements/TriggerPipeSignal.java b/common/buildcraft/transport/statements/TriggerPipeSignal.java index 63c7b21f..644ad3db 100644 --- a/common/buildcraft/transport/statements/TriggerPipeSignal.java +++ b/common/buildcraft/transport/statements/TriggerPipeSignal.java @@ -11,14 +11,16 @@ package buildcraft.transport.statements; import java.util.Locale; import buildcraft.api.gates.IGate; -import buildcraft.api.gates.IStatementParameter; +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; +import buildcraft.api.statements.ITriggerInternal; import buildcraft.api.transport.PipeWire; -import buildcraft.core.statements.BCTrigger; +import buildcraft.core.statements.BCStatement; import buildcraft.core.statements.StatementIconProvider; import buildcraft.core.utils.StringUtils; import buildcraft.transport.Pipe; -public class TriggerPipeSignal extends BCTrigger { +public class TriggerPipeSignal extends BCStatement implements ITriggerInternal { boolean active; PipeWire color; @@ -42,8 +44,12 @@ public class TriggerPipeSignal extends BCTrigger { } @Override - public boolean isTriggerActive(IGate gate, IStatementParameter[] parameters) { - Pipe pipe = (Pipe) gate.getPipe(); + public boolean isTriggerActive(IStatementContainer container, IStatementParameter[] parameters) { + if (!(container instanceof IGate)) { + return false; + } + + Pipe pipe = (Pipe) ((IGate) container).getPipe(); if (active) { if (pipe.signalStrength[color.ordinal()] == 0) { diff --git a/common/buildcraft/transport/statements/TriggerRedstoneFaderInput.java b/common/buildcraft/transport/statements/TriggerRedstoneFaderInput.java index d3245ea7..172cc744 100644 --- a/common/buildcraft/transport/statements/TriggerRedstoneFaderInput.java +++ b/common/buildcraft/transport/statements/TriggerRedstoneFaderInput.java @@ -12,13 +12,15 @@ import net.minecraft.client.renderer.texture.IIconRegister; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import buildcraft.api.gates.IGate; -import buildcraft.api.gates.IStatementParameter; -import buildcraft.core.statements.BCTrigger; +import buildcraft.api.statements.IStatementContainer; +import buildcraft.api.statements.IStatementParameter; +import buildcraft.api.statements.ITriggerInternal; +import buildcraft.core.statements.BCStatement; import buildcraft.core.statements.StatementParameterRedstoneGateSideOnly; import buildcraft.core.utils.StringUtils; import buildcraft.transport.TileGenericPipe; -public class TriggerRedstoneFaderInput extends BCTrigger { +public class TriggerRedstoneFaderInput extends BCStatement implements ITriggerInternal { public final int level; @@ -34,7 +36,12 @@ public class TriggerRedstoneFaderInput extends BCTrigger { } @Override - public boolean isTriggerActive(IGate gate, IStatementParameter[] parameters) { + public boolean isTriggerActive(IStatementContainer container, IStatementParameter[] parameters) { + if (!(container instanceof IGate)) { + return false; + } + + IGate gate = (IGate) container; TileGenericPipe tile = (TileGenericPipe) gate.getPipe().getTile(); int inputLevel = tile.redstoneInput; if (parameters.length > 0 && parameters[0] instanceof StatementParameterRedstoneGateSideOnly &&