From 01bf28a77d3a9d913f5f8417a0f9e658f35876cc Mon Sep 17 00:00:00 2001 From: AEnterprise Date: Sun, 4 May 2014 17:11:38 +0200 Subject: [PATCH 1/2] fix for the blueprint deployer --- .../api/blueprints/BlueprintDeployer.java | 8 +++ .../blueprints/RealBlueprintDeployer.java | 55 ++++++++++++++++++- 2 files changed, 60 insertions(+), 3 deletions(-) diff --git a/api/buildcraft/api/blueprints/BlueprintDeployer.java b/api/buildcraft/api/blueprints/BlueprintDeployer.java index baca838b..044db825 100755 --- a/api/buildcraft/api/blueprints/BlueprintDeployer.java +++ b/api/buildcraft/api/blueprints/BlueprintDeployer.java @@ -35,5 +35,13 @@ public abstract class BlueprintDeployer { */ public abstract void deployBlueprint(World world, int x, int y, int z, ForgeDirection dir, File file); + + /** + *Deploy the contents of the byte array as if the builder was located at + *{x, y, z} facing the direction dir. + */ + + public abstract void deployBlueprintFromFileStream(World world, int x, int y, + int z, ForgeDirection dir, byte [] data); } diff --git a/common/buildcraft/core/blueprints/RealBlueprintDeployer.java b/common/buildcraft/core/blueprints/RealBlueprintDeployer.java index 93200b24..952f14c0 100755 --- a/common/buildcraft/core/blueprints/RealBlueprintDeployer.java +++ b/common/buildcraft/core/blueprints/RealBlueprintDeployer.java @@ -9,11 +9,12 @@ package buildcraft.core.blueprints; import java.io.File; +import java.io.IOException; +import net.minecraft.nbt.CompressedStreamTools; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; - import net.minecraftforge.common.util.ForgeDirection; - import buildcraft.api.blueprints.BlueprintDeployer; import buildcraft.api.blueprints.Translation; import buildcraft.builders.blueprints.BlueprintDatabase; @@ -55,7 +56,55 @@ public class RealBlueprintDeployer extends BlueprintDeployer { bpt.transformToWorld(transform); - new BptBuilderBlueprint(bpt, world, x, y, z).deploy (); + BptBuilderBlueprint deployer = new BptBuilderBlueprint(bpt, world, x, y, z); + deployer.initialize(); + deployer.deploy(); } + @Override + public void deployBlueprintFromFileStream(World world, int x, int y, int z, + ForgeDirection dir, byte [] data ) { + + NBTTagCompound nbt; + try { + nbt = CompressedStreamTools.decompress(data); + BlueprintBase blueprint = BlueprintBase.loadBluePrint(nbt); + Blueprint bpt = (Blueprint) blueprint; + bpt.setData(data); + bpt.id = new BlueprintId(); + bpt.id.kind = Kind.Blueprint; + + BptContext context = bpt.getContext(world, bpt.getBoxForPos(x, y, z)); + + if (bpt.rotate) { + if (dir == ForgeDirection.EAST) { + // Do nothing + } else if (dir == ForgeDirection.SOUTH) { + bpt.rotateLeft(context); + } else if (dir == ForgeDirection.WEST) { + bpt.rotateLeft(context); + bpt.rotateLeft(context); + } else if (dir == ForgeDirection.NORTH) { + bpt.rotateLeft(context); + bpt.rotateLeft(context); + bpt.rotateLeft(context); + } + } + Translation transform = new Translation(); + + transform.x = x - bpt.anchorX; + transform.y = y - bpt.anchorY; + transform.z = z - bpt.anchorZ; + + bpt.transformToWorld(transform); + + BptBuilderBlueprint deployer = new BptBuilderBlueprint(bpt, world, x, y, z); + deployer.initialize(); + deployer.deploy(); + } catch (IOException e) { + + e.printStackTrace(); + } + } } + From 810ff8b07d1a0b36f5a1e11e0fc2620ab2898703 Mon Sep 17 00:00:00 2001 From: AEnterprise Date: Sun, 4 May 2014 18:17:10 +0200 Subject: [PATCH 2/2] fix space before ) on the realBueprintDeployer --- common/buildcraft/core/blueprints/RealBlueprintDeployer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/buildcraft/core/blueprints/RealBlueprintDeployer.java b/common/buildcraft/core/blueprints/RealBlueprintDeployer.java index 952f14c0..b3d07d5d 100755 --- a/common/buildcraft/core/blueprints/RealBlueprintDeployer.java +++ b/common/buildcraft/core/blueprints/RealBlueprintDeployer.java @@ -63,7 +63,7 @@ public class RealBlueprintDeployer extends BlueprintDeployer { @Override public void deployBlueprintFromFileStream(World world, int x, int y, int z, - ForgeDirection dir, byte [] data ) { + ForgeDirection dir, byte [] data) { NBTTagCompound nbt; try {