Skip to content

1.12.2 KubeJS

JohnBraham edited this page Nov 28, 2026 · 1 revision

KubeJS on Minecraft 1.12.2

Minecraft 1.12.2 local candidate · 0.1.22.112021 · Forge 14.23.5.2859 · API 8. This port is not published yet.

The optional bridge targets the original KubeJS 1.1.0.65, which uses Java 8 and Nashorn. Put scripts in kubejs/*.js. This is the older events.listen API; examples written for modern KubeJS and Rhino need adapting.

Crop and biome definitions

skyWeather.setCropTemperatureCelsius('minecraft:wheat', -5, 5, 25, 40);
skyWeather.exemptCrop('minecraft:nether_wart');
skyWeather.mapBiome('minecraft:plains', 'central_european');

The four temperatures are minimum, ideal minimum, ideal maximum and maximum, in Celsius. Selectors accept block properties, just like plant_growth.mappings. The precedence is KubeJS, CraftTweaker, config, Java API, bundled defaults. Each script engine owns its definitions, so removing KubeJS definitions reveals the remaining CraftTweaker rules when the world next starts.

Definitions load before gameplay. A reload while a world is running stages changed definitions for its next restart; it keeps the active crop and biome snapshot, including the copy sent to clients. A failed load retains that engine's last valid definitions. /skyweather validate reports pending changes. Reloading scripts can still have immediate runtime effects through the controls below; those actions are not rolled back if a later script statement fails.

Read current conditions

// Call while the world is running, for example from a player event.
// player can be KubeJS PlayerJS or a Minecraft EntityPlayer.
var season = skyWeather.getSeason();
var local = skyWeather.getLocalClimate(0, 8, 80, 8);
if (local.available) {
    var celsius = local.temperatureCelsius;
    var source = local.source;
}
var growth = skyWeather.getPlantGrowth(0, 8, 80, 8);

The first coordinate argument is a dimension ID. An unloaded position or dimension returns available: false and never requests terrain. The alternative forms are getSeason(player), getLocalClimate(player) and getPlantGrowth(player, x, y, z). Climate maps include available temperature, source, precipitation, intensity, wind, fog, thunder, climate ID, season and weather-event ID. Growth maps provide available, multiplier and reason.

Weather and calendar controls

Use controls from a running server callback, on its logical thread:

events.listen('server.load', function(event) {
    // Example test setup; remove this to keep normal world weather.
    skyWeather.setClimateMode('universal');
    skyWeather.setPreset('burlington');
    skyWeather.setSeason('winter', 45);
    skyWeather.forceWeather('frontal_precipitation', 120, 0.8);
});

nextSeason(), previousSeason() and advanceDays(days) move the seasonal calendar without moving the daylight clock. setSeason(name, day) uses days starting at one. setPreset(id) selects Universal Climate; setClimateMode('per_biome'|'universal'|'real_world') chooses the mode. setSeasonalStrength(value) accepts the same range as the admin command.

forceWeather(id[, seconds, intensity[, includeDryBiomes]]) defaults to 90 seconds and 0.85 intensity. Durations are 1–2400 real seconds of server ticks; intensity is 0.01–1. clearWeather([seconds]) makes a timed clear preview and automaticWeather() returns to the schedule. Event IDs match /skyweather weather tab completion. Previews expire and are not persisted.

saveWorldSettings() saves explicit settings edits and discardWorldSettings() restores the last saved settings. These have the same semantics as the controller; scripts are trusted pack code with server control privileges.

Events

events.listen('skyweather.season_changed', function(event) {
    var phase = event.current.season;
    var day = event.current.day;
});
events.listen('skyweather.weather_changed', function(event) {
    var kind = event.current.kind; // clear when there is no carrier episode
});

Both expose world, dimension, previous and current. They are notifications, not cancellable events. The weather event describes the world's carrier episode; Per Biome weather and moving storm coverage still need a local query. Nested climate controls made by a callback apply without recursively dispatching another Sky's weather or season callback. The current calendar map includes season, day, length and progress; the previous calendar map contains the previous season name. Episode maps include availability, kind, start/end ticks, peak intensity, forced status and whether dry biomes are included.

Temperature zones

events.listen('server.load', function(event) {
    skyWeather.putTemperatureZone({
        id: 'greenhouse', dimension: 0,
        min: [100, 64, 100], max: [110, 70, 110],
        temperatureCelsius: 22, priority: 10, mode: 'OVERRIDE'
    });
});
// From a running server callback:
// skyWeather.removeTemperatureZone('greenhouse', 0);

Corners are inclusive. MINIMUM warms without cooling a warmer ambient reading; OVERRIDE sets an exact temperature. Higher priorities win. IDs are lowercase paths owned under skysrealisticweather:kubejs/. Bounds and registration limits match the temperature-zone API. Only loaded dimensions and server-thread calls are accepted, and zones never load chunks.

Zones are runtime registrations. Recreate them at server/world load and after script reload when needed. Reload removes only this bridge's zones; registrations belonging to other mods remain. A running-world reload does not replay server.load, so a pack's reload handler must recreate any zones it needs then.

Set integrations.kubejs=false and restart to disable this bridge. KubeJS remains optional on clients; the server sends resolved weather and crop rules normally.

Clone this wiki locally