started work on crafting robot and related blocks, for #1973
|
@ -13,6 +13,7 @@ buildcraft.boardRobotHarvester=Harvester
|
|||
buildcraft.boardRobotShovelman=Shovelman
|
||||
buildcraft.boardRobotButcher=Butcher
|
||||
buildcraft.boardRobotBuilder=Builder
|
||||
buildcraft.boardRobotCrafter=Crafter
|
||||
buildcraft.boardDetail.parameters=Parameters
|
||||
buildcraft.boardDetail.range=Range
|
||||
|
||||
|
@ -64,6 +65,7 @@ gate.action.pipe.close=Close Pipe
|
|||
gate.action.station.provide_items=Provide 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.robot.work_in_area=Work in Area
|
||||
gate.action.robot.wakeup=Wake Up
|
||||
gate.action.station.forbid_robot=Robot Forbidden
|
||||
|
|
BIN
buildcraft_resources/assets/buildcraft/textures/blocks/commander_side.png
Executable file
After Width: | Height: | Size: 447 B |
BIN
buildcraft_resources/assets/buildcraft/textures/blocks/mailbox_front.png
Executable file
After Width: | Height: | Size: 465 B |
BIN
buildcraft_resources/assets/buildcraft/textures/blocks/requester_front.png
Executable file
After Width: | Height: | Size: 465 B |
BIN
buildcraft_resources/assets/buildcraft/textures/entities/robot_crafter.png
Executable file
After Width: | Height: | Size: 972 B |
BIN
buildcraft_resources/assets/buildcraft/textures/gui/requester_gui.png
Executable file
After Width: | Height: | Size: 1.6 KiB |
BIN
buildcraft_resources/assets/buildcraft/textures/items/letter.png
Executable file
After Width: | Height: | Size: 209 B |
After Width: | Height: | Size: 590 B |
After Width: | Height: | Size: 449 B |
|
@ -35,6 +35,7 @@ import buildcraft.api.gates.TriggerParameterItemStack;
|
|||
import buildcraft.api.recipes.BuildcraftRecipeRegistry;
|
||||
import buildcraft.api.transport.PipeWire;
|
||||
import buildcraft.builders.schematics.SchematicRotateMeta;
|
||||
import buildcraft.commander.BlockRequester;
|
||||
import buildcraft.commander.BlockZonePlan;
|
||||
import buildcraft.commander.TileZonePlan;
|
||||
import buildcraft.core.DefaultProps;
|
||||
|
@ -49,6 +50,7 @@ import buildcraft.core.robots.boards.BoardRobotBomberNBT;
|
|||
import buildcraft.core.robots.boards.BoardRobotBuilderNBT;
|
||||
import buildcraft.core.robots.boards.BoardRobotButcherNBT;
|
||||
import buildcraft.core.robots.boards.BoardRobotCarrierNBT;
|
||||
import buildcraft.core.robots.boards.BoardRobotCrafterNBT;
|
||||
import buildcraft.core.robots.boards.BoardRobotFarmerNBT;
|
||||
import buildcraft.core.robots.boards.BoardRobotHarvesterNBT;
|
||||
import buildcraft.core.robots.boards.BoardRobotKnightNBT;
|
||||
|
@ -80,6 +82,7 @@ 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;
|
||||
|
@ -111,6 +114,7 @@ public class BuildCraftSilicon extends BuildCraftMod {
|
|||
public static BlockLaser laserBlock;
|
||||
public static BlockLaserTable assemblyTableBlock;
|
||||
public static BlockZonePlan zonePlanBlock;
|
||||
public static BlockRequester requesterBlock;
|
||||
public static Item redstoneCrystal;
|
||||
public static Item robotItem;
|
||||
|
||||
|
@ -120,6 +124,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 actionStationRequestItems = new ActionStationRequestItemsInv();
|
||||
public static IAction actionStationProvideItems = new ActionStationProvideItems();
|
||||
public static IAction actionStationForbidRobot = new ActionStationForbidRobot();
|
||||
|
@ -174,6 +179,10 @@ public class BuildCraftSilicon extends BuildCraftMod {
|
|||
zonePlanBlock.setBlockName("zonePlan");
|
||||
CoreProxy.proxy.registerBlock(zonePlanBlock);
|
||||
|
||||
requesterBlock = new BlockRequester();
|
||||
requesterBlock.setBlockName("requester");
|
||||
CoreProxy.proxy.registerBlock(requesterBlock);
|
||||
|
||||
redstoneChipset = new ItemRedstoneChipset();
|
||||
redstoneChipset.setUnlocalizedName("redstoneChipset");
|
||||
CoreProxy.proxy.registerItem(redstoneChipset);
|
||||
|
@ -202,6 +211,7 @@ public class BuildCraftSilicon extends BuildCraftMod {
|
|||
RedstoneBoardRegistry.instance.registerBoardClass(BoardRobotLeaveCutterNBT.instance, 5);
|
||||
RedstoneBoardRegistry.instance.registerBoardClass(BoardRobotButcherNBT.instance, 5);
|
||||
RedstoneBoardRegistry.instance.registerBoardClass(BoardRobotShovelmanNBT.instance, 5);
|
||||
RedstoneBoardRegistry.instance.registerBoardClass(BoardRobotCrafterNBT.instance, 5);
|
||||
RedstoneBoardRegistry.instance.registerBoardClass(BoardRobotKnightNBT.instance, 1);
|
||||
RedstoneBoardRegistry.instance.registerBoardClass(BoardRobotBomberNBT.instance, 1);
|
||||
RedstoneBoardRegistry.instance.registerBoardClass(BoardRobotBuilderNBT.instance, 0.5F);
|
||||
|
|
|
@ -25,8 +25,11 @@ import buildcraft.builders.gui.GuiFiller;
|
|||
import buildcraft.builders.urbanism.ContainerUrbanist;
|
||||
import buildcraft.builders.urbanism.GuiUrbanist;
|
||||
import buildcraft.builders.urbanism.TileUrbanist;
|
||||
import buildcraft.commander.ContainerRequester;
|
||||
import buildcraft.commander.ContainerZonePlan;
|
||||
import buildcraft.commander.GuiRequester;
|
||||
import buildcraft.commander.GuiZonePlan;
|
||||
import buildcraft.commander.TileRequester;
|
||||
import buildcraft.commander.TileZonePlan;
|
||||
import buildcraft.core.GuiIds;
|
||||
|
||||
|
@ -78,6 +81,12 @@ public class GuiHandler implements IGuiHandler {
|
|||
}
|
||||
return new GuiZonePlan(player.inventory, (TileZonePlan) tile);
|
||||
|
||||
case GuiIds.REQUESTER:
|
||||
if (!(tile instanceof TileRequester)) {
|
||||
return null;
|
||||
}
|
||||
return new GuiRequester(player.inventory, (TileRequester) tile);
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
@ -133,6 +142,13 @@ public class GuiHandler implements IGuiHandler {
|
|||
return new ContainerZonePlan(player.inventory, (TileZonePlan) tile);
|
||||
}
|
||||
|
||||
case GuiIds.REQUESTER:
|
||||
if (!(tile instanceof TileRequester)) {
|
||||
return null;
|
||||
} else {
|
||||
return new ContainerRequester(player.inventory, (TileRequester) tile);
|
||||
}
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
|
85
common/buildcraft/commander/BlockRequester.java
Executable file
|
@ -0,0 +1,85 @@
|
|||
/**
|
||||
* 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.commander;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import buildcraft.BuildCraftBuilders;
|
||||
import buildcraft.core.BlockBuildCraft;
|
||||
import buildcraft.core.GuiIds;
|
||||
import buildcraft.core.utils.Utils;
|
||||
|
||||
public class BlockRequester extends BlockBuildCraft {
|
||||
|
||||
private IIcon blockTextureSide;
|
||||
private IIcon blockTextureFront;
|
||||
|
||||
public BlockRequester() {
|
||||
super(Material.iron);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world, int meta) {
|
||||
return new TileRequester();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer entityplayer, int par6, float par7,
|
||||
float par8, float par9) {
|
||||
|
||||
if (!world.isRemote) {
|
||||
entityplayer.openGui(BuildCraftBuilders.instance, GuiIds.REQUESTER,
|
||||
world, i, j, k);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase entityliving, ItemStack stack) {
|
||||
super.onBlockPlacedBy(world, i, j, k, entityliving, stack);
|
||||
|
||||
ForgeDirection orientation = Utils.get2dOrientation(entityliving);
|
||||
|
||||
world.setBlockMetadataWithNotify(i, j, k, orientation.getOpposite().ordinal(), 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister par1IconRegister) {
|
||||
blockTextureSide = par1IconRegister.registerIcon("buildcraft:commander_side");
|
||||
blockTextureFront = par1IconRegister.registerIcon("buildcraft:requester_front");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int i, int j) {
|
||||
if (j == 0 && i == 3) {
|
||||
return blockTextureFront;
|
||||
}
|
||||
|
||||
if (i == j) {
|
||||
return blockTextureFront;
|
||||
}
|
||||
|
||||
return blockTextureSide;
|
||||
}
|
||||
|
||||
}
|
50
common/buildcraft/commander/ContainerRequester.java
Executable file
|
@ -0,0 +1,50 @@
|
|||
/**
|
||||
* 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.commander;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
|
||||
import buildcraft.core.gui.BuildCraftContainer;
|
||||
|
||||
public class ContainerRequester extends BuildCraftContainer {
|
||||
|
||||
public GuiRequester gui;
|
||||
|
||||
private TileRequester requester;
|
||||
|
||||
public ContainerRequester(IInventory playerInventory, TileRequester iRequester) {
|
||||
super(iRequester.getSizeInventory());
|
||||
|
||||
requester = iRequester;
|
||||
|
||||
for (int x = 0; x < 4; ++x) {
|
||||
for (int y = 0; y < 5; ++y) {
|
||||
addSlotToContainer(new Slot(iRequester, x * 5 + y, 117 + x * 18, 7 + y * 18));
|
||||
}
|
||||
}
|
||||
|
||||
// Player inventory
|
||||
for (int l = 0; l < 3; l++) {
|
||||
for (int k1 = 0; k1 < 9; k1++) {
|
||||
addSlotToContainer(new Slot(playerInventory, k1 + l * 9 + 9, 19 + k1 * 18, 101 + l * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (int i1 = 0; i1 < 9; i1++) {
|
||||
addSlotToContainer(new Slot(playerInventory, i1, 19 + i1 * 18, 159));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
return true;
|
||||
}
|
||||
}
|
88
common/buildcraft/commander/GuiRequester.java
Executable file
|
@ -0,0 +1,88 @@
|
|||
/**
|
||||
* 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.commander;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import buildcraft.core.DefaultProps;
|
||||
import buildcraft.core.gui.AdvancedSlot;
|
||||
import buildcraft.core.gui.GuiAdvancedInterface;
|
||||
|
||||
public class GuiRequester extends GuiAdvancedInterface {
|
||||
|
||||
private static final ResourceLocation TEXTURE = new ResourceLocation("buildcraft",
|
||||
DefaultProps.TEXTURE_PATH_GUI + "/requester_gui.png");
|
||||
|
||||
private TileRequester requester;
|
||||
|
||||
private IInventory playerInventory;
|
||||
|
||||
private static class RequestSlot extends AdvancedSlot {
|
||||
|
||||
private ItemStack item;
|
||||
|
||||
public RequestSlot(GuiAdvancedInterface gui, int x, int y) {
|
||||
super(gui, x, y);
|
||||
}
|
||||
|
||||
public void setItem(ItemStack itemStack) {
|
||||
item = itemStack.copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack() {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
public GuiRequester(IInventory iPlayerInventory, TileRequester iRequester) {
|
||||
super(new ContainerRequester(iPlayerInventory, iRequester), iPlayerInventory, TEXTURE);
|
||||
|
||||
getContainer().gui = this;
|
||||
|
||||
xSize = 256;
|
||||
ySize = 220;
|
||||
|
||||
requester = iRequester;
|
||||
playerInventory = iPlayerInventory;
|
||||
|
||||
for (int x = 0; x < 4; ++x) {
|
||||
for (int y = 0; y < 5; ++y) {
|
||||
|
||||
slots.add(new RequestSlot(this, 9 + 18 * x, 7 + 18 * y));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float f, int x, int y) {
|
||||
super.drawGuiContainerBackgroundLayer(f, x, y);
|
||||
|
||||
drawBackgroundSlots();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) {
|
||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
|
||||
RequestSlot slot = (RequestSlot) getSlotAtLocation(mouseX, mouseY);
|
||||
|
||||
if (slot != null) {
|
||||
slot.setItem(mc.thePlayer.inventory.getItemStack());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContainerRequester getContainer() {
|
||||
return (ContainerRequester) super.getContainer();
|
||||
}
|
||||
}
|
|
@ -222,10 +222,7 @@ public class GuiZonePlan extends GuiAdvancedInterface {
|
|||
selY2 = 0;
|
||||
}
|
||||
} else {
|
||||
int cornerX = (width - xSize) / 2;
|
||||
int cornerY = (height - ySize) / 2;
|
||||
|
||||
AdvancedSlot slot = getSlotAtLocation(mouseX - cornerX, mouseY - cornerY);
|
||||
AdvancedSlot slot = getSlotAtLocation(mouseX, mouseY);
|
||||
|
||||
if (slot instanceof AreaSlot) {
|
||||
colorSelected = (AreaSlot) slot;
|
||||
|
|
48
common/buildcraft/commander/StackRequest.java
Executable file
|
@ -0,0 +1,48 @@
|
|||
/**
|
||||
* 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.commander;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import buildcraft.api.core.WorldBlockIndex;
|
||||
|
||||
public class StackRequest {
|
||||
|
||||
public static final int NULL_LIFETIME = 20 * 60;
|
||||
|
||||
public WorldBlockIndex holder;
|
||||
public int indexInHolder;
|
||||
public ItemStack stack;
|
||||
public long requestDate;
|
||||
public long loadDate;
|
||||
public boolean fulfilled;
|
||||
|
||||
/**
|
||||
* when loading from NBT, this field may be null. The requested is supposed
|
||||
* to notify the requester upon loading. If fail to do so for more than
|
||||
* NULL_LIFETIME cycles, then the request is forgotten
|
||||
*/
|
||||
public Entity requester;
|
||||
|
||||
public void saveToNBT(NBTTagCompound nbt) {
|
||||
NBTTagCompound index = new NBTTagCompound();
|
||||
holder.writeTo(index);
|
||||
nbt.setTag("index", index);
|
||||
|
||||
nbt.setInteger("indexInHolder", indexInHolder);
|
||||
}
|
||||
|
||||
public void loadFromNBT(NBTTagCompound nbt) {
|
||||
holder = new WorldBlockIndex(nbt.getCompoundTag("index"));
|
||||
indexInHolder = nbt.getInteger("indexInHolder");
|
||||
}
|
||||
}
|
||||
|
146
common/buildcraft/commander/TileRequester.java
Executable file
|
@ -0,0 +1,146 @@
|
|||
/**
|
||||
* 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.commander;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import buildcraft.api.core.WorldBlockIndex;
|
||||
import buildcraft.core.TileBuildCraft;
|
||||
import buildcraft.core.inventory.SimpleInventory;
|
||||
import buildcraft.core.inventory.StackHelper;
|
||||
|
||||
public class TileRequester extends TileBuildCraft implements IInventory {
|
||||
|
||||
public static final int NB_ITEMS = 20;
|
||||
|
||||
private SimpleInventory inv = new SimpleInventory(NB_ITEMS, "items", 64);
|
||||
|
||||
private ArrayList<StackRequest> requirements = new ArrayList<StackRequest>();
|
||||
|
||||
public TileRequester() {
|
||||
for (int i = 0; i < NB_ITEMS; ++i) {
|
||||
requirements.add(null);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean addRequest(ItemStack stack, Entity from) {
|
||||
for (int i = 0; i < NB_ITEMS; ++i) {
|
||||
if (requirements.get(i) == null) {
|
||||
StackRequest r = new StackRequest();
|
||||
|
||||
r.fulfilled = false;
|
||||
r.holder = new WorldBlockIndex(worldObj, xCoord, yCoord, zCoord);
|
||||
r.indexInHolder = i;
|
||||
r.loadDate = worldObj.getTotalWorldTime();
|
||||
r.requestDate = worldObj.getTotalWorldTime();
|
||||
r.requester = from;
|
||||
r.stack = stack;
|
||||
|
||||
requirements.set(i, r);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return inv.getInventoryStackLimit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slotId) {
|
||||
return inv.getStackInSlot(slotId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int slotId, int count) {
|
||||
return inv.decrStackSize(slotId, count);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int slotId) {
|
||||
return inv.getStackInSlotOnClosing(slotId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int slotId, ItemStack itemStack) {
|
||||
inv.setInventorySlotContents(slotId, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return inv.getInventoryName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return inv.hasCustomInventoryName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return inv.getInventoryStackLimit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer entityPlayer) {
|
||||
return inv.isUseableByPlayer(entityPlayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {
|
||||
inv.openInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
inv.closeInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemStack) {
|
||||
StackRequest req = requirements.get(i);
|
||||
|
||||
if (req == null) {
|
||||
return false;
|
||||
} else if (!StackHelper.isMatchingItem(req.stack, itemStack)) {
|
||||
return false;
|
||||
} else {
|
||||
return inv.isItemValidForSlot(i, itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
super.writeToNBT(nbt);
|
||||
|
||||
NBTTagCompound invNBT = new NBTTagCompound();
|
||||
inv.writeToNBT(invNBT);
|
||||
nbt.setTag("inv", invNBT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
super.readFromNBT(nbt);
|
||||
|
||||
System.out.println("READ");
|
||||
|
||||
inv.readFromNBT(nbt.getCompoundTag("inv"));
|
||||
|
||||
}
|
||||
}
|
|
@ -16,6 +16,7 @@ public final class GuiIds {
|
|||
public static final int BLUEPRINT_LIBRARY = 13;
|
||||
public static final int URBANIST = 14;
|
||||
public static final int MAP = 15;
|
||||
public static final int REQUESTER = 16;
|
||||
|
||||
public static final int ENGINE_IRON = 20;
|
||||
public static final int ENGINE_STONE = 21;
|
||||
|
|
|
@ -29,10 +29,13 @@ public abstract class GuiAdvancedInterface extends GuiBuildCraft {
|
|||
}
|
||||
|
||||
public int getSlotIndexAtLocation(int i, int j) {
|
||||
int x = i - (width - xSize) / 2;
|
||||
int y = j - (height - ySize) / 2;
|
||||
|
||||
for (int position = 0; position < slots.size(); ++position) {
|
||||
AdvancedSlot s = slots.get(position);
|
||||
|
||||
if (s != null && i >= s.x && i <= s.x + 16 && j >= s.y && j <= s.y + 16) {
|
||||
if (s != null && x >= s.x && x <= s.x + 16 && y >= s.y && y <= s.y + 16) {
|
||||
return position;
|
||||
}
|
||||
}
|
||||
|
@ -74,10 +77,7 @@ public abstract class GuiAdvancedInterface extends GuiBuildCraft {
|
|||
}
|
||||
|
||||
public void drawTooltipForSlotAt(int mouseX, int mouseY) {
|
||||
int cornerX = (width - xSize) / 2;
|
||||
int cornerY = (height - ySize) / 2;
|
||||
|
||||
AdvancedSlot slot = getSlotAtLocation(mouseX - cornerX, mouseY - cornerY);
|
||||
AdvancedSlot slot = getSlotAtLocation(mouseX, mouseY);
|
||||
|
||||
if (slot != null) {
|
||||
slot.drawTooltip(this, mouseX, mouseY);
|
||||
|
@ -131,10 +131,7 @@ public abstract class GuiAdvancedInterface extends GuiBuildCraft {
|
|||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) {
|
||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
|
||||
int cornerX = (width - xSize) / 2;
|
||||
int cornerY = (height - ySize) / 2;
|
||||
|
||||
AdvancedSlot slot = getSlotAtLocation(mouseX - cornerX, mouseY - cornerY);
|
||||
AdvancedSlot slot = getSlotAtLocation(mouseX, mouseY);
|
||||
|
||||
if (slot != null && slot.isDefined()) {
|
||||
slotClicked(slot);
|
||||
|
|
|
@ -52,8 +52,6 @@ public class BuildCraftRecipe extends ShapedOreRecipe {
|
|||
|
||||
for (Object p : crafters) {
|
||||
EntityPlayer player = (EntityPlayer) p;
|
||||
|
||||
System.out.println(player.getEntityId());
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -19,12 +19,12 @@ public class AIRobotGotoSleep extends AIRobot {
|
|||
|
||||
@Override
|
||||
public void start() {
|
||||
startDelegateAI(new AIRobotGotoDock(robot, robot.getLinkedStation()));
|
||||
startDelegateAI(new AIRobotGotoStation(robot, robot.getLinkedStation()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delegateAIEnded(AIRobot ai) {
|
||||
if (ai instanceof AIRobotGotoDock) {
|
||||
if (ai instanceof AIRobotGotoStation) {
|
||||
startDelegateAI(new AIRobotSleep(robot));
|
||||
} else if (ai instanceof AIRobotSleep) {
|
||||
terminate();
|
||||
|
|
|
@ -12,15 +12,15 @@ import buildcraft.api.robots.AIRobot;
|
|||
import buildcraft.api.robots.EntityRobotBase;
|
||||
import buildcraft.api.robots.IDockingStation;
|
||||
|
||||
public class AIRobotGotoDock extends AIRobot {
|
||||
public class AIRobotGotoStation extends AIRobot {
|
||||
|
||||
private IDockingStation station;
|
||||
|
||||
public AIRobotGotoDock(EntityRobotBase iRobot) {
|
||||
public AIRobotGotoStation(EntityRobotBase iRobot) {
|
||||
super(iRobot);
|
||||
}
|
||||
|
||||
public AIRobotGotoDock(EntityRobotBase iRobot, IDockingStation iStation) {
|
||||
public AIRobotGotoStation(EntityRobotBase iRobot, IDockingStation iStation) {
|
||||
super(iRobot);
|
||||
|
||||
station = iStation;
|
|
@ -72,40 +72,42 @@ public class AIRobotLoad extends AIRobot {
|
|||
IInventory tileInventory = (IInventory) nearbyTile;
|
||||
ITransactor robotTransactor = Transactor.getTransactorFor(robot);
|
||||
|
||||
for (int i = 0; i < robot.getSizeInventory(); ++i) {
|
||||
// TODO: This is suboptimal. We should try to put items
|
||||
// on existing stacks. Look fo AIRobotGotoStationToLoad
|
||||
// as well to fix this problem
|
||||
if (robot.getStackInSlot(i) == null) {
|
||||
for (IInvSlot slot : InventoryIterator.getIterable(tileInventory, dir.getOpposite())) {
|
||||
ItemStack stack = slot.getStackInSlot();
|
||||
for (IInvSlot slot : InventoryIterator.getIterable(tileInventory, dir.getOpposite())) {
|
||||
ItemStack stack = slot.getStackInSlot();
|
||||
|
||||
if (stack != null) {
|
||||
boolean allowed = false;
|
||||
if (stack != null) {
|
||||
boolean allowed = false;
|
||||
|
||||
for (ActionSlot s : new ActionIterator(station.pipe.pipe)) {
|
||||
if (s.action instanceof ActionStationProvideItems) {
|
||||
StatementParameterStackFilter param = new StatementParameterStackFilter(
|
||||
s.parameters);
|
||||
for (ActionSlot s : new ActionIterator(station.pipe.pipe)) {
|
||||
if (s.action instanceof ActionStationProvideItems) {
|
||||
StatementParameterStackFilter param = new StatementParameterStackFilter(
|
||||
s.parameters);
|
||||
|
||||
if (!param.hasFilter() || param.matches(stack)) {
|
||||
allowed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!param.hasFilter() || param.matches(stack)) {
|
||||
allowed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (allowed && filter.matches(stack)) {
|
||||
ITransactor t = Transactor.getTransactorFor(robot);
|
||||
|
||||
if (quantity == -1) {
|
||||
|
||||
ItemStack added = t.add(slot.getStackInSlot(), ForgeDirection.UNKNOWN, true);
|
||||
slot.decreaseStackInSlot(added.stackSize);
|
||||
return;
|
||||
} else {
|
||||
ItemStack toAdd = slot.getStackInSlot().copy();
|
||||
|
||||
if (toAdd.stackSize >= quantity) {
|
||||
toAdd.stackSize = quantity;
|
||||
}
|
||||
|
||||
if (allowed && filter.matches(stack)) {
|
||||
if (quantity == -1) {
|
||||
slot.setStackInSlot(null);
|
||||
robot.setInventorySlotContents(i, stack);
|
||||
return;
|
||||
} else {
|
||||
robot.setInventorySlotContents
|
||||
(i, slot.decreaseStackInSlot(quantity));
|
||||
return;
|
||||
}
|
||||
}
|
||||
ItemStack added = t.add(toAdd, ForgeDirection.UNKNOWN, true);
|
||||
slot.decreaseStackInSlot(added.stackSize);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ public class AIRobotSearchAndGotoStation extends AIRobot {
|
|||
public void start() {
|
||||
if (robot.getDockingStation() != null
|
||||
&& filter.matches((DockingStation) robot.getDockingStation())) {
|
||||
targetStation = (DockingStation) robot.getDockingStation();
|
||||
terminate();
|
||||
return;
|
||||
}
|
||||
|
@ -73,7 +74,7 @@ public class AIRobotSearchAndGotoStation extends AIRobot {
|
|||
|
||||
if (potentialStation != null) {
|
||||
targetStation = potentialStation;
|
||||
startDelegateAI(new AIRobotGotoDock(robot, potentialStation));
|
||||
startDelegateAI(new AIRobotGotoStation(robot, potentialStation));
|
||||
} else {
|
||||
terminate();
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
package buildcraft.core.robots;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.LinkedList;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
@ -20,6 +21,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.EntityDamageSource;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
|
@ -28,6 +30,8 @@ import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData;
|
|||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
|
||||
import buildcraft.BuildCraftSilicon;
|
||||
import buildcraft.api.boards.RedstoneBoardNBT;
|
||||
import buildcraft.api.boards.RedstoneBoardRegistry;
|
||||
|
@ -39,6 +43,7 @@ import buildcraft.api.mj.MjBattery;
|
|||
import buildcraft.api.robots.AIRobot;
|
||||
import buildcraft.api.robots.EntityRobotBase;
|
||||
import buildcraft.api.robots.IDockingStation;
|
||||
import buildcraft.commander.StackRequest;
|
||||
import buildcraft.core.DefaultProps;
|
||||
import buildcraft.core.LaserData;
|
||||
import buildcraft.core.network.RPC;
|
||||
|
@ -89,9 +94,14 @@ public class EntityRobot extends EntityRobotBase implements
|
|||
private IDockingStation currentDockingStation;
|
||||
private WeakHashMap<Entity, Boolean> unreachableEntities = new WeakHashMap<Entity, Boolean>();
|
||||
|
||||
private NBTTagList stackRequestNBT;
|
||||
private LinkedList<StackRequest> stackRequests = new LinkedList<StackRequest>();
|
||||
|
||||
@MjBattery
|
||||
private double mjStored;
|
||||
|
||||
private boolean firstUpdateDone = false;
|
||||
|
||||
public EntityRobot(World world, NBTTagCompound boardNBT) {
|
||||
this(world);
|
||||
|
||||
|
@ -195,8 +205,19 @@ public class EntityRobot extends EntityRobotBase implements
|
|||
}
|
||||
}
|
||||
|
||||
protected void firstUpdate() {
|
||||
if (stackRequestNBT != null) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
if (!firstUpdateDone) {
|
||||
firstUpdate();
|
||||
firstUpdateDone = true;
|
||||
}
|
||||
|
||||
if (!worldObj.isRemote && needsUpdate) {
|
||||
updateDataServer();
|
||||
needsUpdate = false;
|
||||
|
@ -401,6 +422,22 @@ public class EntityRobot extends EntityRobotBase implements
|
|||
board.writeToNBT(boardNBT);
|
||||
nbt.setTag("board", boardNBT);
|
||||
}
|
||||
|
||||
NBTTagList requestsNBT = new NBTTagList();
|
||||
|
||||
for (StackRequest r : stackRequests) {
|
||||
NBTTagCompound cpt = new NBTTagCompound();
|
||||
|
||||
NBTTagCompound index = new NBTTagCompound();
|
||||
r.holder.writeTo(index);
|
||||
cpt.setTag("index", index);
|
||||
|
||||
cpt.setInteger("indexInHolder", r.indexInHolder);
|
||||
|
||||
requestsNBT.appendTag(cpt);
|
||||
}
|
||||
|
||||
nbt.setTag("stackRequests", requestsNBT);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -445,6 +482,8 @@ public class EntityRobot extends EntityRobotBase implements
|
|||
}
|
||||
|
||||
dataWatcher.updateObject(16, board.getNBTHandler().getID());
|
||||
|
||||
stackRequestNBT = nbt.getTagList("stackRequests", Constants.NBT.TAG_COMPOUND);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
311
common/buildcraft/core/robots/boards/BoardRobotCrafter.java
Executable file
|
@ -0,0 +1,311 @@
|
|||
/**
|
||||
* 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.ArrayList;
|
||||
import java.util.HashSet;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockWorkbench;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.item.crafting.ShapedRecipes;
|
||||
import net.minecraft.item.crafting.ShapelessRecipes;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import buildcraft.api.boards.RedstoneBoardRobot;
|
||||
import buildcraft.api.boards.RedstoneBoardRobotNBT;
|
||||
import buildcraft.api.core.IInvSlot;
|
||||
import buildcraft.api.gates.ActionParameterItemStack;
|
||||
import buildcraft.api.gates.IActionParameter;
|
||||
import buildcraft.api.robots.AIRobot;
|
||||
import buildcraft.api.robots.EntityRobotBase;
|
||||
import buildcraft.api.robots.IDockingStation;
|
||||
import buildcraft.core.inventory.ITransactor;
|
||||
import buildcraft.core.inventory.InventoryIterator;
|
||||
import buildcraft.core.inventory.StackHelper;
|
||||
import buildcraft.core.inventory.Transactor;
|
||||
import buildcraft.core.inventory.filters.ArrayStackFilter;
|
||||
import buildcraft.core.inventory.filters.IStackFilter;
|
||||
import buildcraft.core.robots.AIRobotGotoStationToLoad;
|
||||
import buildcraft.core.robots.AIRobotGotoStationToUnload;
|
||||
import buildcraft.core.robots.AIRobotLoad;
|
||||
import buildcraft.core.robots.AIRobotSearchAndGotoStation;
|
||||
import buildcraft.core.robots.AIRobotSleep;
|
||||
import buildcraft.core.robots.AIRobotUnload;
|
||||
import buildcraft.core.robots.DockingStation;
|
||||
import buildcraft.core.robots.IStationFilter;
|
||||
import buildcraft.silicon.statements.ActionRobotCraft;
|
||||
import buildcraft.transport.gates.ActionIterator;
|
||||
import buildcraft.transport.gates.ActionSlot;
|
||||
|
||||
public class BoardRobotCrafter extends RedstoneBoardRobot {
|
||||
|
||||
private ItemStack order;
|
||||
private ArrayList<ItemStack> craftingBlacklist = new ArrayList<ItemStack>();
|
||||
private HashSet<IDockingStation> reservedStations = new HashSet<IDockingStation>();
|
||||
private ArrayList<ItemStack> requirements = new ArrayList<ItemStack>();
|
||||
private IRecipe recipe;
|
||||
private int craftingTimer = 0;
|
||||
|
||||
public BoardRobotCrafter(EntityRobotBase iRobot) {
|
||||
super(iRobot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedstoneBoardRobotNBT getNBTHandler() {
|
||||
return BoardRobotCrafterNBT.instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
|
||||
// [1] look for a crafting order
|
||||
// -- if none, clear temporary item blacklist and sleep
|
||||
// [2] look and fetch items needed to craft (problem with 9 slots inv?)
|
||||
// -- if can't be done, add item to temporary blacklist, drop inv either
|
||||
// -- in a inventory accepting items or drop in the world, then look for
|
||||
// -- another order
|
||||
// [3] look and goto a station next to a workbench, craft
|
||||
// -- if not, sleep
|
||||
// [4] drop the crafting item where possible
|
||||
// -- if not, sleep
|
||||
|
||||
if (craftingTimer > 0) {
|
||||
craftingTimer--;
|
||||
|
||||
if (craftingTimer == 0) {
|
||||
craft();
|
||||
startDelegateAI(new AIRobotGotoStationToUnload(robot, robot.getZoneToWork()));
|
||||
}
|
||||
} else if (order == null) {
|
||||
order = getCraftingOrder();
|
||||
|
||||
if (order == null) {
|
||||
craftingBlacklist.clear();
|
||||
startDelegateAI(new AIRobotSleep(robot));
|
||||
return;
|
||||
}
|
||||
|
||||
recipe = lookForRecipe(order);
|
||||
|
||||
if (recipe == null) {
|
||||
craftingBlacklist.add(order);
|
||||
order = null;
|
||||
return;
|
||||
}
|
||||
|
||||
requirements = getRequirements(recipe);
|
||||
|
||||
if (requirements == null) {
|
||||
craftingBlacklist.add(order);
|
||||
order = null;
|
||||
return;
|
||||
}
|
||||
|
||||
mergeRequirements();
|
||||
} else if (requirements.size() > 0) {
|
||||
startDelegateAI(new AIRobotGotoStationToLoad(robot, new ReqStackFilter(), robot.getZoneToWork()));
|
||||
} else {
|
||||
startDelegateAI(new AIRobotSearchAndGotoStation(robot, new StationWorkbenchFilter(), robot.getZoneToWork()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delegateAIEnded(AIRobot ai) {
|
||||
if (ai instanceof AIRobotGotoStationToLoad) {
|
||||
if (((AIRobotGotoStationToLoad) ai).found) {
|
||||
startDelegateAI(new AIRobotLoad(robot, new ReqStackFilter(), 1));
|
||||
} else {
|
||||
craftingBlacklist.add(order);
|
||||
order = null;
|
||||
requirements.clear();
|
||||
|
||||
// drop items in inventory.
|
||||
startDelegateAI(new AIRobotGotoStationToUnload(robot, robot.getZoneToWork()));
|
||||
}
|
||||
} else if (ai instanceof AIRobotLoad) {
|
||||
// Check requirements v.s. contents
|
||||
|
||||
for (int i = requirements.size() - 1; i >= 0; --i) {
|
||||
ItemStack req = requirements.get(i);
|
||||
int qty = 0;
|
||||
|
||||
for (IInvSlot slot : InventoryIterator.getIterable(robot)) {
|
||||
if (StackHelper.isMatchingItem(req, slot.getStackInSlot())) {
|
||||
qty += slot.getStackInSlot().stackSize;
|
||||
}
|
||||
}
|
||||
|
||||
if (qty >= req.stackSize) {
|
||||
requirements.remove(i);
|
||||
}
|
||||
}
|
||||
} else if (ai instanceof AIRobotGotoStationToUnload) {
|
||||
if (((AIRobotGotoStationToUnload) ai).found) {
|
||||
startDelegateAI(new AIRobotUnload(robot));
|
||||
}
|
||||
} else if (ai instanceof AIRobotSearchAndGotoStation) {
|
||||
if (new StationWorkbenchFilter().matches((DockingStation) robot.getDockingStation())) {
|
||||
craftingTimer = 40;
|
||||
} else {
|
||||
startDelegateAI(new AIRobotSleep(robot));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void mergeRequirements() {
|
||||
for (int i = 0; i < requirements.size(); ++i) {
|
||||
for (int j = i + 1; j < requirements.size(); ++j) {
|
||||
if (StackHelper.isMatchingItem(requirements.get(i), requirements.get(j))) {
|
||||
requirements.get(i).stackSize += requirements.get(j).stackSize;
|
||||
requirements.get(j).stackSize = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = requirements.size() - 1; i >= 0; --i) {
|
||||
if (requirements.get(i).stackSize == 0) {
|
||||
requirements.remove(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ArrayList<ItemStack> getRequirements(IRecipe recipe) {
|
||||
if (recipe instanceof ShapelessRecipes) {
|
||||
ArrayList<ItemStack> result = new ArrayList<ItemStack>();
|
||||
|
||||
ShapelessRecipes r = (ShapelessRecipes) recipe;
|
||||
|
||||
for (Object o : r.recipeItems) {
|
||||
result.add(((ItemStack) o).copy());
|
||||
}
|
||||
|
||||
return result;
|
||||
} else if (recipe instanceof ShapedRecipes) {
|
||||
ArrayList<ItemStack> result = new ArrayList<ItemStack>();
|
||||
|
||||
ShapedRecipes r = (ShapedRecipes) recipe;
|
||||
|
||||
for (ItemStack s : r.recipeItems) {
|
||||
if (s != null) {
|
||||
result.add(s.copy());
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private IRecipe lookForRecipe(ItemStack order) {
|
||||
for (Object o : CraftingManager.getInstance().getRecipeList()) {
|
||||
IRecipe r = (IRecipe) o;
|
||||
|
||||
if (r instanceof ShapedRecipes || r instanceof ShapelessRecipes) {
|
||||
if (StackHelper.isMatchingItem(r.getRecipeOutput(), order)) {
|
||||
return r;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean isBlacklisted(ItemStack stack) {
|
||||
for (ItemStack black : craftingBlacklist) {
|
||||
if (StackHelper.isMatchingItem(stack, black)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private ItemStack getCraftingOrder() {
|
||||
// [1] priority from the current station order
|
||||
|
||||
DockingStation s = (DockingStation) robot.getLinkedStation();
|
||||
|
||||
for (ActionSlot slot : new ActionIterator(s.pipe.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// [2] if no order, will look at the "request" stations (either from
|
||||
// inventories or machines).
|
||||
// when taking a "request" order, lock the target station
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void craft() {
|
||||
ArrayList<ItemStack> tmpReq = getRequirements(recipe);
|
||||
|
||||
ITransactor transactor = Transactor.getTransactorFor(robot);
|
||||
|
||||
for (ItemStack s : tmpReq) {
|
||||
for (int i = 0; i < s.stackSize; ++i) {
|
||||
transactor.remove(new ArrayStackFilter(s), ForgeDirection.UNKNOWN, true);
|
||||
}
|
||||
}
|
||||
|
||||
transactor.add(order, ForgeDirection.UNKNOWN, true);
|
||||
|
||||
order = null;
|
||||
recipe = null;
|
||||
}
|
||||
|
||||
private class ReqStackFilter implements IStackFilter {
|
||||
|
||||
@Override
|
||||
public boolean matches(ItemStack stack) {
|
||||
for (ItemStack s : requirements) {
|
||||
if (StackHelper.isMatchingItem(stack, s)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private class StationWorkbenchFilter implements IStationFilter {
|
||||
|
||||
@Override
|
||||
public boolean matches(DockingStation station) {
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
Block nearbyBlock = robot.worldObj.getBlock(station.x() + dir.offsetX, station.y()
|
||||
+ dir.offsetY, station.z()
|
||||
+ dir.offsetZ);
|
||||
|
||||
if (nearbyBlock instanceof BlockWorkbench) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
64
common/buildcraft/core/robots/boards/BoardRobotCrafterNBT.java
Executable file
|
@ -0,0 +1,64 @@
|
|||
/**
|
||||
* 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 BoardRobotCrafterNBT extends RedstoneBoardRobotNBT {
|
||||
|
||||
public static BoardRobotCrafterNBT instance = new BoardRobotCrafterNBT();
|
||||
|
||||
private static final ResourceLocation TEXTURE = new ResourceLocation("buildcraft",
|
||||
DefaultProps.TEXTURE_PATH_ENTITIES + "/robot_crafter.png");
|
||||
|
||||
private IIcon icon;
|
||||
|
||||
@Override
|
||||
public RedstoneBoardRobot create(NBTTagCompound nbt, EntityRobotBase robot) {
|
||||
return new BoardRobotCrafter(robot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getRobotTexture() {
|
||||
return TEXTURE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getID() {
|
||||
return "buildcraft:boardRobotCrafter";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean advanced) {
|
||||
list.add(StringUtils.localize("buildcraft.boardRobotCrafter"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IIconRegister iconRegister) {
|
||||
icon = iconRegister.registerIcon("buildcraft:board_blue");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(NBTTagCompound nbt) {
|
||||
return icon;
|
||||
}
|
||||
}
|
|
@ -69,10 +69,7 @@ public class GuiRefinery extends GuiAdvancedInterface {
|
|||
protected void mouseClicked(int i, int j, int k) {
|
||||
super.mouseClicked(i, j, k);
|
||||
|
||||
int cornerX = (width - xSize) / 2;
|
||||
int cornerY = (height - ySize) / 2;
|
||||
|
||||
int position = getSlotIndexAtLocation(i - cornerX, j - cornerY);
|
||||
int position = getSlotIndexAtLocation(i, j);
|
||||
|
||||
if (position >= 0 && position < 2) {
|
||||
if (k == 0) {
|
||||
|
|
|
@ -162,10 +162,7 @@ public class GuiAssemblyTable extends GuiAdvancedInterface {
|
|||
protected void mouseClicked(int i, int j, int k) {
|
||||
super.mouseClicked(i, j, k);
|
||||
|
||||
int cornerX = (width - xSize) / 2;
|
||||
int cornerY = (height - ySize) / 2;
|
||||
|
||||
RecipeSlot slot = (RecipeSlot) getSlotAtLocation(i - cornerX, j - cornerY);
|
||||
RecipeSlot slot = (RecipeSlot) getSlotAtLocation(i, j);
|
||||
|
||||
if (slot != null) {
|
||||
if (slot.crafting == null) {
|
||||
|
|
43
common/buildcraft/silicon/statements/ActionRobotCraft.java
Executable file
|
@ -0,0 +1,43 @@
|
|||
/**
|
||||
* 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 buildcraft.api.gates.ActionParameterItemStack;
|
||||
import buildcraft.api.gates.IActionParameter;
|
||||
import buildcraft.core.triggers.BCActionPassive;
|
||||
import buildcraft.core.utils.StringUtils;
|
||||
|
||||
public class ActionRobotCraft extends BCActionPassive {
|
||||
|
||||
public ActionRobotCraft() {
|
||||
super("buildcraft:station.craft");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return StringUtils.localize("gate.action.station.craft");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerIcons(IIconRegister iconRegister) {
|
||||
icon = iconRegister.registerIcon("buildcraft:triggers/action_robot_craft");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int maxParameters() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IActionParameter createParameter(int index) {
|
||||
return new ActionParameterItemStack();
|
||||
}
|
||||
}
|
|
@ -8,6 +8,7 @@
|
|||
*/
|
||||
package buildcraft.silicon.statements;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
|
||||
|
@ -21,6 +22,8 @@ import buildcraft.BuildCraftSilicon;
|
|||
import buildcraft.api.gates.IAction;
|
||||
import buildcraft.api.gates.IActionProvider;
|
||||
import buildcraft.api.transport.IPipeTile;
|
||||
import buildcraft.core.robots.DockingStation;
|
||||
import buildcraft.core.robots.boards.BoardRobotCrafter;
|
||||
import buildcraft.transport.PipeTransportItems;
|
||||
import buildcraft.transport.TileGenericPipe;
|
||||
|
||||
|
@ -30,16 +33,15 @@ public class RobotsActionProvider implements IActionProvider {
|
|||
public Collection<IAction> getPipeActions(IPipeTile pipe) {
|
||||
LinkedList<IAction> result = new LinkedList<IAction>();
|
||||
|
||||
boolean stationFound = false;
|
||||
ArrayList<DockingStation> stations = new ArrayList<DockingStation>();
|
||||
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
if (((TileGenericPipe) pipe).getStation(dir) != null) {
|
||||
stationFound = true;
|
||||
break;
|
||||
stations.add(((TileGenericPipe) pipe).getStation(dir));
|
||||
}
|
||||
}
|
||||
|
||||
if (!stationFound) {
|
||||
if (stations.size() == 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -49,6 +51,12 @@ public class RobotsActionProvider implements IActionProvider {
|
|||
result.add(BuildCraftSilicon.actionRobotFilter);
|
||||
result.add(BuildCraftSilicon.actionStationForbidRobot);
|
||||
|
||||
for (DockingStation s : stations) {
|
||||
if (s.linked() != null && s.linked().getBoard() instanceof BoardRobotCrafter) {
|
||||
result.add(BuildCraftSilicon.actionRobotCraft);
|
||||
}
|
||||
}
|
||||
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
if (((TileGenericPipe) pipe).getTile(dir) instanceof IInventory) {
|
||||
result.add(BuildCraftSilicon.actionStationProvideItems);
|
||||
|
|
|
@ -372,11 +372,7 @@ public class GuiGateInterface extends GuiAdvancedInterface {
|
|||
}
|
||||
super.mouseClicked(i, j, k);
|
||||
|
||||
int cornerX = (width - xSize) / 2;
|
||||
int cornerY = (height - ySize) / 2;
|
||||
|
||||
|
||||
AdvancedSlot slot = getSlotAtLocation(i - cornerX, j - cornerY);
|
||||
AdvancedSlot slot = getSlotAtLocation(i, j);
|
||||
|
||||
if (slot instanceof TriggerSlot && container.hasTriggers()) {
|
||||
TriggerSlot triggerSlot = (TriggerSlot) slot;
|
||||
|
|