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

    Details

    • Type: Bug
    • Status: Open
    • Resolution: Unresolved
    • Affects Version/s: 1.17, 1.17.1
    • Fix Version/s: None
    • Labels:
      None
    • Environment:
      Windows 8.1, 4GB Ram, 64-bit OS, x64-based processor, Java 8 Update 291.
    • Confirmation Status:
      Confirmed
    • Category:
      (Unassigned)

      Description

      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"
                      }
                    ]
                  }
      

        Attachments

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

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              BlackeyeI Samuel Robinson
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                CHK: