Inventory Slot Confusion
Apologies for creating a post so soon after resolving one, however I seem to have encountered an error(?) that no site or forum mentions.
I attempted to write a function that detects when an inventory slot has a specific item in it. The slot of my choosing was slot 17b--the far-most top right inventory slot. However, when attempting to detect it using
Continue to help postexecute as @a if items entity @s inventory.17
, the item was not located. Rather, execute as @a if items entity @s inventory.8
did find the item in slot 17b. Is there something I'm missing?
The entire item detection function (It removes a health modifier, then checks for the players top-right-most inventory slot(?) for a necklace and adds the modifier back when the necklace is present; called every frame):
execute as @a run attribute @s max_health modifier remove minecraft:amethyst_necklace` execute as @a if items entity @s inventory.8 minecraft:poisonous_potato[minecraft:custom_data~{isamethystnecklace:true}] run attribute @s max_health modifier add minecraft:amethyst_necklace .1 add_value
(The attached screenshot shows:
1. The inventory slot
2. The code detecting slot 17b and thereby giving the player an extra heart)