diff --git a/src/main/java/com/flowpowered/nbt/ListTag.java b/src/main/java/com/flowpowered/nbt/ListTag.java index 97ba63e..43ca95a 100644 --- a/src/main/java/com/flowpowered/nbt/ListTag.java +++ b/src/main/java/com/flowpowered/nbt/ListTag.java @@ -34,7 +34,7 @@ public class ListTag> extends Tag> { /** * The type of entries within this list. */ - private final Class type; + private final TagType type; /** * The value. */ @@ -47,7 +47,7 @@ public class ListTag> extends Tag> { * @param type The type of item in the list. * @param value The value. */ - public ListTag(String name, Class type, List value) { + public ListTag(String name, TagType type, List value) { super(TagType.TAG_LIST, name); this.type = type; this.value = value; @@ -58,7 +58,7 @@ public ListTag(String name, Class type, List value) { * * @return The type of item in this list. */ - public Class getElementType() { + public TagType getElementType() { return type; } @@ -81,7 +81,7 @@ public String toString() { } StringBuilder bldr = new StringBuilder(); - bldr.append("TAG_List").append(append).append(": ").append(value.size()).append(" entries of type ").append(TagType.getByTagClass(type).getTypeName()).append("\r\n{\r\n"); + bldr.append("TAG_List").append(append).append(": ").append(value.size()).append(" entries of type ").append(type.getTypeName()).append("\r\n{\r\n"); for (Tag t : value) { bldr.append(" ").append(t.toString().replaceAll("\r\n", "\r\n ")).append("\r\n"); } diff --git a/src/main/java/com/flowpowered/nbt/regionfile/Chunk.java b/src/main/java/com/flowpowered/nbt/regionfile/Chunk.java index 5fa4800..edae2bc 100644 --- a/src/main/java/com/flowpowered/nbt/regionfile/Chunk.java +++ b/src/main/java/com/flowpowered/nbt/regionfile/Chunk.java @@ -15,6 +15,7 @@ import com.flowpowered.nbt.IntTag; import com.flowpowered.nbt.ListTag; import com.flowpowered.nbt.Tag; +import com.flowpowered.nbt.TagType; import com.flowpowered.nbt.stream.NBTInputStream; import com.flowpowered.nbt.stream.NBTOutputStream; @@ -267,7 +268,7 @@ public static void moveChunk(CompoundTag level, int sourceX, int sourceZ, int de /* Update entities */ for (CompoundTag entity : ((ListTag) value.get("Entities")).getValue()) { List pos = ((ListTag) entity.getValue().get("Pos")).getValue(); - entity.getValue().put(new ListTag<>("Pos", DoubleTag.class, + entity.getValue().put(new ListTag<>("Pos", TagType.TAG_DOUBLE, Arrays.asList( new DoubleTag(null, pos.get(0).getValue() + diffX), new DoubleTag(null, pos.get(1).getValue() + diffY), diff --git a/src/main/java/com/flowpowered/nbt/stream/NBTInputStream.java b/src/main/java/com/flowpowered/nbt/stream/NBTInputStream.java index b3754ad..90dac6c 100644 --- a/src/main/java/com/flowpowered/nbt/stream/NBTInputStream.java +++ b/src/main/java/com/flowpowered/nbt/stream/NBTInputStream.java @@ -225,7 +225,7 @@ private Tag readTagPayload(TagType type, String name, int depth) throws IOExcept tagList.add(tag); } - return new ListTag(name, clazz, tagList); + return new ListTag(name, childType, tagList); case TAG_COMPOUND: CompoundMap compoundTagList = new CompoundMap(); diff --git a/src/main/java/com/flowpowered/nbt/stream/NBTOutputStream.java b/src/main/java/com/flowpowered/nbt/stream/NBTOutputStream.java index c9e3523..79419f8 100644 --- a/src/main/java/com/flowpowered/nbt/stream/NBTOutputStream.java +++ b/src/main/java/com/flowpowered/nbt/stream/NBTOutputStream.java @@ -252,11 +252,10 @@ private void writeCompoundTagPayload(CompoundTag tag) throws IOException { */ @SuppressWarnings("unchecked") private void writeListTagPayload(ListTag tag) throws IOException { - Class> clazz = tag.getElementType(); List> tags = (List>) tag.getValue(); int size = tags.size(); - dataOut.writeByte(TagType.getByTagClass(clazz).getId()); + dataOut.writeByte(tag.getElementType().getId()); dataOut.writeInt(size); for (Tag tag1 : tags) { writeTagPayload(tag1);