Record Class WidgetSprites
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 ClassesModifier and TypeClassDescriptionstatic final recordHow a nine-sliced sprite is cut: the size of its textures and the borders that keep their size. -
Constructor Summary
ConstructorsConstructorDescriptionWidgetSprites(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 aWidgetSpritesrecord class. -
Method Summary
Modifier and TypeMethodDescriptionvoidblit(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.voidblit(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.voidblit(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 byget(boolean, boolean)) over the given area.net.minecraft.resources.ResourceLocationdisabled()Returns the value of thedisabledrecord component.net.minecraft.resources.ResourceLocationReturns the value of thedisabledFocusedrecord component.net.minecraft.resources.ResourceLocationenabled()Returns the value of theenabledrecord component.net.minecraft.resources.ResourceLocationReturns the value of theenabledFocusedrecord component.final booleanIndicates whether some other object is "equal to" this one.net.minecraft.resources.ResourceLocationget(boolean enabled, boolean focused) final inthashCode()Returns a hash code value for this object.@Nullable WidgetSprites.NineSliceReturns the value of thenineSlicerecord 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 istextureWidth x textureHeightwith the given borders.final StringtoString()Returns a string representation of this record class.
-
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 aWidgetSpritesrecord class.- Parameters:
enabled- the value for theenabledrecord componentdisabled- the value for thedisabledrecord componentenabledFocused- the value for theenabledFocusedrecord componentdisabledFocused- the value for thedisabledFocusedrecord componentnineSlice- the value for thenineSlicerecord 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 istextureWidth x textureHeightwith the given borders. -
nineSliced
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 byget(boolean, boolean)) over the given area. -
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. -
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. -
equals
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 withObjects::equals(Object,Object). -
enabled
public net.minecraft.resources.ResourceLocation enabled()Returns the value of theenabledrecord component.- Returns:
- the value of the
enabledrecord component
-
disabled
public net.minecraft.resources.ResourceLocation disabled()Returns the value of thedisabledrecord component.- Returns:
- the value of the
disabledrecord component
-
enabledFocused
public net.minecraft.resources.ResourceLocation enabledFocused()Returns the value of theenabledFocusedrecord component.- Returns:
- the value of the
enabledFocusedrecord component
-
disabledFocused
public net.minecraft.resources.ResourceLocation disabledFocused()Returns the value of thedisabledFocusedrecord component.- Returns:
- the value of the
disabledFocusedrecord component
-
nineSlice
Returns the value of thenineSlicerecord component.- Returns:
- the value of the
nineSlicerecord component
-