Package net.minestom.server.color
Record Class Color
java.lang.Object
java.lang.Record
net.minestom.server.color.Color
- All Implemented Interfaces:
RGBLike
A general purpose class for representing colors.
Colors must be in the range of 0-255.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
asRGB()
Gets the color as an RGB integer.int
blue()
Returns the value of theblue
record component.final boolean
Indicates whether some other object is "equal to" this one.int
green()
Returns the value of thegreen
record component.final int
hashCode()
Returns a hash code value for this object.@NotNull Color
Mixes this color with a series of other colors, as if they were combined in a crafting table.int
red()
Returns the value of thered
record component.final String
toString()
Returns a string representation of this record class.@NotNull Color
withBlue
(int blue) @NotNull Color
withGreen
(int green) @NotNull Color
withRed
(int red)
-
Constructor Details
-
Color
public Color(int red, int green, int blue) Creates an instance of aColor
record class.- Parameters:
red
- the value for thered
record componentgreen
- the value for thegreen
record componentblue
- the value for theblue
record component
-
Color
public Color(int rgb) Creates a color from an integer. This is done by reading each color component from the lowest order 24 bits of the integer, and creating a color from those components.- Parameters:
rgb
- the integer
-
Color
Creates a color from an RGB-like color.- Parameters:
rgbLike
- the color
-
-
Method Details
-
withRed
-
withGreen
-
withBlue
-
asRGB
public int asRGB()Gets the color as an RGB integer.- Returns:
- An integer representation of this color, as 0xRRGGBB
-
mixWith
Mixes this color with a series of other colors, as if they were combined in a crafting table. This function works out the average of each RGB component and then multiplies the components by a scale factor that is calculated from the average of all maximum values divided by the maximum of each average value. This is how Minecraft mixes colors.- Parameters:
colors
- the colors
-
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 '=='. -
red
public int red()Returns the value of thered
record component. -
green
public int green()Returns the value of thegreen
record component. -
blue
public int blue()Returns the value of theblue
record component.
-