Class CameraZoom

java.lang.Object
net.ixdarklord.coolcatcanvas.api.client.camera.CameraZoom

public final class CameraZoom extends Object
Zooms the camera: a spyglass of a mod's own, a scope, a lens. The view narrows smoothly to the zoom asked for, and the mouse slows by as much, so aiming stays as steady at 4x as at 1x.
CameraZoom.set(3.0F);        // three times closer; eases in
CameraZoom.reset();          // back to the player's own field of view

// The wheel zooms while the lens is raised (and scrolls the hotbar as usual when it is not).
CameraZoom.scroll(() -> MyLens.isRaised(), 1.0F, 4.0F, 0.5F);
Zoom is client state. Whoever sets it resets it: an item raised sets it each tick it is raised and resets it when lowered. It is cleared when the player leaves the world.
  • Method Summary

    Modifier and Type
    Method
    Description
    static float
    The zoom as drawn this tick, on its way to target().
    static void
    ease(float perTick)
    How quickly the view eases to the zoom asked for: the share of the way left that it covers each tick.
    static void
    Back to the player's own view.
    static void
    scroll(@Nullable BooleanSupplier active, float min, float max, float step)
    Lets the mouse wheel zoom.
    static void
    set(float factor)
    Zooms to a factor: 1 is the player's own view, 2 shows half as wide a field.
    static float
    The zoom being eased towards.

    Methods inherited from class Object

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

    • set

      public static void set(float factor)
      Zooms to a factor: 1 is the player's own view, 2 shows half as wide a field. Eases there over a few ticks.
    • ease

      public static void ease(float perTick)
      How quickly the view eases to the zoom asked for: the share of the way left that it covers each tick. 0.35 by default (snappy); around 0.15 is a slow, heavy lens; 1 is instant.
    • reset

      public static void reset()
      Back to the player's own view.
    • target

      public static float target()
      The zoom being eased towards.
    • current

      public static float current()
      The zoom as drawn this tick, on its way to target().
    • scroll

      public static void scroll(@Nullable BooleanSupplier active, float min, float max, float step)
      Lets the mouse wheel zoom. While active says so (and no screen is open), a notch of the wheel changes the zoom by step between min and max, and does nothing else. One wheel control at a time: a second call replaces the first.
      Parameters:
      active - when the wheel zooms; null removes the control