mirror of
https://github.com/Dreeam-qwq/Gale.git
synced 2025-12-19 14:59:29 +00:00
Add first bootstrap patches
This commit is contained in:
26
patches/api/0001-Gale-configuration.patch
Normal file
26
patches/api/0001-Gale-configuration.patch
Normal file
@@ -0,0 +1,26 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MartijnMuijsers <martijnmuijsers@live.nl>
|
||||
Date: Wed, 23 Nov 2022 21:03:04 +0100
|
||||
Subject: [PATCH] Gale configuration
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
||||
index e43fef0152468944d8a33036344a43e95fe58476..5d03be9b9ff305aa46f9e2443750387dbc2e1623 100644
|
||||
--- a/src/main/java/org/bukkit/Server.java
|
||||
+++ b/src/main/java/org/bukkit/Server.java
|
||||
@@ -1967,6 +1967,15 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
+
|
||||
+ // Gale start - Gale configuration - API
|
||||
+ @NotNull
|
||||
+ public org.bukkit.configuration.file.YamlConfiguration getGaleConfig()
|
||||
+ {
|
||||
+ throw new UnsupportedOperationException("Not supported yet.");
|
||||
+ }
|
||||
+ // Gale end - Gale configuration - API
|
||||
+
|
||||
// Paper end
|
||||
|
||||
/**
|
||||
124
patches/api/0002-SIMD-support.patch
Normal file
124
patches/api/0002-SIMD-support.patch
Normal file
@@ -0,0 +1,124 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MartijnMuijsers <martijnmuijsers@live.nl>
|
||||
Date: Thu, 24 Nov 2022 01:21:32 +0100
|
||||
Subject: [PATCH] SIMD support
|
||||
|
||||
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
This patch is based on the following patch:
|
||||
"Add SIMD utilities"
|
||||
By: Kevin Raneri <kevin.raneri@gmail.com>
|
||||
As part of: Pufferfish (https://github.com/pufferfish-gg/Pufferfish)
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||
index 9f5694204091e23c4771657127a06f98e27ad8f1..27aa04782d9c5aecdcbbe0314dd5be1a076b4f50 100644
|
||||
--- a/build.gradle.kts
|
||||
+++ b/build.gradle.kts
|
||||
@@ -83,6 +83,13 @@ val generateApiVersioningFile by tasks.registering {
|
||||
}
|
||||
}
|
||||
|
||||
+// Gale start - Pufferfish - SIMD support
|
||||
+tasks.withType<JavaCompile> {
|
||||
+ val compilerArgs = options.compilerArgs
|
||||
+ compilerArgs.add("--add-modules=jdk.incubator.vector")
|
||||
+}
|
||||
+// Gale end - Pufferfish - SIMD support
|
||||
+
|
||||
tasks.jar {
|
||||
from(generateApiVersioningFile.map { it.outputs.files.singleFile }) {
|
||||
into("META-INF/maven/${project.group}/${project.name}")
|
||||
diff --git a/src/main/java/gg/pufferfish/pufferfish/simd/SIMDChecker.java b/src/main/java/gg/pufferfish/pufferfish/simd/SIMDChecker.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..22f20b934c0481c27248a808535987176216f400
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/gg/pufferfish/pufferfish/simd/SIMDChecker.java
|
||||
@@ -0,0 +1,44 @@
|
||||
+// Gale - Pufferfish - SIMD support
|
||||
+
|
||||
+package gg.pufferfish.pufferfish.simd;
|
||||
+
|
||||
+import jdk.incubator.vector.FloatVector;
|
||||
+import jdk.incubator.vector.IntVector;
|
||||
+import jdk.incubator.vector.VectorSpecies;
|
||||
+
|
||||
+import org.slf4j.Logger;
|
||||
+
|
||||
+/**
|
||||
+ * Basically, java is annoying and we have to push this out to its own class.
|
||||
+ */
|
||||
+@Deprecated
|
||||
+public class SIMDChecker {
|
||||
+
|
||||
+ @Deprecated
|
||||
+ public static boolean canEnable(Logger logger, boolean logVectorSizesToConsole) {
|
||||
+ try {
|
||||
+ if (SIMDDetection.getJavaVersion() != 17 && SIMDDetection.getJavaVersion() != 18) {
|
||||
+ return false;
|
||||
+ } else {
|
||||
+ SIMDDetection.testRun = true;
|
||||
+
|
||||
+ VectorSpecies<Integer> ISPEC = IntVector.SPECIES_PREFERRED;
|
||||
+ VectorSpecies<Float> FSPEC = FloatVector.SPECIES_PREFERRED;
|
||||
+
|
||||
+ if (logVectorSizesToConsole) {
|
||||
+ logger.info("Max SIMD vector size on this system is " + ISPEC.vectorBitSize() + " bits (int)");
|
||||
+ logger.info("Max SIMD vector size on this system is " + FSPEC.vectorBitSize() + " bits (float)");
|
||||
+ }
|
||||
+
|
||||
+ if (ISPEC.elementSize() < 2 || FSPEC.elementSize() < 2) {
|
||||
+ SIMDDetection.unsupportingLaneSize = true;
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ return true;
|
||||
+ }
|
||||
+ } catch (NoClassDefFoundError | Exception ignored) {} // Basically, we don't do anything. This lets us detect if it's not functional and disable it.
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
diff --git a/src/main/java/gg/pufferfish/pufferfish/simd/SIMDDetection.java b/src/main/java/gg/pufferfish/pufferfish/simd/SIMDDetection.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..5eca1f3099401bebab322953771a232e532bee11
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/gg/pufferfish/pufferfish/simd/SIMDDetection.java
|
||||
@@ -0,0 +1,37 @@
|
||||
+// Gale - Pufferfish - SIMD support
|
||||
+
|
||||
+package gg.pufferfish.pufferfish.simd;
|
||||
+
|
||||
+import org.slf4j.Logger;
|
||||
+
|
||||
+@Deprecated
|
||||
+public class SIMDDetection {
|
||||
+
|
||||
+ public static boolean isEnabled = false;
|
||||
+ public static boolean testRun = false;
|
||||
+ public static boolean unsupportingLaneSize = false;
|
||||
+
|
||||
+ @Deprecated
|
||||
+ public static boolean canEnable(Logger logger, boolean logVectorSizesToConsole) {
|
||||
+ try {
|
||||
+ return SIMDChecker.canEnable(logger, logVectorSizesToConsole);
|
||||
+ } catch (NoClassDefFoundError | Exception ignored) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Deprecated
|
||||
+ public static int getJavaVersion() {
|
||||
+ // https://stackoverflow.com/a/2591122
|
||||
+ String version = System.getProperty("java.version");
|
||||
+ if(version.startsWith("1.")) {
|
||||
+ version = version.substring(2, 3);
|
||||
+ } else {
|
||||
+ int dot = version.indexOf(".");
|
||||
+ if(dot != -1) { version = version.substring(0, dot); }
|
||||
+ }
|
||||
+ version = version.split("-")[0]; // Azul is stupid
|
||||
+ return Integer.parseInt(version);
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
148
patches/api/0003-Vectorized-map-color-conversion.patch
Normal file
148
patches/api/0003-Vectorized-map-color-conversion.patch
Normal file
@@ -0,0 +1,148 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MartijnMuijsers <martijnmuijsers@live.nl>
|
||||
Date: Thu, 24 Nov 2022 17:03:21 +0100
|
||||
Subject: [PATCH] Vectorized map color conversion
|
||||
|
||||
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
This patch is based on the following patch:
|
||||
"Optimize map rendering"
|
||||
By: Kevin Raneri <kevin.raneri@gmail.com>
|
||||
As part of: Pufferfish (https://github.com/pufferfish-gg/Pufferfish)
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
* Pufferfish description *
|
||||
|
||||
This patch does not add any API that should be used by plugins. Any
|
||||
classes and methods added by this patch should NOT be used in plugins.
|
||||
|
||||
diff --git a/src/main/java/gg/pufferfish/pufferfish/simd/VectorMapPalette.java b/src/main/java/gg/pufferfish/pufferfish/simd/VectorMapPalette.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..ed7671eae309a0c72957bd8c9dc8a0de480e2bf6
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/gg/pufferfish/pufferfish/simd/VectorMapPalette.java
|
||||
@@ -0,0 +1,86 @@
|
||||
+// Gale - Pufferfish - vectorize map color conversion
|
||||
+
|
||||
+package gg.pufferfish.pufferfish.simd;
|
||||
+
|
||||
+import jdk.incubator.vector.FloatVector;
|
||||
+import jdk.incubator.vector.IntVector;
|
||||
+import jdk.incubator.vector.VectorMask;
|
||||
+import jdk.incubator.vector.VectorSpecies;
|
||||
+import org.bukkit.map.MapPalette;
|
||||
+
|
||||
+import java.awt.*;
|
||||
+
|
||||
+@Deprecated
|
||||
+public class VectorMapPalette {
|
||||
+
|
||||
+ private static final VectorSpecies<Integer> I_SPEC = IntVector.SPECIES_PREFERRED;
|
||||
+ private static final VectorSpecies<Float> F_SPEC = FloatVector.SPECIES_PREFERRED;
|
||||
+
|
||||
+ @Deprecated
|
||||
+ public static void matchColorVectorized(int[] in, byte[] out) {
|
||||
+ int speciesLength = I_SPEC.length();
|
||||
+ int i;
|
||||
+ for (i = 0; i < in.length - speciesLength; i += speciesLength) {
|
||||
+ float[] redsArr = new float[speciesLength];
|
||||
+ float[] bluesArr = new float[speciesLength];
|
||||
+ float[] greensArr = new float[speciesLength];
|
||||
+ int[] alphasArr = new int[speciesLength];
|
||||
+
|
||||
+ for (int j = 0; j < speciesLength; j++) {
|
||||
+ alphasArr[j] = (in[i + j] >> 24) & 0xFF;
|
||||
+ redsArr[j] = (in[i + j] >> 16) & 0xFF;
|
||||
+ greensArr[j] = (in[i + j] >> 8) & 0xFF;
|
||||
+ bluesArr[j] = (in[i + j] >> 0) & 0xFF;
|
||||
+ }
|
||||
+
|
||||
+ IntVector alphas = IntVector.fromArray(I_SPEC, alphasArr, 0);
|
||||
+ FloatVector reds = FloatVector.fromArray(F_SPEC, redsArr, 0);
|
||||
+ FloatVector greens = FloatVector.fromArray(F_SPEC, greensArr, 0);
|
||||
+ FloatVector blues = FloatVector.fromArray(F_SPEC, bluesArr, 0);
|
||||
+ IntVector resultIndex = IntVector.zero(I_SPEC);
|
||||
+ VectorMask<Integer> modificationMask = VectorMask.fromLong(I_SPEC, 0xffffffff);
|
||||
+
|
||||
+ modificationMask = modificationMask.and(alphas.lt(128).not());
|
||||
+ FloatVector bestDistances = FloatVector.broadcast(F_SPEC, Float.MAX_VALUE);
|
||||
+
|
||||
+ for (int c = 4; c < MapPalette.colors.length; c++) {
|
||||
+ // We're using 32-bit floats here because it's 2x faster and nobody will know the difference.
|
||||
+ // For correctness, the original algorithm uses 64-bit floats instead. Completely unnecessary.
|
||||
+ FloatVector compReds = FloatVector.broadcast(F_SPEC, MapPalette.colors[c].getRed());
|
||||
+ FloatVector compGreens = FloatVector.broadcast(F_SPEC, MapPalette.colors[c].getGreen());
|
||||
+ FloatVector compBlues = FloatVector.broadcast(F_SPEC, MapPalette.colors[c].getBlue());
|
||||
+
|
||||
+ FloatVector rMean = reds.add(compReds).div(2.0f);
|
||||
+ FloatVector rDiff = reds.sub(compReds);
|
||||
+ FloatVector gDiff = greens.sub(compGreens);
|
||||
+ FloatVector bDiff = blues.sub(compBlues);
|
||||
+
|
||||
+ FloatVector weightR = rMean.div(256.0f).add(2);
|
||||
+ FloatVector weightG = FloatVector.broadcast(F_SPEC, 4.0f);
|
||||
+ FloatVector weightB = FloatVector.broadcast(F_SPEC, 255.0f).sub(rMean).div(256.0f).add(2.0f);
|
||||
+
|
||||
+ FloatVector distance = weightR.mul(rDiff).mul(rDiff).add(weightG.mul(gDiff).mul(gDiff)).add(weightB.mul(bDiff).mul(bDiff));
|
||||
+
|
||||
+ // Now we compare to the best distance we've found.
|
||||
+ // This mask contains a "1" if better, and a "0" otherwise.
|
||||
+ VectorMask<Float> bestDistanceMask = distance.lt(bestDistances);
|
||||
+ bestDistances = bestDistances.blend(distance, bestDistanceMask); // Update the best distances
|
||||
+
|
||||
+ // Update the result array
|
||||
+ // We also AND with the modification mask because we don't want to interfere if the alpha value isn't large enough.
|
||||
+ resultIndex = resultIndex.blend(c, bestDistanceMask.cast(I_SPEC).and(modificationMask)); // Update the results
|
||||
+ }
|
||||
+
|
||||
+ for (int j = 0; j < speciesLength; j++) {
|
||||
+ int index = resultIndex.lane(j);
|
||||
+ out[i + j] = (byte) (index < 128 ? index : -129 + (index - 127));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // For the final ones, fall back to the regular method
|
||||
+ for (; i < in.length; i++) {
|
||||
+ out[i] = MapPalette.matchColor(new Color(in[i], true));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
diff --git a/src/main/java/org/bukkit/map/MapPalette.java b/src/main/java/org/bukkit/map/MapPalette.java
|
||||
index 3a9aaca2e76411a9c27f9f5e0f22d060d5a66d06..b21c4b9c379951f749b5b1db81f94d2c504d31d2 100644
|
||||
--- a/src/main/java/org/bukkit/map/MapPalette.java
|
||||
+++ b/src/main/java/org/bukkit/map/MapPalette.java
|
||||
@@ -5,6 +5,8 @@ import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Image;
|
||||
import java.awt.image.BufferedImage;
|
||||
+
|
||||
+import gg.pufferfish.pufferfish.simd.SIMDDetection;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -40,7 +42,7 @@ public final class MapPalette {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
- static final Color[] colors = {
|
||||
+ public static final Color[] colors = { // Gale - Pufferfish - vectorized map color conversion - package -> public
|
||||
c(0, 0, 0, 0), c(0, 0, 0, 0), c(0, 0, 0, 0), c(0, 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),
|
||||
@@ -211,9 +213,15 @@ public final class MapPalette {
|
||||
temp.getRGB(0, 0, temp.getWidth(), temp.getHeight(), pixels, 0, temp.getWidth());
|
||||
|
||||
byte[] result = new byte[temp.getWidth() * temp.getHeight()];
|
||||
+ if (!SIMDDetection.isEnabled) { // Gale - Pufferfish - vectorized map color conversion
|
||||
for (int i = 0; i < pixels.length; i++) {
|
||||
result[i] = matchColor(new Color(pixels[i], true));
|
||||
}
|
||||
+ // Gale start - Pufferfish - vectorized map color conversion
|
||||
+ } else {
|
||||
+ gg.pufferfish.pufferfish.simd.VectorMapPalette.matchColorVectorized(pixels, result);
|
||||
+ }
|
||||
+ // Gale end - Pufferfish - vectorized map color conversion
|
||||
return result;
|
||||
}
|
||||
|
||||
542
patches/server/0002-Gale-branding-changes.patch
Normal file
542
patches/server/0002-Gale-branding-changes.patch
Normal file
@@ -0,0 +1,542 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MartijnMuijsers <martijnmuijsers@live.nl>
|
||||
Date: Wed, 23 Nov 2022 15:34:33 +0100
|
||||
Subject: [PATCH] Gale branding changes
|
||||
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/Metrics.java b/src/main/java/com/destroystokyo/paper/Metrics.java
|
||||
index 7b1843e16745ca8db2244e17490d291401f22679..20fa3302f9b3153e24033feb2d05f0b22b0efeb3 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/Metrics.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/Metrics.java
|
||||
@@ -593,7 +593,7 @@ public class Metrics {
|
||||
boolean logFailedRequests = config.getBoolean("logFailedRequests", false);
|
||||
// Only start Metrics, if it's enabled in the config
|
||||
if (config.getBoolean("enabled", true)) {
|
||||
- Metrics metrics = new Metrics("Paper", serverUUID, logFailedRequests, Bukkit.getLogger());
|
||||
+ Metrics metrics = new Metrics("Paper", serverUUID, logFailedRequests, Bukkit.getLogger()); // Gale - branding changes - TODO - make Gale (register with bStats)
|
||||
|
||||
metrics.addCustomChart(new Metrics.SimplePie("minecraft_version", () -> {
|
||||
String minecraftVersion = Bukkit.getVersion();
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
|
||||
index bf42969859545a8a520923ef1836ffa4a5cc24a0..91e97c57c3202f84986ec4d9cb1a374fd5256eac 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java
|
||||
@@ -1,85 +1,40 @@
|
||||
package com.destroystokyo.paper;
|
||||
|
||||
-import com.destroystokyo.paper.util.VersionFetcher;
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.io.Resources;
|
||||
-import com.google.gson.*;
|
||||
-import net.kyori.adventure.text.Component;
|
||||
-import net.kyori.adventure.text.event.ClickEvent;
|
||||
-import net.kyori.adventure.text.format.NamedTextColor;
|
||||
-import net.kyori.adventure.text.format.TextDecoration;
|
||||
-import net.kyori.adventure.text.TextComponent;
|
||||
+import com.google.gson.Gson;
|
||||
+import com.google.gson.JsonArray;
|
||||
+import com.google.gson.JsonObject;
|
||||
+import com.google.gson.JsonSyntaxException;
|
||||
+import org.galemc.gale.version.AbstractPaperVersionFetcher;
|
||||
|
||||
-import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
-import java.io.*;
|
||||
-import java.net.HttpURLConnection;
|
||||
+import java.io.BufferedReader;
|
||||
+import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
-public class PaperVersionFetcher implements VersionFetcher {
|
||||
- private static final java.util.regex.Pattern VER_PATTERN = java.util.regex.Pattern.compile("^([0-9\\.]*)\\-.*R"); // R is an anchor, will always give '-R' at end
|
||||
- private static final String GITHUB_BRANCH_NAME = "master";
|
||||
- private static final String DOWNLOAD_PAGE = "https://papermc.io/downloads";
|
||||
- private static @Nullable String mcVer;
|
||||
+// Gale start - branding changes - version fetcher
|
||||
+/**
|
||||
+ * The original version fetcher for Paper. Most of the original content of this class has been moved to
|
||||
+ * {@link AbstractPaperVersionFetcher}.
|
||||
+ */
|
||||
+public class PaperVersionFetcher extends AbstractPaperVersionFetcher {
|
||||
|
||||
- @Override
|
||||
- public long getCacheTime() {
|
||||
- return 720000;
|
||||
+ public PaperVersionFetcher() {
|
||||
+ super("master", "https://papermc.io/downloads", "Paper", "PaperMC", "PaperMC", "Paper");
|
||||
}
|
||||
|
||||
- @Nonnull
|
||||
@Override
|
||||
- public Component getVersionMessage(@Nonnull String serverVersion) {
|
||||
- String[] parts = serverVersion.substring("git-Paper-".length()).split("[-\\s]");
|
||||
- final Component updateMessage = getUpdateStatusMessage("PaperMC/Paper", GITHUB_BRANCH_NAME, parts[0]);
|
||||
- final Component history = getHistory();
|
||||
-
|
||||
- return history != null ? TextComponent.ofChildren(updateMessage, Component.newline(), history) : updateMessage;
|
||||
- }
|
||||
-
|
||||
- private static @Nullable String getMinecraftVersion() {
|
||||
- if (mcVer == null) {
|
||||
- java.util.regex.Matcher matcher = VER_PATTERN.matcher(org.bukkit.Bukkit.getBukkitVersion());
|
||||
- if (matcher.find()) {
|
||||
- String result = matcher.group();
|
||||
- mcVer = result.substring(0, result.length() - 2); // strip 'R' anchor and trailing '-'
|
||||
- } else {
|
||||
- org.bukkit.Bukkit.getLogger().warning("Unable to match version to pattern! Report to PaperMC!");
|
||||
- org.bukkit.Bukkit.getLogger().warning("Pattern: " + VER_PATTERN.toString());
|
||||
- org.bukkit.Bukkit.getLogger().warning("Version: " + org.bukkit.Bukkit.getBukkitVersion());
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- return mcVer;
|
||||
+ protected boolean canFetchDistanceFromSiteApi() {
|
||||
+ return true;
|
||||
}
|
||||
|
||||
- private static Component getUpdateStatusMessage(@Nonnull String repo, @Nonnull String branch, @Nonnull String versionInfo) {
|
||||
- int distance;
|
||||
- try {
|
||||
- int jenkinsBuild = Integer.parseInt(versionInfo);
|
||||
- distance = fetchDistanceFromSiteApi(jenkinsBuild, getMinecraftVersion());
|
||||
- } catch (NumberFormatException ignored) {
|
||||
- versionInfo = versionInfo.replace("\"", "");
|
||||
- distance = fetchDistanceFromGitHub(repo, branch, versionInfo);
|
||||
- }
|
||||
-
|
||||
- switch (distance) {
|
||||
- case -1:
|
||||
- return Component.text("Error obtaining version information", NamedTextColor.YELLOW);
|
||||
- case 0:
|
||||
- return Component.text("You are running the latest version", NamedTextColor.GREEN);
|
||||
- case -2:
|
||||
- return Component.text("Unknown version", NamedTextColor.YELLOW);
|
||||
- default:
|
||||
- return Component.text("You are " + distance + " version(s) behind", NamedTextColor.YELLOW)
|
||||
- .append(Component.newline())
|
||||
- .append(Component.text("Download the new version at: ")
|
||||
- .append(Component.text(DOWNLOAD_PAGE, NamedTextColor.GOLD)
|
||||
- .hoverEvent(Component.text("Click to open", NamedTextColor.WHITE))
|
||||
- .clickEvent(ClickEvent.openUrl(DOWNLOAD_PAGE))));
|
||||
- }
|
||||
+ @Override
|
||||
+ protected int fetchDistanceFromSiteApi(int jenkinsBuild) {
|
||||
+ return fetchDistanceFromSiteApi(jenkinsBuild, this.getMinecraftVersion());
|
||||
}
|
||||
+ // Gale end - branding changes - version fetcher
|
||||
|
||||
private static int fetchDistanceFromSiteApi(int jenkinsBuild, @Nullable String siteApiVersion) {
|
||||
if (siteApiVersion == null) { return -1; }
|
||||
@@ -105,45 +60,4 @@ public class PaperVersionFetcher implements VersionFetcher {
|
||||
}
|
||||
}
|
||||
|
||||
- // Contributed by Techcable <Techcable@outlook.com> in GH-65
|
||||
- private static int fetchDistanceFromGitHub(@Nonnull String repo, @Nonnull String branch, @Nonnull String hash) {
|
||||
- try {
|
||||
- HttpURLConnection connection = (HttpURLConnection) new URL("https://api.github.com/repos/" + repo + "/compare/" + branch + "..." + hash).openConnection();
|
||||
- connection.connect();
|
||||
- if (connection.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) return -2; // Unknown commit
|
||||
- try (BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), Charsets.UTF_8))) {
|
||||
- JsonObject obj = new Gson().fromJson(reader, JsonObject.class);
|
||||
- String status = obj.get("status").getAsString();
|
||||
- switch (status) {
|
||||
- case "identical":
|
||||
- return 0;
|
||||
- case "behind":
|
||||
- return obj.get("behind_by").getAsInt();
|
||||
- default:
|
||||
- return -1;
|
||||
- }
|
||||
- } catch (JsonSyntaxException | NumberFormatException e) {
|
||||
- e.printStackTrace();
|
||||
- return -1;
|
||||
- }
|
||||
- } catch (IOException e) {
|
||||
- e.printStackTrace();
|
||||
- return -1;
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- @Nullable
|
||||
- private Component getHistory() {
|
||||
- final VersionHistoryManager.VersionData data = VersionHistoryManager.INSTANCE.getVersionData();
|
||||
- if (data == null) {
|
||||
- return null;
|
||||
- }
|
||||
-
|
||||
- final String oldVersion = data.getOldVersion();
|
||||
- if (oldVersion == null) {
|
||||
- return null;
|
||||
- }
|
||||
-
|
||||
- return Component.text("Previous version: " + oldVersion, NamedTextColor.GRAY, TextDecoration.ITALIC);
|
||||
- }
|
||||
}
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/console/PaperConsole.java b/src/main/java/com/destroystokyo/paper/console/PaperConsole.java
|
||||
index c5d5648f4ca603ef2b1df723b58f9caf4dd3c722..dc5557fb3682934fee31ac2b7d6a3f244049e62d 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/console/PaperConsole.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/console/PaperConsole.java
|
||||
@@ -17,7 +17,7 @@ public final class PaperConsole extends SimpleTerminalConsole {
|
||||
@Override
|
||||
protected LineReader buildReader(LineReaderBuilder builder) {
|
||||
builder
|
||||
- .appName("Paper")
|
||||
+ .appName("Gale") // Gale - branding changes
|
||||
.variable(LineReader.HISTORY_FILE, java.nio.file.Paths.get(".console_history"))
|
||||
.completer(new ConsoleCommandCompleter(this.server))
|
||||
.option(LineReader.Option.COMPLETE_IN_WORD, true);
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index 6dc6c3bccb4ba34268a87b0754c87eb1e0df4135..5bfeb649336f023d05392c07d040299c605133c8 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -921,7 +921,13 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
shutdownThread = Thread.currentThread();
|
||||
org.spigotmc.WatchdogThread.doStop(); // Paper
|
||||
if (!isSameThread()) {
|
||||
- MinecraftServer.LOGGER.info("Stopping main thread (Ignore any thread death message you see! - DO NOT REPORT THREAD DEATH TO PAPER)");
|
||||
+ // Gale start - branding changes
|
||||
+ /*
|
||||
+ We do not want people to report thread issues to Paper,
|
||||
+ but we do want people to report thread issues to Gale.
|
||||
+ */
|
||||
+ MinecraftServer.LOGGER.info("Stopping main thread (Ignore any thread death message you see! - DO NOT REPORT THREAD DEATH TO PAPER - If you think this is a Gale bug, please report it at https://github.com/GaleMC/Gale/issues )");
|
||||
+ // Gale end - branding changes
|
||||
while (this.getRunningThread().isAlive()) {
|
||||
this.getRunningThread().stop();
|
||||
try {
|
||||
@@ -1654,7 +1660,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
|
||||
@DontObfuscate
|
||||
public String getServerModName() {
|
||||
- return "Paper"; // Paper - Paper > // Spigot - Spigot > // CraftBukkit - cb > vanilla!
|
||||
+ return "Gale"; // Gale - branding changes - Gale > // Paper - Paper > // Spigot - Spigot > // CraftBukkit - cb > vanilla!
|
||||
}
|
||||
|
||||
public SystemReport fillSystemReport(SystemReport details) {
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 07eac5439164a7345476c55277538a152359630a..e41e390a2eaf7f9dc489304db3e499d5055e7cff 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -248,7 +248,7 @@ import javax.annotation.Nullable; // Paper
|
||||
import javax.annotation.Nonnull; // Paper
|
||||
|
||||
public final class CraftServer implements Server {
|
||||
- private final String serverName = "Paper"; // Paper
|
||||
+ private final String serverName = "Gale"; // Paper // Gale - branding changes
|
||||
private final String serverVersion;
|
||||
private final String bukkitVersion = Versioning.getBukkitVersion();
|
||||
private final Logger logger = Logger.getLogger("Minecraft");
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
|
||||
index cdefb2025eedea7e204d70d568adaf1c1ec4c03c..d9c1047df7f7bbe6d89c1cfd57711de6d224c0d6 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
|
||||
@@ -504,7 +504,7 @@ public class CraftScheduler implements BukkitScheduler {
|
||||
this.parsePending();
|
||||
} else {
|
||||
//this.debugTail = this.debugTail.setNext(new CraftAsyncDebugger(currentTick + CraftScheduler.RECENT_TICKS, task.getOwner(), task.getTaskClass())); // Paper
|
||||
- task.getOwner().getLogger().log(Level.SEVERE, "Unexpected Async Task in the Sync Scheduler. Report this to Paper"); // Paper
|
||||
+ task.getOwner().getLogger().log(Level.SEVERE, "Unexpected Async Task in the Sync Scheduler. Report this to Gale"); // Paper // Gale - branding changes
|
||||
// We don't need to parse pending
|
||||
// (async tasks must live with race-conditions if they attempt to cancel between these few lines of code)
|
||||
}
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
index 103ab25119bfcdd21eac7e1deeac025108e3c138..7819f7d3b0dd766cd8b53b654937d9e34d316086 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
|
||||
@@ -435,7 +435,7 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
||||
|
||||
@Override
|
||||
public com.destroystokyo.paper.util.VersionFetcher getVersionFetcher() {
|
||||
- return new com.destroystokyo.paper.PaperVersionFetcher();
|
||||
+ return new org.galemc.gale.version.GaleVersionFetcher(); // Gale - branding changes - version fetcher
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java b/src/main/java/org/bukkit/craftbukkit/util/Versioning.java
|
||||
index 774556a62eb240da42e84db4502e2ed43495be17..a10b3d4484a3ce3ec0ea5eb49d89497fcc9e955e 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/util/Versioning.java
|
||||
@@ -11,7 +11,7 @@ public final class Versioning {
|
||||
public static String getBukkitVersion() {
|
||||
String result = "Unknown-Version";
|
||||
|
||||
- InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("META-INF/maven/io.papermc.paper/paper-api/pom.properties");
|
||||
+ InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("META-INF/maven/org.galemc.gale/gale-api/pom.properties"); // Gale - branding changes
|
||||
Properties properties = new Properties();
|
||||
|
||||
if (stream != null) {
|
||||
diff --git a/src/main/java/org/galemc/gale/version/AbstractPaperVersionFetcher.java b/src/main/java/org/galemc/gale/version/AbstractPaperVersionFetcher.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..11404abc8891ef4a0340fd4006d32c66769bee59
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/galemc/gale/version/AbstractPaperVersionFetcher.java
|
||||
@@ -0,0 +1,179 @@
|
||||
+// Gale - branding changes - version fetcher
|
||||
+
|
||||
+package org.galemc.gale.version;
|
||||
+
|
||||
+import com.destroystokyo.paper.PaperVersionFetcher;
|
||||
+import com.destroystokyo.paper.VersionHistoryManager;
|
||||
+import com.destroystokyo.paper.util.VersionFetcher;
|
||||
+import com.google.common.base.Charsets;
|
||||
+import com.google.gson.Gson;
|
||||
+import com.google.gson.JsonObject;
|
||||
+import com.google.gson.JsonSyntaxException;
|
||||
+import net.kyori.adventure.text.Component;
|
||||
+import net.kyori.adventure.text.TextComponent;
|
||||
+import net.kyori.adventure.text.event.ClickEvent;
|
||||
+import net.kyori.adventure.text.format.NamedTextColor;
|
||||
+import net.kyori.adventure.text.format.TextDecoration;
|
||||
+
|
||||
+import javax.annotation.Nonnull;
|
||||
+import javax.annotation.Nullable;
|
||||
+import java.io.BufferedReader;
|
||||
+import java.io.IOException;
|
||||
+import java.io.InputStreamReader;
|
||||
+import java.net.HttpURLConnection;
|
||||
+import java.net.URL;
|
||||
+
|
||||
+/**
|
||||
+ * An abstract version fetcher, derived from {@link PaperVersionFetcher}.
|
||||
+ * This class was then made to be a superclass of both {@link PaperVersionFetcher}
|
||||
+ * and {@link GaleVersionFetcher}.
|
||||
+ * <br>
|
||||
+ * Changes to {@link PaperVersionFetcher} are indicated by Gale marker comments.
|
||||
+ */
|
||||
+public abstract class AbstractPaperVersionFetcher implements VersionFetcher {
|
||||
+ private static final java.util.regex.Pattern VER_PATTERN = java.util.regex.Pattern.compile("^([0-9\\.]*)\\-.*R"); // R is an anchor, will always give '-R' at end
|
||||
+ private static @Nullable String mcVer;
|
||||
+
|
||||
+ // Gale start - branding changes - version fetcher
|
||||
+
|
||||
+ protected final String gitHubBranchName;
|
||||
+ protected final String downloadPage;
|
||||
+ protected final String projectDisplayName;
|
||||
+ protected final String organizationDisplayName;
|
||||
+ protected final String gitHubOrganizationName;
|
||||
+ protected final String gitHubRepoName;
|
||||
+
|
||||
+ protected AbstractPaperVersionFetcher(String githubBranchName, String downloadPage, String projectDisplayName, String organizationDisplayName, String gitHubOrganizationName, String gitHubRepoName) {
|
||||
+ this.gitHubBranchName = githubBranchName;
|
||||
+ this.downloadPage = downloadPage;
|
||||
+ this.projectDisplayName = projectDisplayName;
|
||||
+ this.organizationDisplayName = organizationDisplayName;
|
||||
+ this.gitHubOrganizationName = gitHubOrganizationName;
|
||||
+ this.gitHubRepoName = gitHubRepoName;
|
||||
+ }
|
||||
+
|
||||
+ // Gale end - branding changes - version fetcher
|
||||
+
|
||||
+ @Override
|
||||
+ public long getCacheTime() {
|
||||
+ return 720000;
|
||||
+ }
|
||||
+
|
||||
+ @Nonnull
|
||||
+ @Override
|
||||
+ public Component getVersionMessage(@Nonnull String serverVersion) {
|
||||
+ // Gale start - branding changes - version fetcher
|
||||
+ String[] parts = serverVersion.substring(("git-" + this.projectDisplayName + "-").length()).split("[-\\s]");
|
||||
+ final Component updateMessage = getUpdateStatusMessage(this.gitHubOrganizationName + "/" + this.gitHubRepoName, this.gitHubBranchName, parts[0]);
|
||||
+ // Gale end - branding changes - version fetcher
|
||||
+ final Component history = getHistory();
|
||||
+
|
||||
+ return history != null ? TextComponent.ofChildren(updateMessage, Component.newline(), history) : updateMessage;
|
||||
+ }
|
||||
+
|
||||
+ protected @Nullable String getMinecraftVersion() { // Gale - branding changes - version fetcher
|
||||
+ if (mcVer == null) {
|
||||
+ java.util.regex.Matcher matcher = VER_PATTERN.matcher(org.bukkit.Bukkit.getBukkitVersion());
|
||||
+ if (matcher.find()) {
|
||||
+ String result = matcher.group();
|
||||
+ mcVer = result.substring(0, result.length() - 2); // strip 'R' anchor and trailing '-'
|
||||
+ } else {
|
||||
+ org.bukkit.Bukkit.getLogger().warning("Unable to match version to pattern! Report to " + this.organizationDisplayName + "!"); // Gale - branding changes - version fetcher
|
||||
+ org.bukkit.Bukkit.getLogger().warning("Pattern: " + VER_PATTERN.toString());
|
||||
+ org.bukkit.Bukkit.getLogger().warning("Version: " + org.bukkit.Bukkit.getBukkitVersion());
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return mcVer;
|
||||
+ }
|
||||
+
|
||||
+ // Gale start - branding changes - version fetcher
|
||||
+
|
||||
+ protected boolean canFetchDistanceFromSiteApi() {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ protected int fetchDistanceFromSiteApi(int jenkinsBuild) {
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ // Gale end - branding changes - version fetcher
|
||||
+
|
||||
+ private Component getUpdateStatusMessage(@Nonnull String repo, @Nonnull String branch, @Nonnull String versionInfo) {
|
||||
+ // Gale start - branding changes - version fetcher
|
||||
+ int distance = -1;
|
||||
+ boolean readFromSiteApi = false;
|
||||
+ if (this.canFetchDistanceFromSiteApi()) {
|
||||
+ // Gale end - branding changes - version fetcher
|
||||
+ try {
|
||||
+ int jenkinsBuild = Integer.parseInt(versionInfo);
|
||||
+ // Gale start - branding changes - version fetcher
|
||||
+ distance = this.fetchDistanceFromSiteApi(jenkinsBuild);
|
||||
+ readFromSiteApi = true;
|
||||
+ } catch (NumberFormatException ignored) {}
|
||||
+ }
|
||||
+ if (!readFromSiteApi) {
|
||||
+ // Gale end - branding changes - version fetcher
|
||||
+ versionInfo = versionInfo.replace("\"", "");
|
||||
+ distance = fetchDistanceFromGitHub(repo, branch, versionInfo);
|
||||
+ }
|
||||
+
|
||||
+ switch (distance) {
|
||||
+ case -1:
|
||||
+ return Component.text("Error obtaining version information", NamedTextColor.YELLOW);
|
||||
+ case 0:
|
||||
+ return Component.text("You are running the latest version", NamedTextColor.GREEN);
|
||||
+ case -2:
|
||||
+ return Component.text("Unknown version", NamedTextColor.YELLOW);
|
||||
+ default:
|
||||
+ return Component.text("You are " + distance + " version(s) behind", NamedTextColor.YELLOW)
|
||||
+ .append(Component.newline())
|
||||
+ .append(Component.text("Download the new version at: ")
|
||||
+ .append(Component.text(this.downloadPage, NamedTextColor.GOLD) // Gale - branding changes - version fetcher
|
||||
+ .hoverEvent(Component.text("Click to open", NamedTextColor.WHITE))
|
||||
+ .clickEvent(ClickEvent.openUrl(this.downloadPage)))); // Gale - branding changes - version fetcher
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // Contributed by Techcable <Techcable@outlook.com> in GH-65
|
||||
+ private static int fetchDistanceFromGitHub(@Nonnull String repo, @Nonnull String branch, @Nonnull String hash) {
|
||||
+ try {
|
||||
+ HttpURLConnection connection = (HttpURLConnection) new URL("https://api.github.com/repos/" + repo + "/compare/" + branch + "..." + hash).openConnection();
|
||||
+ connection.connect();
|
||||
+ if (connection.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) return -2; // Unknown commit
|
||||
+ try (BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), Charsets.UTF_8))) {
|
||||
+ JsonObject obj = new Gson().fromJson(reader, JsonObject.class);
|
||||
+ String status = obj.get("status").getAsString();
|
||||
+ switch (status) {
|
||||
+ case "identical":
|
||||
+ return 0;
|
||||
+ case "behind":
|
||||
+ return obj.get("behind_by").getAsInt();
|
||||
+ default:
|
||||
+ return -1;
|
||||
+ }
|
||||
+ } catch (JsonSyntaxException | NumberFormatException e) {
|
||||
+ e.printStackTrace();
|
||||
+ return -1;
|
||||
+ }
|
||||
+ } catch (IOException e) {
|
||||
+ e.printStackTrace();
|
||||
+ return -1;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Nullable
|
||||
+ private Component getHistory() {
|
||||
+ final VersionHistoryManager.VersionData data = VersionHistoryManager.INSTANCE.getVersionData();
|
||||
+ if (data == null) {
|
||||
+ return null;
|
||||
+ }
|
||||
+
|
||||
+ final String oldVersion = data.getOldVersion();
|
||||
+ if (oldVersion == null) {
|
||||
+ return null;
|
||||
+ }
|
||||
+
|
||||
+ return Component.text("Previous version: " + oldVersion, NamedTextColor.GRAY, TextDecoration.ITALIC);
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/org/galemc/gale/version/GaleVersionFetcher.java b/src/main/java/org/galemc/gale/version/GaleVersionFetcher.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..28518511dbb705a693af8f2dfba20e58b39e1446
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/galemc/gale/version/GaleVersionFetcher.java
|
||||
@@ -0,0 +1,11 @@
|
||||
+// Gale - branding changes - version fetcher
|
||||
+
|
||||
+package org.galemc.gale.version;
|
||||
+
|
||||
+public class GaleVersionFetcher extends AbstractPaperVersionFetcher {
|
||||
+
|
||||
+ public GaleVersionFetcher() {
|
||||
+ super("master", "https://github.com/GaleMC/Gale", "Gale", "GaleMC", "GaleMC", "Gale");
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
diff --git a/src/main/java/org/spigotmc/WatchdogThread.java b/src/main/java/org/spigotmc/WatchdogThread.java
|
||||
index e9fa7faaa4451e36b3908cbcbbe0baf213abde96..65cf07734299dae297fca838172f9c210691e2a6 100644
|
||||
--- a/src/main/java/org/spigotmc/WatchdogThread.java
|
||||
+++ b/src/main/java/org/spigotmc/WatchdogThread.java
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.spigotmc;
|
||||
|
||||
+import java.awt.print.Paper;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.lang.management.MonitorInfo;
|
||||
import java.lang.management.ThreadInfo;
|
||||
@@ -155,14 +156,20 @@ public final class WatchdogThread extends io.papermc.paper.util.TickThread // Pa
|
||||
if (isLongTimeout) {
|
||||
// Paper end
|
||||
log.log( Level.SEVERE, "------------------------------" );
|
||||
- log.log( Level.SEVERE, "The server has stopped responding! This is (probably) not a Paper bug." ); // Paper
|
||||
+ // Gale start - branding changes
|
||||
+ /*
|
||||
+ We do not want people to report thread issues to Paper,
|
||||
+ but we do want people to report thread issues to Gale.
|
||||
+ */
|
||||
+ log.log( Level.SEVERE, "The server has stopped responding! This is (probably) not a Paper bug. This could be a Gale bug." ); // Paper
|
||||
+ // Gale end - branding changes
|
||||
log.log( Level.SEVERE, "If you see a plugin in the Server thread dump below, then please report it to that author" );
|
||||
log.log( Level.SEVERE, "\t *Especially* if it looks like HTTP or MySQL operations are occurring" );
|
||||
log.log( Level.SEVERE, "If you see a world save or edit, then it means you did far more than your server can handle at once" );
|
||||
log.log( Level.SEVERE, "\t If this is the case, consider increasing timeout-time in spigot.yml but note that this will replace the crash with LARGE lag spikes" );
|
||||
- log.log( Level.SEVERE, "If you are unsure or still think this is a Paper bug, please report this to https://github.com/PaperMC/Paper/issues" );
|
||||
+ log.log( Level.SEVERE, "If you are unsure or think this is a Gale bug, please report this to https://github.com/GaleMC/Gale/issues - and if you think this is a Paper bug, please report this to https://github.com/PaperMC/Paper/issues" ); // Gale - branding changes
|
||||
log.log( Level.SEVERE, "Be sure to include ALL relevant console errors and Minecraft crash reports" );
|
||||
- log.log( Level.SEVERE, "Paper version: " + Bukkit.getServer().getVersion() );
|
||||
+ log.log( Level.SEVERE, "Gale version: " + Bukkit.getServer().getVersion() ); // Gale - branding changes
|
||||
//
|
||||
if ( net.minecraft.world.level.Level.lastPhysicsProblem != null )
|
||||
{
|
||||
@@ -185,12 +192,18 @@ public final class WatchdogThread extends io.papermc.paper.util.TickThread // Pa
|
||||
// Paper end
|
||||
} else
|
||||
{
|
||||
- log.log(Level.SEVERE, "--- DO NOT REPORT THIS TO PAPER - THIS IS NOT A BUG OR A CRASH - " + Bukkit.getServer().getVersion() + " ---");
|
||||
+ // Gale start - branding changes
|
||||
+ /*
|
||||
+ We do not want people to report thread issues to Paper,
|
||||
+ but we do want people to report thread issues to Gale.
|
||||
+ */
|
||||
+ log.log(Level.SEVERE, "--- DO NOT REPORT THIS TO PAPER - If you think this is a Gale bug, please report it at https://github.com/GaleMC/Gale/issues - THIS IS NOT A PAPER BUG OR CRASH - " + Bukkit.getServer().getVersion() + " ---");
|
||||
+ // Gale end - branding changes
|
||||
log.log(Level.SEVERE, "The server has not responded for " + (currentTime - lastTick) / 1000 + " seconds! Creating thread dump");
|
||||
}
|
||||
// Paper end - Different message for short timeout
|
||||
log.log( Level.SEVERE, "------------------------------" );
|
||||
- log.log( Level.SEVERE, "Server thread dump (Look for plugins here before reporting to Paper!):" ); // Paper
|
||||
+ log.log( Level.SEVERE, "Server thread dump (Look for plugins here before reporting to Gale!):" ); // Paper // Gale - branding changes
|
||||
io.papermc.paper.chunk.system.scheduling.ChunkTaskScheduler.dumpAllChunkLoadInfo(isLongTimeout); // Paper // Paper - rewrite chunk system
|
||||
this.dumpTickingInfo(); // Paper - log detailed tick information
|
||||
WatchdogThread.dumpThread( ManagementFactory.getThreadMXBean().getThreadInfo( MinecraftServer.getServer().serverThread.getId(), Integer.MAX_VALUE ), log );
|
||||
@@ -206,7 +219,13 @@ public final class WatchdogThread extends io.papermc.paper.util.TickThread // Pa
|
||||
WatchdogThread.dumpThread( thread, log );
|
||||
}
|
||||
} else {
|
||||
- log.log(Level.SEVERE, "--- DO NOT REPORT THIS TO PAPER - THIS IS NOT A BUG OR A CRASH ---");
|
||||
+ // Gale start - branding changes
|
||||
+ /*
|
||||
+ We do not want people to report thread issues to Paper,
|
||||
+ but we do want people to report thread issues to Gale.
|
||||
+ */
|
||||
+ log.log(Level.SEVERE, "--- DO NOT REPORT THIS TO PAPER - If you think this is a Gale bug, please report it at https://github.com/GaleMC/Gale/issues - THIS IS NOT A PAPER BUG OR CRASH ---");
|
||||
+ // Gale end - branding changes
|
||||
}
|
||||
|
||||
log.log( Level.SEVERE, "------------------------------" );
|
||||
919
patches/server/0003-Gale-configuration.patch
Normal file
919
patches/server/0003-Gale-configuration.patch
Normal file
@@ -0,0 +1,919 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MartijnMuijsers <martijnmuijsers@live.nl>
|
||||
Date: Wed, 23 Nov 2022 21:05:47 +0100
|
||||
Subject: [PATCH] Gale configuration
|
||||
|
||||
|
||||
diff --git a/src/main/java/co/aikar/timings/TimingsExport.java b/src/main/java/co/aikar/timings/TimingsExport.java
|
||||
index 06bff37e4c1fddd3be6343049a66787c63fb420c..09e8cf64d85ef7147e0106ba0c477590b6f1c534 100644
|
||||
--- a/src/main/java/co/aikar/timings/TimingsExport.java
|
||||
+++ b/src/main/java/co/aikar/timings/TimingsExport.java
|
||||
@@ -241,7 +241,10 @@ public class TimingsExport extends Thread {
|
||||
parent.put("config", createObject(
|
||||
pair("spigot", mapAsJSON(Bukkit.spigot().getSpigotConfig(), null)),
|
||||
pair("bukkit", mapAsJSON(Bukkit.spigot().getBukkitConfig(), null)),
|
||||
- pair("paper", mapAsJSON(Bukkit.spigot().getPaperConfig(), null))
|
||||
+ // Gale start - Gale configuration - including in timings
|
||||
+ pair("paper", mapAsJSON(Bukkit.spigot().getPaperConfig(), null)),
|
||||
+ pair("gale", mapAsJSON(Bukkit.spigot().getGaleConfig(), null))
|
||||
+ // Gale end - Gale configuration - including in timings
|
||||
));
|
||||
|
||||
new TimingsExport(listeners, parent, history).start();
|
||||
@@ -282,7 +285,7 @@ public class TimingsExport extends Thread {
|
||||
return timingsCost;
|
||||
}
|
||||
|
||||
- private static JSONObject mapAsJSON(ConfigurationSection config, String parentKey) {
|
||||
+ public static JSONObject mapAsJSON(ConfigurationSection config, String parentKey) { // Gale - Gale configuration
|
||||
|
||||
JSONObject object = new JSONObject();
|
||||
for (String key : config.getKeys(false)) {
|
||||
diff --git a/src/main/java/io/papermc/paper/configuration/ConfigurationPart.java b/src/main/java/io/papermc/paper/configuration/ConfigurationPart.java
|
||||
index 7a4a7a654fe2516ed894a68f2657344df9d70f4c..b81dec5f603a9224e48a01d401ab262a2deb0844 100644
|
||||
--- a/src/main/java/io/papermc/paper/configuration/ConfigurationPart.java
|
||||
+++ b/src/main/java/io/papermc/paper/configuration/ConfigurationPart.java
|
||||
@@ -1,6 +1,6 @@
|
||||
package io.papermc.paper.configuration;
|
||||
|
||||
-abstract class ConfigurationPart {
|
||||
+public abstract class ConfigurationPart { // Gale - Gale configuration
|
||||
|
||||
public static abstract class Post extends ConfigurationPart {
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/configuration/Configurations.java b/src/main/java/io/papermc/paper/configuration/Configurations.java
|
||||
index c2dca89291361d60cbf160cab77749cb0130035a..ea03a1c02732a2b068686c603adcd443f05fba89 100644
|
||||
--- a/src/main/java/io/papermc/paper/configuration/Configurations.java
|
||||
+++ b/src/main/java/io/papermc/paper/configuration/Configurations.java
|
||||
@@ -5,7 +5,10 @@ import io.leangen.geantyref.TypeToken;
|
||||
import io.papermc.paper.configuration.constraint.Constraint;
|
||||
import io.papermc.paper.configuration.constraint.Constraints;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
+import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
+import org.bukkit.configuration.ConfigurationSection;
|
||||
+import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.jetbrains.annotations.MustBeInvokedByOverriders;
|
||||
import org.slf4j.Logger;
|
||||
@@ -88,7 +91,7 @@ public abstract class Configurations<G, W> {
|
||||
};
|
||||
}
|
||||
|
||||
- static <T> CheckedFunction<ConfigurationNode, T, SerializationException> reloader(Class<T> type, T instance) {
|
||||
+ public static <T> CheckedFunction<ConfigurationNode, T, SerializationException> reloader(Class<T> type, T instance) { // Gale - Gale configuration
|
||||
return node -> {
|
||||
ObjectMapper.Factory factory = (ObjectMapper.Factory) Objects.requireNonNull(node.options().serializers().get(type));
|
||||
ObjectMapper.Mutable<T> mutable = (ObjectMapper.Mutable<T>) factory.get(type);
|
||||
@@ -148,7 +151,7 @@ public abstract class Configurations<G, W> {
|
||||
final YamlConfigurationLoader loader = result.loader();
|
||||
final ConfigurationNode node = loader.load();
|
||||
if (result.isNewFile()) { // add version to new files
|
||||
- node.node(Configuration.VERSION_FIELD).raw(WorldConfiguration.CURRENT_VERSION);
|
||||
+ node.node(Configuration.VERSION_FIELD).raw(getWorldConfigurationCurrentVersion()); // Gale - Gale configuration
|
||||
}
|
||||
this.applyWorldConfigTransformations(contextMap, node);
|
||||
final W instance = node.require(this.worldConfigClass);
|
||||
@@ -207,7 +210,7 @@ public abstract class Configurations<G, W> {
|
||||
.build();
|
||||
final ConfigurationNode worldNode = worldLoader.load();
|
||||
if (newFile) { // set the version field if new file
|
||||
- worldNode.node(Configuration.VERSION_FIELD).set(WorldConfiguration.CURRENT_VERSION);
|
||||
+ worldNode.node(Configuration.VERSION_FIELD).set(getWorldConfigurationCurrentVersion()); // Gale - Gale configuration
|
||||
}
|
||||
this.applyWorldConfigTransformations(contextMap, worldNode);
|
||||
this.applyDefaultsAwareWorldConfigTransformations(contextMap, worldNode, defaultsNode);
|
||||
@@ -308,4 +311,25 @@ public abstract class Configurations<G, W> {
|
||||
return "ContextKey{" + this.name + "}";
|
||||
}
|
||||
}
|
||||
+
|
||||
+ // Gale start - Gale configuration
|
||||
+
|
||||
+ public static final String legacyWorldsSectionKey = "__________WORLDS__________";
|
||||
+ public static final String legacyWorldDefaultsSectionKey = "__defaults__";
|
||||
+
|
||||
+ @Deprecated
|
||||
+ public YamlConfiguration createLegacyObject(final MinecraftServer server) {
|
||||
+ YamlConfiguration global = YamlConfiguration.loadConfiguration(this.globalFolder.resolve(this.globalConfigFileName).toFile());
|
||||
+ ConfigurationSection worlds = global.createSection(legacyWorldsSectionKey);
|
||||
+ worlds.set(legacyWorldDefaultsSectionKey, YamlConfiguration.loadConfiguration(this.globalFolder.resolve(this.defaultWorldConfigFileName).toFile()));
|
||||
+ for (ServerLevel level : server.getAllLevels()) {
|
||||
+ worlds.set(level.getWorld().getName(), YamlConfiguration.loadConfiguration(getWorldConfigFile(level).toFile()));
|
||||
+ }
|
||||
+ return global;
|
||||
+ }
|
||||
+
|
||||
+ public abstract int getWorldConfigurationCurrentVersion();
|
||||
+
|
||||
+ // Gale end - Gale configuration
|
||||
+
|
||||
}
|
||||
diff --git a/src/main/java/io/papermc/paper/configuration/InnerClassFieldDiscoverer.java b/src/main/java/io/papermc/paper/configuration/InnerClassFieldDiscoverer.java
|
||||
index a0aa1f1a7adf986d500a2135aa42e138aa3c4f08..b58bbb0643dc72eba056e421d35362de855eb6f8 100644
|
||||
--- a/src/main/java/io/papermc/paper/configuration/InnerClassFieldDiscoverer.java
|
||||
+++ b/src/main/java/io/papermc/paper/configuration/InnerClassFieldDiscoverer.java
|
||||
@@ -5,6 +5,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.spongepowered.configurate.objectmapping.FieldDiscoverer;
|
||||
import org.spongepowered.configurate.serialize.SerializationException;
|
||||
import org.spongepowered.configurate.util.CheckedSupplier;
|
||||
+import org.galemc.gale.configuration.GaleWorldConfiguration;
|
||||
|
||||
import java.lang.reflect.AnnotatedType;
|
||||
import java.lang.reflect.Constructor;
|
||||
@@ -17,7 +18,7 @@ import java.util.Map;
|
||||
|
||||
import static io.leangen.geantyref.GenericTypeReflector.erase;
|
||||
|
||||
-final class InnerClassFieldDiscoverer implements FieldDiscoverer<Map<Field, Object>> {
|
||||
+public final class InnerClassFieldDiscoverer implements FieldDiscoverer<Map<Field, Object>> { // Gale - Gale configuration
|
||||
|
||||
private final Map<Class<?>, Object> instanceMap = new HashMap<>();
|
||||
private final Map<Class<?>, Object> overrides;
|
||||
@@ -136,7 +137,19 @@ final class InnerClassFieldDiscoverer implements FieldDiscoverer<Map<Field, Obje
|
||||
return new InnerClassFieldDiscoverer(overrides);
|
||||
}
|
||||
|
||||
- static FieldDiscoverer<?> globalConfig() {
|
||||
+ // Gale start - Gale configuration
|
||||
+ public static FieldDiscoverer<?> galeWorldConfig(Configurations.ContextMap contextMap) {
|
||||
+ final Map<Class<?>, Object> overrides = Map.of(
|
||||
+ GaleWorldConfiguration.class, new GaleWorldConfiguration(
|
||||
+ contextMap.require(PaperConfigurations.SPIGOT_WORLD_CONFIG_CONTEXT_KEY).get(),
|
||||
+ contextMap.require(Configurations.WORLD_KEY)
|
||||
+ )
|
||||
+ );
|
||||
+ return new InnerClassFieldDiscoverer(overrides);
|
||||
+ }
|
||||
+ // Gale end - Gale configuration
|
||||
+
|
||||
+ public static FieldDiscoverer<?> globalConfig() { // Gale - Gale configuration
|
||||
return new InnerClassFieldDiscoverer(Collections.emptyMap());
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java
|
||||
index e731de3ac158c5a4cff236c6f5001674cd488a77..b51df5d61745890faff60ea32bee754aed28b939 100644
|
||||
--- a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java
|
||||
+++ b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java
|
||||
@@ -125,13 +125,13 @@ public class PaperConfigurations extends Configurations<GlobalConfiguration, Wor
|
||||
See https://docs.papermc.io/paper/configuration for more information.
|
||||
""";
|
||||
|
||||
- private static final Supplier<SpigotWorldConfig> SPIGOT_WORLD_DEFAULTS = Suppliers.memoize(() -> new SpigotWorldConfig(RandomStringUtils.randomAlphabetic(255)) {
|
||||
+ public static final Supplier<SpigotWorldConfig> SPIGOT_WORLD_DEFAULTS = Suppliers.memoize(() -> new SpigotWorldConfig(RandomStringUtils.randomAlphabetic(255)) { // Gale - Gale configuration
|
||||
@Override // override to ensure "verbose" is false
|
||||
public void init() {
|
||||
SpigotConfig.readConfig(SpigotWorldConfig.class, this);
|
||||
}
|
||||
});
|
||||
- static final ContextKey<Supplier<SpigotWorldConfig>> SPIGOT_WORLD_CONFIG_CONTEXT_KEY = new ContextKey<>(new TypeToken<Supplier<SpigotWorldConfig>>() {}, "spigot world config");
|
||||
+ public static final ContextKey<Supplier<SpigotWorldConfig>> SPIGOT_WORLD_CONFIG_CONTEXT_KEY = new ContextKey<>(new TypeToken<Supplier<SpigotWorldConfig>>() {}, "spigot world config"); // Gale - Gale configuration
|
||||
|
||||
|
||||
public PaperConfigurations(final Path globalFolder) {
|
||||
@@ -293,7 +293,7 @@ public class PaperConfigurations extends Configurations<GlobalConfiguration, Wor
|
||||
}
|
||||
}
|
||||
|
||||
- private static ContextMap createWorldContextMap(ServerLevel level) {
|
||||
+ public static ContextMap createWorldContextMap(ServerLevel level) { // Gale - Gale configuration
|
||||
return createWorldContextMap(level.convertable.levelDirectory.path(), level.serverLevelData.getLevelName(), level.dimension().location(), level.spigotConfig);
|
||||
}
|
||||
|
||||
@@ -394,17 +394,6 @@ public class PaperConfigurations extends Configurations<GlobalConfiguration, Wor
|
||||
return Files.exists(legacyConfig) && Files.isRegularFile(legacyConfig);
|
||||
}
|
||||
|
||||
- @Deprecated
|
||||
- public YamlConfiguration createLegacyObject(final MinecraftServer server) {
|
||||
- YamlConfiguration global = YamlConfiguration.loadConfiguration(this.globalFolder.resolve(this.globalConfigFileName).toFile());
|
||||
- ConfigurationSection worlds = global.createSection("__________WORLDS__________");
|
||||
- worlds.set("__defaults__", YamlConfiguration.loadConfiguration(this.globalFolder.resolve(this.defaultWorldConfigFileName).toFile()));
|
||||
- for (ServerLevel level : server.getAllLevels()) {
|
||||
- worlds.set(level.getWorld().getName(), YamlConfiguration.loadConfiguration(getWorldConfigFile(level).toFile()));
|
||||
- }
|
||||
- return global;
|
||||
- }
|
||||
-
|
||||
@Deprecated
|
||||
public static YamlConfiguration loadLegacyConfigFile(File configFile) throws Exception {
|
||||
YamlConfiguration config = new YamlConfiguration();
|
||||
@@ -427,9 +416,16 @@ public class PaperConfigurations extends Configurations<GlobalConfiguration, Wor
|
||||
}
|
||||
|
||||
// Symlinks are not correctly checked in createDirectories
|
||||
- static void createDirectoriesSymlinkAware(Path path) throws IOException {
|
||||
+ public static void createDirectoriesSymlinkAware(Path path) throws IOException { // Gale - Gale configuration
|
||||
if (!Files.isDirectory(path)) {
|
||||
Files.createDirectories(path);
|
||||
}
|
||||
}
|
||||
+
|
||||
+ // Gale start - Gale configuration
|
||||
+ @Override
|
||||
+ public int getWorldConfigurationCurrentVersion() {
|
||||
+ return WorldConfiguration.CURRENT_VERSION;
|
||||
+ }
|
||||
+ // Gale end - Gale configuration
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index 5bfeb649336f023d05392c07d040299c605133c8..afd22d4446b29e83fea9c84b97ef96798d7e6895 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -2,9 +2,6 @@ package net.minecraft.server;
|
||||
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
-import co.aikar.timings.Timings;
|
||||
-import com.destroystokyo.paper.event.server.PaperServerListPingEvent;
|
||||
-import com.google.common.base.Stopwatch;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
@@ -80,7 +77,6 @@ import net.minecraft.server.level.ServerChunkCache;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.level.ServerPlayerGameMode;
|
||||
-import net.minecraft.server.level.TicketType;
|
||||
import net.minecraft.server.level.progress.ChunkProgressListener;
|
||||
import net.minecraft.server.level.progress.ChunkProgressListenerFactory;
|
||||
import net.minecraft.server.network.ServerConnectionListener;
|
||||
@@ -104,7 +100,6 @@ import net.minecraft.util.NativeModuleLister;
|
||||
import net.minecraft.util.ProgressListener;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.util.SignatureValidator;
|
||||
-import net.minecraft.util.Unit;
|
||||
import net.minecraft.util.datafix.DataFixers;
|
||||
import net.minecraft.util.profiling.EmptyProfileResults;
|
||||
import net.minecraft.util.profiling.ProfileResults;
|
||||
@@ -153,6 +148,7 @@ import net.minecraft.world.level.storage.loot.PredicateManager;
|
||||
import net.minecraft.world.phys.Vec2;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
+import org.galemc.gale.configuration.GaleConfigurations;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
// CraftBukkit start
|
||||
@@ -170,13 +166,6 @@ import net.minecraft.world.level.levelgen.PhantomSpawner;
|
||||
import net.minecraft.world.level.levelgen.WorldGenSettings;
|
||||
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.level.levelgen.presets.WorldPresets;
|
||||
-import org.bukkit.Bukkit;
|
||||
-import org.bukkit.craftbukkit.CraftServer;
|
||||
-import org.bukkit.craftbukkit.Main;
|
||||
-import org.bukkit.craftbukkit.generator.CustomWorldChunkManager;
|
||||
-import org.bukkit.craftbukkit.util.CraftChatMessage;
|
||||
-import org.bukkit.craftbukkit.util.LazyPlayerSet;
|
||||
-import org.bukkit.event.player.AsyncPlayerChatPreviewEvent;
|
||||
import org.bukkit.event.server.ServerLoadEvent;
|
||||
// CraftBukkit end
|
||||
|
||||
@@ -293,6 +282,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
public final double[] recentTps = new double[ 3 ];
|
||||
// Spigot end
|
||||
public final io.papermc.paper.configuration.PaperConfigurations paperConfigurations;
|
||||
+ public final GaleConfigurations galeConfigurations; // Gale - Gale configuration
|
||||
public static long currentTickLong = 0L; // Paper
|
||||
|
||||
public volatile Thread shutdownThread; // Paper
|
||||
@@ -395,6 +385,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
// Paper end
|
||||
Runtime.getRuntime().addShutdownHook(new org.bukkit.craftbukkit.util.ServerShutdownThread(this));
|
||||
this.paperConfigurations = services.paperConfigurations(); // Paper
|
||||
+ this.galeConfigurations = services.galeConfigurations(); // Gale - Gale configuration
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/Services.java b/src/main/java/net/minecraft/server/Services.java
|
||||
index ef6ff78af2ae747e939895b82ee9d11c75012dcd..7e4f2b3ecaeac731ee3a6b66ce85f239fe5f11b6 100644
|
||||
--- a/src/main/java/net/minecraft/server/Services.java
|
||||
+++ b/src/main/java/net/minecraft/server/Services.java
|
||||
@@ -6,12 +6,13 @@ import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
|
||||
import java.io.File;
|
||||
import net.minecraft.server.players.GameProfileCache;
|
||||
import net.minecraft.util.SignatureValidator;
|
||||
+import org.galemc.gale.configuration.GaleConfigurations;
|
||||
|
||||
// Paper start
|
||||
-public record Services(MinecraftSessionService sessionService, SignatureValidator serviceSignatureValidator, GameProfileRepository profileRepository, GameProfileCache profileCache, @javax.annotation.Nullable io.papermc.paper.configuration.PaperConfigurations paperConfigurations) {
|
||||
+public record Services(MinecraftSessionService sessionService, SignatureValidator serviceSignatureValidator, GameProfileRepository profileRepository, GameProfileCache profileCache, @javax.annotation.Nullable io.papermc.paper.configuration.PaperConfigurations paperConfigurations, @javax.annotation.Nullable GaleConfigurations galeConfigurations) { // Gale - Gale configuration
|
||||
|
||||
public Services(MinecraftSessionService sessionService, SignatureValidator signatureValidator, GameProfileRepository profileRepository, GameProfileCache profileCache) {
|
||||
- this(sessionService, signatureValidator, profileRepository, profileCache, null);
|
||||
+ this(sessionService, signatureValidator, profileRepository, profileCache, null, null); // Gale - Gale configuration
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -19,6 +20,11 @@ public record Services(MinecraftSessionService sessionService, SignatureValidato
|
||||
return java.util.Objects.requireNonNull(this.paperConfigurations);
|
||||
}
|
||||
// Paper end
|
||||
+ // Gale start - Gale configuration
|
||||
+ public GaleConfigurations galeConfigurations() {
|
||||
+ return java.util.Objects.requireNonNull(this.galeConfigurations);
|
||||
+ }
|
||||
+ // Gale end - Gale configuration
|
||||
public static final String USERID_CACHE_FILE = "usercache.json"; // Paper - private -> public
|
||||
|
||||
public static Services create(YggdrasilAuthenticationService authenticationService, File rootDirectory, File userCacheFile, joptsimple.OptionSet optionSet) throws Exception { // Paper
|
||||
@@ -30,7 +36,10 @@ public record Services(MinecraftSessionService sessionService, SignatureValidato
|
||||
final java.nio.file.Path legacyConfigPath = ((File) optionSet.valueOf("paper-settings")).toPath();
|
||||
final java.nio.file.Path configDirPath = ((File) optionSet.valueOf("paper-settings-directory")).toPath();
|
||||
io.papermc.paper.configuration.PaperConfigurations paperConfigurations = io.papermc.paper.configuration.PaperConfigurations.setup(legacyConfigPath, configDirPath, rootDirectory.toPath(), (File) optionSet.valueOf("spigot-settings"));
|
||||
- return new Services(minecraftSessionService, signatureValidator, gameProfileRepository, gameProfileCache, paperConfigurations);
|
||||
+ // Gale start - Gale configuration
|
||||
+ GaleConfigurations galeConfigurations = GaleConfigurations.setup(configDirPath);
|
||||
+ return new Services(minecraftSessionService, signatureValidator, gameProfileRepository, gameProfileCache, paperConfigurations, galeConfigurations);
|
||||
+ // Gale end - Gale configuration
|
||||
// Paper end
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
index ff3eced0e20c39b825586897ee2fed01dd471d88..acb9e2f67a5ffe46136e1687561630f96b27ce06 100644
|
||||
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
@@ -1,20 +1,15 @@
|
||||
package net.minecraft.server.dedicated;
|
||||
|
||||
-import com.google.common.collect.Lists;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.datafixers.DataFixer;
|
||||
import com.mojang.logging.LogUtils;
|
||||
-import java.io.BufferedReader;
|
||||
+
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
-import java.io.InputStreamReader;
|
||||
import java.net.InetAddress;
|
||||
import java.net.Proxy;
|
||||
-import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
-import java.util.Collections;
|
||||
-import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
import java.util.function.BooleanSupplier;
|
||||
@@ -213,6 +208,10 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
io.papermc.paper.util.ObfHelper.INSTANCE.getClass(); // Paper - load mappings for stacktrace deobf and etc.
|
||||
paperConfigurations.initializeGlobalConfiguration();
|
||||
paperConfigurations.initializeWorldDefaultsConfiguration();
|
||||
+ // Gale start - Gale configuration
|
||||
+ galeConfigurations.initializeGlobalConfiguration();
|
||||
+ galeConfigurations.initializeWorldDefaultsConfiguration();
|
||||
+ // Gale end - Gale configuration
|
||||
// Paper start - moved up to right after PlayerList creation but before file load/save
|
||||
if (this.convertOldUsers()) {
|
||||
this.getProfileCache().save(false); // Paper
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index feb0a6d6a90850977b393440881c472c317a9323..73e5a7893c49d488525ed53ca09e91d8f90cc7bd 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -125,12 +125,10 @@ import net.minecraft.world.level.chunk.storage.EntityStorage;
|
||||
import net.minecraft.world.level.dimension.BuiltinDimensionTypes;
|
||||
import net.minecraft.world.level.dimension.LevelStem;
|
||||
import net.minecraft.world.level.dimension.end.EndDragonFight;
|
||||
-import net.minecraft.world.level.entity.EntityPersistentStorage;
|
||||
import net.minecraft.world.level.entity.EntityTickList;
|
||||
import net.minecraft.world.level.entity.EntityTypeTest;
|
||||
import net.minecraft.world.level.entity.LevelCallback;
|
||||
import net.minecraft.world.level.entity.LevelEntityGetter;
|
||||
-import net.minecraft.world.level.entity.PersistentEntitySectionManager;
|
||||
import net.minecraft.world.level.gameevent.DynamicGameEventListener;
|
||||
import net.minecraft.world.level.gameevent.GameEvent;
|
||||
import net.minecraft.world.level.gameevent.GameEventListener;
|
||||
@@ -525,7 +523,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
public ServerLevel(MinecraftServer minecraftserver, Executor executor, LevelStorageSource.LevelStorageAccess convertable_conversionsession, PrimaryLevelData iworlddataserver, ResourceKey<Level> resourcekey, LevelStem worlddimension, ChunkProgressListener worldloadlistener, boolean flag, long i, List<CustomSpawner> list, boolean flag1, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider) {
|
||||
// Holder holder = worlddimension.typeHolder(); // CraftBukkit - decompile error
|
||||
// Objects.requireNonNull(minecraftserver); // CraftBukkit - decompile error
|
||||
- super(iworlddataserver, resourcekey, worlddimension.typeHolder(), minecraftserver::getProfiler, false, flag, i, minecraftserver.getMaxChainedNeighborUpdates(), gen, biomeProvider, env, spigotConfig -> minecraftserver.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(convertable_conversionsession.levelDirectory.path(), iworlddataserver.getLevelName(), resourcekey.location(), spigotConfig)), executor); // Paper - Async-Anti-Xray - Pass executor
|
||||
+ super(iworlddataserver, resourcekey, worlddimension.typeHolder(), minecraftserver::getProfiler, false, flag, i, minecraftserver.getMaxChainedNeighborUpdates(), gen, biomeProvider, env, spigotConfig -> minecraftserver.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(convertable_conversionsession.levelDirectory.path(), iworlddataserver.getLevelName(), resourcekey.location(), spigotConfig)), spigotConfig -> minecraftserver.galeConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(convertable_conversionsession.levelDirectory.path(), iworlddataserver.getLevelName(), resourcekey.location(), spigotConfig)), executor); // Paper - Async-Anti-Xray - Pass executor // Gale - Gale configuration
|
||||
this.pvpMode = minecraftserver.isPvpAllowed();
|
||||
this.convertable = convertable_conversionsession;
|
||||
this.uuid = WorldUUID.getUUID(convertable_conversionsession.levelDirectory.path().toFile());
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
||||
index 596fb8ee21ba8450db13a11890d241ef3974d81d..ed65805906a6e1e03c2d96b76bba749a9dfd27be 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Level.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
||||
@@ -1,10 +1,7 @@
|
||||
package net.minecraft.world.level;
|
||||
|
||||
-import co.aikar.timings.Timing;
|
||||
-import co.aikar.timings.Timings;
|
||||
import com.destroystokyo.paper.event.server.ServerExceptionEvent;
|
||||
import com.destroystokyo.paper.exception.ServerInternalException;
|
||||
-import com.google.common.base.MoreObjects;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.mojang.serialization.Codec;
|
||||
import java.io.IOException;
|
||||
@@ -17,7 +14,6 @@ import java.util.function.Supplier;
|
||||
import javax.annotation.Nullable;
|
||||
import net.minecraft.CrashReport;
|
||||
import net.minecraft.CrashReportCategory;
|
||||
-import net.minecraft.ReportedException;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Holder;
|
||||
@@ -40,8 +36,6 @@ import net.minecraft.util.profiling.ProfilerFiller;
|
||||
import net.minecraft.world.DifficultyInstance;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
-import net.minecraft.world.entity.boss.EnderDragonPart;
|
||||
-import net.minecraft.world.entity.boss.enderdragon.EnderDragon;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
@@ -90,17 +84,15 @@ import net.minecraft.network.protocol.game.ClientboundSetBorderSizePacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundSetBorderWarningDelayPacket;
|
||||
import net.minecraft.network.protocol.game.ClientboundSetBorderWarningDistancePacket;
|
||||
import org.bukkit.Bukkit;
|
||||
-import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.block.CapturedBlockState;
|
||||
import org.bukkit.craftbukkit.block.CraftBlockState;
|
||||
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
import org.bukkit.craftbukkit.util.CraftSpawnCategory;
|
||||
-import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||
import org.bukkit.entity.SpawnCategory;
|
||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||
-import org.bukkit.event.world.GenericGameEvent;
|
||||
+import org.galemc.gale.configuration.GaleWorldConfiguration;
|
||||
// CraftBukkit end
|
||||
|
||||
public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||
@@ -172,6 +164,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||
return this.paperConfig;
|
||||
}
|
||||
// Paper end
|
||||
+ // Gale start - Gale configuration
|
||||
+ private final GaleWorldConfiguration galeConfig;
|
||||
+ public GaleWorldConfiguration galeConfig() {
|
||||
+ return this.galeConfig;
|
||||
+ }
|
||||
+ // Gale end - Gale configuration
|
||||
|
||||
public final com.destroystokyo.paper.antixray.ChunkPacketBlockController chunkPacketBlockController; // Paper - Anti-Xray
|
||||
public final co.aikar.timings.WorldTimingsHandler timings; // Paper
|
||||
@@ -271,9 +269,10 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||
|
||||
public abstract ResourceKey<LevelStem> getTypeKey();
|
||||
|
||||
- protected Level(WritableLevelData worlddatamutable, ResourceKey<Level> resourcekey, Holder<DimensionType> holder, Supplier<ProfilerFiller> supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function<org.spigotmc.SpigotWorldConfig, io.papermc.paper.configuration.WorldConfiguration> paperWorldConfigCreator, java.util.concurrent.Executor executor) { // Paper - Async-Anti-Xray - Pass executor
|
||||
+ protected Level(WritableLevelData worlddatamutable, ResourceKey<Level> resourcekey, Holder<DimensionType> holder, Supplier<ProfilerFiller> supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function<org.spigotmc.SpigotWorldConfig, io.papermc.paper.configuration.WorldConfiguration> paperWorldConfigCreator, java.util.function.Function<org.spigotmc.SpigotWorldConfig, GaleWorldConfiguration> galeWorldConfigCreator, java.util.concurrent.Executor executor) { // Paper - Async-Anti-Xray - Pass executor // Gale - Gale configuration
|
||||
this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot
|
||||
this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper
|
||||
+ this.galeConfig = galeWorldConfigCreator.apply(this.spigotConfig); // Gale - Gale configuration
|
||||
this.generator = gen;
|
||||
this.world = new CraftWorld((ServerLevel) this, gen, biomeProvider, env);
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index e41e390a2eaf7f9dc489304db3e499d5055e7cff..4ccd6640bf0125d5b6734ef0de993e675fd9d45a 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -966,6 +966,7 @@ public final class CraftServer implements Server {
|
||||
|
||||
org.spigotmc.SpigotConfig.init((File) console.options.valueOf("spigot-settings")); // Spigot
|
||||
this.console.paperConfigurations.reloadConfigs(this.console);
|
||||
+ this.console.galeConfigurations.reloadConfigs(this.console); // Gale - Gale configuration
|
||||
for (ServerLevel world : this.console.getAllLevels()) {
|
||||
// world.serverLevelData.setDifficulty(config.difficulty); // Paper - per level difficulty
|
||||
world.setSpawnSettings(world.serverLevelData.getDifficulty() != Difficulty.PEACEFUL && config.spawnMonsters, config.spawnAnimals); // Paper - per level difficulty (from MinecraftServer#setDifficulty(ServerLevel, Difficulty, boolean))
|
||||
@@ -2736,6 +2737,14 @@ public final class CraftServer implements Server {
|
||||
return CraftServer.this.console.paperConfigurations.createLegacyObject(CraftServer.this.console);
|
||||
}
|
||||
|
||||
+ // Gale start - Gale configuration - API
|
||||
+ @Override
|
||||
+ public YamlConfiguration getGaleConfig()
|
||||
+ {
|
||||
+ return CraftServer.this.console.galeConfigurations.createLegacyObject(CraftServer.this.console);
|
||||
+ }
|
||||
+ // Gale end - Gale configuration - API
|
||||
+
|
||||
@Override
|
||||
public void restart() {
|
||||
org.spigotmc.RestartCommand.restart();
|
||||
diff --git a/src/main/java/org/galemc/gale/configuration/GaleConfigurations.java b/src/main/java/org/galemc/gale/configuration/GaleConfigurations.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..e42a31422ea04243f62a5d34753d10269f7e977e
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/galemc/gale/configuration/GaleConfigurations.java
|
||||
@@ -0,0 +1,291 @@
|
||||
+// Gale - Gale configuration
|
||||
+
|
||||
+package org.galemc.gale.configuration;
|
||||
+
|
||||
+import com.google.common.collect.Table;
|
||||
+import com.mojang.logging.LogUtils;
|
||||
+import io.leangen.geantyref.TypeToken;
|
||||
+import io.papermc.paper.configuration.Configuration;
|
||||
+import io.papermc.paper.configuration.ConfigurationPart;
|
||||
+import io.papermc.paper.configuration.Configurations;
|
||||
+import io.papermc.paper.configuration.InnerClassFieldDiscoverer;
|
||||
+import io.papermc.paper.configuration.NestedSetting;
|
||||
+import io.papermc.paper.configuration.PaperConfigurations;
|
||||
+import io.papermc.paper.configuration.legacy.RequiresSpigotInitialization;
|
||||
+import io.papermc.paper.configuration.serializer.ComponentSerializer;
|
||||
+import io.papermc.paper.configuration.serializer.EnumValueSerializer;
|
||||
+import io.papermc.paper.configuration.serializer.FastutilMapSerializer;
|
||||
+import io.papermc.paper.configuration.serializer.PacketClassSerializer;
|
||||
+import io.papermc.paper.configuration.serializer.StringRepresentableSerializer;
|
||||
+import io.papermc.paper.configuration.serializer.TableSerializer;
|
||||
+import io.papermc.paper.configuration.serializer.collections.MapSerializer;
|
||||
+import io.papermc.paper.configuration.serializer.registry.RegistryHolderSerializer;
|
||||
+import io.papermc.paper.configuration.serializer.registry.RegistryValueSerializer;
|
||||
+import io.papermc.paper.configuration.transformation.Transformations;
|
||||
+import io.papermc.paper.configuration.type.BooleanOrDefault;
|
||||
+import io.papermc.paper.configuration.type.DoubleOrDefault;
|
||||
+import io.papermc.paper.configuration.type.Duration;
|
||||
+import io.papermc.paper.configuration.type.EngineMode;
|
||||
+import io.papermc.paper.configuration.type.IntOr;
|
||||
+import io.papermc.paper.configuration.type.fallback.FallbackValueSerializer;
|
||||
+import it.unimi.dsi.fastutil.objects.Reference2IntMap;
|
||||
+import it.unimi.dsi.fastutil.objects.Reference2IntOpenHashMap;
|
||||
+import it.unimi.dsi.fastutil.objects.Reference2LongMap;
|
||||
+import it.unimi.dsi.fastutil.objects.Reference2LongOpenHashMap;
|
||||
+import net.minecraft.core.Registry;
|
||||
+import net.minecraft.server.MinecraftServer;
|
||||
+import net.minecraft.server.level.ServerLevel;
|
||||
+import net.minecraft.world.entity.EntityType;
|
||||
+import net.minecraft.world.item.Item;
|
||||
+import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
|
||||
+import org.slf4j.Logger;
|
||||
+import org.spongepowered.configurate.ConfigurateException;
|
||||
+import org.spongepowered.configurate.ConfigurationNode;
|
||||
+import org.spongepowered.configurate.ConfigurationOptions;
|
||||
+import org.spongepowered.configurate.NodePath;
|
||||
+import org.spongepowered.configurate.objectmapping.ObjectMapper;
|
||||
+import org.spongepowered.configurate.transformation.ConfigurationTransformation;
|
||||
+import org.spongepowered.configurate.transformation.TransformAction;
|
||||
+import org.spongepowered.configurate.yaml.YamlConfigurationLoader;
|
||||
+
|
||||
+import java.io.File;
|
||||
+import java.io.IOException;
|
||||
+import java.lang.reflect.Type;
|
||||
+import java.nio.file.Files;
|
||||
+import java.nio.file.Path;
|
||||
+import java.util.Collections;
|
||||
+import java.util.List;
|
||||
+import java.util.function.Function;
|
||||
+
|
||||
+import static io.leangen.geantyref.GenericTypeReflector.erase;
|
||||
+
|
||||
+@SuppressWarnings("Convert2Diamond")
|
||||
+public class GaleConfigurations extends Configurations<GaleGlobalConfiguration, GaleWorldConfiguration> {
|
||||
+
|
||||
+ private static final Logger LOGGER = LogUtils.getLogger();
|
||||
+ static final String GLOBAL_CONFIG_FILE_NAME = "gale-global.yml";
|
||||
+ static final String WORLD_DEFAULTS_CONFIG_FILE_NAME = "gale-world-defaults.yml";
|
||||
+ static final String WORLD_CONFIG_FILE_NAME = "gale-world.yml";
|
||||
+ public static final String CONFIG_DIR = "config";
|
||||
+
|
||||
+ private static final String GLOBAL_HEADER = String.format("""
|
||||
+ This is the global configuration file for Gale.
|
||||
+ As you can see, there's a lot to configure. Some options may impact gameplay, so use
|
||||
+ with caution, and make sure you know what each option does before configuring.
|
||||
+
|
||||
+ If you need help with the configuration or have any questions related to Gale,
|
||||
+ join us in our Discord, or check the GitHub Wiki pages.
|
||||
+
|
||||
+ The world configuration options are inside
|
||||
+ their respective world folder. The files are named %s
|
||||
+
|
||||
+ Wiki: https://github.com/GaleMC/Gale/wiki
|
||||
+ Discord: TODO""", WORLD_CONFIG_FILE_NAME);
|
||||
+
|
||||
+ private static final String WORLD_DEFAULTS_HEADER = """
|
||||
+ This is the world defaults configuration file for Gale.
|
||||
+ As you can see, there's a lot to configure. Some options may impact gameplay, so use
|
||||
+ with caution, and make sure you know what each option does before configuring.
|
||||
+
|
||||
+ If you need help with the configuration or have any questions related to Gale,
|
||||
+ join us in our Discord, or check the GitHub Wiki pages.
|
||||
+
|
||||
+ Configuration options here apply to all worlds, unless you specify overrides inside
|
||||
+ the world-specific config file inside each world folder.
|
||||
+
|
||||
+ Wiki: https://github.com/GaleMC/Gale/wiki
|
||||
+ Discord: TODO""";
|
||||
+
|
||||
+ private static final Function<ContextMap, String> WORLD_HEADER = map -> String.format("""
|
||||
+ This is a world configuration file for Gale.
|
||||
+ This file may start empty but can be filled with settings to override ones in the %s/%s
|
||||
+
|
||||
+ World: %s (%s)""",
|
||||
+ CONFIG_DIR,
|
||||
+ WORLD_DEFAULTS_CONFIG_FILE_NAME,
|
||||
+ map.require(WORLD_NAME),
|
||||
+ map.require(WORLD_KEY)
|
||||
+ );
|
||||
+
|
||||
+ private static final String MOVED_NOTICE = """
|
||||
+ The global and world default configuration files have moved to %s
|
||||
+ and the world-specific configuration file has been moved inside
|
||||
+ the respective world folder.
|
||||
+
|
||||
+ See https://github.com/GaleMC/Gale/wiki for more information.
|
||||
+ """;
|
||||
+
|
||||
+ public GaleConfigurations(final Path globalFolder) {
|
||||
+ super(globalFolder, GaleGlobalConfiguration.class, GaleWorldConfiguration.class, GLOBAL_CONFIG_FILE_NAME, WORLD_DEFAULTS_CONFIG_FILE_NAME, WORLD_CONFIG_FILE_NAME);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ protected YamlConfigurationLoader.Builder createLoaderBuilder() {
|
||||
+ return super.createLoaderBuilder()
|
||||
+ .defaultOptions(GaleConfigurations::defaultOptions);
|
||||
+ }
|
||||
+
|
||||
+ private static ConfigurationOptions defaultOptions(ConfigurationOptions options) {
|
||||
+ return options.serializers(builder -> builder
|
||||
+ .register(MapSerializer.TYPE, new MapSerializer(false))
|
||||
+ .register(new EnumValueSerializer())
|
||||
+ .register(new ComponentSerializer())
|
||||
+ );
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ protected ObjectMapper.Factory.Builder createGlobalObjectMapperFactoryBuilder() {
|
||||
+ return defaultGlobalFactoryBuilder(super.createGlobalObjectMapperFactoryBuilder());
|
||||
+ }
|
||||
+
|
||||
+ private static ObjectMapper.Factory.Builder defaultGlobalFactoryBuilder(ObjectMapper.Factory.Builder builder) {
|
||||
+ return builder.addDiscoverer(InnerClassFieldDiscoverer.globalConfig());
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ protected YamlConfigurationLoader.Builder createGlobalLoaderBuilder() {
|
||||
+ return super.createGlobalLoaderBuilder()
|
||||
+ .defaultOptions(GaleConfigurations::defaultGlobalOptions);
|
||||
+ }
|
||||
+
|
||||
+ private static ConfigurationOptions defaultGlobalOptions(ConfigurationOptions options) {
|
||||
+ return options
|
||||
+ .header(GLOBAL_HEADER)
|
||||
+ .serializers(builder -> builder.register(new PacketClassSerializer()));
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public GaleGlobalConfiguration initializeGlobalConfiguration() throws ConfigurateException {
|
||||
+ GaleGlobalConfiguration configuration = super.initializeGlobalConfiguration();
|
||||
+ GaleGlobalConfiguration.set(configuration);
|
||||
+ return configuration;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ protected ContextMap.Builder createDefaultContextMap() {
|
||||
+ return super.createDefaultContextMap()
|
||||
+ .put(PaperConfigurations.SPIGOT_WORLD_CONFIG_CONTEXT_KEY, PaperConfigurations.SPIGOT_WORLD_DEFAULTS);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ protected ObjectMapper.Factory.Builder createWorldObjectMapperFactoryBuilder(final ContextMap contextMap) {
|
||||
+ return super.createWorldObjectMapperFactoryBuilder(contextMap)
|
||||
+ .addNodeResolver(new RequiresSpigotInitialization.Factory(contextMap.require(PaperConfigurations.SPIGOT_WORLD_CONFIG_CONTEXT_KEY).get()))
|
||||
+ .addNodeResolver(new NestedSetting.Factory())
|
||||
+ .addDiscoverer(InnerClassFieldDiscoverer.galeWorldConfig(contextMap));
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ protected YamlConfigurationLoader.Builder createWorldConfigLoaderBuilder(final ContextMap contextMap) {
|
||||
+ return super.createWorldConfigLoaderBuilder(contextMap)
|
||||
+ .defaultOptions(options -> options
|
||||
+ .header(contextMap.require(WORLD_NAME).equals(WORLD_DEFAULTS) ? WORLD_DEFAULTS_HEADER : WORLD_HEADER.apply(contextMap))
|
||||
+ .serializers(serializers -> serializers
|
||||
+ .register(new TypeToken<Reference2IntMap<?>>() {}, new FastutilMapSerializer.SomethingToPrimitive<Reference2IntMap<?>>(Reference2IntOpenHashMap::new, Integer.TYPE))
|
||||
+ .register(new TypeToken<Reference2LongMap<?>>() {}, new FastutilMapSerializer.SomethingToPrimitive<Reference2LongMap<?>>(Reference2LongOpenHashMap::new, Long.TYPE))
|
||||
+ .register(new TypeToken<Table<?, ?, ?>>() {}, new TableSerializer())
|
||||
+ .register(new StringRepresentableSerializer())
|
||||
+ .register(IntOr.Default.SERIALIZER)
|
||||
+ .register(IntOr.Disabled.SERIALIZER)
|
||||
+ .register(DoubleOrDefault.SERIALIZER)
|
||||
+ .register(BooleanOrDefault.SERIALIZER)
|
||||
+ .register(Duration.SERIALIZER)
|
||||
+ .register(EngineMode.SERIALIZER)
|
||||
+ .register(FallbackValueSerializer.create(contextMap.require(PaperConfigurations.SPIGOT_WORLD_CONFIG_CONTEXT_KEY).get(), MinecraftServer::getServer))
|
||||
+ .register(new RegistryValueSerializer<>(new TypeToken<EntityType<?>>() {}, Registry.ENTITY_TYPE_REGISTRY, true))
|
||||
+ .register(new RegistryValueSerializer<>(Item.class, Registry.ITEM_REGISTRY, true))
|
||||
+ .register(new RegistryHolderSerializer<>(new TypeToken<ConfiguredFeature<?, ?>>() {}, Registry.CONFIGURED_FEATURE_REGISTRY, false))
|
||||
+ .register(new RegistryHolderSerializer<>(Item.class, Registry.ITEM_REGISTRY, true))
|
||||
+ )
|
||||
+ );
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ protected void applyWorldConfigTransformations(final ContextMap contextMap, final ConfigurationNode node) throws ConfigurateException {
|
||||
+ final ConfigurationNode version = node.node(Configuration.VERSION_FIELD);
|
||||
+ final String world = contextMap.require(WORLD_NAME);
|
||||
+ if (version.virtual()) {
|
||||
+ LOGGER.warn("The Gale world config file for " + world + " didn't have a version set, assuming latest");
|
||||
+ version.raw(GaleWorldConfiguration.CURRENT_VERSION);
|
||||
+ }
|
||||
+ if (GaleRemovedConfigurations.REMOVED_WORLD_PATHS.length > 0) {
|
||||
+ ConfigurationTransformation.Builder builder = ConfigurationTransformation.builder();
|
||||
+ for (NodePath path : GaleRemovedConfigurations.REMOVED_WORLD_PATHS) {
|
||||
+ builder.addAction(path, TransformAction.remove());
|
||||
+ }
|
||||
+ builder.build().apply(node);
|
||||
+ }
|
||||
+ // ADD FUTURE TRANSFORMS HERE
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ protected void applyGlobalConfigTransformations(ConfigurationNode node) throws ConfigurateException {
|
||||
+ if (GaleRemovedConfigurations.REMOVED_GLOBAL_PATHS.length > 0) {
|
||||
+ ConfigurationTransformation.Builder builder = ConfigurationTransformation.builder();
|
||||
+ for (NodePath path : GaleRemovedConfigurations.REMOVED_GLOBAL_PATHS) {
|
||||
+ builder.addAction(path, TransformAction.remove());
|
||||
+ }
|
||||
+ builder.build().apply(node);
|
||||
+ }
|
||||
+ // ADD FUTURE TRANSFORMS HERE
|
||||
+ }
|
||||
+
|
||||
+ private static final List<Transformations.DefaultsAware> DEFAULT_AWARE_TRANSFORMATIONS = Collections.emptyList();
|
||||
+
|
||||
+ @Override
|
||||
+ protected void applyDefaultsAwareWorldConfigTransformations(final ContextMap contextMap, final ConfigurationNode worldNode, final ConfigurationNode defaultsNode) throws ConfigurateException {
|
||||
+ final ConfigurationTransformation.Builder builder = ConfigurationTransformation.builder();
|
||||
+ // ADD FUTURE TRANSFORMS HERE (these transforms run after the defaults have been merged into the node)
|
||||
+ DEFAULT_AWARE_TRANSFORMATIONS.forEach(transform -> transform.apply(builder, contextMap, defaultsNode));
|
||||
+
|
||||
+ ConfigurationTransformation transformation;
|
||||
+ try {
|
||||
+ transformation = builder.build(); // build throws IAE if no actions were provided (bad zml)
|
||||
+ } catch (IllegalArgumentException ignored) {
|
||||
+ return;
|
||||
+ }
|
||||
+ transformation.apply(worldNode);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public GaleWorldConfiguration createWorldConfig(final ContextMap contextMap) {
|
||||
+ final String levelName = contextMap.require(WORLD_NAME);
|
||||
+ try {
|
||||
+ return super.createWorldConfig(contextMap);
|
||||
+ } catch (IOException exception) {
|
||||
+ throw new RuntimeException("Could not create Gale world config for " + levelName, exception);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ protected boolean isConfigType(final Type type) {
|
||||
+ return ConfigurationPart.class.isAssignableFrom(erase(type));
|
||||
+ }
|
||||
+
|
||||
+ public void reloadConfigs(MinecraftServer server) {
|
||||
+ try {
|
||||
+ this.initializeGlobalConfiguration(reloader(this.globalConfigClass, GaleGlobalConfiguration.get()));
|
||||
+ this.initializeWorldDefaultsConfiguration();
|
||||
+ for (ServerLevel level : server.getAllLevels()) {
|
||||
+ this.createWorldConfig(PaperConfigurations.createWorldContextMap(level), reloader(this.worldConfigClass, level.galeConfig()));
|
||||
+ }
|
||||
+ } catch (Exception ex) {
|
||||
+ throw new RuntimeException("Could not reload Gale configuration files", ex);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static GaleConfigurations setup(final Path configDir) throws Exception {
|
||||
+ try {
|
||||
+ PaperConfigurations.createDirectoriesSymlinkAware(configDir);
|
||||
+ return new GaleConfigurations(configDir);
|
||||
+ } catch (final IOException ex) {
|
||||
+ throw new RuntimeException("Could not setup GaleConfigurations", ex);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int getWorldConfigurationCurrentVersion() {
|
||||
+ return GaleWorldConfiguration.CURRENT_VERSION;
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
diff --git a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..83b804746cce3660f4e3d1027375b052d4d7f59a
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java
|
||||
@@ -0,0 +1,30 @@
|
||||
+// Gale - Gale configuration
|
||||
+
|
||||
+package org.galemc.gale.configuration;
|
||||
+
|
||||
+import io.papermc.paper.configuration.Configuration;
|
||||
+import io.papermc.paper.configuration.ConfigurationPart;
|
||||
+import org.spongepowered.configurate.objectmapping.meta.Setting;
|
||||
+
|
||||
+@SuppressWarnings({"CanBeFinal", "FieldCanBeLocal", "FieldMayBeFinal", "NotNullFieldNotInitialized", "InnerClassMayBeStatic"})
|
||||
+public class GaleGlobalConfiguration extends ConfigurationPart {
|
||||
+ static final int CURRENT_VERSION = 18;
|
||||
+ private static GaleGlobalConfiguration instance;
|
||||
+ public static GaleGlobalConfiguration get() {
|
||||
+ return instance;
|
||||
+ }
|
||||
+ static void set(GaleGlobalConfiguration instance) {
|
||||
+ GaleGlobalConfiguration.instance = instance;
|
||||
+ }
|
||||
+
|
||||
+ @Setting(Configuration.VERSION_FIELD)
|
||||
+ public int version = CURRENT_VERSION;
|
||||
+
|
||||
+ public SmallOptimizations smallOptimizations;
|
||||
+ public class SmallOptimizations extends ConfigurationPart {
|
||||
+
|
||||
+ public int dummyValue = 0;
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
diff --git a/src/main/java/org/galemc/gale/configuration/GaleRemovedConfigurations.java b/src/main/java/org/galemc/gale/configuration/GaleRemovedConfigurations.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..f95f4166999d5b6d5363a49a181ffae618e2dce0
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/galemc/gale/configuration/GaleRemovedConfigurations.java
|
||||
@@ -0,0 +1,13 @@
|
||||
+// Gale - Gale configuration
|
||||
+
|
||||
+package org.galemc.gale.configuration;
|
||||
+
|
||||
+import org.spongepowered.configurate.NodePath;
|
||||
+
|
||||
+interface GaleRemovedConfigurations {
|
||||
+
|
||||
+ NodePath[] REMOVED_WORLD_PATHS = {};
|
||||
+
|
||||
+ NodePath[] REMOVED_GLOBAL_PATHS = {};
|
||||
+
|
||||
+}
|
||||
diff --git a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..b2113c0ad2a7e6e19b3b981428cfc6f9df8423ac
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
||||
@@ -0,0 +1,40 @@
|
||||
+// Gale - Gale configuration
|
||||
+
|
||||
+package org.galemc.gale.configuration;
|
||||
+
|
||||
+import com.mojang.logging.LogUtils;
|
||||
+import io.papermc.paper.configuration.Configuration;
|
||||
+import io.papermc.paper.configuration.ConfigurationPart;
|
||||
+import io.papermc.paper.configuration.PaperConfigurations;
|
||||
+import net.minecraft.resources.ResourceLocation;
|
||||
+import org.slf4j.Logger;
|
||||
+import org.spigotmc.SpigotWorldConfig;
|
||||
+import org.spongepowered.configurate.objectmapping.meta.Setting;
|
||||
+
|
||||
+@SuppressWarnings({"FieldCanBeLocal", "FieldMayBeFinal", "NotNullFieldNotInitialized", "InnerClassMayBeStatic"})
|
||||
+public class GaleWorldConfiguration extends ConfigurationPart {
|
||||
+ private static final Logger LOGGER = LogUtils.getLogger();
|
||||
+ public static final int CURRENT_VERSION = 19;
|
||||
+
|
||||
+ private transient final SpigotWorldConfig spigotConfig;
|
||||
+ private transient final ResourceLocation worldKey;
|
||||
+ public GaleWorldConfiguration(SpigotWorldConfig spigotConfig, ResourceLocation worldKey) {
|
||||
+ this.spigotConfig = spigotConfig;
|
||||
+ this.worldKey = worldKey;
|
||||
+ }
|
||||
+
|
||||
+ public boolean isDefault() {
|
||||
+ return this.worldKey.equals(PaperConfigurations.WORLD_DEFAULTS_KEY);
|
||||
+ }
|
||||
+
|
||||
+ @Setting(Configuration.VERSION_FIELD)
|
||||
+ public int version = CURRENT_VERSION;
|
||||
+
|
||||
+ public SmallOptimizations smallOptimizations;
|
||||
+ public class SmallOptimizations extends ConfigurationPart {
|
||||
+
|
||||
+ public int dummyValue = 0;
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
diff --git a/src/main/java/org/galemc/gale/configuration/timingsexport/GaleConfigurationTimingsExport.java b/src/main/java/org/galemc/gale/configuration/timingsexport/GaleConfigurationTimingsExport.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..5196416daeba635b303fa553c92d0741d5fb154c
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/galemc/gale/configuration/timingsexport/GaleConfigurationTimingsExport.java
|
||||
@@ -0,0 +1,19 @@
|
||||
+// Gale - Gale configuration
|
||||
+
|
||||
+package org.galemc.gale.configuration.timingsexport;
|
||||
+
|
||||
+import co.aikar.timings.TimingsExport;
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.json.simple.JSONObject;
|
||||
+
|
||||
+public final class GaleConfigurationTimingsExport {
|
||||
+
|
||||
+ private GaleConfigurationTimingsExport() {}
|
||||
+
|
||||
+ public static @NotNull JSONObject get() {
|
||||
+ var json = TimingsExport.mapAsJSON(Bukkit.spigot().getGaleConfig(), null);
|
||||
+ return json;
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
@@ -0,0 +1,77 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MartijnMuijsers <martijnmuijsers@live.nl>
|
||||
Date: Wed, 23 Nov 2022 16:02:19 +0100
|
||||
Subject: [PATCH] Recommend disabling timings on startup
|
||||
|
||||
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
This patch is based on the following patch:
|
||||
"Disable Paper timings by default"
|
||||
By: Paul Sauve <paul@technove.co>
|
||||
As part of: Airplane (https://github.com/TECHNOVE/Airplane)
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
* Airplane copyright *
|
||||
|
||||
Airplane
|
||||
Copyright (C) 2020 Technove LLC
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java
|
||||
index 63ec2ebb71aa0e0dbb64bbce7cd3c9494e9ce2e7..d66b0d5f77b273af053e3471af4ef18956ba85ff 100644
|
||||
--- a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java
|
||||
+++ b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java
|
||||
@@ -7,6 +7,7 @@ import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.protocol.game.ServerboundPlaceRecipePacket;
|
||||
+import org.bukkit.Bukkit;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
|
||||
import org.spongepowered.configurate.objectmapping.meta.Comment;
|
||||
@@ -16,6 +17,7 @@ import org.spongepowered.configurate.objectmapping.meta.Setting;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
+import java.util.logging.Level;
|
||||
|
||||
@SuppressWarnings({"CanBeFinal", "FieldCanBeLocal", "FieldMayBeFinal", "NotNullFieldNotInitialized", "InnerClassMayBeStatic"})
|
||||
public class GlobalConfiguration extends ConfigurationPart {
|
||||
@@ -50,7 +52,10 @@ public class GlobalConfiguration extends ConfigurationPart {
|
||||
public Timings timings;
|
||||
|
||||
public class Timings extends ConfigurationPart.Post {
|
||||
- public boolean enabled = true;
|
||||
+ // Gale start - recommend disabling timings on startup
|
||||
+ public boolean enabled = false; // Gale - set default value to false
|
||||
+ public boolean warnIfEnabled = true;
|
||||
+ // Gale end - recommend disabling timings on startup
|
||||
public boolean verbose = true;
|
||||
public String url = "https://timings.aikar.co/";
|
||||
public boolean serverNamePrivacy = false;
|
||||
@@ -64,6 +69,13 @@ public class GlobalConfiguration extends ConfigurationPart {
|
||||
|
||||
@Override
|
||||
public void postProcess() {
|
||||
+ // Gale start - recommend disabling timings on startup
|
||||
+ if (enabled && warnIfEnabled) {
|
||||
+ net.minecraft.server.MinecraftServer.LOGGER.warn("To improve performance, we recommend setting timings.enabled to false in paper-global.yml");
|
||||
+ net.minecraft.server.MinecraftServer.LOGGER.warn("(If you do this, timings will not start on server startup, but you can still start timings later by using /timings on)");
|
||||
+ net.minecraft.server.MinecraftServer.LOGGER.warn("If you would like to disable this message, set timings.warn-if-enabled to false in paper-global.yml.");
|
||||
+ }
|
||||
+ // Gale end - recommend disabling timings on startup
|
||||
MinecraftTimings.processConfig(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MartijnMuijsers <martijnmuijsers@live.nl>
|
||||
Date: Wed, 23 Nov 2022 16:15:43 +0100
|
||||
Subject: [PATCH] Strip raytracing for EntityLiving#hasLineOfSight
|
||||
|
||||
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
This patch is based on the following patch:
|
||||
"Strip raytracing for EntityLiving#hasLineOfSight"
|
||||
By: Paul Sauve <paul@technove.co>
|
||||
As part of: Airplane (https://github.com/TECHNOVE/Airplane)
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
* Airplane description *
|
||||
|
||||
The IBlockAccess#rayTrace method is very wasteful in both allocations,
|
||||
and in logic. While EntityLiving#hasLineOfSight provides static
|
||||
parameters for collisions with blocks and fluids, the method still does
|
||||
a lot of dynamic checks for both of these, which result in extra work.
|
||||
As well, since the fluid collision option is set to NONE, the entire
|
||||
fluid collision system is completely unneeded, yet used anyways.
|
||||
|
||||
* Airplane copyright *
|
||||
|
||||
Airplane
|
||||
Copyright (C) 2020 Technove LLC
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index 3bfa0c6a0d82ed980b3289051892a6d1745ebb69..4eb6d1536cdc105aacf7507b69b7ac16a2dbd78a 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -3607,7 +3607,7 @@ public abstract class LivingEntity extends Entity {
|
||||
Vec3 vec3d1 = new Vec3(entity.getX(), entity.getEyeY(), entity.getZ());
|
||||
|
||||
// Paper - diff on change - used in CraftLivingEntity#hasLineOfSight(Location) and CraftWorld#lineOfSightExists
|
||||
- return vec3d1.distanceToSqr(vec3d) > 128D * 128D ? false : this.level.clip(new ClipContext(vec3d, vec3d1, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, this)).getType() == HitResult.Type.MISS; // Paper - use distanceToSqr
|
||||
+ return vec3d1.distanceToSqr(vec3d) > 128D * 128D ? false : this.level.rayTraceDirect(vec3d, vec3d1, net.minecraft.world.phys.shapes.CollisionContext.of(this)) == net.minecraft.world.phys.BlockHitResult.Type.MISS; // Paper - use distanceToSqr // Gale - Airplane - strip raytracing for EntityLiving#hasLineOfSight
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/BlockGetter.java b/src/main/java/net/minecraft/world/level/BlockGetter.java
|
||||
index d1eefa6ef3e9abfe7af4d8310aa64465fa2d5463..413f5cc82e94a6308279be618d8ed1438b3bfb9d 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/BlockGetter.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/BlockGetter.java
|
||||
@@ -73,6 +73,16 @@ public interface BlockGetter extends LevelHeightAccessor {
|
||||
});
|
||||
}
|
||||
|
||||
+ // Gale start - Airplane - strip raytracing for EntityLiving#hasLineOfSight - broken down variant of below rayTraceBlock, used by World#rayTraceDirect
|
||||
+ default net.minecraft.world.phys.BlockHitResult.Type rayTraceBlockDirect(Vec3 vec3d, Vec3 vec3d1, BlockPos blockposition, BlockState iblockdata, net.minecraft.world.phys.shapes.CollisionContext voxelshapecoll) {
|
||||
+ if (iblockdata.isAir()) return null; // Tuinity - optimise air cases
|
||||
+ VoxelShape voxelshape = ClipContext.Block.COLLIDER.get(iblockdata, this, blockposition, voxelshapecoll);
|
||||
+ net.minecraft.world.phys.BlockHitResult movingobjectpositionblock = this.clipWithInteractionOverride(vec3d, vec3d1, blockposition, voxelshape, iblockdata);
|
||||
+
|
||||
+ return movingobjectpositionblock == null ? null : movingobjectpositionblock.getType();
|
||||
+ }
|
||||
+ // Gale end - Airplane - strip raytracing for EntityLiving#hasLineOfSight - broken down variant of below rayTraceBlock, used by World#rayTraceDirect
|
||||
+
|
||||
// CraftBukkit start - moved block handling into separate method for use by Block#rayTrace
|
||||
default BlockHitResult clip(ClipContext raytrace1, BlockPos blockposition) {
|
||||
// Paper start - Prevent raytrace from loading chunks
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
||||
index ed65805906a6e1e03c2d96b76bba749a9dfd27be..bf82deab0fb527cfc7f480f8db7801fa066c4e4e 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Level.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
||||
@@ -407,6 +407,91 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||
return null;
|
||||
}
|
||||
|
||||
+ // Gale start - Airplane - strip raytracing for EntityLiving#hasLineOfSight - broken down method of raytracing for EntityLiving#hasLineOfSight, replaces IBlockAccess#rayTrace(RayTrace)
|
||||
+ public net.minecraft.world.phys.BlockHitResult.Type rayTraceDirect(net.minecraft.world.phys.Vec3 vec3d, net.minecraft.world.phys.Vec3 vec3d1, net.minecraft.world.phys.shapes.CollisionContext voxelshapecoll) {
|
||||
+ // most of this code comes from IBlockAccess#a(RayTrace, BiFunction, Function), but removes the needless functions
|
||||
+ if (vec3d.equals(vec3d1)) {
|
||||
+ return net.minecraft.world.phys.BlockHitResult.Type.MISS;
|
||||
+ }
|
||||
+
|
||||
+ double endX = Mth.lerp(-1.0E-7D, vec3d1.x, vec3d.x);
|
||||
+ double endY = Mth.lerp(-1.0E-7D, vec3d1.y, vec3d.y);
|
||||
+ double endZ = Mth.lerp(-1.0E-7D, vec3d1.z, vec3d.z);
|
||||
+
|
||||
+ double startX = Mth.lerp(-1.0E-7D, vec3d.x, vec3d1.x);
|
||||
+ double startY = Mth.lerp(-1.0E-7D, vec3d.y, vec3d1.y);
|
||||
+ double startZ = Mth.lerp(-1.0E-7D, vec3d.z, vec3d1.z);
|
||||
+
|
||||
+ int currentX = Mth.floor(startX);
|
||||
+ int currentY = Mth.floor(startY);
|
||||
+ int currentZ = Mth.floor(startZ);
|
||||
+
|
||||
+ BlockPos.MutableBlockPos currentBlock = new BlockPos.MutableBlockPos(currentX, currentY, currentZ);
|
||||
+
|
||||
+ LevelChunk chunk = this.getChunkIfLoaded(currentBlock);
|
||||
+ if (chunk == null) {
|
||||
+ return net.minecraft.world.phys.BlockHitResult.Type.MISS;
|
||||
+ }
|
||||
+
|
||||
+ net.minecraft.world.phys.BlockHitResult.Type initialCheck = this.rayTraceBlockDirect(vec3d, vec3d1, currentBlock, chunk.getBlockState(currentBlock), voxelshapecoll);
|
||||
+
|
||||
+ if (initialCheck != null) {
|
||||
+ return initialCheck;
|
||||
+ }
|
||||
+
|
||||
+ double diffX = endX - startX;
|
||||
+ double diffY = endY - startY;
|
||||
+ double diffZ = endZ - startZ;
|
||||
+
|
||||
+ int xDirection = Mth.sign(diffX);
|
||||
+ int yDirection = Mth.sign(diffY);
|
||||
+ int zDirection = Mth.sign(diffZ);
|
||||
+
|
||||
+ double normalizedX = xDirection == 0 ? Double.MAX_VALUE : (double) xDirection / diffX;
|
||||
+ double normalizedY = yDirection == 0 ? Double.MAX_VALUE : (double) yDirection / diffY;
|
||||
+ double normalizedZ = zDirection == 0 ? Double.MAX_VALUE : (double) zDirection / diffZ;
|
||||
+
|
||||
+ double normalizedXDirection = normalizedX * (xDirection > 0 ? 1.0D - Mth.frac(startX) : Mth.frac(startX));
|
||||
+ double normalizedYDirection = normalizedY * (yDirection > 0 ? 1.0D - Mth.frac(startY) : Mth.frac(startY));
|
||||
+ double normalizedZDirection = normalizedZ * (zDirection > 0 ? 1.0D - Mth.frac(startZ) : Mth.frac(startZ));
|
||||
+
|
||||
+ net.minecraft.world.phys.BlockHitResult.Type result;
|
||||
+
|
||||
+ do {
|
||||
+ if (normalizedXDirection > 1.0D && normalizedYDirection > 1.0D && normalizedZDirection > 1.0D) {
|
||||
+ return net.minecraft.world.phys.BlockHitResult.Type.MISS;
|
||||
+ }
|
||||
+
|
||||
+ if (normalizedXDirection < normalizedYDirection) {
|
||||
+ if (normalizedXDirection < normalizedZDirection) {
|
||||
+ currentX += xDirection;
|
||||
+ normalizedXDirection += normalizedX;
|
||||
+ } else {
|
||||
+ currentZ += zDirection;
|
||||
+ normalizedZDirection += normalizedZ;
|
||||
+ }
|
||||
+ } else if (normalizedYDirection < normalizedZDirection) {
|
||||
+ currentY += yDirection;
|
||||
+ normalizedYDirection += normalizedY;
|
||||
+ } else {
|
||||
+ currentZ += zDirection;
|
||||
+ normalizedZDirection += normalizedZ;
|
||||
+ }
|
||||
+
|
||||
+ currentBlock.set(currentX, currentY, currentZ);
|
||||
+ if (chunk.getPos().x != currentBlock.getX() >> 4 || chunk.getPos().z != currentBlock.getZ() >> 4) {
|
||||
+ chunk = this.getChunkIfLoaded(currentBlock);
|
||||
+ if (chunk == null) {
|
||||
+ return net.minecraft.world.phys.BlockHitResult.Type.MISS;
|
||||
+ }
|
||||
+ }
|
||||
+ result = this.rayTraceBlockDirect(vec3d, vec3d1, currentBlock, chunk.getBlockState(currentBlock), voxelshapecoll);
|
||||
+ } while (result == null);
|
||||
+
|
||||
+ return result;
|
||||
+ }
|
||||
+ // Gale end - Airplane - strip raytracing for EntityLiving#hasLineOfSight - broken down method of raytracing for EntityLiving#hasLineOfSight, replaces IBlockAccess#rayTrace(RayTrace)
|
||||
+
|
||||
public boolean isInWorldBounds(BlockPos pos) {
|
||||
return pos.isInsideBuildHeightAndWorldBoundsHorizontal(this); // Paper - use better/optimized check
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MartijnMuijsers <martijnmuijsers@live.nl>
|
||||
Date: Wed, 23 Nov 2022 16:22:47 +0100
|
||||
Subject: [PATCH] Simpler ShapelessRecipe comparison for vanilla
|
||||
|
||||
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
This patch is based on the following patch:
|
||||
"Simpler ShapelessRecipes comparison for Vanilla"
|
||||
By: Paul Sauve <paul@technove.co>
|
||||
As part of: Airplane (https://github.com/TECHNOVE/Airplane)
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
* Airplane description *
|
||||
|
||||
Paper added a fancy sorting comparison due to Bukkit recipes breaking
|
||||
the vanilla one, however this is far more advanced than what you need
|
||||
for all the vanilla recipes.
|
||||
|
||||
* Airplane copyright *
|
||||
|
||||
Airplane
|
||||
Copyright (C) 2020 Technove LLC
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/item/crafting/ShapelessRecipe.java b/src/main/java/net/minecraft/world/item/crafting/ShapelessRecipe.java
|
||||
index ffe5476d8ed15ee4384b679c341688787205ce59..367ed0c8fba3ed4672970f6042db393a3eda6560 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/crafting/ShapelessRecipe.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/crafting/ShapelessRecipe.java
|
||||
@@ -25,8 +25,14 @@ public class ShapelessRecipe implements CraftingRecipe {
|
||||
final String group;
|
||||
final ItemStack result;
|
||||
final NonNullList<Ingredient> ingredients;
|
||||
+ private final boolean isBukkit; // Gale - Airplane - simpler ShapelessRecipe comparison for vanilla
|
||||
|
||||
public ShapelessRecipe(ResourceLocation id, String group, ItemStack output, NonNullList<Ingredient> input) {
|
||||
+ // Gale start - Airplane - simpler ShapelessRecipe comparison for vanilla
|
||||
+ this(id, group, output, input, false);
|
||||
+ }
|
||||
+ public ShapelessRecipe(ResourceLocation id, String group, ItemStack output, NonNullList<Ingredient> input, boolean isBukkit) { this.isBukkit = isBukkit;
|
||||
+ // Gale end - Airplane - simpler ShapelessRecipe comparison for vanilla
|
||||
this.id = id;
|
||||
this.group = group;
|
||||
this.result = output;
|
||||
@@ -73,6 +79,28 @@ public class ShapelessRecipe implements CraftingRecipe {
|
||||
}
|
||||
|
||||
public boolean matches(CraftingContainer inventory, Level world) {
|
||||
+ // Gale start - Airplane - simpler ShapelessRecipe comparison for vanilla
|
||||
+ if (!this.isBukkit) {
|
||||
+ java.util.List<Ingredient> ingredients = com.google.common.collect.Lists.newArrayList(this.ingredients.toArray(new Ingredient[0]));
|
||||
+
|
||||
+ inventory: for (int index = 0; index < inventory.getContainerSize(); index++) {
|
||||
+ ItemStack itemStack = inventory.getItem(index);
|
||||
+
|
||||
+ if (!itemStack.isEmpty()) {
|
||||
+ for (int i = 0; i < ingredients.size(); i++) {
|
||||
+ if (ingredients.get(i).test(itemStack)) {
|
||||
+ ingredients.remove(i);
|
||||
+ continue inventory;
|
||||
+ }
|
||||
+ }
|
||||
+ return false;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return ingredients.isEmpty();
|
||||
+ }
|
||||
+ // Gale end - Airplane - simpler ShapelessRecipe comparison for vanilla
|
||||
+
|
||||
StackedContents autorecipestackmanager = new StackedContents();
|
||||
int i = 0;
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java
|
||||
index 0b3b46348ac9195bff1492ffc11fcbff7d3f5c6f..ec46ccb2bcc697461e433d265eb593d3360dd469 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java
|
||||
@@ -43,6 +43,6 @@ public class CraftShapelessRecipe extends ShapelessRecipe implements CraftRecipe
|
||||
data.set(i, toNMS(ingred.get(i), true));
|
||||
}
|
||||
|
||||
- MinecraftServer.getServer().getRecipeManager().addRecipe(new net.minecraft.world.item.crafting.ShapelessRecipe(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), CraftItemStack.asNMSCopy(this.getResult()), data));
|
||||
+ MinecraftServer.getServer().getRecipeManager().addRecipe(new net.minecraft.world.item.crafting.ShapelessRecipe(CraftNamespacedKey.toMinecraft(this.getKey()), this.getGroup(), CraftItemStack.asNMSCopy(this.getResult()), data, true)); // Gale - Airplane - simpler ShapelessRecipe comparison for vanilla
|
||||
}
|
||||
}
|
||||
141
patches/server/0007-Reduce-projectile-chunk-loading.patch
Normal file
141
patches/server/0007-Reduce-projectile-chunk-loading.patch
Normal file
@@ -0,0 +1,141 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MartijnMuijsers <martijnmuijsers@live.nl>
|
||||
Date: Thu, 24 Nov 2022 12:00:55 +0100
|
||||
Subject: [PATCH] Reduce projectile chunk loading
|
||||
|
||||
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
This patch is based on the following patch:
|
||||
"Reduce projectile chunk loading"
|
||||
By: Paul Sauve <paul@technove.co>
|
||||
As part of: Airplane (https://github.com/TECHNOVE/Airplane)
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
* Airplane copyright *
|
||||
|
||||
Airplane
|
||||
Copyright (C) 2020 Technove LLC
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
|
||||
index 713c11d6547cb02ac4b6a02aec07a8ba68019f3f..d6b714ef427052bc9378567542c9f0b56de58b6c 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java
|
||||
@@ -42,6 +42,44 @@ public abstract class Projectile extends Entity {
|
||||
super(type, world);
|
||||
}
|
||||
|
||||
+ // Gale start - Airplane - reduce projectile chunk loading
|
||||
+ private static int chunksLoadedThisTick = 0;
|
||||
+ private static int chunksLoadedInTick;
|
||||
+ private int chunksLoadedByProjectile = 0;
|
||||
+
|
||||
+ @Override
|
||||
+ public void setPos(double x, double y, double z) {
|
||||
+ int currentTick = net.minecraft.server.MinecraftServer.currentTick;
|
||||
+ if (chunksLoadedInTick != currentTick) {
|
||||
+ chunksLoadedInTick = currentTick;
|
||||
+ chunksLoadedThisTick = 0;
|
||||
+ }
|
||||
+ int previousX = Mth.floor(this.getX()) >> 4, previousZ = Mth.floor(this.getZ()) >> 4;
|
||||
+ int newX = Mth.floor(x) >> 4, newZ = Mth.floor(z) >> 4;
|
||||
+ if (previousX != newX || previousZ != newZ) {
|
||||
+ boolean isLoaded = ((net.minecraft.server.level.ServerChunkCache) this.level.getChunkSource()).getChunkAtIfLoadedImmediately(newX, newZ) != null;
|
||||
+ if (!isLoaded) {
|
||||
+ int maxChunkLoadsPerTick = this.level.galeConfig().smallOptimizations.maxProjectileChunkLoads.perTick;
|
||||
+ if (maxChunkLoadsPerTick >= 0 && chunksLoadedThisTick > maxChunkLoadsPerTick) {
|
||||
+ return;
|
||||
+ }
|
||||
+ int maxChunkLoadsPerProjectile = this.level.galeConfig().smallOptimizations.maxProjectileChunkLoads.perProjectile.max;
|
||||
+ if (maxChunkLoadsPerProjectile >= 0 && this.chunksLoadedByProjectile >= maxChunkLoadsPerProjectile) {
|
||||
+ if (this.level.galeConfig().smallOptimizations.maxProjectileChunkLoads.perProjectile.removeFromWorld) {
|
||||
+ this.discard();
|
||||
+ } else if (this.level.galeConfig().smallOptimizations.maxProjectileChunkLoads.perProjectile.resetMovement) {
|
||||
+ this.setDeltaMovement(0, this.getDeltaMovement().y, 0);
|
||||
+ }
|
||||
+ return;
|
||||
+ }
|
||||
+ chunksLoadedThisTick++;
|
||||
+ this.chunksLoadedByProjectile++;
|
||||
+ }
|
||||
+ }
|
||||
+ super.setPos(x, y, z);
|
||||
+ }
|
||||
+ // Gale end - Airplane - reduce projectile chunk loading
|
||||
+
|
||||
public void setOwner(@Nullable Entity entity) {
|
||||
if (entity != null) {
|
||||
this.ownerUUID = entity.getUUID();
|
||||
diff --git a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
||||
index b2113c0ad2a7e6e19b3b981428cfc6f9df8423ac..fa513614e32963fede05e05cacefbf31010d0c07 100644
|
||||
--- a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
||||
+++ b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
||||
@@ -33,7 +33,55 @@ public class GaleWorldConfiguration extends ConfigurationPart {
|
||||
public SmallOptimizations smallOptimizations;
|
||||
public class SmallOptimizations extends ConfigurationPart {
|
||||
|
||||
- public int dummyValue = 0;
|
||||
+ // Gale start - Airplane - reduce projectile chunk loading
|
||||
+ public MaxProjectileChunkLoads maxProjectileChunkLoads;
|
||||
+ public class MaxProjectileChunkLoads extends ConfigurationPart {
|
||||
+
|
||||
+ /**
|
||||
+ * The maximum number of chunks that can be synchronously loaded by all projectiles in one world in a tick.
|
||||
+ * Any value < 0 means no maximum.
|
||||
+ * <ul>
|
||||
+ * <li><i>Default</i>: 10</li>
|
||||
+ * <li><i>Vanilla</i>: -1</li>
|
||||
+ * </ul>
|
||||
+ */
|
||||
+ public int perTick = 10;
|
||||
+
|
||||
+ public PerProjectile perProjectile;
|
||||
+ public class PerProjectile extends ConfigurationPart {
|
||||
+
|
||||
+ /**
|
||||
+ * The maximum number of chunks that can be synchronously loaded by a projectile throughout its lifetime.
|
||||
+ * Any value < 0 means no maximum.
|
||||
+ * <ul>
|
||||
+ * <li><i>Default</i>: 10</li>
|
||||
+ * <li><i>Vanilla</i>: -1</li>
|
||||
+ * </ul>
|
||||
+ */
|
||||
+ public int max = 10;
|
||||
+
|
||||
+ /**
|
||||
+ * Whether to set the planar velocity of projectiles that cross the {@link #max} threshold
|
||||
+ * to zero, so that they stop attempting to cross chunk boundaries.
|
||||
+ * This has no effect if {@link #removeFromWorld} is true.
|
||||
+ * <ul>
|
||||
+ * <li><i>Default</i>: false</li>
|
||||
+ * </ul>
|
||||
+ */
|
||||
+ public boolean resetMovement = false;
|
||||
+
|
||||
+ /**
|
||||
+ * Whether to remove projectiles that cross the {@link #max} threshold from the world entirely.
|
||||
+ * <ul>
|
||||
+ * <li><i>Default</i>: false</li>
|
||||
+ * </ul>
|
||||
+ */
|
||||
+ public boolean removeFromWorld = false;
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ }
|
||||
+ // Gale end - Airplane - reduce projectile chunk loading
|
||||
|
||||
}
|
||||
|
||||
99
patches/server/0008-Reduce-spooky-season-checks.patch
Normal file
99
patches/server/0008-Reduce-spooky-season-checks.patch
Normal file
@@ -0,0 +1,99 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MartijnMuijsers <martijnmuijsers@live.nl>
|
||||
Date: Wed, 23 Nov 2022 16:29:01 +0100
|
||||
Subject: [PATCH] Reduce spooky season checks
|
||||
|
||||
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
This patch is based on the following patch:
|
||||
"Only check for spooky season once an hour"
|
||||
By: Paul Sauve <paul@technove.co>
|
||||
As part of: Airplane (https://github.com/TECHNOVE/Airplane)
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
* Airplane copyright *
|
||||
|
||||
Airplane
|
||||
Copyright (C) 2020 Technove LLC
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ambient/Bat.java b/src/main/java/net/minecraft/world/entity/ambient/Bat.java
|
||||
index def01d221f36d71640bf4ef982a984909aacc6da..e7147ee37139c9e823787f1f815fc0aee8da4f59 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ambient/Bat.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ambient/Bat.java
|
||||
@@ -28,6 +28,7 @@ import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
|
||||
+import org.galemc.gale.configuration.GaleGlobalConfiguration;
|
||||
|
||||
public class Bat extends AmbientCreature {
|
||||
|
||||
@@ -253,12 +254,25 @@ public class Bat extends AmbientCreature {
|
||||
}
|
||||
}
|
||||
|
||||
+ // Gale start - Airplane - reduced spooky season checks
|
||||
+ private static boolean isSpookySeason = false;
|
||||
+ private static int lastSpookyCheck = -((1 << 30) - 1);
|
||||
+ // Gale end - Airplane - reduced spooky season checks
|
||||
private static boolean isHalloween() {
|
||||
+ // Gale start - Airplane - reduced spooky season checks
|
||||
+ int checkSpookySeasonInterval = GaleGlobalConfiguration.get().smallOptimizations.reducedIntervals.checkSpookySeason;
|
||||
+ if (checkSpookySeasonInterval <= 1 || net.minecraft.server.MinecraftServer.currentTick - lastSpookyCheck > checkSpookySeasonInterval) {
|
||||
+ // Gale end - Airplane - reduced spooky season checks
|
||||
LocalDate localdate = LocalDate.now();
|
||||
int i = localdate.get(ChronoField.DAY_OF_MONTH);
|
||||
int j = localdate.get(ChronoField.MONTH_OF_YEAR);
|
||||
|
||||
- return j == 10 && i >= 20 || j == 11 && i <= 3;
|
||||
+ // Gale start - Airplane - reduced spooky season checks
|
||||
+ isSpookySeason = j == 10 && i >= 20 || j == 11 && i <= 3;
|
||||
+ lastSpookyCheck = net.minecraft.server.MinecraftServer.currentTick;
|
||||
+ }
|
||||
+ return isSpookySeason;
|
||||
+ // Gale end - Airplane - reduced spooky season checks
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java
|
||||
index 83b804746cce3660f4e3d1027375b052d4d7f59a..1ed2275e3e630c1f0dfa29676a239a4af8264332 100644
|
||||
--- a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java
|
||||
+++ b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java
|
||||
@@ -23,7 +23,23 @@ public class GaleGlobalConfiguration extends ConfigurationPart {
|
||||
public SmallOptimizations smallOptimizations;
|
||||
public class SmallOptimizations extends ConfigurationPart {
|
||||
|
||||
- public int dummyValue = 0;
|
||||
+ public ReducedIntervals reducedIntervals;
|
||||
+ public class ReducedIntervals extends ConfigurationPart {
|
||||
+
|
||||
+ // Gale start - Airplane - reduced spooky season checks
|
||||
+ /**
|
||||
+ * The interval at which to check for the spooky season for bats.
|
||||
+ * Given in ticks.
|
||||
+ * Any value <= 0 behaves like 1.
|
||||
+ * <ul>
|
||||
+ * <li><i>Default</i>: 72000 (1 hour)</li>
|
||||
+ * <li><i>Vanilla</i>: 1</li>
|
||||
+ * </ul>
|
||||
+ */
|
||||
+ public int checkSpookySeason = 20 * 60 * 60;
|
||||
+ // Gale end - Airplane - reduced spooky season checks
|
||||
+
|
||||
+ }
|
||||
|
||||
}
|
||||
|
||||
44
patches/server/0009-Move-random-tick-random.patch
Normal file
44
patches/server/0009-Move-random-tick-random.patch
Normal file
@@ -0,0 +1,44 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MartijnMuijsers <martijnmuijsers@live.nl>
|
||||
Date: Wed, 23 Nov 2022 16:53:40 +0100
|
||||
Subject: [PATCH] Move random tick random
|
||||
|
||||
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
This patch is based on the following patch:
|
||||
"Move ThreadUnsafeRandom Initialization"
|
||||
By: Kevin Raneri <kevin.raneri@gmail.com>
|
||||
As part of: Pufferfish (https://github.com/pufferfish-gg/Pufferfish)
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
* Pufferfish description *
|
||||
|
||||
ThreadUnsafeRandom is initialized too late and some of our patches
|
||||
require it to be initialized earlier. By moving it to the superclass, we
|
||||
initialize it earlier, ensuring that it is available sooner.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index 73e5a7893c49d488525ed53ca09e91d8f90cc7bd..c6e56abd3e62a93320bc11e9ae8f94e1e83a6956 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -792,7 +792,6 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
}
|
||||
// Paper start - optimise random block ticking
|
||||
private final BlockPos.MutableBlockPos chunkTickMutablePosition = new BlockPos.MutableBlockPos();
|
||||
- private final io.papermc.paper.util.math.ThreadUnsafeRandom randomTickRandom = new io.papermc.paper.util.math.ThreadUnsafeRandom(this.random.nextLong());
|
||||
// Paper end
|
||||
|
||||
public void tickChunk(LevelChunk chunk, int randomTickSpeed) {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
||||
index bf82deab0fb527cfc7f480f8db7801fa066c4e4e..7c782e642b7489981d55012d16d9107ae6a0be03 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Level.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
||||
@@ -180,6 +180,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||
public final Map<Explosion.CacheKey, Float> explosionDensityCache = new HashMap<>(); // Paper - Optimize explosions
|
||||
public java.util.ArrayDeque<net.minecraft.world.level.block.RedstoneTorchBlock.Toggle> redstoneUpdateInfos; // Paper - Move from Map in BlockRedstoneTorch to here
|
||||
|
||||
+ public final io.papermc.paper.util.math.ThreadUnsafeRandom randomTickRandom = new io.papermc.paper.util.math.ThreadUnsafeRandom(this.random.nextLong()); // Gale - Pufferfish - move random tick random
|
||||
+
|
||||
// Paper start - fix and optimise world upgrading
|
||||
// copied from below
|
||||
public static ResourceKey<DimensionType> getDimensionKey(DimensionType manager) {
|
||||
126
patches/server/0010-Optimize-random-calls-in-chunk-ticking.patch
Normal file
126
patches/server/0010-Optimize-random-calls-in-chunk-ticking.patch
Normal file
@@ -0,0 +1,126 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MartijnMuijsers <martijnmuijsers@live.nl>
|
||||
Date: Wed, 23 Nov 2022 16:45:45 +0100
|
||||
Subject: [PATCH] Optimize random calls in chunk ticking
|
||||
|
||||
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
This patch is based on the following patch:
|
||||
"Disable Paper timings by default"
|
||||
By: Paul Sauve <paul@technove.co>
|
||||
As part of: Airplane (https://github.com/TECHNOVE/Airplane)
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
The patch also received the following subsequent modification:
|
||||
By: Kevin Raneri <kevin.raneri@gmail.com>
|
||||
As part of: Pufferfish (https://github.com/pufferfish-gg/Pufferfish)
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
* Airplane description *
|
||||
|
||||
Especially at over 30,000 chunks these random calls are fairly heavy. We
|
||||
use a different method here for checking lightning, and for checking
|
||||
ice.
|
||||
|
||||
Lightning: Each chunk now keeps an int of how many ticks until the
|
||||
lightning should strike. This int is a random number from 0 to 100000 * 2,
|
||||
the multiplication is required to keep the probability the same.
|
||||
|
||||
Ice and snow: We just generate a single random number 0-16 and increment
|
||||
it, while checking if it's 0 for the current chunk.
|
||||
|
||||
Depending on configuration for things that tick in a chunk, this is a
|
||||
5-10% improvement.
|
||||
|
||||
* Airplane copyright *
|
||||
|
||||
Airplane
|
||||
Copyright (C) 2020 Technove LLC
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||
index 4ff563d903633f181e1268daa77f250cfec204a0..41d3dae2ddfa32d9d77566f27e1292c5152f94cc 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||
@@ -702,6 +702,7 @@ public class ServerChunkCache extends ChunkSource {
|
||||
ProfilerFiller gameprofilerfiller = this.level.getProfiler();
|
||||
|
||||
gameprofilerfiller.push("pollingChunks");
|
||||
+ this.level.resetIceAndSnowTick(); // Gale - Airplane - optimize random calls in chunk ticking - reset ice & snow tick random
|
||||
int k = this.level.getGameRules().getInt(GameRules.RULE_RANDOMTICKING);
|
||||
boolean flag1 = level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) != 0L && worlddata.getGameTime() % level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) == 0L; // CraftBukkit
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index c6e56abd3e62a93320bc11e9ae8f94e1e83a6956..69fffb33ca1398892732fccd376c22cd0ce03f0a 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -794,6 +794,8 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
private final BlockPos.MutableBlockPos chunkTickMutablePosition = new BlockPos.MutableBlockPos();
|
||||
// Paper end
|
||||
|
||||
+ private int currentIceAndSnowTick = 0; protected void resetIceAndSnowTick() { this.currentIceAndSnowTick = this.randomTickRandom.nextInt(16); } // Gale - Airplane - optimize random calls in chunk ticking
|
||||
+
|
||||
public void tickChunk(LevelChunk chunk, int randomTickSpeed) {
|
||||
ChunkPos chunkcoordintpair = chunk.getPos();
|
||||
boolean flag = this.isRaining();
|
||||
@@ -804,7 +806,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
gameprofilerfiller.push("thunder");
|
||||
final BlockPos.MutableBlockPos blockposition = this.chunkTickMutablePosition; // Paper - use mutable to reduce allocation rate, final to force compile fail on change
|
||||
|
||||
- if (!this.paperConfig().environment.disableThunder && flag && this.isThundering() && this.spigotConfig.thunderChance > 0 && this.random.nextInt(this.spigotConfig.thunderChance) == 0) { // Spigot // Paper - disable thunder
|
||||
+ if (!this.paperConfig().environment.disableThunder && flag && this.isThundering() && this.spigotConfig.thunderChance > 0 && /*this.random.nextInt(this.spigotConfig.thunderChance) == 0 &&*/ chunk.shouldDoLightning(this.random)) { // Spigot // Paper - disable thunder // Gale - Airplane - optimize random calls in chunk ticking - replace random with shouldDoLightning
|
||||
blockposition.set(this.findLightningTargetAround(this.getBlockRandomPos(j, 0, k, 15))); // Paper
|
||||
if (this.isRainingAt(blockposition)) {
|
||||
DifficultyInstance difficultydamagescaler = this.getCurrentDifficultyAt(blockposition);
|
||||
@@ -828,7 +830,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
}
|
||||
|
||||
gameprofilerfiller.popPush("iceandsnow");
|
||||
- if (!this.paperConfig().environment.disableIceAndSnow && this.random.nextInt(16) == 0) { // Paper - Disable ice and snow
|
||||
+ if (!this.paperConfig().environment.disableIceAndSnow && (this.currentIceAndSnowTick++ & 15) == 0) { // Paper - Disable ice and snow // Paper - optimise random ticking // Gale - Airplane - optimize random calls in chunk ticking - optimize further random ticking
|
||||
// Paper start - optimise chunk ticking
|
||||
this.getRandomBlockPosition(j, 0, k, 15, blockposition);
|
||||
int normalY = chunk.getHeight(Heightmap.Types.MOTION_BLOCKING, blockposition.getX() & 15, blockposition.getZ() & 15) + 1;
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
|
||||
index 5e54cf312160e537d2fe6e6fedc618160359330e..f840a350b06d86a17e5a3de3c6f09bda91225268 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
|
||||
@@ -88,6 +88,18 @@ public class LevelChunk extends ChunkAccess {
|
||||
private final LevelChunkTicks<Block> blockTicks;
|
||||
private final LevelChunkTicks<Fluid> fluidTicks;
|
||||
|
||||
+ // Gale start - Airplane - optimize random calls in chunk ticking - instead of using a random every time the chunk is ticked, define when lightning strikes preemptively
|
||||
+ private int lightningTick;
|
||||
+ // shouldDoLightning compiles down to 29 bytes, which with the default of 35 byte inlining should guarantee an inline
|
||||
+ public final boolean shouldDoLightning(net.minecraft.util.RandomSource random) {
|
||||
+ if (this.lightningTick-- <= 0) {
|
||||
+ this.lightningTick = random.nextInt(this.level.spigotConfig.thunderChance) << 1;
|
||||
+ return true;
|
||||
+ }
|
||||
+ return false;
|
||||
+ }
|
||||
+ // Gale end - Airplane - optimize random calls in chunk ticking - instead of using a random every time the chunk is ticked, define when lightning strikes preemptively
|
||||
+
|
||||
public LevelChunk(Level world, ChunkPos pos) {
|
||||
this(world, pos, UpgradeData.EMPTY, new LevelChunkTicks<>(), new LevelChunkTicks<>(), 0L, (LevelChunkSection[]) null, (LevelChunk.PostLoadProcessor) null, (BlendingData) null);
|
||||
}
|
||||
@@ -118,6 +130,7 @@ public class LevelChunk extends ChunkAccess {
|
||||
this.fluidTicks = fluidTickScheduler;
|
||||
// CraftBukkit start
|
||||
this.bukkitChunk = new org.bukkit.craftbukkit.CraftChunk(this);
|
||||
+ this.lightningTick = this.level.randomTickRandom.nextInt(100000) << 1; // Gale - Airplane - optimize random calls in chunk ticking - initialize lightning tick
|
||||
}
|
||||
|
||||
public org.bukkit.Chunk bukkitChunk;
|
||||
@@ -0,0 +1,55 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MartijnMuijsers <martijnmuijsers@live.nl>
|
||||
Date: Wed, 23 Nov 2022 19:53:35 +0100
|
||||
Subject: [PATCH] Reduce enderman teleport chunk lookups
|
||||
|
||||
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
This patch is based on the following patch:
|
||||
"Reduce chunk loading & lookups"
|
||||
By: Paul Sauve <paul@technove.co>
|
||||
As part of: Airplane (https://github.com/TECHNOVE/Airplane)
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
* Airplane copyright *
|
||||
|
||||
Airplane
|
||||
Copyright (C) 2020 Technove LLC
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
|
||||
index f22e615dba31619c97bf58930da060476a52facf..cc9c5737519ccc6d534d0a43053e2a6f3823a8be 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
|
||||
@@ -317,11 +317,17 @@ public class EnderMan extends Monster implements NeutralMob {
|
||||
private boolean teleport(double x, double y, double z) {
|
||||
BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos(x, y, z);
|
||||
|
||||
- while (blockposition_mutableblockposition.getY() > this.level.getMinBuildHeight() && !this.level.getBlockState(blockposition_mutableblockposition).getMaterial().blocksMotion()) {
|
||||
+ // Gale start - Airplane - single chunk lookup
|
||||
+ net.minecraft.world.level.chunk.LevelChunk chunk = this.level.getChunkIfLoaded(blockposition_mutableblockposition);
|
||||
+ if (chunk == null) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ while (blockposition_mutableblockposition.getY() > this.level.getMinBuildHeight() && !chunk.getBlockState(blockposition_mutableblockposition).getMaterial().blocksMotion()) {
|
||||
+ // Gale end - Airplane - single chunk lookup
|
||||
blockposition_mutableblockposition.move(Direction.DOWN);
|
||||
}
|
||||
|
||||
- BlockState iblockdata = this.level.getBlockState(blockposition_mutableblockposition);
|
||||
+ BlockState iblockdata = chunk.getBlockState(blockposition_mutableblockposition); // Gale - Airplane - single chunk lookup
|
||||
boolean flag = iblockdata.getMaterial().blocksMotion();
|
||||
boolean flag1 = iblockdata.getFluidState().is(FluidTags.WATER);
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MartijnMuijsers <martijnmuijsers@live.nl>
|
||||
Date: Wed, 23 Nov 2022 20:12:48 +0100
|
||||
Subject: [PATCH] Reduce acquire POI for stuck entities
|
||||
|
||||
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
This patch is based on the following patch:
|
||||
"Skip POI finding if stuck in vehicle"
|
||||
By: Paul Sauve <paul@technove.co>
|
||||
As part of: Airplane (https://github.com/TECHNOVE/Airplane)
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
* Airplane copyright *
|
||||
|
||||
Airplane
|
||||
Copyright (C) 2020 Technove LLC
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/AcquirePoi.java b/src/main/java/net/minecraft/world/entity/ai/behavior/AcquirePoi.java
|
||||
index 43243537b765a2d270be6de3f053fea77ff67d18..b7013df56364a4503bfc9e56533cb1fcef49f4c6 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/AcquirePoi.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/AcquirePoi.java
|
||||
@@ -65,7 +65,10 @@ public class AcquirePoi extends Behavior<PathfinderMob> {
|
||||
this.nextScheduledStart = entity.level.getGameTime() + (long)world.random.nextInt(20);
|
||||
return false;
|
||||
} else {
|
||||
- return world.getGameTime() >= this.nextScheduledStart;
|
||||
+ // Gale start - Airplane - reduce acquire POI for stuck entities
|
||||
+ long stuckEntityAdditionalWaitTime = world.galeConfig().smallOptimizations.reducedIntervals.acquirePoiForStuckEntity;
|
||||
+ return world.getGameTime() >= this.nextScheduledStart + (stuckEntityAdditionalWaitTime <= 0L ? 0L : entity.getNavigation().isStuck() ? stuckEntityAdditionalWaitTime : 0L);
|
||||
+ // Gale end - Airplane - reduce acquire POI for stuck entities
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
||||
index fa513614e32963fede05e05cacefbf31010d0c07..a277e64b3bcfe3add3d3652b65255c8c91cdbdd8 100644
|
||||
--- a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
||||
+++ b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
||||
@@ -83,6 +83,26 @@ public class GaleWorldConfiguration extends ConfigurationPart {
|
||||
}
|
||||
// Gale end - Airplane - reduce projectile chunk loading
|
||||
|
||||
+ public ReducedIntervals reducedIntervals;
|
||||
+ public class ReducedIntervals extends ConfigurationPart {
|
||||
+
|
||||
+ // Gale start - Airplane - reduce acquire POI for stuck entities
|
||||
+ /**
|
||||
+ * Extra interval (on top of the regular interval)
|
||||
+ * for entities that are stuck (e.g. in a vehicle) to attempt to acquire a POI.
|
||||
+ * If they become unstuck during this time, they will immediately be free to acquire a POI again.
|
||||
+ * Given in ticks.
|
||||
+ * Any value < 0 behaves like 0.
|
||||
+ * <ul>
|
||||
+ * <li><i>Default</i>: 200 (10 seconds)</li>
|
||||
+ * <li><i>Vanilla</i>: 0</li>
|
||||
+ * </ul>
|
||||
+ */
|
||||
+ public int acquirePoiForStuckEntity = 200;
|
||||
+ // Gale end - Airplane - reduce acquire POI for stuck entities
|
||||
+
|
||||
+ }
|
||||
+
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MartijnMuijsers <martijnmuijsers@live.nl>
|
||||
Date: Wed, 23 Nov 2022 20:18:05 +0100
|
||||
Subject: [PATCH] Remove iterators from Inventory#contains
|
||||
|
||||
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
This patch is based on the following patch:
|
||||
"Remove iterators from inventory contains"
|
||||
By: Paul Sauve <paul@technove.co>
|
||||
As part of: Airplane (https://github.com/TECHNOVE/Airplane)
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
* Airplane copyright *
|
||||
|
||||
Airplane
|
||||
Copyright (C) 2020 Technove LLC
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/player/Inventory.java b/src/main/java/net/minecraft/world/entity/player/Inventory.java
|
||||
index a1a625a8dacf4d2bbf75ddd90dce1b1be663c919..e1bd7984d08f43ba6646e4223fce9201178c174d 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/player/Inventory.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/player/Inventory.java
|
||||
@@ -681,6 +681,8 @@ public class Inventory implements Container, Nameable {
|
||||
}
|
||||
|
||||
public boolean contains(ItemStack stack) {
|
||||
+ // Gale start - Airplane - remove iterators from Inventory#contains
|
||||
+ /*
|
||||
Iterator iterator = this.compartments.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
@@ -695,7 +697,18 @@ public class Inventory implements Container, Nameable {
|
||||
}
|
||||
}
|
||||
}
|
||||
+ */
|
||||
+ for (int i = 0; i < this.compartments.size(); i++) {
|
||||
+ List<ItemStack> list = this.compartments.get(i);
|
||||
+ for (int j = 0; j < list.size(); j++) {
|
||||
+ ItemStack itemstack1 = list.get(j);
|
||||
|
||||
+ if (!itemstack1.isEmpty() && itemstack1.sameItem(stack)) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ // Gale end - Airplane - remove iterators from Inventory#contains
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MartijnMuijsers <martijnmuijsers@live.nl>
|
||||
Date: Wed, 23 Nov 2022 20:21:06 +0100
|
||||
Subject: [PATCH] Check targeting range before getting visibility
|
||||
|
||||
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
This patch is based on the following patch:
|
||||
"Early return optimization for target finding"
|
||||
By: Paul Sauve <paul@technove.co>
|
||||
As part of: Airplane (https://github.com/TECHNOVE/Airplane)
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
* Airplane copyright *
|
||||
|
||||
Airplane
|
||||
Copyright (C) 2020 Technove LLC
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java b/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java
|
||||
index a7575b5ef56af6f53448d391abb4956e130148ca..14a66220f2a88a292ea6acc3bd57ea32e7bf372b 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java
|
||||
@@ -75,9 +75,18 @@ public class TargetingConditions {
|
||||
}
|
||||
|
||||
if (this.range > 0.0D) {
|
||||
- double d = this.testInvisible ? targetEntity.getVisibilityPercent(baseEntity) : 1.0D;
|
||||
- double e = Math.max((this.useFollowRange ? this.getFollowRange(baseEntity) : this.range) * d, 2.0D); // Paper
|
||||
+ // Gale start - Airplane - check targeting range before getting visibility
|
||||
+ // d = invisibility percent, e = follow range adjusted for invisibility, f = distance
|
||||
double f = baseEntity.distanceToSqr(targetEntity.getX(), targetEntity.getY(), targetEntity.getZ());
|
||||
+ double followRangeRaw = this.useFollowRange ? this.getFollowRange(baseEntity) : this.range;
|
||||
+
|
||||
+ if (f > followRangeRaw * followRangeRaw) { // the actual follow range will always be this value or smaller, so if the distance is larger then it never will return true after getting invis
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ double d = this.testInvisible ? targetEntity.getVisibilityPercent(baseEntity) : 1.0D;
|
||||
+ double e = Math.max((followRangeRaw) * d, 2.0D); // Paper
|
||||
+ // Gale end - Airplane - check targeting range before getting visibility
|
||||
if (f > e * e) {
|
||||
return false;
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MartijnMuijsers <martijnmuijsers@live.nl>
|
||||
Date: Wed, 23 Nov 2022 20:28:07 +0100
|
||||
Subject: [PATCH] Print stack trace for plugins not shutting down tasks
|
||||
|
||||
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
This patch is based on the following patch:
|
||||
"More debug for plugins not shutting down tasks"
|
||||
By: Paul Sauve <paul@technove.co>
|
||||
As part of: Airplane (https://github.com/TECHNOVE/Airplane)
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
* Airplane copyright *
|
||||
|
||||
Airplane
|
||||
Copyright (C) 2020 Technove LLC
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
index 4ccd6640bf0125d5b6734ef0de993e675fd9d45a..ebd0abcb6c7c04d18b6be254d4bb1224945a4ffc 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
||||
@@ -1053,6 +1053,13 @@ public final class CraftServer implements Server {
|
||||
plugin.getDescription().getName(),
|
||||
"This plugin is not properly shutting down its async tasks when it is being shut down. This task may throw errors during the final shutdown logs and might not complete before process dies."
|
||||
));
|
||||
+ // Gale start - Airplane - print stack trace for plugins not shutting down tasks
|
||||
+ getLogger().log(Level.SEVERE, String.format("%s Stacktrace", worker.getThread().getName()));
|
||||
+ StackTraceElement[] stackTrace = worker.getThread().getStackTrace();
|
||||
+ for (StackTraceElement element : stackTrace) {
|
||||
+ getLogger().log(Level.SEVERE, " " + element.toString());
|
||||
+ }
|
||||
+ // Gale end - Airplane - print stack trace for plugins not shutting down tasks
|
||||
}
|
||||
}
|
||||
// Paper end
|
||||
275
patches/server/0016-Improve-fluid-direction-caching.patch
Normal file
275
patches/server/0016-Improve-fluid-direction-caching.patch
Normal file
@@ -0,0 +1,275 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MartijnMuijsers <martijnmuijsers@live.nl>
|
||||
Date: Wed, 23 Nov 2022 20:35:40 +0100
|
||||
Subject: [PATCH] Improve fluid direction caching
|
||||
|
||||
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
This patch is based on the following patch:
|
||||
"Improve fluid direction caching"
|
||||
By: Paul Sauve <paul@technove.co>
|
||||
As part of: Airplane (https://github.com/TECHNOVE/Airplane)
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
* Airplane description *
|
||||
|
||||
Implements a custom cache that better fits the needs of fluids
|
||||
calculating whether a direction can be moved in or something. There's a
|
||||
big javadoc on the FluidDirectionCache with some more information.
|
||||
|
||||
* Airplane copyright *
|
||||
|
||||
Airplane
|
||||
Copyright (C) 2020 Technove LLC
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
diff --git a/src/main/java/gg/airplane/structs/FluidDirectionCache.java b/src/main/java/gg/airplane/structs/FluidDirectionCache.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..3a405aabeec696fad5ccebb921da374836fb1201
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/gg/airplane/structs/FluidDirectionCache.java
|
||||
@@ -0,0 +1,143 @@
|
||||
+// Gale - Airplane - improve fluid direction caching
|
||||
+
|
||||
+package gg.airplane.structs;
|
||||
+
|
||||
+import it.unimi.dsi.fastutil.HashCommon;
|
||||
+
|
||||
+/**
|
||||
+ * This is a replacement for the cache used in FluidTypeFlowing.
|
||||
+ * The requirements for the previous cache were:
|
||||
+ * <ul>
|
||||
+ * <li>Store 200 entries</li>
|
||||
+ * <li>Look for the flag in the cache</li>
|
||||
+ * <li>If it exists, move to front of cache</li>
|
||||
+ * <li>If it doesn't exist, remove last entry in cache and insert in front</li>
|
||||
+ * </ul>
|
||||
+ * This class accomplishes something similar, however has a few different
|
||||
+ * requirements put into place to make this more optimize:
|
||||
+ * <ul>
|
||||
+ * <li>
|
||||
+ * maxDistance is the most amount of entries to be checked, instead
|
||||
+ * of having to check the entire list.
|
||||
+ * </li>
|
||||
+ * <li>
|
||||
+ * In combination with that, entries are all tracked by age and how
|
||||
+ * frequently they're used. This enables us to remove old entries,
|
||||
+ * without constantly shifting any around.
|
||||
+ * </li>
|
||||
+ * </ul>
|
||||
+ * Usage of the previous map would have to reset the head every single usage,
|
||||
+ * shifting the entire map. Here, nothing happens except an increment when
|
||||
+ * the cache is hit, and when it needs to replace an old element only a single
|
||||
+ * element is modified.
|
||||
+ */
|
||||
+public class FluidDirectionCache<T> {
|
||||
+
|
||||
+ private static class FluidDirectionEntry<T> {
|
||||
+ private final T data;
|
||||
+ private final boolean flag;
|
||||
+ private int uses = 0;
|
||||
+ private int age = 0;
|
||||
+
|
||||
+ private FluidDirectionEntry(T data, boolean flag) {
|
||||
+ this.data = data;
|
||||
+ this.flag = flag;
|
||||
+ }
|
||||
+
|
||||
+ public int getValue() {
|
||||
+ return this.uses - (this.age >> 1); // age isn't as important as uses
|
||||
+ }
|
||||
+
|
||||
+ public void incrementUses() {
|
||||
+ this.uses = this.uses + 1 & Integer.MAX_VALUE;
|
||||
+ }
|
||||
+
|
||||
+ public void incrementAge() {
|
||||
+ this.age = this.age + 1 & Integer.MAX_VALUE;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private final FluidDirectionEntry[] entries;
|
||||
+ private final int mask;
|
||||
+ private final int maxDistance; // the most amount of entries to check for a value
|
||||
+
|
||||
+ public FluidDirectionCache(int size) {
|
||||
+ int arraySize = HashCommon.nextPowerOfTwo(size);
|
||||
+ this.entries = new FluidDirectionEntry[arraySize];
|
||||
+ this.mask = arraySize - 1;
|
||||
+ this.maxDistance = Math.min(arraySize, 4);
|
||||
+ }
|
||||
+
|
||||
+ public Boolean getValue(T data) {
|
||||
+ FluidDirectionEntry curr;
|
||||
+ int pos;
|
||||
+
|
||||
+ if ((curr = this.entries[pos = HashCommon.mix(data.hashCode()) & this.mask]) == null) {
|
||||
+ return null;
|
||||
+ } else if (data.equals(curr.data)) {
|
||||
+ curr.incrementUses();
|
||||
+ return curr.flag;
|
||||
+ }
|
||||
+
|
||||
+ int checked = 1; // start at 1 because we already checked the first spot above
|
||||
+
|
||||
+ while ((curr = this.entries[pos = (pos + 1) & this.mask]) != null) {
|
||||
+ if (data.equals(curr.data)) {
|
||||
+ curr.incrementUses();
|
||||
+ return curr.flag;
|
||||
+ } else if (++checked >= this.maxDistance) {
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return null;
|
||||
+ }
|
||||
+
|
||||
+ public void putValue(T data, boolean flag) {
|
||||
+ FluidDirectionEntry<T> curr;
|
||||
+ int pos;
|
||||
+
|
||||
+ if ((curr = this.entries[pos = HashCommon.mix(data.hashCode()) & this.mask]) == null) {
|
||||
+ this.entries[pos] = new FluidDirectionEntry<>(data, flag); // add
|
||||
+ return;
|
||||
+ } else if (data.equals(curr.data)) {
|
||||
+ curr.incrementUses();
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ int checked = 1; // start at 1 because we already checked the first spot above
|
||||
+
|
||||
+ while ((curr = this.entries[pos = (pos + 1) & this.mask]) != null) {
|
||||
+ if (data.equals(curr.data)) {
|
||||
+ curr.incrementUses();
|
||||
+ return;
|
||||
+ } else if (++checked >= this.maxDistance) {
|
||||
+ this.forceAdd(data, flag);
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ this.entries[pos] = new FluidDirectionEntry<>(data, flag); // add
|
||||
+ }
|
||||
+
|
||||
+ private void forceAdd(T data, boolean flag) {
|
||||
+ int expectedPos = HashCommon.mix(data.hashCode()) & this.mask;
|
||||
+
|
||||
+ int toRemovePos = expectedPos;
|
||||
+ FluidDirectionEntry entryToRemove = this.entries[toRemovePos];
|
||||
+
|
||||
+ for (int i = expectedPos + 1; i < expectedPos + this.maxDistance; i++) {
|
||||
+ int pos = i & this.mask;
|
||||
+ FluidDirectionEntry entry = this.entries[pos];
|
||||
+ if (entry.getValue() < entryToRemove.getValue()) {
|
||||
+ toRemovePos = pos;
|
||||
+ entryToRemove = entry;
|
||||
+ }
|
||||
+
|
||||
+ entry.incrementAge(); // use this as a mechanism to age the other entries
|
||||
+ }
|
||||
+
|
||||
+ // remove the least used/oldest entry
|
||||
+ this.entries[toRemovePos] = new FluidDirectionEntry(data, flag);
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
|
||||
index ff40fe323964f173561a6838fb443e79abf9df38..38edb592998f04d3b862f2af44755f47b3b82ae5 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java
|
||||
@@ -43,6 +43,8 @@ public abstract class FlowingFluid extends Fluid {
|
||||
public static final BooleanProperty FALLING = BlockStateProperties.FALLING;
|
||||
public static final IntegerProperty LEVEL = BlockStateProperties.LEVEL_FLOWING;
|
||||
private static final int CACHE_SIZE = 200;
|
||||
+ // Gale start - Airplane - improve fluid direction caching - use our own cache
|
||||
+ /*
|
||||
private static final ThreadLocal<Object2ByteLinkedOpenHashMap<Block.BlockStatePairKey>> OCCLUSION_CACHE = ThreadLocal.withInitial(() -> {
|
||||
Object2ByteLinkedOpenHashMap<Block.BlockStatePairKey> object2bytelinkedopenhashmap = new Object2ByteLinkedOpenHashMap<Block.BlockStatePairKey>(200) {
|
||||
protected void rehash(int i) {}
|
||||
@@ -51,6 +53,14 @@ public abstract class FlowingFluid extends Fluid {
|
||||
object2bytelinkedopenhashmap.defaultReturnValue((byte) 127);
|
||||
return object2bytelinkedopenhashmap;
|
||||
});
|
||||
+ */
|
||||
+
|
||||
+ private static final ThreadLocal<gg.airplane.structs.FluidDirectionCache<Block.BlockStatePairKey>> localFluidDirectionCache = ThreadLocal.withInitial(() -> {
|
||||
+ // Gale - Airplane - TODO - mess with this number for performance
|
||||
+ // with 2048 it seems very infrequent on a small world that it has to remove old entries
|
||||
+ return new gg.airplane.structs.FluidDirectionCache<>(2048);
|
||||
+ });
|
||||
+ // Gale end - Airplane - improve fluid direction caching - use our own cache
|
||||
private final Map<FluidState, VoxelShape> shapes = Maps.newIdentityHashMap();
|
||||
|
||||
public FlowingFluid() {}
|
||||
@@ -239,6 +249,8 @@ public abstract class FlowingFluid extends Fluid {
|
||||
}
|
||||
|
||||
private boolean canPassThroughWall(Direction face, BlockGetter world, BlockPos pos, BlockState state, BlockPos fromPos, BlockState fromState) {
|
||||
+ // Gale start - Airplane - improve fluid direction caching - modify to use our cache
|
||||
+ /*
|
||||
Object2ByteLinkedOpenHashMap object2bytelinkedopenhashmap;
|
||||
|
||||
if (!state.getBlock().hasDynamicShape() && !fromState.getBlock().hasDynamicShape()) {
|
||||
@@ -246,9 +258,16 @@ public abstract class FlowingFluid extends Fluid {
|
||||
} else {
|
||||
object2bytelinkedopenhashmap = null;
|
||||
}
|
||||
+ */
|
||||
+ gg.airplane.structs.FluidDirectionCache<Block.BlockStatePairKey> cache = null;
|
||||
+
|
||||
+ if (!state.getBlock().hasDynamicShape() && !fromState.getBlock().hasDynamicShape()) {
|
||||
+ cache = localFluidDirectionCache.get();
|
||||
+ }
|
||||
|
||||
Block.BlockStatePairKey block_a;
|
||||
|
||||
+ /*
|
||||
if (object2bytelinkedopenhashmap != null) {
|
||||
block_a = new Block.BlockStatePairKey(state, fromState, face);
|
||||
byte b0 = object2bytelinkedopenhashmap.getAndMoveToFirst(block_a);
|
||||
@@ -259,11 +278,22 @@ public abstract class FlowingFluid extends Fluid {
|
||||
} else {
|
||||
block_a = null;
|
||||
}
|
||||
+ */
|
||||
+ if (cache != null) {
|
||||
+ block_a = new Block.BlockStatePairKey(state, fromState, face);
|
||||
+ Boolean flag = cache.getValue(block_a);
|
||||
+ if (flag != null) {
|
||||
+ return flag;
|
||||
+ }
|
||||
+ } else {
|
||||
+ block_a = null;
|
||||
+ }
|
||||
|
||||
VoxelShape voxelshape = state.getCollisionShape(world, pos);
|
||||
VoxelShape voxelshape1 = fromState.getCollisionShape(world, fromPos);
|
||||
boolean flag = !Shapes.mergedFaceOccludes(voxelshape, voxelshape1, face);
|
||||
|
||||
+ /*
|
||||
if (object2bytelinkedopenhashmap != null) {
|
||||
if (object2bytelinkedopenhashmap.size() == 200) {
|
||||
object2bytelinkedopenhashmap.removeLastByte();
|
||||
@@ -271,6 +301,11 @@ public abstract class FlowingFluid extends Fluid {
|
||||
|
||||
object2bytelinkedopenhashmap.putAndMoveToFirst(block_a, (byte) (flag ? 1 : 0));
|
||||
}
|
||||
+ */
|
||||
+ if (cache != null) {
|
||||
+ cache.putValue(block_a, flag);
|
||||
+ }
|
||||
+ // Gale end - Airplane - improve fluid direction caching - modify to use our cache
|
||||
|
||||
return flag;
|
||||
}
|
||||
69
patches/server/0017-Cache-on-climbable-check.patch
Normal file
69
patches/server/0017-Cache-on-climbable-check.patch
Normal file
@@ -0,0 +1,69 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MartijnMuijsers <martijnmuijsers@live.nl>
|
||||
Date: Wed, 23 Nov 2022 20:40:40 +0100
|
||||
Subject: [PATCH] Cache on climbable check
|
||||
|
||||
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
This patch is based on the following patch:
|
||||
"Cache climbing check for activation"
|
||||
By: Paul Sauve <paul@technove.co>
|
||||
As part of: Airplane (https://github.com/TECHNOVE/Airplane)
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
* Airplane copyright *
|
||||
|
||||
Airplane
|
||||
Copyright (C) 2020 Technove LLC
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index 4eb6d1536cdc105aacf7507b69b7ac16a2dbd78a..842f12ad6106eaa9a5bde69d3702abcac4d347b1 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -1906,6 +1906,20 @@ public abstract class LivingEntity extends Entity {
|
||||
return this.lastClimbablePos;
|
||||
}
|
||||
|
||||
+
|
||||
+ // Gale start - Airplane - cache on climbable check
|
||||
+ private boolean cachedOnClimable = false;
|
||||
+ private BlockPos lastClimbingPosition = null;
|
||||
+
|
||||
+ public boolean onClimbableCached() {
|
||||
+ if (!this.blockPosition().equals(this.lastClimbingPosition)) {
|
||||
+ this.cachedOnClimable = this.onClimbable();
|
||||
+ this.lastClimbingPosition = this.blockPosition();
|
||||
+ }
|
||||
+ return this.cachedOnClimable;
|
||||
+ }
|
||||
+ // Gale end - Airplane - cache on climbable check
|
||||
+
|
||||
public boolean onClimbable() {
|
||||
if (this.isSpectator()) {
|
||||
return false;
|
||||
diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java
|
||||
index 1b42c98956342832c37f0aa266f85271daa4ba5b..c9da41176d03c572b83d18f160b873c732686bd2 100644
|
||||
--- a/src/main/java/org/spigotmc/ActivationRange.java
|
||||
+++ b/src/main/java/org/spigotmc/ActivationRange.java
|
||||
@@ -291,7 +291,7 @@ public class ActivationRange
|
||||
if ( entity instanceof LivingEntity )
|
||||
{
|
||||
LivingEntity living = (LivingEntity) entity;
|
||||
- if ( living.onClimbable() || living.jumping || living.hurtTime > 0 || living.activeEffects.size() > 0 ) // Paper
|
||||
+ if ( living.onClimbableCached() || living.jumping || living.hurtTime > 0 || living.activeEffects.size() > 0 ) // Paper // Gale - Airplane - cache on climbable check - use cached
|
||||
{
|
||||
return 1; // Paper
|
||||
}
|
||||
92
patches/server/0018-Config-to-disable-vanilla-profiler.patch
Normal file
92
patches/server/0018-Config-to-disable-vanilla-profiler.patch
Normal file
@@ -0,0 +1,92 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MartijnMuijsers <martijnmuijsers@live.nl>
|
||||
Date: Wed, 23 Nov 2022 21:45:42 +0100
|
||||
Subject: [PATCH] Config to disable vanilla profiler
|
||||
|
||||
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
This patch is based on the following patch:
|
||||
"Config to disable method profiler"
|
||||
By: Paul Sauve <paul@technove.co>
|
||||
As part of: Airplane (https://github.com/TECHNOVE/Airplane)
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
* Airplane copyright *
|
||||
|
||||
Airplane
|
||||
Copyright (C) 2020 Technove LLC
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index afd22d4446b29e83fea9c84b97ef96798d7e6895..da83060f671bee830ea65fe4e4303d22c1c5fa99 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -149,6 +149,7 @@ import net.minecraft.world.phys.Vec2;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.galemc.gale.configuration.GaleConfigurations;
|
||||
+import org.galemc.gale.configuration.GaleGlobalConfiguration;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
// CraftBukkit start
|
||||
@@ -2230,6 +2231,11 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
}
|
||||
|
||||
public ProfilerFiller getProfiler() {
|
||||
+ // Gale start - Airplane - config to disable vanilla profiler
|
||||
+ if (GaleGlobalConfiguration.get().smallOptimizations.disableVanillaProfiler) {
|
||||
+ return net.minecraft.util.profiling.InactiveProfiler.INSTANCE;
|
||||
+ }
|
||||
+ // Gale end - Airplane - config to disable vanilla profiler
|
||||
return this.profiler;
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
||||
index 7c782e642b7489981d55012d16d9107ae6a0be03..4c38c9d6eef8186bd4b1725520047cd7ee78ce28 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Level.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
||||
@@ -92,6 +92,7 @@ import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
||||
import org.bukkit.craftbukkit.util.CraftSpawnCategory;
|
||||
import org.bukkit.entity.SpawnCategory;
|
||||
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||
+import org.galemc.gale.configuration.GaleGlobalConfiguration;
|
||||
import org.galemc.gale.configuration.GaleWorldConfiguration;
|
||||
// CraftBukkit end
|
||||
|
||||
@@ -1474,6 +1475,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||
}
|
||||
|
||||
public ProfilerFiller getProfiler() {
|
||||
+ // Gale start - Airplane - config to disable vanilla profiler
|
||||
+ if (GaleGlobalConfiguration.get().smallOptimizations.disableVanillaProfiler) {
|
||||
+ return net.minecraft.util.profiling.InactiveProfiler.INSTANCE;
|
||||
+ }
|
||||
+ // Gale end - Airplane - config to disable vanilla profiler
|
||||
return (ProfilerFiller) this.profiler.get();
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java
|
||||
index 1ed2275e3e630c1f0dfa29676a239a4af8264332..5bb57e160b446d96147fe1f8b2cfa8e26eb8e651 100644
|
||||
--- a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java
|
||||
+++ b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java
|
||||
@@ -41,6 +41,8 @@ public class GaleGlobalConfiguration extends ConfigurationPart {
|
||||
|
||||
}
|
||||
|
||||
+ public boolean disableVanillaProfiler = true; // Gale - Airplane - config to disable vanilla profiler
|
||||
+
|
||||
}
|
||||
|
||||
}
|
||||
91
patches/server/0019-Use-array-for-gamerule-storage.patch
Normal file
91
patches/server/0019-Use-array-for-gamerule-storage.patch
Normal file
@@ -0,0 +1,91 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MartijnMuijsers <martijnmuijsers@live.nl>
|
||||
Date: Wed, 23 Nov 2022 21:52:25 +0100
|
||||
Subject: [PATCH] Use array for gamerule storage
|
||||
|
||||
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
This patch is based on the following patch:
|
||||
"Use array for gamerule storage"
|
||||
By: Paul Sauve <paul@technove.co>
|
||||
As part of: Airplane (https://github.com/TECHNOVE/Airplane)
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
* Airplane copyright *
|
||||
|
||||
Airplane
|
||||
Copyright (C) 2020 Technove LLC
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/GameRules.java b/src/main/java/net/minecraft/world/level/GameRules.java
|
||||
index 2c500cfdd594e24b039d698bced1f9f9537722e3..9409c5d501e60b828b65b4eaef79af2a3ef3fc2b 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/GameRules.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/GameRules.java
|
||||
@@ -91,6 +91,7 @@ public class GameRules {
|
||||
public static final GameRules.Key<GameRules.BooleanValue> RULE_UNIVERSAL_ANGER = GameRules.register("universalAnger", GameRules.Category.MOBS, GameRules.BooleanValue.create(false));
|
||||
public static final GameRules.Key<GameRules.IntegerValue> RULE_PLAYERS_SLEEPING_PERCENTAGE = GameRules.register("playersSleepingPercentage", GameRules.Category.PLAYER, GameRules.IntegerValue.create(100));
|
||||
private final Map<GameRules.Key<?>, GameRules.Value<?>> rules;
|
||||
+ private final GameRules.Value<?>[] gameruleArray; // Gale - Airplane - use array for gamerule storage
|
||||
|
||||
private static <T extends GameRules.Value<T>> GameRules.Key<T> register(String name, GameRules.Category category, GameRules.Type<T> type) {
|
||||
GameRules.Key<T> gamerules_gamerulekey = new GameRules.Key<>(name, category);
|
||||
@@ -109,17 +110,33 @@ public class GameRules {
|
||||
}
|
||||
|
||||
public GameRules() {
|
||||
- this.rules = (Map) GameRules.GAME_RULE_TYPES.entrySet().stream().collect(ImmutableMap.toImmutableMap(Entry::getKey, (entry) -> {
|
||||
+ // Gale start - Airplane - use array for gamerule storage - use this to ensure gameruleArray is initialized
|
||||
+ this((Map) GameRules.GAME_RULE_TYPES.entrySet().stream().collect(ImmutableMap.toImmutableMap(Entry::getKey, (entry) -> {
|
||||
return ((GameRules.Type) entry.getValue()).createRule();
|
||||
- }));
|
||||
+ })));
|
||||
+ // Gale end - Airplane - use array for gamerule storage - use this to ensure gameruleArray is initialized
|
||||
}
|
||||
|
||||
private GameRules(Map<GameRules.Key<?>, GameRules.Value<?>> rules) {
|
||||
this.rules = rules;
|
||||
+
|
||||
+ // Gale start - Airplane - use array for gamerule storage
|
||||
+ int arraySize = rules.keySet().stream().mapToInt(key -> key.gameRuleIndex).max().orElse(-1) + 1;
|
||||
+ GameRules.Value<?>[] values = new GameRules.Value[arraySize];
|
||||
+
|
||||
+ for (Entry<GameRules.Key<?>, GameRules.Value<?>> entry : rules.entrySet()) {
|
||||
+ values[entry.getKey().gameRuleIndex] = entry.getValue();
|
||||
+ }
|
||||
+
|
||||
+ this.gameruleArray = values;
|
||||
+ // Gale end - Airplane - use array for gamerule storage
|
||||
}
|
||||
|
||||
public <T extends GameRules.Value<T>> T getRule(GameRules.Key<T> key) {
|
||||
- return (T) this.rules.get(key); // CraftBukkit - decompile error
|
||||
+ // Gale start - Airplane - use array for gamerule storage
|
||||
+ return key == null ? null : (T) this.gameruleArray[key.gameRuleIndex];
|
||||
+ //return (T) this.rules.get(key); // CraftBukkit - decompile error
|
||||
+ // Gale end - Airplane - use array for gamerule storage
|
||||
}
|
||||
|
||||
public CompoundTag createTag() {
|
||||
@@ -178,6 +195,10 @@ public class GameRules {
|
||||
}
|
||||
|
||||
public static final class Key<T extends GameRules.Value<T>> {
|
||||
+ // Gale start - Airplane - use array for gamerule storage
|
||||
+ private static int lastGameRuleIndex = 0;
|
||||
+ public final int gameRuleIndex = lastGameRuleIndex++;
|
||||
+ // Gale end - Airplane - use array for gamerule storage
|
||||
|
||||
final String id;
|
||||
private final GameRules.Category category;
|
||||
@@ -0,0 +1,121 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MartijnMuijsers <martijnmuijsers@live.nl>
|
||||
Date: Wed, 23 Nov 2022 22:03:33 +0100
|
||||
Subject: [PATCH] Make EntityCollisionContext a live representation
|
||||
|
||||
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
This patch is based on the following patch:
|
||||
"Make EntityCollisionContext a live representation"
|
||||
By: Paul Sauve <paul@technove.co>
|
||||
As part of: Airplane (https://github.com/TECHNOVE/Airplane)
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
* Airplane description *
|
||||
|
||||
While Context is in the name, it is not used as a context. Instead it is
|
||||
always created, use temporarily, then thrown away. This means having a
|
||||
lot of fields to initialize and make space for is useless. I cannot find
|
||||
anywhere in the codebase where this is used as a context which may be
|
||||
saved for later, so this should be safe assuming plugins don't use it
|
||||
for some strange reason.
|
||||
|
||||
* Airplane copyright *
|
||||
|
||||
Airplane
|
||||
Copyright (C) 2020 Technove LLC
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/phys/shapes/EntityCollisionContext.java b/src/main/java/net/minecraft/world/phys/shapes/EntityCollisionContext.java
|
||||
index ebe65474a4a05ff1637d7f37ebcfe690af59def5..ec0151ae2a8779d8380efcbb554d3961f5df42bf 100644
|
||||
--- a/src/main/java/net/minecraft/world/phys/shapes/EntityCollisionContext.java
|
||||
+++ b/src/main/java/net/minecraft/world/phys/shapes/EntityCollisionContext.java
|
||||
@@ -19,47 +19,72 @@ public class EntityCollisionContext implements CollisionContext {
|
||||
return defaultValue;
|
||||
}
|
||||
};
|
||||
+ // Gale start - Airplane - make EntityCollisionContext a live representation - remove these and pray no plugin uses them
|
||||
+ /*
|
||||
private final boolean descending;
|
||||
private final double entityBottom;
|
||||
private final ItemStack heldItem;
|
||||
private final Predicate<FluidState> canStandOnFluid;
|
||||
+ */
|
||||
+ // Gale end - Airplane - make EntityCollisionContext a live representation - remove these and pray no plugin uses them
|
||||
@Nullable
|
||||
private final Entity entity;
|
||||
|
||||
protected EntityCollisionContext(boolean descending, double minY, ItemStack heldItem, Predicate<FluidState> walkOnFluidPredicate, @Nullable Entity entity) {
|
||||
+ // Gale start - Airplane - make EntityCollisionContext a live representation - remove these and pray no plugin uses them
|
||||
+ /*
|
||||
this.descending = descending;
|
||||
this.entityBottom = minY;
|
||||
this.heldItem = heldItem;
|
||||
this.canStandOnFluid = walkOnFluidPredicate;
|
||||
+ */
|
||||
+ // Gale end - Airplane - make EntityCollisionContext a live representation - remove these and pray no plugin uses them
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
/** @deprecated */
|
||||
@Deprecated
|
||||
protected EntityCollisionContext(Entity entity) {
|
||||
+ // Gale start - Airplane - make EntityCollisionContext a live representation - remove unneeded things
|
||||
+ /*
|
||||
this(entity.isDescending(), entity.getY(), entity instanceof LivingEntity ? ((LivingEntity)entity).getMainHandItem() : ItemStack.EMPTY, entity instanceof LivingEntity ? ((LivingEntity)entity)::canStandOnFluid : (fluidState) -> {
|
||||
return false;
|
||||
}, entity);
|
||||
+ */
|
||||
+ // Gale end - Airplane - make EntityCollisionContext a live representation - remove unneeded things
|
||||
+ this.entity = entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHoldingItem(Item item) {
|
||||
- return this.heldItem.is(item);
|
||||
+ // Gale start - Airplane - make EntityCollisionContext a live representation
|
||||
+ Entity entity = this.entity;
|
||||
+ if (entity instanceof LivingEntity livingEntity) {
|
||||
+ return livingEntity.getMainHandItem().is(item);
|
||||
+ }
|
||||
+ return ItemStack.EMPTY.is(item);
|
||||
+ // Gale end - Airplane - make EntityCollisionContext a live representation
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canStandOnFluid(FluidState stateAbove, FluidState state) {
|
||||
- return this.canStandOnFluid.test(state) && !stateAbove.getType().isSame(state.getType());
|
||||
+ // Gale start - Airplane - make EntityCollisionContext a live representation
|
||||
+ Entity entity = this.entity;
|
||||
+ if (entity instanceof LivingEntity livingEntity) {
|
||||
+ return livingEntity.canStandOnFluid(state) && !stateAbove.getType().isSame(state.getType());
|
||||
+ }
|
||||
+ return false;
|
||||
+ // Gale end - Airplane - make EntityCollisionContext a live representation
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDescending() {
|
||||
- return this.descending;
|
||||
+ return this.entity != null && this.entity.isDescending(); // Gale - Airplane - make EntityCollisionContext a live representation
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAbove(VoxelShape shape, BlockPos pos, boolean defaultValue) {
|
||||
- return this.entityBottom > (double)pos.getY() + shape.max(Direction.Axis.Y) - (double)1.0E-5F;
|
||||
+ return (this.entity == null ? -Double.MAX_VALUE : entity.getY()) > (double)pos.getY() + shape.max(Direction.Axis.Y) - (double)1.0E-5F; // Gale - Airplane - make EntityCollisionContext a live representation
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -0,0 +1,524 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MartijnMuijsers <martijnmuijsers@live.nl>
|
||||
Date: Wed, 23 Nov 2022 22:11:06 +0100
|
||||
Subject: [PATCH] Improve container checking with a bitset
|
||||
|
||||
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
This patch is based on the following patch:
|
||||
"Improve container checking with a bitset"
|
||||
By: Paul Sauve <paul@technove.co>
|
||||
As part of: Airplane (https://github.com/TECHNOVE/Airplane)
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
* Airplane copyright *
|
||||
|
||||
Airplane
|
||||
Copyright (C) 2020 Technove LLC
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
diff --git a/src/main/java/gg/airplane/structs/ItemListWithBitset.java b/src/main/java/gg/airplane/structs/ItemListWithBitset.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..193a58189e7173131e2c23780043adf9d4726fa3
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/gg/airplane/structs/ItemListWithBitset.java
|
||||
@@ -0,0 +1,116 @@
|
||||
+// Gale - Airplane - improve container checking with a bitset
|
||||
+
|
||||
+package gg.airplane.structs;
|
||||
+
|
||||
+import net.minecraft.core.NonNullList;
|
||||
+import net.minecraft.world.item.ItemStack;
|
||||
+import org.apache.commons.lang.Validate;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import org.jetbrains.annotations.Nullable;
|
||||
+
|
||||
+import java.util.AbstractList;
|
||||
+import java.util.Arrays;
|
||||
+import java.util.List;
|
||||
+
|
||||
+public class ItemListWithBitset extends AbstractList<ItemStack> {
|
||||
+ public static ItemListWithBitset fromList(List<ItemStack> list) {
|
||||
+ if (list instanceof ItemListWithBitset ours) {
|
||||
+ return ours;
|
||||
+ }
|
||||
+ return new ItemListWithBitset(list);
|
||||
+ }
|
||||
+
|
||||
+ private static ItemStack[] createArray(int size) {
|
||||
+ ItemStack[] array = new ItemStack[size];
|
||||
+ Arrays.fill(array, ItemStack.EMPTY);
|
||||
+ return array;
|
||||
+ }
|
||||
+
|
||||
+ private final ItemStack[] items;
|
||||
+
|
||||
+ private long bitSet = 0;
|
||||
+ private final long allBits;
|
||||
+
|
||||
+ private static class OurNonNullList extends NonNullList<ItemStack> {
|
||||
+ protected OurNonNullList(List<ItemStack> delegate) {
|
||||
+ super(delegate, ItemStack.EMPTY);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public final NonNullList<ItemStack> nonNullList = new OurNonNullList(this);
|
||||
+
|
||||
+ private ItemListWithBitset(List<ItemStack> list) {
|
||||
+ this(list.size());
|
||||
+
|
||||
+ for (int i = 0; i < list.size(); i++) {
|
||||
+ this.set(i, list.get(i));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public ItemListWithBitset(int size) {
|
||||
+ Validate.isTrue(size < Long.BYTES * 8, "size is too large");
|
||||
+
|
||||
+ this.items = createArray(size);
|
||||
+ this.allBits = ((1L << size) - 1);
|
||||
+ }
|
||||
+
|
||||
+ public boolean isCompletelyEmpty() {
|
||||
+ return this.bitSet == 0;
|
||||
+ }
|
||||
+
|
||||
+ public boolean hasFullStacks() {
|
||||
+ return (this.bitSet & this.allBits) == allBits;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public ItemStack set(int index, @NotNull ItemStack itemStack) {
|
||||
+ ItemStack existing = this.items[index];
|
||||
+
|
||||
+ this.items[index] = itemStack;
|
||||
+
|
||||
+ if (itemStack == ItemStack.EMPTY) {
|
||||
+ this.bitSet &= ~(1L << index);
|
||||
+ } else {
|
||||
+ this.bitSet |= 1L << index;
|
||||
+ }
|
||||
+
|
||||
+ return existing;
|
||||
+ }
|
||||
+
|
||||
+ @NotNull
|
||||
+ @Override
|
||||
+ public ItemStack get(int var0) {
|
||||
+ return this.items[var0];
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int size() {
|
||||
+ return this.items.length;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void clear() {
|
||||
+ Arrays.fill(this.items, ItemStack.EMPTY);
|
||||
+ }
|
||||
+
|
||||
+ // these are unsupported for block inventories which have a static size
|
||||
+ @Override
|
||||
+ public void add(int var0, ItemStack var1) {
|
||||
+ throw new UnsupportedOperationException();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public ItemStack remove(int var0) {
|
||||
+ throw new UnsupportedOperationException();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String toString() {
|
||||
+ return "ItemListWithBitset{" +
|
||||
+ "items=" + Arrays.toString(items) +
|
||||
+ ", bitSet=" + Long.toString(bitSet, 2) +
|
||||
+ ", allBits=" + Long.toString(allBits, 2) +
|
||||
+ ", size=" + this.items.length +
|
||||
+ '}';
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/world/CompoundContainer.java b/src/main/java/net/minecraft/world/CompoundContainer.java
|
||||
index 241fec02e6869c638d3a160819b32173a081467b..d245210d0b01449894018717bc984fa577fc62ec 100644
|
||||
--- a/src/main/java/net/minecraft/world/CompoundContainer.java
|
||||
+++ b/src/main/java/net/minecraft/world/CompoundContainer.java
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.minecraft.world;
|
||||
|
||||
+import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
@@ -64,6 +65,23 @@ public class CompoundContainer implements Container {
|
||||
this.container2 = second;
|
||||
}
|
||||
|
||||
+ // Gale start - Airplane - improve container checking with a bitset
|
||||
+ @Override
|
||||
+ public boolean hasEmptySlot(Direction enumdirection) {
|
||||
+ return this.container1.hasEmptySlot(null) || this.container2.hasEmptySlot(null);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCompletelyFull(Direction enumdirection) {
|
||||
+ return this.container1.isCompletelyFull(null) && this.container2.isCompletelyFull(null);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCompletelyEmpty(Direction enumdirection) {
|
||||
+ return this.container1.isCompletelyEmpty(null) && this.container2.isCompletelyEmpty(null);
|
||||
+ }
|
||||
+ // Gale end - Airplane - improve container checking with a bitset
|
||||
+
|
||||
@Override
|
||||
public int getContainerSize() {
|
||||
return this.container1.getContainerSize() + this.container2.getContainerSize();
|
||||
diff --git a/src/main/java/net/minecraft/world/Container.java b/src/main/java/net/minecraft/world/Container.java
|
||||
index 540bc9500c35c0db719b00aa26f6fb3a1b08ed9f..1e7dba1ca2fd270a7c362e3113f1a0060d835ee0 100644
|
||||
--- a/src/main/java/net/minecraft/world/Container.java
|
||||
+++ b/src/main/java/net/minecraft/world/Container.java
|
||||
@@ -2,6 +2,8 @@ package net.minecraft.world;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
+
|
||||
+import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
@@ -10,6 +12,63 @@ import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
||||
// CraftBukkit end
|
||||
|
||||
public interface Container extends Clearable {
|
||||
+ // Gale start - Airplane - improve container checking with a bitset - allow the inventory to override and optimize these frequent calls
|
||||
+ default boolean hasEmptySlot(@org.jetbrains.annotations.Nullable Direction enumdirection) { // there is a slot with 0 items in it
|
||||
+ if (this instanceof WorldlyContainer worldlyContainer) {
|
||||
+ for (int i : worldlyContainer.getSlotsForFace(enumdirection)) {
|
||||
+ if (this.getItem(i).isEmpty()) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
+ } else {
|
||||
+ int size = this.getContainerSize();
|
||||
+ for (int i = 0; i < size; i++) {
|
||||
+ if (this.getItem(i).isEmpty()) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ default boolean isCompletelyFull(@org.jetbrains.annotations.Nullable Direction enumdirection) { // every stack is maxed
|
||||
+ if (this instanceof WorldlyContainer worldlyContainer) {
|
||||
+ for (int i : worldlyContainer.getSlotsForFace(enumdirection)) {
|
||||
+ ItemStack itemStack = this.getItem(i);
|
||||
+ if (itemStack.getCount() < itemStack.getMaxStackSize()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ }
|
||||
+ } else {
|
||||
+ int size = this.getContainerSize();
|
||||
+ for (int i = 0; i < size; i++) {
|
||||
+ ItemStack itemStack = this.getItem(i);
|
||||
+ if (itemStack.getCount() < itemStack.getMaxStackSize()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ default boolean isCompletelyEmpty(@org.jetbrains.annotations.Nullable Direction enumdirection) {
|
||||
+ if (this instanceof WorldlyContainer worldlyContainer) {
|
||||
+ for (int i : worldlyContainer.getSlotsForFace(enumdirection)) {
|
||||
+ if (!this.getItem(i).isEmpty()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ }
|
||||
+ } else {
|
||||
+ int size = this.getContainerSize();
|
||||
+ for (int i = 0; i < size; i++) {
|
||||
+ if (!this.getItem(i).isEmpty()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ return true;
|
||||
+ }
|
||||
+ // Gale end - Airplane - improve container checking with a bitset - allow the inventory to override and optimize these frequent calls
|
||||
|
||||
int LARGE_MAX_STACK_SIZE = 64;
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
|
||||
index b8fb7b5a347298ada16bc8b818edf1863e3f6040..b2c1e7f9d2132ee830d3e44941291bc7863cc1c4 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
|
||||
@@ -27,7 +27,10 @@ import org.bukkit.inventory.InventoryHolder;
|
||||
|
||||
public abstract class AbstractMinecartContainer extends AbstractMinecart implements ContainerEntity {
|
||||
|
||||
+ // Gale start - Airplane - improve container checking with a bitset
|
||||
private NonNullList<ItemStack> itemStacks;
|
||||
+ private gg.airplane.structs.ItemListWithBitset itemStacksOptimized;
|
||||
+ // Gale end - Airplane - improve container checking with a bitset
|
||||
@Nullable
|
||||
public ResourceLocation lootTable;
|
||||
public long lootTableSeed;
|
||||
@@ -89,12 +92,18 @@ public abstract class AbstractMinecartContainer extends AbstractMinecart impleme
|
||||
|
||||
protected AbstractMinecartContainer(EntityType<?> type, Level world) {
|
||||
super(type, world);
|
||||
- this.itemStacks = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY); // CraftBukkit - SPIGOT-3513
|
||||
+ // Gale start - Airplane - improve container checking with a bitset
|
||||
+ this.itemStacksOptimized = new gg.airplane.structs.ItemListWithBitset(this.getContainerSize()); // CraftBukkit - SPIGOT-3513
|
||||
+ this.itemStacks = this.itemStacksOptimized.nonNullList;
|
||||
+ // Gale end - Airplane - improve container checking with a bitset
|
||||
}
|
||||
|
||||
protected AbstractMinecartContainer(EntityType<?> type, double x, double y, double z, Level world) {
|
||||
super(type, world, x, y, z);
|
||||
- this.itemStacks = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY); // CraftBukkit - SPIGOT-3513
|
||||
+ // Gale start - Airplane - improve container checking with a bitset
|
||||
+ this.itemStacksOptimized = new gg.airplane.structs.ItemListWithBitset(this.getContainerSize()); // CraftBukkit - SPIGOT-3513
|
||||
+ this.itemStacks = this.itemStacksOptimized.nonNullList;
|
||||
+ // Gale end - Airplane - improve container checking with a bitset
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -156,6 +165,10 @@ public abstract class AbstractMinecartContainer extends AbstractMinecart impleme
|
||||
protected void readAdditionalSaveData(CompoundTag nbt) {
|
||||
super.readAdditionalSaveData(nbt);
|
||||
this.lootableData.loadNbt(nbt); // Paper
|
||||
+ // Gale start - Airplane - improve container checking with a bitset
|
||||
+ this.itemStacksOptimized = new gg.airplane.structs.ItemListWithBitset(this.getContainerSize());
|
||||
+ this.itemStacks = this.itemStacksOptimized.nonNullList;
|
||||
+ // Gale end - Airplane - improve container checking with a bitset
|
||||
this.readChestVehicleSaveData(nbt);
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java
|
||||
index a71414397bd45ee7bcacfeef0041d80dfa25f114..045325103597f91e257799ea567cc26ae9b66bd5 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/ChestBlockEntity.java
|
||||
@@ -31,7 +31,10 @@ import org.bukkit.entity.HumanEntity;
|
||||
public class ChestBlockEntity extends RandomizableContainerBlockEntity implements LidBlockEntity {
|
||||
|
||||
private static final int EVENT_SET_OPEN_COUNT = 1;
|
||||
+ // Gale start - Airplane - improve container checking with a bitset
|
||||
private NonNullList<ItemStack> items;
|
||||
+ private gg.airplane.structs.ItemListWithBitset optimizedItems;
|
||||
+ // Gale end - Airplane - improve container checking with a bitset
|
||||
public final ContainerOpenersCounter openersCounter;
|
||||
private final ChestLidController chestLidController;
|
||||
|
||||
@@ -65,9 +68,13 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
+ private final boolean isNative = getClass().equals(ChestBlockEntity.class); // Gale - Airplane - improve container checking with a bitset
|
||||
protected ChestBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
|
||||
super(type, pos, state);
|
||||
- this.items = NonNullList.withSize(27, ItemStack.EMPTY);
|
||||
+ // Gale start - Airplane - improve container checking with a bitset
|
||||
+ this.optimizedItems = new gg.airplane.structs.ItemListWithBitset(27);
|
||||
+ this.items = this.optimizedItems.nonNullList;
|
||||
+ // Gale end - Airplane - improve container checking with a bitset
|
||||
this.openersCounter = new ContainerOpenersCounter() {
|
||||
@Override
|
||||
protected void onOpen(Level world, BlockPos pos, BlockState state) {
|
||||
@@ -98,6 +105,23 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement
|
||||
this.chestLidController = new ChestLidController();
|
||||
}
|
||||
|
||||
+ // Gale start - Airplane - improve container checking with a bitset
|
||||
+ @Override
|
||||
+ public boolean hasEmptySlot(Direction enumdirection) {
|
||||
+ return isNative ? !this.optimizedItems.hasFullStacks() : super.hasEmptySlot(enumdirection);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCompletelyFull(Direction enumdirection) {
|
||||
+ return isNative ? this.optimizedItems.hasFullStacks() && super.isCompletelyFull(enumdirection) : super.isCompletelyFull(enumdirection);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCompletelyEmpty(Direction enumdirection) {
|
||||
+ return isNative && this.optimizedItems.isCompletelyEmpty() || super.isCompletelyEmpty(enumdirection);
|
||||
+ }
|
||||
+ // Gale end - Airplane - improve container checking with a bitset
|
||||
+
|
||||
public ChestBlockEntity(BlockPos pos, BlockState state) {
|
||||
this(BlockEntityType.CHEST, pos, state);
|
||||
}
|
||||
@@ -115,7 +139,10 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement
|
||||
@Override
|
||||
public void load(CompoundTag nbt) {
|
||||
super.load(nbt);
|
||||
- this.items = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY);
|
||||
+ // Gale start - Airplane - improve container checking with a bitset
|
||||
+ this.optimizedItems = new gg.airplane.structs.ItemListWithBitset(this.getContainerSize());
|
||||
+ this.items = this.optimizedItems.nonNullList;
|
||||
+ // Gale end - Airplane - improve container checking with a bitset
|
||||
if (!this.tryLoadLootTable(nbt)) {
|
||||
ContainerHelper.loadAllItems(nbt, this.items);
|
||||
}
|
||||
@@ -187,7 +214,10 @@ public class ChestBlockEntity extends RandomizableContainerBlockEntity implement
|
||||
|
||||
@Override
|
||||
protected void setItems(NonNullList<ItemStack> list) {
|
||||
- this.items = list;
|
||||
+ // Gale start - Airplane - improve container checking with a bitset
|
||||
+ this.optimizedItems = gg.airplane.structs.ItemListWithBitset.fromList(list);
|
||||
+ this.items = this.optimizedItems.nonNullList;
|
||||
+ // Gale end - Airplane - improve container checking with a bitset
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||
index ccad692aba2ed77259f6814d88f01b91ed9d229b..28e864885be7af3eaefae709fa6c390b6ce483d8 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||
@@ -43,7 +43,10 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||
|
||||
public static final int MOVE_ITEM_SPEED = 8;
|
||||
public static final int HOPPER_CONTAINER_SIZE = 5;
|
||||
+ // Gale start - Airplane - improve container checking with a bitset
|
||||
private NonNullList<ItemStack> items;
|
||||
+ private gg.airplane.structs.ItemListWithBitset optimizedItems;
|
||||
+ // Gale end - Airplane - improve container checking with a bitset
|
||||
private int cooldownTime;
|
||||
private long tickedGameTime;
|
||||
|
||||
@@ -79,14 +82,37 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||
|
||||
public HopperBlockEntity(BlockPos pos, BlockState state) {
|
||||
super(BlockEntityType.HOPPER, pos, state);
|
||||
- this.items = NonNullList.withSize(5, ItemStack.EMPTY);
|
||||
+ // Gale start - Airplane - improve container checking with a bitset
|
||||
+ this.optimizedItems = new gg.airplane.structs.ItemListWithBitset(5);
|
||||
+ this.items = this.optimizedItems.nonNullList;
|
||||
+ // Gale end - Airplane - improve container checking with a bitset
|
||||
this.cooldownTime = -1;
|
||||
}
|
||||
|
||||
+ // Gale start - Airplane - improve container checking with a bitset
|
||||
+ @Override
|
||||
+ public boolean hasEmptySlot(Direction enumdirection) {
|
||||
+ return !this.optimizedItems.hasFullStacks();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCompletelyFull(Direction enumdirection) {
|
||||
+ return this.optimizedItems.hasFullStacks() && super.isCompletelyFull(enumdirection);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isCompletelyEmpty(Direction enumdirection) {
|
||||
+ return this.optimizedItems.isCompletelyEmpty() || super.isCompletelyEmpty(enumdirection);
|
||||
+ }
|
||||
+ // Gale end - Airplane - improve container checking with a bitset
|
||||
+
|
||||
@Override
|
||||
public void load(CompoundTag nbt) {
|
||||
super.load(nbt);
|
||||
- this.items = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY);
|
||||
+ // Gale start - Airplane - improve container checking with a bitset
|
||||
+ this.optimizedItems = new gg.airplane.structs.ItemListWithBitset(this.getContainerSize());
|
||||
+ this.items = this.optimizedItems.nonNullList;
|
||||
+ // Gale end - Airplane - improve container checking with a bitset
|
||||
if (!this.tryLoadLootTable(nbt)) {
|
||||
ContainerHelper.loadAllItems(nbt, this.items);
|
||||
}
|
||||
@@ -158,7 +184,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||
flag = HopperBlockEntity.ejectItems(world, pos, state, (Container) blockEntity, blockEntity); // CraftBukkit
|
||||
}
|
||||
|
||||
- if (!blockEntity.inventoryFull()) {
|
||||
+ if (!blockEntity.optimizedItems.hasFullStacks() || !blockEntity.inventoryFull()) { // Gale - Airplane - improve container checking with a bitset - use bitset first
|
||||
flag |= booleansupplier.getAsBoolean();
|
||||
}
|
||||
|
||||
@@ -197,7 +223,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||
skipPushModeEventFire = skipHopperEvents;
|
||||
boolean foundItem = false;
|
||||
for (int i = 0; i < hopper.getContainerSize(); ++i) {
|
||||
- ItemStack item = hopper.getItem(i);
|
||||
+ ItemStack item = hopper.getItem(i); // Gale - Airplane - improve container checking with a bitset
|
||||
if (!item.isEmpty()) {
|
||||
foundItem = true;
|
||||
ItemStack origItemStack = item;
|
||||
@@ -400,12 +426,18 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||
}
|
||||
|
||||
private static boolean isFullContainer(Container inventory, Direction direction) {
|
||||
- return allMatch(inventory, direction, STACK_SIZE_TEST); // Paper - no streams
|
||||
+ // Gale start - Airplane - improve container checking with a bitset - use bitsets
|
||||
+ //return allMatch(inventory, direction, STACK_SIZE_TEST); // Paper - no streams
|
||||
+ return inventory.isCompletelyFull(direction);
|
||||
+ // Gale end - Airplane - improve container checking with a bitset - use bitsets
|
||||
}
|
||||
|
||||
private static boolean isEmptyContainer(Container inv, Direction facing) {
|
||||
// Paper start
|
||||
- return allMatch(inv, facing, IS_EMPTY_TEST);
|
||||
+ // Gale start - Airplane - improve container checking with a bitset - use bitsets
|
||||
+ //return allMatch(inv, facing, IS_EMPTY_TEST);
|
||||
+ return inv.isCompletelyEmpty(facing);
|
||||
+ // Gale start - Airplane - improve container checking with a bitset - use bitsets
|
||||
}
|
||||
private static boolean allMatch(Container iinventory, Direction enumdirection, java.util.function.BiPredicate<ItemStack, Integer> test) {
|
||||
if (iinventory instanceof WorldlyContainer) {
|
||||
@@ -582,7 +614,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||
|
||||
if (HopperBlockEntity.canPlaceItemInContainer(to, stack, slot, side)) {
|
||||
boolean flag = false;
|
||||
- boolean flag1 = to.isEmpty();
|
||||
+ boolean flag1 = to.isCompletelyEmpty(side); // Gale - Airplane - improve container checking with a bitset
|
||||
|
||||
if (itemstack1.isEmpty()) {
|
||||
// Spigot start - SPIGOT-6693, InventorySubcontainer#setItem
|
||||
@@ -730,7 +762,10 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||
|
||||
@Override
|
||||
protected void setItems(NonNullList<ItemStack> list) {
|
||||
- this.items = list;
|
||||
+ // Gale start - Airplane - improve container checking with a bitset
|
||||
+ this.optimizedItems = gg.airplane.structs.ItemListWithBitset.fromList(list);
|
||||
+ this.items = this.optimizedItems.nonNullList;
|
||||
+ // Gale end - Airplane - improve container checking with a bitset
|
||||
}
|
||||
|
||||
public static void entityInside(Level world, BlockPos pos, BlockState state, Entity entity, HopperBlockEntity blockEntity) {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java
|
||||
index d559f93a9a09bac414dd5d58afccad42c127f09b..a25eb07c1209c935e4d97f24c820dc78742aca9d 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java
|
||||
@@ -96,13 +96,8 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc
|
||||
public boolean isEmpty() {
|
||||
this.unpackLootTable((Player)null);
|
||||
// Paper start
|
||||
- for (ItemStack itemStack : this.getItems()) {
|
||||
- if (!itemStack.isEmpty()) {
|
||||
- return false;
|
||||
- }
|
||||
- }
|
||||
+ return this.isCompletelyEmpty(null); // Gale - Airplane - improve container checking with a bitset - use super
|
||||
// Paper end
|
||||
- return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -0,0 +1,51 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MartijnMuijsers <martijnmuijsers@live.nl>
|
||||
Date: Wed, 23 Nov 2022 22:26:37 +0100
|
||||
Subject: [PATCH] Better checking for useless move packets
|
||||
|
||||
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
This patch is based on the following patch:
|
||||
"Better checking for useless move packets"
|
||||
By: Paul Sauve <paul@technove.co>
|
||||
As part of: Airplane (https://github.com/TECHNOVE/Airplane)
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
* Airplane copyright *
|
||||
|
||||
Airplane
|
||||
Copyright (C) 2020 Technove LLC
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java
|
||||
index 2358bb1788cfb902bac9b3b7588954af2d2cd823..b299c490882d51cfc5f268c15f40ae2b4a3552fc 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
|
||||
@@ -166,6 +166,7 @@ public class ServerEntity {
|
||||
boolean flag4 = k < -32768L || k > 32767L || l < -32768L || l > 32767L || i1 < -32768L || i1 > 32767L;
|
||||
|
||||
if (!flag4 && this.teleportDelay <= 400 && !this.wasRiding && this.wasOnGround == this.entity.isOnGround() && !(io.papermc.paper.configuration.GlobalConfiguration.get().collisions.sendFullPosForHardCollidingEntities && this.entity.hardCollides())) { // Paper - send full pos for hard colliding entities to prevent collision problems due to desync
|
||||
+ if (flag2 || flag3 || this.entity instanceof AbstractArrow) { // Gale - Airplane - better checking for useless move packets
|
||||
if ((!flag2 || !flag3) && !(this.entity instanceof AbstractArrow)) {
|
||||
if (flag2) {
|
||||
packet1 = new ClientboundMoveEntityPacket.Pos(this.entity.getId(), (short) ((int) k), (short) ((int) l), (short) ((int) i1), this.entity.isOnGround());
|
||||
@@ -175,6 +176,7 @@ public class ServerEntity {
|
||||
} else {
|
||||
packet1 = new ClientboundMoveEntityPacket.PosRot(this.entity.getId(), (short) ((int) k), (short) ((int) l), (short) ((int) i1), (byte) i, (byte) j, this.entity.isOnGround());
|
||||
}
|
||||
+ } // Gale - Airplane - better checking for useless move packets
|
||||
} else {
|
||||
this.wasOnGround = this.entity.isOnGround();
|
||||
this.teleportDelay = 0;
|
||||
52
patches/server/0023-Use-fast-item-merge-raytracing.patch
Normal file
52
patches/server/0023-Use-fast-item-merge-raytracing.patch
Normal file
@@ -0,0 +1,52 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MartijnMuijsers <martijnmuijsers@live.nl>
|
||||
Date: Wed, 23 Nov 2022 22:29:05 +0100
|
||||
Subject: [PATCH] Use fast item merge raytracing
|
||||
|
||||
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
This patch is based on the following patch:
|
||||
"Patch Paper to use fast item merge raytracing"
|
||||
By: Paul Sauve <paul@technove.co>
|
||||
As part of: Airplane (https://github.com/TECHNOVE/Airplane)
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
* Airplane copyright *
|
||||
|
||||
Airplane
|
||||
Copyright (C) 2020 Technove LLC
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
||||
index fcc5444a1268931a0fd2df1e6bbbc17cfd5a61e0..2e07ce1264680ae433a2da7ce90569368e74ab21 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
||||
@@ -252,10 +252,16 @@ public class ItemEntity extends Entity {
|
||||
if (entityitem.isMergable()) {
|
||||
// Paper Start - Fix items merging through walls
|
||||
if (this.level.paperConfig().fixes.fixItemsMergingThroughWalls) {
|
||||
+ // Gale start - Airplane - use fast item merge raytracing - skip the allocations
|
||||
+ /*
|
||||
net.minecraft.world.level.ClipContext rayTrace = new net.minecraft.world.level.ClipContext(this.position(), entityitem.position(),
|
||||
net.minecraft.world.level.ClipContext.Block.COLLIDER, net.minecraft.world.level.ClipContext.Fluid.NONE, this);
|
||||
net.minecraft.world.phys.BlockHitResult rayTraceResult = level.clip(rayTrace);
|
||||
if (rayTraceResult.getType() == net.minecraft.world.phys.HitResult.Type.BLOCK) continue;
|
||||
+ */
|
||||
+ if (level.rayTraceDirect(this.position(), entityitem.position(), net.minecraft.world.phys.shapes.CollisionContext.of(this)) ==
|
||||
+ net.minecraft.world.phys.HitResult.Type.BLOCK) continue;
|
||||
+ // Gale end - Airplane - use fast item merge raytracing - skip the allocations
|
||||
}
|
||||
// Paper End
|
||||
this.tryToMerge(entityitem);
|
||||
207
patches/server/0024-Use-aging-cache-for-biome-temperatures.patch
Normal file
207
patches/server/0024-Use-aging-cache-for-biome-temperatures.patch
Normal file
@@ -0,0 +1,207 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MartijnMuijsers <martijnmuijsers@live.nl>
|
||||
Date: Wed, 23 Nov 2022 22:33:06 +0100
|
||||
Subject: [PATCH] Use aging cache for biome temperatures
|
||||
|
||||
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
This patch is based on the following patch:
|
||||
"Use aging cache for biome temperatures"
|
||||
By: Paul Sauve <paul@technove.co>
|
||||
As part of: Airplane (https://github.com/TECHNOVE/Airplane)
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
* Airplane copyright *
|
||||
|
||||
Airplane
|
||||
Copyright (C) 2020 Technove LLC
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
diff --git a/src/main/java/gg/airplane/structs/Long2FloatAgingCache.java b/src/main/java/gg/airplane/structs/Long2FloatAgingCache.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..e7cb935e96fa69db8b6dfc0273a2a59cdaad2dea
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/gg/airplane/structs/Long2FloatAgingCache.java
|
||||
@@ -0,0 +1,121 @@
|
||||
+// Gale - Airplane - use aging cache for biome temperatures
|
||||
+
|
||||
+package gg.airplane.structs;
|
||||
+
|
||||
+import it.unimi.dsi.fastutil.HashCommon;
|
||||
+
|
||||
+/**
|
||||
+ * A replacement for the cache used in Biome.
|
||||
+ */
|
||||
+public class Long2FloatAgingCache {
|
||||
+
|
||||
+ private static class AgingEntry {
|
||||
+ private long data;
|
||||
+ private float value;
|
||||
+ private int uses = 0;
|
||||
+ private int age = 0;
|
||||
+
|
||||
+ private AgingEntry(long data, float value) {
|
||||
+ this.data = data;
|
||||
+ this.value = value;
|
||||
+ }
|
||||
+
|
||||
+ public void replace(long data, float flag) {
|
||||
+ this.data = data;
|
||||
+ this.value = flag;
|
||||
+ }
|
||||
+
|
||||
+ public int getValue() {
|
||||
+ return this.uses - (this.age >> 1); // age isn't as important as uses
|
||||
+ }
|
||||
+
|
||||
+ public void incrementUses() {
|
||||
+ this.uses = this.uses + 1 & Integer.MAX_VALUE;
|
||||
+ }
|
||||
+
|
||||
+ public void incrementAge() {
|
||||
+ this.age = this.age + 1 & Integer.MAX_VALUE;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private final AgingEntry[] entries;
|
||||
+ private final int mask;
|
||||
+ private final int maxDistance; // the most amount of entries to check for a value
|
||||
+
|
||||
+ public Long2FloatAgingCache(int size) {
|
||||
+ int arraySize = HashCommon.nextPowerOfTwo(size);
|
||||
+ this.entries = new AgingEntry[arraySize];
|
||||
+ this.mask = arraySize - 1;
|
||||
+ this.maxDistance = Math.min(arraySize, 4);
|
||||
+ }
|
||||
+
|
||||
+ public float getValue(long data) {
|
||||
+ AgingEntry curr;
|
||||
+ int pos;
|
||||
+
|
||||
+ if ((curr = this.entries[pos = HashCommon.mix(HashCommon.long2int(data)) & this.mask]) == null) {
|
||||
+ return Float.NaN;
|
||||
+ } else if (data == curr.data) {
|
||||
+ curr.incrementUses();
|
||||
+ return curr.value;
|
||||
+ }
|
||||
+
|
||||
+ int checked = 1; // start at 1 because we already checked the first spot above
|
||||
+
|
||||
+ while ((curr = this.entries[pos = (pos + 1) & this.mask]) != null) {
|
||||
+ if (data == curr.data) {
|
||||
+ curr.incrementUses();
|
||||
+ return curr.value;
|
||||
+ } else if (++checked >= this.maxDistance) {
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return Float.NaN;
|
||||
+ }
|
||||
+
|
||||
+ public void putValue(long data, float value) {
|
||||
+ AgingEntry curr;
|
||||
+ int pos;
|
||||
+
|
||||
+ if ((curr = this.entries[pos = HashCommon.mix(HashCommon.long2int(data)) & this.mask]) == null) {
|
||||
+ this.entries[pos] = new AgingEntry(data, value); // add
|
||||
+ return;
|
||||
+ } else if (data == curr.data) {
|
||||
+ curr.incrementUses();
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ int checked = 1; // start at 1 because we already checked the first spot above
|
||||
+
|
||||
+ while ((curr = this.entries[pos = (pos + 1) & this.mask]) != null) {
|
||||
+ if (data == curr.data) {
|
||||
+ curr.incrementUses();
|
||||
+ return;
|
||||
+ } else if (++checked >= this.maxDistance) {
|
||||
+ this.forceAdd(data, value);
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ this.entries[pos] = new AgingEntry(data, value); // add
|
||||
+ }
|
||||
+
|
||||
+ private void forceAdd(long data, float value) {
|
||||
+ int expectedPos = HashCommon.mix(HashCommon.long2int(data)) & this.mask;
|
||||
+ AgingEntry entryToRemove = this.entries[expectedPos];
|
||||
+
|
||||
+ for (int i = expectedPos + 1; i < expectedPos + this.maxDistance; i++) {
|
||||
+ int pos = i & this.mask;
|
||||
+ AgingEntry entry = this.entries[pos];
|
||||
+ if (entry.getValue() < entryToRemove.getValue()) {
|
||||
+ entryToRemove = entry;
|
||||
+ }
|
||||
+
|
||||
+ entry.incrementAge(); // use this as a mechanism to age the other entries
|
||||
+ }
|
||||
+
|
||||
+ // remove the least used/oldest entry
|
||||
+ entryToRemove.replace(data, value);
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/biome/Biome.java b/src/main/java/net/minecraft/world/level/biome/Biome.java
|
||||
index ca259e278ad10347567c021376abca0287610432..3c73e260e77150e6870389a1dbeb07595ba7fcc3 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/biome/Biome.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/biome/Biome.java
|
||||
@@ -66,14 +66,20 @@ public final class Biome {
|
||||
private final BiomeGenerationSettings generationSettings;
|
||||
private final MobSpawnSettings mobSettings;
|
||||
private final BiomeSpecialEffects specialEffects;
|
||||
- private final ThreadLocal<Long2FloatLinkedOpenHashMap> temperatureCache = ThreadLocal.withInitial(() -> {
|
||||
+ // Gale start - Airplane - use aging cache for biome temperatures - use our cache
|
||||
+ private final ThreadLocal<gg.airplane.structs.Long2FloatAgingCache> temperatureCache = ThreadLocal.withInitial(() -> {
|
||||
return Util.make(() -> {
|
||||
+ /*
|
||||
Long2FloatLinkedOpenHashMap long2FloatLinkedOpenHashMap = new Long2FloatLinkedOpenHashMap(1024, 0.25F) {
|
||||
protected void rehash(int i) {
|
||||
}
|
||||
};
|
||||
long2FloatLinkedOpenHashMap.defaultReturnValue(Float.NaN);
|
||||
return long2FloatLinkedOpenHashMap;
|
||||
+
|
||||
+ */
|
||||
+ return new gg.airplane.structs.Long2FloatAgingCache(TEMPERATURE_CACHE_SIZE);
|
||||
+ // Gale end - Airplane - use aging cache for biome temperatures - use our cache
|
||||
});
|
||||
});
|
||||
|
||||
@@ -114,17 +120,15 @@ public final class Biome {
|
||||
@Deprecated
|
||||
public float getTemperature(BlockPos blockPos) {
|
||||
long l = blockPos.asLong();
|
||||
- Long2FloatLinkedOpenHashMap long2FloatLinkedOpenHashMap = this.temperatureCache.get();
|
||||
- float f = long2FloatLinkedOpenHashMap.get(l);
|
||||
+ // Gale start - Airplane - use aging cache for biome temperatures
|
||||
+ gg.airplane.structs.Long2FloatAgingCache cache = this.temperatureCache.get();
|
||||
+ float f = cache.getValue(l);
|
||||
if (!Float.isNaN(f)) {
|
||||
return f;
|
||||
} else {
|
||||
float g = this.getHeightAdjustedTemperature(blockPos);
|
||||
- if (long2FloatLinkedOpenHashMap.size() == 1024) {
|
||||
- long2FloatLinkedOpenHashMap.removeFirstFloat();
|
||||
- }
|
||||
-
|
||||
- long2FloatLinkedOpenHashMap.put(l, g);
|
||||
+ cache.putValue(l, g);
|
||||
+ // Gale end - Airplane - use aging cache for biome temperatures
|
||||
return g;
|
||||
}
|
||||
}
|
||||
65
patches/server/0025-Inline-level-height.patch
Normal file
65
patches/server/0025-Inline-level-height.patch
Normal file
@@ -0,0 +1,65 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MartijnMuijsers <martijnmuijsers@live.nl>
|
||||
Date: Wed, 23 Nov 2022 22:41:54 +0100
|
||||
Subject: [PATCH] Inline level height
|
||||
|
||||
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
This patch is based on the following patch:
|
||||
"Ensure level height is inlined"
|
||||
By: Paul Sauve <paul@technove.co>
|
||||
As part of: Airplane (https://github.com/TECHNOVE/Airplane)
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
* Airplane copyright *
|
||||
|
||||
Airplane
|
||||
Copyright (C) 2020 Technove LLC
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
||||
index 4c38c9d6eef8186bd4b1725520047cd7ee78ce28..ee1c45e472c2c92490e076e65ee9213dd32be9fe 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Level.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
||||
@@ -272,6 +272,15 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||
|
||||
public abstract ResourceKey<LevelStem> getTypeKey();
|
||||
|
||||
+ // Gale start - Airplane - inline level height
|
||||
+ private final int minBuildHeight, minSection, height, maxBuildHeight, maxSection;
|
||||
+ @Override public final int getMaxBuildHeight() { return this.maxBuildHeight; }
|
||||
+ @Override public final int getMinSection() { return this.minSection; }
|
||||
+ @Override public final int getMaxSection() { return this.maxSection; }
|
||||
+ @Override public final int getMinBuildHeight() { return this.minBuildHeight; }
|
||||
+ @Override public final int getHeight() { return this.height; }
|
||||
+ // Gale end - Airplane - inline level height
|
||||
+
|
||||
protected Level(WritableLevelData worlddatamutable, ResourceKey<Level> resourcekey, Holder<DimensionType> holder, Supplier<ProfilerFiller> supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function<org.spigotmc.SpigotWorldConfig, io.papermc.paper.configuration.WorldConfiguration> paperWorldConfigCreator, java.util.function.Function<org.spigotmc.SpigotWorldConfig, GaleWorldConfiguration> galeWorldConfigCreator, java.util.concurrent.Executor executor) { // Paper - Async-Anti-Xray - Pass executor // Gale - Gale configuration
|
||||
this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot
|
||||
this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper
|
||||
@@ -295,6 +304,13 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||
});
|
||||
final DimensionType dimensionmanager = (DimensionType) holder.value();
|
||||
|
||||
+ // Gale start - Airplane - inline level height
|
||||
+ this.minBuildHeight = dimensionmanager.minY();
|
||||
+ this.minSection = SectionPos.blockToSectionCoord(this.minBuildHeight);
|
||||
+ this.height = dimensionmanager.height();
|
||||
+ this.maxBuildHeight = this.minBuildHeight + this.height;
|
||||
+ this.maxSection = SectionPos.blockToSectionCoord(this.maxBuildHeight - 1) + 1;
|
||||
+ // Gale end - Airplane - inline level height
|
||||
this.dimension = resourcekey;
|
||||
this.isClientSide = flag;
|
||||
if (dimensionmanager.coordinateScale() != 1.0D) {
|
||||
@@ -0,0 +1,55 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MartijnMuijsers <martijnmuijsers@live.nl>
|
||||
Date: Wed, 23 Nov 2022 22:49:59 +0100
|
||||
Subject: [PATCH] Use ThreadUnsafeRandom for mob spawning
|
||||
|
||||
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
This patch is based on the following patch:
|
||||
"Use thread unsafe random for mob spawning"
|
||||
By: Paul Sauve <paul@technove.co>
|
||||
As part of: Airplane (https://github.com/TECHNOVE/Airplane)
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
* Airplane copyright *
|
||||
|
||||
Airplane
|
||||
Copyright (C) 2020 Technove LLC
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/NaturalSpawner.java b/src/main/java/net/minecraft/world/level/NaturalSpawner.java
|
||||
index 7c7408b9686c8ff945c30892d45914c60f6c5e4a..700408ed6f9109bd1cd56aeb0e46305d502ac862 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/NaturalSpawner.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/NaturalSpawner.java
|
||||
@@ -415,13 +415,14 @@ public final class NaturalSpawner {
|
||||
}
|
||||
}
|
||||
|
||||
- private static BlockPos getRandomPosWithin(Level world, LevelChunk chunk) {
|
||||
+ private static BlockPos getRandomPosWithin(ServerLevel world, LevelChunk chunk) { // Gale - Airplane - Use ThreadUnsafeRandom for mob spawning - accept ServerLevel
|
||||
ChunkPos chunkcoordintpair = chunk.getPos();
|
||||
- int i = chunkcoordintpair.getMinBlockX() + world.random.nextInt(16);
|
||||
- int j = chunkcoordintpair.getMinBlockZ() + world.random.nextInt(16);
|
||||
+ // Gale start - Airplane - Use ThreadUnsafeRandom for mob spawning - use ThreadUnsafeRandom
|
||||
+ int i = chunkcoordintpair.getMinBlockX() + world.randomTickRandom.nextInt(16);
|
||||
+ int j = chunkcoordintpair.getMinBlockZ() + world.randomTickRandom.nextInt(16);
|
||||
+ // Gale end - Airplane - Use ThreadUnsafeRandom for mob spawning - use ThreadUnsafeRandom
|
||||
int k = chunk.getHeight(Heightmap.Types.WORLD_SURFACE, i, j) + 1;
|
||||
- int l = Mth.randomBetweenInclusive(world.random, world.getMinBuildHeight(), k);
|
||||
-
|
||||
+ int l = Mth.randomBetweenInclusive(world.randomTickRandom, world.getMinBuildHeight(), k); // Gale - Airplane - Use ThreadUnsafeRandom for mob spawning - use ThreadUnsafeRandom
|
||||
return new BlockPos(i, l, j);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MartijnMuijsers <martijnmuijsers@live.nl>
|
||||
Date: Wed, 23 Nov 2022 22:53:39 +0100
|
||||
Subject: [PATCH] Remove streams and iterators from range check
|
||||
|
||||
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
This patch is based on the following patch:
|
||||
"Remove streams and iterators from range check"
|
||||
By: Paul Sauve <paul@technove.co>
|
||||
As part of: Airplane (https://github.com/TECHNOVE/Airplane)
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
* Airplane copyright *
|
||||
|
||||
Airplane
|
||||
Copyright (C) 2020 Technove LLC
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
index 55d8ced734a408c990c6c4fbc81707bcb1f27daa..472c9bc6d4702e91b6ee909459c5f82a57156fa5 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java
|
||||
@@ -1589,8 +1589,30 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
return ChunkMap.this.level.getServer().getScaledTrackingDistance(initialDistance);
|
||||
}
|
||||
|
||||
+ // Gale start - Airplane - remove streams and iterators from range check
|
||||
+ private static int getHighestRange(Entity parent, int highest) {
|
||||
+ List<Entity> passengers = parent.getPassengers();
|
||||
+
|
||||
+ for (int i = 0, size = passengers.size(); i < size; i++) {
|
||||
+ Entity entity = passengers.get(i);
|
||||
+ int range = entity.getType().clientTrackingRange() * 16;
|
||||
+ range = org.spigotmc.TrackingRange.getEntityTrackingRange(entity, range); // Paper
|
||||
+
|
||||
+ if (range > highest) { // Paper - we need the lowest range thanks to the fact that our tracker doesn't account for passenger logic // Tuinity - not anymore!
|
||||
+ highest = range;
|
||||
+ }
|
||||
+
|
||||
+ highest = getHighestRange(entity, highest);
|
||||
+ }
|
||||
+
|
||||
+ return highest;
|
||||
+ }
|
||||
+ // Gale end - Airplane - remove streams and iterators from range check
|
||||
+
|
||||
private int getEffectiveRange() {
|
||||
int i = this.range;
|
||||
+ // Gale start - Airplane - remove streams and iterators from range check
|
||||
+ /*
|
||||
Iterator iterator = this.entity.getIndirectPassengers().iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
@@ -1602,6 +1624,9 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
i = j;
|
||||
}
|
||||
}
|
||||
+ */
|
||||
+ i = getHighestRange(this.entity, i);
|
||||
+ // Gale end - Airplane - remove streams and iterators from range check
|
||||
|
||||
return this.scaledRange(i);
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MartijnMuijsers <martijnmuijsers@live.nl>
|
||||
Date: Wed, 23 Nov 2022 22:56:19 +0100
|
||||
Subject: [PATCH] Remove streams from getting nearby players
|
||||
|
||||
This patch is based on the following patch:
|
||||
"Remove streams from getting nearby players"
|
||||
By: Paul Sauve <paul@technove.co>
|
||||
As part of: Airplane (https://github.com/TECHNOVE/Airplane)
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
* Airplane copyright *
|
||||
|
||||
Airplane
|
||||
Copyright (C) 2020 Technove LLC
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 6fa47becd0f83ac4273ef3a10c314aa27b08184b..3f265ea03ac101aa6915f5013602cb60389c2257 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -487,17 +487,37 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
this.isLegacyTrackingEntity = isLegacyTrackingEntity;
|
||||
}
|
||||
|
||||
+ // Gale start - Airplane - remove streams from getting nearby players
|
||||
+ private org.spigotmc.TrackingRange.TrackingRangeType getFurthestEntity(Entity entity, net.minecraft.server.level.ChunkMap chunkMap, org.spigotmc.TrackingRange.TrackingRangeType type, int range) {
|
||||
+ List<Entity> passengers = entity.getPassengers();
|
||||
+ for (int i = 0, size = passengers.size(); i < size; i++) {
|
||||
+ Entity passenger = passengers.get(i);
|
||||
+ org.spigotmc.TrackingRange.TrackingRangeType passengerType = passenger.trackingRangeType;
|
||||
+ int passengerRange = chunkMap.getEntityTrackerRange(passengerType.ordinal());
|
||||
+ if (passengerRange > range) {
|
||||
+ type = passengerType;
|
||||
+ range = passengerRange;
|
||||
+ }
|
||||
+
|
||||
+ type = this.getFurthestEntity(passenger, chunkMap, type, range);
|
||||
+ }
|
||||
+
|
||||
+ return type;
|
||||
+ }
|
||||
+ // Gale end - Airplane - remove streams from getting nearby players
|
||||
+
|
||||
public final com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet<ServerPlayer> getPlayersInTrackRange() {
|
||||
// determine highest range of passengers
|
||||
if (this.passengers.isEmpty()) {
|
||||
return ((ServerLevel)this.level).getChunkSource().chunkMap.playerEntityTrackerTrackMaps[this.trackingRangeType.ordinal()]
|
||||
.getObjectsInRange(MCUtil.getCoordinateKey(this));
|
||||
}
|
||||
- Iterable<Entity> passengers = this.getIndirectPassengers();
|
||||
net.minecraft.server.level.ChunkMap chunkMap = ((ServerLevel)this.level).getChunkSource().chunkMap;
|
||||
org.spigotmc.TrackingRange.TrackingRangeType type = this.trackingRangeType;
|
||||
int range = chunkMap.getEntityTrackerRange(type.ordinal());
|
||||
|
||||
+ // Gale start - Airplane - remove streams from getting nearby players - use getFurthestEntity to skip getIndirectPassengers
|
||||
+ /*
|
||||
for (Entity passenger : passengers) {
|
||||
org.spigotmc.TrackingRange.TrackingRangeType passengerType = passenger.trackingRangeType;
|
||||
int passengerRange = chunkMap.getEntityTrackerRange(passengerType.ordinal());
|
||||
@@ -506,6 +526,9 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
range = passengerRange;
|
||||
}
|
||||
}
|
||||
+ */
|
||||
+ type = this.getFurthestEntity(this, chunkMap, type, range);
|
||||
+ // Gale end - Airplane - remove streams from getting nearby players - use getFurthestEntity to skip getIndirectPassengers
|
||||
|
||||
return chunkMap.playerEntityTrackerTrackMaps[type.ordinal()].getObjectsInRange(MCUtil.getCoordinateKey(this));
|
||||
}
|
||||
55
patches/server/0029-Skip-cloning-loot-parameters.patch
Normal file
55
patches/server/0029-Skip-cloning-loot-parameters.patch
Normal file
@@ -0,0 +1,55 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MartijnMuijsers <martijnmuijsers@live.nl>
|
||||
Date: Wed, 23 Nov 2022 23:01:31 +0100
|
||||
Subject: [PATCH] Skip cloning loot parameters
|
||||
|
||||
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
This patch is based on the following patch:
|
||||
"Skip cloning loot parameters"
|
||||
By: Paul Sauve <paul@technove.co>
|
||||
As part of: Airplane (https://github.com/TECHNOVE/Airplane)
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
* Airplane description *
|
||||
|
||||
Small improvement in CPU, much larger improvement in allocations. As a
|
||||
new loot context is created every time a player moves (along with a lot
|
||||
of other times) the constant cloning churns out a lot of useless
|
||||
objects.
|
||||
|
||||
* Airplane copyright *
|
||||
|
||||
Airplane
|
||||
Copyright (C) 2020 Technove LLC
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/storage/loot/LootContext.java b/src/main/java/net/minecraft/world/level/storage/loot/LootContext.java
|
||||
index 35f9b11a3a61976c952a2c1c64bb2a932538f54f..27a07b15f85c8d0711654f0266236f4910daa4d2 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/storage/loot/LootContext.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/storage/loot/LootContext.java
|
||||
@@ -41,8 +41,10 @@ public class LootContext {
|
||||
this.level = world;
|
||||
this.lootTables = tableGetter;
|
||||
this.conditions = conditionGetter;
|
||||
- this.params = ImmutableMap.copyOf(parameters);
|
||||
- this.dynamicDrops = ImmutableMap.copyOf(drops);
|
||||
+ // Gale start - Airplane - skip cloning loot parameters - use unmodifiable maps instead of immutable ones to skip the copy
|
||||
+ this.params = java.util.Collections.unmodifiableMap(parameters);
|
||||
+ this.dynamicDrops = java.util.Collections.unmodifiableMap(drops);
|
||||
+ // Gale end - Airplane - skip cloning loot parameters - use unmodifiable maps instead of immutable ones to skip the copy
|
||||
}
|
||||
|
||||
public boolean hasParam(LootContextParam<?> parameter) {
|
||||
43
patches/server/0030-Block-goal-does-not-load-chunks.patch
Normal file
43
patches/server/0030-Block-goal-does-not-load-chunks.patch
Normal file
@@ -0,0 +1,43 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MartijnMuijsers <martijnmuijsers@live.nl>
|
||||
Date: Wed, 23 Nov 2022 23:05:45 +0100
|
||||
Subject: [PATCH] Block goal does not load chunks
|
||||
|
||||
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
This patch is based on the following patch:
|
||||
"Fix Paper#6045, block goal shouldn't load chunks"
|
||||
By: Paul Sauve <paul@technove.co>
|
||||
As part of: Airplane (https://github.com/TECHNOVE/Airplane)
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
* Airplane copyright *
|
||||
|
||||
Airplane
|
||||
Copyright (C) 2020 Technove LLC
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java b/src/main/java/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java
|
||||
index 26bf383caea68834c654b25653ced9017f1b1b22..fd973375ad8c8f8dfd962b0b3484c81538649a5f 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/goal/MoveToBlockGoal.java
|
||||
@@ -119,6 +119,7 @@ public abstract class MoveToBlockGoal extends Goal {
|
||||
for(int m = 0; m <= l; m = m > 0 ? -m : 1 - m) {
|
||||
for(int n = m < l && m > -l ? l : 0; n <= l; n = n > 0 ? -n : 1 - n) {
|
||||
mutableBlockPos.setWithOffset(blockPos, m, k - 1, n);
|
||||
+ if (!this.mob.level.hasChunkAt(mutableBlockPos)) continue; // Gale - Airplane - block goal does not load chunks - if this block isn't loaded, continue
|
||||
if (this.mob.isWithinRestriction(mutableBlockPos) && this.isValidTarget(this.mob.level, mutableBlockPos)) {
|
||||
this.blockPos = mutableBlockPos;
|
||||
setTargetPosition(mutableBlockPos.immutable()); // Paper
|
||||
73
patches/server/0031-Reduce-entity-allocations.patch
Normal file
73
patches/server/0031-Reduce-entity-allocations.patch
Normal file
@@ -0,0 +1,73 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MartijnMuijsers <martijnmuijsers@live.nl>
|
||||
Date: Wed, 23 Nov 2022 23:10:56 +0100
|
||||
Subject: [PATCH] Reduce entity allocations
|
||||
|
||||
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
This patch is based on the following patch:
|
||||
"Reduce entity allocations"
|
||||
By: Paul Sauve <paul@technove.co>
|
||||
As part of: Airplane (https://github.com/TECHNOVE/Airplane)
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
* Airplane copyright *
|
||||
|
||||
Airplane
|
||||
Copyright (C) 2020 Technove LLC
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 3f265ea03ac101aa6915f5013602cb60389c2257..2409c2ddfefc5d382c0d5edda63495e1ed723496 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -413,6 +413,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
return this.originWorld;
|
||||
}
|
||||
// Paper end
|
||||
+
|
||||
public float getBukkitYaw() {
|
||||
return this.yRot;
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java b/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java
|
||||
index 692524a69d43dcf52ae1b0f7f593fc53f3878137..f45af229cbd3d0f07a62d039691e370241e9c36c 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java
|
||||
@@ -22,9 +22,11 @@ public class AttributeMap {
|
||||
private final Map<Attribute, AttributeInstance> attributes = Maps.newHashMap();
|
||||
private final Set<AttributeInstance> dirtyAttributes = Sets.newHashSet();
|
||||
private final AttributeSupplier supplier;
|
||||
+ private final java.util.function.Function<Attribute, AttributeInstance> createInstance; // Gale - Airplane - reduce entity allocations
|
||||
|
||||
public AttributeMap(AttributeSupplier defaultAttributes) {
|
||||
this.supplier = defaultAttributes;
|
||||
+ this.createInstance = attribute -> this.supplier.createInstance(this::onAttributeModified, attribute); // Gale - Airplane - reduce entity allocations
|
||||
}
|
||||
|
||||
private void onAttributeModified(AttributeInstance instance) {
|
||||
@@ -44,11 +46,10 @@ public class AttributeMap {
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
+
|
||||
@Nullable
|
||||
public AttributeInstance getInstance(Attribute attribute) {
|
||||
- return this.attributes.computeIfAbsent(attribute, (attributex) -> {
|
||||
- return this.supplier.createInstance(this::onAttributeModified, attributex);
|
||||
- });
|
||||
+ return this.attributes.computeIfAbsent(attribute, this.createInstance); // Gale - Airplane - reduce entity allocations - cache lambda, as for some reason java allocates it anyways
|
||||
}
|
||||
|
||||
public boolean hasAttribute(Attribute attribute) {
|
||||
77
patches/server/0032-Remove-lambda-from-ticking-guard.patch
Normal file
77
patches/server/0032-Remove-lambda-from-ticking-guard.patch
Normal file
@@ -0,0 +1,77 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MartijnMuijsers <martijnmuijsers@live.nl>
|
||||
Date: Wed, 23 Nov 2022 23:13:56 +0100
|
||||
Subject: [PATCH] Remove lambda from ticking guard
|
||||
|
||||
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
This patch is based on the following patch:
|
||||
"Remove lambda from ticking guard"
|
||||
By: Paul Sauve <paul@technove.co>
|
||||
As part of: Airplane (https://github.com/TECHNOVE/Airplane)
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
* Airplane copyright *
|
||||
|
||||
Airplane
|
||||
Copyright (C) 2020 Technove LLC
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index 69fffb33ca1398892732fccd376c22cd0ce03f0a..f1e5206a0bf3a10b8a471afa0aedb867eb848669 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -725,7 +725,20 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
}
|
||||
|
||||
gameprofilerfiller.push("tick");
|
||||
- this.guardEntityTick(this::tickNonPassenger, entity);
|
||||
+ // Gale start - Airplane - remove lambda from ticking guard - copied from guardEntityTick
|
||||
+ try {
|
||||
+ this.tickNonPassenger(entity); // Gale - Airplane - remove lambda from ticking guard - changed
|
||||
+ MinecraftServer.getServer().executeMidTickTasks(); // Tuinity - execute chunk tasks mid tick
|
||||
+ } catch (Throwable throwable) {
|
||||
+ if (throwable instanceof ThreadDeath) throw throwable; // Paper
|
||||
+ // Paper start - Prevent tile entity and entity crashes
|
||||
+ final String msg = String.format("Entity threw exception at %s:%s,%s,%s", entity.level.getWorld().getName(), entity.getX(), entity.getY(), entity.getZ());
|
||||
+ MinecraftServer.LOGGER.error(msg, throwable);
|
||||
+ getCraftServer().getPluginManager().callEvent(new com.destroystokyo.paper.event.server.ServerExceptionEvent(new com.destroystokyo.paper.exception.ServerInternalException(msg, throwable)));
|
||||
+ entity.discard();
|
||||
+ // Paper end
|
||||
+ }
|
||||
+ // Gale end - Airplane - remove lambda from ticking guard - copied from guardEntityTick
|
||||
gameprofilerfiller.pop();
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
|
||||
index ee1c45e472c2c92490e076e65ee9213dd32be9fe..7442e846076fa86065a10f17ee91df40204daa19 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/Level.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/Level.java
|
||||
@@ -999,13 +999,13 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
|
||||
try {
|
||||
tickConsumer.accept(entity);
|
||||
MinecraftServer.getServer().executeMidTickTasks(); // Paper - execute chunk tasks mid tick
|
||||
- } catch (Throwable throwable) {
|
||||
+ } catch (Throwable throwable) { // Gale - Airplane - remove lambda from ticking guard - diff on change ServerLevel#tick
|
||||
if (throwable instanceof ThreadDeath) throw throwable; // Paper
|
||||
// Paper start - Prevent tile entity and entity crashes
|
||||
final String msg = String.format("Entity threw exception at %s:%s,%s,%s", entity.level.getWorld().getName(), entity.getX(), entity.getY(), entity.getZ());
|
||||
MinecraftServer.LOGGER.error(msg, throwable);
|
||||
getCraftServer().getPluginManager().callEvent(new ServerExceptionEvent(new ServerInternalException(msg, throwable)));
|
||||
- entity.discard();
|
||||
+ entity.discard(); // Gale - Airplane - remove lambda from ticking guard - diff on change ServerLevel#tick
|
||||
// Paper end
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,178 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MartijnMuijsers <martijnmuijsers@live.nl>
|
||||
Date: Wed, 23 Nov 2022 23:19:12 +0100
|
||||
Subject: [PATCH] Reduce entity fluid lookups if no fluids
|
||||
|
||||
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
This patch is based on the following patch:
|
||||
"Reduce entity fluid lookups if no fluids"
|
||||
By: Paul Sauve <paul@technove.co>
|
||||
As part of: Airplane (https://github.com/TECHNOVE/Airplane)
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
* Airplane copyright *
|
||||
|
||||
Airplane
|
||||
Copyright (C) 2020 Technove LLC
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 2409c2ddfefc5d382c0d5edda63495e1ed723496..7ebff259973a1c920a04041c77bcfe457f960993 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -4043,16 +4043,18 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
}
|
||||
|
||||
public boolean updateFluidHeightAndDoFluidPushing(TagKey<Fluid> tag, double speed) {
|
||||
- if (this.touchingUnloadedChunk()) {
|
||||
+ if (false && this.touchingUnloadedChunk()) { // Gale - Airplane - reduce entity fluid lookups if no fluids - cost of a lookup here is the same cost as below, so skip
|
||||
return false;
|
||||
} else {
|
||||
AABB axisalignedbb = this.getBoundingBox().deflate(0.001D);
|
||||
- int i = Mth.floor(axisalignedbb.minX);
|
||||
- int j = Mth.ceil(axisalignedbb.maxX);
|
||||
- int k = Mth.floor(axisalignedbb.minY);
|
||||
- int l = Mth.ceil(axisalignedbb.maxY);
|
||||
- int i1 = Mth.floor(axisalignedbb.minZ);
|
||||
- int j1 = Mth.ceil(axisalignedbb.maxZ);
|
||||
+ // Gale start - Airplane - reduce entity fluid lookups if no fluids - rename
|
||||
+ int minBlockX = Mth.floor(axisalignedbb.minX);
|
||||
+ int maxBlockX = Mth.ceil(axisalignedbb.maxX);
|
||||
+ int minBlockY = Mth.floor(axisalignedbb.minY);
|
||||
+ int maxBlockY = Mth.ceil(axisalignedbb.maxY);
|
||||
+ int minBlockZ = Mth.floor(axisalignedbb.minZ);
|
||||
+ int maxBlockZ = Mth.ceil(axisalignedbb.maxZ);
|
||||
+ // Gale end - Airplane - reduce entity fluid lookups if no fluids - rename
|
||||
double d1 = 0.0D;
|
||||
boolean flag = this.isPushedByFluid();
|
||||
boolean flag1 = false;
|
||||
@@ -4060,14 +4062,61 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
int k1 = 0;
|
||||
BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos();
|
||||
|
||||
- for (int l1 = i; l1 < j; ++l1) {
|
||||
- for (int i2 = k; i2 < l; ++i2) {
|
||||
- for (int j2 = i1; j2 < j1; ++j2) {
|
||||
- blockposition_mutableblockposition.set(l1, i2, j2);
|
||||
- FluidState fluid = this.level.getFluidState(blockposition_mutableblockposition);
|
||||
+ // Gale start - Airplane - reduce entity fluid lookups if no fluids - based off CollisionUtil.getCollisionsForBlocksOrWorldBorder
|
||||
+ final int minSection = io.papermc.paper.util.WorldUtil.getMinSection(this.level);
|
||||
+ final int maxSection = io.papermc.paper.util.WorldUtil.getMaxSection(this.level);
|
||||
+ final int minBlock = minSection << 4;
|
||||
+ final int maxBlock = (maxSection << 4) | 15;
|
||||
+
|
||||
+ // special cases:
|
||||
+ if (minBlockY > maxBlock || maxBlockY < minBlock) {
|
||||
+ // no point in checking
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ int minYIterate = Math.max(minBlock, minBlockY);
|
||||
+ int maxYIterate = Math.min(maxBlock, maxBlockY);
|
||||
+
|
||||
+ int minChunkX = minBlockX >> 4;
|
||||
+ int maxChunkX = maxBlockX >> 4;
|
||||
+
|
||||
+ int minChunkZ = minBlockZ >> 4;
|
||||
+ int maxChunkZ = maxBlockZ >> 4;
|
||||
+
|
||||
+ for (int currChunkZ = minChunkZ; currChunkZ <= maxChunkZ; ++currChunkZ) {
|
||||
+ int minZ = currChunkZ == minChunkZ ? minBlockZ & 15 : 0; // coordinate in chunk
|
||||
+ int maxZ = currChunkZ == maxChunkZ ? maxBlockZ & 15 : 16; // coordinate in chunk
|
||||
+
|
||||
+ for (int currChunkX = minChunkX; currChunkX <= maxChunkX; ++currChunkX) {
|
||||
+ int minX = currChunkX == minChunkX ? minBlockX & 15 : 0; // coordinate in chunk
|
||||
+ int maxX = currChunkX == maxChunkX ? maxBlockX & 15 : 16; // coordinate in chunk
|
||||
+
|
||||
+ net.minecraft.world.level.chunk.ChunkAccess chunk = this.level.getChunkIfLoadedImmediately(currChunkX, currChunkZ);
|
||||
+ if (chunk == null) {
|
||||
+ return false; // if we're touching an unloaded chunk then it's false
|
||||
+ }
|
||||
+
|
||||
+ net.minecraft.world.level.chunk.LevelChunkSection[] sections = chunk.getSections();
|
||||
+
|
||||
+ for (int currY = minYIterate; currY < maxYIterate; ++currY) {
|
||||
+ net.minecraft.world.level.chunk.LevelChunkSection section = sections[(currY >> 4) - minSection];
|
||||
+
|
||||
+ if (section == null || section.hasOnlyAir() || section.fluidStateCount == 0) { // if no fluids, nothing in this section
|
||||
+ // empty
|
||||
+ // skip to next section
|
||||
+ currY = (currY & ~(15)) + 15; // increment by 15: iterator loop increments by the extra one
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ net.minecraft.world.level.chunk.PalettedContainer<BlockState> blocks = section.states;
|
||||
+
|
||||
+ for (int currZ = minZ; currZ < maxZ; ++currZ) {
|
||||
+ for (int currX = minX; currX < maxX; ++currX) {
|
||||
+ FluidState fluid = blocks.get(currX & 15, currY & 15, currZ & 15).getFluidState();
|
||||
|
||||
if (fluid.is(tag)) {
|
||||
- double d2 = (double) ((float) i2 + fluid.getHeight(this.level, blockposition_mutableblockposition));
|
||||
+ blockposition_mutableblockposition.set((currChunkX << 4) + currX, currY, (currChunkZ << 4) + currZ);
|
||||
+ double d2 = (double) ((float) currY + fluid.getHeight(this.level, blockposition_mutableblockposition));
|
||||
|
||||
if (d2 >= axisalignedbb.minY) {
|
||||
flag1 = true;
|
||||
@@ -4089,9 +4138,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
// CraftBukkit end
|
||||
}
|
||||
}
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
}
|
||||
}
|
||||
+ // Gale end - Airplane - reduce entity fluid lookups if no fluids - based off CollisionUtil.getCollisionsForBlocksOrWorldBorder
|
||||
|
||||
if (vec3d.length() > 0.0D) {
|
||||
if (k1 > 0) {
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java
|
||||
index b0c9fce9d4e06cac139e341d218d0b6aac1f1943..028defc43439258b102b780d1470e2e49e614ee0 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java
|
||||
@@ -27,6 +27,7 @@ public class LevelChunkSection {
|
||||
public final PalettedContainer<BlockState> states;
|
||||
// CraftBukkit start - read/write
|
||||
private PalettedContainer<Holder<Biome>> biomes;
|
||||
+ public short fluidStateCount; // Gale - Airplane - reduce entity fluid lookups if no fluids
|
||||
public final com.destroystokyo.paper.util.maplist.IBlockDataList tickingList = new com.destroystokyo.paper.util.maplist.IBlockDataList(); // Paper
|
||||
|
||||
public LevelChunkSection(int i, PalettedContainer<BlockState> datapaletteblock, PalettedContainer<Holder<Biome>> palettedcontainerro) {
|
||||
@@ -198,6 +199,7 @@ public class LevelChunkSection {
|
||||
|
||||
if (!fluid.isEmpty()) {
|
||||
--this.tickingFluidCount;
|
||||
+ --this.fluidStateCount; // Gale - Airplane - reduce entity fluid lookups if no fluids
|
||||
}
|
||||
|
||||
if (!state.isAir()) {
|
||||
@@ -212,6 +214,7 @@ public class LevelChunkSection {
|
||||
|
||||
if (!fluid1.isEmpty()) {
|
||||
++this.tickingFluidCount;
|
||||
+ ++this.fluidStateCount; // Gale - Airplane - reduce entity fluid lookups if no fluids
|
||||
}
|
||||
|
||||
this.updateKnownBlockInfo(x | (z << 4) | (y << 8), iblockdata1, state); // Paper
|
||||
@@ -260,6 +263,7 @@ public class LevelChunkSection {
|
||||
if (fluid.isRandomlyTicking()) {
|
||||
this.tickingFluidCount = (short) (this.tickingFluidCount + 1);
|
||||
}
|
||||
+ this.fluidStateCount++; // Gale - Airplane - reduce entity fluid lookups if no fluids
|
||||
}
|
||||
|
||||
});
|
||||
95
patches/server/0034-SIMD-support.patch
Normal file
95
patches/server/0034-SIMD-support.patch
Normal file
@@ -0,0 +1,95 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MartijnMuijsers <martijnmuijsers@live.nl>
|
||||
Date: Thu, 24 Nov 2022 01:19:12 +0100
|
||||
Subject: [PATCH] SIMD support
|
||||
|
||||
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
This patch is based on the following patch:
|
||||
"Add SIMD utilities"
|
||||
By: Kevin Raneri <kevin.raneri@gmail.com>
|
||||
As part of: Pufferfish (https://github.com/pufferfish-gg/Pufferfish)
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||
index 1a29eac414ad97c36fa92d65ea230b4f537492d1..69b35adc97166d540a583c1a467ee1651df873e7 100644
|
||||
--- a/build.gradle.kts
|
||||
+++ b/build.gradle.kts
|
||||
@@ -55,7 +55,14 @@ dependencies {
|
||||
implementation("io.netty:netty-all:4.1.77.Final"); // Paper - Bump netty
|
||||
}
|
||||
|
||||
-val craftbukkitPackageVersion = "1_19_R1" // Paper
|
||||
+val craftbukkitPackageVersion = "1_19_R1" // Paper// Pufferfish Start
|
||||
+
|
||||
+// Gale start - Pufferfish - SIMD support
|
||||
+tasks.withType<JavaCompile> {
|
||||
+ val compilerArgs = options.compilerArgs
|
||||
+ compilerArgs.add("--add-modules=jdk.incubator.vector")
|
||||
+}
|
||||
+// Gale end - Pufferfish - SIMD support
|
||||
tasks.jar {
|
||||
archiveClassifier.set("dev")
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
index acb9e2f67a5ffe46136e1687561630f96b27ce06..6dbd6d6339ef61db4eb961330e6a4df5a401f88b 100644
|
||||
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
@@ -14,6 +14,8 @@ import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
import java.util.function.BooleanSupplier;
|
||||
import javax.annotation.Nullable;
|
||||
+
|
||||
+import gg.pufferfish.pufferfish.simd.SIMDDetection;
|
||||
import net.minecraft.DefaultUncaughtExceptionHandler;
|
||||
import net.minecraft.DefaultUncaughtExceptionHandlerWithName;
|
||||
import net.minecraft.SharedConstants;
|
||||
@@ -50,6 +52,7 @@ import net.minecraft.world.level.GameRules;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import net.minecraft.world.level.block.entity.SkullBlockEntity;
|
||||
import net.minecraft.world.level.storage.LevelStorageSource;
|
||||
+import org.galemc.gale.configuration.GaleGlobalConfiguration;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
// CraftBukkit start
|
||||
@@ -226,6 +229,21 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
io.papermc.paper.brigadier.PaperBrigadierProviderImpl.INSTANCE.getClass(); // init PaperBrigadierProvider
|
||||
// Paper end
|
||||
|
||||
+ // Gale start - Pufferfish - SIMD support
|
||||
+ // Attempt to detect vectorization
|
||||
+ try {
|
||||
+ SIMDDetection.isEnabled = SIMDDetection.canEnable(LOGGER, GaleGlobalConfiguration.get().smallOptimizations.simd.logVectorSizesToConsole);
|
||||
+ } catch (NoClassDefFoundError | Exception ignored) {}
|
||||
+
|
||||
+ if (!SIMDDetection.isEnabled && !SIMDDetection.unsupportingLaneSize && GaleGlobalConfiguration.get().smallOptimizations.simd.warnIfDisabled) {
|
||||
+ LOGGER.warn("SIMD operations are available for your server, but are not configured!");
|
||||
+ LOGGER.warn("To enable additional optimizations, add \"--add-modules=jdk.incubator.vector\" to your startup flags, BEFORE the \"-jar\".");
|
||||
+ LOGGER.warn("If you have already added this flag, then SIMD operations are not supported on your JVM or CPU.");
|
||||
+ LOGGER.warn("Debug: Java: " + System.getProperty("java.version") + ", test run: " + SIMDDetection.testRun);
|
||||
+ LOGGER.warn("If you would like to disable this message, set simd.warn-if-disabled to false in gale-global.yml");
|
||||
+ }
|
||||
+ // Gale start - Pufferfish - SIMD support
|
||||
+
|
||||
this.setPvpAllowed(dedicatedserverproperties.pvp);
|
||||
this.setFlightAllowed(dedicatedserverproperties.allowFlight);
|
||||
this.setMotd(dedicatedserverproperties.motd);
|
||||
diff --git a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java
|
||||
index 5bb57e160b446d96147fe1f8b2cfa8e26eb8e651..e9e9bfc76786525e0a6b41ba52776e93efc1ff65 100644
|
||||
--- a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java
|
||||
+++ b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java
|
||||
@@ -43,6 +43,14 @@ public class GaleGlobalConfiguration extends ConfigurationPart {
|
||||
|
||||
public boolean disableVanillaProfiler = true; // Gale - Airplane - config to disable vanilla profiler
|
||||
|
||||
+ // Gale start - Pufferfish - SIMD support
|
||||
+ public Simd simd;
|
||||
+ public class Simd extends ConfigurationPart {
|
||||
+ public boolean warnIfDisabled = true;
|
||||
+ public boolean logVectorSizesToConsole = false;
|
||||
+ }
|
||||
+ // Gale end - Pufferfish - SIMD support
|
||||
+
|
||||
}
|
||||
|
||||
}
|
||||
48
patches/server/0035-Optimize-entity-coordinate-key.patch
Normal file
48
patches/server/0035-Optimize-entity-coordinate-key.patch
Normal file
@@ -0,0 +1,48 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MartijnMuijsers <martijnmuijsers@live.nl>
|
||||
Date: Wed, 23 Nov 2022 23:32:51 +0100
|
||||
Subject: [PATCH] Optimize entity coordinate key
|
||||
|
||||
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
This patch is based on the following patch:
|
||||
"Optimize entity coordinate key"
|
||||
By: Kevin Raneri <kevin.raneri@gmail.com>
|
||||
As part of: Pufferfish (https://github.com/pufferfish-gg/Pufferfish)
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
* Pufferfish description *
|
||||
|
||||
When executing getCoordinateKey for entities (a hotpath), the JVM is
|
||||
required to repeatedly cast doubles to longs. The performance impact of
|
||||
this depends on the CPU architecture, but generally switching between
|
||||
FPU and ALU incurs a significant performance hit. The casted/rounded
|
||||
data is already available in the blockPosition struct, so we use that
|
||||
instead of re-doing the casting.
|
||||
|
||||
diff --git a/src/main/java/io/papermc/paper/util/MCUtil.java b/src/main/java/io/papermc/paper/util/MCUtil.java
|
||||
index dacb00c7cb2702ae8e9c6be61ca08e41bd6009e4..b20ec9a39d6602451c36b31d401355c4b4674a87 100644
|
||||
--- a/src/main/java/io/papermc/paper/util/MCUtil.java
|
||||
+++ b/src/main/java/io/papermc/paper/util/MCUtil.java
|
||||
@@ -209,7 +209,7 @@ public final class MCUtil {
|
||||
}
|
||||
|
||||
public static long getCoordinateKey(final Entity entity) {
|
||||
- return ((long)(MCUtil.fastFloor(entity.getZ()) >> 4) << 32) | ((MCUtil.fastFloor(entity.getX()) >> 4) & 0xFFFFFFFFL);
|
||||
+ return ((long)(entity.blockPosition.getZ() >> 4) << 32) | ((entity.blockPosition.getX() >> 4) & 0xFFFFFFFFL); // Gale - Pufferfish - optimize entity coordinate key - eliminate double->long cast in hotpath
|
||||
}
|
||||
|
||||
public static long getCoordinateKey(final ChunkPos pair) {
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
index 7ebff259973a1c920a04041c77bcfe457f960993..4bda47a87071aafd7bbb8888ce522099940d3180 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||
@@ -291,7 +291,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||
public double yo;
|
||||
public double zo;
|
||||
private Vec3 position;
|
||||
- private BlockPos blockPosition;
|
||||
+ public BlockPos blockPosition; // Gale - Pufferfish - optimize entity coordinate key - private -> public
|
||||
private ChunkPos chunkPosition;
|
||||
private Vec3 deltaMovement;
|
||||
private float yRot;
|
||||
86
patches/server/0036-Reduce-in-wall-checks.patch
Normal file
86
patches/server/0036-Reduce-in-wall-checks.patch
Normal file
@@ -0,0 +1,86 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MartijnMuijsers <martijnmuijsers@live.nl>
|
||||
Date: Thu, 24 Nov 2022 10:31:38 +0100
|
||||
Subject: [PATCH] Reduce in wall checks
|
||||
|
||||
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
This patch is based on the following patch:
|
||||
"Optimize suffocation"
|
||||
By: Kevin Raneri <kevin.raneri@gmail.com>
|
||||
As part of: Pufferfish (https://github.com/pufferfish-gg/Pufferfish)
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
* Pufferfish description *
|
||||
|
||||
The isInWall check to determine suffocation is quite expensive, and
|
||||
often is completely unnecessary to check. We do two things here to
|
||||
improve this:
|
||||
|
||||
1. We only check for suffocation once per 20 ticks. The maximum
|
||||
no-damage ticks value means that this change should be extremely
|
||||
difficult, if not impossible, for players to notice.
|
||||
|
||||
2. We additionally execute a check to see if the player can even take
|
||||
damage in the first place. This check doesn't improve performance much
|
||||
but is so much cheaper than the suffocation check that it's worth
|
||||
keeping it.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
index 842f12ad6106eaa9a5bde69d3702abcac4d347b1..69b04b9e92985eef2a23a497387249c31918a7d8 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -399,7 +399,10 @@ public abstract class LivingEntity extends Entity {
|
||||
if (this.isAlive()) {
|
||||
boolean flag = this instanceof net.minecraft.world.entity.player.Player;
|
||||
|
||||
- if (this.isInWall()) {
|
||||
+ // Gale start - Pufferfish - reduce in wall checks
|
||||
+ long checkStuckInWallInterval = this.level.galeConfig().smallOptimizations.reducedIntervals.checkStuckInWall;
|
||||
+ if ((checkStuckInWallInterval <= 1 || (tickCount % checkStuckInWallInterval == 0 && couldPossiblyBeHurt(1.0F))) && this.isInWall()) {
|
||||
+ // Gale end - Pufferfish - reduce in wall checks
|
||||
this.hurt(DamageSource.IN_WALL, 1.0F);
|
||||
} else if (flag && !this.level.getWorldBorder().isWithinBounds(this.getBoundingBox())) {
|
||||
double d0 = this.level.getWorldBorder().getDistanceToBorder(this) + this.level.getWorldBorder().getDamageSafeZone();
|
||||
@@ -1313,6 +1316,15 @@ public abstract class LivingEntity extends Entity {
|
||||
return this.getHealth() <= 0.0F;
|
||||
}
|
||||
|
||||
+ // Gale start - Pufferfish - reduce in wall checks
|
||||
+ public boolean couldPossiblyBeHurt(float amount) {
|
||||
+ if ((float) this.invulnerableTime > (float) this.invulnerableDuration / 2.0F && amount <= this.lastHurt) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ return true;
|
||||
+ }
|
||||
+ // Gale end - Pufferfish - reduce in wall checks
|
||||
+
|
||||
@Override
|
||||
public boolean hurt(DamageSource source, float amount) {
|
||||
if (this.isInvulnerableTo(source)) {
|
||||
diff --git a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
||||
index a277e64b3bcfe3add3d3652b65255c8c91cdbdd8..870ca1a1d96b0554294a9fe27fc2abb9747f29f8 100644
|
||||
--- a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
||||
+++ b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
|
||||
@@ -101,6 +101,21 @@ public class GaleWorldConfiguration extends ConfigurationPart {
|
||||
public int acquirePoiForStuckEntity = 200;
|
||||
// Gale end - Airplane - reduce acquire POI for stuck entities
|
||||
|
||||
+ // Gale start - Pufferfish - reduce in wall checks
|
||||
+ /**
|
||||
+ * Interval at which to check whether an entity is stuck in a wall, to deal suffocation damage.
|
||||
+ * Since after dealing damage, there is an interval (this may change in the future, but approximately
|
||||
+ * 1 second) at which entities cannot take repeated damage, delaying the suffocation check by less is
|
||||
+ * almost unnoticeable.
|
||||
+ * Any value <= 0 behaves like 1.
|
||||
+ * <ul>
|
||||
+ * <li><i>Default</i>: 10 (twice per second)</li>
|
||||
+ * <li><i>Vanilla</i>: 1</li>
|
||||
+ * </ul>
|
||||
+ */
|
||||
+ public int checkStuckInWall = 10;
|
||||
+ // Gale end - Pufferfish - reduce in wall checks
|
||||
+
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user