Fix DataConverter ConverterParticleToNBT.parseProperties

- The old code was using `StringReader.peek()` in a place where it meant to be `StringReader.skip()`.
- The vanilla code allows a trailing comma, but only if there is no whitespace between it and the closing bracket, which is a bit weird. I think that's a bug and it shouldn't allow trailing commas, but if you disagree then only the first issue needs to be fixed.
This commit is contained in:
Joseph Burton 2024-05-10 00:31:58 -07:00
parent 79fcb6baf4
commit 67b30c5ed5

View file

@ -7970,27 +7970,29 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ reader.expect('[');
+ reader.skipWhitespace();
+
+ while (reader.canRead() && reader.peek() != ']') {
+ reader.skipWhitespace();
+
+ final String property = reader.readString();
+
+ reader.skipWhitespace();
+ reader.expect('=');
+ reader.skipWhitespace();
+
+ final String value = reader.readString();
+ ret.setString(property, value);
+
+ reader.skipWhitespace();
+ if (reader.canRead()) {
+ if (reader.peek() != ',') {
+ // invalid character or ']'
+ break;
+ if (reader.canRead() && reader.peek() != ']') {
+ while (reader.canRead()) {
+ final String property = reader.readString();
+
+ reader.skipWhitespace();
+ reader.expect('=');
+ reader.skipWhitespace();
+
+ final String value = reader.readString();
+ ret.setString(property, value);
+
+ reader.skipWhitespace();
+ if (reader.canRead()) {
+ if (reader.peek() != ',') {
+ // invalid character or ']'
+ break;
+ }
+
+ // skip ',' and move onto next entry
+ reader.skip();
+ }
+
+ // skip ',' and move onto next entry
+ reader.peek();
+
+ reader.skipWhitespace();
+ }
+ }
+