started work on builder robot, for #1908
This commit is contained in:
parent
1153dd3c9f
commit
4c731c533c
12 changed files with 340 additions and 14 deletions
BIN
buildcraft_resources/assets/buildcraft/textures/blocks/constructMarker.png
Executable file
BIN
buildcraft_resources/assets/buildcraft/textures/blocks/constructMarker.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 208 B |
|
@ -54,6 +54,7 @@ import buildcraft.builders.BlockArchitect;
|
||||||
import buildcraft.builders.BlockBlueprintLibrary;
|
import buildcraft.builders.BlockBlueprintLibrary;
|
||||||
import buildcraft.builders.BlockBuildTool;
|
import buildcraft.builders.BlockBuildTool;
|
||||||
import buildcraft.builders.BlockBuilder;
|
import buildcraft.builders.BlockBuilder;
|
||||||
|
import buildcraft.builders.BlockConstructionMarker;
|
||||||
import buildcraft.builders.BlockFiller;
|
import buildcraft.builders.BlockFiller;
|
||||||
import buildcraft.builders.BlockMarker;
|
import buildcraft.builders.BlockMarker;
|
||||||
import buildcraft.builders.BlockPathMarker;
|
import buildcraft.builders.BlockPathMarker;
|
||||||
|
@ -65,6 +66,7 @@ import buildcraft.builders.ItemBlueprintTemplate;
|
||||||
import buildcraft.builders.TileArchitect;
|
import buildcraft.builders.TileArchitect;
|
||||||
import buildcraft.builders.TileBlueprintLibrary;
|
import buildcraft.builders.TileBlueprintLibrary;
|
||||||
import buildcraft.builders.TileBuilder;
|
import buildcraft.builders.TileBuilder;
|
||||||
|
import buildcraft.builders.TileConstructionMarker;
|
||||||
import buildcraft.builders.TileFiller;
|
import buildcraft.builders.TileFiller;
|
||||||
import buildcraft.builders.TileMarker;
|
import buildcraft.builders.TileMarker;
|
||||||
import buildcraft.builders.TilePathMarker;
|
import buildcraft.builders.TilePathMarker;
|
||||||
|
@ -135,6 +137,7 @@ public class BuildCraftBuilders extends BuildCraftMod {
|
||||||
public static BlockBuildTool buildToolBlock;
|
public static BlockBuildTool buildToolBlock;
|
||||||
public static BlockMarker markerBlock;
|
public static BlockMarker markerBlock;
|
||||||
public static BlockPathMarker pathMarkerBlock;
|
public static BlockPathMarker pathMarkerBlock;
|
||||||
|
public static BlockConstructionMarker constructionMarkerBlock;
|
||||||
public static BlockFiller fillerBlock;
|
public static BlockFiller fillerBlock;
|
||||||
public static BlockBuilder builderBlock;
|
public static BlockBuilder builderBlock;
|
||||||
public static BlockArchitect architectBlock;
|
public static BlockArchitect architectBlock;
|
||||||
|
@ -385,6 +388,7 @@ public class BuildCraftBuilders extends BuildCraftMod {
|
||||||
|
|
||||||
SchematicRegistry.registerSchematicBlock(markerBlock, SchematicWallSide.class);
|
SchematicRegistry.registerSchematicBlock(markerBlock, SchematicWallSide.class);
|
||||||
SchematicRegistry.registerSchematicBlock(pathMarkerBlock, SchematicWallSide.class);
|
SchematicRegistry.registerSchematicBlock(pathMarkerBlock, SchematicWallSide.class);
|
||||||
|
SchematicRegistry.registerSchematicBlock(constructionMarkerBlock, SchematicWallSide.class);
|
||||||
|
|
||||||
// Factories required to save entities in world
|
// Factories required to save entities in world
|
||||||
|
|
||||||
|
@ -420,6 +424,9 @@ public class BuildCraftBuilders extends BuildCraftMod {
|
||||||
pathMarkerBlock = new BlockPathMarker();
|
pathMarkerBlock = new BlockPathMarker();
|
||||||
CoreProxy.proxy.registerBlock(pathMarkerBlock.setBlockName("pathMarkerBlock"));
|
CoreProxy.proxy.registerBlock(pathMarkerBlock.setBlockName("pathMarkerBlock"));
|
||||||
|
|
||||||
|
constructionMarkerBlock = new BlockConstructionMarker();
|
||||||
|
CoreProxy.proxy.registerBlock(constructionMarkerBlock.setBlockName("constructionMarkerBlock"));
|
||||||
|
|
||||||
fillerBlock = new BlockFiller();
|
fillerBlock = new BlockFiller();
|
||||||
CoreProxy.proxy.registerBlock(fillerBlock.setBlockName("fillerBlock"));
|
CoreProxy.proxy.registerBlock(fillerBlock.setBlockName("fillerBlock"));
|
||||||
|
|
||||||
|
@ -443,6 +450,7 @@ public class BuildCraftBuilders extends BuildCraftMod {
|
||||||
GameRegistry.registerTileEntity(TileBuilder.class, "net.minecraft.src.builders.TileBuilder");
|
GameRegistry.registerTileEntity(TileBuilder.class, "net.minecraft.src.builders.TileBuilder");
|
||||||
GameRegistry.registerTileEntity(TileArchitect.class, "net.minecraft.src.builders.TileTemplate");
|
GameRegistry.registerTileEntity(TileArchitect.class, "net.minecraft.src.builders.TileTemplate");
|
||||||
GameRegistry.registerTileEntity(TilePathMarker.class, "net.minecraft.src.builders.TilePathMarker");
|
GameRegistry.registerTileEntity(TilePathMarker.class, "net.minecraft.src.builders.TilePathMarker");
|
||||||
|
GameRegistry.registerTileEntity(TileConstructionMarker.class, "net.minecraft.src.builders.TileConstructionMarker");
|
||||||
GameRegistry.registerTileEntity(TileBlueprintLibrary.class, "net.minecraft.src.builders.TileBlueprintLibrary");
|
GameRegistry.registerTileEntity(TileBlueprintLibrary.class, "net.minecraft.src.builders.TileBlueprintLibrary");
|
||||||
|
|
||||||
SchematicRegistry.readConfiguration(BuildCraftCore.mainConfiguration);
|
SchematicRegistry.readConfiguration(BuildCraftCore.mainConfiguration);
|
||||||
|
|
73
common/buildcraft/builders/BlockConstructionMarker.java
Executable file
73
common/buildcraft/builders/BlockConstructionMarker.java
Executable file
|
@ -0,0 +1,73 @@
|
||||||
|
/**
|
||||||
|
* 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.builders;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
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.world.World;
|
||||||
|
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
|
import buildcraft.core.utils.Utils;
|
||||||
|
|
||||||
|
public class BlockConstructionMarker extends BlockMarker {
|
||||||
|
|
||||||
|
public BlockConstructionMarker() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TileEntity createNewTileEntity(World world, int metadata) {
|
||||||
|
return new TileConstructionMarker();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void breakBlock(World world, int x, int y, int z, Block block, int par6) {
|
||||||
|
Utils.preDestroyBlock(world, x, y, z);
|
||||||
|
super.breakBlock(world, x, y, z, block, par6);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public void registerBlockIcons(IIconRegister par1IconRegister) {
|
||||||
|
blockIcon = par1IconRegister.registerIcon("buildcraft:constructMarker");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase entityliving, ItemStack stack) {
|
||||||
|
super.onBlockPlacedBy(world, i, j, k, entityliving, stack);
|
||||||
|
|
||||||
|
TileConstructionMarker tile = (TileConstructionMarker) world.getTileEntity(i, j, k);
|
||||||
|
tile.direction = Utils.get2dOrientation(entityliving);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int par6, float par7,
|
||||||
|
float par8, float par9) {
|
||||||
|
super.onBlockActivated(world, x, y, z, entityplayer, par6, par7, par8, par9);
|
||||||
|
|
||||||
|
TileConstructionMarker marker = (TileConstructionMarker) world.getTileEntity(x, y, z);
|
||||||
|
|
||||||
|
if (marker.itemBlueprint == null
|
||||||
|
&& entityplayer.inventory.getCurrentItem() != null
|
||||||
|
&& entityplayer.inventory.getCurrentItem().getItem() instanceof ItemBlueprint) {
|
||||||
|
|
||||||
|
marker.setBlueprint(entityplayer.inventory.getCurrentItem().copy());
|
||||||
|
entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, null);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -38,7 +38,6 @@ public class BlockPathMarker extends BlockMarker {
|
||||||
super.breakBlock(world, x, y, z, block, par6);
|
super.breakBlock(world, x, y, z, block, par6);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
@SuppressWarnings({ "all" })
|
@SuppressWarnings({ "all" })
|
||||||
// @Override (client only)
|
// @Override (client only)
|
||||||
public IIcon getIcon(IBlockAccess iblockaccess, int i, int j, int k, int l) {
|
public IIcon getIcon(IBlockAccess iblockaccess, int i, int j, int k, int l) {
|
||||||
|
@ -55,6 +54,5 @@ public class BlockPathMarker extends BlockMarker {
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public void registerBlockIcons(IIconRegister par1IconRegister) {
|
public void registerBlockIcons(IIconRegister par1IconRegister) {
|
||||||
blockIcon = par1IconRegister.registerIcon("buildcraft:blockPathMarker");
|
blockIcon = par1IconRegister.registerIcon("buildcraft:blockPathMarker");
|
||||||
activeMarker = par1IconRegister.registerIcon("buildcraft:blockPathMarkerActive");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,5 +31,6 @@ public class BuilderProxyClient extends BuilderProxy {
|
||||||
ClientRegistry.bindTileEntitySpecialRenderer(TileFiller.class, new RenderBuilder());
|
ClientRegistry.bindTileEntitySpecialRenderer(TileFiller.class, new RenderBuilder());
|
||||||
ClientRegistry.bindTileEntitySpecialRenderer(TileBuilder.class, new RenderBuilder());
|
ClientRegistry.bindTileEntitySpecialRenderer(TileBuilder.class, new RenderBuilder());
|
||||||
ClientRegistry.bindTileEntitySpecialRenderer(TilePathMarker.class, new RenderPathMarker());
|
ClientRegistry.bindTileEntitySpecialRenderer(TilePathMarker.class, new RenderPathMarker());
|
||||||
|
ClientRegistry.bindTileEntitySpecialRenderer(TileConstructionMarker.class, new RenderConstructionMarker());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
16
common/buildcraft/builders/IBuildingItemsProvider.java
Executable file
16
common/buildcraft/builders/IBuildingItemsProvider.java
Executable file
|
@ -0,0 +1,16 @@
|
||||||
|
/**
|
||||||
|
* 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.builders;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public interface IBuildingItemsProvider {
|
||||||
|
|
||||||
|
ArrayList<BuildingItem> getBuildersInAction();
|
||||||
|
}
|
108
common/buildcraft/builders/RenderConstructionMarker.java
Executable file
108
common/buildcraft/builders/RenderConstructionMarker.java
Executable file
|
@ -0,0 +1,108 @@
|
||||||
|
/**
|
||||||
|
* 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.builders;
|
||||||
|
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
import net.minecraft.client.model.ModelBase;
|
||||||
|
import net.minecraft.client.model.ModelRenderer;
|
||||||
|
import net.minecraft.client.renderer.entity.RenderItem;
|
||||||
|
import net.minecraft.client.renderer.entity.RenderManager;
|
||||||
|
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||||
|
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||||
|
import net.minecraft.entity.item.EntityItem;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
|
||||||
|
import buildcraft.core.EntityLaser;
|
||||||
|
import buildcraft.core.render.RenderLaser;
|
||||||
|
|
||||||
|
public class RenderConstructionMarker extends TileEntitySpecialRenderer {
|
||||||
|
|
||||||
|
private final EntityItem dummyEntityItem = new EntityItem(null);
|
||||||
|
private final RenderItem customRenderItem;
|
||||||
|
|
||||||
|
private ModelBase model = new ModelBase() {
|
||||||
|
};
|
||||||
|
private ModelRenderer box;
|
||||||
|
|
||||||
|
public RenderConstructionMarker() {
|
||||||
|
box = new ModelRenderer(model, 0, 1);
|
||||||
|
box.addBox(-8F, -8F, -8F, 16, 4, 16);
|
||||||
|
box.rotationPointX = 8;
|
||||||
|
box.rotationPointY = 8;
|
||||||
|
box.rotationPointZ = 8;
|
||||||
|
|
||||||
|
customRenderItem = new RenderItem() {
|
||||||
|
@Override
|
||||||
|
public boolean shouldBob() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldSpreadItems() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
customRenderItem.setRenderManager(RenderManager.instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) {
|
||||||
|
TileConstructionMarker marker = (TileConstructionMarker) tileentity;
|
||||||
|
|
||||||
|
if (marker != null) {
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
|
||||||
|
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||||
|
GL11.glEnable(GL11.GL_LIGHTING);
|
||||||
|
GL11.glEnable(GL11.GL_BLEND);
|
||||||
|
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
|
GL11.glTranslated(x, y, z);
|
||||||
|
GL11.glTranslated(-tileentity.xCoord, -tileentity.yCoord, -tileentity.zCoord);
|
||||||
|
|
||||||
|
if (marker.laser != null) {
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
RenderLaser
|
||||||
|
.doRenderLaser(
|
||||||
|
TileEntityRendererDispatcher.instance.field_147553_e,
|
||||||
|
marker.laser, EntityLaser.LASER_TEXTURES[4]);
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (marker.itemBlueprint != null) {
|
||||||
|
doRenderItem(marker.itemBlueprint,
|
||||||
|
marker.xCoord + 0.5F,
|
||||||
|
marker.yCoord + 0.2F,
|
||||||
|
marker.zCoord + 0.5F);
|
||||||
|
}
|
||||||
|
|
||||||
|
//GL11.glEnable(GL11.GL_LIGHTING);
|
||||||
|
GL11.glPopAttrib();
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void doRenderItem(ItemStack stack, double x, double y, double z) {
|
||||||
|
if (stack == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
float renderScale = 1.5f;
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
GL11.glTranslatef((float) x, (float) y, (float) z);
|
||||||
|
GL11.glTranslatef(0, 0.25F, 0);
|
||||||
|
GL11.glScalef(renderScale, renderScale, renderScale);
|
||||||
|
dummyEntityItem.setEntityItemStack(stack);
|
||||||
|
customRenderItem.doRender(dummyEntityItem, 0, 0, 0, 0, 0);
|
||||||
|
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
}
|
||||||
|
}
|
|
@ -15,18 +15,13 @@ import net.minecraft.client.model.ModelRenderer;
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
|
|
||||||
import buildcraft.core.DefaultProps;
|
|
||||||
import buildcraft.core.EntityLaser;
|
import buildcraft.core.EntityLaser;
|
||||||
import buildcraft.core.LaserData;
|
import buildcraft.core.LaserData;
|
||||||
import buildcraft.core.render.RenderLaser;
|
import buildcraft.core.render.RenderLaser;
|
||||||
|
|
||||||
public class RenderPathMarker extends TileEntitySpecialRenderer {
|
public class RenderPathMarker extends TileEntitySpecialRenderer {
|
||||||
|
|
||||||
private static final ResourceLocation CHAMBER_TEXTURE = new ResourceLocation(DefaultProps.TEXTURE_PATH_BLOCKS
|
|
||||||
+ "/chamber2.png");
|
|
||||||
|
|
||||||
private ModelBase model = new ModelBase() {
|
private ModelBase model = new ModelBase() {
|
||||||
};
|
};
|
||||||
private ModelRenderer box;
|
private ModelRenderer box;
|
||||||
|
|
|
@ -27,7 +27,8 @@ import buildcraft.core.network.RPCHandler;
|
||||||
import buildcraft.core.network.RPCMessageInfo;
|
import buildcraft.core.network.RPCMessageInfo;
|
||||||
import buildcraft.core.network.RPCSide;
|
import buildcraft.core.network.RPCSide;
|
||||||
|
|
||||||
public abstract class TileAbstractBuilder extends TileBuildCraft implements ITileBuilder, IInventory, IBoxProvider {
|
public abstract class TileAbstractBuilder extends TileBuildCraft implements ITileBuilder, IInventory, IBoxProvider,
|
||||||
|
IBuildingItemsProvider {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Computes the maximum amount of energy required to build a full chest,
|
* Computes the maximum amount of energy required to build a full chest,
|
||||||
|
@ -151,4 +152,9 @@ public abstract class TileAbstractBuilder extends TileBuildCraft implements ITil
|
||||||
mjPrev = mjStored;
|
mjPrev = mjStored;
|
||||||
mjUnchangedCycles = 0;
|
mjUnchangedCycles = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ArrayList<BuildingItem> getBuildersInAction() {
|
||||||
|
return buildersInAction;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
119
common/buildcraft/builders/TileConstructionMarker.java
Executable file
119
common/buildcraft/builders/TileConstructionMarker.java
Executable file
|
@ -0,0 +1,119 @@
|
||||||
|
/**
|
||||||
|
* 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.builders;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
|
||||||
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
|
import buildcraft.api.core.NetworkData;
|
||||||
|
import buildcraft.api.core.Position;
|
||||||
|
import buildcraft.core.LaserData;
|
||||||
|
import buildcraft.core.TileBuildCraft;
|
||||||
|
import buildcraft.core.blueprints.Blueprint;
|
||||||
|
import buildcraft.core.blueprints.BptBuilderBase;
|
||||||
|
import buildcraft.core.blueprints.BptBuilderBlueprint;
|
||||||
|
|
||||||
|
public class TileConstructionMarker extends TileBuildCraft implements IBuildingItemsProvider {
|
||||||
|
|
||||||
|
public ForgeDirection direction = ForgeDirection.UNKNOWN;
|
||||||
|
|
||||||
|
@NetworkData
|
||||||
|
public LaserData laser;
|
||||||
|
|
||||||
|
@NetworkData
|
||||||
|
public ItemStack itemBlueprint;
|
||||||
|
|
||||||
|
private BptBuilderBase bluePrintBuilder;
|
||||||
|
private ArrayList<BuildingItem> buildersInAction = new ArrayList<BuildingItem>();
|
||||||
|
private NBTTagCompound initNBT;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateEntity() {
|
||||||
|
super.updateEntity();
|
||||||
|
|
||||||
|
if (worldObj.isRemote) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (itemBlueprint != null && bluePrintBuilder == null) {
|
||||||
|
bluePrintBuilder = new BptBuilderBlueprint((Blueprint) ItemBlueprint.loadBlueprint(itemBlueprint),
|
||||||
|
worldObj, xCoord,
|
||||||
|
yCoord, zCoord);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (laser == null && direction != ForgeDirection.UNKNOWN) {
|
||||||
|
laser = new LaserData();
|
||||||
|
laser.head = new Position(xCoord + 0.5F, yCoord + 0.5F, zCoord + 0.5F);
|
||||||
|
laser.tail = new Position(xCoord + 0.5F + direction.offsetX * 0.5F,
|
||||||
|
yCoord + 0.5F + direction.offsetY * 0.5F,
|
||||||
|
zCoord + 0.5F + direction.offsetZ * 0.5F);
|
||||||
|
laser.isVisible = true;
|
||||||
|
sendNetworkUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (initNBT != null) {
|
||||||
|
if (bluePrintBuilder != null) {
|
||||||
|
bluePrintBuilder.loadBuildStateToNBT(initNBT.getCompoundTag("builderState"), this);
|
||||||
|
}
|
||||||
|
|
||||||
|
initNBT = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeToNBT(NBTTagCompound nbt) {
|
||||||
|
super.writeToNBT(nbt);
|
||||||
|
|
||||||
|
nbt.setInteger("direction", direction.ordinal());
|
||||||
|
|
||||||
|
if (itemBlueprint != null) {
|
||||||
|
NBTTagCompound bptNBT = new NBTTagCompound();
|
||||||
|
itemBlueprint.writeToNBT(bptNBT);
|
||||||
|
nbt.setTag("itemBlueprint", bptNBT);
|
||||||
|
}
|
||||||
|
|
||||||
|
NBTTagCompound bptNBT = new NBTTagCompound();
|
||||||
|
|
||||||
|
if (bluePrintBuilder != null) {
|
||||||
|
NBTTagCompound builderCpt = new NBTTagCompound();
|
||||||
|
bluePrintBuilder.saveBuildStateToNBT(builderCpt, this);
|
||||||
|
bptNBT.setTag("builderState", builderCpt);
|
||||||
|
}
|
||||||
|
|
||||||
|
nbt.setTag("bptBuilder", bptNBT);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void readFromNBT(NBTTagCompound nbt) {
|
||||||
|
super.readFromNBT(nbt);
|
||||||
|
|
||||||
|
direction = ForgeDirection.values()[nbt.getInteger("direction")];
|
||||||
|
|
||||||
|
if (nbt.hasKey("itemBlueprint")) {
|
||||||
|
itemBlueprint = ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("itemBlueprint"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// The rest of load has to be done upon initialize.
|
||||||
|
initNBT = (NBTTagCompound) nbt.getCompoundTag("bptBuilder").copy();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBlueprint(ItemStack currentItem) {
|
||||||
|
itemBlueprint = currentItem;
|
||||||
|
sendNetworkUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ArrayList<BuildingItem> getBuildersInAction() {
|
||||||
|
return buildersInAction;
|
||||||
|
}
|
||||||
|
}
|
|
@ -30,6 +30,7 @@ import buildcraft.api.core.BlockIndex;
|
||||||
import buildcraft.api.core.IAreaProvider;
|
import buildcraft.api.core.IAreaProvider;
|
||||||
import buildcraft.api.core.Position;
|
import buildcraft.api.core.Position;
|
||||||
import buildcraft.builders.BuildingItem;
|
import buildcraft.builders.BuildingItem;
|
||||||
|
import buildcraft.builders.IBuildingItemsProvider;
|
||||||
import buildcraft.builders.TileAbstractBuilder;
|
import buildcraft.builders.TileAbstractBuilder;
|
||||||
import buildcraft.core.Box;
|
import buildcraft.core.Box;
|
||||||
|
|
||||||
|
@ -168,7 +169,7 @@ public abstract class BptBuilderBase implements IAreaProvider {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveBuildStateToNBT (NBTTagCompound nbt, TileAbstractBuilder builder) {
|
public void saveBuildStateToNBT(NBTTagCompound nbt, IBuildingItemsProvider builder) {
|
||||||
NBTTagList clearList = new NBTTagList();
|
NBTTagList clearList = new NBTTagList();
|
||||||
|
|
||||||
for (BlockIndex loc : clearedLocations) {
|
for (BlockIndex loc : clearedLocations) {
|
||||||
|
@ -191,7 +192,7 @@ public abstract class BptBuilderBase implements IAreaProvider {
|
||||||
|
|
||||||
NBTTagList buildingList = new NBTTagList();
|
NBTTagList buildingList = new NBTTagList();
|
||||||
|
|
||||||
for (BuildingItem item : builder.buildersInAction) {
|
for (BuildingItem item : builder.getBuildersInAction()) {
|
||||||
NBTTagCompound sub = new NBTTagCompound();
|
NBTTagCompound sub = new NBTTagCompound();
|
||||||
item.writeToNBT(sub);
|
item.writeToNBT(sub);
|
||||||
buildingList.appendTag(sub);
|
buildingList.appendTag(sub);
|
||||||
|
@ -200,7 +201,7 @@ public abstract class BptBuilderBase implements IAreaProvider {
|
||||||
nbt.setTag("buildersInAction", buildingList);
|
nbt.setTag("buildersInAction", buildingList);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadBuildStateToNBT (NBTTagCompound nbt, TileAbstractBuilder builder) {
|
public void loadBuildStateToNBT(NBTTagCompound nbt, IBuildingItemsProvider builder) {
|
||||||
NBTTagList clearList = nbt.getTagList("clearList", Constants.NBT.TAG_COMPOUND);
|
NBTTagList clearList = nbt.getTagList("clearList", Constants.NBT.TAG_COMPOUND);
|
||||||
|
|
||||||
for (int i = 0; i < clearList.tagCount(); ++i) {
|
for (int i = 0; i < clearList.tagCount(); ++i) {
|
||||||
|
@ -227,7 +228,7 @@ public abstract class BptBuilderBase implements IAreaProvider {
|
||||||
try {
|
try {
|
||||||
item.readFromNBT(buildingList.getCompoundTagAt(i));
|
item.readFromNBT(buildingList.getCompoundTagAt(i));
|
||||||
item.context = getContext();
|
item.context = getContext();
|
||||||
builder.buildersInAction.add(item);
|
builder.getBuildersInAction().add(item);
|
||||||
} catch (MappingNotFoundException e) {
|
} catch (MappingNotFoundException e) {
|
||||||
BCLog.logger.log(Level.WARNING, "can't load building item", e);
|
BCLog.logger.log(Level.WARNING, "can't load building item", e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,7 @@ import buildcraft.api.core.BlockIndex;
|
||||||
import buildcraft.api.core.BuildCraftAPI;
|
import buildcraft.api.core.BuildCraftAPI;
|
||||||
import buildcraft.api.core.IInvSlot;
|
import buildcraft.api.core.IInvSlot;
|
||||||
import buildcraft.api.core.StackKey;
|
import buildcraft.api.core.StackKey;
|
||||||
|
import buildcraft.builders.IBuildingItemsProvider;
|
||||||
import buildcraft.builders.TileAbstractBuilder;
|
import buildcraft.builders.TileAbstractBuilder;
|
||||||
import buildcraft.builders.TileBuilder;
|
import buildcraft.builders.TileBuilder;
|
||||||
import buildcraft.core.blueprints.BuildingSlotBlock.Mode;
|
import buildcraft.core.blueprints.BuildingSlotBlock.Mode;
|
||||||
|
@ -663,7 +664,7 @@ public class BptBuilderBlueprint extends BptBuilderBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveBuildStateToNBT (NBTTagCompound nbt, TileAbstractBuilder builder) {
|
public void saveBuildStateToNBT(NBTTagCompound nbt, IBuildingItemsProvider builder) {
|
||||||
super.saveBuildStateToNBT(nbt, builder);
|
super.saveBuildStateToNBT(nbt, builder);
|
||||||
|
|
||||||
int [] entitiesBuiltArr = new int [builtEntities.size()];
|
int [] entitiesBuiltArr = new int [builtEntities.size()];
|
||||||
|
@ -679,7 +680,7 @@ public class BptBuilderBlueprint extends BptBuilderBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadBuildStateToNBT (NBTTagCompound nbt, TileAbstractBuilder builder) {
|
public void loadBuildStateToNBT(NBTTagCompound nbt, IBuildingItemsProvider builder) {
|
||||||
super.loadBuildStateToNBT(nbt, builder);
|
super.loadBuildStateToNBT(nbt, builder);
|
||||||
|
|
||||||
int [] entitiesBuiltArr = nbt.getIntArray("builtEntities");
|
int [] entitiesBuiltArr = nbt.getIntArray("builtEntities");
|
||||||
|
|
Loading…
Reference in a new issue