mojira.dev
MC-206118

"type" in loot table number providers is not optional anymore

The bug

Before 20w46a, when "type" was not specified, it would default to "minecraft:uniform", now it throws an error which breaks existing loot tables.

How to reproduce

  1. Add this loot table to a data pack

    {
      "pools": [
        {
          "rolls": {
            "min": 1,
            "max": 4
          },
          "entries": []
        }
      ]
    }
  2. Reload

  3. You get the following error in the output log

    Couldn't parse loot table test:uniform
    com.google.gson.JsonSyntaxException: Missing type, expected to find a string
    	at afm.h(SourceFile:111)
    	at dbh$c.deserialize(SourceFile:76)
    	at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:69)
    	at com.google.gson.Gson.fromJson(Gson.java:887)
    	at com.google.gson.Gson.fromJson(Gson.java:952)
    	...

Original description

Loot tables that have worked for a few major versions (1.12 and before) now are incompatible across the board (as far as I can tell...feel free to comment with any exceptions).

 

According to user @unknown on another similar but not quite the same bug report:

Datapack coder here, I'm having the same validation errors with the parser for loot tables compatible in 20w45a and prior but incompatible with 20w46a, and the issue seems to be that the "set_count" function expects an "add" parameter instead of defaulting to "false", which invalidates most datapack loot tabes. Is this intended behaviour or will this be looked at to allow for backwards compatibility?

Update: I'd like to correct myself! The problem isn't the "add" parameter, but rather that distributions require a specified "type" (like "type": "minecraft:uniform"), whilst previously this was only true for "set_count". In other words, "set_damage", "looting_enchant", etc. all have new requirements.

Nowhere in the changelog does it say that this was added. This took a long time to figure out and even longer to fix my packs.

 

So is 1.17 intended to be incompatible with everything that came before in datapack history? Or is this a bug?

 

EDIT: to be clear, the behavior I was expecting was that if the new fields were left out the game would assume the defaults were the intended values. The changelog for 20w46a listed perfectly sensible default values for the new fields.

Linked issues

Attachments

Comments 6

It has been noted in several other reports that the way data packs work has changed with 1.17 and snapshots.

You probably need to visit the support forums for further information.

 

What I really want to know is if it's intended and will stay this way or if it's a bug and will be fixed in a later update.

 

EDIT: also sorry to see bug reporting will be shutting down due to microsoft's new rules (because finding a bug is technically "exploiting" (can't prove if you knew ahead of time that bug was there) and will now result in your account being taken away). It was nice while it lasted but I guess Mojang are going to have to be the only bugtesters from now on.

Please include an example loot table that breaks between 1.16.4 and 20w46a

Attached "squid" loot table. Only change is that they always drop 1 cod in addition to the normal drops.

This works for any random number distribution within loot tables; 

Prior to 20w46a, the only distribution that was always specified was "set_count" as "type":"uniform". Everything else seemed to default to uniform when unspecified.

Post 20w46a, it seems like loot tables distributions no longer have a specified type, making the JSON parser detect an error for missing type parameter. This means that for "rolls" amount, for the "set_damage" function and probably a few others, if you don't specify a type it will no longer default to "type":"uniform".

So the problem is only unidirectional; loot tables written prior to 20w46a don't work in the latest snapshot, but with some testing, 20w46a loot tables work in previous versions. The main issue I guess is that old datapacks using loot tables will no longer be compatible with 1.17. 

Note that this problem isn't solved by Misode's generator yet (at least to my knowledge!)

Let me know if you guys need more details. I'll attach an example of the before/after from fixing a chest loot table for the Pillager Outpost I'd written where the "set_damage" function caused an error when updating: 

Before:

[media]



After:

[media]

Tokes

boq

Confirmed

Important

Commands, Data Packs

data-pack, loot-table

20w46a, 20w48a, 20w49a, 20w51a

21w03a

Retrieved