Package net.minestom.server.color
Class Color
java.lang.Object
net.minestom.server.color.Color
- All Implemented Interfaces:
RGBLike
- Direct Known Subclasses:
AlphaColor
A general purpose class for representing colors.
Colors must be in the range of 0-255.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final BinaryTagSerializer
<RGBLike> static final NetworkBuffer.Type
<RGBLike> static final RGBLike
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
asRGB()
Gets the color as an RGB integer.int
blue()
boolean
static @NotNull Color
fromRGBLike
(@NotNull RGBLike rgbLike) int
getBlue()
Deprecated.int
getGreen()
Deprecated.int
getRed()
Deprecated.int
green()
int
hashCode()
@NotNull Color
Mixes this color with a series of other colors, as if they were combined in a crafting table.int
red()
toString()
@NotNull AlphaColor
withAlpha
(int alpha) @NotNull Color
withBlue
(int blue) @NotNull Color
withGreen
(int green) @NotNull Color
withRed
(int red)
-
Field Details
-
NETWORK_TYPE
-
NBT_TYPE
-
WHITE
-
-
Constructor Details
-
Color
public Color(int red, int green, int blue) -
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
-
fromRGBLike
-
withRed
-
withGreen
-
withBlue
-
withAlpha
-
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
-
getRed
Deprecated. -
getGreen
Deprecated. -
getBlue
Deprecated. -
red
public int red() -
green
public int green() -
blue
public int blue() -
equals
-
hashCode
public int hashCode() -
toString
-