Take damage at night time in the overworld unless in the nether

I'm trying to sort out a command which forces players to return to the nether after night comes in the overword.

For example, at night all players in the overworld will be struck with the hunger effect. once they've returned to the nether, they will be cleared of the effect.


you can use the output of a daylight detector to determine if it is nighttime. Connecting the redstone to a commandblock, which is set to "needs redstone" and "repeat". This creats a commandblock that executes the same command over and over at night.

with the command:

/effect @a[nbt={Dimension:1}] minecraft:hunger 2 2

this will cause everyone to get the hunger debuff as long as they don't return to the nether

NOTE: If you want this to work all the time you need to place this in the spawn chunk


First of all you'd want to set up a scoreboard to hold the time of day:

/scoreboard objectives add time dummy

Then you'd want to have each player store the time of day in the objective created previously:

(Repeating command): /execute as @a[nbt={Dimension:0}] store result score @s time run time query daytime

Then run your command to damage players:

(Repeating command): /effect give @a[scores={time=12000..24000},nbt={Dimension:0}] wither 1 1 true

Hope this helps.