Class BlockPalette
java.lang.Object
dev.despical.pixelpainter.image.BlockPalette
Resolves configured material colors and performs perceptual nearest-color matching.
Loading runs on the server thread because it resolves Bukkit materials and creates canonical block-data strings. Unknown materials are skipped for cross-version palettes; unsafe blocks, invalid colors and unavailable explicit inclusions reject the candidate palette.
Matching uses cached Oklab coordinates without world access. The entry list is copied. Treat each entry's coordinate array as read-only when sharing a palette with image workers; subsets reuse those entries.
Supported transparent cubes include stable ice and leaves; glass is never used. Leaves use persistent block data to prevent natural decay. Gravity blocks and block entities are rejected before a candidate can reach the painting service.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordAssociates a material and canonical block data with its representative color. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionBlockPalette(List<BlockPalette.Entry> entries) Copies a non-empty list of prepared palette entries. -
Method Summary
Modifier and TypeMethodDescriptionentries()Returns the unmodifiable candidate list.static BlockPaletteLoads and filters material colors using the current server material registry.nearest(int rgb) Finds the closest representative color by squared Oklab distance.Selects a named material family within the configured global filters.
-
Field Details
-
DECAYING
-
-
Constructor Details
-
BlockPalette
Copies a non-empty list of prepared palette entries.- Parameters:
entries- matching candidates- Throws:
IllegalArgumentException- if no candidates are available
-
-
Method Details
-
load
public static BlockPalette load(Path file, Set<String> included, Set<String> excluded) throws Exception Loads and filters material colors using the current server material registry.- Parameters:
file- palette YAML fileincluded- exact allowlist; empty means all available entriesexcluded- exact material denylist- Returns:
- non-empty validated palette
- Throws:
Exception- if loading or palette validation fails
-
subset
Selects a named material family within the configured global filters.- Parameters:
name- all, concrete, wool or terracotta, ignoring case- Returns:
- this palette for all, or a new family palette
- Throws:
IllegalArgumentException- if the family is unknown or empty
-
nearest
Finds the closest representative color by squared Oklab distance.- Parameters:
rgb- packed sRGB sample- Returns:
- closest entry, with palette order breaking equal-distance ties
-
entries
Returns the unmodifiable candidate list.- Returns:
- entries; cached coordinate arrays must be treated as read-only
-