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
Give yourself a standard item with a use that is not placing related, such as a golden apple or potion
/give @s golden_apple
Attempt to eat the apple while in adventure mode and looking at a block
Now give yourself the same item but with
CanPlaceOn
NBT for the blocks you are looking at/give @s golden_apple{CanPlaceOn:["minecraft:stone"]}
Note that you can now consume the apple while looking at the block
Now place the apple in your offhand slot and place any item without a use into your mainhand, such as a stick or diamond
Switching between mainhand and offhand note that you can only consume the apple while your mainhand is empty
Now give yourself an item without a use with
CanPlaceOn
NBT for the blocks you are looking at/give @s stick{CanPlaceOn:["minecraft:stone"]}
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
relates to 1
Comments 5
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.
Is this an issue on 1.12.2?