diff --git a/patches/api/0007-Do-not-log-plugin-library-loads.patch b/patches/api/0007-Do-not-log-plugin-library-loads.patch index 245ca85..019e035 100644 --- a/patches/api/0007-Do-not-log-plugin-library-loads.patch +++ b/patches/api/0007-Do-not-log-plugin-library-loads.patch @@ -37,7 +37,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java -index eaefbb00e9993d54906cc8cf35cf753c0d6c7707..12fe20a5a05dc3780def4c0cb3de0b291c2a8185 100644 +index eaefbb00e9993d54906cc8cf35cf753c0d6c7707..92d20e70d26318fbaed8adffd21c6b77336eb9c5 100644 --- a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java +++ b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java @@ -56,6 +56,13 @@ public final class JavaPluginLoader implements PluginLoader { @@ -48,14 +48,14 @@ index eaefbb00e9993d54906cc8cf35cf753c0d6c7707..12fe20a5a05dc3780def4c0cb3de0b29 + public static boolean SuppressLibraryLoaderLogger = false; // This is not set by Gale, but is included for compatibility with Purpur plugins + public static boolean logDownloads = true; + public static boolean logStartLoadLibrariesForPlugin = true; -+ public static boolean logLibrariesLoaded = true; ++ public static boolean logLibraryLoaded = true; + // Gale end - Purpur - do not log plugin library loads + /** * This class was not meant to be constructed explicitly * diff --git a/src/main/java/org/bukkit/plugin/java/LibraryLoader.java b/src/main/java/org/bukkit/plugin/java/LibraryLoader.java -index e4b6f278a811acbb0070e311c5c3bdaff7b00474..354abafef044532bacfbc55d1d7355528c960df9 100644 +index e4b6f278a811acbb0070e311c5c3bdaff7b00474..a749856a6a4189d1f5aa3f193f5fa6a9dd7b13f1 100644 --- a/src/main/java/org/bukkit/plugin/java/LibraryLoader.java +++ b/src/main/java/org/bukkit/plugin/java/LibraryLoader.java @@ -65,6 +65,7 @@ public class LibraryLoader @@ -78,7 +78,7 @@ index e4b6f278a811acbb0070e311c5c3bdaff7b00474..354abafef044532bacfbc55d1d735552 } jarFiles.add( url ); -+ if (JavaPluginLoader.logLibrariesLoaded && !JavaPluginLoader.SuppressLibraryLoaderLogger) // Gale - Purpur - do not log plugin library loads ++ if (JavaPluginLoader.logLibraryLoaded && !JavaPluginLoader.SuppressLibraryLoaderLogger) // Gale - Purpur - do not log plugin library loads logger.log( Level.INFO, "[{0}] Loaded library {1}", new Object[] { java.util.Objects.requireNonNullElseGet(desc.getPrefix(), desc::getName), file // Paper - use configured log prefix diff --git a/patches/server/0008-Gale-semantic-version.patch b/patches/server/0008-Gale-semantic-version.patch index 939ec80..0d90d9e 100644 --- a/patches/server/0008-Gale-semantic-version.patch +++ b/patches/server/0008-Gale-semantic-version.patch @@ -29,7 +29,7 @@ index 2868dab7b100d9c325b0e5056f86660d631dec4b..2acad4c3fd58178b0f8b22bdb04eeeeb } diff --git a/src/main/java/org/galemc/gale/version/GaleSemanticVersion.java b/src/main/java/org/galemc/gale/version/GaleSemanticVersion.java new file mode 100644 -index 0000000000000000000000000000000000000000..4c0ae932fd4ecc4ec103b19b32d0eb4ebef3cb74 +index 0000000000000000000000000000000000000000..0e9b11940513e96a21bed011afb0b05257782bfc --- /dev/null +++ b/src/main/java/org/galemc/gale/version/GaleSemanticVersion.java @@ -0,0 +1,37 @@ @@ -57,7 +57,7 @@ index 0000000000000000000000000000000000000000..4c0ae932fd4ecc4ec103b19b32d0eb4e + * The patch version is incremented for small changes that do not affect the goal of any feature, + * such as bug fixes, performance improvements or changes in wording. + */ -+ public static final @NotNull String version = "0.6.6"; ++ public static final @NotNull String version = "0.6.8"; + + /** + * The "major.minor" portion of the {@link #version}. diff --git a/patches/server/0145-Reduce-line-of-sight-updates-and-cache-lookups.patch b/patches/server/0145-Reduce-line-of-sight-updates-and-cache-lookups.patch new file mode 100644 index 0000000..54e9503 --- /dev/null +++ b/patches/server/0145-Reduce-line-of-sight-updates-and-cache-lookups.patch @@ -0,0 +1,128 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Martijn Muijsers +Date: Wed, 30 Aug 2023 20:01:31 +0200 +Subject: [PATCH] Reduce line of sight updates and cache lookups + +License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) +Gale - https://galemc.org + +This patch is based on the following patch: +"feat: reduce sensor work" +By: peaches94 +As part of: Petal (https://github.com/Bloom-host/Petal) +Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) + +* Petal description * + +this patch is focused around the sensors used for ai +delete the line of sight cache less often and use a faster nearby comparison + +diff --git a/src/main/java/net/minecraft/world/entity/ai/sensing/Sensing.java b/src/main/java/net/minecraft/world/entity/ai/sensing/Sensing.java +index 57472cb54e9fd83e980e3c57f28d6e6643f422e8..ce50852a9b18679a80e9393e8d904935917e0439 100644 +--- a/src/main/java/net/minecraft/world/entity/ai/sensing/Sensing.java ++++ b/src/main/java/net/minecraft/world/entity/ai/sensing/Sensing.java +@@ -1,39 +1,81 @@ + package net.minecraft.world.entity.ai.sensing; + +-import it.unimi.dsi.fastutil.ints.IntOpenHashSet; +-import it.unimi.dsi.fastutil.ints.IntSet; ++import it.unimi.dsi.fastutil.ints.Int2IntMap; ++import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; ++import it.unimi.dsi.fastutil.ints.IntArrayList; ++import it.unimi.dsi.fastutil.ints.IntList; + import net.minecraft.world.entity.Entity; + import net.minecraft.world.entity.Mob; ++import org.galemc.gale.configuration.GaleGlobalConfiguration; ++import org.jetbrains.annotations.NotNull; ++import org.jetbrains.annotations.Nullable; + + public class Sensing { + private final Mob mob; +- // Gale start - initialize line of sight cache with low capacity +- private final IntSet seen = new IntOpenHashSet(2); +- private final IntSet unseen = new IntOpenHashSet(2); +- // Gale end - initialize line of sight cache with low capacity ++ private final Int2IntMap seen = new Int2IntOpenHashMap(2); // Gale end - initialize line of sight cache with low capacity // Gale - Petal - reduce line of sight cache lookups - merge sets ++ ++ // Gale start - Petal - reduce line of sight updates - expiring entity id lists ++ private final @NotNull IntList @Nullable [] expiring; ++ private int currentCacheAddIndex = 0; ++ private int nextToExpireIndex = 1; ++ // Gale end - Petal - reduce line of sight updates - expiring entity id lists + + public Sensing(Mob owner) { + this.mob = owner; ++ // Gale start - Petal - reduce line of sight updates - expiring entity id lists ++ int updateLineOfSightInterval = GaleGlobalConfiguration.get().smallOptimizations.reducedIntervals.updateEntityLineOfSight; ++ if (updateLineOfSightInterval <= 1) { ++ this.expiring = null; ++ } else { ++ this.expiring = new IntList[updateLineOfSightInterval]; ++ for (int i = 0; i < updateLineOfSightInterval; i++) { ++ this.expiring[i] = new IntArrayList(0); ++ } ++ } ++ // Gale end - Petal - reduce line of sight updates - expiring entity id lists + } + + public void tick() { ++ if (this.expiring == null) { // Gale - Petal - reduce line of sight updates + this.seen.clear(); +- this.unseen.clear(); ++ // Gale start - Petal - reduce line of sight updates ++ } else { ++ var expiringNow = this.expiring[this.nextToExpireIndex]; ++ expiringNow.forEach(this.seen::remove); ++ expiringNow.clear(); ++ this.currentCacheAddIndex++; ++ if (this.currentCacheAddIndex == this.expiring.length) { ++ this.currentCacheAddIndex = 0; ++ } ++ this.nextToExpireIndex++; ++ if (this.nextToExpireIndex == this.expiring.length) { ++ this.nextToExpireIndex = 0; ++ } ++ } ++ // Gale end - Petal - reduce line of sight updates + } + + public boolean hasLineOfSight(Entity entity) { + int i = entity.getId(); +- if (this.seen.contains(i)) { ++ // Gale start - Petal - reduce line of sight cache lookups - merge sets ++ int cached = this.seen.get(i); ++ if (cached == 1) { ++ // Gale end - Petal - reduce line of sight cache lookups - merge sets + return true; +- } else if (this.unseen.contains(i)) { ++ } else if (cached == 2) { // Gale - Petal - reduce line of sight cache lookups - merge sets + return false; + } else { + boolean bl = this.mob.hasLineOfSight(entity); + if (bl) { +- this.seen.add(i); ++ this.seen.put(i, 1); // Gale - Petal - reduce line of sight cache lookups - merge sets + } else { +- this.unseen.add(i); ++ this.seen.put(i, 2); // Gale - Petal - reduce line of sight cache lookups - merge sets ++ } ++ // Gale start - Petal - reduce line of sight updates ++ if (this.expiring != null) { ++ this.expiring[this.currentCacheAddIndex].add(i); + } ++ // Gale end - Petal - reduce line of sight updates + + return bl; + } +diff --git a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java +index ac8a36585e7f77e5789bc6f17489cf12f21ddfcc..5b7e2afd8ecc5b8bbe524d4ba6e1d0ac0282878b 100644 +--- a/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java ++++ b/src/main/java/org/galemc/gale/configuration/GaleGlobalConfiguration.java +@@ -33,6 +33,7 @@ public class GaleGlobalConfiguration extends ConfigurationPart { + public class ReducedIntervals extends ConfigurationPart.Post { + + public int increaseTimeStatistics = 20; // Gale - Hydrinity - increase time statistics in intervals ++ public int updateEntityLineOfSight = 4; // Gale - Petal - reduce line of sight updates + + @Override + public void postProcess() { diff --git a/patches/server/0145-Server-thread-priority-environment-variable.patch b/patches/server/0146-Server-thread-priority-environment-variable.patch similarity index 100% rename from patches/server/0145-Server-thread-priority-environment-variable.patch rename to patches/server/0146-Server-thread-priority-environment-variable.patch diff --git a/patches/server/0146-Instantly-continue-on-world-upgrade-finish.patch b/patches/server/0147-Instantly-continue-on-world-upgrade-finish.patch similarity index 100% rename from patches/server/0146-Instantly-continue-on-world-upgrade-finish.patch rename to patches/server/0147-Instantly-continue-on-world-upgrade-finish.patch diff --git a/patches/server/0147-Virtual-thread-support.patch b/patches/server/0148-Virtual-thread-support.patch similarity index 100% rename from patches/server/0147-Virtual-thread-support.patch rename to patches/server/0148-Virtual-thread-support.patch