restore List support to Force/Forbid Robot

This commit is contained in:
Adrian 2015-08-08 15:58:59 +02:00
parent 6536c2bae1
commit a5e61ad767
6 changed files with 21 additions and 4 deletions

View file

@ -10,4 +10,5 @@ Improvements:
Bugs fixed:
* [#2948] Precise damage checking not working (asie)
* Force/Forbid Robot statements not accepting lists (asie)
* Hovering over slot causing incorrect item lighting (asie)

View file

@ -431,6 +431,8 @@ public class BuildCraftRobotics extends BuildCraftMod {
managerThread = new Thread(manager);
managerThread.start();
BoardRobotPicker.onServerStart();
MinecraftForge.EVENT_BUS.register(manager);
FMLCommonHandler.instance().bus().register(manager);
}

View file

@ -21,13 +21,16 @@ import buildcraft.robotics.ai.AIRobotGotoStationAndUnload;
import buildcraft.robotics.statements.ActionRobotFilter;
public class BoardRobotPicker extends RedstoneBoardRobot {
// TODO: Clean this when world unloaded
public static Set<Integer> targettedItems = new HashSet<Integer>();
public BoardRobotPicker(EntityRobotBase iRobot) {
super(iRobot);
}
public static void onServerStart() {
targettedItems.clear();
}
@Override
public void update() {
startDelegateAI(new AIRobotFetchItem(robot, 250, ActionRobotFilter.getGateFilter(robot

View file

@ -324,7 +324,7 @@ public class GuiZonePlan extends GuiAdvancedInterface {
if (blocksPerPixel > 4.0f) {
blocksPerPixel = 4.0f;
}
mapWidth = this.mc.displayWidth;
mapHeight = this.mc.displayHeight;

View file

@ -66,7 +66,7 @@ public class ActionStationForbidRobot extends BCStatement implements IActionInte
public static boolean isForbidden(StatementSlot slot, EntityRobotBase robot) {
for (IStatementParameter p : slot.parameters) {
if (StatementParameterRobot.matches(p, robot)) {
if (p != null && StatementParameterRobot.matches(p, robot)) {
return true;
}
}

View file

@ -3,6 +3,7 @@ package buildcraft.robotics.statements;
import net.minecraft.item.ItemStack;
import buildcraft.api.boards.RedstoneBoardRobotNBT;
import buildcraft.api.items.IList;
import buildcraft.api.robots.EntityRobotBase;
import buildcraft.api.statements.IStatement;
import buildcraft.api.statements.IStatementContainer;
@ -39,7 +40,17 @@ public class StatementParameterRobot extends StatementParameterItemStack {
public static boolean matches(IStatementParameter param, EntityRobotBase robot) {
ItemStack stack = param.getItemStack();
if (stack != null) {
if (stack.getItem() instanceof ItemRobot) {
if (stack.getItem() instanceof IList) {
IList list = (IList) stack.getItem();
if (list.matches(stack, ItemRobot.createRobotStack(robot.getBoard().getNBTHandler(), robot.getEnergy()))) {
return true;
}
for (ItemStack target : ((EntityRobot) robot).getWearables()) {
if (target != null && list.matches(stack, target)) {
return true;
}
}
} else if (stack.getItem() instanceof ItemRobot) {
if (ItemRobot.getRobotNBT(stack) == robot.getBoard().getNBTHandler()) {
return true;
}