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

"Pick Block" bind doesn't work on entities in survival mode, which isn't consistent with creative mode

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • None
    • 1.21.1
    • None
    • Unconfirmed
    • (Unassigned)

      When you click a block with the Pick Block keybind (middle mouse button by default)
      if you have the matching block in your inventory, you get the block in your currently active hotbar slot. and it doesn't check whether the player in creative or not.

      Issues arise when the player tries to pick an entity, such boat/minecart/armor stand/spawn egg/end crystal/item frame, etc.
      then it works only for for creative mode players, even if the survival mode player has the item necessary.

      it happens due to a what seems an accidental check for creative mode in the net.minecraft.client.MinecraftClient class, method doItemPick()

      for example, this is how the check is done for blocks:
      if (type == HitResult.Type.BLOCK)
      and this is how it's done for entities
      if (type != HitResult.Type.ENTITY || !bl)
      where bl is a boolean value that is only true when the player is in creative mode
      i also think it's worth noting that the code does a check for bl a little later on as well
      if (bl)
      in order to see if the player actually can pull the item out of their creative mode inventory
      so i find it really strange that it has to do one of these checks for entities specifically.

      in order to address this issue, all it takes is to just remove the second usage of bl after assignment and it works properly again

            Unassigned Unassigned
            Meowphedrone Meowphedrone
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: