mojira.dev
MC-173446

NBT to SNBT converter fails: "String index out of range: -4"

If the tutorial in the German Minecraft wiki is correct (the English one doesn't really have a tutorial, just a general description), then the data generator is broken.

I made a copy of "level.dat" named "level.nbt" and a copy of "r.-1.-1.mca" named "r.-1.-1.nbt", both result in the same error when I try to convert them:

[fabian@laptop Downloads]$ java -cp server.jar net.minecraft.data.Main --dev --input "/home/fabian/hdd/drive/minecraft/saves/test/level.nbt" --output "/home/fabian/Downloads/test"
[16:48:25] [main/INFO]: Starting provider: NBT to SNBT
Exception in thread "main" [16:48:25] [main/INFO]: [STDERR]: java.lang.StringIndexOutOfBoundsException: String index out of range: -4
[16:48:25] [main/INFO]: [STDERR]: 	at java.lang.String.substring(String.java:1967)
[16:48:25] [main/INFO]: [STDERR]: 	at ic.a(SourceFile:43)
[16:48:25] [main/INFO]: [STDERR]: 	at ic.a(SourceFile:32)
[16:48:25] [main/INFO]: [STDERR]: 	at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
[16:48:25] [main/INFO]: [STDERR]: 	at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
[16:48:25] [main/INFO]: [STDERR]: 	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
[16:48:25] [main/INFO]: [STDERR]: 	at java.util.Iterator.forEachRemaining(Iterator.java:116)
[16:48:25] [main/INFO]: [STDERR]: 	at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
[16:48:25] [main/INFO]: [STDERR]: 	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)
[16:48:25] [main/INFO]: [STDERR]: 	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
[16:48:25] [main/INFO]: [STDERR]: 	at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
[16:48:25] [main/INFO]: [STDERR]: 	at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
[16:48:25] [main/INFO]: [STDERR]: 	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
[16:48:25] [main/INFO]: [STDERR]: 	at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:485)
[16:48:25] [main/INFO]: [STDERR]: 	at ic.a(SourceFile:32)
[16:48:25] [main/INFO]: [STDERR]: 	at gy.c(SourceFile:48)
[16:48:25] [main/INFO]: [STDERR]: 	at net.minecraft.data.Main.main(SourceFile:55)
[fabian@laptop Downloads]$ java -cp server.jar net.minecraft.data.Main --dev --input "/home/fabian/hdd/drive/minecraft/saves/test/region/r.-1.-1.nbt" --output "/home/fabian/Downloads/test"
[16:49:41] [main/INFO]: Starting provider: NBT to SNBT
Exception in thread "main" [16:49:41] [main/INFO]: [STDERR]: java.lang.StringIndexOutOfBoundsException: String index out of range: -4
[16:49:41] [main/INFO]: [STDERR]: 	at java.lang.String.substring(String.java:1967)
[16:49:41] [main/INFO]: [STDERR]: 	at ic.a(SourceFile:43)
[16:49:41] [main/INFO]: [STDERR]: 	at ic.a(SourceFile:32)
[16:49:41] [main/INFO]: [STDERR]: 	at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
[16:49:41] [main/INFO]: [STDERR]: 	at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
[16:49:41] [main/INFO]: [STDERR]: 	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
[16:49:41] [main/INFO]: [STDERR]: 	at java.util.Iterator.forEachRemaining(Iterator.java:116)
[16:49:41] [main/INFO]: [STDERR]: 	at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
[16:49:41] [main/INFO]: [STDERR]: 	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)
[16:49:41] [main/INFO]: [STDERR]: 	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
[16:49:41] [main/INFO]: [STDERR]: 	at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
[16:49:41] [main/INFO]: [STDERR]: 	at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
[16:49:41] [main/INFO]: [STDERR]: 	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
[16:49:41] [main/INFO]: [STDERR]: 	at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:485)
[16:49:41] [main/INFO]: [STDERR]: 	at ic.a(SourceFile:32)
[16:49:41] [main/INFO]: [STDERR]: 	at gy.c(SourceFile:48)
[16:49:41] [main/INFO]: [STDERR]: 	at net.minecraft.data.Main.main(SourceFile:55)

Comments 9

What are the exact steps to reproduce this? In what way does this affect the game?

The steps to reproduce this are by having the server.jar in the current folder and running those example commands. It doesn't affect the regular Survival gameplay, but the data generator is supposedly another feature of the Minecraft server. Here is the tutorial in the wiki, if that helps you: https://minecraft.gamepedia.com/Tutorials/Running_the_Data_Generator

In case you're questioning whether data generator bugs are valid, look at MC-131740.

FYI it works if you make input a folder path, but this is probably an unhelpful error

Then I get "Not in GZIP format" for a renamed .mca file, that sounds promising at least…

When I manually pack it into a GZIP file (still named .nbt), I get "Root tag must be a named compound tag".

It does actually work with a renamed level.dat file, so thanks for that tip at least. But I wanted to look at a region file. Is that simply impossible or did I do something wrong again? The wiki claims that both just work, but apparently that's not true.

I'm having the same issue. I assume the data generator is intended for use by the user but it's incredibly poorly documented

 

Is this still an issue in 1.16.3?

FaRo1

(Unassigned)

Confirmed

(Unassigned)

1.15.2, 1.16.3

Retrieved