mirror of
https://github.com/EngineHub/WorldEdit.git
synced 2024-12-21 04:49:51 +08:00
Offsets are now saved with .schematic files.
This commit is contained in:
parent
cc9d639afb
commit
7f2391649e
@ -227,6 +227,9 @@ public void saveSchematic(String path) throws IOException, DataException {
|
|||||||
schematic.put("WEOriginX", new IntTag("WEOriginX", getOrigin().getBlockX()));
|
schematic.put("WEOriginX", new IntTag("WEOriginX", getOrigin().getBlockX()));
|
||||||
schematic.put("WEOriginY", new IntTag("WEOriginY", getOrigin().getBlockY()));
|
schematic.put("WEOriginY", new IntTag("WEOriginY", getOrigin().getBlockY()));
|
||||||
schematic.put("WEOriginZ", new IntTag("WEOriginZ", getOrigin().getBlockZ()));
|
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
|
// Copy
|
||||||
byte[] blocks = new byte[width * height * length];
|
byte[] blocks = new byte[width * height * length];
|
||||||
@ -289,6 +292,7 @@ public static CuboidClipboard loadSchematic(String path)
|
|||||||
NBTInputStream nbtStream = new NBTInputStream(stream);
|
NBTInputStream nbtStream = new NBTInputStream(stream);
|
||||||
|
|
||||||
Vector origin = new Vector();
|
Vector origin = new Vector();
|
||||||
|
Vector offset = new Vector();
|
||||||
|
|
||||||
// Schematic tag
|
// Schematic tag
|
||||||
CompoundTag schematicTag = (CompoundTag)nbtStream.readTag();
|
CompoundTag schematicTag = (CompoundTag)nbtStream.readTag();
|
||||||
@ -316,6 +320,15 @@ public static CuboidClipboard loadSchematic(String path)
|
|||||||
// No origin data
|
// 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
|
// Check type of Schematic
|
||||||
String materials = (String)getChildTag(schematic, "Materials", StringTag.class).getValue();
|
String materials = (String)getChildTag(schematic, "Materials", StringTag.class).getValue();
|
||||||
if (!materials.equals("Alpha")) {
|
if (!materials.equals("Alpha")) {
|
||||||
@ -367,6 +380,7 @@ public static CuboidClipboard loadSchematic(String path)
|
|||||||
Vector size = new Vector(width, height, length);
|
Vector size = new Vector(width, height, length);
|
||||||
CuboidClipboard clipboard = new CuboidClipboard(size);
|
CuboidClipboard clipboard = new CuboidClipboard(size);
|
||||||
clipboard.setOrigin(origin);
|
clipboard.setOrigin(origin);
|
||||||
|
clipboard.setOffset(offset);
|
||||||
|
|
||||||
for (int x = 0; x < width; x++) {
|
for (int x = 0; x < width; x++) {
|
||||||
for (int y = 0; y < height; y++) {
|
for (int y = 0; y < height; y++) {
|
||||||
@ -434,4 +448,18 @@ public Vector getOrigin() {
|
|||||||
public void setOrigin(Vector origin) {
|
public void setOrigin(Vector origin) {
|
||||||
this.origin = 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user