/execute at @e[type=minecart] run execute if entity @e[type=player,distance=..0.5] run say Minecart !
works perfectly in 1.14.4 as well. I used this to kill creepers that get too close to a player while traveling on a rail...so annoying when they blow up the rail!
/execute at @e[type=minecart] run execute if entity @e[type=player,distance=..0.5] run kill @e[type=minecraft:creeper,distance=..5]
Looking now for a way to do that for all hostile mobs aside for creating a block for each one.
/execute at @e[type=minecart] run execute if entity @e[type=player,distance=..0.5] run say Minecart !
works perfectly in 1.14.4 as well. I used this to kill creepers that get too close to a player while traveling on a rail...so annoying when they blow up the rail!
/execute at @e[type=minecart] run execute if entity @e[type=player,distance=..0.5] run kill @e[type=minecraft:creeper,distance=..5]
Looking now for a way to do that for all hostile mobs aside for creating a block for each one.
Try:
/execute at @e[type=minecart] run execute if entity @e[type=player,distance=..0.5] run kill @e[type=!player,type=!armor_stand,type=!iron_golem,type=!item,type=!cat,type=!cow,type=!bat,type=!donkey,type=!fox,type=!dolphin,type=!llama,type=!trader_llama,type=!panda,type=!wolf,type=!polar_bear,type=!pufferfish,type=!rabbit,type=!parrot,type=!mule,type=!villager,type=!wandering_trader,type=!squid,type=!mooshroom,type=!cod,type=!salmon,type=!turtle,type=!pig,type=!chicken,type=!sheep,type=!horse,distance=..5]
How can I check if a player is inside a minecart via /execute ?
If you are playing on 1.13.2 you could try this:
/execute at @e[type=minecart] run execute if entity @e[type=player,distance=..0.5]
and then detect if that is true and power something else
example:
/execute at @e[type=minecart] run execute if entity @e[type=player,distance=..0.5] run say Minecart !
this will say Minecart ! when the previous command is true
use da cmd blox dud !
Lumpy668's command:
/execute at @e[type=minecart] run execute if entity @e[type=player,distance=..0.5] run say Minecart !
works perfectly in 1.14.4 as well. I used this to kill creepers that get too close to a player while traveling on a rail...so annoying when they blow up the rail!
/execute at @e[type=minecart] run execute if entity @e[type=player,distance=..0.5] run kill @e[type=minecraft:creeper,distance=..5]
Looking now for a way to do that for all hostile mobs aside for creating a block for each one.
Try:
/execute at @e[type=minecart] run execute if entity @e[type=player,distance=..0.5] run kill @e[type=!player,type=!armor_stand,type=!iron_golem,type=!item,type=!cat,type=!cow,type=!bat,type=!donkey,type=!fox,type=!dolphin,type=!llama,type=!trader_llama,type=!panda,type=!wolf,type=!polar_bear,type=!pufferfish,type=!rabbit,type=!parrot,type=!mule,type=!villager,type=!wandering_trader,type=!squid,type=!mooshroom,type=!cod,type=!salmon,type=!turtle,type=!pig,type=!chicken,type=!sheep,type=!horse,distance=..5]
Only one cmd block
/data get entity @s is very useful when you want to see the data available to you.
Command block engineer // Developer // #TeamTrees