-1

The command should be simple but i can't figure it out basically i want it so that if a player is stanting under a block the command will not activate but if the player has only air blocks above him then the command would activate dealing him some poison damage.

0

3 Answers 3

2

If you don't want to download a data pack or something, you can just do this:
/execute as <your target> at @s if blocks ~ ~ ~ ~ ~128 ~ ~ ~3 ~ masked run effect give @s minecraft:poison <the time you want> <the strength you want>.

2

As of 2024 and accounting for the new build height, the command execute as @s at @s if blocks ~ ~ ~ ~ 319 ~ ~ ~3 ~ masked run seems to work great for me. However, the "masked" parameter only works for air blocks.

If any non-air block is above the entity's head, for example, a torch, this condition will return as false. I don't currently know how to get around this, but in the meantime, that command works great for me.

1

I wanted the same thing in the form of acid Rain, so a Made a Data Pack that detects if there are any blocks above your head.

Here's the Link

If you need help installing it, there are plenty of tutorials on Youtube.

Once you install it and open your minecraft world make sure to run a few commands or else it won't work

/reload

then

/function sky_test:setup

Then a message will pop up telling you how to activate it.

If you want to change the command that activates when there are no blocks above your head, then go into the Data Pack and find the tick.MCFUNCTION file, and open it. Once inside go all the way to the bottom, and under where it says #Output Command is the command you'd want to change. If you're gong to use a selector like @a, @e, or @p just make sure to put [scores={255=-1}] after it. Example: say hi @e[scores={255=-1}] Also, make sure not to use a / before the command, or it won't work.

Hope this Helps! :D

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.