Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-229209

Loot table function set_count doesn't work with unstackable items anymore

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • None
    • 1.17, 1.17.1, 1.19.3, 1.20.2
    • None
    • Confirmed
    • Loot tables

      Issue

      After updating to 1.17 I discovered that the set_count function for a loot table only outputs a single item to the player when it had previously given the intended amount throughout the 1.16 releases. Note this applies to all count settings including exact, range, and binomial. The error only applies to unstackable items such as saddles and minecarts, in 1.16 multiple slots would be filled with a single unstackable item but now there is only one.

      Recreate

      Recreating this issue is simple and all you have to do is create a loot table with one roll that uses a function to set the count of an item. To assist with this report I have attached raw code, screenshots showing the transition between versions, and a map in 1.16.5 that contains all of the necessary loot tables.

      Code 1: set_count exact (format 2)

      {
        "type": "minecraft:entity",
        "pools": [
          {
            "rolls": 1,
            "entries": [
              {
                "type": "item",
                "weight": 1,
                "name": "minecraft:saddle",
                "functions": [
                  {
                    "function": "set_count",
                    "count": 2
                  },
                  {
                    "function": "set_nbt",
                    "tag": "{CustomModelData:7}"
                  },
                  {
                    "function": "set_name",
                    "name": [
                      {
                        "text": "Exact Format 2",
                        "color": "white",
                        "bold": "true"
                      }
                    ]
                  }
                ]
              }
            ]
          }
        ]
      }
      

      Code 2: set_count range

      {
        "type": "minecraft:entity",
        "pools": [
          {
            "rolls": 1,
            "entries": [
              {
                "type": "minecraft:item",
                "name": "minecraft:saddle",
                "functions": [
                  {
                    "function": "minecraft:set_count",
                    "count": {
                      "min": 2,
                      "max": 4
                    }
                  },
                  {
                    "function": "minecraft:set_nbt",
                    "tag": "{CustomModelData:7}"
                  },
                  {
                    "function": "minecraft:set_name",
                    "name": [
                      {
                        "text": "Range",
                        "color": "white",
                        "bold": true
                      }
                    ]
                  }
                ]
              }
            ]
          }
        ]
      }
      

       Code 3: set_count binomial

      {
        "type": "minecraft:entity",
        "pools": [
          {
            "rolls": 1,
            "entries": [
              {
                "type": "minecraft:item",
                "name": "minecraft:saddle",
                "functions": [
                  {
                    "function": "minecraft:set_count",
                    "count": {
                      "type": "minecraft:binomial",
                      "n": 4,
                      "p": 1
                    }
                  },
                  {
                    "function": "minecraft:set_nbt",
                    "tag": "{CustomModelData:7}"
                  },
                  {
                    "function": "minecraft:set_name",
                    "name": [
                      {
                        "text": "Binomial",
                        "color": "white",
                        "bold": true
                      }
                    ]
                  }
                ]
              }
            ]
          }
        ]
      }
      

      Notes
      At first I thought it was because of the format I used to compress NBT data into one line. However, after changing the format I realized that this has no effect.

      Code 4: Compressed NBT (format 1)

      {
        "function": "minecraft:set_nbt","tag": "{display:{Name:'{\"text\":\"Exact Format 1\",\"color\":\"white\",\"bold\":true}'},CustomModelData:7}"
      }
      

      Code 5: Simplified NBT (format 2)

      "functions": [
                  {
                    "function": "set_count",
                    "count": 2
                  },
                  {
                    "function": "set_nbt",
                    "tag": "{CustomModelData:7}"
                  },
                  {
                    "function": "set_name",
                    "name": [
                      {
                        "text": "Exact Format 2",
                        "color": "white",
                        "bold": "true"
                      }
                    ]
                  }
      

        1. Exact1-Before.png
          Exact1-Before.png
          100 kB
        2. Exact1-After.png
          Exact1-After.png
          99 kB
        3. Loot-Table-Bug.zip
          121 kB
        4. Binomial-Before.png
          Binomial-Before.png
          103 kB
        5. Binomial-After.png
          Binomial-After.png
          102 kB
        6. Range-After.png
          Range-After.png
          107 kB
        7. Range-Before.png
          Range-Before.png
          107 kB

            Unassigned Unassigned
            BlackeyeI Samuel Robinson
            Votes:
            6 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              CHK: