TAG_Byte_Array
tag.
+ *
+ * @author Graham Edgecombe
+ */
+public final class ByteArrayTag extends Tag {
+
+ /**
+ * The value.
+ */
+ private final byte[] value;
+
+ /**
+ * Creates the tag.
+ *
+ * @param name The name.
+ * @param value The value.
+ */
+ public ByteArrayTag(String name, byte[] value) {
+ super(name);
+ this.value = value;
+ }
+
+ @Override
+ public byte[] getValue() {
+ return value;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder hex = new StringBuilder();
+ for (byte b : value) {
+ String hexDigits = Integer.toHexString(b).toUpperCase();
+ if (hexDigits.length() == 1) {
+ hex.append("0");
+ }
+ hex.append(hexDigits).append(" ");
+ }
+ String name = getName();
+ String append = "";
+ if (name != null && !name.equals("")) {
+ append = "(\"" + this.getName() + "\")";
+ }
+ return "TAG_Byte_Array" + append + ": " + hex;
+ }
+
+}
diff --git a/src/main/java/com/volmit/iris/util/oldnbt/ByteTag.java b/src/main/java/com/volmit/iris/util/oldnbt/ByteTag.java
new file mode 100644
index 000000000..edb4bf2b6
--- /dev/null
+++ b/src/main/java/com/volmit/iris/util/oldnbt/ByteTag.java
@@ -0,0 +1,59 @@
+/*
+ * Iris is a World Generator for Minecraft Bukkit Servers
+ * Copyright (c) 2021 Arcane Arts (Volmit Software)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see TAG_Byte
tag.
+ *
+ * @author Graham Edgecombe
+ */
+public final class ByteTag extends Tag {
+
+ /**
+ * The value.
+ */
+ private final byte value;
+
+ /**
+ * Creates the tag.
+ *
+ * @param name The name.
+ * @param value The value.
+ */
+ public ByteTag(String name, byte value) {
+ super(name);
+ this.value = value;
+ }
+
+ @Override
+ public Byte getValue() {
+ return value;
+ }
+
+ @Override
+ public String toString() {
+ String name = getName();
+ String append = "";
+ if (name != null && !name.equals("")) {
+ append = "(\"" + this.getName() + "\")";
+ }
+ return "TAG_Byte" + append + ": " + value;
+ }
+
+}
diff --git a/src/main/java/com/volmit/iris/util/oldnbt/CompoundTag.java b/src/main/java/com/volmit/iris/util/oldnbt/CompoundTag.java
new file mode 100644
index 000000000..61d61d606
--- /dev/null
+++ b/src/main/java/com/volmit/iris/util/oldnbt/CompoundTag.java
@@ -0,0 +1,67 @@
+/*
+ * Iris is a World Generator for Minecraft Bukkit Servers
+ * Copyright (c) 2021 Arcane Arts (Volmit Software)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see TAG_Compound
tag.
+ *
+ * @author Graham Edgecombe
+ */
+public final class CompoundTag extends Tag {
+
+ /**
+ * The value.
+ */
+ private final MapTAG_Double
tag.
+ *
+ * @author Graham Edgecombe
+ */
+public final class DoubleTag extends Tag {
+
+ /**
+ * The value.
+ */
+ private final double value;
+
+ /**
+ * Creates the tag.
+ *
+ * @param name The name.
+ * @param value The value.
+ */
+ public DoubleTag(String name, double value) {
+ super(name);
+ this.value = value;
+ }
+
+ @Override
+ public Double getValue() {
+ return value;
+ }
+
+ @Override
+ public String toString() {
+ String name = getName();
+ String append = "";
+ if (name != null && !name.equals("")) {
+ append = "(\"" + this.getName() + "\")";
+ }
+ return "TAG_Double" + append + ": " + value;
+ }
+
+}
diff --git a/src/main/java/com/volmit/iris/util/oldnbt/EndTag.java b/src/main/java/com/volmit/iris/util/oldnbt/EndTag.java
new file mode 100644
index 000000000..4488e18ec
--- /dev/null
+++ b/src/main/java/com/volmit/iris/util/oldnbt/EndTag.java
@@ -0,0 +1,45 @@
+/*
+ * Iris is a World Generator for Minecraft Bukkit Servers
+ * Copyright (c) 2021 Arcane Arts (Volmit Software)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see TAG_End
tag.
+ *
+ * @author Graham Edgecombe
+ */
+public final class EndTag extends Tag {
+
+ /**
+ * Creates the tag.
+ */
+ public EndTag() {
+ super("");
+ }
+
+ @Override
+ public Object getValue() {
+ return null;
+ }
+
+ @Override
+ public String toString() {
+ return "TAG_End";
+ }
+
+}
diff --git a/src/main/java/com/volmit/iris/util/oldnbt/FloatTag.java b/src/main/java/com/volmit/iris/util/oldnbt/FloatTag.java
new file mode 100644
index 000000000..17833b557
--- /dev/null
+++ b/src/main/java/com/volmit/iris/util/oldnbt/FloatTag.java
@@ -0,0 +1,59 @@
+/*
+ * Iris is a World Generator for Minecraft Bukkit Servers
+ * Copyright (c) 2021 Arcane Arts (Volmit Software)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see TAG_Float
tag.
+ *
+ * @author Graham Edgecombe
+ */
+public final class FloatTag extends Tag {
+
+ /**
+ * The value.
+ */
+ private final float value;
+
+ /**
+ * Creates the tag.
+ *
+ * @param name The name.
+ * @param value The value.
+ */
+ public FloatTag(String name, float value) {
+ super(name);
+ this.value = value;
+ }
+
+ @Override
+ public Float getValue() {
+ return value;
+ }
+
+ @Override
+ public String toString() {
+ String name = getName();
+ String append = "";
+ if (name != null && !name.equals("")) {
+ append = "(\"" + this.getName() + "\")";
+ }
+ return "TAG_Float" + append + ": " + value;
+ }
+
+}
diff --git a/src/main/java/com/volmit/iris/util/oldnbt/IntArrayTag.java b/src/main/java/com/volmit/iris/util/oldnbt/IntArrayTag.java
new file mode 100644
index 000000000..a2e9ebef4
--- /dev/null
+++ b/src/main/java/com/volmit/iris/util/oldnbt/IntArrayTag.java
@@ -0,0 +1,61 @@
+/*
+ * Iris is a World Generator for Minecraft Bukkit Servers
+ * Copyright (c) 2021 Arcane Arts (Volmit Software)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see TAG_Int_Array
tag.
+ *
+ * @author Neil Wightman
+ */
+public final class IntArrayTag extends Tag {
+
+ /**
+ * The value.
+ */
+ private final int[] value;
+
+ /**
+ * Creates the tag.
+ *
+ * @param name The name.
+ * @param value The value.
+ */
+ public IntArrayTag(String name, int[] value) {
+ super(name);
+ this.value = value;
+ }
+
+ @Override
+ public int[] getValue() {
+ return value;
+ }
+
+ @Override
+ public String toString() {
+ String name = getName();
+ String append = "";
+ if (name != null && !name.equals("")) {
+ append = "(\"" + this.getName() + "\")";
+ }
+ return "TAG_Int_Array" + append + ": " + Arrays.toString(value);
+ }
+
+}
diff --git a/src/main/java/com/volmit/iris/util/oldnbt/IntTag.java b/src/main/java/com/volmit/iris/util/oldnbt/IntTag.java
new file mode 100644
index 000000000..7f2537249
--- /dev/null
+++ b/src/main/java/com/volmit/iris/util/oldnbt/IntTag.java
@@ -0,0 +1,59 @@
+/*
+ * Iris is a World Generator for Minecraft Bukkit Servers
+ * Copyright (c) 2021 Arcane Arts (Volmit Software)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see TAG_Int
tag.
+ *
+ * @author Graham Edgecombe
+ */
+public final class IntTag extends Tag {
+
+ /**
+ * The value.
+ */
+ private final int value;
+
+ /**
+ * Creates the tag.
+ *
+ * @param name The name.
+ * @param value The value.
+ */
+ public IntTag(String name, int value) {
+ super(name);
+ this.value = value;
+ }
+
+ @Override
+ public Integer getValue() {
+ return value;
+ }
+
+ @Override
+ public String toString() {
+ String name = getName();
+ String append = "";
+ if (name != null && !name.equals("")) {
+ append = "(\"" + this.getName() + "\")";
+ }
+ return "TAG_Int" + append + ": " + value;
+ }
+
+}
diff --git a/src/main/java/com/volmit/iris/util/oldnbt/ListTag.java b/src/main/java/com/volmit/iris/util/oldnbt/ListTag.java
new file mode 100644
index 000000000..71d144d75
--- /dev/null
+++ b/src/main/java/com/volmit/iris/util/oldnbt/ListTag.java
@@ -0,0 +1,84 @@
+/*
+ * Iris is a World Generator for Minecraft Bukkit Servers
+ * Copyright (c) 2021 Arcane Arts (Volmit Software)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see TAG_List
tag.
+ *
+ * @author Graham Edgecombe
+ */
+public final class ListTag extends Tag {
+
+ /**
+ * The type.
+ */
+ private final Class extends Tag> type;
+
+ /**
+ * The value.
+ */
+ private final ListTAG_Long
tag.
+ *
+ * @author Graham Edgecombe
+ */
+public final class LongTag extends Tag {
+
+ /**
+ * The value.
+ */
+ private final long value;
+
+ /**
+ * Creates the tag.
+ *
+ * @param name The name.
+ * @param value The value.
+ */
+ public LongTag(String name, long value) {
+ super(name);
+ this.value = value;
+ }
+
+ @Override
+ public Long getValue() {
+ return value;
+ }
+
+ @Override
+ public String toString() {
+ String name = getName();
+ String append = "";
+ if (name != null && !name.equals("")) {
+ append = "(\"" + this.getName() + "\")";
+ }
+ return "TAG_Long" + append + ": " + value;
+ }
+
+}
diff --git a/src/main/java/com/volmit/iris/util/oldnbt/NBTConstants.java b/src/main/java/com/volmit/iris/util/oldnbt/NBTConstants.java
new file mode 100644
index 000000000..690bf1514
--- /dev/null
+++ b/src/main/java/com/volmit/iris/util/oldnbt/NBTConstants.java
@@ -0,0 +1,63 @@
+/*
+ * Iris is a World Generator for Minecraft Bukkit Servers
+ * Copyright (c) 2021 Arcane Arts (Volmit Software)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see
+ * This class reads NBT, or
+ * Named Binary Tag streams, and produces an object graph of subclasses of the Tag
object.
+ * The NBT format was created by Markus Persson, and the specification may be found at + * http://www.minecraft.net/docs/NBT.txt.
+ * + * @author Graham Edgecombe + */ +public final class NBTInputStream implements Closeable { + + /** + * The data input stream. + */ + private final DataInputStream is; + + /** + * Create a newNBTInputStream
, which will source its data from the specified input stream.
+ *
+ * @param is The output stream
+ */
+ public NBTInputStream(DataInputStream is) {
+ this.is = is;
+ }
+
+ /**
+ * Creates a new NBTInputStream
, which will source its data from the specified input stream.
+ * The stream will be decompressed using GZIP.
+ *
+ * @param is The input stream.
+ * @throws IOException if an I/O error occurs.
+ */
+ public NBTInputStream(InputStream is) throws IOException {
+ this.is = new DataInputStream(new GZIPInputStream(is));
+ }
+
+ /**
+ * Reads an NBT tag from the stream.
+ *
+ * @return The tag that was read.
+ * @throws IOException if an I/O error occurs.
+ */
+ public Tag readTag() throws IOException {
+ return readTag(0);
+ }
+
+ /**
+ * Reads an NBT from the stream.
+ *
+ * @param depth The depth of this tag.
+ * @return The tag that was read.
+ * @throws IOException if an I/O error occurs.
+ */
+ private Tag readTag(int depth) throws IOException {
+ int type = is.readByte() & 0xFF;
+
+ String name;
+ if (type != NBTConstants.TYPE_END) {
+ int nameLength = is.readShort() & 0xFFFF;
+ byte[] nameBytes = new byte[nameLength];
+ is.readFully(nameBytes);
+ name = new String(nameBytes, NBTConstants.CHARSET);
+ } else {
+ name = "";
+ }
+
+ return readTagPayload(type, name, depth);
+ }
+
+ /**
+ * Reads the payload of a tag, given the name and type.
+ *
+ * @param type The type.
+ * @param name The name.
+ * @param depth The depth.
+ * @return The tag.
+ * @throws IOException if an I/O error occurs.
+ */
+ private Tag readTagPayload(int type, String name, int depth) throws IOException {
+ switch (type) {
+ case NBTConstants.TYPE_END:
+ if (depth == 0) {
+ throw new IOException("TAG_End found without a TAG_Compound/TAG_List tag preceding it.");
+ } else {
+ return new EndTag();
+ }
+ case NBTConstants.TYPE_BYTE:
+ return new ByteTag(name, is.readByte());
+ case NBTConstants.TYPE_SHORT:
+ return new ShortTag(name, is.readShort());
+ case NBTConstants.TYPE_INT:
+ return new IntTag(name, is.readInt());
+ case NBTConstants.TYPE_LONG:
+ return new LongTag(name, is.readLong());
+ case NBTConstants.TYPE_FLOAT:
+ return new FloatTag(name, is.readFloat());
+ case NBTConstants.TYPE_DOUBLE:
+ return new DoubleTag(name, is.readDouble());
+ case NBTConstants.TYPE_BYTE_ARRAY:
+ int length = is.readInt();
+ byte[] bytes = new byte[length];
+ is.readFully(bytes);
+ return new ByteArrayTag(name, bytes);
+ case NBTConstants.TYPE_STRING:
+ length = is.readShort();
+ bytes = new byte[length];
+ is.readFully(bytes);
+ return new StringTag(name, new String(bytes, NBTConstants.CHARSET));
+ case NBTConstants.TYPE_LIST:
+ int childType = is.readByte();
+ length = is.readInt();
+
+ List
+ * This class writes NBT, or
+ * Named Binary Tag Tag
objects to an underlying OutputStream
.
+ * The NBT format was created by Markus Persson, and the specification may be found at + * http://www.minecraft.net/docs/NBT.txt.
+ * + * @author Graham Edgecombe + */ +@SuppressWarnings({"EmptyMethod", "JavaDoc"}) +public final class NBTOutputStream implements Closeable { + + /** + * The output stream. + */ + private final DataOutputStream os; + + /** + * Create a newNBTOutputStream
, which will write data to the specified underlying output stream.
+ *
+ * @param os The output stream
+ */
+ public NBTOutputStream(DataOutputStream os) {
+ this.os = os;
+ }
+
+ /**
+ * Creates a new NBTOutputStream
, which will write data to the specified underlying output stream.
+ * the stream will be compressed using GZIP.
+ *
+ * @param os The output stream.
+ * @throws IOException if an I/O error occurs.
+ */
+ public NBTOutputStream(OutputStream os) throws IOException {
+ this.os = new DataOutputStream(new GZIPOutputStream(os));
+ }
+
+ /**
+ * Writes a tag.
+ *
+ * @param tag The tag to write.
+ * @throws IOException if an I/O error occurs.
+ */
+ public void writeTag(Tag tag) throws IOException {
+ int type = NBTUtils.getTypeCode(tag.getClass());
+ String name = tag.getName();
+ byte[] nameBytes = name.getBytes(NBTConstants.CHARSET);
+
+ os.writeByte(type);
+ os.writeShort(nameBytes.length);
+ os.write(nameBytes);
+
+ if (type == NBTConstants.TYPE_END) {
+ throw new IOException("Named TAG_End not permitted.");
+ }
+
+ writeTagPayload(tag);
+ }
+
+ /**
+ * Writes tag payload.
+ *
+ * @param tag The tag.
+ * @throws IOException if an I/O error occurs.
+ */
+ private void writeTagPayload(Tag tag) throws IOException {
+ int type = NBTUtils.getTypeCode(tag.getClass());
+ switch (type) {
+ case NBTConstants.TYPE_END -> writeEndTagPayload((EndTag) tag);
+ case NBTConstants.TYPE_BYTE -> writeByteTagPayload((ByteTag) tag);
+ case NBTConstants.TYPE_SHORT -> writeShortTagPayload((ShortTag) tag);
+ case NBTConstants.TYPE_INT -> writeIntTagPayload((IntTag) tag);
+ case NBTConstants.TYPE_LONG -> writeLongTagPayload((LongTag) tag);
+ case NBTConstants.TYPE_FLOAT -> writeFloatTagPayload((FloatTag) tag);
+ case NBTConstants.TYPE_DOUBLE -> writeDoubleTagPayload((DoubleTag) tag);
+ case NBTConstants.TYPE_BYTE_ARRAY -> writeByteArrayTagPayload((ByteArrayTag) tag);
+ case NBTConstants.TYPE_STRING -> writeStringTagPayload((StringTag) tag);
+ case NBTConstants.TYPE_LIST -> writeListTagPayload((ListTag) tag);
+ case NBTConstants.TYPE_COMPOUND -> writeCompoundTagPayload((CompoundTag) tag);
+ case NBTConstants.TYPE_INT_ARRAY -> writeIntArrayTagPayload((IntArrayTag) tag);
+ default -> throw new IOException("Invalid tag type: " + type + ".");
+ }
+ }
+
+ /**
+ * Writes a TAG_Byte
tag.
+ *
+ * @param tag The tag.
+ * @throws IOException if an I/O error occurs.
+ */
+ private void writeByteTagPayload(ByteTag tag) throws IOException {
+ os.writeByte(tag.getValue());
+ }
+
+ /**
+ * Writes a TAG_Byte_Array
tag.
+ *
+ * @param tag The tag.
+ * @throws IOException if an I/O error occurs.
+ */
+ private void writeByteArrayTagPayload(ByteArrayTag tag) throws IOException {
+ byte[] bytes = tag.getValue();
+ os.writeInt(bytes.length);
+ os.write(bytes);
+ }
+
+
+ /**
+ * Writes a TAG_Compound
tag.
+ *
+ * @param tag The tag.
+ * @throws IOException if an I/O error occurs.
+ */
+ private void writeCompoundTagPayload(CompoundTag tag) throws IOException {
+ for (Tag childTag : tag.getValue().values()) {
+ writeTag(childTag);
+ }
+ os.writeByte((byte) 0); // end tag - better way?
+ }
+
+ /**
+ * Writes a TAG_List
tag.
+ *
+ * @param tag The tag.
+ * @throws IOException if an I/O error occurs.
+ */
+ private void writeListTagPayload(ListTag tag) throws IOException {
+ Class extends Tag> clazz = tag.getType();
+ ListTAG_String
tag.
+ *
+ * @param tag The tag.
+ * @throws IOException if an I/O error occurs.
+ */
+ private void writeStringTagPayload(StringTag tag) throws IOException {
+ byte[] bytes = tag.getValue().getBytes(NBTConstants.CHARSET);
+ os.writeShort(bytes.length);
+ os.write(bytes);
+ }
+
+ /**
+ * Writes a TAG_Double
tag.
+ *
+ * @param tag The tag.
+ * @throws IOException if an I/O error occurs.
+ */
+ private void writeDoubleTagPayload(DoubleTag tag) throws IOException {
+ os.writeDouble(tag.getValue());
+ }
+
+ /**
+ * Writes a TAG_Float
tag.
+ *
+ * @param tag The tag.
+ * @throws IOException if an I/O error occurs.
+ */
+ private void writeFloatTagPayload(FloatTag tag) throws IOException {
+ os.writeFloat(tag.getValue());
+ }
+
+ /**
+ * Writes a TAG_Long
tag.
+ *
+ * @param tag The tag.
+ * @throws IOException if an I/O error occurs.
+ */
+ private void writeLongTagPayload(LongTag tag) throws IOException {
+ os.writeLong(tag.getValue());
+ }
+
+ /**
+ * Writes a TAG_Int
tag.
+ *
+ * @param tag The tag.
+ * @throws IOException if an I/O error occurs.
+ */
+ private void writeIntTagPayload(IntTag tag) throws IOException {
+ os.writeInt(tag.getValue());
+ }
+
+ /**
+ * Writes a TAG_Short
tag.
+ *
+ * @param tag The tag.
+ * @throws IOException if an I/O error occurs.
+ */
+ private void writeShortTagPayload(ShortTag tag) throws IOException {
+ os.writeShort(tag.getValue());
+ }
+
+ /**
+ * Writes a TAG_Empty
tag.
+ *
+ * @param tag The tag.
+ * @throws IOException if an I/O error occurs.
+ */
+ private void writeEndTagPayload(EndTag tag) {
+ /* empty */
+ }
+
+ /**
+ * Writes a TAG_Int_Array
tag.
+ *
+ * @param tag The tag.
+ * @throws IOException if an I/O error occurs.
+ */
+ private void writeIntArrayTagPayload(IntArrayTag tag) throws IOException {
+ final int[] values = tag.getValue();
+ os.writeInt(values.length);
+ for (final int value : values) {
+ os.writeInt(value);
+ }
+ }
+
+ @Override
+ public void close() throws IOException {
+ os.close();
+ }
+
+}
diff --git a/src/main/java/com/volmit/iris/util/oldnbt/NBTUtils.java b/src/main/java/com/volmit/iris/util/oldnbt/NBTUtils.java
new file mode 100644
index 000000000..3062584a7
--- /dev/null
+++ b/src/main/java/com/volmit/iris/util/oldnbt/NBTUtils.java
@@ -0,0 +1,137 @@
+/*
+ * Iris is a World Generator for Minecraft Bukkit Servers
+ * Copyright (c) 2021 Arcane Arts (Volmit Software)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see TAG_Short
tag.
+ *
+ * @author Graham Edgecombe
+ */
+public final class ShortTag extends Tag {
+
+ /**
+ * The value.
+ */
+ private final short value;
+
+ /**
+ * Creates the tag.
+ *
+ * @param name The name.
+ * @param value The value.
+ */
+ public ShortTag(String name, short value) {
+ super(name);
+ this.value = value;
+ }
+
+ @Override
+ public Short getValue() {
+ return value;
+ }
+
+ @Override
+ public String toString() {
+ String name = getName();
+ String append = "";
+ if (name != null && !name.equals("")) {
+ append = "(\"" + this.getName() + "\")";
+ }
+ return "TAG_Short" + append + ": " + value;
+ }
+
+}
diff --git a/src/main/java/com/volmit/iris/util/oldnbt/StringTag.java b/src/main/java/com/volmit/iris/util/oldnbt/StringTag.java
new file mode 100644
index 000000000..54ddce7da
--- /dev/null
+++ b/src/main/java/com/volmit/iris/util/oldnbt/StringTag.java
@@ -0,0 +1,59 @@
+/*
+ * Iris is a World Generator for Minecraft Bukkit Servers
+ * Copyright (c) 2021 Arcane Arts (Volmit Software)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see TAG_String
tag.
+ *
+ * @author Graham Edgecombe
+ */
+public final class StringTag extends Tag {
+
+ /**
+ * The value.
+ */
+ private final String value;
+
+ /**
+ * Creates the tag.
+ *
+ * @param name The name.
+ * @param value The value.
+ */
+ public StringTag(String name, String value) {
+ super(name);
+ this.value = value;
+ }
+
+ @Override
+ public String getValue() {
+ return value;
+ }
+
+ @Override
+ public String toString() {
+ String name = getName();
+ String append = "";
+ if (name != null && !name.equals("")) {
+ append = "(\"" + this.getName() + "\")";
+ }
+ return "TAG_String" + append + ": " + value;
+ }
+
+}
diff --git a/src/main/java/com/volmit/iris/util/oldnbt/Tag.java b/src/main/java/com/volmit/iris/util/oldnbt/Tag.java
new file mode 100644
index 000000000..d5fdac4ab
--- /dev/null
+++ b/src/main/java/com/volmit/iris/util/oldnbt/Tag.java
@@ -0,0 +1,58 @@
+/*
+ * Iris is a World Generator for Minecraft Bukkit Servers
+ * Copyright (c) 2021 Arcane Arts (Volmit Software)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see