So, I want to make a command block module (what it's about isn't important). So I need to execute, and to test this I want to kill all villagers standing on bedrock. What I currently have is this:
execute at @e[type=minecraft:villager] if block ~ ~-1 ~ minecraft:bedrock run kill @e[type=villager,limit=1]
However, this kills each villager until the one on bedrock is killed.
So I changed it:
execute at @e[type=minecraft:villager] if block ~ ~-1 ~ minecraft:bedrock run kill @e[type=villager,limit=1,distance=1]
But that does NOTHING at all.
So can somebody please help me by telling me what I'm doing wrong? I want the villager on bedrock to die, and ONLY the villager on bedrock.
(Note: everything with 'as' instead of 'at' that I've tried does nothing at all)
The reason why yours doent work because what you detected is not related to what you killed. In another words, you let the command block find a nearly random villager's location to see if he stand on bedrock, if success, the command block is trying to again find a nearly random villager to kill.
execute as @e[type=minecraft:villager] at @s if block ~ ~-0.1 ~ minecraft:bedrock run kill @s
This will let all the villager become the executor, at their own position, if bedrock is below, kill the entity who is executing this command.
Also, distance=1 hardly find anything, it means those who are exactly 1 block away to the location. And it should be distance=..1
You said that you tried as and at but does nothing, I assume that you tried both /execute as and /execute at, except /execute as at, which is what you have not try....
No...not the -0.1, it is the use of both as and at together, and the @s at the end...
-0.1 is my own habit, so it wouldn't detect when an entity is standing on 2 layers snow, bottom half slab... and change it to 0.05 affect carpet.
So, I want to make a command block module (what it's about isn't important). So I need to execute, and to test this I want to kill all villagers standing on bedrock. What I currently have is this:
execute at @e[type=minecraft:villager] if block ~ ~-1 ~ minecraft:bedrock run kill @e[type=villager,limit=1]
However, this kills each villager until the one on bedrock is killed.
So I changed it:
execute at @e[type=minecraft:villager] if block ~ ~-1 ~ minecraft:bedrock run kill @e[type=villager,limit=1,distance=1]
But that does NOTHING at all.
So can somebody please help me by telling me what I'm doing wrong? I want the villager on bedrock to die, and ONLY the villager on bedrock.
(Note: everything with 'as' instead of 'at' that I've tried does nothing at all)
e
The reason why yours doent work because what you detected is not related to what you killed. In another words, you let the command block find a nearly random villager's location to see if he stand on bedrock, if success, the command block is trying to again find a nearly random villager to kill.
It works perfectly. Thank you. (It must've been the -0.1 that did it, because I tried killing @s with -1)
e