From 7f2391649eca59ab974bd4faf5ae938dd63f1722 Mon Sep 17 00:00:00 2001 From: sk89q Date: Tue, 16 Nov 2010 22:34:18 -0800 Subject: [PATCH] Offsets are now saved with .schematic files. --- src/CuboidClipboard.java | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/CuboidClipboard.java b/src/CuboidClipboard.java index df1b22ba8..d73abaef0 100644 --- a/src/CuboidClipboard.java +++ b/src/CuboidClipboard.java @@ -227,6 +227,9 @@ public class CuboidClipboard { schematic.put("WEOriginX", new IntTag("WEOriginX", getOrigin().getBlockX())); schematic.put("WEOriginY", new IntTag("WEOriginY", getOrigin().getBlockY())); schematic.put("WEOriginZ", new IntTag("WEOriginZ", getOrigin().getBlockZ())); + schematic.put("WEOffsetX", new IntTag("WEOffsetX", getOffset().getBlockX())); + schematic.put("WEOffsetY", new IntTag("WEOffsetY", getOffset().getBlockY())); + schematic.put("WEOffsetZ", new IntTag("WEOffsetZ", getOffset().getBlockZ())); // Copy byte[] blocks = new byte[width * height * length]; @@ -289,6 +292,7 @@ public class CuboidClipboard { NBTInputStream nbtStream = new NBTInputStream(stream); Vector origin = new Vector(); + Vector offset = new Vector(); // Schematic tag CompoundTag schematicTag = (CompoundTag)nbtStream.readTag(); @@ -316,6 +320,15 @@ public class CuboidClipboard { // No origin data } + try { + int offsetX = (Integer)getChildTag(schematic, "WEOffsetX", IntTag.class).getValue(); + int offsetY = (Integer)getChildTag(schematic, "WEOffsetY", IntTag.class).getValue(); + int offsetZ = (Integer)getChildTag(schematic, "WEOffsetZ", IntTag.class).getValue(); + offset = new Vector(offsetX, offsetY, offsetZ); + } catch (DataException e) { + // No offset data + } + // Check type of Schematic String materials = (String)getChildTag(schematic, "Materials", StringTag.class).getValue(); if (!materials.equals("Alpha")) { @@ -367,6 +380,7 @@ public class CuboidClipboard { Vector size = new Vector(width, height, length); CuboidClipboard clipboard = new CuboidClipboard(size); clipboard.setOrigin(origin); + clipboard.setOffset(offset); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { @@ -434,4 +448,18 @@ public class CuboidClipboard { public void setOrigin(Vector origin) { this.origin = origin; } + + /** + * @return the offset + */ + public Vector getOffset() { + return offset; + } + + /** + * @param origin the offset to set + */ + public void setOffset(Vector offset) { + this.offset = offset; + } }