Added LongArrayTag support to NBT

This commit is contained in:
Matthew Miller
2018-08-05 13:36:53 +10:00
parent 9494c4445a
commit 334143357a
12 changed files with 135 additions and 7 deletions

View File

@ -76,7 +76,7 @@ public enum BuiltInClipboardFormat implements ClipboardFormat {
if (!schematic.containsKey("Materials")) {
return false;
}
} catch (IOException e) {
} catch (Exception e) {
return false;
}
return true;
@ -115,7 +115,7 @@ public enum BuiltInClipboardFormat implements ClipboardFormat {
if (!schematic.containsKey("Version")) {
return false;
}
} catch (IOException e) {
} catch (Exception e) {
return false;
}

View File

@ -202,6 +202,12 @@ public class SpongeSchematicReader extends NBTSchematicReader {
handler.updateNBT(state, values);
}
}
values.put("x", new IntTag(pt.getBlockX()));
values.put("y", new IntTag(pt.getBlockY()));
values.put("z", new IntTag(pt.getBlockZ()));
values.put("id", values.get("Id"));
values.remove("Id");
values.remove("Pos");
clipboard.setBlock(pt, new BaseBlock(state, new CompoundTag(values)));
} else {
clipboard.setBlock(pt, state);

View File

@ -117,7 +117,7 @@ public class SpongeSchematicWriter implements ClipboardWriter {
int paletteMax = 0;
Map<String, Integer> palette = new HashMap<>();
List<Tag> tileEntities = new ArrayList<>();
List<CompoundTag> tileEntities = new ArrayList<>();
ByteArrayOutputStream buffer = new ByteArrayOutputStream(width * height * length);
@ -135,6 +135,13 @@ public class SpongeSchematicWriter implements ClipboardWriter {
values.put(entry.getKey(), entry.getValue());
}
values.remove("id"); // Remove 'id' if it exists. We want 'Id'
// Positions are kept in NBT, we don't want that.
values.remove("x");
values.remove("y");
values.remove("z");
values.put("Id", new StringTag(block.getNbtId()));
values.put("Pos", new IntArrayTag(new int[]{
x,
@ -142,8 +149,7 @@ public class SpongeSchematicWriter implements ClipboardWriter {
z
}));
CompoundTag tileEntityTag = new CompoundTag(values);
tileEntities.add(tileEntityTag);
tileEntities.add(new CompoundTag(values));
}
String blockKey = block.toImmutableState().getAsString();