File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
paper-api/src/main/java/org/bukkit/map Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change 1111/**
1212 * Represents the palette that map items use.
1313 * <p>
14- * These fields are hee base color ranges. Each entry corresponds to four
14+ * These fields are the base color ranges. Each entry corresponds to four
1515 * colors of varying shades with values entry to entry + 3.
1616 */
1717public final class MapPalette {
@@ -27,7 +27,7 @@ private static double getDistance(@NotNull Color c1, @NotNull Color c2) {
2727 // All weights are 512x their original to avoid floating point division
2828 int weightR = 1024 + rsum ;
2929 int weightG = 2048 ;
30- int weightB = 1024 + (255 * 2 - rsum );
30+ int weightB = 1024 + (255 * 2 - rsum );
3131
3232 // Division by 256 here is unnecessary as this won't change the result of the sort
3333 return weightR * r * r + weightG * g * g + weightB * b * b ;
@@ -460,6 +460,18 @@ public static Color getColor(byte index) {
460460 return colors [index >= 0 ? index : index + 256 ];
461461 }
462462
463+ /**
464+ * Gets the closest {@link Color} in the map palette.
465+ *
466+ * @param color to match against the map palette
467+ * @return the nearest {@link Color} from the map palette
468+ */
469+ @ NotNull
470+ public static Color getNearestColor (@ NotNull Color color ) {
471+ byte b = matchColor (color );
472+ return getColor (b );
473+ }
474+
463475 private static MapColorCache mapColorCache ;
464476
465477 /**
You can’t perform that action at this time.
0 commit comments