Custom gamerule to apply a potion effect under certain circumstances? (night time, sees sky, in overworld)

Started by appycake on

Topic category: Help with MCreator software

Joined Mar 2026
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Custom gamerule to apply a potion effect under certain circumstances? (night time, sees sky, in overworld)

I wanted to make a game rule which when set to true checks if the player is in overworld, if its night time and if the player can see the sky. then it would apply a poison like potion effect that slowly kills the player but it doesnt apply the potion effect. pls help thanks.

Ive made a game rule which is boolean and true by default

Ive made an effect named "suffering under Bad light" with "On effect active tick" with No additional triggers that deals 1 damage to Event/target entity from source damage source of type: magic

Then ive made a script that triggers on player tick update (which ik might be laggy but couldnt find of a better solution):

If "get logic game rule " = true AND ID of dimension Event/target entity is in = surface AND Get current world time <1300 AND Get current world time >2300 AND can location at x y z see the sky

do add potion suffering under bad light with level 1 for 100 ticks to event/entity target.

My problems are that
1- When all conditions are met it doesnt apply the potion effect
2- Even if i give myself the effect it doesnt damage me

How could i fix these issues? also do you guys have any advice for optimisations? thanks. Ive tried to include as many images as possible for documentation and helping people who might need em in the future but couldnt because it said post was spam.

Joined Apr 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I'm not sure why it isn't…
Sat, 03/28/2026 - 13:43

I'm not sure why it isn't damaging you, but I think I can see why the potion effect isn't applying. It looks like you might have < and > swapped, so you are basically checking if the time is less than a smaller number and greater than a larger one, which will never be true.

However, world time also doesn't reset to 0 every day, I don't think, so it still might act funny unless you get into modulo (which isn't too hard, to be fair). However, there is an easier solution. There is a procedure block that checks if it is day, and you can pair that with a not block to check if it is night, it might not be exactly what you want, but it would likely be close for less effort.

Another thing, is that potion effects sometimes get weird if they are applied on client-side (by default they are applied on client-side and server-side, which can still cause some problems), but that can easily be fixed by checking if "Not" "Is provided world client-side".

I've also noticed that vanilla Minecraft damage-dealing potion effects don't deal damage if they are constantly re-applied. This might not be the same problem that is causing your potion effect to deal no damage, but if it is, it could be fixed by checking if the player doesn't already have the potion effect before applying it, that way it is only re-applied when it runs out.