World Events
World events are the world-side counterpart of the entity/player events: instead of reacting to an entity action, they react to the world itself ticking, the weather changing, the day/night cycle, or a fixed interval elapsing. Everything stays 100% datapack-side - no in-world command blocks. Dynamic data is read with predicates and scoreboards, and where a value has to be read at runtime you should reach for macros rather than command blocks.
Like entity events, multiple handlers can be registered for the same event and they all fire together. Each event is backed by a function registered in the vanilla tick/load tag that dispatches to a per-event function tag.
The world handle
Register events on a world() handle. Pass a dimension to scope a handler so it runs with the execution context set to that dimension (execute in <dimension> run ...):
World event helpers only need a DataPack in scope, so you can register them straight in the datapack { } block, or inside a function { } when you want to mix them with other commands.
Available events
| Function | Trigger |
|---|---|
onDayStart |
The tick daytime enters 0..11999 (dawn) |
onInterval(period) |
Every period ticks (scoreboard counter, immune to a frozen daytime) |
onLoad |
Once on datapack load / /reload |
onMidnight |
The tick daytime reaches 18000 |
onNightStart |
The tick daytime enters 13000..23999 |
onNoon |
The tick daytime reaches 6000 |
onRainStart |
The tick precipitation starts (rain or thunder) |
onRainStop |
The tick precipitation stops |
onThunderStart |
The tick a thunderstorm starts |
onThunderStop |
The tick a thunderstorm stops |
onTick |
Every tick (20 times per second) |
onTimeOfDay(time) |
The tick daytime reaches time (0..23999) |
How edge events work
onRainStart, onThunderStart, onDayStart and friends are edge-triggered: they fire only on the single tick the condition flips, not every tick the condition is true. The dispatcher stores the current state into a kore_world scoreboard, compares it to the previous tick, runs the handlers on a transition, then saves the new state:
Because the previous state is unset on the first tick after a reload, edge events never fire spuriously on load.
onInterval instead keeps a counter on the same objective, so it stays accurate even when doDaylightCycle is off:
Notes
onRainStart/onRainStoptrack precipitation in general (a thunderstorm also counts as raining). Use the thunder events when you specifically care about storms.- Weather and time are global in vanilla; binding an event to a dimension changes where the handler runs, not which world's weather is read.
- The shared
kore_worldobjective is created once per datapack in the generatedkore_world_initload function. onNoonandonMidnightare thin wrappers overonTimeOfDay. UseonTimeOfDaydirectly for sunset (12000), sunrise (23000), or any custom moment. Moon-phase logic can be layered on top: react inonNightStart, then read the game time with a macro to compute(day % 8).
