Skip to content

1.10.2 API Getting Started

JohnBraham edited this page Nov 28, 2026 · 2 revisions

Start a Java API integration

Minecraft 1.10.2 · Sky’s Realistic Weather 0.1.22.110021 · API 8 · config 8. See version support before using these examples in another port.

The supported package is zone.moddev.mc.skysrealisticweather.api. The current API version is 8. Client and server use matching mod builds. Internal game, climate, client, compat and network classes are not a stable integration contract.

Add a compile dependency

The API jar is published separately on the MMD Maven. Add it as a compile-only dependency and install the matching main mod jar at runtime. Keep native Minecraft and Forge types supplied by your normal development environment.

repositories {
    maven { url 'https://maven.moddev.zone/releases/' }
}
dependencies {
    compileOnly 'zone.moddev.mc.skysrealisticweather:SkysRealisticWeather:0.1.22.110021:api'
}

Use your ForgeGradle project’s equivalent provided/deobfuscated dependency mechanism. Do not shade or copy Weather classes into your mod. You can also download the API jar from the GitHub release.

Required or optional loading

For a required dependency use required-after:skysrealisticweather in your mod’s Forge dependency declaration. For an optional one, use after:skysrealisticweather, check Loader.isModLoaded and keep all API references in a separate compatibility class. Do not expose API types in the fields or signatures of your always-loaded entry class.

Here are complete Java 8 source files. Replace the example mod, biome and crop IDs with IDs your mod actually registers. Register once during init/post-init, on both physical distributions; world events and runtime queries are separate from this startup registration.

WeatherExampleMod.java

package example.weather;

import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;

@Mod(modid="weatherexample", name="Weather integration example", version="1.0",
     dependencies="after:skysrealisticweather")
public final class WeatherExampleMod {
    @Mod.EventHandler
    public void init(FMLInitializationEvent event) {
        if (Loader.isModLoaded("skysrealisticweather")) {
            WeatherCompatibility.register();
        }
    }
}

WeatherCompatibility.java

package example.weather;

import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import zone.moddev.mc.skysrealisticweather.api.BiomeClimate;
import zone.moddev.mc.skysrealisticweather.api.PlantGrowthProfile;
import zone.moddev.mc.skysrealisticweather.api.SeasonalSurfaceEvent;
import zone.moddev.mc.skysrealisticweather.api.WeatherApi;

public final class WeatherCompatibility {
    public static void register() {
        WeatherApi.registerBiomeClimate(
            new ResourceLocation("weatherexample", "misty_highlands"),
            new BiomeClimate(-0.2F, 0.75F, BiomeClimate.PrecipitationRule.BIOME_DEFAULT));
        WeatherApi.registerPlantGrowthProfile("weatherexample:tomato",
            new PlantGrowthProfile(mc(-5), mc(5), mc(25), mc(40)));
        WeatherApi.registerPlantGrowthProfile("weatherexample:magic_crop", PlantGrowthProfile.EXEMPT);
        MinecraftForge.EVENT_BUS.register(new WeatherCompatibility());
    }

    private static float mc(float celsius) {
        return WeatherApi.SNOW_LINE + 0.045F * celsius;
    }

    @SubscribeEvent
    public void protectDisplayGarden(SeasonalSurfaceEvent event) {
        // Example garden: inclusive x/z 10..20, y 64..70 in the Overworld.
        int x=event.position.getX(), y=event.position.getY(), z=event.position.getZ();
        if (event.world.provider.getDimension()==0
                && x>=10 && x<=20 && y>=64 && y<=70 && z>=10 && z<=20) {
            event.setCanceled(true);
        }
    }
}

The event example vetoes this mod’s surface changes inside a fixed example garden. It does not prevent vanilla melting, other mods’ changes or precipitation particles, and it does not register a heated area. For heating use temperature zones.

Availability and ownership

Query world state on that world’s logical thread. Startup registration is done before load completion; runtime zone mutations require the logical server thread. Do not use a rendering/worker thread to mutate a server world. Schedule a server task when a worker needs to request a change.

Most weather queries return an Optional because a world may not be supported or initialized, a position may be unloaded or a client may still be awaiting synchronization. Supply non-null arguments; an Optional does not mean arbitrary null inputs are accepted. Treat an absent reading as unavailable and preserve your own fallback.

Use the reference for method-specific exceptions, including loaded local-temperature fallbacks outside seasonal dimensions. The cookbook shows safe runtime reads and complete utility methods.


Wiki home · Minecraft 1.10.2 guide · Implementation source

Clone this wiki locally