completed a first robot+board, #1732
This commit is contained in:
parent
ce55fe5eb1
commit
3f925ae0e9
19 changed files with 335 additions and 394 deletions
api/buildcraft/api/boards
buildcraft_resources/assets/buildcraft/lang
common/buildcraft
|
@ -12,4 +12,5 @@ public interface IRedstoneBoard<T> {
|
|||
|
||||
void updateBoard(T container);
|
||||
|
||||
String getID();
|
||||
}
|
||||
|
|
17
api/buildcraft/api/boards/IRedstoneBoardRobot.java
Executable file
17
api/buildcraft/api/boards/IRedstoneBoardRobot.java
Executable file
|
@ -0,0 +1,17 @@
|
|||
/**
|
||||
* 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.api.boards;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public interface IRedstoneBoardRobot<T> extends IRedstoneBoard<T> {
|
||||
|
||||
ResourceLocation getRobotTexture();
|
||||
|
||||
}
|
21
api/buildcraft/api/boards/IRedstoneBoardRobotNBT.java
Executable file
21
api/buildcraft/api/boards/IRedstoneBoardRobotNBT.java
Executable file
|
@ -0,0 +1,21 @@
|
|||
/**
|
||||
* 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.api.boards;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public interface IRedstoneBoardRobotNBT extends IRedstoneBoardNBT {
|
||||
|
||||
@Override
|
||||
IRedstoneBoardRobot create(NBTTagCompound nbt);
|
||||
|
||||
ResourceLocation getRobotTexture();
|
||||
|
||||
}
|
|
@ -21,5 +21,7 @@ public abstract class RedstoneBoardRegistry {
|
|||
|
||||
public abstract IRedstoneBoardNBT getRedstoneBoard(NBTTagCompound nbt);
|
||||
|
||||
public abstract IRedstoneBoardNBT getRedstoneBoard(String id);
|
||||
|
||||
public abstract void registerIcons(IIconRegister par1IconRegister);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# Master language file
|
||||
|
||||
buildcraft.boardRobotPicker=Picker Program
|
||||
|
||||
chat.pipe.power.iron.mode=Switched to %d MJ/t limit
|
||||
chat.pipe.power.energyConverter=Energy conversion: %s
|
||||
chat.pipe.power.energyConverter.from_old_to_new=From old API to new API
|
||||
|
@ -133,6 +135,7 @@ item.redstone_pulsating_chipset.name=Pulsating Chipset
|
|||
item.redstone_quartz_chipset.name=Quartz Chipset
|
||||
item.redstone_comp_chipset.name=Redstone Comp Chipset
|
||||
item.redstone_board.name=Redstone Board
|
||||
item.robot.name=Robot
|
||||
item.blueprintItem.name=Blueprint
|
||||
item.blueprint.unnamed=<unnamed>
|
||||
item.blueprint.author=by
|
||||
|
|
|
@ -85,8 +85,6 @@ import buildcraft.core.recipes.IntegrationRecipeManager;
|
|||
import buildcraft.core.recipes.RefineryRecipeManager;
|
||||
import buildcraft.core.render.BlockHighlightHandler;
|
||||
import buildcraft.core.robots.EntityRobot;
|
||||
import buildcraft.core.robots.EntityRobotBuilder;
|
||||
import buildcraft.core.robots.EntityRobotPicker;
|
||||
import buildcraft.core.triggers.ActionMachineControl;
|
||||
import buildcraft.core.triggers.ActionMachineControl.Mode;
|
||||
import buildcraft.core.triggers.ActionRedstoneOutput;
|
||||
|
@ -322,10 +320,7 @@ public class BuildCraftCore extends BuildCraftMod {
|
|||
loadRecipes();
|
||||
}
|
||||
EntityRegistry.registerModEntity(EntityRobot.class, "bcRobot", EntityIds.ROBOT, instance, 50, 1, true);
|
||||
EntityRegistry.registerModEntity(EntityRobotPicker.class, "bcRobotPicker", EntityIds.ROBOT_PICKER, instance, 50, 1, true);
|
||||
EntityRegistry.registerModEntity(EntityRobotBuilder.class, "bcRobotBuilder", EntityIds.ROBOT_BUILDER, instance, 50, 1, true);
|
||||
EntityRegistry.registerModEntity(EntityRobotUrbanism.class, "bcRobotUrbanism", EntityIds.ROBOT_URBANISM, instance, 50, 1, true);
|
||||
EntityList.classToStringMapping.remove(EntityRobotBuilder.class);
|
||||
EntityList.stringToClassMapping.remove("BuildCraft|Core.bcRobot");
|
||||
EntityList.stringToClassMapping.remove("BuildCraft|Core.bcLaser");
|
||||
EntityList.stringToClassMapping.remove("BuildCraft|Core.bcEnergyLaser");
|
||||
|
|
|
@ -36,9 +36,7 @@ import buildcraft.core.ItemBuildCraft;
|
|||
import buildcraft.core.ItemRobot;
|
||||
import buildcraft.core.Version;
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
import buildcraft.core.robots.EntityRobot;
|
||||
import buildcraft.core.robots.EntityRobotBuilder;
|
||||
import buildcraft.core.robots.EntityRobotPicker;
|
||||
import buildcraft.core.robots.RobotIntegrationRecipe;
|
||||
import buildcraft.core.robots.boards.BoardRobotPickerNBT;
|
||||
import buildcraft.silicon.BlockLaser;
|
||||
import buildcraft.silicon.BlockLaserTable;
|
||||
|
@ -76,9 +74,7 @@ public class BuildCraftSilicon extends BuildCraftMod {
|
|||
public static BuildCraftSilicon instance;
|
||||
|
||||
public static Item redstoneCrystal;
|
||||
public static Item robotBaseItem;
|
||||
public static Item robotBuilderItem;
|
||||
public static Item robotPickerItem;
|
||||
public static Item robotItem;
|
||||
|
||||
@Mod.EventHandler
|
||||
public void preInit(FMLPreInitializationEvent evt) {
|
||||
|
@ -106,14 +102,8 @@ public class BuildCraftSilicon extends BuildCraftMod {
|
|||
CoreProxy.proxy.registerItem(redstoneCrystal);
|
||||
OreDictionary.registerOre("redstoneCrystal", new ItemStack(redstoneCrystal));
|
||||
|
||||
robotBaseItem = new ItemRobot(EntityRobot.class).setUnlocalizedName("robotBase");
|
||||
CoreProxy.proxy.registerItem(robotBaseItem);
|
||||
|
||||
robotPickerItem = new ItemRobot(EntityRobotPicker.class).setUnlocalizedName("robotPicker");
|
||||
CoreProxy.proxy.registerItem(robotPickerItem);
|
||||
|
||||
robotBuilderItem = new ItemRobot(EntityRobotBuilder.class).setUnlocalizedName("robotBuilder");
|
||||
CoreProxy.proxy.registerItem(robotBuilderItem);
|
||||
robotItem = new ItemRobot().setUnlocalizedName("robot");
|
||||
CoreProxy.proxy.registerItem(robotItem);
|
||||
|
||||
RedstoneBoardRegistry.instance = new ImplRedstoneBoardRegistry();
|
||||
|
||||
|
@ -211,7 +201,7 @@ public class BuildCraftSilicon extends BuildCraftMod {
|
|||
'R', Items.redstone,
|
||||
'P', Items.paper);
|
||||
|
||||
CoreProxy.proxy.addCraftingRecipe(new ItemStack(robotBaseItem),
|
||||
CoreProxy.proxy.addCraftingRecipe(new ItemStack(robotItem),
|
||||
"PPP",
|
||||
"PRP",
|
||||
"C C",
|
||||
|
@ -220,6 +210,7 @@ public class BuildCraftSilicon extends BuildCraftMod {
|
|||
'C', Chipset.DIAMOND.getStack());
|
||||
|
||||
BuildcraftRecipes.assemblyTable.addRecipe(new BoardRecipe());
|
||||
BuildcraftRecipes.integrationTable.addRecipe(new RobotIntegrationRecipe());
|
||||
|
||||
// REVERSAL RECIPES
|
||||
EnumSet<GateMaterial> materials = EnumSet.allOf(GateMaterial.class);
|
||||
|
|
|
@ -8,27 +8,75 @@
|
|||
*/
|
||||
package buildcraft.core;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import buildcraft.api.boards.IRedstoneBoardNBT;
|
||||
import buildcraft.api.boards.IRedstoneBoardRobot;
|
||||
import buildcraft.api.boards.IRedstoneBoardRobotNBT;
|
||||
import buildcraft.api.boards.RedstoneBoardRegistry;
|
||||
import buildcraft.core.robots.EntityRobot;
|
||||
import buildcraft.core.utils.NBTUtils;
|
||||
|
||||
public class ItemRobot extends ItemBuildCraft {
|
||||
|
||||
Class<? extends EntityRobot> robotClass;
|
||||
|
||||
public ItemRobot(Class<? extends EntityRobot> robotClass) {
|
||||
public ItemRobot() {
|
||||
super(CreativeTabBuildCraft.ITEMS);
|
||||
|
||||
this.robotClass = robotClass;
|
||||
}
|
||||
|
||||
public EntityRobot createRobot (World world) {
|
||||
public EntityRobot createRobot(ItemStack stack, World world) {
|
||||
try {
|
||||
return this.robotClass.getConstructor(World.class).newInstance(world);
|
||||
IRedstoneBoardRobot board = null;
|
||||
NBTTagCompound nbt = NBTUtils.getItemData(stack);
|
||||
|
||||
if (nbt.hasKey("board")) {
|
||||
NBTTagCompound boardCpt = nbt.getCompoundTag("board");
|
||||
IRedstoneBoardNBT boardNBT = RedstoneBoardRegistry.instance.getRedstoneBoard(boardCpt);
|
||||
|
||||
if (boardNBT instanceof IRedstoneBoardRobotNBT) {
|
||||
board = ((IRedstoneBoardRobotNBT) boardNBT).create(boardCpt);
|
||||
}
|
||||
}
|
||||
|
||||
EntityRobot robot = new EntityRobot(world, board);
|
||||
|
||||
return robot;
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public ResourceLocation getTextureRobot(ItemStack stack) {
|
||||
NBTTagCompound nbt = NBTUtils.getItemData(stack);
|
||||
|
||||
if (!nbt.hasKey("board")) {
|
||||
return EntityRobot.ROBOT_BASE;
|
||||
} else {
|
||||
NBTTagCompound board = nbt.getCompoundTag("board");
|
||||
IRedstoneBoardNBT boardNBT = RedstoneBoardRegistry.instance.getRedstoneBoard(board);
|
||||
|
||||
if (boardNBT instanceof IRedstoneBoardRobotNBT) {
|
||||
return ((IRedstoneBoardRobotNBT) boardNBT).getRobotTexture();
|
||||
} else {
|
||||
return EntityRobot.ROBOT_BASE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean advanced) {
|
||||
NBTTagCompound cpt = NBTUtils.getItemData(stack).getCompoundTag("board");
|
||||
|
||||
if (cpt.hasKey("id") && !cpt.getString("id").equals("<unknown>")) {
|
||||
RedstoneBoardRegistry.instance.getRedstoneBoard(cpt).addInformation(stack, player, list, advanced);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -38,7 +38,6 @@ import buildcraft.core.render.RenderRobot;
|
|||
import buildcraft.core.render.RenderingEntityBlocks;
|
||||
import buildcraft.core.render.RenderingMarkers;
|
||||
import buildcraft.core.robots.EntityRobot;
|
||||
import buildcraft.core.robots.EntityRobotBuilder;
|
||||
import buildcraft.transport.render.TileEntityPickupFX;
|
||||
|
||||
public class CoreProxyClient extends CoreProxy {
|
||||
|
@ -101,16 +100,13 @@ public class CoreProxyClient extends CoreProxy {
|
|||
RenderingRegistry.registerBlockHandler(new RenderingMarkers());
|
||||
|
||||
// TODO: Move these to a Silicon proxy renderer
|
||||
MinecraftForgeClient.registerItemRenderer(BuildCraftSilicon.robotBaseItem, new RenderRobot());
|
||||
MinecraftForgeClient.registerItemRenderer(BuildCraftSilicon.robotBuilderItem, new RenderRobot());
|
||||
MinecraftForgeClient.registerItemRenderer(BuildCraftSilicon.robotPickerItem, new RenderRobot());
|
||||
MinecraftForgeClient.registerItemRenderer(BuildCraftSilicon.robotItem, new RenderRobot());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initializeEntityRendering() {
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityBlock.class, RenderEntityBlock.INSTANCE);
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityRobot.class, new RenderRobot());
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityRobotBuilder.class, new RenderRobot());
|
||||
}
|
||||
|
||||
/* BUILDCRAFT PLAYER */
|
||||
|
|
|
@ -22,16 +22,12 @@ import net.minecraft.util.ResourceLocation;
|
|||
import net.minecraftforge.client.IItemRenderer;
|
||||
|
||||
import buildcraft.BuildCraftSilicon;
|
||||
import buildcraft.core.DefaultProps;
|
||||
import buildcraft.core.EntityLaser;
|
||||
import buildcraft.core.ItemRobot;
|
||||
import buildcraft.core.robots.EntityRobot;
|
||||
|
||||
public class RenderRobot extends Render implements IItemRenderer {
|
||||
|
||||
public static final ResourceLocation TEXTURE_BASE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_ENTITIES + "/robot_base.png");
|
||||
public static final ResourceLocation TEXTURE_BUILDER = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_ENTITIES + "/robot_builder.png");
|
||||
public static final ResourceLocation TEXTURE_PICKER = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_ENTITIES + "/robot_picker.png");
|
||||
|
||||
protected ModelBase model = new ModelBase() {
|
||||
};
|
||||
private ModelRenderer box;
|
||||
|
@ -75,7 +71,7 @@ public class RenderRobot extends Render implements IItemRenderer {
|
|||
|
||||
@Override
|
||||
protected ResourceLocation getEntityTexture(Entity entity) {
|
||||
return TEXTURE_BASE;
|
||||
return ((EntityRobot) entity).getTexture();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -106,14 +102,9 @@ public class RenderRobot extends Render implements IItemRenderer {
|
|||
GL11.glPushMatrix();
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
|
||||
// FIXME: Texture localisation should be factorized between items and
|
||||
// entities.
|
||||
if (item.getItem() == BuildCraftSilicon.robotBaseItem) {
|
||||
RenderManager.instance.renderEngine.bindTexture(TEXTURE_BASE);
|
||||
} else if (item.getItem() == BuildCraftSilicon.robotBuilderItem) {
|
||||
RenderManager.instance.renderEngine.bindTexture(TEXTURE_BUILDER);
|
||||
} else if (item.getItem() == BuildCraftSilicon.robotPickerItem) {
|
||||
RenderManager.instance.renderEngine.bindTexture(TEXTURE_PICKER);
|
||||
if (item.getItem() == BuildCraftSilicon.robotItem) {
|
||||
ItemRobot robot = (ItemRobot) item.getItem();
|
||||
RenderManager.instance.renderEngine.bindTexture(robot.getTextureRobot(item));
|
||||
}
|
||||
|
||||
float factor = (float) (1.0 / 16.0);
|
||||
|
|
|
@ -11,6 +11,8 @@ package buildcraft.core.robots;
|
|||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
@ -20,13 +22,24 @@ import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData;
|
|||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import buildcraft.api.boards.IRedstoneBoardNBT;
|
||||
import buildcraft.api.boards.IRedstoneBoardRobot;
|
||||
import buildcraft.api.boards.IRedstoneBoardRobotNBT;
|
||||
import buildcraft.api.boards.RedstoneBoardRegistry;
|
||||
import buildcraft.api.core.SafeTimeTracker;
|
||||
import buildcraft.core.DefaultProps;
|
||||
import buildcraft.core.LaserData;
|
||||
import buildcraft.transport.TileGenericPipe;
|
||||
|
||||
public class EntityRobot extends EntityLiving implements
|
||||
IEntityAdditionalSpawnData {
|
||||
IEntityAdditionalSpawnData, IInventory {
|
||||
|
||||
public static final ResourceLocation ROBOT_BASE = new ResourceLocation("buildcraft",
|
||||
DefaultProps.TEXTURE_PATH_ENTITIES + "/robot_base.png");
|
||||
public static final ResourceLocation ROBOT_BUILDER = new ResourceLocation("buildcraft",
|
||||
DefaultProps.TEXTURE_PATH_ENTITIES + "/robot_builder.png");
|
||||
public static final ResourceLocation ROBOT_TRANSPORT = new ResourceLocation("buildcraft",
|
||||
DefaultProps.TEXTURE_PATH_ENTITIES + "/robot_picker.png");
|
||||
|
||||
private static ResourceLocation defaultTexture = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_ENTITIES + "/robot_base.png");
|
||||
|
||||
|
@ -37,16 +50,28 @@ public class EntityRobot extends EntityLiving implements
|
|||
public DockingStation dockingStation = new DockingStation();
|
||||
public boolean isDocked = false;
|
||||
|
||||
public IRedstoneBoardRobot board;
|
||||
|
||||
public RobotAIBase currentAI;
|
||||
protected RobotAIBase nextAI;
|
||||
|
||||
private boolean needsUpdate = false;
|
||||
private ItemStack[] inv = new ItemStack[6];
|
||||
private String boardID;
|
||||
private ResourceLocation texture;
|
||||
|
||||
public class DockingStation {
|
||||
public int x, y, z;
|
||||
public ForgeDirection side;
|
||||
}
|
||||
|
||||
public EntityRobot(World world, IRedstoneBoardRobot iBoard) {
|
||||
this(world);
|
||||
|
||||
board = iBoard;
|
||||
dataWatcher.updateObject(16, board.getID());
|
||||
}
|
||||
|
||||
public EntityRobot(World par1World) {
|
||||
super(par1World);
|
||||
|
||||
|
@ -73,10 +98,7 @@ public class EntityRobot extends EntityLiving implements
|
|||
dataWatcher.addObject(13, Float.valueOf(0));
|
||||
dataWatcher.addObject(14, Float.valueOf(0));
|
||||
dataWatcher.addObject(15, Byte.valueOf((byte) 0));
|
||||
dataWatcher.addObject(16, Float.valueOf(0));
|
||||
dataWatcher.addObject(17, Float.valueOf(0));
|
||||
dataWatcher.addObject(18, Float.valueOf(0));
|
||||
dataWatcher.addObject(19, Byte.valueOf((byte) 0));
|
||||
dataWatcher.addObject(16, "");
|
||||
}
|
||||
|
||||
protected void updateDataClient() {
|
||||
|
@ -84,6 +106,13 @@ public class EntityRobot extends EntityLiving implements
|
|||
laser.tail.y = dataWatcher.getWatchableObjectFloat(13);
|
||||
laser.tail.z = dataWatcher.getWatchableObjectFloat(14);
|
||||
laser.isVisible = dataWatcher.getWatchableObjectByte(15) == 1;
|
||||
|
||||
IRedstoneBoardNBT boardNBT = RedstoneBoardRegistry.instance.getRedstoneBoard(dataWatcher
|
||||
.getWatchableObjectString(16));
|
||||
|
||||
if (boardNBT != null) {
|
||||
texture = ((IRedstoneBoardRobotNBT) boardNBT).getRobotTexture();
|
||||
}
|
||||
}
|
||||
|
||||
protected void updateDataServer() {
|
||||
|
@ -143,6 +172,8 @@ public class EntityRobot extends EntityLiving implements
|
|||
}
|
||||
|
||||
if (!worldObj.isRemote) {
|
||||
board.updateBoard(this);
|
||||
|
||||
if (currentTask == null) {
|
||||
if (scanForTasks.markTimeIfDelay(worldObj)) {
|
||||
RobotTaskProviderRegistry.scanForTask(this);
|
||||
|
@ -259,7 +290,7 @@ public class EntityRobot extends EntityLiving implements
|
|||
}
|
||||
|
||||
public ResourceLocation getTexture () {
|
||||
return defaultTexture;
|
||||
return texture;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -278,6 +309,14 @@ public class EntityRobot extends EntityLiving implements
|
|||
NBTTagCompound nbtLaser = new NBTTagCompound();
|
||||
laser.writeToNBT(nbtLaser);
|
||||
nbt.setTag("laser", nbtLaser);
|
||||
|
||||
for (int i = 0; i < inv.length; ++i) {
|
||||
NBTTagCompound stackNbt = new NBTTagCompound();
|
||||
|
||||
if (inv[i] != null) {
|
||||
nbt.setTag("inv[" + i + "]", inv[i].writeToNBT(stackNbt));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -296,6 +335,12 @@ public class EntityRobot extends EntityLiving implements
|
|||
*/
|
||||
|
||||
laser.readFromNBT(nbt.getCompoundTag("laser"));
|
||||
|
||||
for (int i = 0; i < inv.length; ++i) {
|
||||
inv[i] = ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("inv[" + i + "]"));
|
||||
}
|
||||
|
||||
setDead();
|
||||
}
|
||||
|
||||
public void setDockingStation (TileGenericPipe tile, ForgeDirection side) {
|
||||
|
@ -323,4 +368,75 @@ public class EntityRobot extends EntityLiving implements
|
|||
public void setMainAI (RobotAIBase ai) {
|
||||
nextAI = ai;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return inv.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int var1) {
|
||||
return inv[var1];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int var1, int var2) {
|
||||
ItemStack result = inv[var1].splitStack(var2);
|
||||
|
||||
if (inv[var1].stackSize == 0) {
|
||||
inv[var1] = null;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int var1) {
|
||||
return inv[var1].splitStack(var1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int var1, ItemStack var2) {
|
||||
inv[var1] = var2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer var1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int var1, ItemStack var2) {
|
||||
return inv[var1] == null
|
||||
|| (inv[var1].isItemEqual(var2) && inv[var1].isStackable() && inv[var1].stackSize
|
||||
+ var2.stackSize <= inv[var1].getItem()
|
||||
.getItemStackLimit());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,179 +0,0 @@
|
|||
/**
|
||||
* 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;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
|
||||
import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData;
|
||||
|
||||
import buildcraft.builders.blueprints.IBlueprintBuilderAgent;
|
||||
import buildcraft.builders.urbanism.TaskBuildSchematic;
|
||||
import buildcraft.core.DefaultProps;
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
|
||||
public class EntityRobotBuilder extends EntityRobot implements
|
||||
IEntityAdditionalSpawnData, IBlueprintBuilderAgent, IInventory {
|
||||
|
||||
private static ResourceLocation texture = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_ENTITIES + "/robot_builder.png");
|
||||
|
||||
ItemStack buildingStack = null;
|
||||
float curBlockDamage = 0;
|
||||
float buildEnergy = 0;
|
||||
|
||||
public EntityRobotBuilder(World par1World) {
|
||||
super (par1World);
|
||||
}
|
||||
|
||||
/**
|
||||
* Operate a block break. Return true is the block has indeed been broken.
|
||||
*/
|
||||
@Override
|
||||
public boolean breakBlock (int x, int y, int z) {
|
||||
Block block = worldObj.getBlock(x, y, z);
|
||||
|
||||
if (block != null) {
|
||||
curBlockDamage += 1 / (block.getBlockHardness(worldObj, x, y, z) * 20);
|
||||
}
|
||||
|
||||
if (block != null && curBlockDamage < 1) {
|
||||
worldObj.destroyBlockInWorldPartially(getEntityId(), x, y, z,
|
||||
(int) (this.curBlockDamage * 10.0F) - 1);
|
||||
|
||||
setLaserDestination(x + 0.5F, y + 0.5F, z + 0.5F);
|
||||
showLaser();
|
||||
|
||||
return false;
|
||||
} else {
|
||||
worldObj.destroyBlockInWorldPartially(getEntityId(), x, y, z, -1);
|
||||
worldObj.setBlock(x, y, z, Blocks.air);
|
||||
curBlockDamage = 0;
|
||||
|
||||
hideLaser();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean buildBlock(int x, int y, int z) {
|
||||
if (buildingStack == null) {
|
||||
if (worldObj.getBlock(x, y, z) != Blocks.air) {
|
||||
breakBlock(x, y, z);
|
||||
} else {
|
||||
setLaserDestination(x + 0.5F, y + 0.5F, z + 0.5F);
|
||||
showLaser();
|
||||
|
||||
buildingStack = getInventory().decrStackSize(0, 1);
|
||||
buildEnergy = 0;
|
||||
}
|
||||
|
||||
return false;
|
||||
} else {
|
||||
buildEnergy++;
|
||||
|
||||
if (buildEnergy >= 25) {
|
||||
buildingStack.getItem().onItemUse(buildingStack,
|
||||
CoreProxy.proxy.getBuildCraftPlayer((WorldServer) worldObj).get(),
|
||||
worldObj, x, y - 1, z, 1, 0.0f, 0.0f, 0.0f);
|
||||
|
||||
buildingStack = null;
|
||||
|
||||
hideLaser();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventory() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int i) {
|
||||
// Fake inventory filled with bricks
|
||||
return new ItemStack(Blocks.brick_block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int i, int j) {
|
||||
// Fake inventory filled with bricks
|
||||
return new ItemStack(Blocks.brick_block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int i) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int i, ItemStack itemstack) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer entityplayer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemstack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptTask (IRobotTask task) {
|
||||
return task instanceof TaskBuildSchematic;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getTexture () {
|
||||
return texture;
|
||||
}
|
||||
}
|
|
@ -1,142 +0,0 @@
|
|||
/**
|
||||
* 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;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import buildcraft.api.boards.IRedstoneBoard;
|
||||
import buildcraft.core.DefaultProps;
|
||||
import buildcraft.core.robots.boards.BoardRobotPicker;
|
||||
|
||||
public class EntityRobotPicker extends EntityRobot implements IInventory {
|
||||
|
||||
private static ResourceLocation texture = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_ENTITIES + "/robot_picker.png");
|
||||
|
||||
ItemStack[] inv = new ItemStack[6];
|
||||
|
||||
private IRedstoneBoard<EntityRobotPicker> board;
|
||||
|
||||
public EntityRobotPicker(World par1World) {
|
||||
super(par1World);
|
||||
|
||||
board = new BoardRobotPicker();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getTexture () {
|
||||
return texture;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate () {
|
||||
super.onUpdate();
|
||||
|
||||
board.updateBoard(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return inv.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int var1) {
|
||||
return inv [var1];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int var1, int var2) {
|
||||
ItemStack result = inv [var1].splitStack(var2);
|
||||
|
||||
if (inv [var1].stackSize == 0) {
|
||||
inv [var1] = null;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int var1) {
|
||||
return inv [var1].splitStack(var1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int var1, ItemStack var2) {
|
||||
inv [var1] = var2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer var1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int var1, ItemStack var2) {
|
||||
return inv[var1] == null
|
||||
|| (inv[var1].isItemEqual(var2) && inv[var1].isStackable() && inv[var1].stackSize
|
||||
+ var2.stackSize <= inv[var1].getItem()
|
||||
.getItemStackLimit());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeEntityToNBT(NBTTagCompound nbt) {
|
||||
super.writeEntityToNBT(nbt);
|
||||
|
||||
for (int i = 0; i < inv.length; ++i) {
|
||||
NBTTagCompound stackNbt = new NBTTagCompound();
|
||||
|
||||
if (inv [i] != null) {
|
||||
nbt.setTag("inv[" + i + "]", inv [i].writeToNBT(stackNbt));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readEntityFromNBT(NBTTagCompound nbt) {
|
||||
super.readEntityFromNBT(nbt);
|
||||
|
||||
for (int i = 0; i < inv.length; ++i) {
|
||||
inv [i] = ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("inv[" + i + "]"));
|
||||
}
|
||||
|
||||
setDead();
|
||||
}
|
||||
}
|
61
common/buildcraft/core/robots/RobotIntegrationRecipe.java
Executable file
61
common/buildcraft/core/robots/RobotIntegrationRecipe.java
Executable file
|
@ -0,0 +1,61 @@
|
|||
/**
|
||||
* 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;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import buildcraft.BuildCraftSilicon;
|
||||
import buildcraft.api.recipes.IIntegrationRecipeManager.IIntegrationRecipe;
|
||||
import buildcraft.core.ItemRobot;
|
||||
import buildcraft.core.utils.NBTUtils;
|
||||
import buildcraft.silicon.ItemRedstoneBoard;
|
||||
|
||||
public class RobotIntegrationRecipe implements IIntegrationRecipe {
|
||||
|
||||
@Override
|
||||
public double getEnergyCost() {
|
||||
// return 10000;
|
||||
return 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidInputA(ItemStack inputA) {
|
||||
return inputA != null && inputA.getItem() instanceof ItemRobot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidInputB(ItemStack inputB) {
|
||||
return inputB != null && inputB.getItem() instanceof ItemRedstoneBoard;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getOutputForInputs(ItemStack inputA, ItemStack inputB, ItemStack[] components) {
|
||||
ItemStack robot = new ItemStack(BuildCraftSilicon.robotItem);
|
||||
|
||||
NBTUtils.getItemData(robot).setTag("board", NBTUtils.getItemData(inputB));
|
||||
|
||||
return robot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getComponents() {
|
||||
return new ItemStack[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getExampleInputsA() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getExampleInputsB() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -5,20 +5,21 @@ import java.util.Set;
|
|||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import buildcraft.api.boards.IRedstoneBoard;
|
||||
import buildcraft.api.boards.IRedstoneBoardRobot;
|
||||
import buildcraft.api.core.SafeTimeTracker;
|
||||
import buildcraft.core.inventory.TransactorSimple;
|
||||
import buildcraft.core.robots.EntityRobotPicker;
|
||||
import buildcraft.core.robots.EntityRobot;
|
||||
import buildcraft.core.robots.RobotAIMoveTo;
|
||||
import buildcraft.core.robots.RobotAIReturnToDock;
|
||||
import buildcraft.transport.PipeTransportItems;
|
||||
import buildcraft.transport.TileGenericPipe;
|
||||
import buildcraft.transport.TravelingItem;
|
||||
|
||||
public class BoardRobotPicker implements IRedstoneBoard<EntityRobotPicker> {
|
||||
public class BoardRobotPicker implements IRedstoneBoardRobot<EntityRobot> {
|
||||
|
||||
private static Set<Integer> targettedItems = new HashSet<Integer>();
|
||||
|
||||
|
@ -29,7 +30,7 @@ public class BoardRobotPicker implements IRedstoneBoard<EntityRobotPicker> {
|
|||
private int pickTime = -1;
|
||||
|
||||
@Override
|
||||
public void updateBoard(EntityRobotPicker robot) {
|
||||
public void updateBoard(EntityRobot robot) {
|
||||
TransactorSimple inventoryInsert = new TransactorSimple(robot);
|
||||
|
||||
if (robot.worldObj.isRemote) {
|
||||
|
@ -96,7 +97,7 @@ public class BoardRobotPicker implements IRedstoneBoard<EntityRobotPicker> {
|
|||
}
|
||||
}
|
||||
|
||||
public void scan(EntityRobotPicker robot) {
|
||||
public void scan(EntityRobot robot) {
|
||||
TransactorSimple inventoryInsert = new TransactorSimple(robot);
|
||||
|
||||
for (Object o : robot.worldObj.loadedEntityList) {
|
||||
|
@ -129,4 +130,14 @@ public class BoardRobotPicker implements IRedstoneBoard<EntityRobotPicker> {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getRobotTexture() {
|
||||
return EntityRobot.ROBOT_TRANSPORT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getID() {
|
||||
return "buildcraft:boardRobotPicker";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,12 +15,14 @@ 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.IRedstoneBoard;
|
||||
import buildcraft.api.boards.IRedstoneBoardNBT;
|
||||
import buildcraft.api.boards.IRedstoneBoardRobot;
|
||||
import buildcraft.api.boards.IRedstoneBoardRobotNBT;
|
||||
import buildcraft.core.robots.EntityRobot;
|
||||
import buildcraft.core.utils.StringUtils;
|
||||
|
||||
public class BoardRobotPickerNBT implements IRedstoneBoardNBT {
|
||||
public class BoardRobotPickerNBT implements IRedstoneBoardRobotNBT {
|
||||
|
||||
public IIcon icon;
|
||||
|
||||
|
@ -35,7 +37,7 @@ public class BoardRobotPickerNBT implements IRedstoneBoardNBT {
|
|||
}
|
||||
|
||||
@Override
|
||||
public IRedstoneBoard create(NBTTagCompound nbt) {
|
||||
public IRedstoneBoardRobot create(NBTTagCompound nbt) {
|
||||
return new BoardRobotPicker();
|
||||
}
|
||||
|
||||
|
@ -49,4 +51,9 @@ public class BoardRobotPickerNBT implements IRedstoneBoardNBT {
|
|||
icon = iconRegister.registerIcon("buildcraft:board_green");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getRobotTexture() {
|
||||
return EntityRobot.ROBOT_TRANSPORT;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -58,7 +58,18 @@ public class ImplRedstoneBoardRegistry extends RedstoneBoardRegistry {
|
|||
|
||||
@Override
|
||||
public IRedstoneBoardNBT getRedstoneBoard(NBTTagCompound nbt) {
|
||||
return boards.get(nbt.getString("id")).boardNBT;
|
||||
return getRedstoneBoard(nbt.getString("id"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRedstoneBoardNBT getRedstoneBoard(String id) {
|
||||
BoardFactory factory = boards.get(id);
|
||||
|
||||
if (factory != null) {
|
||||
return factory.boardNBT;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -67,4 +78,5 @@ public class ImplRedstoneBoardRegistry extends RedstoneBoardRegistry {
|
|||
f.boardNBT.registerIcons(par1IconRegister);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -788,7 +788,7 @@ public class BlockGenericPipe extends BlockBuildCraft {
|
|||
|
||||
if (rayTraceResult.hitPart == Part.RobotStation) {
|
||||
EntityRobot robot = ((ItemRobot) currentItem.getItem())
|
||||
.createRobot(world);
|
||||
.createRobot(currentItem, world);
|
||||
|
||||
float px = x + 0.5F + rayTraceResult.sideHit.offsetX * 0.5F;
|
||||
float py = y + 0.5F + rayTraceResult.sideHit.offsetY * 0.5F;
|
||||
|
|
|
@ -113,16 +113,6 @@ public class PipeIconProvider implements IIconProvider {
|
|||
PipePowerIronM64("pipePowerIronM64"),
|
||||
PipePowerIronM128("pipePowerIronM128"),
|
||||
//
|
||||
PipePowerHeat0("pipePowerHeat0"),
|
||||
PipePowerHeat1("pipePowerHeat1"),
|
||||
PipePowerHeat2("pipePowerHeat2"),
|
||||
PipePowerHeat3("pipePowerHeat3"),
|
||||
PipePowerHeat4("pipePowerHeat4"),
|
||||
PipePowerHeat5("pipePowerHeat5"),
|
||||
PipePowerHeat6("pipePowerHeat6"),
|
||||
PipePowerHeat7("pipePowerHeat7"),
|
||||
PipePowerHeat8("pipePowerHeat8"),
|
||||
//
|
||||
PipeRobotStation("pipeRobotStation"),
|
||||
//
|
||||
Power_Normal("texture_cyan"),
|
||||
|
|
Loading…
Add table
Reference in a new issue