From 68c63d20ed59af9410900d45f96becdcf2ebe2ab Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Sat, 2 Oct 2021 11:27:18 +0200 Subject: [PATCH] Fix reading of explicit int array entries See https://github.com/KyoriPowered/adventure/pull/460 --- .../viaversion/api/minecraft/nbt/TagStringReader.java | 4 +++- .../java/com/viaversion/viaversion/common/nbt/NBTTagTest.java | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/nbt/TagStringReader.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/nbt/TagStringReader.java index 960c937c8..1195c44dd 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/nbt/TagStringReader.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/nbt/TagStringReader.java @@ -265,13 +265,15 @@ final class TagStringReader { Tag result = null; try { switch (Character.toLowerCase(current)) { // try to read and return as a number - // case Tokens.TYPE_INTEGER: // handled below, ints are ~special~ case Tokens.TYPE_BYTE: result = new ByteTag(Byte.parseByte(builder.toString())); break; case Tokens.TYPE_SHORT: result = new ShortTag(Short.parseShort(builder.toString())); break; + case Tokens.TYPE_INT: + result = new IntTag(Integer.parseInt(builder.toString())); + break; case Tokens.TYPE_LONG: result = new LongTag(Long.parseLong(builder.toString())); break; diff --git a/common/src/test/java/com/viaversion/viaversion/common/nbt/NBTTagTest.java b/common/src/test/java/com/viaversion/viaversion/common/nbt/NBTTagTest.java index 9b77ae69f..dc7f8b703 100644 --- a/common/src/test/java/com/viaversion/viaversion/common/nbt/NBTTagTest.java +++ b/common/src/test/java/com/viaversion/viaversion/common/nbt/NBTTagTest.java @@ -35,6 +35,7 @@ public class NBTTagTest { readString("{id:[I;1,2, 3, 4,5]}"); // >=1.11 readString("{id:1b,b:true}"); readString("{id:[L;1l,2L,3L]}"); // >=1.11 + readString("{id:[I;1i,2I,3I]}"); readString("{id:'minecraft:stone'}"); // >=1.13 readString("{id:1,id:2}"); readString("{id:-20b,test:3.19f}"); @@ -47,7 +48,6 @@ public class NBTTagTest { //TODO fix legacy < 1.12 // readString("{id:minecraft:stone}"); - // readString("{id:[I;1i,2I,3I]}"); // readString("{id:[1,2, 3, 4,5]}"); } }