mirror of
https://github.com/ViaVersion/ViaNBT.git
synced 2024-11-14 10:15:40 +01:00
Ignore invalid list tag type if the ID is 0; this is written when the list is empty.
This commit is contained in:
parent
a2c24ac40f
commit
835829105e
@ -147,7 +147,7 @@ public class ListTag extends Tag implements Iterable<Tag> {
|
||||
int id = in.readUnsignedByte();
|
||||
this.type = TagRegistry.getClassFor(id);
|
||||
this.value = new ArrayList<Tag>();
|
||||
if(this.type == null) {
|
||||
if(id != 0 && this.type == null) {
|
||||
throw new IOException("Unknown tag ID in ListTag: " + id);
|
||||
}
|
||||
|
||||
@ -167,12 +167,17 @@ public class ListTag extends Tag implements Iterable<Tag> {
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream out) throws IOException {
|
||||
int id = TagRegistry.getIdFor(this.type);
|
||||
if(id == -1) {
|
||||
throw new IOException("ListTag contains unregistered tag class.");
|
||||
if(this.value.isEmpty()) {
|
||||
out.writeByte(0);
|
||||
} else {
|
||||
int id = TagRegistry.getIdFor(this.type);
|
||||
if(id == -1) {
|
||||
throw new IOException("ListTag contains unregistered tag class.");
|
||||
}
|
||||
|
||||
out.writeByte(id);
|
||||
}
|
||||
|
||||
out.writeByte(id);
|
||||
out.writeInt(this.value.size());
|
||||
for(Tag tag : this.value) {
|
||||
tag.write(out);
|
||||
|
Loading…
Reference in New Issue
Block a user