4

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 Sep 5 at 6:19
  • What do you mean with "they end up killing you even if you're safe"? – Joachim Sep 5 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 Sep 5 at 14:25
  • Try checking if there is no block above a player. – iDoProgramming Sep 10 at 4:24
9

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, …

0

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

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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