add the ability to scroll through the parameters of the Forbid/Force robot

This commit is contained in:
Hea3veN 2015-06-05 21:47:20 -03:00
parent 1f33864dae
commit 72d4ad5ada
5 changed files with 75 additions and 4 deletions

View file

@ -8,6 +8,7 @@ Additions:
* Container item support for the Stamping Table (asie)
* Packagers only allow items relevant to the recipe to be inserted (asie)
* Builders now light up when working (asie)
* Add the ability to scroll through the parameters of the Forbid/Force robot (hea3ven)
Improvements:

View file

@ -142,6 +142,7 @@ import buildcraft.robotics.statements.ActionStationRequestItems;
import buildcraft.robotics.statements.ActionStationRequestItemsMachine;
import buildcraft.robotics.statements.RobotsActionProvider;
import buildcraft.robotics.statements.RobotsTriggerProvider;
import buildcraft.robotics.statements.StatementParameterRobot;
import buildcraft.robotics.statements.TriggerRobotInStation;
import buildcraft.robotics.statements.TriggerRobotLinked;
import buildcraft.robotics.statements.TriggerRobotSleep;
@ -175,7 +176,7 @@ public class BuildCraftRobotics extends BuildCraftMod {
public static IActionInternal actionStationAcceptFluids = new ActionStationAcceptFluids();
public static IActionInternal actionStationProvideFluids = new ActionStationProvideFluids();
public static IActionInternal actionStationForceRobot = new ActionStationForbidRobot(true);
public static IActionInternal actionStationForbidRobot = new ActionStationForbidRobot(true);
public static IActionInternal actionStationForbidRobot = new ActionStationForbidRobot(false);
public static IActionInternal actionStationAcceptItems = new ActionStationAcceptItems();
public static IActionInternal actionStationMachineRequestItems = new ActionStationRequestItemsMachine();
@ -248,6 +249,7 @@ public class BuildCraftRobotics extends BuildCraftMod {
RedstoneBoardRegistry.instance.registerBoardType(new BCBoardNBT("buildcraft:boardRobotBuilder", "builder", BoardRobotBuilder.class, "yellow"), 512000);
}
StatementManager.registerParameterClass(StatementParameterRobot.class);
StatementManager.registerActionProvider(new RobotsActionProvider());
StatementManager.registerTriggerProvider(new RobotsTriggerProvider());
}

View file

@ -5,7 +5,6 @@ import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.block.BlockCrops;
import net.minecraft.block.BlockDoublePlant;
import net.minecraft.block.BlockFlower;
import net.minecraft.block.BlockMelon;
import net.minecraft.block.BlockMushroom;
import net.minecraft.block.BlockTallGrass;

View file

@ -16,7 +16,6 @@ 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.api.statements.StatementSlot;
import buildcraft.core.lib.utils.StringUtils;
import buildcraft.core.statements.BCStatement;
@ -52,7 +51,7 @@ public class ActionStationForbidRobot extends BCStatement implements IActionInte
@Override
public IStatementParameter createParameter(int index) {
return new StatementParameterItemStack();
return new StatementParameterRobot();
}
public static boolean isForbidden(DockingStation station, EntityRobotBase robot) {

View file

@ -0,0 +1,70 @@
package buildcraft.robotics.statements;
import java.util.Collection;
import java.util.List;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import net.minecraft.item.ItemStack;
import buildcraft.api.boards.RedstoneBoardNBT;
import buildcraft.api.boards.RedstoneBoardRegistry;
import buildcraft.api.boards.RedstoneBoardRobotNBT;
import buildcraft.api.statements.IStatement;
import buildcraft.api.statements.IStatementContainer;
import buildcraft.api.statements.StatementMouseClick;
import buildcraft.api.statements.StatementParameterItemStack;
import buildcraft.robotics.ItemRobot;
public class StatementParameterRobot extends StatementParameterItemStack {
@Override
public void onClick(IStatementContainer source, IStatement stmt, ItemStack stack,
StatementMouseClick mouse) {
if (stack != null) {
if (stack.getItem() instanceof ItemRobot) {
super.onClick(source, stmt, stack, mouse);
} else {
this.stack = null;
}
} else {
RedstoneBoardRobotNBT nextBoard = getNextBoard(mouse);
if (nextBoard != null) {
this.stack = ItemRobot.createRobotStack(nextBoard, 0);
} else {
this.stack = null;
}
}
}
private RedstoneBoardRobotNBT getNextBoard(StatementMouseClick mouse) {
Collection<RedstoneBoardNBT<?>> boards = RedstoneBoardRegistry.instance.getAllBoardNBTs();
if (this.stack == null) {
if (mouse.getButton() == 0) {
return (RedstoneBoardRobotNBT) Iterables.getFirst(boards, null);
} else {
return (RedstoneBoardRobotNBT) Iterables.getLast(boards, null);
}
} else {
if (mouse.getButton() > 0) {
boards = Lists.reverse((List<RedstoneBoardNBT<?>>) boards);
}
boolean found = false;
for (RedstoneBoardNBT boardNBT : boards) {
if (found) {
return (RedstoneBoardRobotNBT) boardNBT;
} else if (ItemRobot.getRobotNBT(this.stack) == boardNBT) {
found = true;
}
}
return null;
}
}
@Override
public String getUniqueTag() {
return "buildcraft:robot";
}
}