I'm trying to find a way to make it so when someone is outside during the day they get killed. I've searched for a long time and I've tried many different things, but they end up killing you even if you're safe.

  • 1
    Is this for an adventure map, or for a map that can be affected by the player to a huge degree (basically, will they be able to build their own house, or cover, or is it set for them?)
    – user232393
    Commented Sep 5, 2019 at 6:19
  • What do you mean with "they end up killing you even if you're safe"?
    – Joachim
    Commented Sep 5, 2019 at 14:22
  • So I would guess emulate the Zombie/Skeletons? If you stand somewhere where theres nothing over your head you die? (They do by catching fire, but I guess you could up the damage if you hook into some 'IsStandingInSun' function?)
    – Fredy31
    Commented Sep 5, 2019 at 14:25
  • Try checking if there is no block above a player.
    – fwoosh
    Commented Sep 10, 2019 at 4:24

4 Answers 4


It might seem like the best idea to use a daylight sensor for this, but that has lots of little problems, like being visible when placed at the player's location, potentially overwriting blocks (like grass), not being able to check its output level directly, …

Instead I would suggest simply checking for air in a column from the player's head to the build limit.

First make sure that you have a column of air at a known position, for example 0 0 (preferably in the spawn chunks):

/fill 0 0 0 0 255 0 air

Whenever you now want to check if everything above the player is air, you just need to compare with partially relative coordinates:

execute if blocks ~ ~ ~ ~ 255 ~ 0 ~ 0 all run <command>

The downside of this is that all blocks except air protect a player, including glass, buttons, signs, …


Well, the initial part is easy. You could hook up a daylight sensor with a command block, to trigger the command to deal damage by way of applying the "Instant_Damage" effect constantly, or kill them outright

/effect <player> minecraft:instant_damage

/kill @p 

Instant damage deals 3 damage each time it is applied, so it would require a clock setup.

However, I'm unaware of how you might need to go about checking for anyone who is "outside", beyond checking for players that are in an area that is of a certain light level, and you'd have to figure out what light level that is, as exposure to different light sources might throw this out a bit


I tihnk it would be best, if you would make a datapack for this. In a datapack you are able to have your own aliases, so you
are able to make one like 'not_protect', and then check if the area '~ ~2 ~ ~ 255 ~' contains something other than specified in your alias,
and then,at least, run your command.

Hope that this is what you've looked for.


Here's a proof of concept for a very lightweight solution. You need a marker entity, summoned as:

/summon minecraft:armor_stand -114.60 90.00 221.33 {Marker: 1b, Invulnerable: 1b, Invisible: 1b, Tags: ["sun-burner"]}

Then you need a repeating command block and two chained command blocks, which contain in order:

execute as @e[tag = sun-burner] at @p run spreadplayers ~ ~ 0 1 false @s
execute at @e[tag = sun-burner] run effect give @p[distance = ..1] minecraft:wither 5 1 true
# Just for fluff
execute at @e[tag = sun-burner] at @p[distance = ..1] run particle minecraft:flame ~ ~1 ~ 0.5 1 0.5 0.1 32 normal

This uses spreadplayers to teleport the marker to the surface at the position of the player, then checks whether it reached the player (i.e, the player is also on the surface). In that case case, the player gets withered.

Notes & caveats:

  • This works only for a single player. For multiple players, the best solution is probably to put the spreadplayers + detection code in a single function, and running the function as @a.

  • This won't reliably target players standing in water (not sure why it does work sometimes, but that could be a feature for you) or in lava (but I guess they'd have bigger fish to fry).

  • This won't target players in the air, which could be an issue.

  • The effect currently reaches one block into overhangs. You can remove this "bleeding" by changing the second command to read @p[distance = ..0.5], but I found it cool.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .