Class Skyboxes
java.lang.Object
net.ixdarklord.coolcatcanvas.api.client.sky.Skyboxes
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 shared static meshes, with no allocation per frame.
-
Method Summary
Modifier and TypeMethodDescriptionstatic Collection<Skybox> all()static voidHides every skybox at once, back to vanilla's sky.get(net.minecraft.resources.ResourceLocation id) A registered skybox, or one a resource pack added (once resources have loaded).static Skyboxregister(net.minecraft.resources.ResourceLocation id, SkyboxDefinition definition) Registers a skybox from a definition built in code.static Skyboxregister(net.minecraft.resources.ResourceLocation id, net.minecraft.resources.ResourceLocation definition) Registers a skybox loaded fromassets/<namespace>/skybox/<path>.json.static booleanunregister(net.minecraft.resources.ResourceLocation id) Removes a skybox and frees what it holds.
-
Method Details
-
register
public static Skybox register(net.minecraft.resources.ResourceLocation 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.ResourceLocation id, net.minecraft.resources.ResourceLocation definition) Registers a skybox loaded fromassets/<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
A registered skybox, or one a resource pack added (once resources have loaded). -
all
-
unregister
public static boolean unregister(net.minecraft.resources.ResourceLocation id) Removes a skybox and frees what it holds. -
disableAllInstantly
public static void disableAllInstantly()Hides every skybox at once, back to vanilla's sky.
-