Skip to content

Environment API

editorAPI.sky reference: time in ticks, moon phases, gamma, render distance, environment activation, and reading the current state.

editorAPI.sky controls the Minecraft sky and lighting in the editor. All methods are synchronous. Methods that change settings and refresh() return a state object; getMoonPhases() returns an array of strings. If the subsystem has not been created yet, methods return null, while getMoonPhases() returns an empty array. Call them after the interface is ready, as described in the plugin startup sequence.

Activation and refresh

editorAPI.sky.enable({ time: 6000, render: true });
editorAPI.sky.disable({ render: true });
editorAPI.sky.refresh({ render: true });

All options objects are optional. enable() enables the environment; the optional time sets the total time in ticks before activation. disable() removes the public API’s request to display the sky. Setting individual parameters does not enable the environment by itself.

render defaults to true. Only an explicit false disables immediate rendering. This is useful when changing several settings together:

editorAPI.sky.setDayTime(18000, { render: false });
editorAPI.sky.setMoonPhase('full_moon', { render: false });
editorAPI.sky.setGamma(0.5, { render: false });
editorAPI.sky.enable();

refresh() recalculates the visual state from the current time and renders the scene if requested. You do not need to call it after every setter when using the default options.

Time of day

Method Behavior
setTime(ticks, options = {}) Set the total time. The day number affects the moon phase.
setDayTime(ticks, options = {}) Change the time within the current day while preserving the day number.
tick(delta = 1, options = {}) Add delta to the total time. A negative value moves time backward.

A day contains 24,000 game ticks. At Minecraft’s normal speed, 20 ticks equal one second, but these methods do not start a timer or follow real time. Each tick() call advances the time only once.

Values are converted with Number(). Finite negative and fractional values are accepted; NaN and infinities leave the state unchanged. setDayTime() wraps the value modulo 24,000: 24000 gives the beginning of the current day, while -1 gives 23999. The total time accepted by setTime() is not limited to a single day.

Time within the day Reference point
0 Beginning of the day.
6000 Noon.
12000 Evening.
18000 Midnight.

The initial total time when the subsystem is created is 6000. Read the actual current value with getState(), since other editor modes can also control the environment.

Moon phase

editorAPI.sky.setMoonPhase(4);
editorAPI.sky.setMoonPhase('new_moon');
const phases = editorAPI.sky.getMoonPhases();
Index Identifier Phase
0 full_moon Full moon.
1 waning_gibbous Waning gibbous.
2 third_quarter Third quarter.
3 waning_crescent Waning crescent.
4 new_moon New moon.
5 waxing_crescent Waxing crescent.
6 first_quarter First quarter.
7 waxing_gibbous Waxing gibbous.

setMoonPhase(phase, options = {}) accepts a numeric index or an exact string identifier. Numeric values are rounded and wrapped modulo eight: 8 means 0, and -1 means 7. An unknown string leaves the state unchanged.

The method changes the day number within the current eight-day cycle while preserving the time of day. It therefore also changes totalTicks. A subsequent setTime() determines the phase from the total time again. getMoonPhases() returns a copy of the identifier array in index order.

Environment gamma

editorAPI.sky.setGamma(value, options = {});

The value is converted with Number() and clamped to 0-1. The initial value is 0.5. A nonnumeric value or infinity leaves the state unchanged.

This controls MinecraftSky’s game lighting. It is separate from gamma processing for the final Render RT image. The method updates the lighting and renders the scene unless render is false.

Environment render distance

editorAPI.sky.setRenderDistance(chunks, options = {});

chunks is measured in chunks of 16 blocks. The value is converted to a number and clamped to 2-250 without rounding to an integer. The initial value is 25.

The parameter affects environment rendering and world fog. The fog’s far distance is min(chunks * 16, 512) blocks, and its near distance is 75% of that value. Increasing the setting beyond 32 chunks therefore does not move the far fog boundary any farther away. This method does not load chunks or set the Minecraft Live Link radius.

State and compatibility

const state = editorAPI.sky.getState();
Field Value
active Whether at least one owner has enabled the environment.
owners Array of string identifiers for owners requesting activation. The public API uses editor-api.
totalTicks Total time in game ticks.
dayTime Time within the day, from 0 inclusive to 24,000 exclusive.
sunAngle Calculated sun angle in degrees.
moonPhase, moonPhaseName Phase index and string identifier.
starBrightness Calculated star brightness for the current sky state.
gamma Game lighting gamma, 0-1.
renderDistanceChunks Configured render distance in chunks.

This is a snapshot of the values. Changing the returned object does not change the environment. sky also has a getSky() method that returns the internal MinecraftSky object or null; its fields and additional methods are part of the editor’s internals and may change.

Activation can have multiple owners. Immersion, Live Link, and time-of-day animation can keep the environment enabled independently of a plugin. This means active may remain true after disable(). All plugins using editorAPI.sky share one owner, editor-api: a disable() call from one plugin removes the shared API request, not only that plugin’s request.

The environment values are shared as well: Live Link can update the time from the world, and Animator can update it from a time-of-day track. setTime() does not create an animation key, add an Undo command, or save the plugin’s setting in the project. Current sky values are not serialized separately into .bdengine; for a reusable preset, store the required values in your plugin’s settings and apply them explicitly. Time-of-day animation keys and project saving are separate editor mechanisms.

For a practical example of changing parameters and cleaning up, see Control the environment.

Put it into practice