What happens
Attempting to increment Statistic.USE_ITEM for Material.CARROTS (and other crop blocks) in 1.21.5 causes /save-all to fail (no error in console), and causes the next auto save to crash the server.
What I expect to happen
I expect either of these options:
- The behavior returns to silently failing without errors or crashing like in 1.21.4
- The server throws a useful stacktrace immediately when trying to increment a stat for Materials that aren't supposed to have that stat.
Workarounds
- Attempt to figure out what plugin is causing it, then fix the plugin by using a 'valid' Material.
- Disable statistic saving in spigot.yml by setting stats.disable-saving to true.
Example plugin (TestStatisticCrash.jar)
This line is the cause of the crash:
event.getPlayer().incrementStatistic(Statistic.USE_ITEM, Material.CARROTS);
Step-by-step instructions{}
- Create a new 1.21.5 spigot server (do not use an old world)
- Add the test plugin to the plugins folder
- Start the server
- Join the server with your game client
- Run save-all in the console to verify that it works (or op yourself and run /save-all in game)
- Left-click to punch any block near your player (you'll see text in the chat when you do)
- Run save-all again (it should still say that it "Saved the game")
- Right-click any block near your player (you'll see text in the chat when you do)
- Notice that the text says CARROTS with an S this time instead of CARROT (CARROT is the item in your inventory, and CARROTS is the crop block. The game uses CARROT when you plant carrots normally)
- Run save-all again (it will say "An unexpected error occurred trying to execute that command")
- Wait a few minutes for the server to run an auto save (or have your player log off). The server will crash with the error java.lang.IllegalStateException: Unregistered holder in ResourceKey[minecraft:root / minecraft:item]: Direct{null}
(All of the save-all steps are optional and they don't affect whether or not the server crashes.)
Server log: 2025-04-03-1.log
Crash log: crash-2025-04-03_22.11.07-server.txt
Video showing that 1.21.5 has the issue and 1.21.4 doesn't: spigot_stat_test5.mp4
Extra notes:
- I have no idea how this would be tested in vanilla.
- I didn't test non-crop materials.
- Using a 1.21.4 world on a 1.21.5 server doesn't seem to have this issue.
- The text in the test plugin was slightly modified after the video was recorded.
- You won't know exactly which action is triggering the crash during normal gameplay because it happens X minutes later during an auto save.
- The error text and crash log won't tell you which plugin caused the crash. The only clue to tracking it down is "ServerStatisticManager".