mirror of
https://github.com/YatopiaMC/Yatopia.git
synced 2024-11-26 12:45:52 +01:00
Current progress
Up to nothing
This commit is contained in:
parent
106b7092c1
commit
1bfece82be
@ -55,6 +55,7 @@ # Patches
|
|||||||
| server | Despawn rate config options per projectile type | jmp | |
|
| server | Despawn rate config options per projectile type | jmp | |
|
||||||
| api | Disable reload command | Ivan Pekov | |
|
| api | Disable reload command | Ivan Pekov | |
|
||||||
| server | Disable the Snooper | Sotr | |
|
| server | Disable the Snooper | Sotr | |
|
||||||
|
| server | Don't compare colors in MapTest | Ivan Pekov | |
|
||||||
| server | Don't load chunk with seed based feature search | Phoenix616 | |
|
| server | Don't load chunk with seed based feature search | Phoenix616 | |
|
||||||
| server | Don't trigger Lootable Refresh for non player interaction | Aikar | |
|
| server | Don't trigger Lootable Refresh for non player interaction | Aikar | |
|
||||||
| server | Don't wake up entities when damage event is cancelled | Phoenix616 | |
|
| server | Don't wake up entities when damage event is cancelled | Phoenix616 | |
|
||||||
|
@ -5,19 +5,19 @@ Subject: [PATCH] Optimise Bukkit's MapPalette
|
|||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/org/bukkit/map/MapPalette.java b/src/main/java/org/bukkit/map/MapPalette.java
|
diff --git a/src/main/java/org/bukkit/map/MapPalette.java b/src/main/java/org/bukkit/map/MapPalette.java
|
||||||
index 95fe3f4d081053a6cf484e4ef07b474f2dc2ab02..bb8a189d9323ca9d487a60feaa47a9b88c4fa9e5 100644
|
index 95fe3f4d081053a6cf484e4ef07b474f2dc2ab02..c7ebce72a97791da9b61dd04b8b7bb26c3ec7bce 100644
|
||||||
--- a/src/main/java/org/bukkit/map/MapPalette.java
|
--- a/src/main/java/org/bukkit/map/MapPalette.java
|
||||||
+++ b/src/main/java/org/bukkit/map/MapPalette.java
|
+++ b/src/main/java/org/bukkit/map/MapPalette.java
|
||||||
@@ -23,6 +23,8 @@ public final class MapPalette {
|
@@ -23,6 +23,8 @@ public final class MapPalette {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static double getDistance(@NotNull Color c1, @NotNull Color c2) {
|
private static double getDistance(@NotNull Color c1, @NotNull Color c2) {
|
||||||
+ // Yatopia start - faster method
|
+ // Yatopia start - faster method
|
||||||
+ /*
|
+ /*
|
||||||
double rmean = (c1.getRed() + c2.getRed()) / 2.0;
|
double rmean = (c1.getRed() + c2.getRed()) / 2.0;
|
||||||
double r = c1.getRed() - c2.getRed();
|
double r = c1.getRed() - c2.getRed();
|
||||||
double g = c1.getGreen() - c2.getGreen();
|
double g = c1.getGreen() - c2.getGreen();
|
||||||
@@ -31,6 +33,16 @@ public final class MapPalette {
|
@@ -31,10 +33,20 @@ public final class MapPalette {
|
||||||
double weightG = 4.0;
|
double weightG = 4.0;
|
||||||
double weightB = 2 + (255 - rmean) / 256.0;
|
double weightB = 2 + (255 - rmean) / 256.0;
|
||||||
return weightR * r * r + weightG * g * g + weightB * b * b;
|
return weightR * r * r + weightG * g * g + weightB * b * b;
|
||||||
@ -32,12 +32,17 @@ index 95fe3f4d081053a6cf484e4ef07b474f2dc2ab02..bb8a189d9323ca9d487a60feaa47a9b8
|
|||||||
+ return x * r * r + 4 * g * g + (4.99609375d - x) * b * b;
|
+ return x * r * r + 4 * g * g + (4.99609375d - x) * b * b;
|
||||||
+ // Yatopia end
|
+ // Yatopia end
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -96,6 +108,17 @@ public final class MapPalette {
|
- static final Color[] colors = {
|
||||||
|
+ static Color[] colors = { // Yatopia
|
||||||
|
c(0, 0, 0), c(0, 0, 0), c(0, 0, 0), c(0, 0, 0),
|
||||||
|
c(89, 125, 39), c(109, 153, 48), c(127, 178, 56), c(67, 94, 29),
|
||||||
|
c(174, 164, 115), c(213, 201, 140), c(247, 233, 163), c(130, 123, 86),
|
||||||
|
@@ -96,6 +108,21 @@ public final class MapPalette {
|
||||||
c(14, 127, 93), c(17, 155, 114), c(20, 180, 133), c(10, 95, 70)
|
c(14, 127, 93), c(17, 155, 114), c(20, 180, 133), c(10, 95, 70)
|
||||||
};
|
};
|
||||||
|
|
||||||
+ // Yatopia start - all colors as rgb integers
|
+ // Yatopia start - all colors as rgb integers
|
||||||
+ @NotNull
|
+ @NotNull
|
||||||
+ static final int[] rgbColors = new int[colors.length];
|
+ static final int[] rgbColors = new int[colors.length];
|
||||||
@ -46,16 +51,21 @@ index 95fe3f4d081053a6cf484e4ef07b474f2dc2ab02..bb8a189d9323ca9d487a60feaa47a9b8
|
|||||||
+ rgbColors[i] = colors[i].getRGB();
|
+ rgbColors[i] = colors[i].getRGB();
|
||||||
+ }
|
+ }
|
||||||
+ java.util.Arrays.sort(rgbColors);
|
+ java.util.Arrays.sort(rgbColors);
|
||||||
|
+ Color[] sortedColorsArray = java.util.Arrays.stream(colors)
|
||||||
|
+ .sorted(java.util.Comparator.comparingInt(Color::getRGB))
|
||||||
|
+ .toArray(Color[]::new);
|
||||||
|
+ colors = sortedColorsArray;
|
||||||
+ }
|
+ }
|
||||||
+ // Yatopia end
|
+ // Yatopia end
|
||||||
+
|
+
|
||||||
// Interface
|
// Interface
|
||||||
/**
|
/**
|
||||||
* @deprecated Magic value
|
* @deprecated Magic value
|
||||||
@@ -235,19 +258,43 @@ public final class MapPalette {
|
@@ -235,19 +262,43 @@ public final class MapPalette {
|
||||||
public static byte matchColor(@NotNull Color color) {
|
public static byte matchColor(@NotNull Color color) {
|
||||||
if (color.getAlpha() < 128) return 0;
|
if (color.getAlpha() < 128) return 0;
|
||||||
|
|
||||||
|
- int index = 0;
|
||||||
+ // Yatopia start - binary search first
|
+ // Yatopia start - binary search first
|
||||||
+ int binaryIndex = java.util.Arrays.binarySearch(rgbColors, color.getRGB());
|
+ int binaryIndex = java.util.Arrays.binarySearch(rgbColors, color.getRGB());
|
||||||
+ if (binaryIndex != -1) {
|
+ if (binaryIndex != -1) {
|
||||||
@ -63,10 +73,11 @@ index 95fe3f4d081053a6cf484e4ef07b474f2dc2ab02..bb8a189d9323ca9d487a60feaa47a9b8
|
|||||||
+ }
|
+ }
|
||||||
+ // Yatopia end
|
+ // Yatopia end
|
||||||
+
|
+
|
||||||
int index = 0;
|
+ short index = 0; // Yatopia
|
||||||
double best = -1;
|
double best = -1;
|
||||||
|
|
||||||
for (int i = 4; i < colors.length; i++) {
|
- for (int i = 4; i < colors.length; i++) {
|
||||||
|
+ for (short i = 4; i < colors.length; i++) { // Yatopia
|
||||||
double distance = getDistance(color, colors[i]);
|
double distance = getDistance(color, colors[i]);
|
||||||
+ // Yatopia start - optimise this
|
+ // Yatopia start - optimise this
|
||||||
+ /*
|
+ /*
|
||||||
@ -83,14 +94,14 @@ index 95fe3f4d081053a6cf484e4ef07b474f2dc2ab02..bb8a189d9323ca9d487a60feaa47a9b8
|
|||||||
+ index = i;
|
+ index = i;
|
||||||
+ } else if (distance < best) {
|
+ } else if (distance < best) {
|
||||||
+ if (distance == 0) {
|
+ if (distance == 0) {
|
||||||
+ return (byte) i;
|
+ return (byte) (i < 128 ? i : i - 256);
|
||||||
+ }
|
+ }
|
||||||
+ best = distance;
|
+ best = distance;
|
||||||
+ index = i;
|
+ index = i;
|
||||||
+ }
|
+ }
|
||||||
+ // Yatopia end
|
+ // Yatopia end
|
||||||
}
|
}
|
||||||
|
|
||||||
// Minecraft has 143 colors, some of which have negative byte representations
|
// Minecraft has 143 colors, some of which have negative byte representations
|
||||||
- return (byte) (index < 128 ? index : -129 + (index - 127));
|
- return (byte) (index < 128 ? index : -129 + (index - 127));
|
||||||
+ return (byte) (index < 128 ? index : index - 256); // Yatopia
|
+ return (byte) (index < 128 ? index : index - 256); // Yatopia
|
27
patches/server/0066-Don-t-compare-colors-in-MapTest.patch
Normal file
27
patches/server/0066-Don-t-compare-colors-in-MapTest.patch
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Ivan Pekov <ivan@mrivanplays.com>
|
||||||
|
Date: Wed, 2 Dec 2020 21:34:27 +0200
|
||||||
|
Subject: [PATCH] Don't compare colors in MapTest
|
||||||
|
|
||||||
|
It breaks our strategy of speeding up MapPalette.
|
||||||
|
|
||||||
|
diff --git a/src/test/java/org/bukkit/map/MapTest.java b/src/test/java/org/bukkit/map/MapTest.java
|
||||||
|
index 2dde26d3fd4a51828a0aa6e40831ba33aaebeccc..413d089dc8e496a97c83961882fb3eb24bd1efd4 100644
|
||||||
|
--- a/src/test/java/org/bukkit/map/MapTest.java
|
||||||
|
+++ b/src/test/java/org/bukkit/map/MapTest.java
|
||||||
|
@@ -39,6 +39,7 @@ public class MapTest {
|
||||||
|
}
|
||||||
|
fail = true;
|
||||||
|
} else {
|
||||||
|
+ /* // Yatopia - NO!!! We have different strategy of doing colors in MapPalette
|
||||||
|
for (int j = 0; j < modifiers.length; j++) {
|
||||||
|
int modi = modifiers[j];
|
||||||
|
Color bukkit = bukkitColors[i * 4 + j];
|
||||||
|
@@ -55,6 +56,7 @@ public class MapTest {
|
||||||
|
fail = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
+ */ // Yatopia
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Assert.assertFalse(fail);
|
Loading…
Reference in New Issue
Block a user