java.lang.Object
java.lang.Record
net.ixdarklord.coolcatcanvas.api.client.gui.components.widgets.WidgetSprites

public record WidgetSprites(net.minecraft.resources.ResourceLocation enabled, net.minecraft.resources.ResourceLocation disabled, net.minecraft.resources.ResourceLocation enabledFocused, net.minecraft.resources.ResourceLocation disabledFocused, @Nullable WidgetSprites.NineSlice nineSlice) extends Record
The textures of a widget for each of its states; a backport of the vanilla class added in Minecraft 1.20.2.

Minecraft 1.20.1 has no GUI sprite atlas, so the locations are full texture paths (e.g. modid:textures/gui/button.png). By default a texture is stretched over the widget; use nineSliced(int, int, net.ixdarklord.coolcatcanvas.api.client.utils.NineSliceInfo.SliceBounds) for textures whose borders must keep their size (the equivalent of a nine_slice GUI scaling on newer versions).

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final record 
    How a nine-sliced sprite is cut: the size of its textures and the borders that keep their size.
  • Constructor Summary

    Constructors
    Constructor
    Description
    WidgetSprites(net.minecraft.resources.ResourceLocation enabled, net.minecraft.resources.ResourceLocation focused)
     
    WidgetSprites(net.minecraft.resources.ResourceLocation enabled, net.minecraft.resources.ResourceLocation disabled, net.minecraft.resources.ResourceLocation enabledFocused)
     
    WidgetSprites(net.minecraft.resources.ResourceLocation enabled, net.minecraft.resources.ResourceLocation disabled, net.minecraft.resources.ResourceLocation enabledFocused, net.minecraft.resources.ResourceLocation disabledFocused)
     
    WidgetSprites(net.minecraft.resources.ResourceLocation enabled, net.minecraft.resources.ResourceLocation disabled, net.minecraft.resources.ResourceLocation enabledFocused, net.minecraft.resources.ResourceLocation disabledFocused, @Nullable WidgetSprites.NineSlice nineSlice)
    Creates an instance of a WidgetSprites record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    blit(net.minecraft.client.gui.GuiGraphics graphics, boolean enabled, boolean focused, int x, int y, int width, int height)
    Draws the sprite for the given state over the given area.
    void
    blit(net.minecraft.client.gui.GuiGraphics graphics, boolean enabled, boolean focused, int x, int y, int width, int height, int color)
    Draws the sprite for the given state over the given area, tinted by an ARGB color.
    void
    blit(net.minecraft.client.gui.GuiGraphics graphics, net.minecraft.resources.ResourceLocation sprite, int x, int y, int width, int height)
    Draws one of these sprites (as returned by get(boolean, boolean)) over the given area.
    net.minecraft.resources.ResourceLocation
    Returns the value of the disabled record component.
    net.minecraft.resources.ResourceLocation
    Returns the value of the disabledFocused record component.
    net.minecraft.resources.ResourceLocation
    Returns the value of the enabled record component.
    net.minecraft.resources.ResourceLocation
    Returns the value of the enabledFocused record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    net.minecraft.resources.ResourceLocation
    get(boolean enabled, boolean focused)
     
    final int
    Returns a hash code value for this object.
    Returns the value of the nineSlice record component.
    nineSliced(int textureWidth, int textureHeight, int border)
    These sprites drawn nine-sliced with the same border on every side.
    nineSliced(int textureWidth, int textureHeight, NineSliceInfo.SliceBounds border)
    These sprites drawn nine-sliced: every texture is textureWidth x textureHeight with the given borders.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • WidgetSprites

      public WidgetSprites(net.minecraft.resources.ResourceLocation enabled, net.minecraft.resources.ResourceLocation disabled, net.minecraft.resources.ResourceLocation enabledFocused, net.minecraft.resources.ResourceLocation disabledFocused)
    • WidgetSprites

      public WidgetSprites(net.minecraft.resources.ResourceLocation enabled, net.minecraft.resources.ResourceLocation focused)
    • WidgetSprites

      public WidgetSprites(net.minecraft.resources.ResourceLocation enabled, net.minecraft.resources.ResourceLocation disabled, net.minecraft.resources.ResourceLocation enabledFocused)
    • WidgetSprites

      public WidgetSprites(net.minecraft.resources.ResourceLocation enabled, net.minecraft.resources.ResourceLocation disabled, net.minecraft.resources.ResourceLocation enabledFocused, net.minecraft.resources.ResourceLocation disabledFocused, @Nullable @Nullable WidgetSprites.NineSlice nineSlice)
      Creates an instance of a WidgetSprites record class.
      Parameters:
      enabled - the value for the enabled record component
      disabled - the value for the disabled record component
      enabledFocused - the value for the enabledFocused record component
      disabledFocused - the value for the disabledFocused record component
      nineSlice - the value for the nineSlice record component
  • Method Details

    • get

      public net.minecraft.resources.ResourceLocation get(boolean enabled, boolean focused)
    • nineSliced

      public WidgetSprites nineSliced(int textureWidth, int textureHeight, NineSliceInfo.SliceBounds border)
      These sprites drawn nine-sliced: every texture is textureWidth x textureHeight with the given borders.
    • nineSliced

      public WidgetSprites nineSliced(int textureWidth, int textureHeight, int border)
      These sprites drawn nine-sliced with the same border on every side.
    • blit

      public void blit(net.minecraft.client.gui.GuiGraphics graphics, boolean enabled, boolean focused, int x, int y, int width, int height)
      Draws the sprite for the given state over the given area.
    • blit

      public void blit(net.minecraft.client.gui.GuiGraphics graphics, boolean enabled, boolean focused, int x, int y, int width, int height, int color)
      Draws the sprite for the given state over the given area, tinted by an ARGB color.
    • blit

      public void blit(net.minecraft.client.gui.GuiGraphics graphics, net.minecraft.resources.ResourceLocation sprite, int x, int y, int width, int height)
      Draws one of these sprites (as returned by get(boolean, boolean)) over the given area.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • enabled

      public net.minecraft.resources.ResourceLocation enabled()
      Returns the value of the enabled record component.
      Returns:
      the value of the enabled record component
    • disabled

      public net.minecraft.resources.ResourceLocation disabled()
      Returns the value of the disabled record component.
      Returns:
      the value of the disabled record component
    • enabledFocused

      public net.minecraft.resources.ResourceLocation enabledFocused()
      Returns the value of the enabledFocused record component.
      Returns:
      the value of the enabledFocused record component
    • disabledFocused

      public net.minecraft.resources.ResourceLocation disabledFocused()
      Returns the value of the disabledFocused record component.
      Returns:
      the value of the disabledFocused record component
    • nineSlice

      @Nullable public @Nullable WidgetSprites.NineSlice nineSlice()
      Returns the value of the nineSlice record component.
      Returns:
      the value of the nineSlice record component