Vanilla Command Help (summon/execute)

  • Please make sure you are posting in the correct place. Server ads go here and modpack bugs go here

Flexico

Well-Known Member
Dec 15, 2012
328
39
53
2018-09-28_06.50.54.png
I'm posting this here because MC Forums are down and peeps here seem pretty smart, so here's hopin'~

My command block contraption is meant to allow players to drain their XP into bottles by throwing empty bottles onto an emerald block.

Repeating command block:
Code:
execute as @e[type=minecraft:item, nbt={Item:{id:"minecraft:glass_bottle"}}] run execute if block ~ ~-1 ~ minecraft:emerald_block run summon minecraft:item ~ ~1 ~ {id:"experience_bottle",Count:1b}
# If there's an empty bottle on top of an emerald block, spawn an experience bottle one block above it.

Then that is chained to:
Code:
execute as @e[type=minecraft:item, nbt={item:{id:"minecraft:experience_bottle"},Count:1b}] run xp add @p -7 points
# Drain 7 XP points from the nearest player
and
Code:
kill @e[type=minecraft:item, nbt={item:{id:"minecraft:glass_bottle"},Count:1b}]
# Delete the original empty bottle

I've tested each bit individually, and the only commands that seem to work are the one that subtracts the experience from the player, and the one that deletes the empty bottle. What am I doing wrong?
 
C

Citron

Guest
You need to run the command at the Empty_Bottle coordinate.

Code:
execute positioned X Y Z if block ~ ~-1 ~ minecraft:emerald_block run execute as @e[type=minecraft:item,nbt={Item:{id:"minecraft:glass_bottle"}}] run summon minecraft:item ~ ~1 ~ {id:"experience_bottle",Count:1b}
 

Flexico

Well-Known Member
Dec 15, 2012
328
39
53
I thought running "execute as" automatically ran from the target entity's position.