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

Give comand item duplication

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • None
    • 1.18.1, 22w03a
    • None
    • openjdk version "17.0.1" 2021-10-19
      OpenJDK Runtime Environment Temurin-17.0.1+12 (build 17.0.1+12)
      OpenJDK 64-Bit Server VM Temurin-17.0.1+12 (build 17.0.1+12, mixed mode, sharing)
    • Unconfirmed
    • (Unassigned)

      Description

      When executing the /give command, players that are standing inside of a hopper minecart will not only get the item added to their inventory, it will also appear inside of the hopper.

      Reproduction steps

      • Connect to a vanilla server or open a singleplayer world.
      • Place a single rail with a hopper minecart on top, surrounded by blocks so the minecart can't drive away.
      • Stand inside of the minecart and run /give.

      An unlisted YouTube video executing these steps can be found here: https://youtu.be/wXnugysvc3c

      Code analysis

      In the GiveCommand#giveItem method, a fake item is created, that is set to have an infinite pickup delay and is scheduled to despawn in the next tick (since the age is set to 5999). Since the minecart will be ticked before the itemstack, it will be able to pick it up, right before it is supposed to despawn.

            Unassigned Unassigned
            NoahvdAa Noah van der Aa
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: