Record Class Texture
- Record Components:
image
- the image of this texturetype
- the type of this textureu1
- the start U-coordinate, between 0 and 1v1
- the start V-coordinate, between 0 and 1u2
- the end U-coordinate, between 0 and 1v2
- the end V-coordinate, between 0 and 1
Types
Each texture has a type: it's either a standalone texture file or a sprite on the GUI sprite atlas. Their properties are slightly different.
GUI sprites can use their full range of features such as tiling, stretching and nine-slice drawing modes, while standalone textures are only drawn stretched.
The format of the image ID depends on the type. See the documentation of the individual type constants and the table below for details.
Type | File path | Image ID |
---|---|---|
STANDALONE |
assets/my_mod/textures/widget/example.png |
my_mod:textures/widget/example.png |
GUI_SPRITE |
assets/my_mod/textures/gui/sprites/example.png |
my_mod:example |
Note that the image ID can only be passed to non-Texture
overloads of
when the ScreenDrawing
.texturedRect()type
is Texture.Type.STANDALONE
. GUI sprites need specialised code for drawing them,
and they need to be drawn with specific Texture
-accepting methods
or DrawContext
.
GUI sprite textures don't currently support flipping the texture by flipping UV coordinates.
- Since:
- 3.0.0
-
Nested Class Summary
-
Constructor Summary
ConstructorDescriptionTexture
(Identifier image) Constructs a new standalone texture that uses the full image.Texture
(Identifier image, float u1, float v1, float u2, float v2) Constructs a new standalone texture with custom UV values.Texture
(Identifier image, Texture.Type type) Constructs a new texture that uses the full image.Texture
(Identifier image, Texture.Type type, float u1, float v1, float u2, float v2) Constructs a new texture with custom UV values. -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.image()
Returns the value of theimage
record component.final String
toString()
Returns a string representation of this record class.type()
Returns the value of thetype
record component.float
u1()
Returns the value of theu1
record component.float
u2()
Returns the value of theu2
record component.float
v1()
Returns the value of thev1
record component.float
v2()
Returns the value of thev2
record component.withUv
(float u1, float v1, float u2, float v2) Creates a new texture with different UV values.
-
Constructor Details
-
Texture
Constructs a new texture that uses the full image.- Parameters:
image
- the imagetype
- the type- Throws:
NullPointerException
- if the image or the type is null
-
Texture
Constructs a new standalone texture with custom UV values.- Parameters:
image
- the image of this textureu1
- the start U-coordinate, between 0 and 1v1
- the start V-coordinate, between 0 and 1u2
- the end U-coordinate, between 0 and 1v2
- the end V-coordinate, between 0 and 1- Throws:
NullPointerException
- if the image is null
-
Texture
Constructs a new standalone texture that uses the full image.- Parameters:
image
- the image- Throws:
NullPointerException
- if the image is null
-
Texture
Constructs a new texture with custom UV values.- Parameters:
image
- the imagetype
- the typeu1
- the left U coordinatev1
- the top V coordinateu2
- the right U coordinatev2
- the bottom V coordinate- Throws:
NullPointerException
- if the image or the type is null
-
-
Method Details
-
withUv
Creates a new texture with different UV values.- Parameters:
u1
- the left U coordinatev1
- the top V coordinateu2
- the right U coordinatev2
- the bottom V coordinate- Returns:
- the created texture
-
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. Reference components are compared withObjects::equals(Object,Object)
; primitive components are compared with '=='. -
image
Returns the value of theimage
record component.- Returns:
- the value of the
image
record component
-
type
Returns the value of thetype
record component.- Returns:
- the value of the
type
record component
-
u1
public float u1()Returns the value of theu1
record component.- Returns:
- the value of the
u1
record component
-
v1
public float v1()Returns the value of thev1
record component.- Returns:
- the value of the
v1
record component
-
u2
public float u2()Returns the value of theu2
record component.- Returns:
- the value of the
u2
record component
-
v2
public float v2()Returns the value of thev2
record component.- Returns:
- the value of the
v2
record component
-