Merge branch '6.0.x' of https://github.com/AEnterprise/BuildCraft into AEnterprise-6.0.x
This commit is contained in:
commit
949d8054c4
2 changed files with 60 additions and 3 deletions
|
@ -35,5 +35,13 @@ public abstract class BlueprintDeployer {
|
||||||
*/
|
*/
|
||||||
public abstract void deployBlueprint(World world, int x, int y, int z,
|
public abstract void deployBlueprint(World world, int x, int y, int z,
|
||||||
ForgeDirection dir, File file);
|
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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,11 +9,12 @@
|
||||||
package buildcraft.core.blueprints;
|
package buildcraft.core.blueprints;
|
||||||
|
|
||||||
import java.io.File;
|
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.minecraft.world.World;
|
||||||
|
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
import buildcraft.api.blueprints.BlueprintDeployer;
|
import buildcraft.api.blueprints.BlueprintDeployer;
|
||||||
import buildcraft.api.blueprints.Translation;
|
import buildcraft.api.blueprints.Translation;
|
||||||
import buildcraft.builders.blueprints.BlueprintDatabase;
|
import buildcraft.builders.blueprints.BlueprintDatabase;
|
||||||
|
@ -55,7 +56,55 @@ public class RealBlueprintDeployer extends BlueprintDeployer {
|
||||||
|
|
||||||
bpt.transformToWorld(transform);
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue