started work on bomber, for #1913

This commit is contained in:
SpaceToad 2014-06-26 08:51:28 +02:00
parent 3d9a2ee9de
commit 3c409ca0b9
15 changed files with 284 additions and 4 deletions

View file

@ -14,6 +14,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import buildcraft.api.boards.RedstoneBoardRobot;
import buildcraft.api.core.IBox;
public abstract class EntityRobotBase extends EntityLiving implements IInventory {
@ -51,4 +52,8 @@ public abstract class EntityRobotBase extends EntityLiving implements IInventory
public abstract boolean linkToStation(IDockingStation station);
public abstract void workInArea(IBox box);
public abstract IBox getAreaToWork();
}

View file

@ -5,6 +5,8 @@ buildcraft.boardRobotLumberjack=Lumberjack
buildcraft.boardRobotPlanter=Planter
buildcraft.boardRobotLeaveCutter=Leave Cutter
buildcraft.boardRobotCarrier=Carrier
buildcraft.boardRobotBomber=Bomber
buildcraft.boardRobotKnight=Knight
buildcraft.boardDetail.parameters=Parameters
buildcraft.boardDetail.range=Range
@ -55,6 +57,7 @@ gate.action.robot.goto_station=Goto Station
gate.action.pipe.close=Close Pipe
gate.action.station.provide_items=Provide Items
gate.action.station.request_items=Request Items
gate.action.robot.work_in_area=Work in Area
gate.expansion.fader=Redstone Fader
gate.expansion.pulsar=Autarchic Pulsar

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View file

@ -40,6 +40,7 @@ import buildcraft.core.Version;
import buildcraft.core.network.BuildCraftChannelHandler;
import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.robots.RobotIntegrationRecipe;
import buildcraft.core.robots.boards.BoardRobotBomberNBT;
import buildcraft.core.robots.boards.BoardRobotCarrierNBT;
import buildcraft.core.robots.boards.BoardRobotKnightNBT;
import buildcraft.core.robots.boards.BoardRobotLeaveCutterNBT;
@ -66,6 +67,7 @@ import buildcraft.silicon.recipes.AdvancedFacadeRecipe;
import buildcraft.silicon.recipes.GateExpansionRecipe;
import buildcraft.silicon.recipes.GateLogicSwapRecipe;
import buildcraft.silicon.statements.ActionRobotGoToStation;
import buildcraft.silicon.statements.ActionRobotWorkInArea;
import buildcraft.silicon.statements.ActionStationProvideItems;
import buildcraft.silicon.statements.ActionStationRequestItems;
import buildcraft.silicon.statements.RobotsActionProvider;
@ -92,6 +94,7 @@ public class BuildCraftSilicon extends BuildCraftMod {
public static Item robotItem;
public static BCAction actionRobotGotoStation = new ActionRobotGoToStation();
public static BCAction actionRobotWorkInArea = new ActionRobotWorkInArea();
public static BCAction actionStationRequestItems = new ActionStationRequestItems();
public static BCAction actionStationProvideItems = new ActionStationProvideItems();
@ -132,6 +135,7 @@ public class BuildCraftSilicon extends BuildCraftMod {
RedstoneBoardRegistry.instance.registerBoardClass(BoardRobotPlanterNBT.instance, 5);
RedstoneBoardRegistry.instance.registerBoardClass(BoardRobotLeaveCutterNBT.instance, 5);
RedstoneBoardRegistry.instance.registerBoardClass(BoardRobotKnightNBT.instance, 1);
RedstoneBoardRegistry.instance.registerBoardClass(BoardRobotBomberNBT.instance, 1);
StatementManager.registerActionProvider(new RobotsActionProvider());
}

View file

@ -27,6 +27,7 @@ import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.boards.RedstoneBoardRegistry;
import buildcraft.api.core.BlockIndex;
import buildcraft.api.core.IBox;
import buildcraft.builders.TileMarker;
import buildcraft.builders.TilePathMarker;
import buildcraft.core.utils.NBTUtils;
@ -185,6 +186,23 @@ public class ItemMapLocation extends ItemBuildCraft {
}
}
public static IBox getBlox(ItemStack item) {
NBTTagCompound cpt = NBTUtils.getItemData(item);
if (cpt.hasKey("kind") && cpt.getByte("kind") == 1) {
int xMin = cpt.getInteger("xMin");
int yMin = cpt.getInteger("yMin");
int zMin = cpt.getInteger("zMin");
int xMax = cpt.getInteger("xMax");
int yMax = cpt.getInteger("yMax");
int zMax = cpt.getInteger("zMax");
return new Box(xMin, yMin, zMin, xMax, yMax, zMax);
} else {
return null;
}
}
public static ForgeDirection getSide(ItemStack item) {
NBTTagCompound cpt = NBTUtils.getItemData(item);

View file

@ -20,11 +20,16 @@ import buildcraft.api.robots.EntityRobotBase;
import buildcraft.core.inventory.ITransactor;
import buildcraft.core.inventory.InventoryIterator;
import buildcraft.core.inventory.Transactor;
import buildcraft.core.inventory.filters.IStackFilter;
public class AIRobotLoad extends AIRobot {
public AIRobotLoad(EntityRobotBase iRobot) {
private IStackFilter filter;
public AIRobotLoad(EntityRobotBase iRobot, IStackFilter iFilter) {
super(iRobot, 0, 1);
filter = iFilter;
}
@Override
@ -48,7 +53,7 @@ public class AIRobotLoad extends AIRobot {
for (IInvSlot slot : InventoryIterator.getIterable(tileInventory, dir.getOpposite())) {
ItemStack stack = slot.getStackInSlot();
if (stack != null) {
if (stack != null && filter.matches(stack)) {
slot.setStackInSlot(null);
robot.setInventorySlotContents(i, stack);
break;

View file

@ -33,6 +33,7 @@ import buildcraft.api.boards.RedstoneBoardNBT;
import buildcraft.api.boards.RedstoneBoardRegistry;
import buildcraft.api.boards.RedstoneBoardRobot;
import buildcraft.api.boards.RedstoneBoardRobotNBT;
import buildcraft.api.core.IBox;
import buildcraft.api.core.SafeTimeTracker;
import buildcraft.api.robots.AIRobot;
import buildcraft.api.robots.DockingStationRegistry;
@ -84,6 +85,9 @@ public class EntityRobot extends EntityRobotBase implements
private double mjStored;
private IBox areaToWork;
private long areaResetDate;
public EntityRobot(World world, NBTTagCompound boardNBT) {
this(world);
@ -652,4 +656,14 @@ public class EntityRobot extends EntityRobotBase implements
}
}
@Override
public void workInArea(IBox box) {
areaToWork = box;
areaResetDate = worldObj.getTotalWorldTime() + 5;
}
@Override
public IBox getAreaToWork() {
return areaToWork;
}
}

View file

@ -0,0 +1,57 @@
/**
* 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.robots.boards;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import buildcraft.api.boards.RedstoneBoardRobot;
import buildcraft.api.boards.RedstoneBoardRobotNBT;
import buildcraft.api.robots.AIRobot;
import buildcraft.api.robots.EntityRobotBase;
import buildcraft.core.inventory.filters.ArrayStackFilter;
import buildcraft.core.inventory.filters.IStackFilter;
import buildcraft.core.robots.AIRobotGotoStationToLoad;
import buildcraft.core.robots.AIRobotLoad;
public class BoardRobotBomber extends RedstoneBoardRobot {
private static final IStackFilter TNT_FILTER = new ArrayStackFilter(new ItemStack(Blocks.tnt));
public BoardRobotBomber(EntityRobotBase iRobot) {
super(iRobot, 0);
}
@Override
public RedstoneBoardRobotNBT getNBTHandler() {
return BoardRobotBomberNBT.instance;
}
@Override
public final void update() {
boolean containItems = false;
for (int i = 0; i < robot.getSizeInventory(); ++i) {
if (robot.getStackInSlot(i) != null) {
containItems = true;
}
}
if (!containItems) {
startDelegateAI(new AIRobotGotoStationToLoad(robot, TNT_FILTER));
}
}
@Override
public void delegateAIEnded(AIRobot ai) {
if (ai instanceof AIRobotGotoStationToLoad) {
startDelegateAI(new AIRobotLoad(robot, TNT_FILTER));
}
}
}

View file

@ -0,0 +1,72 @@
/**
* 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.robots.boards;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;
import buildcraft.api.boards.RedstoneBoardRobot;
import buildcraft.api.boards.RedstoneBoardRobotNBT;
import buildcraft.api.robots.EntityRobotBase;
import buildcraft.core.DefaultProps;
import buildcraft.core.utils.StringUtils;
public final class BoardRobotBomberNBT extends RedstoneBoardRobotNBT {
public static BoardRobotBomberNBT instance = new BoardRobotBomberNBT();
private static final ResourceLocation TEXTURE = new ResourceLocation("buildcraft",
DefaultProps.TEXTURE_PATH_ENTITIES + "/robot_bomber.png");
private IIcon icon;
@Override
public RedstoneBoardRobot create(NBTTagCompound nbt, EntityRobotBase robot) {
return new BoardRobotBomber(robot);
}
@Override
public ResourceLocation getRobotTexture() {
return TEXTURE;
}
@Override
public String getID() {
return "buildcraft:boardRobotBomber";
}
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean advanced) {
list.add(StringUtils.localize("buildcraft.boardRobotBomber"));
}
@Override
public void registerIcons(IIconRegister iconRegister) {
icon = iconRegister.registerIcon("buildcraft:board_red");
}
@Override
public IIcon getIcon(NBTTagCompound nbt) {
return icon;
}
@Override
public void createRandomBoard(NBTTagCompound nbt) {
}
@Override
public void createDefaultBoard(NBTTagCompound nbt) {
}
}

View file

@ -49,7 +49,7 @@ public class BoardRobotCarrier extends RedstoneBoardRobot {
@Override
public void delegateAIEnded(AIRobot ai) {
if (ai instanceof AIRobotGotoStationToLoad) {
startDelegateAI(new AIRobotLoad(robot));
startDelegateAI(new AIRobotLoad(robot, new PassThroughStackFilter()));
} else if (ai instanceof AIRobotGoToStationToUnload) {
startDelegateAI(new AIRobotUnload(robot));
}

View file

@ -26,4 +26,9 @@ public abstract class BCAction extends BCStatement implements IAction {
@Override
public void actionActivate(IGate gate, IActionParameter[] parameters) {
}
@Override
public IAction rotateLeft() {
return this;
}
}

View file

@ -51,4 +51,9 @@ public abstract class BCTrigger extends BCStatement implements ITrigger {
public ITriggerParameter createParameter(int index) {
return new TriggerParameterItemStack();
}
@Override
public ITrigger rotateLeft() {
return this;
}
}

View file

@ -81,7 +81,7 @@ public class ActionRobotGoToStation extends BCAction {
ItemStack item = stackParam.getItemStackToDraw();
if (item.getItem() instanceof ItemMapLocation) {
BlockIndex index = ItemMapLocation.getBlockIndex (item);
BlockIndex index = ItemMapLocation.getBlockIndex(item);
if (index != null) {
ForgeDirection side = ItemMapLocation.getSide(item);
@ -109,4 +109,5 @@ public class ActionRobotGoToStation extends BCAction {
public IActionParameter createParameter(int index) {
return new ActionParameterItemStack();
}
}

View file

@ -0,0 +1,90 @@
/**
* 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.silicon.statements;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraftforge.common.util.ForgeDirection;
import buildcraft.api.core.IBox;
import buildcraft.api.gates.ActionParameterItemStack;
import buildcraft.api.gates.IActionParameter;
import buildcraft.api.gates.IGate;
import buildcraft.core.ItemMapLocation;
import buildcraft.core.robots.DockingStation;
import buildcraft.core.triggers.BCAction;
import buildcraft.core.utils.StringUtils;
import buildcraft.transport.Pipe;
import buildcraft.transport.TileGenericPipe;
public class ActionRobotWorkInArea extends BCAction {
private IIcon icon;
public ActionRobotWorkInArea() {
super("buildcraft:robot.work_in_area");
}
@Override
public IIcon getIcon() {
return icon;
}
@Override
public String getDescription() {
return StringUtils.localize("gate.action.robot.work_in_area");
}
@Override
public void registerIcons(IIconRegister iconRegister) {
icon = iconRegister.registerIcon("buildcraft:triggers/action_robot_in_area");
}
@Override
public void actionActivate(IGate gate, IActionParameter[] parameters) {
if (parameters[0] == null) {
return;
}
ItemStack stack = ((ActionParameterItemStack) parameters[0]).getItemStackToDraw();
if (!(stack.getItem() instanceof ItemMapLocation)) {
return;
}
IBox box = ItemMapLocation.getBlox(stack);
if (box == null) {
return;
}
Pipe<?> pipe = (Pipe<?>) gate.getPipe();
TileGenericPipe tile = pipe.container;
for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
DockingStation station = tile.getStation(d);
if (station != null && station.linked() != null) {
station.linked().workInArea(box);
}
}
}
@Override
public int maxParameters() {
return 1;
}
@Override
public IActionParameter createParameter(int index) {
return new ActionParameterItemStack();
}
}

View file

@ -43,6 +43,7 @@ public class RobotsActionProvider implements IActionProvider {
}
result.add(BuildCraftSilicon.actionRobotGotoStation);
result.add(BuildCraftSilicon.actionRobotWorkInArea);
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
if (((TileGenericPipe) pipe).getTile(dir) instanceof IInventory) {