Reputation: 21
So i'm developing a datapack for Minecraft 1.15 and I want to add a feature where if a player puts a water bucket into their main-hand whilst inside the Nether, it'll "boil" and turn the water bucket into an empty bucket.
execute if entity @e[nbt={SelectedItem:{id:"minecraft:water_bucket"}}] in minecraft:the_nether run replaceitem entity @s weapon.mainhand minecraft:bucket 1
This is the command I am using, I've put it inside a function in the datapack that executes whatever is inside every tick, and I've also tried putting it inside a repeating command block. Neither of which works and I need to know why, and how to fix it!
Upvotes: 0
Views: 2370
Reputation: 121
The command doesn't work because "@s" is not referred to as the player. Try changing it to this:
execute as @e[nbt={SelectedItem:{id:"minecraft:water_bucket"}}] in minecraft:the_nether run replaceitem entity @s weapon.mainhand minecraft:bucket 1
The "as" will make the command refer to the selector @e[nbt={SelectedItem:{id:"minecraft:water_bucket"}}]
Upvotes: 1