Package top.girlkisser.lazuli.api.colour
Record Class UnpackedColour
java.lang.Object
java.lang.Record
top.girlkisser.lazuli.api.colour.UnpackedColour
- Record Components:
r- Red value from 0 to 255.g- Green value from 0 to 255.b- Blue value from 0 to 255.a- Alpha value from 0 to 255.
Represents an RGBA colour in an unpacked form.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.Codec<UnpackedColour> static final com.mojang.serialization.Codec<UnpackedColour> A codec for colours allowing a variety of formats: - RGB(A) as an object ({"r":255,"g":100,"b":150,"a":255}) - RGBA as a list ([255, 100, 150, 255]) - RGB as a list ([255, 100, 150]) - Hex (RGBA) codes as a string ("#rrggbbaa") - Hex (RGB) codes as a string ("#rrggbb") - Packed colours as an integer (16777215)static final com.mojang.serialization.Codec<UnpackedColour> static final com.mojang.serialization.Codec<UnpackedColour> static final com.mojang.serialization.Codec<UnpackedColour> -
Constructor Summary
ConstructorsConstructorDescriptionUnpackedColour(int packedColour) Creates an unpacked colour from the packed colour (expects ARGB32).UnpackedColour(int r, int g, int b) Creates an unpacked colour using the provided R, G, and B values (0-255).UnpackedColour(int r, int g, int b, int a) Creates an instance of aUnpackedColourrecord class. -
Method Summary
Modifier and TypeMethodDescriptioninta()Returns the value of thearecord component.intb()Returns the value of thebrecord component.final booleanIndicates whether some other object is "equal to" this one.intg()Returns the value of thegrecord component.final inthashCode()Returns a hash code value for this object.modulateAlpha(net.minecraft.util.RandomSource random, int variance) Addrandom.nextInt(-variance, variance)to the alpha value.modulateRGB(net.minecraft.util.RandomSource random, int variance) Addrandom.nextInt(-variance, variance)to the R, G, and B values.intpack()Gets the colour as a packed integer in ARGB32 format.intr()Returns the value of therrecord component.net.minecraft.util.ColorRGBAConverts the unpacked colour to aColorRGBA.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
CODEC
-
LIST_CODEC
-
STRING_CODEC
-
PACKED_CODEC
-
FLEXIBLE_CODEC
A codec for colours allowing a variety of formats: - RGB(A) as an object ({"r":255,"g":100,"b":150,"a":255}) - RGBA as a list ([255, 100, 150, 255]) - RGB as a list ([255, 100, 150]) - Hex (RGBA) codes as a string ("#rrggbbaa") - Hex (RGB) codes as a string ("#rrggbb") - Packed colours as an integer (16777215)
-
-
Constructor Details
-
UnpackedColour
public UnpackedColour(int r, int g, int b) Creates an unpacked colour using the provided R, G, and B values (0-255).- Parameters:
r- Red value from 0 to 255.g- Green value from 0 to 255.b- Blue value from 0 to 255.
-
UnpackedColour
public UnpackedColour(int packedColour) Creates an unpacked colour from the packed colour (expects ARGB32).- Parameters:
packedColour- The packed colour.
-
UnpackedColour
public UnpackedColour(int r, int g, int b, int a) Creates an instance of aUnpackedColourrecord class.
-
-
Method Details
-
pack
public int pack()Gets the colour as a packed integer in ARGB32 format.- Returns:
- The packed colour.
-
toColorRGBA
public net.minecraft.util.ColorRGBA toColorRGBA()Converts the unpacked colour to aColorRGBA.- Returns:
- The ColorRGBA.
-
modulateRGB
Addrandom.nextInt(-variance, variance)to the R, G, and B values.- Parameters:
random- The random source to use.variance- How much to vary the ranges.- Returns:
- A
UnpackedColourwith the new values.
-
modulateAlpha
Addrandom.nextInt(-variance, variance)to the alpha value.- Parameters:
random- The random source to use.variance- How much to vary the range.- Returns:
- A
UnpackedColourwith the new value.
-
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 with '=='. -
r
public int r()Returns the value of therrecord component.- Returns:
- the value of the
rrecord component
-
g
public int g()Returns the value of thegrecord component.- Returns:
- the value of the
grecord component
-
b
public int b()Returns the value of thebrecord component.- Returns:
- the value of the
brecord component
-
a
public int a()Returns the value of thearecord component.- Returns:
- the value of the
arecord component
-