Contents
Class BlockColorIndex
java.lang.Object
com.hypixel.hytale.builtin.buildertools.BlockColorIndex
Index of solid block colors for fast color-to-block matching.
Uses LAB color space for perceptually accurate matching.
Lazily initialized on first access.
TODO: When refactoring type replace related logic, maybe generalize this class to be an index that groups blocks
by their variants and color. That way looking up variants of a block is better.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintfindBlockForLerpedColor(int rA, int gA, int bA, int rB, int gB, int bB, float t) Interpolates between two colors and finds the closest block.intfindClosestBlock(int r, int g, int b) Finds the closest matching block for the given RGB color.intfindClosestVariant(int sourceBlockId, String suffix) Finds the block whose id ends with the given shape suffix and whose colour is closest to the source block.intfindDarkerVariant(int blockId, float darkenAmount) Finds a darker variant of the given block.intfindLighterVariant(int blockId, float lightenAmount) Finds a lighter variant of the given block.intgetBlockColor(int blockId) Gets the RGB color of a block.booleanisEmpty()Checks if the index has any entries.booleanisExcludedQuality(int blockId)
-
Constructor Details
-
BlockColorIndex
public BlockColorIndex()
-
-
Method Details
-
isExcludedQuality
public boolean isExcludedQuality(int blockId) -
findClosestBlock
public int findClosestBlock(int r, int g, int b) Finds the closest matching block for the given RGB color.- Returns:
- block ID or -1 if no match found
-
findClosestVariant
Finds the block whose id ends with the given shape suffix and whose colour is closest to the source block.- Returns:
- block id of the closest same-shape block, or -1 if none has a usable colour
-
findDarkerVariant
public int findDarkerVariant(int blockId, float darkenAmount) Finds a darker variant of the given block.- Parameters:
blockId- the source block IDdarkenAmount- how much to darken (0.0 - 1.0)- Returns:
- block ID of a darker variant, or the original if none found
-
findLighterVariant
public int findLighterVariant(int blockId, float lightenAmount) Finds a lighter variant of the given block.- Parameters:
blockId- the source block IDlightenAmount- how much to lighten (0.0 - 1.0)- Returns:
- block ID of a lighter variant, or the original if none found
-
getBlockColor
public int getBlockColor(int blockId) Gets the RGB color of a block.- Returns:
- packed RGB (0xRRGGBB) or -1 if not found
-
findBlockForLerpedColor
public int findBlockForLerpedColor(int rA, int gA, int bA, int rB, int gB, int bB, float t) Interpolates between two colors and finds the closest block.- Parameters:
t- interpolation factor (0.0 = colorA, 1.0 = colorB)
-
isEmpty
public boolean isEmpty()Checks if the index has any entries.
-