From 5bd9aec80aa4c0335743e840b0ecd2842ffddc5e Mon Sep 17 00:00:00 2001 From: SpaceToad Date: Thu, 1 May 2014 23:40:30 +0200 Subject: [PATCH] Implemented builder state save for filler and quarry. Fixed API, and moved out some non-essencial files. Close #1618 --- .../api/blueprints/SchematicBlockBase.java | 4 -- .../api/blueprints/SchematicMask.java | 14 ----- .../api/blueprints/SchematicRegistry.java | 8 +-- api/buildcraft/api/core/JavaTools.java | 8 +++ common/buildcraft/BuildCraftBuilders.java | 6 +- common/buildcraft/BuildCraftTransport.java | 22 +++---- common/buildcraft/builders/TileBuilder.java | 3 +- common/buildcraft/builders/TileFiller.java | 57 ++++++++++++++----- .../schematics}/SchematicFactoryBlock.java | 6 +- .../schematics}/SchematicFactoryEntity.java | 6 +- .../schematics}/SchematicFactoryMask.java | 5 +- .../core/BuildCraftConfiguration.java | 9 +-- .../core/blueprints/BuildingSlotBlock.java | 42 +++++++++++--- common/buildcraft/factory/TileQuarry.java | 28 ++++++++- common/buildcraft/transport/ItemFacade.java | 42 +++++++------- 15 files changed, 169 insertions(+), 91 deletions(-) rename {api/buildcraft/api/blueprints => common/buildcraft/builders/schematics}/SchematicFactoryBlock.java (84%) rename {api/buildcraft/api/blueprints => common/buildcraft/builders/schematics}/SchematicFactoryEntity.java (81%) rename {api/buildcraft/api/blueprints => common/buildcraft/builders/schematics}/SchematicFactoryMask.java (81%) diff --git a/api/buildcraft/api/blueprints/SchematicBlockBase.java b/api/buildcraft/api/blueprints/SchematicBlockBase.java index c571f7e3..0c680279 100755 --- a/api/buildcraft/api/blueprints/SchematicBlockBase.java +++ b/api/buildcraft/api/blueprints/SchematicBlockBase.java @@ -34,10 +34,6 @@ package buildcraft.api.blueprints; */ public abstract class SchematicBlockBase extends Schematic { - public void writeCompleted(IBuilderContext context, int x, int y, int z, double completed) { - - } - /** * Return true if the block should not be placed to the world. Requirements * will not be asked on such a block, and building will not be called. diff --git a/api/buildcraft/api/blueprints/SchematicMask.java b/api/buildcraft/api/blueprints/SchematicMask.java index ba8002c0..12e6e1bc 100755 --- a/api/buildcraft/api/blueprints/SchematicMask.java +++ b/api/buildcraft/api/blueprints/SchematicMask.java @@ -57,20 +57,6 @@ public class SchematicMask extends SchematicBlockBase { } } - // TODO: To be removed with the "real" list of items - @Override - public void addRequirements(IBuilderContext context, LinkedList requirements) { - requirements.add(new ItemStack(Blocks.brick_block)); - } - - @Override - public void writeCompleted(IBuilderContext context, int x, int y, int z, double completed) { - if (!isConcrete) { - context.world().destroyBlockInWorldPartially(0, x, y, z, - (int) (completed * 10.0F) - 1); - } - } - @Override public void writeToNBT(NBTTagCompound nbt, MappingRegistry registry) { nbt.setBoolean("isConcrete", isConcrete); diff --git a/api/buildcraft/api/blueprints/SchematicRegistry.java b/api/buildcraft/api/blueprints/SchematicRegistry.java index c7f0083c..0b903108 100644 --- a/api/buildcraft/api/blueprints/SchematicRegistry.java +++ b/api/buildcraft/api/blueprints/SchematicRegistry.java @@ -18,7 +18,7 @@ import net.minecraft.entity.Entity; import net.minecraft.init.Blocks; import net.minecraftforge.common.config.Configuration; import net.minecraftforge.common.config.Property; -import buildcraft.core.BuildCraftConfiguration; +import buildcraft.api.core.JavaTools; public class SchematicRegistry { @@ -138,14 +138,14 @@ public class SchematicRegistry { return !modsForbidden.contains(modid) && !blocksForbidden.contains(name); } - public static void readConfiguration (BuildCraftConfiguration conf) { + public static void readConfiguration (Configuration conf) { Property excludedMods = conf.get(Configuration.CATEGORY_GENERAL, "builder.excludedMods", new String [0], "mods that should be excluded from the builder."); Property excludedBlocks = conf.get(Configuration.CATEGORY_GENERAL, "builder.excludedBlocks", new String [0], "blocks that should be excluded from the builder."); for (String id : excludedMods.getStringList()) { - id = BuildCraftConfiguration.stripSurroundingQuotes (id.trim()); + id = JavaTools.stripSurroundingQuotes (id.trim()); if (id.length() > 0) { modsForbidden.add(id); @@ -153,7 +153,7 @@ public class SchematicRegistry { } for (String id : excludedBlocks.getStringList()) { - id = BuildCraftConfiguration.stripSurroundingQuotes (id.trim()); + id = JavaTools.stripSurroundingQuotes (id.trim()); if (id.length() > 0) { blocksForbidden.add(id); diff --git a/api/buildcraft/api/core/JavaTools.java b/api/buildcraft/api/core/JavaTools.java index cc619c1d..0502ea5b 100755 --- a/api/buildcraft/api/core/JavaTools.java +++ b/api/buildcraft/api/core/JavaTools.java @@ -78,4 +78,12 @@ public class JavaTools { return result; } + + public static String surroundWithQuotes(String stringToSurroundWithQuotes){ + return String.format("\"%s\"", stringToSurroundWithQuotes); + } + + public static String stripSurroundingQuotes(String stringToStripQuotes) { + return stringToStripQuotes.replaceAll("^\"|\"$", ""); + } } diff --git a/common/buildcraft/BuildCraftBuilders.java b/common/buildcraft/BuildCraftBuilders.java index f7ebfaf0..5a6c7c12 100644 --- a/common/buildcraft/BuildCraftBuilders.java +++ b/common/buildcraft/BuildCraftBuilders.java @@ -27,9 +27,6 @@ import net.minecraftforge.common.config.Property; import buildcraft.api.blueprints.SchematicBlock; import buildcraft.api.blueprints.SchematicEntity; import buildcraft.api.blueprints.SchematicFactory; -import buildcraft.api.blueprints.SchematicFactoryBlock; -import buildcraft.api.blueprints.SchematicFactoryEntity; -import buildcraft.api.blueprints.SchematicFactoryMask; import buildcraft.api.blueprints.SchematicMask; import buildcraft.api.blueprints.SchematicRegistry; import buildcraft.api.core.BCLog; @@ -73,6 +70,9 @@ import buildcraft.builders.schematics.SchematicCustomStack; import buildcraft.builders.schematics.SchematicDirt; import buildcraft.builders.schematics.SchematicDoor; import buildcraft.builders.schematics.SchematicEnderChest; +import buildcraft.builders.schematics.SchematicFactoryBlock; +import buildcraft.builders.schematics.SchematicFactoryEntity; +import buildcraft.builders.schematics.SchematicFactoryMask; import buildcraft.builders.schematics.SchematicFarmland; import buildcraft.builders.schematics.SchematicFire; import buildcraft.builders.schematics.SchematicFluid; diff --git a/common/buildcraft/BuildCraftTransport.java b/common/buildcraft/BuildCraftTransport.java index 48cb75e1..66122adf 100644 --- a/common/buildcraft/BuildCraftTransport.java +++ b/common/buildcraft/BuildCraftTransport.java @@ -23,13 +23,13 @@ import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.oredict.RecipeSorter; import buildcraft.api.blueprints.SchematicRegistry; import buildcraft.api.core.IIconProvider; +import buildcraft.api.core.JavaTools; import buildcraft.api.gates.ActionManager; import buildcraft.api.gates.GateExpansions; import buildcraft.api.recipes.BuildcraftRecipes; import buildcraft.api.transport.IExtractionHandler; import buildcraft.api.transport.PipeManager; import buildcraft.api.transport.PipeWire; -import buildcraft.core.BuildCraftConfiguration; import buildcraft.core.CreativeTabBuildCraft; import buildcraft.core.DefaultProps; import buildcraft.core.InterModComms; @@ -295,16 +295,16 @@ public class BuildCraftTransport extends BuildCraftMod { Block.blockRegistry.getNameForObject(Blocks.double_stone_slab), Block.blockRegistry.getNameForObject(Blocks.double_wooden_slab), Block.blockRegistry.getNameForObject(Blocks.sponge), - BuildCraftConfiguration.surroundWithQuotes(Block.blockRegistry.getNameForObject(BuildCraftBuilders.architectBlock)), - BuildCraftConfiguration.surroundWithQuotes(Block.blockRegistry.getNameForObject(BuildCraftBuilders.builderBlock)), - BuildCraftConfiguration.surroundWithQuotes(Block.blockRegistry.getNameForObject(BuildCraftBuilders.fillerBlock)), - BuildCraftConfiguration.surroundWithQuotes(Block.blockRegistry.getNameForObject(BuildCraftBuilders.libraryBlock)), - BuildCraftConfiguration.surroundWithQuotes(Block.blockRegistry.getNameForObject(BuildCraftFactory.autoWorkbenchBlock)), - BuildCraftConfiguration.surroundWithQuotes(Block.blockRegistry.getNameForObject(BuildCraftFactory.floodGateBlock)), - BuildCraftConfiguration.surroundWithQuotes(Block.blockRegistry.getNameForObject(BuildCraftFactory.miningWellBlock)), - BuildCraftConfiguration.surroundWithQuotes(Block.blockRegistry.getNameForObject(BuildCraftFactory.pumpBlock)), - BuildCraftConfiguration.surroundWithQuotes(Block.blockRegistry.getNameForObject(BuildCraftFactory.quarryBlock)), - BuildCraftConfiguration.surroundWithQuotes(Block.blockRegistry.getNameForObject(BuildCraftTransport.filteredBufferBlock)), + JavaTools.surroundWithQuotes(Block.blockRegistry.getNameForObject(BuildCraftBuilders.architectBlock)), + JavaTools.surroundWithQuotes(Block.blockRegistry.getNameForObject(BuildCraftBuilders.builderBlock)), + JavaTools.surroundWithQuotes(Block.blockRegistry.getNameForObject(BuildCraftBuilders.fillerBlock)), + JavaTools.surroundWithQuotes(Block.blockRegistry.getNameForObject(BuildCraftBuilders.libraryBlock)), + JavaTools.surroundWithQuotes(Block.blockRegistry.getNameForObject(BuildCraftFactory.autoWorkbenchBlock)), + JavaTools.surroundWithQuotes(Block.blockRegistry.getNameForObject(BuildCraftFactory.floodGateBlock)), + JavaTools.surroundWithQuotes(Block.blockRegistry.getNameForObject(BuildCraftFactory.miningWellBlock)), + JavaTools.surroundWithQuotes(Block.blockRegistry.getNameForObject(BuildCraftFactory.pumpBlock)), + JavaTools.surroundWithQuotes(Block.blockRegistry.getNameForObject(BuildCraftFactory.quarryBlock)), + JavaTools.surroundWithQuotes(Block.blockRegistry.getNameForObject(BuildCraftTransport.filteredBufferBlock)), }); facadeBlacklistProp.comment = "Blocks listed here will not have facades created. The format is modid:blockname.\nFor mods with a | character, the value needs to be surrounded with quotes."; diff --git a/common/buildcraft/builders/TileBuilder.java b/common/buildcraft/builders/TileBuilder.java index ba5ad96d..e5415614 100644 --- a/common/buildcraft/builders/TileBuilder.java +++ b/common/buildcraft/builders/TileBuilder.java @@ -58,7 +58,7 @@ public class TileBuilder extends TileAbstractBuilder implements IMachine { private LinkedList requiredToBuild; - NBTTagCompound initNBT = null; + private NBTTagCompound initNBT = null; private class PathIterator { @@ -215,7 +215,6 @@ public class TileBuilder extends TileAbstractBuilder implements IMachine { } if (bluePrintBuilder != null) { - NBTTagCompound builderCpt = new NBTTagCompound(); bluePrintBuilder.loadBuildStateToNBT( initNBT.getCompoundTag("builderState"), this); } diff --git a/common/buildcraft/builders/TileFiller.java b/common/buildcraft/builders/TileFiller.java index 9ec9caed..e86788fd 100644 --- a/common/buildcraft/builders/TileFiller.java +++ b/common/buildcraft/builders/TileFiller.java @@ -52,6 +52,8 @@ public class TileFiller extends TileAbstractBuilder implements IMachine, IAction private ActionMachineControl.Mode lastMode = ActionMachineControl.Mode.Unknown; private SimpleInventory inv = new SimpleInventory(27, "Filler", 64); + private NBTTagCompound initNBT = null; + public TileFiller() { inv.addListener(this); box.kind = Kind.STRIPES; @@ -61,19 +63,35 @@ public class TileFiller extends TileAbstractBuilder implements IMachine, IAction public void initialize() { super.initialize(); - if (!worldObj.isRemote) { - IAreaProvider a = Utils.getNearbyAreaProvider(worldObj, xCoord, yCoord, zCoord); - - if (a != null) { - box.initialize(a); - - if (a instanceof TileMarker) { - ((TileMarker) a).removeFromWorld(); - } - - sendNetworkUpdate(); - } + if (worldObj.isRemote) { + return; } + + IAreaProvider a = Utils.getNearbyAreaProvider(worldObj, xCoord, yCoord, + zCoord); + + if (a != null) { + box.initialize(a); + + if (a instanceof TileMarker) { + ((TileMarker) a).removeFromWorld(); + } + + sendNetworkUpdate(); + } + + if (currentPattern != null && currentTemplate == null) { + currentTemplate = currentPattern + .getTemplateBuilder(box, getWorld()); + context = currentTemplate.getContext(); + } + + if (initNBT != null && currentTemplate != null) { + currentTemplate.loadBuildStateToNBT( + initNBT.getCompoundTag("builderState"), this); + } + + initNBT = null; } @Override @@ -92,7 +110,7 @@ public class TileFiller extends TileAbstractBuilder implements IMachine, IAction return; } - if (mjStored < POWER_ACTIVATION && !buildTracker.markTimeIfDelay(worldObj)) { + if (mjStored < POWER_ACTIVATION || !buildTracker.markTimeIfDelay(worldObj)) { return; } @@ -175,6 +193,9 @@ public class TileFiller extends TileAbstractBuilder implements IMachine, IAction done = nbt.getBoolean("done"); lastMode = Mode.values()[nbt.getByte("lastMode")]; + + // The rest of load has to be done upon initialize. + initNBT = (NBTTagCompound) nbt.getCompoundTag("bpt").copy(); } @Override @@ -193,6 +214,16 @@ public class TileFiller extends TileAbstractBuilder implements IMachine, IAction nbt.setBoolean("done", done); nbt.setByte("lastMode", (byte) lastMode.ordinal()); + + NBTTagCompound bptNBT = new NBTTagCompound(); + + if (currentTemplate != null) { + NBTTagCompound builderCpt = new NBTTagCompound(); + currentTemplate.saveBuildStateToNBT(builderCpt, this); + bptNBT.setTag("builderState", builderCpt); + } + + nbt.setTag("bpt", bptNBT); } @Override diff --git a/api/buildcraft/api/blueprints/SchematicFactoryBlock.java b/common/buildcraft/builders/schematics/SchematicFactoryBlock.java similarity index 84% rename from api/buildcraft/api/blueprints/SchematicFactoryBlock.java rename to common/buildcraft/builders/schematics/SchematicFactoryBlock.java index 28ee77c4..5c4c006c 100755 --- a/api/buildcraft/api/blueprints/SchematicFactoryBlock.java +++ b/common/buildcraft/builders/schematics/SchematicFactoryBlock.java @@ -6,8 +6,12 @@ * 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.blueprints; +package buildcraft.builders.schematics; +import buildcraft.api.blueprints.MappingRegistry; +import buildcraft.api.blueprints.SchematicBlock; +import buildcraft.api.blueprints.SchematicFactory; +import buildcraft.api.blueprints.SchematicRegistry; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.nbt.NBTTagCompound; diff --git a/api/buildcraft/api/blueprints/SchematicFactoryEntity.java b/common/buildcraft/builders/schematics/SchematicFactoryEntity.java similarity index 81% rename from api/buildcraft/api/blueprints/SchematicFactoryEntity.java rename to common/buildcraft/builders/schematics/SchematicFactoryEntity.java index 9e275d02..8db37f3b 100755 --- a/api/buildcraft/api/blueprints/SchematicFactoryEntity.java +++ b/common/buildcraft/builders/schematics/SchematicFactoryEntity.java @@ -6,8 +6,12 @@ * 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.blueprints; +package buildcraft.builders.schematics; +import buildcraft.api.blueprints.MappingRegistry; +import buildcraft.api.blueprints.SchematicEntity; +import buildcraft.api.blueprints.SchematicFactory; +import buildcraft.api.blueprints.SchematicRegistry; import net.minecraft.nbt.NBTTagCompound; public class SchematicFactoryEntity extends SchematicFactory { diff --git a/api/buildcraft/api/blueprints/SchematicFactoryMask.java b/common/buildcraft/builders/schematics/SchematicFactoryMask.java similarity index 81% rename from api/buildcraft/api/blueprints/SchematicFactoryMask.java rename to common/buildcraft/builders/schematics/SchematicFactoryMask.java index 1bc7b0dd..f5c3765a 100755 --- a/api/buildcraft/api/blueprints/SchematicFactoryMask.java +++ b/common/buildcraft/builders/schematics/SchematicFactoryMask.java @@ -6,8 +6,11 @@ * 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.blueprints; +package buildcraft.builders.schematics; +import buildcraft.api.blueprints.MappingRegistry; +import buildcraft.api.blueprints.SchematicFactory; +import buildcraft.api.blueprints.SchematicMask; import net.minecraft.nbt.NBTTagCompound; public class SchematicFactoryMask extends SchematicFactory { diff --git a/common/buildcraft/core/BuildCraftConfiguration.java b/common/buildcraft/core/BuildCraftConfiguration.java index e32192ba..b0b9b8f6 100644 --- a/common/buildcraft/core/BuildCraftConfiguration.java +++ b/common/buildcraft/core/BuildCraftConfiguration.java @@ -9,6 +9,7 @@ package buildcraft.core; import java.io.File; + import net.minecraftforge.common.config.Configuration; import net.minecraftforge.common.config.Property; @@ -24,12 +25,4 @@ public class BuildCraftConfiguration extends Configuration { versionProp.set(Version.VERSION); super.save(); } - - public static String surroundWithQuotes(String stringToSurroundWithQuotes){ - return String.format("\"%s\"", stringToSurroundWithQuotes); - } - - public static String stripSurroundingQuotes(String stringToStripQuotes) { - return stringToStripQuotes.replaceAll("^\"|\"$", ""); - } } diff --git a/common/buildcraft/core/blueprints/BuildingSlotBlock.java b/common/buildcraft/core/blueprints/BuildingSlotBlock.java index 4a54f551..9b485aa2 100755 --- a/common/buildcraft/core/blueprints/BuildingSlotBlock.java +++ b/common/buildcraft/core/blueprints/BuildingSlotBlock.java @@ -12,13 +12,14 @@ import java.util.LinkedList; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.util.Constants; import buildcraft.api.blueprints.IBuilderContext; import buildcraft.api.blueprints.MappingRegistry; import buildcraft.api.blueprints.SchematicBlockBase; import buildcraft.api.blueprints.SchematicFactory; import buildcraft.api.blueprints.SchematicMask; -import buildcraft.api.core.BuildCraftAPI; import buildcraft.api.core.Position; public class BuildingSlotBlock extends BuildingSlot { @@ -93,8 +94,9 @@ public class BuildingSlotBlock extends BuildingSlot { @Override public void writeCompleted (IBuilderContext context, double complete) { - if (BuildCraftAPI.isSoftBlock(context.world(), x, y, z)) { - getSchematic().writeCompleted(context, x, y, z, complete); + if (mode == Mode.ClearIfInvalid) { + context.world().destroyBlockInWorldPartially(0, x, y, z, + (int) (complete * 10.0F) - 1); } } @@ -110,10 +112,22 @@ public class BuildingSlotBlock extends BuildingSlot { nbt.setInteger("y", y); nbt.setInteger("z", z); - NBTTagCompound schematicNBT = new NBTTagCompound(); - SchematicFactory.getFactory(schematic.getClass()) - .saveSchematicToWorldNBT(schematicNBT, schematic, registry); - nbt.setTag("schematic", schematicNBT); + if (schematic != null) { + NBTTagCompound schematicNBT = new NBTTagCompound(); + SchematicFactory.getFactory(schematic.getClass()) + .saveSchematicToWorldNBT(schematicNBT, schematic, registry); + nbt.setTag("schematic", schematicNBT); + } + + NBTTagList nbtStacks = new NBTTagList (); + + for (ItemStack stack : stackConsumed) { + NBTTagCompound nbtStack = new NBTTagCompound(); + stack.writeToNBT(nbtStack); + nbtStacks.appendTag(nbtStack); + } + + nbt.setTag("stackConsumed", nbtStacks); } @Override @@ -123,8 +137,20 @@ public class BuildingSlotBlock extends BuildingSlot { y = nbt.getInteger("y"); z = nbt.getInteger("z"); - schematic = (SchematicBlockBase) SchematicFactory + if (nbt.hasKey("schematic")) { + schematic = (SchematicBlockBase) SchematicFactory .createSchematicFromWorldNBT(nbt.getCompoundTag("schematic"), registry); + } + + stackConsumed = new LinkedList(); + + NBTTagList nbtStacks = nbt.getTagList("stackConsumed", Constants.NBT.TAG_COMPOUND); + + for (int i = 0; i < nbtStacks.tagCount(); ++i) { + stackConsumed.add(ItemStack.loadItemStackFromNBT(nbtStacks + .getCompoundTagAt(i))); + } + } @Override diff --git a/common/buildcraft/factory/TileQuarry.java b/common/buildcraft/factory/TileQuarry.java index e4c18587..3be78aeb 100644 --- a/common/buildcraft/factory/TileQuarry.java +++ b/common/buildcraft/factory/TileQuarry.java @@ -87,7 +87,9 @@ public class TileQuarry extends TileAbstractBuilder implements IMachine { private Ticket chunkTicket; public EntityPlayer placedBy; - boolean frameProducer = true; + private boolean frameProducer = true; + + private NBTTagCompound initNBT = null; public TileQuarry () { box.kind = Kind.STRIPES; @@ -167,7 +169,9 @@ public class TileQuarry extends TileAbstractBuilder implements IMachine { if (stage == Stage.BUILDING) { if (builder != null && !builder.isDone(this)) { - builder.buildNextSlot(worldObj, this, xCoord, yCoord, zCoord); + if (buildTracker.markTimeIfDelay(worldObj)) { + builder.buildNextSlot(worldObj, this, xCoord, yCoord, zCoord); + } } else { stage = Stage.IDLE; } @@ -360,6 +364,9 @@ public class TileQuarry extends TileAbstractBuilder implements IMachine { headPosX = nbttagcompound.getDouble("headPosX"); headPosY = nbttagcompound.getDouble("headPosY"); headPosZ = nbttagcompound.getDouble("headPosZ"); + + // The rest of load has to be done upon initialize. + initNBT = (NBTTagCompound) nbttagcompound.getCompoundTag("bpt").copy(); } @Override @@ -376,6 +383,16 @@ public class TileQuarry extends TileAbstractBuilder implements IMachine { NBTTagCompound boxTag = new NBTTagCompound(); box.writeToNBT(boxTag); nbttagcompound.setTag("box", boxTag); + + NBTTagCompound bptNBT = new NBTTagCompound(); + + if (builder != null) { + NBTTagCompound builderCpt = new NBTTagCompound(); + builder.saveBuildStateToNBT(builderCpt, this); + bptNBT.setTag("builderState", builderCpt); + } + + nbttagcompound.setTag("bpt", bptNBT); } @SuppressWarnings("rawtypes") @@ -627,6 +644,13 @@ public class TileQuarry extends TileAbstractBuilder implements IMachine { createUtilsIfNeeded(); + if (initNBT != null && builder != null) { + builder.loadBuildStateToNBT( + initNBT.getCompoundTag("builderState"), this); + } + + initNBT = null; + sendNetworkUpdate(); } diff --git a/common/buildcraft/transport/ItemFacade.java b/common/buildcraft/transport/ItemFacade.java index 7c833eed..913d173c 100644 --- a/common/buildcraft/transport/ItemFacade.java +++ b/common/buildcraft/transport/ItemFacade.java @@ -8,19 +8,10 @@ */ package buildcraft.transport; -import buildcraft.BuildCraftTransport; -import buildcraft.api.core.Position; -import buildcraft.api.recipes.BuildcraftRecipes; -import buildcraft.api.transport.PipeWire; -import buildcraft.core.BlockSpring; -import buildcraft.core.BuildCraftConfiguration; -import buildcraft.core.CreativeTabBuildCraft; -import buildcraft.core.ItemBuildCraft; -import buildcraft.core.proxy.CoreProxy; -import com.google.common.base.Strings; -import com.google.common.collect.Sets; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; + import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; @@ -34,10 +25,21 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; +import buildcraft.BuildCraftTransport; +import buildcraft.api.core.JavaTools; +import buildcraft.api.core.Position; +import buildcraft.api.recipes.BuildcraftRecipes; +import buildcraft.api.transport.PipeWire; +import buildcraft.core.BlockSpring; +import buildcraft.core.CreativeTabBuildCraft; +import buildcraft.core.ItemBuildCraft; +import buildcraft.core.proxy.CoreProxy; -import java.util.LinkedList; -import java.util.List; -import java.util.Set; +import com.google.common.base.Strings; +import com.google.common.collect.Sets; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; public class ItemFacade extends ItemBuildCraft { @@ -121,14 +123,16 @@ public class ItemFacade extends ItemBuildCraft { @Override public boolean onItemUse(ItemStack stack, EntityPlayer player, World worldObj, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { - if (worldObj.isRemote) + if (worldObj.isRemote) { return false; + } Position pos = new Position(x, y, z, ForgeDirection.getOrientation(side)); pos.moveForwards(1.0); TileEntity tile = worldObj.getTileEntity((int) pos.x, (int) pos.y, (int) pos.z); - if (!(tile instanceof TileGenericPipe)) + if (!(tile instanceof TileGenericPipe)) { return false; + } TileGenericPipe pipeTile = (TileGenericPipe) tile; if (pipeTile.addFacade(ForgeDirection.getOrientation(side).getOpposite(), ItemFacade.getType(stack), ItemFacade.getWireType(stack), ItemFacade.getBlocks(stack), ItemFacade.getMetaValues(stack))) { @@ -194,7 +198,7 @@ public class ItemFacade extends ItemBuildCraft { } for (String blacklistedBlock : BuildCraftTransport.facadeBlacklist) { - if(blockName.equals(BuildCraftConfiguration.stripSurroundingQuotes(blacklistedBlock))) { + if(blockName.equals(JavaTools.stripSurroundingQuotes(blacklistedBlock))) { return true; } }