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

CanPlaceOn inconsistencies involving looking at blocks



    • Bug
    • Status: Resolved
    • Resolution: Awaiting Response
    • Minecraft 18w03b
    • None
    • Confirmed


      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.


        Issue Links



              grum [Mojang] Grum (Erik Broes)
              Archee Archee
              8 Vote for this issue
              5 Start watching this issue