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 GuiGraphicsExtractor.
GUI sprite textures don't currently support flipping the texture by flipping UV coordinates.
- Since:
- 3.0.0
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionTexture(net.minecraft.resources.Identifier image) Constructs a new standalone texture that uses the full image.Texture(net.minecraft.resources.Identifier image, float u1, float v1, float u2, float v2) Constructs a new standalone texture with custom UV values.Texture(net.minecraft.resources.Identifier image, Texture.Type type) Constructs a new texture that uses the full image.Texture(net.minecraft.resources.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 booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.net.minecraft.resources.Identifierimage()Returns the value of theimagerecord component.final StringtoString()Returns a string representation of this record class.type()Returns the value of thetyperecord component.floatu1()Returns the value of theu1record component.floatu2()Returns the value of theu2record component.floatv1()Returns the value of thev1record component.floatv2()Returns the value of thev2record 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
public Texture(net.minecraft.resources.Identifier image, float u1, float v1, float u2, float v2) 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
public Texture(net.minecraft.resources.Identifier image) Constructs a new standalone texture that uses the full image.- Parameters:
image- the image- Throws:
NullPointerException- if the image is null
-
Texture
public Texture(net.minecraft.resources.Identifier image, Texture.Type type, float u1, float v1, float u2, float v2) 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
-
hashCode
-
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 thecomparemethod from their corresponding wrapper classes. -
image
-
type
-
u1
-
v1
-
u2
-
v2
-