From 73198c4a7bdcc956dad5014587f128f2c67206d7 Mon Sep 17 00:00:00 2001 From: SpaceToad Date: Sun, 17 Aug 2014 11:37:30 +0200 Subject: [PATCH] Implemented filters for crafting robots. Crafting robots now only answers to stack requests. --- .../assets/buildcraft/lang/en_US.lang | 2 +- .../items/triggers/action_robot_craft.png | Bin 590 -> 0 bytes .../triggers/action_station_allow_craft.png | Bin 0 -> 586 bytes common/buildcraft/BuildCraftSilicon.java | 4 +- common/buildcraft/core/TileBuffer.java | 18 +++----- .../robots/AIRobotCraftAssemblyTable.java | 7 ++++ .../core/robots/AIRobotCraftFurnace.java | 11 ++++- .../core/robots/AIRobotCraftWorkbench.java | 7 ++++ .../core/robots/AIRobotGotoStationToLoad.java | 22 +--------- .../buildcraft/core/robots/AIRobotLoad.java | 20 ++------- .../robots/AIRobotSearchStackRequest.java | 23 +++++------ .../buildcraft/core/robots/EntityRobot.java | 3 +- .../core/robots/boards/BoardRobotCrafter.java | 39 ++++-------------- .../robots/boards/BoardRobotDelivery.java | 4 +- .../silicon/statements/ActionRobotFilter.java | 19 +++++++++ ...raft.java => ActionStationAllowCraft.java} | 10 ++--- .../statements/RobotsActionProvider.java | 25 ++++++----- .../transport/ItemRobotStation.java | 4 +- 18 files changed, 101 insertions(+), 117 deletions(-) delete mode 100755 buildcraft_resources/assets/buildcraft/textures/items/triggers/action_robot_craft.png create mode 100755 buildcraft_resources/assets/buildcraft/textures/items/triggers/action_station_allow_craft.png rename common/buildcraft/silicon/statements/{ActionRobotCraft.java => ActionStationAllowCraft.java} (75%) diff --git a/buildcraft_resources/assets/buildcraft/lang/en_US.lang b/buildcraft_resources/assets/buildcraft/lang/en_US.lang index de02b70f..686f67c5 100755 --- a/buildcraft_resources/assets/buildcraft/lang/en_US.lang +++ b/buildcraft_resources/assets/buildcraft/lang/en_US.lang @@ -66,7 +66,7 @@ gate.action.station.provide_items=Provide Items gate.action.station.accept_items=Accept Items gate.action.station.request_items=Request Items gate.action.station.drop_items_in_pipe=Drop Items In Pipe -gate.action.station.craft=Craft +gate.action.station.allow_craft=Allow Craft gate.action.station.provide_machine_request=Provide Computed Items gate.action.station.accept_fluids=Accept Fluids gate.action.station.povide_fluids=Provide Fluids diff --git a/buildcraft_resources/assets/buildcraft/textures/items/triggers/action_robot_craft.png b/buildcraft_resources/assets/buildcraft/textures/items/triggers/action_robot_craft.png deleted file mode 100755 index cddd714cbe6aafd9e59454817de6a1ed3968165a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 590 zcmV-U0Jq^sh!Ua_ z5FDI>lVlL7bP*$nREHA+u~aL?gfoyh2nhyq=}$C}b2tqZTS(|Pe(=8E^S+;wPN&(; z3~#rzEX!-R+e9J}gb-9J74rGK(zk&Sf>luk0w6xJN_=FMBVvQhqq}~Ds9_Q{OkS*f1mLB;ft0_Pv0_|W z%+Qh-Xi3SY><|b9{_kL`V0qpV`)vyjY^UOdN`9%SkDT2H(wJAMaq({aws zPO*^80#L2jsMc#Zj>C_Zi{m(m(Eweq%ZZD32nJQG!+RLhgTBF50f4CqOikdGvYbDD zl+o%EQwL1kru@_VFs3HxdR;$)sR;nQQkEylv&vu7TMysR@f0#QPqOy8#_8EZJ^WhB c#cfJ{13sm&)#y5`uK)l507*qoM6N<$g8qmCM*si- diff --git a/buildcraft_resources/assets/buildcraft/textures/items/triggers/action_station_allow_craft.png b/buildcraft_resources/assets/buildcraft/textures/items/triggers/action_station_allow_craft.png new file mode 100755 index 0000000000000000000000000000000000000000..ca9bcd15f875749cec3bf020fc718cc0874882b4 GIT binary patch literal 586 zcmV-Q0=4~#P)Cu%}PAdKJWvhw%R4VX}$yC_E&5k-DbP+2GsOcg|io#d_h60xbz=Oh) z9&Z?k;!1AN#HUZ@8S8BD^UG^WXO0eL%h}_V?O^DF`-?BT`EqKLa%z)HVw>fq$B}~5 zV+J!*(7`hGT>t<8 literal 0 HcmV?d00001 diff --git a/common/buildcraft/BuildCraftSilicon.java b/common/buildcraft/BuildCraftSilicon.java index 889fc4fa..d815dea6 100644 --- a/common/buildcraft/BuildCraftSilicon.java +++ b/common/buildcraft/BuildCraftSilicon.java @@ -85,7 +85,6 @@ import buildcraft.silicon.network.PacketHandlerSilicon; import buildcraft.silicon.recipes.AdvancedFacadeRecipe; import buildcraft.silicon.recipes.GateExpansionRecipe; import buildcraft.silicon.recipes.GateLogicSwapRecipe; -import buildcraft.silicon.statements.ActionRobotCraft; import buildcraft.silicon.statements.ActionRobotFilter; import buildcraft.silicon.statements.ActionRobotGotoStation; import buildcraft.silicon.statements.ActionRobotWakeUp; @@ -93,6 +92,7 @@ import buildcraft.silicon.statements.ActionRobotWorkInArea; import buildcraft.silicon.statements.ActionStationAcceptFluids; import buildcraft.silicon.statements.ActionStationAcceptItemsInv; import buildcraft.silicon.statements.ActionStationAcceptItemsPipe; +import buildcraft.silicon.statements.ActionStationAllowCraft; import buildcraft.silicon.statements.ActionStationForbidRobot; import buildcraft.silicon.statements.ActionStationProvideFluids; import buildcraft.silicon.statements.ActionStationProvideItems; @@ -131,7 +131,7 @@ public class BuildCraftSilicon extends BuildCraftMod { public static IAction actionRobotWakeUp = new ActionRobotWakeUp(); public static IAction actionRobotWorkInArea = new ActionRobotWorkInArea(); public static IAction actionRobotFilter = new ActionRobotFilter(); - public static IAction actionRobotCraft = new ActionRobotCraft(); + public static IAction actionRobotAllowCraft = new ActionStationAllowCraft(); public static IAction actionStationRequestItems = new ActionStationRequestItems(); public static IAction actionStationAcceptItems = new ActionStationAcceptItemsInv(); public static IAction actionStationProvideItems = new ActionStationProvideItems(); diff --git a/common/buildcraft/core/TileBuffer.java b/common/buildcraft/core/TileBuffer.java index 907d85e6..1331ddb2 100644 --- a/common/buildcraft/core/TileBuffer.java +++ b/common/buildcraft/core/TileBuffer.java @@ -44,10 +44,10 @@ public final class TileBuffer { return; } - block = world.getBlock(this.x, this.y, this.z); + block = world.getBlock(x, y, z); - if (block != null && block.hasTileEntity(world.getBlockMetadata(this.x, this.y, this.z))) { - tile = world.getTileEntity(this.x, this.y, this.z); + if (block != null && block.hasTileEntity(world.getBlockMetadata(x, y, z))) { + tile = world.getTileEntity(x, y, z); } } @@ -59,19 +59,11 @@ public final class TileBuffer { public Block getBlock() { - if (tile != null && !tile.isInvalid()) { - return block; - } - - if (tracker.markTimeIfDelay(world)) { + if ((tile != null && tile.isInvalid()) || (tile == null && tracker.markTimeIfDelay(world))) { refresh(); - - if (tile != null && !tile.isInvalid()) { - return block; - } } - return null; + return block; } public TileEntity getTile() { diff --git a/common/buildcraft/core/robots/AIRobotCraftAssemblyTable.java b/common/buildcraft/core/robots/AIRobotCraftAssemblyTable.java index bde7e96c..6e80f5ba 100755 --- a/common/buildcraft/core/robots/AIRobotCraftAssemblyTable.java +++ b/common/buildcraft/core/robots/AIRobotCraftAssemblyTable.java @@ -31,6 +31,8 @@ import buildcraft.core.inventory.filters.ArrayStackFilter; import buildcraft.core.inventory.filters.IStackFilter; import buildcraft.silicon.BlockLaserTable; import buildcraft.silicon.TileAssemblyTable; +import buildcraft.silicon.statements.ActionRobotFilter; +import buildcraft.silicon.statements.ActionStationAllowCraft; public class AIRobotCraftAssemblyTable extends AIRobotCraftGeneric { @@ -207,6 +209,11 @@ public class AIRobotCraftAssemblyTable extends AIRobotCraftGeneric { @Override public boolean matches(DockingStation station) { + if (!ActionRobotFilter.canInteractWithItem(station, new ArrayStackFilter(expectedResult.crafted), + ActionStationAllowCraft.class)) { + return false; + } + for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { if (getUsableAssemblyTable(new BlockIndex(station.x(), station.y(), station.z())) != null) { return true; diff --git a/common/buildcraft/core/robots/AIRobotCraftFurnace.java b/common/buildcraft/core/robots/AIRobotCraftFurnace.java index 572ebfcf..d3e2800b 100755 --- a/common/buildcraft/core/robots/AIRobotCraftFurnace.java +++ b/common/buildcraft/core/robots/AIRobotCraftFurnace.java @@ -25,6 +25,8 @@ import buildcraft.core.inventory.StackHelper; import buildcraft.core.inventory.Transactor; import buildcraft.core.inventory.filters.ArrayStackFilter; import buildcraft.core.inventory.filters.IStackFilter; +import buildcraft.silicon.statements.ActionRobotFilter; +import buildcraft.silicon.statements.ActionStationAllowCraft; public class AIRobotCraftFurnace extends AIRobotCraftGeneric { @@ -38,15 +40,17 @@ public class AIRobotCraftFurnace extends AIRobotCraftGeneric { private boolean craftStarted = false; private int waitedTime = 0; + private ItemStack expectedOutput; public AIRobotCraftFurnace(EntityRobotBase iRobot) { super(iRobot); } - public AIRobotCraftFurnace(EntityRobotBase iRobot, ItemStack iInput) { + public AIRobotCraftFurnace(EntityRobotBase iRobot, ItemStack iInput, ItemStack iOutput) { super(iRobot); input = iInput; + expectedOutput = iOutput; } @Override @@ -158,6 +162,11 @@ public class AIRobotCraftFurnace extends AIRobotCraftGeneric { @Override public boolean matches(DockingStation station) { + if (!ActionRobotFilter.canInteractWithItem(station, new ArrayStackFilter(expectedOutput), + ActionStationAllowCraft.class)) { + return false; + } + for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { if (getUsableFurnace(new BlockIndex(station.x(), station.y(), station.z())) != null) { return true; diff --git a/common/buildcraft/core/robots/AIRobotCraftWorkbench.java b/common/buildcraft/core/robots/AIRobotCraftWorkbench.java index 548bcbfb..4d090c02 100755 --- a/common/buildcraft/core/robots/AIRobotCraftWorkbench.java +++ b/common/buildcraft/core/robots/AIRobotCraftWorkbench.java @@ -34,6 +34,8 @@ import buildcraft.core.inventory.InventoryIterator; import buildcraft.core.inventory.Transactor; import buildcraft.core.inventory.filters.ArrayStackFilter; import buildcraft.core.inventory.filters.IStackFilter; +import buildcraft.silicon.statements.ActionRobotFilter; +import buildcraft.silicon.statements.ActionStationAllowCraft; public class AIRobotCraftWorkbench extends AIRobotCraftGeneric { @@ -217,6 +219,11 @@ public class AIRobotCraftWorkbench extends AIRobotCraftGeneric { @Override public boolean matches(DockingStation station) { + if (!ActionRobotFilter.canInteractWithItem(station, new ArrayStackFilter(recipe.getRecipeOutput()), + ActionStationAllowCraft.class)) { + return false; + } + for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { Block nearbyBlock = robot.worldObj.getBlock(station.x() + dir.offsetX, station.y() + dir.offsetY, station.z() diff --git a/common/buildcraft/core/robots/AIRobotGotoStationToLoad.java b/common/buildcraft/core/robots/AIRobotGotoStationToLoad.java index 1ed60f3e..a7f91dd6 100755 --- a/common/buildcraft/core/robots/AIRobotGotoStationToLoad.java +++ b/common/buildcraft/core/robots/AIRobotGotoStationToLoad.java @@ -19,11 +19,8 @@ import buildcraft.api.robots.EntityRobotBase; import buildcraft.core.inventory.ITransactor; import buildcraft.core.inventory.Transactor; import buildcraft.core.inventory.filters.IStackFilter; -import buildcraft.core.inventory.filters.StatementParameterStackFilter; +import buildcraft.silicon.statements.ActionRobotFilter; import buildcraft.silicon.statements.ActionStationProvideItems; -import buildcraft.transport.Pipe; -import buildcraft.transport.gates.ActionIterator; -import buildcraft.transport.gates.ActionSlot; public class AIRobotGotoStationToLoad extends AIRobot { @@ -65,22 +62,7 @@ public class AIRobotGotoStationToLoad extends AIRobot { @Override public boolean matches(DockingStation station) { - boolean actionFound = false; - - Pipe pipe = station.getPipe().pipe; - - for (ActionSlot s : new ActionIterator(pipe)) { - if (s.action instanceof ActionStationProvideItems) { - StatementParameterStackFilter param = new StatementParameterStackFilter(s.parameters); - - if (!param.hasFilter() || param.matches(filter)) { - actionFound = true; - break; - } - } - } - - if (!actionFound) { + if (!ActionRobotFilter.canInteractWithItem(station, filter, ActionStationProvideItems.class)) { return false; } diff --git a/common/buildcraft/core/robots/AIRobotLoad.java b/common/buildcraft/core/robots/AIRobotLoad.java index eb1d887c..87700c7d 100755 --- a/common/buildcraft/core/robots/AIRobotLoad.java +++ b/common/buildcraft/core/robots/AIRobotLoad.java @@ -21,10 +21,8 @@ import buildcraft.core.inventory.ITransactor; import buildcraft.core.inventory.InventoryIterator; import buildcraft.core.inventory.Transactor; import buildcraft.core.inventory.filters.IStackFilter; -import buildcraft.core.inventory.filters.StatementParameterStackFilter; +import buildcraft.silicon.statements.ActionRobotFilter; import buildcraft.silicon.statements.ActionStationProvideItems; -import buildcraft.transport.gates.ActionIterator; -import buildcraft.transport.gates.ActionSlot; public class AIRobotLoad extends AIRobot { @@ -76,21 +74,9 @@ public class AIRobotLoad extends AIRobot { ItemStack stack = slot.getStackInSlot(); if (stack != null) { - boolean allowed = false; + if (ActionRobotFilter.canInteractWithItem(station, filter, ActionStationProvideItems.class) + && filter.matches(stack)) { - for (ActionSlot s : new ActionIterator(station.getPipe().pipe)) { - if (s.action instanceof ActionStationProvideItems) { - StatementParameterStackFilter param = new StatementParameterStackFilter( - s.parameters); - - if (!param.hasFilter() || param.matches(stack)) { - allowed = true; - break; - } - } - } - - if (allowed && filter.matches(stack)) { ITransactor t = Transactor.getTransactorFor(robot); if (quantity == -1) { diff --git a/common/buildcraft/core/robots/AIRobotSearchStackRequest.java b/common/buildcraft/core/robots/AIRobotSearchStackRequest.java index 93f29ee1..0ada6363 100755 --- a/common/buildcraft/core/robots/AIRobotSearchStackRequest.java +++ b/common/buildcraft/core/robots/AIRobotSearchStackRequest.java @@ -22,6 +22,8 @@ import buildcraft.api.robots.EntityRobotBase; import buildcraft.api.robots.IRequestProvider; import buildcraft.api.robots.StackRequest; import buildcraft.core.inventory.StackHelper; +import buildcraft.core.inventory.filters.IStackFilter; +import buildcraft.silicon.statements.ActionRobotFilter; import buildcraft.silicon.statements.ActionStationRequestItems; import buildcraft.silicon.statements.ActionStationRequestItemsMachine; import buildcraft.transport.Pipe; @@ -34,14 +36,17 @@ public class AIRobotSearchStackRequest extends AIRobot { private Collection blackList; + private IStackFilter filter; + public AIRobotSearchStackRequest(EntityRobotBase iRobot) { super(iRobot); } - public AIRobotSearchStackRequest(EntityRobotBase iRobot, Collection iBlackList) { + public AIRobotSearchStackRequest(EntityRobotBase iRobot, IStackFilter iFilter, Collection iBlackList) { super(iRobot); blackList = iBlackList; + filter = iFilter; } @Override @@ -82,17 +87,7 @@ public class AIRobotSearchStackRequest extends AIRobot { } private StackRequest getOrderFromRequestingStation(DockingStation station, boolean take) { - boolean actionFound = false; - - Pipe pipe = station.getPipe().pipe; - - for (ActionSlot s : new ActionIterator(pipe)) { - if (s.action instanceof ActionStationRequestItemsMachine) { - actionFound = true; - } - } - - if (!actionFound) { + if (!ActionRobotFilter.canInteractWithItem(station, filter, ActionStationRequestItemsMachine.class)) { return null; } @@ -107,7 +102,9 @@ public class AIRobotSearchStackRequest extends AIRobot { for (int i = 0; i < provider.getNumberOfRequests(); ++i) { StackRequest requestFound = provider.getAvailableRequest(i); - if (requestFound != null && !isBlacklisted(requestFound.stack)) { + if (requestFound != null + && !isBlacklisted(requestFound.stack) + && filter.matches(requestFound.stack)) { requestFound.station = station; if (take) { diff --git a/common/buildcraft/core/robots/EntityRobot.java b/common/buildcraft/core/robots/EntityRobot.java index 7b3c8ac9..b37d3565 100755 --- a/common/buildcraft/core/robots/EntityRobot.java +++ b/common/buildcraft/core/robots/EntityRobot.java @@ -288,7 +288,8 @@ public class EntityRobot extends EntityRobotBase implements linkedDockingStationIndex = null; - if (linkedDockingStation.robotTaking() != this) { + if (linkedDockingStation == null + || linkedDockingStation.robotTaking() != this) { // Error at load time, the expected linked stations is not // properly set, kill this robot. diff --git a/common/buildcraft/core/robots/boards/BoardRobotCrafter.java b/common/buildcraft/core/robots/boards/BoardRobotCrafter.java index c80d6ac1..e6f84f6f 100755 --- a/common/buildcraft/core/robots/boards/BoardRobotCrafter.java +++ b/common/buildcraft/core/robots/boards/BoardRobotCrafter.java @@ -24,8 +24,6 @@ import net.minecraftforge.oredict.ShapelessOreRecipe; import buildcraft.api.boards.RedstoneBoardRobot; import buildcraft.api.boards.RedstoneBoardRobotNBT; -import buildcraft.api.gates.ActionParameterItemStack; -import buildcraft.api.gates.IActionParameter; import buildcraft.api.recipes.CraftingResult; import buildcraft.api.recipes.IFlexibleRecipe; import buildcraft.api.robots.AIRobot; @@ -44,10 +42,7 @@ import buildcraft.core.robots.AIRobotGotoSleep; import buildcraft.core.robots.AIRobotGotoStationToUnload; import buildcraft.core.robots.AIRobotSearchStackRequest; import buildcraft.core.robots.AIRobotUnload; -import buildcraft.core.robots.DockingStation; -import buildcraft.silicon.statements.ActionRobotCraft; -import buildcraft.transport.gates.ActionIterator; -import buildcraft.transport.gates.ActionSlot; +import buildcraft.silicon.statements.ActionRobotFilter; public class BoardRobotCrafter extends RedstoneBoardRobot { @@ -75,14 +70,15 @@ public class BoardRobotCrafter extends RedstoneBoardRobot { return; } - if (currentRequest == null) { - order = getOrderFromHomeStation(); - } else { + if (currentRequest != null) { order = currentRequest.stack; + } else { + order = null; } if (order == null) { - startDelegateAI(new AIRobotSearchStackRequest(robot, craftingBlacklist)); + startDelegateAI(new AIRobotSearchStackRequest(robot, ActionRobotFilter.getGateFilter(robot + .getLinkedStation()), craftingBlacklist)); return; } @@ -96,7 +92,7 @@ public class BoardRobotCrafter extends RedstoneBoardRobot { ItemStack furnaceInput = lookForFurnaceRecipe(order); if (furnaceInput != null) { - startDelegateAI(new AIRobotCraftFurnace(robot, furnaceInput)); + startDelegateAI(new AIRobotCraftFurnace(robot, furnaceInput, order)); return; } @@ -203,25 +199,4 @@ public class BoardRobotCrafter extends RedstoneBoardRobot { return false; } - - private ItemStack getOrderFromHomeStation() { - DockingStation s = (DockingStation) robot.getLinkedStation(); - - for (ActionSlot slot : new ActionIterator(s.getPipe().pipe)) { - if (slot.action instanceof ActionRobotCraft) { - for (IActionParameter p : slot.parameters) { - if (p != null && p instanceof ActionParameterItemStack) { - ActionParameterItemStack param = (ActionParameterItemStack) p; - ItemStack stack = param.getItemStackToDraw(); - - if (stack != null && !isBlacklisted(stack)) { - return stack; - } - } - } - } - } - - return null; - } } diff --git a/common/buildcraft/core/robots/boards/BoardRobotDelivery.java b/common/buildcraft/core/robots/boards/BoardRobotDelivery.java index ab293813..cf48ff7f 100755 --- a/common/buildcraft/core/robots/boards/BoardRobotDelivery.java +++ b/common/buildcraft/core/robots/boards/BoardRobotDelivery.java @@ -24,6 +24,7 @@ import buildcraft.core.robots.AIRobotDisposeItems; import buildcraft.core.robots.AIRobotGotoSleep; import buildcraft.core.robots.AIRobotGotoStationAndLoad; import buildcraft.core.robots.AIRobotSearchStackRequest; +import buildcraft.silicon.statements.ActionRobotFilter; public class BoardRobotDelivery extends RedstoneBoardRobot { @@ -51,7 +52,8 @@ public class BoardRobotDelivery extends RedstoneBoardRobot { } if (currentRequest == null) { - startDelegateAI(new AIRobotSearchStackRequest(robot, deliveryBlacklist)); + startDelegateAI(new AIRobotSearchStackRequest(robot, ActionRobotFilter.getGateFilter(robot + .getLinkedStation()), deliveryBlacklist)); } else { startDelegateAI(new AIRobotGotoStationAndLoad(robot, new ReqFilter(), robot.getZoneToWork())); } diff --git a/common/buildcraft/silicon/statements/ActionRobotFilter.java b/common/buildcraft/silicon/statements/ActionRobotFilter.java index ec6a3ccd..1313d844 100755 --- a/common/buildcraft/silicon/statements/ActionRobotFilter.java +++ b/common/buildcraft/silicon/statements/ActionRobotFilter.java @@ -106,6 +106,25 @@ public class ActionRobotFilter extends BCActionPassive { } } + public static boolean canInteractWithItem(DockingStation station, IStackFilter filter, Class actionClass) { + boolean actionFound = false; + + Pipe pipe = station.getPipe().pipe; + + for (ActionSlot s : new ActionIterator(pipe)) { + if (actionClass.isAssignableFrom(s.action.getClass())) { + StatementParameterStackFilter param = new StatementParameterStackFilter(s.parameters); + + if (!param.hasFilter() || param.matches(filter)) { + actionFound = true; + break; + } + } + } + + return actionFound; + } + public static boolean canInteractWithFluid(DockingStation station, IFluidFilter filter, Class actionClass) { boolean actionFound = false; Pipe pipe = station.getPipe().pipe; diff --git a/common/buildcraft/silicon/statements/ActionRobotCraft.java b/common/buildcraft/silicon/statements/ActionStationAllowCraft.java similarity index 75% rename from common/buildcraft/silicon/statements/ActionRobotCraft.java rename to common/buildcraft/silicon/statements/ActionStationAllowCraft.java index 7be937f8..c72a66af 100755 --- a/common/buildcraft/silicon/statements/ActionRobotCraft.java +++ b/common/buildcraft/silicon/statements/ActionStationAllowCraft.java @@ -15,20 +15,20 @@ import buildcraft.api.gates.IActionParameter; import buildcraft.core.triggers.BCActionPassive; import buildcraft.core.utils.StringUtils; -public class ActionRobotCraft extends BCActionPassive { +public class ActionStationAllowCraft extends BCActionPassive { - public ActionRobotCraft() { - super("buildcraft:station.craft"); + public ActionStationAllowCraft() { + super("buildcraft:robot.allow_craft"); } @Override public String getDescription() { - return StringUtils.localize("gate.action.station.craft"); + return StringUtils.localize("gate.action.station.allow_craft"); } @Override public void registerIcons(IIconRegister iconRegister) { - icon = iconRegister.registerIcon("buildcraft:triggers/action_robot_craft"); + icon = iconRegister.registerIcon("buildcraft:triggers/action_station_allow_craft"); } @Override diff --git a/common/buildcraft/silicon/statements/RobotsActionProvider.java b/common/buildcraft/silicon/statements/RobotsActionProvider.java index 6b2c4f4a..5c708933 100755 --- a/common/buildcraft/silicon/statements/RobotsActionProvider.java +++ b/common/buildcraft/silicon/statements/RobotsActionProvider.java @@ -13,8 +13,10 @@ import java.util.Collection; import java.util.LinkedList; import net.minecraft.block.Block; +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; @@ -25,7 +27,7 @@ import buildcraft.api.gates.IActionProvider; import buildcraft.api.robots.IRequestProvider; import buildcraft.api.transport.IPipeTile; import buildcraft.core.robots.DockingStation; -import buildcraft.core.robots.boards.BoardRobotCrafter; +import buildcraft.silicon.TileAssemblyTable; import buildcraft.transport.PipeTransportItems; import buildcraft.transport.TileGenericPipe; @@ -53,31 +55,34 @@ public class RobotsActionProvider implements IActionProvider { result.add(BuildCraftSilicon.actionRobotFilter); result.add(BuildCraftSilicon.actionStationForbidRobot); - for (DockingStation s : stations) { - if (s.robotTaking() != null && s.robotTaking().getBoard() instanceof BoardRobotCrafter) { - result.add(BuildCraftSilicon.actionRobotCraft); - } - } - if (((TileGenericPipe) pipe).pipe.transport instanceof PipeTransportItems) { result.add(BuildCraftSilicon.actionStationDropInPipe); } for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { - if (((TileGenericPipe) pipe).getTile(dir) instanceof IInventory) { + TileEntity tile = ((TileGenericPipe) pipe).getTile(dir); + Block block = ((TileGenericPipe) pipe).getBlock(dir); + + if (tile instanceof IInventory) { result.add(BuildCraftSilicon.actionStationProvideItems); result.add(BuildCraftSilicon.actionStationRequestItems); result.add(BuildCraftSilicon.actionStationAcceptItems); } - if (((TileGenericPipe) pipe).getTile(dir) instanceof IFluidHandler) { + if (tile instanceof IFluidHandler) { result.add(BuildCraftSilicon.actionStationAcceptFluids); result.add(BuildCraftSilicon.actionStationProvideFluids); } - if (((TileGenericPipe) pipe).getTile(dir) instanceof IRequestProvider) { + if (tile instanceof IRequestProvider) { result.add(BuildCraftSilicon.actionStationMachineRequestItems); } + + if (tile instanceof TileEntityFurnace + || tile instanceof TileAssemblyTable + || block instanceof BlockWorkbench) { + result.add(BuildCraftSilicon.actionRobotAllowCraft); + } } return result; diff --git a/common/buildcraft/transport/ItemRobotStation.java b/common/buildcraft/transport/ItemRobotStation.java index 4cca7e20..02db6173 100755 --- a/common/buildcraft/transport/ItemRobotStation.java +++ b/common/buildcraft/transport/ItemRobotStation.java @@ -99,7 +99,9 @@ public class ItemRobotStation extends ItemBuildCraft { @Override public void invalidate() { - if (station != null && !station.getPipe().getWorld().isRemote) { + if (station != null + && station.getPipe() != null + && !station.getPipe().getWorld().isRemote) { RobotRegistry.getRegistry(station.world).removeStation(station); isValid = false; }