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

Piglins will pick up all items from dropped stacks of Gold Nuggets if item is under "piglin_loved" item tag

XMLWordPrintable

    • Community Consensus
    • Items, Mob behaviour

      The bug

      If Gold Nuggets are included under the #piglin_loved item tag and then a stack of them is dropped near a Piglin, it will pick up all items from the stack instead of picking up only one of them. This is inconsistent with other items when included in the item tag since it will pick up only one of them when in a stack.

      The bug is caused by the fix of MC-187592.

      How to reproduce

      1. Download and then install the data pack below for easier reproduction.
      2. Spawn a Piglin, and then drop a stack of Gold Ingots or Netherite Ingots near it.
        The Piglin picks up only one item in the stack.
      3. Drop a stack of Gold Nuggets near the same mob.
        The Piglin picks up all items in the stack.

      Code analysis

      The code below is based on a 1.16 Pre-release 3 mapping provided by Yarn from FabricMC.

      It is used to fix the mentioned bug and checks if the dropped item is a Gold Nugget:

      if (drop.getStack().getItem() == Items.GOLD_NUGGET) {
          piglin.sendPickup(drop, drop.getStack().getCount());
          itemStack2 = drop.getStack();
          drop.remove();
      } else {
          piglin.sendPickup(drop, 1);
          itemStack2 = method_24848(drop);
      }
      

      If it is a Gold Nugget, the Piglin will pick up all items from the stack due to the piglin.sendPickup(drop, drop.getStack().getCount()); method. Otherwise, it will pick up only one item from the stack due to the piglin.sendPickup(drop, 1); method.

            Unassigned Unassigned
            jirauser283547 user-a4a49 (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: