mirror of
https://github.com/EngineHub/WorldEdit.git
synced 2024-12-21 04:49:51 +08:00
Fixed up tile entities in Sponge schematics.
This commit is contained in:
parent
b2769befdb
commit
38cff7c7b2
@ -73,7 +73,7 @@ public boolean isFormat(File file) {
|
||||
|
||||
// Check
|
||||
Map<String, Tag> schematic = schematicTag.getValue();
|
||||
if (!schematic.containsKey("Blocks")) {
|
||||
if (!schematic.containsKey("Materials")) {
|
||||
return false;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
|
@ -110,18 +110,18 @@ private Clipboard readVersion1(Map<String, Tag> schematic) throws IOException {
|
||||
throw new IOException("Invalid offset specified in schematic.");
|
||||
}
|
||||
|
||||
Vector offset = new Vector(offsetParts[0], offsetParts[1], offsetParts[2]);
|
||||
Vector min = new Vector(offsetParts[0], offsetParts[1], offsetParts[2]);
|
||||
|
||||
if (metadata.containsKey("WEOriginX")) {
|
||||
if (metadata.containsKey("WEOffsetX")) {
|
||||
// We appear to have WorldEdit Metadata
|
||||
int originX = requireTag(metadata, "WEOriginX", IntTag.class).getValue();
|
||||
int originY = requireTag(metadata, "WEOriginY", IntTag.class).getValue();
|
||||
int originZ = requireTag(metadata, "WEOriginZ", IntTag.class).getValue();
|
||||
Vector min = new Vector(originX, originY, originZ);
|
||||
int offsetX = requireTag(metadata, "WEOffsetX", IntTag.class).getValue();
|
||||
int offsetY = requireTag(metadata, "WEOffsetY", IntTag.class).getValue();
|
||||
int offsetZ = requireTag(metadata, "WEOffsetZ", IntTag.class).getValue();
|
||||
Vector offset = new Vector(offsetX, offsetY, offsetZ);
|
||||
origin = min.subtract(offset);
|
||||
region = new CuboidRegion(origin, origin.add(width, height, length).subtract(Vector.ONE));
|
||||
} else {
|
||||
origin = Vector.ZERO.subtract(offset);
|
||||
origin = min;
|
||||
region = new CuboidRegion(origin, origin.add(width, height, length).subtract(Vector.ONE));
|
||||
}
|
||||
|
||||
@ -160,7 +160,7 @@ private Clipboard readVersion1(Map<String, Tag> schematic) throws IOException {
|
||||
|
||||
for (Map<String, Tag> tileEntity : tileEntityTags) {
|
||||
int[] pos = requireTag(tileEntity, "Pos", IntArrayTag.class).getValue();
|
||||
tileEntitiesMap.put(new BlockVector(pos[0], pos[1], pos[2]), tileEntity);
|
||||
tileEntitiesMap.put(origin.add(new BlockVector(pos[0], pos[1], pos[2])).toBlockVector(), tileEntity);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new IOException("Failed to load Tile Entities: " + e.getMessage());
|
||||
|
@ -97,9 +97,9 @@ private Map<String, Tag> write1(Clipboard clipboard) throws IOException {
|
||||
schematic.put("Version", new IntTag(1));
|
||||
|
||||
Map<String, Tag> metadata = new HashMap<>();
|
||||
metadata.put("WEOriginX", new IntTag(min.getBlockX()));
|
||||
metadata.put("WEOriginY", new IntTag(min.getBlockY()));
|
||||
metadata.put("WEOriginZ", new IntTag(min.getBlockZ()));
|
||||
metadata.put("WEOffsetX", new IntTag(offset.getBlockX()));
|
||||
metadata.put("WEOffsetY", new IntTag(offset.getBlockY()));
|
||||
metadata.put("WEOffsetZ", new IntTag(offset.getBlockZ()));
|
||||
|
||||
schematic.put("Metadata", new CompoundTag(metadata));
|
||||
|
||||
@ -107,10 +107,11 @@ private Map<String, Tag> write1(Clipboard clipboard) throws IOException {
|
||||
schematic.put("Height", new ShortTag((short) height));
|
||||
schematic.put("Length", new ShortTag((short) length));
|
||||
|
||||
// The Sponge format Offset refers to the 'min' points location in the world. That's our 'Origin'
|
||||
schematic.put("Offset", new IntArrayTag(new int[]{
|
||||
offset.getBlockX(),
|
||||
offset.getBlockY(),
|
||||
offset.getBlockZ(),
|
||||
min.getBlockX(),
|
||||
min.getBlockY(),
|
||||
min.getBlockZ(),
|
||||
}));
|
||||
|
||||
int paletteMax = 0;
|
||||
@ -136,9 +137,9 @@ private Map<String, Tag> write1(Clipboard clipboard) throws IOException {
|
||||
|
||||
values.put("Id", new StringTag(block.getNbtId()));
|
||||
values.put("Pos", new IntArrayTag(new int[]{
|
||||
point.getBlockX(),
|
||||
point.getBlockY(),
|
||||
point.getBlockZ()
|
||||
x,
|
||||
y,
|
||||
z
|
||||
}));
|
||||
|
||||
CompoundTag tileEntityTag = new CompoundTag(values);
|
||||
|
Loading…
Reference in New Issue
Block a user