mojira.dev
MC-124497

CanPlaceOn inconsistencies involving looking at blocks

The bug

Use of items from offhand with uses (potions food bows etc..) require CanPlaceOn NBT tags to be useable whilst looking at blocks in adventure mode.
Additionally when these items have the required NBT to be use-able on, if being used from the offhand slot they also require an item in the players mainhand that also has the required CanPlaceOn NBT.
Despite 1.12 items with no NBT would always be useable despite their NBT in any case while in adventure mode.
The current functionality in the snapshots would also mean that CanPlaceOn is more akin to being CanUseOn rather than only handling placing which would still be inconsistent as you can use these items to interact with noteblocks chests and any other items still.
This could be a problem due to MC-116254.

How to reproduce

  1. Give yourself a standard item with a use that is not placing related, such as a golden apple or potion

    /give @s golden_apple
  2. Attempt to eat the apple while in adventure mode and looking at a block

  3. Now give yourself the same item but with CanPlaceOn NBT for the blocks you are looking at

    /give @s golden_apple{CanPlaceOn:["minecraft:stone"]}
  4. Note that you can now consume the apple while looking at the block

  5. Now place the apple in your offhand slot and place any item without a use into your mainhand, such as a stick or diamond

  6. Switching between mainhand and offhand note that you can only consume the apple while your mainhand is empty

  7. Now give yourself an item without a use with CanPlaceOn NBT for the blocks you are looking at

    /give @s stick{CanPlaceOn:["minecraft:stone"]}
  8. Note that you can again consume the apple with the new NBT'd stick in your mainhand

Additionally the same results will be return with other items that have right click uses when used in place of the stick in this example such as a bow, drinkable/throwable potion though in previous versions it would be expected that you would be using the mainhanded item initially anyway.

Linked issues

Comments 5

Is this an issue on 1.12.2?

no this has only been an issue in the snapshots as far back as 17w51a/b❓ as far as i know

Partwise duplicates MC-123366, please change this report to mention only that using the offhand item requires a mainhand item with CanPlaceOn.

This is partly fixed in 1.13-pre2. The only problem is that the outline of the block, you're looking at, doesn't appear.

I can't reproduce this – I'm able to eat the apple during all of the situations described in adventure mode.

Archee

Erik Broes

Confirmed

CanPlaceOn

Minecraft 18w03b

Retrieved