mojira.dev
MC-99905

Villagers spawned with no buy option breaks NBT data. Entitydata commands targeting said villager prevents chunks from saving.

Basically all necessary info is given in the title. If you summon a villager with a broken/incomplete trade, then try to target it with an entitydata command, the console will output a warning, and eventually try to, and fail to save the chunk containing said villager.

Steps to replicate:

-Summon a villager with a trade that has no cost.
-Select that villager with an Entitydata command. Eg:

/entitydata @e[type=Villager] {Invulnerable:1}

Resulting console output should be as follows:

21.03 21:13:41 [Server] Server thread/WARN Couldn't process command: 'entitydata @e[type=Villager] {Invulnerable:1}'
21.03 21:13:42 [Server] INFO Negative index in crash report handler (0/23)
21.03 21:13:42 [Server] Server thread/ERROR Failed to save chunk
21.03 21:13:42 [Server] INFO e: Saving entity NBT
21.03 21:13:42 [Server] INFO at rr.e(SourceFile:1322) ~[minecraft_server.1.9.1-pre3.jar:?]
21.03 21:13:42 [Server] INFO at rr.d(SourceFile:1263) ~[minecraft_server.1.9.1-pre3.jar:?]
21.03 21:13:42 [Server] INFO at ass.a(SourceFile:216) ~[minecraft_server.1.9.1-pre3.jar:?]
21.03 21:13:42 [Server] INFO at ass.a(SourceFile:102) [minecraft_server.1.9.1-pre3.jar:?]
21.03 21:13:42 [Server] INFO at lo.b(SourceFile:147) [minecraft_server.1.9.1-pre3.jar:?]
21.03 21:13:42 [Server] INFO at lo.a(SourceFile:166) [minecraft_server.1.9.1-pre3.jar:?]
21.03 21:13:42 [Server] INFO at lp.a(SourceFile:883) [minecraft_server.1.9.1-pre3.jar:?]
21.03 21:13:42 [Server] INFO at ax.a(SourceFile:36) [minecraft_server.1.9.1-pre3.jar:?]
21.03 21:13:42 [Server] INFO at j.a(SourceFile:82) [minecraft_server.1.9.1-pre3.jar:?]
21.03 21:13:42 [Server] INFO at j.a(SourceFile:65) [minecraft_server.1.9.1-pre3.jar:?]
21.03 21:13:42 [Server] INFO at mb.d(SourceFile:830) [minecraft_server.1.9.1-pre3.jar:?]
21.03 21:13:42 [Server] INFO at mb.a(SourceFile:817) [minecraft_server.1.9.1-pre3.jar:?]
21.03 21:13:42 [Server] INFO at ij.a(SourceFile:37) [minecraft_server.1.9.1-pre3.jar:?]
21.03 21:13:42 [Server] INFO at ij.a(SourceFile:9) [minecraft_server.1.9.1-pre3.jar:?]
21.03 21:13:42 [Server] INFO at fh$1.run(SourceFile:13) [minecraft_server.1.9.1-pre3.jar:?]
21.03 21:13:42 [Server] INFO at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_72]
21.03 21:13:42 [Server] INFO at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_72]
21.03 21:13:42 [Server] INFO at g.a(SourceFile:45) [minecraft_server.1.9.1-pre3.jar:?]
21.03 21:13:42 [Server] INFO at net.minecraft.server.MinecraftServer.D(SourceFile:597) [minecraft_server.1.9.1-pre3.jar:?]
21.03 21:13:42 [Server] INFO at la.D(SourceFile:339) [minecraft_server.1.9.1-pre3.jar:?]
21.03 21:13:42 [Server] INFO at net.minecraft.server.MinecraftServer.C(SourceFile:553) [minecraft_server.1.9.1-pre3.jar:?]
21.03 21:13:42 [Server] INFO at net.minecraft.server.MinecraftServer.run(SourceFile:457) [minecraft_server.1.9.1-pre3.jar:?]
21.03 21:13:42 [Server] INFO at java.lang.Thread.run(Thread.java:745) [?:1.8.0_72]
21.03 21:13:42 [Server] INFO Caused by: java.lang.NullPointerException

Linked issues

Comments 5

Targeting villager with commands after summoning isn't necessary. The chunk will fail to save regardless.

I.. could make several points as to why an entity would need to be targeted after summoning. Besides, that's not the issue at hand. As for your latter point, that's purely just false. For many months, redundant and heavy handed as it may be, I nonetheless have had a repeating command block updating the entitydata of any villager on the server to invulnerable. It is only when one is summoned with the aforementioned broken trade that the command fails, and that specific chunk loses the ability to save.

/summon Villager ~ ~1 ~ {Offers:{Recipes:[{}]}}

Run that command, place a block next to the villager, exit the world, and re-enter; the block (and villager) is no longer there.

OH I think I see what you mean. Whoops. My apologies, I have not slept in some time. But yeah, as far as I know, that won't output anything until the chunk tries to save. I never realized it was an issue on my server until I noticed the console spam from my entitydata command. But yes, you are right, it's not necessary to be targeted I suppose. Still kind of a game breaking bug though. Reminds me of the invalid Json in signs bug from the snapshots.

Very likely relates to MC-18495

Edit: It is MC-18495

The following is based on decompiled version of Minecraft 1.9 using MCP 9.24 beta. All method and class names are the names used in the decompiled version.

The reason why this happens is because the method net.minecraft.village.MerchantRecipeList.readRecipiesFromTags(NBTTagCompound) creates invalid recipes. And then saving is MC-18495

Liam Scott

(Unassigned)

Community Consensus

Minecraft 1.9.1 Pre-Release 3

Retrieved