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

Loot tables do not allow setting the max_stack_size of an item to be less than its count

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • None
    • 1.21.3
    • None
    • Confirmed
    • Commands, Loot tables
    • Normal
    • Platform

      The item stacks used internally in the loot-tables allow users to specify their count greater than their max_stack_size. This is actually normal, because at the end of the loot-table execution, these "overstacked" items will be split into multiple item stacks to fit their max_stack_size. This behavior can be tested with this command.

      /loot give @s loot {pools:[{rolls:1,entries:[{type:item,name:snowball,functions:[{function:set_count,count:64}]}]}]} 

      You specified 64 as the number of snowballs, which is greater than the max_stack_size of 16 for snowballs, but it works fine, and you get 4 stacks of 16 snowballs.

       

      The problem is, this "overstacking" behavior does not seem to be supported when changing max_stack_size with set_components item modifier, and it fails to change its max_stack_size. Compared to the above, this seems unintentional.

      /loot give @s loot {pools:[{rolls:1,entries:[{type:item,name:snowball,functions:[{function:set_count,count:64},{function:set_components,components:{max_stack_size:32}}]}]}]} 

      You tried to change the max_stack_size to 32, but it didn't work, and you get 4 stacks of 16 snowballs again.

      Here's the error message from the log.

      Failed to apply component patch '{minecraft:max_stack_size=>32}' to item: 'Item stack with stack size of 64 was larger than maximum: 32' 

            Unassigned Unassigned
            Triton365 Triton365
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              CHK: