Class Color

java.lang.Object
net.minestom.server.color.Color
All Implemented Interfaces:
RGBLike
Direct Known Subclasses:
AlphaColor

public class Color extends Object implements RGBLike
A general purpose class for representing colors.

Colors must be in the range of 0-255.

  • Field Details

  • 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

      public Color(@NotNull @NotNull RGBLike rgbLike)
      Creates a color from an RGB-like color.
      Parameters:
      rgbLike - the color
  • Method Details

    • fromRGBLike

      @NotNull public static @NotNull Color fromRGBLike(@NotNull @NotNull RGBLike rgbLike)
    • withRed

      @NotNull public @NotNull Color withRed(int red)
    • withGreen

      @NotNull public @NotNull Color withGreen(int green)
    • withBlue

      @NotNull public @NotNull Color withBlue(int blue)
    • withAlpha

      @NotNull public @NotNull AlphaColor withAlpha(int alpha)
    • asRGB

      public int asRGB()
      Gets the color as an RGB integer.
      Returns:
      An integer representation of this color, as 0xRRGGBB
    • mixWith

      @NotNull public @NotNull Color mixWith(@NotNull @NotNull RGBLike... colors)
      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 public int getRed()
      Deprecated.
    • getGreen

      @Deprecated public int getGreen()
      Deprecated.
    • getBlue

      @Deprecated public int getBlue()
      Deprecated.
    • red

      public int red()
      Specified by:
      red in interface RGBLike
    • green

      public int green()
      Specified by:
      green in interface RGBLike
    • blue

      public int blue()
      Specified by:
      blue in interface RGBLike
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object