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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintasRGB()Gets the color as an RGB integer.intblue()Returns the value of thebluerecord component.final booleanIndicates whether some other object is "equal to" this one.intgreen()Returns the value of thegreenrecord component.final inthashCode()Returns a hash code value for this object.@NotNull ColorMixes this color with a series of other colors, as if they were combined in a crafting table.intred()Returns the value of theredrecord component.final StringtoString()Returns a string representation of this record class.@NotNull ColorwithBlue(int blue) @NotNull ColorwithGreen(int green) @NotNull ColorwithRed(int red)
-
Constructor Details
-
Color
public Color(int red, int green, int blue) Creates an instance of aColorrecord class.- Parameters:
red- the value for theredrecord componentgreen- the value for thegreenrecord componentblue- the value for thebluerecord 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 theredrecord component. -
green
public int green()Returns the value of thegreenrecord component. -
blue
public int blue()Returns the value of thebluerecord component.
-