public interface Skybox
A custom sky, made with Skyboxes.register(net.minecraft.resources.ResourceLocation, net.ixdarklord.coolcatcanvas.api.client.sky.SkyboxDefinition): layers of images, gradients and shaders drawn into vanilla's sky, and parts of vanilla's sky hidden. Any number can show at once, drawn by ascending priority.

A skybox shows while it's enabled, fading in and out. Unless told otherwise with activeWhen(java.util.function.Predicate<net.ixdarklord.coolcatcanvas.api.client.sky.SkyContext>), one whose definition lists dimensions enables itself in those; others wait for enable() (or the server's SkyboxControl).

Settings made here override the definition's, and survive resource reloads. Durations are in ticks of real time (20 per second). Only use a skybox from the render thread.

  • Method Summary

    Modifier and Type
    Method
    Description
    activeWhen(@Nullable Predicate<SkyContext> condition)
    Enables the skybox whenever the condition holds and disables it otherwise, checked every frame.
    @Nullable net.minecraft.resources.ResourceLocation
    The skybox JSON it's loaded from, or null for a definition built in code.
    Fades out.
    Hides the skybox right away, skipping the fade-out.
    Fades in, or keeps the skybox on if it's already.
    enableFor(int ticks)
    Fades in, stays for ticks, then fades out.
    Shows the skybox fully right away, skipping the fade-in.
    @Nullable String
    Why it failed to load or draw, if it did.
    default Skybox
    fade(int ticks)
     
    fade(int fadeInTicks, int fadeOutTicks, Easing easing)
    How it fades in and out.
    The parts of vanilla's sky it hides.
    hide(VanillaSky... parts)
    Replaces the parts of vanilla's sky it hides.
    net.minecraft.resources.ResourceLocation
    id()
     
    boolean
    Whether it's enabled; it may still be fading in.
    boolean
    Whether its definition and shaders loaded, so it can be drawn.
    boolean
    Whether it's drawn this frame: enabled, or still fading out.
    layer(String name)
    The layer named name in the definition (unnamed layers are layer_0, layer_1, ...).
    The layers of the loaded definition, in draw order; empty before it has loaded.
    onFrame(@Nullable Consumer<SkyContext> callback)
    Runs every frame while the skybox is visible, before it's drawn: a place to drive its layers.
    int
     
    priority(int priority)
    Lower priorities are drawn first, so higher ones end up on top.
    default Skybox
    setEnabled(boolean enabled)
     
    default Skybox
     
    float
    How visible it is this frame, from its fade: 0 to 1.
  • Method Details

    • id

      net.minecraft.resources.ResourceLocation id()
    • definitionId

      @Nullable @Nullable net.minecraft.resources.ResourceLocation definitionId()
      The skybox JSON it's loaded from, or null for a definition built in code.
    • priority

      int priority()
    • priority

      Skybox priority(int priority)
      Lower priorities are drawn first, so higher ones end up on top. Defaults to the definition's.
    • fade

      Skybox fade(int fadeInTicks, int fadeOutTicks, Easing easing)
      How it fades in and out. Defaults to the definition's durations, with Easing.SINE_IN_OUT.
    • fade

      default Skybox fade(int ticks)
    • activeWhen

      Skybox activeWhen(@Nullable @Nullable Predicate<SkyContext> condition)
      Enables the skybox whenever the condition holds and disables it otherwise, checked every frame. Replaces the definition's dimensions; pass null to leave it to enable() and disable().
    • onFrame

      Skybox onFrame(@Nullable @Nullable Consumer<SkyContext> callback)
      Runs every frame while the skybox is visible, before it's drawn: a place to drive its layers.
    • hide

      Skybox hide(VanillaSky... parts)
      Replaces the parts of vanilla's sky it hides. Defaults to the definition's hide.
    • hidden

      Set<VanillaSky> hidden()
      The parts of vanilla's sky it hides.
    • enable

      Skybox enable()
      Fades in, or keeps the skybox on if it's already. Cancels a pending enableFor(int) timeout.
    • disable

      Skybox disable()
      Fades out.
    • setEnabled

      default Skybox setEnabled(boolean enabled)
    • toggle

      default Skybox toggle()
    • enableFor

      Skybox enableFor(int ticks)
      Fades in, stays for ticks, then fades out.
    • enableInstantly

      Skybox enableInstantly()
      Shows the skybox fully right away, skipping the fade-in.
    • disableInstantly

      Skybox disableInstantly()
      Hides the skybox right away, skipping the fade-out.
    • isEnabled

      boolean isEnabled()
      Whether it's enabled; it may still be fading in.
    • isVisible

      boolean isVisible()
      Whether it's drawn this frame: enabled, or still fading out.
    • visibility

      float visibility()
      How visible it is this frame, from its fade: 0 to 1.
    • layer

      SkyLayer layer(String name)
      The layer named name in the definition (unnamed layers are layer_0, layer_1, ...). The handle can be taken before the definition has loaded.
    • layers

      Collection<SkyLayer> layers()
      The layers of the loaded definition, in draw order; empty before it has loaded.
    • isLoaded

      boolean isLoaded()
      Whether its definition and shaders loaded, so it can be drawn. False until the first resource load, and after errors.
    • error

      @Nullable @Nullable String error()
      Why it failed to load or draw, if it did. Fixed by a resource reload.