2

I want to check what phase the moon is in, on any given night. I know that every 7 in-game days is a full cycle and the fuller the moon is the higher the difficulty of mobs and such. I'm working on a simple datapack that sometimes makes mobs spawn as stronger mobs, and thought it would be cool to have them spawn more often on nights with a full moon and not at all on new moon nights.

So TL;DR is basically: can I check what phase the moon is on with commands?

1 Answer 1

3

You will need a scoreboard objective. I called it 'testing' here:

/scoreboard objectives add testing dummy

Then whenever you want to check, run this command chain:

/execute store result score day testing run time query day
/scoreboard players set operator testing 8
/scoreboard players operation day testing %= operator testing

This will get the current day count (/time query day) and store it in a virtual player score day. Then it will get the 'modulus 8' of that number, which means it'll get the remainder when dividing the number by 8.

Doing this makes the day count loop from 0 -> 7. You can then do certain commands on certain 'weekdays' with the command /execute if score day testing matches <x> run <y> where x is the day and y is the command to be ran.

0 is a full moon, and 4 is a new moon.

0

You must log in to answer this question.

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