Class Skyboxes

java.lang.Object
net.ixdarklord.coolcatcanvas.api.client.sky.Skyboxes

public final class Skyboxes extends Object
Custom skies: images wrapped around the sky (cubemaps and panoramas), images placed in it (sprites), gradients and shaders, each able to rotate, animate frame by frame and fade by time of day, weather or code; and parts of vanilla's sky hidden while they show.

Register skyboxes once, from client code (a ClientModConstructor is a good place):

Skybox bloodMoon = Skyboxes.register(MyMod.id("blood_moon"), SkyboxDefinition.builder()
        .hide(VanillaSky.MOON)
        .layer(SkyLayerDefinition.gradient(0xFF300000, 0xFF801010, 0xFF100000, 2.0F).blend(SkyBlend.MULTIPLY))
        .layer(SkyLayerDefinition.sprite(MyMod.id("textures/sky/red_moon.png"), 25.0F)
                .name("moon")
                .rotation(SkyLayerDefinition.Rotation.withMoon())
                .stage(SkyLayerStage.ABOVE_CELESTIALS))
        .build())
        .fade(100)
        .activeWhen(context -> context.inWorld() && context.isNight() && BloodMoon.isActive(context.level()));
Resource packs can add skyboxes without code, in assets/<namespace>/skybox/<path>.json with a list of dimensions; see SkyboxDefinition. The server can drive registered skyboxes through SkyboxControl.

Cost: a skybox that isn't visible costs nothing. A visible one draws each visible layer with one draw call, from a shared static mesh, in a single render pass per stage, with no allocation per frame.

  • Method Summary

    Modifier and Type
    Method
    Description
    all()
     
    static void
    Hides every skybox at once, back to vanilla's sky.
    get(net.minecraft.resources.Identifier id)
    A registered skybox, or one a resource pack added (once resources have loaded).
    static Skybox
    register(net.minecraft.resources.Identifier id, SkyboxDefinition definition)
    Registers a skybox from a definition built in code.
    static Skybox
    register(net.minecraft.resources.Identifier id, net.minecraft.resources.Identifier definition)
    Registers a skybox loaded from assets/<namespace>/skybox/<path>.json.
    static boolean
    unregister(net.minecraft.resources.Identifier id)
    Removes a skybox and frees what it holds.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • register

      public static Skybox register(net.minecraft.resources.Identifier id, SkyboxDefinition definition)
      Registers a skybox from a definition built in code. Its textures and shaders still come from resources.
      Throws:
      IllegalArgumentException - if the id is taken by another registered skybox
    • register

      public static Skybox register(net.minecraft.resources.Identifier id, net.minecraft.resources.Identifier definition)
      Registers a skybox loaded from assets/<namespace>/skybox/<path>.json. It's loaded with the game's resources, and reloaded with them.
      Throws:
      IllegalArgumentException - if the id is taken by another registered skybox
    • get

      public static Optional<Skybox> get(net.minecraft.resources.Identifier id)
      A registered skybox, or one a resource pack added (once resources have loaded).
    • all

      public static Collection<Skybox> all()
    • unregister

      public static boolean unregister(net.minecraft.resources.Identifier id)
      Removes a skybox and frees what it holds.
    • disableAllInstantly

      public static void disableAllInstantly()
      Hides every skybox at once, back to vanilla's sky.