Further work on refactoring the Gate API for #2107

This commit is contained in:
asiekierka 2014-10-28 16:36:06 +01:00
parent 8728885c2c
commit 4492802f25
130 changed files with 969 additions and 801 deletions

View file

@ -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<ITrigger> list) {
public void addTriggers(List<ITriggerInternal> list) {
}
public void addActions(List<IAction> list) {
public void addActions(List<IActionInternal> list) {
}
public void writeToNBT(NBTTagCompound nbt) {

View file

@ -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();
}

View file

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

View file

@ -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 {

View file

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

View file

@ -0,0 +1,7 @@
package buildcraft.api.statements;
public interface IActionInternal extends IStatement {
void actionActivate(IStatementContainer source, IStatementParameter[] parameters);
}

View file

@ -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<IAction> getInternalActions(TileEntity tile);
Collection<IActionInternal> getInternalActions(IStatementContainer container);
/**
* Returns the list of actions available to a gate next to the given block.
*/
Collection<IAction> getExternalActions(ForgeDirection side, TileEntity tile);
Collection<IActionExternal> getExternalActions(ForgeDirection side, TileEntity tile);
}

View file

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

View file

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

View file

@ -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();
}

View file

@ -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 {

View file

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

View file

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

View file

@ -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<ITrigger> getInternalTriggers(TileEntity tile);
Collection<ITriggerInternal> getInternalTriggers(IStatementContainer container);
/**
* Returns the list of triggers available to a gate next to the given block.
*/
Collection<ITrigger> getExternalTriggers(ForgeDirection side, TileEntity tile);
Collection<ITriggerExternal> getExternalTriggers(ForgeDirection side, TileEntity tile);
}

View file

@ -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<? extends IStatementParameter> param) {
parameters.put(createParameter(param).getUniqueTag(), param);
}
@Deprecated
public static void registerParameterClass(String name, Class<? extends IStatementParameter> param) {
parameters.put(name, param);
}
public static List<ITrigger> getExternalTriggers(ForgeDirection side, TileEntity entity) {
List<ITrigger> result = new LinkedList<ITrigger>();
public static List<ITriggerExternal> getExternalTriggers(ForgeDirection side, TileEntity entity) {
List<ITriggerExternal> result = new LinkedList<ITriggerExternal>();
for (ITriggerProvider provider : triggerProviders) {
Collection<ITrigger> toAdd = provider.getExternalTriggers(side, entity);
Collection<ITriggerExternal> 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<IAction> getExternalActions(ForgeDirection side, TileEntity entity) {
List<IAction> result = new LinkedList<IAction>();
public static List<IActionExternal> getExternalActions(ForgeDirection side, TileEntity entity) {
List<IActionExternal> result = new LinkedList<IActionExternal>();
for (IActionProvider provider : actionProviders) {
Collection<IAction> toAdd = provider.getExternalActions(side, entity);
Collection<IActionExternal> 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<ITrigger> getInternalTriggers(TileEntity tile) {
List<ITrigger> result = new LinkedList<ITrigger>();
public static List<ITriggerInternal> getInternalTriggers(IStatementContainer container) {
List<ITriggerInternal> result = new LinkedList<ITriggerInternal>();
for (ITriggerProvider provider : triggerProviders) {
Collection<ITrigger> toAdd = provider.getInternalTriggers(tile);
Collection<ITriggerInternal> 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<IAction> getInternalActions(TileEntity tile) {
List<IAction> result = new LinkedList<IAction>();
public static List<IActionInternal> getInternalActions(IStatementContainer container) {
List<IActionInternal> result = new LinkedList<IActionInternal>();
for (IActionProvider provider : actionProviders) {
Collection<IAction> toAdd = provider.getInternalActions(tile);
Collection<IActionInternal> toAdd = provider.getInternalActions(container);
if (toAdd != null) {
for (IAction t : toAdd) {
for (IActionInternal t : toAdd) {
if (!result.contains(t)) {
result.add(t);
}

View file

@ -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

View file

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

View file

@ -0,0 +1,5 @@
package buildcraft.api.tiles;
public interface IHasWork {
boolean hasWork();
}

View file

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

View file

@ -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();
}

View file

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

View file

@ -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);

View file

@ -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<Integer> excessiveOilBiomeIDs = new HashSet<Integer>();
public static Set<Integer> excludeOilBiomeIDs = new HashSet<Integer>();
public static TreeMap<BlockIndex, Integer> saturationStored = new TreeMap<BlockIndex, Integer>();
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;

View file

@ -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) {

View file

@ -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<PipeRecipe> pipeRecipes = new LinkedList<PipeRecipe>();

View file

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

View file

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

View file

@ -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) {
}
}

View file

@ -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<String, ActionFiller> actionMap = new HashMap<String, ActionFiller>();
@Override
public Collection<IAction> getInternalActions(TileEntity tile) {
public Collection<IActionInternal> getInternalActions(IStatementContainer container) {
return null;
}
@Override
public Collection<IAction> getExternalActions(ForgeDirection side, TileEntity tile) {
LinkedList<IAction> actions = new LinkedList<IAction>();
public Collection<IActionExternal> getExternalActions(ForgeDirection side, TileEntity tile) {
LinkedList<IActionExternal> actions = new LinkedList<IActionExternal>();
if (tile instanceof TileFiller) {
for (IFillerPattern p : FillerManager.registry.getPatterns()) {
if (p instanceof FillerPattern) {

View file

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

View file

@ -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.

View file

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

View file

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

View file

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

View file

@ -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();
}
}

View file

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

View file

@ -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) {

View file

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

View file

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

View file

@ -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) {
}
}

View file

@ -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) {
}
}

View file

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

View file

@ -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) {
}
}

11
common/buildcraft/core/statements/BCStatement.java Executable file → Normal file
View file

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

View file

@ -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();
}
}

View file

@ -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<IAction> getInternalActions(TileEntity tile) {
return null;
public Collection<IActionInternal> getInternalActions(IStatementContainer container) {
LinkedList<IActionInternal> res = new LinkedList<IActionInternal>();
if (container.getTile() instanceof IPipeTile) {
res.add(BuildCraftCore.actionRedstone);
}
return res;
}
@Override
public Collection<IAction> getExternalActions(ForgeDirection side, TileEntity tile) {
LinkedList<IAction> res = new LinkedList<IAction>();
res.add(BuildCraftCore.actionRedstone);
public Collection<IActionExternal> getExternalActions(ForgeDirection side, TileEntity tile) {
LinkedList<IActionExternal> res = new LinkedList<IActionExternal>();
try {
if (tile instanceof IMachine) {

View file

@ -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<ITrigger> getExternalTriggers(ForgeDirection side, TileEntity tile) {
LinkedList<ITrigger> res = new LinkedList<ITrigger>();
public LinkedList<ITriggerExternal> getExternalTriggers(ForgeDirection side, TileEntity tile) {
LinkedList<ITriggerExternal> res = new LinkedList<ITriggerExternal>();
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<ITrigger> getInternalTriggers(TileEntity pipe) {
public LinkedList<ITriggerInternal> getInternalTriggers(IStatementContainer container) {
return null;
}
}

View file

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

View file

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

View file

@ -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.

View file

@ -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) {

View file

@ -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) {

View file

@ -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) {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -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<ITrigger> getInternalTriggers(TileEntity pipe) {
public Collection<ITriggerInternal> getInternalTriggers(IStatementContainer container) {
return null;
}
@Override
public Collection<ITrigger> getExternalTriggers(ForgeDirection side, TileEntity tile) {
LinkedList<ITrigger> triggers = new LinkedList<ITrigger>();
public Collection<ITriggerExternal> getExternalTriggers(ForgeDirection side, TileEntity tile) {
LinkedList<ITriggerExternal> triggers = new LinkedList<ITriggerExternal>();
if (tile instanceof TileEngine) {
triggers.add(BuildCraftEnergy.triggerBlueEngineHeat);

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -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) {

View file

@ -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) {

View file

@ -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<ItemStack> getGateFilterStacks(IDockingStation station) {
ArrayList<ItemStack> result = new ArrayList<ItemStack>();
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) {
}
}

View file

@ -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();

View file

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

View file

@ -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) {
}
}

View file

@ -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) {
}
}

View file

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

View file

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

View file

@ -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) {
}
}

View file

@ -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) {
}
}

View file

@ -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) {
}
}

View file

@ -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) {
}
}

View file

@ -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) {
}
}

View file

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

View file

@ -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) {
}
}

View file

@ -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<IAction> getInternalActions(TileEntity tile) {
public Collection<IActionInternal> getInternalActions(IStatementContainer container) {
TileEntity tile = container.getTile();
if (!(tile instanceof TileGenericPipe)) {
return null;
}
LinkedList<IAction> result = new LinkedList<IAction>();
LinkedList<IActionInternal> result = new LinkedList<IActionInternal>();
ArrayList<DockingStation> stations = new ArrayList<DockingStation>();
@ -93,7 +95,7 @@ public class RobotsActionProvider implements IActionProvider {
}
@Override
public Collection<IAction> getExternalActions(ForgeDirection side, TileEntity tile) {
public Collection<IActionExternal> getExternalActions(ForgeDirection side, TileEntity tile) {
return null;
}

View file

@ -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<ITrigger> getInternalTriggers(TileEntity tile) {
LinkedList<ITrigger> result = new LinkedList<ITrigger>();
public Collection<ITriggerInternal> getInternalTriggers(IStatementContainer container) {
LinkedList<ITriggerInternal> result = new LinkedList<ITriggerInternal>();
TileEntity tile = container.getTile();
if (!(tile instanceof TileGenericPipe)) {
return result;
@ -51,7 +52,7 @@ public class RobotsTriggerProvider implements ITriggerProvider {
}
@Override
public Collection<ITrigger> getExternalTriggers(ForgeDirection side, TileEntity tile) {
public Collection<ITriggerExternal> getExternalTriggers(ForgeDirection side, TileEntity tile) {
return null;
}

View file

@ -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 {

View file

@ -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 {

View file

@ -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) {

View file

@ -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<IGateExpansion, GateExpansionController> 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<ActionSlot> activeActions = new ArrayList<ActionSlot>();
public ArrayList<StatementSlot> activeActions = new ArrayList<StatementSlot>();
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<ITrigger> triggerList = getAllValidTriggers();
List<IAction> actionList = getAllValidActions();
List<IStatement> triggerList = getAllValidTriggers();
List<IStatement> 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<ActionSlot>();
activeActions = new ArrayList<StatementSlot>();
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<ITrigger> list) {
public void addTriggers(List<ITriggerInternal> 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<ITrigger> getAllValidTriggers() {
ArrayList<ITrigger> allTriggers = new ArrayList<ITrigger>(64);
allTriggers.addAll(StatementManager.getInternalTriggers(pipe.container));
public List<IStatement> getAllValidTriggers() {
ArrayList<IStatement> allTriggers = new ArrayList<IStatement>(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<IAction> list) {
public void addActions(List<IActionInternal> 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<IAction> getAllValidActions() {
ArrayList<IAction> allActions = new ArrayList<IAction>(64);
allActions.addAll(StatementManager.getInternalActions(pipe.container));
public List<IStatement> getAllValidActions() {
ArrayList<IStatement> allActions = new ArrayList<IStatement>(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;
}
}

View file

@ -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<T extends PipeTransport> implements IDropControlInven
return result;
}
public boolean isTriggerActive(ITrigger trigger) {
return false;
}
public LinkedList<IAction> getActions() {
LinkedList<IAction> result = new LinkedList<IAction>();
public LinkedList<IActionInternal> getActions() {
LinkedList<IActionInternal> result = new LinkedList<IActionInternal>();
for (ValveState state : ValveState.VALUES) {
result.add(BuildCraftTransport.actionValve[state.ordinal()]);
@ -552,7 +548,7 @@ public abstract class Pipe<T extends PipeTransport> implements IDropControlInven
container.scheduleRenderUpdate();
}
protected void actionsActivated(Collection<ActionSlot> actions) {
protected void actionsActivated(Collection<StatementSlot> actions) {
}
public TileGenericPipe getContainer() {
@ -659,10 +655,14 @@ public abstract class Pipe<T extends PipeTransport> 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) {

View file

@ -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<IAction> getInternalActions(TileEntity tile) {
LinkedList<IAction> result = new LinkedList<IAction>();
public Collection<IActionInternal> getInternalActions(IStatementContainer container) {
LinkedList<IActionInternal> result = new LinkedList<IActionInternal>();
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<IAction> getExternalActions(ForgeDirection side, TileEntity tile) {
public Collection<IActionExternal> getExternalActions(ForgeDirection side, TileEntity tile) {
return null;
}

View file

@ -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 *
*/

View file

@ -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

View file

@ -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;
*

View file

@ -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<ITrigger> getInternalTriggers(TileEntity tile) {
LinkedList<ITrigger> result = new LinkedList<ITrigger>();
public LinkedList<ITriggerInternal> getInternalTriggers(IStatementContainer container) {
LinkedList<ITriggerInternal> result = new LinkedList<ITriggerInternal>();
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<ITrigger> getExternalTriggers(ForgeDirection side, TileEntity tile) {
public LinkedList<ITriggerExternal> getExternalTriggers(ForgeDirection side, TileEntity tile) {
return null;
}
}

View file

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

View file

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

View file

@ -15,7 +15,7 @@ import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.transport.Gate;
import buildcraft.transport.Pipe;
public class ActionIterator implements Iterable<ActionSlot> {
public class ActionIterator implements Iterable<StatementSlot> {
private Pipe pipe;
@ -24,15 +24,15 @@ public class ActionIterator implements Iterable<ActionSlot> {
}
@Override
public Iterator<ActionSlot> iterator() {
public Iterator<StatementSlot> iterator() {
return new It();
}
private class It implements Iterator<ActionSlot> {
private class It implements Iterator<StatementSlot> {
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<ActionSlot> {
}
@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<ActionSlot> {
}
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;

View file

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

View file

@ -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<IAction> list) {
public void addActions(List<IActionInternal> list) {
super.addActions(list);
list.add(BuildCraftTransport.actionEnergyPulser);
list.add(BuildCraftTransport.actionSingleEnergyPulse);

View file

@ -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<ITrigger> list) {
public void addTriggers(List<ITriggerInternal> list) {
super.addTriggers(list);
list.addAll(Arrays.asList(BuildCraftTransport.triggerRedstoneLevel));
}
@Override
public void addActions(List<IAction> list) {
public void addActions(List<IActionInternal> list) {
super.addActions(list);
list.addAll(Arrays.asList(BuildCraftTransport.actionRedstoneLevel));
}

View file

@ -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<ITrigger> list) {
public void addTriggers(List<ITriggerInternal> list) {
super.addTriggers(list);
for (Time time : TriggerClockTimer.Time.VALUES) {
list.add(BuildCraftTransport.triggerTimer[time.ordinal()]);

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