From b8310d5f89c3ae945a6c7c44c9fd41b98ce3cba1 Mon Sep 17 00:00:00 2001 From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com> Date: Sun, 3 Nov 2024 04:49:12 -0500 Subject: [PATCH] dev ->27 --- build.gradle.kts | 2 +- gradle.properties | 6 +- ...Hide-irrelevant-compilation-warnings.patch | 6 +- patches/api/0002-Gale-branding-changes.patch | 4 +- patches/api/0005-SIMD-support.patch | 6 +- .../0008-Player-canSee-by-entity-UUID.patch | 4 +- .../0002-Dev-import-deobfuscation-fixes.patch | 20 +- ...Hide-irrelevant-compilation-warnings.patch | 4 +- .../server/0005-Gale-branding-changes.patch | 18 +- patches/server/0006-Gale-metrics.patch | 45 +- .../server/0007-Gale-semantic-version.patch | 4 +- patches/server/0008-Gale-configuration.patch | 105 +- patches/server/0010-Gale-commands.patch | 6 +- .../server/0011-Remove-vanilla-profiler.patch | 1754 ++++++++++------- ...aster-floating-point-positive-modulo.patch | 6 +- ...apelessRecipe-comparison-for-vanilla.patch | 32 +- ...0015-Reduce-projectile-chunk-loading.patch | 4 +- patches/server/0016-Predict-Halloween.patch | 4 +- ...timize-random-calls-in-chunk-ticking.patch | 35 +- ...duce-enderman-teleport-chunk-lookups.patch | 9 +- ...ve-iterators-from-Inventory-contains.patch | 24 +- ...ting-range-before-getting-visibility.patch | 16 +- ...e-for-plugins-not-shutting-down-task.patch | 4 +- ...ch => 0023-Cache-on-climbable-check.patch} | 16 +- ...0023-Improve-fluid-direction-caching.patch | 276 --- ...lisionContext-a-live-representation.patch} | 13 +- ...r-checking-for-useless-move-packets.patch} | 32 +- ...026-Block-goal-does-not-load-chunks.patch} | 0 patches/server/0027-Inline-level-height.patch | 66 - ...h => 0027-Reduce-entity-allocations.patch} | 4 +- ...reams-and-iterators-from-range-check.patch | 77 - todos.txt | 4 + 32 files changed, 1193 insertions(+), 1413 deletions(-) rename patches/server/{0024-Cache-on-climbable-check.patch => 0023-Cache-on-climbable-check.patch} (83%) delete mode 100644 patches/server/0023-Improve-fluid-direction-caching.patch rename patches/server/{0025-Make-EntityCollisionContext-a-live-representation.patch => 0024-Make-EntityCollisionContext-a-live-representation.patch} (90%) rename patches/server/{0026-Better-checking-for-useless-move-packets.patch => 0025-Better-checking-for-useless-move-packets.patch} (52%) rename patches/server/{0029-Block-goal-does-not-load-chunks.patch => 0026-Block-goal-does-not-load-chunks.patch} (100%) delete mode 100644 patches/server/0027-Inline-level-height.patch rename patches/server/{0030-Reduce-entity-allocations.patch => 0027-Reduce-entity-allocations.patch} (94%) delete mode 100644 patches/server/0028-Remove-streams-and-iterators-from-range-check.patch create mode 100644 todos.txt diff --git a/build.gradle.kts b/build.gradle.kts index 2e6e01d..d34d414 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,7 +6,7 @@ import kotlin.io.path.deleteRecursively plugins { java `maven-publish` - id("io.papermc.paperweight.patcher") version "1.7.3" + id("io.papermc.paperweight.patcher") version "1.7.4" } allprojects { diff --git a/gradle.properties b/gradle.properties index 7843b8b..bdbf108 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,8 +1,8 @@ group=org.galemc.gale -version=1.21.1-R0.1-SNAPSHOT +version=1.21.3-R0.1-SNAPSHOT -mcVersion=1.21.1 -paperRef=84281ceeefb9d294758a9a292ba6c01da40e8409 +mcVersion=1.21.3 +paperRef=ce0a0419476d1072ca739a0e8f22d8a358c1c1a2 org.gradle.caching=false org.gradle.parallel=true diff --git a/patches/api/0001-Hide-irrelevant-compilation-warnings.patch b/patches/api/0001-Hide-irrelevant-compilation-warnings.patch index bad6f49..465fd59 100644 --- a/patches/api/0001-Hide-irrelevant-compilation-warnings.patch +++ b/patches/api/0001-Hide-irrelevant-compilation-warnings.patch @@ -7,10 +7,10 @@ License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) Gale - https://galemc.org diff --git a/build.gradle.kts b/build.gradle.kts -index ab84a1405acc1f0d5f267892243b82b8dab03e21..7d5f68599e680bd6ce21ff32c902a994e8fc6538 100644 +index 254fd96d3950b4494c7e43547b00b5175ee53c93..855a5eb171ce94444de1313eafacf3558c4cf728 100644 --- a/build.gradle.kts +++ b/build.gradle.kts -@@ -131,6 +131,15 @@ val generateApiVersioningFile by tasks.registering { +@@ -135,6 +135,15 @@ val generateApiVersioningFile by tasks.registering { } } @@ -26,7 +26,7 @@ index ab84a1405acc1f0d5f267892243b82b8dab03e21..7d5f68599e680bd6ce21ff32c902a994 tasks.jar { from(generateApiVersioningFile.map { it.outputs.files.singleFile }) { into("META-INF/maven/${project.group}/${project.name}") -@@ -190,6 +199,8 @@ tasks.withType { +@@ -194,6 +203,8 @@ tasks.withType { into("build/docs/javadoc") } } diff --git a/patches/api/0002-Gale-branding-changes.patch b/patches/api/0002-Gale-branding-changes.patch index b7eadb8..d2c6c7f 100644 --- a/patches/api/0002-Gale-branding-changes.patch +++ b/patches/api/0002-Gale-branding-changes.patch @@ -46,10 +46,10 @@ index 94a9ed024d3859793618152ea559a168bbcbb5e2..e60008693e017bec1b4eb49c84be3898 -. +. diff --git a/build.gradle.kts b/build.gradle.kts -index 7d5f68599e680bd6ce21ff32c902a994e8fc6538..a4c827331900d292febae384701bcd51add111d9 100644 +index 855a5eb171ce94444de1313eafacf3558c4cf728..40fed07c4f1d6205dd79021641fc1395816e7354 100644 --- a/build.gradle.kts +++ b/build.gradle.kts -@@ -149,6 +149,12 @@ tasks.jar { +@@ -153,6 +153,12 @@ tasks.jar { "Automatic-Module-Name" to "org.bukkit" ) } diff --git a/patches/api/0005-SIMD-support.patch b/patches/api/0005-SIMD-support.patch index c2f574c..721c844 100644 --- a/patches/api/0005-SIMD-support.patch +++ b/patches/api/0005-SIMD-support.patch @@ -13,10 +13,10 @@ 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 a4c827331900d292febae384701bcd51add111d9..1a4598388a101795237cba9789b89f0511aca77c 100644 +index 40fed07c4f1d6205dd79021641fc1395816e7354..180c44678973f690c05cab9e5aabcd3715aeb021 100644 --- a/build.gradle.kts +++ b/build.gradle.kts -@@ -137,6 +137,7 @@ tasks.withType { +@@ -141,6 +141,7 @@ tasks.withType { compilerArgs.add("-Xlint:-module") compilerArgs.add("-Xlint:-removal") compilerArgs.add("-Xlint:-dep-ann") @@ -24,7 +24,7 @@ index a4c827331900d292febae384701bcd51add111d9..1a4598388a101795237cba9789b89f05 } // Gale end - hide irrelevant compilation warnings -@@ -207,6 +208,7 @@ tasks.withType { +@@ -211,6 +212,7 @@ tasks.withType { } options.addStringOption("Xdoclint:none", "-quiet") // Gale - hide irrelevant compilation warnings diff --git a/patches/api/0008-Player-canSee-by-entity-UUID.patch b/patches/api/0008-Player-canSee-by-entity-UUID.patch index f4e84d9..643cc96 100644 --- a/patches/api/0008-Player-canSee-by-entity-UUID.patch +++ b/patches/api/0008-Player-canSee-by-entity-UUID.patch @@ -37,10 +37,10 @@ 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/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java -index 7c56182acaf827f4b1a986a61cea8e9960604c98..328c34dee07311193d41f36c0976ed09135ab448 100644 +index 95f0b3186e313c7fbd5c8531d52b82a69e525f94..b9ccc3dda46ab0e759faff9a299798dd75a310eb 100644 --- a/src/main/java/org/bukkit/entity/Player.java +++ b/src/main/java/org/bukkit/entity/Player.java -@@ -2113,6 +2113,16 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM +@@ -2153,6 +2153,16 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM boolean listPlayer(@NotNull Player other); // Paper end diff --git a/patches/server/0002-Dev-import-deobfuscation-fixes.patch b/patches/server/0002-Dev-import-deobfuscation-fixes.patch index 89b2a1e..cee225f 100644 --- a/patches/server/0002-Dev-import-deobfuscation-fixes.patch +++ b/patches/server/0002-Dev-import-deobfuscation-fixes.patch @@ -34,10 +34,10 @@ index b0d26b0eadb2a43924629424a6c13198aace8f69..e8b8c453a7ff7af0a60ae915cfd85aba for (T executionCommandSource2 : list) { diff --git a/src/main/java/net/minecraft/util/ExtraCodecs.java b/src/main/java/net/minecraft/util/ExtraCodecs.java -index 68dda6a3257ca18c1e6c7659d62455da46d187e2..f8fa36b7c3763fed2392d62188bd210241e8f313 100644 +index eaa47e644926d6ec32e1c70523a0e713bc4c4906..4e7ed7fa08fabb4c253c75db41f7f24947aefff0 100644 --- a/src/main/java/net/minecraft/util/ExtraCodecs.java +++ b/src/main/java/net/minecraft/util/ExtraCodecs.java -@@ -223,7 +223,7 @@ public class ExtraCodecs { +@@ -226,7 +226,7 @@ public class ExtraCodecs { P object2 = listx.get(1); return combineFunction.apply(object, object2); }), pair -> ImmutableList.of(leftFunction.apply((I)pair), rightFunction.apply((I)pair))); @@ -46,7 +46,7 @@ index 68dda6a3257ca18c1e6c7659d62455da46d187e2..f8fa36b7c3763fed2392d62188bd2102 instance -> instance.group(codec.fieldOf(leftFieldName).forGetter(Pair::getFirst), codec.fieldOf(rightFieldName).forGetter(Pair::getSecond)) .apply(instance, Pair::of) ) -@@ -240,14 +240,14 @@ public class ExtraCodecs { +@@ -243,14 +243,14 @@ public class ExtraCodecs { }); } @@ -63,7 +63,7 @@ index 68dda6a3257ca18c1e6c7659d62455da46d187e2..f8fa36b7c3763fed2392d62188bd2102 } public DataResult coApply(DynamicOps dynamicOps, A object, DataResult dataResult) { -@@ -256,7 +256,7 @@ public class ExtraCodecs { +@@ -259,7 +259,7 @@ public class ExtraCodecs { @Override public String toString() { @@ -86,7 +86,7 @@ index 2942534d265416a3693848d76538c04735bc14fa..3f48037d5d6a4965b895fde69825d3b2 .put(levelDynamic.createString("x"), levelDynamic.createInt(sectionX * 16 + i)) .put(levelDynamic.createString("y"), levelDynamic.createInt(sectionY * 16 + j)) diff --git a/src/main/java/net/minecraft/world/level/levelgen/SurfaceRules.java b/src/main/java/net/minecraft/world/level/levelgen/SurfaceRules.java -index 9167bad12e1be3f4163f85987862b044a630b2eb..7ba3a3ca57b55f796a90b700b930f365c3508484 100644 +index 7174613ef2cac0f27c72dcfa2f822199ffbc79e5..38428ba2c522108f4f9f7986bc3535d1232ac1f8 100644 --- a/src/main/java/net/minecraft/world/level/levelgen/SurfaceRules.java +++ b/src/main/java/net/minecraft/world/level/levelgen/SurfaceRules.java @@ -177,10 +177,10 @@ public class SurfaceRules { @@ -102,7 +102,7 @@ index 9167bad12e1be3f4163f85987862b044a630b2eb..7ba3a3ca57b55f796a90b700b930f365 } @Override -@@ -514,12 +514,14 @@ public class SurfaceRules { +@@ -522,12 +522,14 @@ public class SurfaceRules { } @Override @@ -120,7 +120,7 @@ index 9167bad12e1be3f4163f85987862b044a630b2eb..7ba3a3ca57b55f796a90b700b930f365 } @Override -@@ -655,12 +657,12 @@ public class SurfaceRules { +@@ -663,12 +665,12 @@ public class SurfaceRules { } @Override @@ -135,7 +135,7 @@ index 9167bad12e1be3f4163f85987862b044a630b2eb..7ba3a3ca57b55f796a90b700b930f365 } @Override -@@ -748,26 +750,32 @@ public class SurfaceRules { +@@ -756,26 +758,32 @@ public class SurfaceRules { } @Override @@ -178,7 +178,7 @@ index 9167bad12e1be3f4163f85987862b044a630b2eb..7ba3a3ca57b55f796a90b700b930f365 return (double)randomSource.nextFloat() < d; } } -@@ -795,10 +803,10 @@ public class SurfaceRules { +@@ -803,10 +811,10 @@ public class SurfaceRules { } @Override @@ -191,7 +191,7 @@ index 9167bad12e1be3f4163f85987862b044a630b2eb..7ba3a3ca57b55f796a90b700b930f365 } @Override -@@ -833,10 +841,10 @@ public class SurfaceRules { +@@ -841,10 +849,10 @@ public class SurfaceRules { } @Override diff --git a/patches/server/0003-Hide-irrelevant-compilation-warnings.patch b/patches/server/0003-Hide-irrelevant-compilation-warnings.patch index 7211f80..39cbf78 100644 --- a/patches/server/0003-Hide-irrelevant-compilation-warnings.patch +++ b/patches/server/0003-Hide-irrelevant-compilation-warnings.patch @@ -7,11 +7,11 @@ License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) Gale - https://galemc.org diff --git a/build.gradle.kts b/build.gradle.kts -index ee1b8fbab56ff0a85a4f2bd071a0de5111aa1d4f..381b4b5d2cc54497c7db46218acc58313552ad78 100644 +index d600158c16341591ec7cd08d7c2894fb34fdab4b..5cc16e573241106d2a8b67c2f6e1a9338cfe6708 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -72,6 +72,15 @@ paperweight { - craftBukkitPackageVersion.set("v1_21_R1") // also needs to be updated in MappingEnvironment + craftBukkitPackageVersion.set("v1_21_R2") // also needs to be updated in MappingEnvironment } +// Gale start - hide irrelevant compilation warnings diff --git a/patches/server/0005-Gale-branding-changes.patch b/patches/server/0005-Gale-branding-changes.patch index 617c2f9..09f4416 100644 --- a/patches/server/0005-Gale-branding-changes.patch +++ b/patches/server/0005-Gale-branding-changes.patch @@ -221,7 +221,7 @@ index 94a9ed024d3859793618152ea559a168bbcbb5e2..e60008693e017bec1b4eb49c84be3898 -. +. diff --git a/build.gradle.kts b/build.gradle.kts -index adb8c4f3ed3cb22b62a4b4eb867b197b10cfac54..badd1433e27e2e95b165618de280cba1ff10a69d 100644 +index c8c3599a780bbc02a1ead1fe66498733ea4075c2..ead700089f8867e38699db409c13162f1014f58a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -94,14 +94,14 @@ tasks.jar { @@ -477,10 +477,10 @@ index bb1a60180e58c1333e7bb33e8acf1b0225eda8a8..4d037e899e0b5548be406ad55acd2062 DamageSource damageSource = this.cloneInstance(); damageSource.customEventDamager = entity; diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java -index 40689256711cc94a806ca1da346f4f62eda31526..11cf6a20550e252501a92be5bdffafcff007cbf9 100644 +index 78922c3e9a69db1774dd846047b79e9523d7cf41..84bc6585702f8d7a801530b09f18912ac083404d 100644 --- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java +++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java -@@ -177,7 +177,13 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise +@@ -274,7 +274,13 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise // Paper start private static void printOversizedLog(String msg, Path file, int x, int z) { @@ -496,24 +496,24 @@ index 40689256711cc94a806ca1da346f4f62eda31526..11cf6a20550e252501a92be5bdffafcf private static CompoundTag readOversizedChunk(RegionFile regionfile, ChunkPos chunkCoordinate) throws IOException { diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java -index 2f4d6b56301195f8d39ed50dffe842464065bfe1..bdfb969f88e68d89a5cad4b145bbc1441a110bac 100644 +index 6fef86e47e37eab6721cfd67d494afb25a2ded68..29aa7549e0082f0061a94b5b2f59aeec39b17c6c 100644 --- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java +++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java -@@ -492,7 +492,7 @@ public class CraftScheduler implements BukkitScheduler { +@@ -491,7 +491,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 + // this.debugTail = this.debugTail.setNext(new CraftAsyncDebugger(this.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 d06aab9bd5cd901c8367f9680f5d27ddb17b3dc4..4d0de69b730599d7a89903dd862b89d51ba79e1b 100644 +index 83020837e29ee627b1081daddb4bdee147b95af3..71d526cf165ff63a7344e19864eed409f3952fbb 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -@@ -489,7 +489,7 @@ public final class CraftMagicNumbers implements UnsafeValues { - +@@ -505,7 +505,7 @@ public final class CraftMagicNumbers implements UnsafeValues { + // Paper start @Override public com.destroystokyo.paper.util.VersionFetcher getVersionFetcher() { - return new com.destroystokyo.paper.PaperVersionFetcher(); diff --git a/patches/server/0006-Gale-metrics.patch b/patches/server/0006-Gale-metrics.patch index b88efcc..56b18a9 100644 --- a/patches/server/0006-Gale-metrics.patch +++ b/patches/server/0006-Gale-metrics.patch @@ -6,21 +6,35 @@ Subject: [PATCH] Gale metrics License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) Gale - https://galemc.org -diff --git a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkTaskScheduler.java b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkTaskScheduler.java -index b1456c1ddf24b625c6caf41a9379d8c011e1c36c..be7a4e2fd8823925847949d33358d64d464ec79f 100644 ---- a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkTaskScheduler.java -+++ b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkTaskScheduler.java -@@ -65,7 +65,7 @@ public final class ChunkTaskScheduler { +diff --git a/src/main/java/ca/spottedleaf/moonrise/common/util/MoonriseCommon.java b/src/main/java/ca/spottedleaf/moonrise/common/util/MoonriseCommon.java +index c125c70a68130be373acc989053a6c0e487be924..bd43c483c2f0837d3d4db9e0a9bc624c8c7b65ba 100644 +--- a/src/main/java/ca/spottedleaf/moonrise/common/util/MoonriseCommon.java ++++ b/src/main/java/ca/spottedleaf/moonrise/common/util/MoonriseCommon.java +@@ -11,6 +11,10 @@ import java.util.function.Consumer; + public final class MoonriseCommon { - private static final Logger LOGGER = LogUtils.getClassLogger(); + private static final Logger LOGGER = LoggerFactory.getLogger(MoonriseCommon.class); ++ // Gale start - metrics - chunk system IO threads ++ public static int chunkSystemIOThreads; ++ public static int chunkSystemWorkerThreads; ++ // Gale end - metrics - chunk system IO threads + + public static final PrioritisedThreadPool WORKER_POOL = new PrioritisedThreadPool( + new Consumer<>() { +@@ -54,6 +58,11 @@ public final class MoonriseCommon { + + final int ioThreads = Math.max(1, configIoThreads); + ++ // Gale start - metrics - chunk system IO threads ++ chunkSystemIOThreads = ioThreads; ++ chunkSystemWorkerThreads = workerThreads; ++ // Gale end - metrics - chunk system IO threads ++ + WORKER_POOL.adjustThreadCount(workerThreads); + IO_POOL.adjustThreadCount(ioThreads); -- static int newChunkSystemIOThreads; -+ public static int newChunkSystemIOThreads; // Gale - metrics - chunk system IO threads - package-private -> public - static int newChunkSystemGenParallelism; - static int newChunkSystemGenPopulationParallelism; - static int newChunkSystemLoadParallelism; diff --git a/src/main/java/com/destroystokyo/paper/Metrics.java b/src/main/java/com/destroystokyo/paper/Metrics.java -index 4b002e8b75d117b726b0de274a76d3596fce015b..7e1405d5e2b847b28b07cb94fcbf5dec78706e34 100644 +index 4b002e8b75d117b726b0de274a76d3596fce015b..e848529892c07cad638090a39ef738b4a068db3e 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 { @@ -77,7 +91,7 @@ index 4b002e8b75d117b726b0de274a76d3596fce015b..7e1405d5e2b847b28b07cb94fcbf5dec entry.put(String.valueOf(legacy), 1); // create buckets as higher dimension -@@ -676,6 +676,253 @@ public class Metrics { +@@ -676,6 +676,256 @@ public class Metrics { return map; })); @@ -216,7 +230,10 @@ index 4b002e8b75d117b726b0de274a76d3596fce015b..7e1405d5e2b847b28b07cb94fcbf5dec + })); + // Gale end - metrics - netty threads + -+ metrics.addCustomChart(new Metrics.SimplePie("chunk_system_io_thread_count", () -> String.valueOf(ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ChunkTaskScheduler.newChunkSystemIOThreads))); // Gale - metrics - chunk system IO threads ++ // Gale start - metrics - chunk system threads ++ metrics.addCustomChart(new Metrics.SimplePie("chunk_system_io_thread_count", () -> String.valueOf(ca.spottedleaf.moonrise.common.util.MoonriseCommon.chunkSystemIOThreads))); ++ metrics.addCustomChart(new Metrics.SimplePie("chunk_system_worker_thread_count", () -> String.valueOf(ca.spottedleaf.moonrise.common.util.MoonriseCommon.chunkSystemWorkerThreads))); ++ // Gale end - metrics - chunk system threads + + // Gale start - metrics - physical cores + metrics.addCustomChart(new Metrics.SimplePie("physical_core_count", () -> { diff --git a/patches/server/0007-Gale-semantic-version.patch b/patches/server/0007-Gale-semantic-version.patch index 7007f46..af18615 100644 --- a/patches/server/0007-Gale-semantic-version.patch +++ b/patches/server/0007-Gale-semantic-version.patch @@ -7,10 +7,10 @@ License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) Gale - https://galemc.org diff --git a/src/main/java/com/destroystokyo/paper/Metrics.java b/src/main/java/com/destroystokyo/paper/Metrics.java -index 7e1405d5e2b847b28b07cb94fcbf5dec78706e34..66477f772ffb9271cf647dfb7567d75c3d5145fb 100644 +index e848529892c07cad638090a39ef738b4a068db3e..cb9e42fea57856f9ab649e33df26071db1b7790f 100644 --- a/src/main/java/com/destroystokyo/paper/Metrics.java +++ b/src/main/java/com/destroystokyo/paper/Metrics.java -@@ -923,6 +923,16 @@ public class Metrics { +@@ -926,6 +926,16 @@ public class Metrics { })); // Gale end - metrics - runtime max memory diff --git a/patches/server/0008-Gale-configuration.patch b/patches/server/0008-Gale-configuration.patch index f5fcf3d..e7d270d 100644 --- a/patches/server/0008-Gale-configuration.patch +++ b/patches/server/0008-Gale-configuration.patch @@ -12,31 +12,6 @@ By: Jake Potrebic As part of: Paper (https://github.com/PaperMC/Paper) Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) -diff --git a/src/main/java/co/aikar/timings/TimingsExport.java b/src/main/java/co/aikar/timings/TimingsExport.java -index 7620c72a4c243cbeea245203ce03a97cbfa7d922..29796a404e210f7864f4b33b3367e02531bca2a0 100644 ---- a/src/main/java/co/aikar/timings/TimingsExport.java -+++ b/src/main/java/co/aikar/timings/TimingsExport.java -@@ -240,7 +240,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 - include in timings -+ pair("paper", mapAsJSON(Bukkit.spigot().getPaperConfig(), null)), -+ pair("gale", mapAsJSON(Bukkit.spigot().getGaleConfig(), null)) -+ // Gale end - Gale configuration - include in timings - )); - - new TimingsExport(listeners, parent, history).start(); -@@ -281,7 +284,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/Configurations.java b/src/main/java/io/papermc/paper/configuration/Configurations.java index 87e5f614ba988547a827486740db217e28585773..38d99d73a33911afa71d02a456bb4df62ce75166 100644 --- a/src/main/java/io/papermc/paper/configuration/Configurations.java @@ -189,7 +164,7 @@ index 8f23276796037d048eb114952891a01a40971b3e..ac9ceb54b894119cb30a22d37e035e2c } } diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 696d075ca2883f3c37e35f983c4d020e5db89d16..1840332f79c5cfc2a913d80d9885939be92f87d6 100644 +index 64b56abf8900d0424100da460fc68ac964394793..072e0188280d4d49fd5a96dbfa95344eec250e8b 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -3,9 +3,6 @@ package net.minecraft.server; @@ -202,7 +177,7 @@ index 696d075ca2883f3c37e35f983c4d020e5db89d16..1840332f79c5cfc2a913d80d9885939b import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; -@@ -149,6 +146,9 @@ import net.minecraft.world.level.levelgen.WorldOptions; +@@ -156,6 +153,9 @@ import net.minecraft.world.level.levelgen.WorldOptions; import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplateManager; import net.minecraft.world.level.storage.WorldData; @@ -212,7 +187,7 @@ index 696d075ca2883f3c37e35f983c4d020e5db89d16..1840332f79c5cfc2a913d80d9885939b import org.slf4j.Logger; // CraftBukkit start -@@ -317,6 +317,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop minecraftserver.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(convertable_conversionsession.levelDirectory.path(), iworlddataserver.getLevelName(), resourcekey.location(), spigotConfig, minecraftserver.registryAccess(), iworlddataserver.getGameRules())), executor); // Paper - create paper world configs; Async-Anti-Xray: Pass executor -+ super(iworlddataserver, resourcekey, minecraftserver.registryAccess(), worlddimension.type(), 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, minecraftserver.registryAccess(), iworlddataserver.getGameRules())), spigotConfig -> minecraftserver.galeConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(convertable_conversionsession.levelDirectory.path(), iworlddataserver.getLevelName(), resourcekey.location(), spigotConfig, minecraftserver.registryAccess(), iworlddataserver.getGameRules())), executor); // Paper - create paper world configs; Async-Anti-Xray: Pass executor // Gale - Gale configuration + // Add env and gen to constructor, IWorldDataServer -> WorldDataServer + public ServerLevel(MinecraftServer minecraftserver, Executor executor, LevelStorageSource.LevelStorageAccess convertable_conversionsession, PrimaryLevelData iworlddataserver, ResourceKey resourcekey, LevelStem worlddimension, ChunkProgressListener worldloadlistener, boolean flag, long i, List list, boolean flag1, @Nullable RandomSequences randomsequences, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider) { +- super(iworlddataserver, resourcekey, minecraftserver.registryAccess(), worlddimension.type(), 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, minecraftserver.registryAccess(), iworlddataserver.getGameRules())), executor); // Paper - create paper world configs; Async-Anti-Xray: Pass executor ++ super(iworlddataserver, resourcekey, minecraftserver.registryAccess(), worlddimension.type(), 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, minecraftserver.registryAccess(), iworlddataserver.getGameRules())), spigotConfig -> minecraftserver.galeConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(convertable_conversionsession.levelDirectory.path(), iworlddataserver.getLevelName(), resourcekey.location(), spigotConfig, minecraftserver.registryAccess(), iworlddataserver.getGameRules())), executor); // Paper - create paper world configs; 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 507671476c3d2d92a2fdb05be24443af27d26dcf..32cd737206dd9f2bcfdacfe17dc0621ee34b589a 100644 +index 022de445bbbb869c38be4972c98dcf1c665539ec..c0e4b996715dec16dd181b7dac87c361a16a1f7f 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -12,7 +12,6 @@ import java.util.function.Supplier; +@@ -11,7 +11,6 @@ import java.util.function.Predicate; import javax.annotation.Nullable; import net.minecraft.CrashReport; import net.minecraft.CrashReportCategory; @@ -322,15 +297,15 @@ index 507671476c3d2d92a2fdb05be24443af27d26dcf..32cd737206dd9f2bcfdacfe17dc0621e import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; -@@ -101,6 +98,7 @@ import org.bukkit.craftbukkit.block.data.CraftBlockData; +@@ -103,6 +100,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.GaleWorldConfiguration; // CraftBukkit end - public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemLevel, ca.spottedleaf.moonrise.patches.chunk_system.world.ChunkSystemEntityGetter, ca.spottedleaf.moonrise.patches.collisions.world.CollisionLevel { // Paper - rewrite chunk system // Paper - optimise collisions -@@ -171,6 +169,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl + public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemLevel, ca.spottedleaf.moonrise.patches.chunk_system.world.ChunkSystemEntityGetter { // Paper - rewrite chunk system // Paper - optimise collisions +@@ -172,6 +170,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl return this.paperConfig; } // Paper end - add paper world config @@ -342,13 +317,18 @@ index 507671476c3d2d92a2fdb05be24443af27d26dcf..32cd737206dd9f2bcfdacfe17dc0621e + // Gale end - Gale configuration public final com.destroystokyo.paper.antixray.ChunkPacketBlockController chunkPacketBlockController; // Paper - Anti-Xray - public final co.aikar.timings.WorldTimingsHandler timings; // Paper -@@ -684,9 +688,10 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl + public static BlockPos lastPhysicsProblem; // Spigot +@@ -830,7 +834,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl } // Paper end - optimise random ticking -- protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, RegistryAccess iregistrycustom, Holder holder, Supplier 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 paperWorldConfigCreator, java.util.concurrent.Executor executor) { // Paper - create paper world config & Anti-Xray -+ protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, RegistryAccess iregistrycustom, Holder holder, Supplier 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 paperWorldConfigCreator, java.util.function.Function galeWorldConfigCreator, java.util.concurrent.Executor executor) { // Paper - create paper world config & Anti-Xray // Gale - Gale configuration +- protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, RegistryAccess iregistrycustom, Holder holder, 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 paperWorldConfigCreator, java.util.concurrent.Executor executor) { // Paper - create paper world config & Anti-Xray ++ protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, RegistryAccess iregistrycustom, Holder holder, 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 paperWorldConfigCreator, java.util.function.Function galeWorldConfigCreator, java.util.concurrent.Executor executor) { // Paper - create paper world config & Anti-Xray // Gale - Gale configuration + // Paper start - getblock optimisations - cache world height/sections + final DimensionType dimType = holder.value(); + this.minY = dimType.minY(); +@@ -842,6 +846,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl + // Paper end - getblock optimisations - cache world height/sections this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper - create paper world config + this.galeConfig = galeWorldConfigCreator.apply(this.spigotConfig); // Gale - Gale configuration @@ -356,18 +336,18 @@ index 507671476c3d2d92a2fdb05be24443af27d26dcf..32cd737206dd9f2bcfdacfe17dc0621e 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 c7df339aeb62ee627edaf1bb4c8474b61e357ba6..b1c1e600100ac31ecb20473b8ad2853676dff84a 100644 +index b185a9b474121b8a4067816b3c3c39270c2a202e..9009da78ba2d7751b974123ce76a37af98189b6a 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -1072,6 +1072,7 @@ public final class CraftServer implements Server { +@@ -1074,6 +1074,7 @@ public final class CraftServer implements Server { org.spigotmc.SpigotConfig.init((File) this.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)) -@@ -2990,6 +2991,14 @@ public final class CraftServer implements Server { + world.setSpawnSettings(world.serverLevelData.getDifficulty() != Difficulty.PEACEFUL && config.spawnMonsters); // Paper - per level difficulty (from MinecraftServer#setDifficulty(ServerLevel, Difficulty, boolean)) +@@ -3009,6 +3010,14 @@ public final class CraftServer implements Server { return CraftServer.this.console.paperConfigurations.createLegacyObject(CraftServer.this.console); } @@ -793,28 +773,3 @@ index 0000000000000000000000000000000000000000..b82bb95b524c95cdefb81abef906eded + } + +} -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..579c2e69d8f6ce8398eb1297d1d1ead98c9068a5 ---- /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; -+ } -+ -+} diff --git a/patches/server/0010-Gale-commands.patch b/patches/server/0010-Gale-commands.patch index 5fcd134..1040053 100644 --- a/patches/server/0010-Gale-commands.patch +++ b/patches/server/0010-Gale-commands.patch @@ -13,10 +13,10 @@ As part of: Paper (https://github.com/PaperMC/Paper) Licensed under: MIT (https://opensource.org/licenses/MIT) diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -index 86c615518e315dd4425d17df163e88a150a4ef7c..8306edb6fb28e90ba4b432a07131e063daa70507 100644 +index 9ce281e220089ea2a9218c25879f42aafa0a4011..43e2ffd275e4ea74edf5eb4065ce2ccb415740f3 100644 --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -@@ -57,6 +57,7 @@ import net.minecraft.world.level.GameRules; +@@ -56,6 +56,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; @@ -24,7 +24,7 @@ index 86c615518e315dd4425d17df163e88a150a4ef7c..8306edb6fb28e90ba4b432a07131e063 import org.slf4j.Logger; // CraftBukkit start -@@ -240,6 +241,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -237,6 +238,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface org.spigotmc.WatchdogThread.doStart(org.spigotmc.SpigotConfig.timeoutTime, org.spigotmc.SpigotConfig.restartOnCrash); // Paper - start watchdog thread thread.start(); // Paper - Enhance console tab completions for brigadier commands; start console thread after MinecraftServer.console & PaperConfig are initialized io.papermc.paper.command.PaperCommands.registerCommands(this); // Paper - setup /paper command diff --git a/patches/server/0011-Remove-vanilla-profiler.patch b/patches/server/0011-Remove-vanilla-profiler.patch index 666ff92..1819b67 100644 --- a/patches/server/0011-Remove-vanilla-profiler.patch +++ b/patches/server/0011-Remove-vanilla-profiler.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/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java -index 5af48400f87500166dd889c57a8df0aadb08d43d..bbfd3e2a7e6a9a47d80bfea765e77b16c269562a 100644 +index 260350422fc724ba5cd5769cbb387b6007f36a84..bd2ee66047c3c7f24ab90951ff50aec5ddc9362d 100644 --- a/src/main/java/net/minecraft/commands/Commands.java +++ b/src/main/java/net/minecraft/commands/Commands.java @@ -55,7 +55,6 @@ import net.minecraft.server.commands.CloneCommands; @@ -48,7 +48,15 @@ index 5af48400f87500166dd889c57a8df0aadb08d43d..bbfd3e2a7e6a9a47d80bfea765e77b16 import net.minecraft.server.commands.DebugConfigCommand; import net.minecraft.server.commands.DebugMobSpawningCommand; import net.minecraft.server.commands.DebugPathCommand; -@@ -165,7 +164,6 @@ public class Commands { +@@ -132,7 +131,6 @@ import net.minecraft.server.commands.WorldBorderCommand; + import net.minecraft.server.commands.data.DataCommands; + import net.minecraft.server.level.ServerPlayer; + import net.minecraft.tags.TagKey; +-import net.minecraft.util.profiling.Profiler; + import net.minecraft.util.profiling.jfr.JvmProfiler; + import net.minecraft.world.flag.FeatureFlagSet; + import net.minecraft.world.flag.FeatureFlags; +@@ -169,7 +167,6 @@ public class Commands { DamageCommand.register(this.dispatcher, commandRegistryAccess); DataCommands.register(this.dispatcher); DataPackCommand.register(this.dispatcher); @@ -56,30 +64,30 @@ index 5af48400f87500166dd889c57a8df0aadb08d43d..bbfd3e2a7e6a9a47d80bfea765e77b16 DefaultGameModeCommands.register(this.dispatcher); DifficultyCommand.register(this.dispatcher); EffectCommands.register(this.dispatcher, commandRegistryAccess); -@@ -340,9 +338,6 @@ public class Commands { +@@ -345,9 +342,6 @@ public class Commands { // Paper end CommandSourceStack commandlistenerwrapper = (CommandSourceStack) parseresults.getContext().getSource(); -- commandlistenerwrapper.getServer().getProfiler().push(() -> { +- Profiler.get().push(() -> { - return "/" + s; - }); ContextChain contextchain = this.finishParsing(parseresults, s, commandlistenerwrapper, label); // CraftBukkit // Paper - Add UnknownCommandEvent try { -@@ -371,8 +366,6 @@ public class Commands { +@@ -376,8 +370,6 @@ public class Commands { commandlistenerwrapper.sendFailure(Component.literal(Util.describeError(exception))); Commands.LOGGER.error("'/{}' threw an exception", s, exception); } - } finally { -- commandlistenerwrapper.getServer().getProfiler().pop(); +- Profiler.get().pop(); } } -@@ -435,7 +428,7 @@ public class Commands { +@@ -440,7 +432,7 @@ public class Commands { int j = minecraftserver.getGameRules().getInt(GameRules.RULE_MAX_COMMAND_FORK_COUNT); try { -- ExecutionContext executioncontext1 = new ExecutionContext<>(i, j, minecraftserver.getProfiler()); +- ExecutionContext executioncontext1 = new ExecutionContext<>(i, j, Profiler.get()); + ExecutionContext executioncontext1 = new ExecutionContext<>(i, j); // Gale - Purpur - remove vanilla profiler try { @@ -164,16 +172,17 @@ index e9775b4506909bee65a74964f0d5391a0513de1d..1c4dd8acdcd571aceffe4b78599ca2c7 } } diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 1840332f79c5cfc2a913d80d9885939be92f87d6..161904cc1d802d9b113f68c2eb46a1c7a7c1b425 100644 +index 072e0188280d4d49fd5a96dbfa95344eec250e8b..8a643e65d805e167516ff3331ab9c6482aa3ec8a 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -103,18 +103,9 @@ import net.minecraft.util.datafix.DataFixers; +@@ -108,19 +108,8 @@ import net.minecraft.util.datafix.DataFixers; import net.minecraft.util.debugchart.RemoteDebugSampleType; import net.minecraft.util.debugchart.SampleLogger; import net.minecraft.util.debugchart.TpsDebugDimensions; -import net.minecraft.util.profiling.EmptyProfileResults; -import net.minecraft.util.profiling.ProfileResults; - import net.minecraft.util.profiling.ProfilerFiller; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; -import net.minecraft.util.profiling.ResultField; -import net.minecraft.util.profiling.SingleTickProfiler; import net.minecraft.util.profiling.jfr.JvmProfiler; @@ -186,12 +195,11 @@ index 1840332f79c5cfc2a913d80d9885939be92f87d6..161904cc1d802d9b113f68c2eb46a1c7 import net.minecraft.util.thread.ReentrantBlockableEventLoop; import net.minecraft.world.Difficulty; import net.minecraft.world.RandomSequences; -@@ -223,14 +214,6 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop tickables = Lists.newArrayList(); - private MetricsRecorder metricsRecorder; -- private ProfilerFiller profiler; - private Consumer onMetricsRecordingStopped; - private Consumer onMetricsRecordingFinished; - private boolean willStartRecordingMetrics; @@ -201,12 +209,11 @@ index 1840332f79c5cfc2a913d80d9885939be92f87d6..161904cc1d802d9b113f68c2eb46a1c7 private ServerConnectionListener connection; public final ChunkProgressListenerFactory progressListenerFactory; @Nullable -@@ -419,13 +402,6 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { - this.stopRecordingMetrics(); - }; @@ -215,7 +222,7 @@ index 1840332f79c5cfc2a913d80d9885939be92f87d6..161904cc1d802d9b113f68c2eb46a1c7 this.random = RandomSource.create(); this.port = -1; this.levels = Maps.newLinkedHashMap(); -@@ -1034,9 +1010,6 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { - return false; - } : this::haveTime); -@@ -1311,7 +1277,6 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { + return false; +@@ -1338,7 +1299,6 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 0 && this.tickCount % autosavePeriod == 0; try { this.isSaving = true; -@@ -1622,7 +1583,6 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { + entityplayer.connection.suspendFlushing(); + }); +@@ -1816,9 +1744,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { +- gameprofilerfiller.push(() -> { - String s = String.valueOf(worldserver); - - return s + " " + String.valueOf(worldserver.dimension().location()); - }); /* Drop global time updates if (this.tickCount % 20 == 0) { -- this.profiler.push("timeSync"); +- gameprofilerfiller.push("timeSync"); this.synchronizeTime(worldserver); -- this.profiler.pop(); +- gameprofilerfiller.pop(); } // CraftBukkit end */ -- this.profiler.push("tick"); +- gameprofilerfiller.push("tick"); - try { - worldserver.timings.doTick.startTiming(); // Spigot worldserver.tick(shouldKeepTicking); -@@ -1812,17 +1759,13 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { - this.executeBlocking(() -> { @@ -417,13 +461,11 @@ index 1840332f79c5cfc2a913d80d9885939be92f87d6..161904cc1d802d9b113f68c2eb46a1c7 - this.willStartRecordingMetrics = false; - } - -- this.profiler = SingleTickProfiler.decorateFiller(this.metricsRecorder.getProfiler(), SingleTickProfiler.createTickProfiler("Server")); - this.metricsRecorder.startTick(); -- this.profiler.startTick(); +- return SingleTickProfiler.decorateFiller(this.metricsRecorder.getProfiler(), SingleTickProfiler.createTickProfiler("Server")); - } - - public void endMetricsRecordingTick() { -- this.profiler.endTick(); - this.metricsRecorder.endTick(); - } - @@ -450,13 +492,12 @@ index 1840332f79c5cfc2a913d80d9885939be92f87d6..161904cc1d802d9b113f68c2eb46a1c7 - - public void cancelRecordingMetrics() { - this.metricsRecorder.cancel(); -- this.profiler = this.metricsRecorder.getProfiler(); - } - public Path getWorldPath(LevelResource worldSavePath) { return this.storageSource.getLevelPath(worldSavePath); } -@@ -2918,25 +2807,6 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop reload( - PreparableReloadListener.PreparationBarrier synchronizer, - ResourceManager manager, -- ProfilerFiller prepareProfiler, -- ProfilerFiller applyProfiler, - Executor prepareExecutor, - Executor applyExecutor - ) { + .thenApply(void_ -> reloadableServerResources); diff --git a/src/main/java/net/minecraft/server/ServerFunctionManager.java b/src/main/java/net/minecraft/server/ServerFunctionManager.java -index 9cd4f7c6910727c849ac7f5d675dc6105c4bbba2..f9f893a286147c9a8e49f78891381227380a2a14 100644 +index 0b348f701b61c7b7ed0190eff8b2d73f3a3d5c74..13b637afe8652327a69c926eded50b0afbf27103 100644 --- a/src/main/java/net/minecraft/server/ServerFunctionManager.java +++ b/src/main/java/net/minecraft/server/ServerFunctionManager.java -@@ -16,7 +16,6 @@ import net.minecraft.commands.functions.CommandFunction; +@@ -16,8 +16,6 @@ import net.minecraft.commands.functions.CommandFunction; import net.minecraft.commands.functions.InstantiatedFunction; import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceLocation; +-import net.minecraft.util.profiling.Profiler; -import net.minecraft.util.profiling.ProfilerFiller; import org.slf4j.Logger; public class ServerFunctionManager { -@@ -53,10 +52,7 @@ public class ServerFunctionManager { +@@ -54,10 +52,7 @@ public class ServerFunctionManager { } private void executeTagFunctions(Collection> functions, ResourceLocation label) { -- ProfilerFiller gameprofilerfiller = this.server.getProfiler(); +- ProfilerFiller gameprofilerfiller = Profiler.get(); - Objects.requireNonNull(label); - gameprofilerfiller.push(label::toString); Iterator iterator = functions.iterator(); while (iterator.hasNext()) { -@@ -64,17 +60,9 @@ public class ServerFunctionManager { +@@ -65,17 +60,9 @@ public class ServerFunctionManager { this.execute(commandfunction, this.getGameLoopSender()); } - -- this.server.getProfiler().pop(); +- Profiler.get().pop(); } public void execute(CommandFunction function, CommandSourceStack source) { -- ProfilerFiller gameprofilerfiller = this.server.getProfiler(); +- ProfilerFiller gameprofilerfiller = Profiler.get(); - - gameprofilerfiller.push(() -> { - return "function " + String.valueOf(function.id()); @@ -606,7 +635,7 @@ index 9cd4f7c6910727c849ac7f5d675dc6105c4bbba2..f9f893a286147c9a8e49f78891381227 try { InstantiatedFunction instantiatedfunction = function.instantiate((CompoundTag) null, this.getDispatcher()); -@@ -85,8 +73,6 @@ public class ServerFunctionManager { +@@ -86,8 +73,6 @@ public class ServerFunctionManager { ; } catch (Exception exception) { ServerFunctionManager.LOGGER.warn("Failed to execute function {}", function.id(), exception); @@ -668,10 +697,10 @@ index 8c587f829c5e8c6b6df3150024c4ae704988c47b..9f00cd7d23710787d0cb94377f21a541 String string = String.format( Locale.ROOT, "%s-%s-%s", Util.getFilenameFormattedDateTime(), server.getWorldData().getLevelName(), SharedConstants.getCurrentVersion().getId() diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -index 8306edb6fb28e90ba4b432a07131e063daa70507..8538024c6345e79d08643e2d68ca146542b7860a 100644 +index 43e2ffd275e4ea74edf5eb4065ce2ccb415740f3..7c3e5d77a63b433c3212c8aab5a37d2af5634091 100644 --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -@@ -891,12 +891,6 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -837,12 +837,6 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface return this.settings.getProperties().serverResourcePackInfo; } @@ -684,23 +713,54 @@ index 8306edb6fb28e90ba4b432a07131e063daa70507..8538024c6345e79d08643e2d68ca1465 @Override public SampleLogger getTickTimeLogger() { return this.tickTimeLogger; +diff --git a/src/main/java/net/minecraft/server/level/ChunkGenerationTask.java b/src/main/java/net/minecraft/server/level/ChunkGenerationTask.java +index 7ea8c13c9993576c1408e710d3ceb9947b09090d..6a0a44ecc7ee6e838574b82f2faf5dcbd19abfa6 100644 +--- a/src/main/java/net/minecraft/server/level/ChunkGenerationTask.java ++++ b/src/main/java/net/minecraft/server/level/ChunkGenerationTask.java +@@ -5,8 +5,6 @@ import java.util.List; + import java.util.concurrent.CompletableFuture; + import javax.annotation.Nullable; + import net.minecraft.util.StaticCache2D; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.Zone; + import net.minecraft.world.level.ChunkPos; + import net.minecraft.world.level.chunk.ChunkAccess; + import net.minecraft.world.level.chunk.status.ChunkDependencies; +@@ -113,8 +111,6 @@ public class ChunkGenerationTask { + } + + private void scheduleLayer(ChunkStatus targetStatus, boolean allowGeneration) { +- try (Zone zone = Profiler.get().zone("scheduleLayer")) { +- zone.addText(targetStatus::getName); + int i = this.getRadiusForLayer(targetStatus, allowGeneration); + + for (int j = this.pos.x - i; j <= this.pos.x + i; j++) { +@@ -125,7 +121,6 @@ public class ChunkGenerationTask { + } + } + } +- } + } + + private int getRadiusForLayer(ChunkStatus status, boolean generate) { diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java -index af8cb316ac169aa8d98a88765b85bb013b9ba961..62bd7523e0d7d2dfdce1ee9edb2249c755f1ade3 100644 +index 5b3a886c624b36557cbfaccdc3fb05a46a4ba36a..d72c49b7861f049ebc32f7bb15345243c4be5838 100644 --- a/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java -@@ -65,7 +65,6 @@ import net.minecraft.server.network.ServerPlayerConnection; +@@ -65,8 +65,6 @@ import net.minecraft.server.network.ServerPlayerConnection; import net.minecraft.util.CsvOutput; import net.minecraft.util.Mth; import net.minecraft.util.StaticCache2D; +-import net.minecraft.util.profiling.Profiler; -import net.minecraft.util.profiling.ProfilerFiller; import net.minecraft.util.thread.BlockableEventLoop; - import net.minecraft.util.thread.ProcessorHandle; - import net.minecraft.util.thread.ProcessorMailbox; -@@ -392,16 +391,10 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider + import net.minecraft.util.thread.ConsecutiveExecutor; + import net.minecraft.world.entity.Entity; +@@ -406,16 +404,10 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider } protected void tick(BooleanSupplier shouldKeepTicking) { -- ProfilerFiller gameprofilerfiller = this.level.getProfiler(); +- ProfilerFiller gameprofilerfiller = Profiler.get(); - - gameprofilerfiller.push("poi"); this.poiManager.tick(shouldKeepTicking); @@ -714,154 +774,155 @@ index af8cb316ac169aa8d98a88765b85bb013b9ba961..62bd7523e0d7d2dfdce1ee9edb2249c7 public boolean hasWork() { diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index dcb5651d1d9b10b40430fb2f713beedf68336704..3b3684d202e460a80b3e6e97afbaa4c84c4e3b3b 100644 +index 3c711e1df57ac5b0f8795ebb12299d275792b1d4..ebed376154ce30bf75fcdc2bd23c4dab251e1719 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -@@ -22,7 +22,6 @@ import net.minecraft.network.protocol.Packet; +@@ -26,8 +26,6 @@ import net.minecraft.network.protocol.Packet; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.progress.ChunkProgressListener; import net.minecraft.util.VisibleForDebug; +-import net.minecraft.util.profiling.Profiler; -import net.minecraft.util.profiling.ProfilerFiller; import net.minecraft.util.thread.BlockableEventLoop; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.ai.village.poi.PoiManager; -@@ -381,19 +380,15 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon +@@ -442,38 +440,28 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon // CraftBukkit start - modelled on below public void purgeUnload() { if (true) return; // Paper - rewrite chunk system -- this.level.getProfiler().push("purge"); +- ProfilerFiller gameprofilerfiller = Profiler.get(); + +- gameprofilerfiller.push("purge"); this.distanceManager.purgeStaleTickets(); this.runDistanceManagerUpdates(); -- this.level.getProfiler().popPush("unload"); +- gameprofilerfiller.popPush("unload"); this.chunkMap.tick(() -> true); -- this.level.getProfiler().pop(); +- gameprofilerfiller.pop(); this.clearCache(); } // CraftBukkit end @Override public void tick(BooleanSupplier shouldKeepTicking, boolean tickChunks) { -- this.level.getProfiler().push("purge"); - this.level.timings.doChunkMap.startTiming(); // Spigot +- ProfilerFiller gameprofilerfiller = Profiler.get(); +- +- gameprofilerfiller.push("purge"); if (this.level.tickRateManager().runsNormally() || !tickChunks || this.level.spigotConfig.unloadFrozenChunks) { // Spigot this.distanceManager.purgeStaleTickets(); -@@ -401,7 +396,6 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon - - this.runDistanceManagerUpdates(); - this.level.timings.doChunkMap.stopTiming(); // Spigot -- this.level.getProfiler().popPush("chunks"); - if (tickChunks) { - this.level.timings.chunks.startTiming(); // Paper - timings - ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)this.level).moonrise$getPlayerChunkLoader().tick(); // Paper - rewrite chunk system -@@ -411,10 +405,8 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon } - this.level.timings.doChunkUnload.startTiming(); // Spigot -- this.level.getProfiler().popPush("unload"); + this.runDistanceManagerUpdates(); +- gameprofilerfiller.popPush("chunks"); + if (tickChunks) { + ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)this.level).moonrise$getPlayerChunkLoader().tick(); // Paper - rewrite chunk system + this.tickChunks(); + this.chunkMap.tick(); + } + +- gameprofilerfiller.popPush("unload"); this.chunkMap.tick(shouldKeepTicking); - this.level.timings.doChunkUnload.stopTiming(); // Spigot -- this.level.getProfiler().pop(); +- gameprofilerfiller.pop(); this.clearCache(); } -@@ -425,10 +417,6 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon +@@ -483,34 +471,26 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon this.lastInhabitedUpdate = i; if (!this.level.isDebug()) { -- ProfilerFiller gameprofilerfiller = this.level.getProfiler(); +- ProfilerFiller gameprofilerfiller = Profiler.get(); - - gameprofilerfiller.push("pollingChunks"); -- gameprofilerfiller.push("filteringLoadedChunks"); - // Paper start - chunk tick iteration optimisations - List list; - { -@@ -454,7 +442,6 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon - // Paper - chunk tick iteration optimisations - if (this.level.tickRateManager().runsNormally()) { -- gameprofilerfiller.popPush("naturalSpawnCount"); - this.level.timings.countNaturalMobs.startTiming(); // Paper - timings - int k = this.distanceManager.getNaturalSpawnChunkCount(); - // Paper start - Optional per player mob spawns -@@ -483,7 +470,6 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon - this.level.timings.countNaturalMobs.stopTiming(); // Paper - timings + List list = this.tickingChunks; - this.lastSpawnState = spawnercreature_d; -- gameprofilerfiller.popPush("spawnAndTick"); - boolean flag = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && !this.level.players().isEmpty(); // CraftBukkit - - if (!this.level.paperConfig().entities.spawning.perPlayerMobSpawns) Util.shuffle(list, this.level.random); // Paper - per player mob spawns - do not need this when per-player is enabled -@@ -523,7 +509,6 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon - } - this.level.timings.chunkTicks.stopTiming(); // Paper - -- gameprofilerfiller.popPush("customSpawners"); - if (flag) { - try (co.aikar.timings.Timing ignored = this.level.timings.miscMobSpawning.startTiming()) { // Paper - timings - this.level.tickCustomSpawners(this.spawnEnemies, this.spawnFriendlies); -@@ -531,7 +516,6 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon + try { +- gameprofilerfiller.push("filteringTickingChunks"); + this.collectTickingChunks(list); +- gameprofilerfiller.popPush("shuffleChunks"); + // Paper start - chunk tick iteration optimisation + this.shuffleRandom.setSeed(this.level.random.nextLong()); + if (!this.level.paperConfig().entities.spawning.perPlayerMobSpawns) Util.shuffle(list, this.shuffleRandom); // Paper - Optional per player mob spawns; do not need this when per-player is enabled + // Paper end - chunk tick iteration optimisation +- this.tickChunks(gameprofilerfiller, j, list); +- gameprofilerfiller.pop(); ++ this.tickChunks(j, list); // Gale - Purpur - remove vanilla profiler + } finally { + list.clear(); } } -- gameprofilerfiller.popPush("broadcast"); - // Paper start - chunk tick iteration optimisations - this.level.timings.broadcastChunkUpdates.startTiming(); // Paper - timing - { -@@ -549,8 +533,6 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon - } - this.level.timings.broadcastChunkUpdates.stopTiming(); // Paper - timing - // Paper end - chunk tick iteration optimisations -- gameprofilerfiller.pop(); +- this.broadcastChangedChunks(gameprofilerfiller); - gameprofilerfiller.pop(); ++ this.broadcastChangedChunks(); // Gale - Purpur - remove vanilla profiler } } -@@ -731,7 +713,6 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon +- private void broadcastChangedChunks(ProfilerFiller profiler) { +- profiler.push("broadcast"); ++ private void broadcastChangedChunks() { // Gale - Purpur - remove vanilla profiler + Iterator iterator = this.chunkHoldersToBroadcast.iterator(); + + while (iterator.hasNext()) { +@@ -523,7 +503,6 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon + } + + this.chunkHoldersToBroadcast.clear(); +- profiler.pop(); + } + + private void collectTickingChunks(List chunks) { +@@ -549,8 +528,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon + // Paper end - chunk tick iteration optimisation + } + +- private void tickChunks(ProfilerFiller profiler, long timeDelta, List chunks) { +- profiler.popPush("naturalSpawnCount"); ++ private void tickChunks(long timeDelta, List chunks) { // Gale - Purpur - remove vanilla profiler + int j = this.distanceManager.getNaturalSpawnChunkCount(); + // Paper start - Optional per player mob spawns + final int naturalSpawnChunkCount = j; +@@ -577,7 +555,6 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon + // Paper end - Optional per player mob spawns + + this.lastSpawnState = spawnercreature_d; +- profiler.popPush("spawnAndTick"); + boolean flag = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && !this.level.players().isEmpty(); // CraftBukkit + int k = this.level.getGameRules().getInt(GameRules.RULE_RANDOMTICKING); + List list1; +@@ -615,7 +592,6 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon + } + } + +- profiler.popPush("customSpawners"); + if (flag) { + this.level.tickCustomSpawners(this.spawnEnemies, this.spawnFriendlies); + } +@@ -813,7 +789,6 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon @Override protected void doRunTask(Runnable task) { -- ServerChunkCache.this.level.getProfiler().incrementCounter("runTask"); +- Profiler.get().incrementCounter("runTask"); super.doRunTask(task); } diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index e20b7a1ad141834a10c5f23f9b27cc41fa25ac0d..9b2833fc9906dc6c0ac254adabc0f471991439a8 100644 +index d406eebb7efb00b79128bdceb71d51be4efbce4c..3401602c57337e96012c2768b38f523ca7dd6798 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java -@@ -80,7 +80,6 @@ import net.minecraft.util.ProgressListener; +@@ -79,8 +79,6 @@ import net.minecraft.util.ProgressListener; import net.minecraft.util.RandomSource; import net.minecraft.util.Unit; import net.minecraft.util.datafix.DataFixTypes; +-import net.minecraft.util.profiling.Profiler; -import net.minecraft.util.profiling.ProfilerFiller; import net.minecraft.util.valueproviders.IntProvider; import net.minecraft.util.valueproviders.UniformInt; import net.minecraft.world.DifficultyInstance; -@@ -503,15 +502,17 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf. - // Holder holder = worlddimension.type(); // CraftBukkit - decompile error - - // Objects.requireNonNull(minecraftserver); // CraftBukkit - decompile error -- super(iworlddataserver, resourcekey, minecraftserver.registryAccess(), worlddimension.type(), 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, minecraftserver.registryAccess(), iworlddataserver.getGameRules())), spigotConfig -> minecraftserver.galeConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(convertable_conversionsession.levelDirectory.path(), iworlddataserver.getLevelName(), resourcekey.location(), spigotConfig, minecraftserver.registryAccess(), iworlddataserver.getGameRules())), executor); // Paper - create paper world configs; Async-Anti-Xray: Pass executor // Gale - Gale configuration -+ super(iworlddataserver, resourcekey, minecraftserver.registryAccess(), worlddimension.type(), 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, minecraftserver.registryAccess(), iworlddataserver.getGameRules())), spigotConfig -> minecraftserver.galeConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(convertable_conversionsession.levelDirectory.path(), iworlddataserver.getLevelName(), resourcekey.location(), spigotConfig, minecraftserver.registryAccess(), iworlddataserver.getGameRules())), executor); // Paper - create paper world configs; Async-Anti-Xray: Pass executor // Gale - Gale configuration // Gale - Purpur - remove vanilla profiler - this.pvpMode = minecraftserver.isPvpAllowed(); - this.convertable = convertable_conversionsession; - this.uuid = WorldUUID.getUUID(convertable_conversionsession.levelDirectory.path().toFile()); - // CraftBukkit end - this.players = Lists.newArrayList(); - this.entityTickList = new EntityTickList(); -- this.blockTicks = new LevelTicks<>(this::isPositionTickingWithEntitiesLoaded, this.getProfilerSupplier()); -- this.fluidTicks = new LevelTicks<>(this::isPositionTickingWithEntitiesLoaded, this.getProfilerSupplier()); -+ // Gale start - Purpur - remove vanilla profiler -+ this.blockTicks = new LevelTicks<>(this::isPositionTickingWithEntitiesLoaded); -+ this.fluidTicks = new LevelTicks<>(this::isPositionTickingWithEntitiesLoaded); -+ // Gale end - Purpur - remove vanilla profiler - this.pathTypesByPosCache = new PathTypeCache(); - this.navigatingMobs = new ObjectOpenHashSet(); - this.blockEvents = new ObjectLinkedOpenHashSet(); -@@ -624,16 +625,12 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf. +@@ -703,18 +701,13 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe } public void tick(BooleanSupplier shouldKeepTicking) { -- ProfilerFiller gameprofilerfiller = this.getProfiler(); +- ProfilerFiller gameprofilerfiller = Profiler.get(); - this.handlingTick = true; TickRateManager tickratemanager = this.tickRateManager(); @@ -872,14 +933,15 @@ index e20b7a1ad141834a10c5f23f9b27cc41fa25ac0d..9b2833fc9906dc6c0ac254adabc0f471 this.getWorldBorder().tick(); - gameprofilerfiller.popPush("weather"); this.advanceWeatherCycle(); +- gameprofilerfiller.pop(); } -@@ -665,30 +662,23 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf. + int i = this.getGameRules().getInt(GameRules.RULE_PLAYERS_SLEEPING_PERCENTAGE); +@@ -745,30 +738,22 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe this.tickTime(); } -- gameprofilerfiller.popPush("tickPending"); - this.timings.scheduledBlocks.startTiming(); // Paper +- gameprofilerfiller.push("tickPending"); if (!this.isDebug() && flag) { j = this.getGameTime(); - gameprofilerfiller.push("blockTicks"); @@ -888,24 +950,17 @@ index e20b7a1ad141834a10c5f23f9b27cc41fa25ac0d..9b2833fc9906dc6c0ac254adabc0f471 this.fluidTicks.tick(j, paperConfig().environment.maxFluidTicks, this::tickFluid); // Paper - configurable max fluid ticks - gameprofilerfiller.pop(); } - this.timings.scheduledBlocks.stopTiming(); // Paper - gameprofilerfiller.popPush("raid"); if (flag) { - this.timings.raids.startTiming(); // Paper - timings this.raids.tick(); - this.timings.raids.stopTiming(); // Paper - timings } - gameprofilerfiller.popPush("chunkSource"); - this.timings.chunkProviderTick.startTiming(); // Paper - timings this.getChunkSource().tick(shouldKeepTicking, true); - this.timings.chunkProviderTick.stopTiming(); // Paper - timings - gameprofilerfiller.popPush("blockEvents"); if (flag) { - this.timings.doSounds.startTiming(); // Spigot this.runBlockEvents(); -@@ -696,7 +686,6 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf. } this.handlingTick = false; @@ -913,12 +968,11 @@ index e20b7a1ad141834a10c5f23f9b27cc41fa25ac0d..9b2833fc9906dc6c0ac254adabc0f471 boolean flag1 = !paperConfig().unsupportedSettings.disableWorldTickingWhenEmpty || !this.players.isEmpty() || !this.getForcedChunks().isEmpty(); // CraftBukkit - this prevents entity cleanup, other issues on servers with no players // Paper - restore this if (flag1) { -@@ -704,12 +693,9 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf. +@@ -776,20 +761,15 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe } if (flag1 || this.emptyTime++ < 300) { - gameprofilerfiller.push("entities"); - this.timings.tickEntities.startTiming(); // Spigot if (this.dragonFight != null && flag) { - gameprofilerfiller.push("dragonFight"); this.dragonFight.tick(); @@ -926,17 +980,16 @@ index e20b7a1ad141834a10c5f23f9b27cc41fa25ac0d..9b2833fc9906dc6c0ac254adabc0f471 } org.spigotmc.ActivationRange.activateEntities(this); // Spigot -@@ -719,9 +705,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf. - if (false && this.shouldDiscardEntity(entity)) { // CraftBukkit - We prevent spawning in general, so this butchering is not needed - entity.discard(); - } else if (!tickratemanager.isEntityFrozen(entity)) { + this.entityTickList.forEach((entity) -> { + if (!entity.isRemoved()) { + if (!tickratemanager.isEntityFrozen(entity)) { - gameprofilerfiller.push("checkDespawn"); entity.checkDespawn(); - gameprofilerfiller.pop(); - if (true || this.chunkSource.chunkMap.getDistanceManager().inEntityTickingRange(entity.chunkPosition().toLong())) { // Paper - rewrite chunk system + if (true) { // Paper - rewrite chunk system Entity entity1 = entity.getVehicle(); -@@ -733,22 +717,17 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf. +@@ -801,20 +781,15 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe entity.stopRiding(); } @@ -947,8 +1000,6 @@ index e20b7a1ad141834a10c5f23f9b27cc41fa25ac0d..9b2833fc9906dc6c0ac254adabc0f471 } } }); - this.timings.entityTick.stopTiming(); // Spigot - this.timings.tickEntities.stopTiming(); // Spigot - gameprofilerfiller.pop(); this.tickBlockEntities(); } @@ -959,17 +1010,27 @@ index e20b7a1ad141834a10c5f23f9b27cc41fa25ac0d..9b2833fc9906dc6c0ac254adabc0f471 } @Override -@@ -860,9 +839,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf. +@@ -830,9 +805,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe + long i = this.levelData.getGameTime() + 1L; + + this.serverLevelData.setGameTime(i); +- Profiler.get().push("scheduledFunctions"); + this.serverLevelData.getScheduledEvents().tick(this.server, i); +- Profiler.get().pop(); + if (this.serverLevelData.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)) { + this.setDayTime(this.levelData.getDayTime() + 1L); + } +@@ -920,9 +893,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe boolean flag = this.isRaining(); int j = chunkcoordintpair.getMinBlockX(); int k = chunkcoordintpair.getMinBlockZ(); -- ProfilerFiller gameprofilerfiller = this.getProfiler(); +- ProfilerFiller gameprofilerfiller = Profiler.get(); - gameprofilerfiller.push("thunder"); - if (!this.paperConfig().environment.disableThunder && flag && this.isThundering() && this.spigotConfig.thunderChance > 0 && this.random.nextInt(this.spigotConfig.thunderChance) == 0) { // Spigot // Paper - Option to disable thunder + if (!this.paperConfig().environment.disableThunder && flag && this.isThundering() && this.spigotConfig.thunderChance > 0 && simpleRandom.nextInt(this.spigotConfig.thunderChance) == 0) { // Spigot // Paper - Option to disable thunder // Paper - optimise random ticking BlockPos blockposition = this.findLightningTargetAround(this.getBlockRandomPos(j, 0, k, 15)); -@@ -891,8 +868,6 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf. +@@ -951,8 +922,6 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe } } @@ -977,47 +1038,46 @@ index e20b7a1ad141834a10c5f23f9b27cc41fa25ac0d..9b2833fc9906dc6c0ac254adabc0f471 - if (!this.paperConfig().environment.disableIceAndSnow) { // Paper - Option to disable ice and snow for (int l = 0; l < randomTickSpeed; ++l) { - if (this.random.nextInt(48) == 0) { -@@ -901,14 +876,12 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf. + if (simpleRandom.nextInt(48) == 0) { // Paper - optimise random ticking +@@ -961,12 +930,9 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe } } // Paper - Option to disable ice and snow - gameprofilerfiller.popPush("tickBlocks"); - timings.chunkTicksBlocks.startTiming(); // Paper if (randomTickSpeed > 0) { this.optimiseRandomTick(chunk, randomTickSpeed); // Paper - optimise random ticking } - - timings.chunkTicksBlocks.stopTiming(); // Paper +- - gameprofilerfiller.pop(); } @VisibleForTesting -@@ -1236,19 +1209,13 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf. - try { - // Paper end - timings +@@ -1286,19 +1252,14 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe + }*/ // Paper - comment out EAR 2 + // Spigot end entity.setOldPosAndRot(); -- ProfilerFiller gameprofilerfiller = this.getProfiler(); +- ProfilerFiller gameprofilerfiller = Profiler.get(); ++entity.tickCount; -- this.getProfiler().push(() -> { +- gameprofilerfiller.push(() -> { - return BuiltInRegistries.ENTITY_TYPE.getKey(entity.getType()).toString(); - }); - gameprofilerfiller.incrementCounter("tickNonPassenger"); ++ + final boolean isActive = org.spigotmc.ActivationRange.checkIfActive(entity); // Paper - EAR 2 if (isActive) { // Paper - EAR 2 - TimingHistory.activatedEntityTicks++; entity.tick(); entity.postTick(); // CraftBukkit } else { entity.inactiveTick(); } // Paper - EAR 2 -- this.getProfiler().pop(); - } finally { timer.stopTiming(); } // Paper - timings +- gameprofilerfiller.pop(); Iterator iterator = entity.getPassengers().iterator(); -@@ -1277,12 +1244,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf. - // Paper end + while (iterator.hasNext()) { +@@ -1321,12 +1282,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe + if (passenger instanceof Player || this.entityTickList.contains(passenger)) { passenger.setOldPosAndRot(); ++passenger.tickCount; -- ProfilerFiller gameprofilerfiller = this.getProfiler(); +- ProfilerFiller gameprofilerfiller = Profiler.get(); - gameprofilerfiller.push(() -> { - return BuiltInRegistries.ENTITY_TYPE.getKey(passenger.getType()).toString(); @@ -1026,8 +1086,8 @@ index e20b7a1ad141834a10c5f23f9b27cc41fa25ac0d..9b2833fc9906dc6c0ac254adabc0f471 // Paper start - EAR 2 if (isActive) { passenger.rideTick(); -@@ -1294,7 +1256,6 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf. - vehicle.positionRider(passenger); +@@ -1338,7 +1294,6 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe + vehicle.positionRider(passenger); } // Paper end - EAR 2 - gameprofilerfiller.pop(); @@ -1035,79 +1095,97 @@ index e20b7a1ad141834a10c5f23f9b27cc41fa25ac0d..9b2833fc9906dc6c0ac254adabc0f471 while (iterator.hasNext()) { diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java -index c396580a9cfd86ff261bed439bb4662ae88010b5..adba25adaaf32c07e6844faec12bcab860eab194 100644 +index cffbd3300967e5d80b5973b35a76235bb2aa1b73..a0d940312e37d7b74df7103878ff547a45fc5c05 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java -@@ -1371,7 +1371,6 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple +@@ -102,8 +102,6 @@ import net.minecraft.tags.FluidTags; + import net.minecraft.util.Mth; + import net.minecraft.util.RandomSource; + import net.minecraft.util.Unit; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + import net.minecraft.world.damagesource.DamageSource; + import net.minecraft.world.damagesource.DamageTypes; + import net.minecraft.world.effect.MobEffectInstance; +@@ -1643,15 +1641,10 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple this.unsetRemoved(); */ // CraftBukkit end -- worldserver1.getProfiler().push("moving"); +- ProfilerFiller gameprofilerfiller = Profiler.get(); +- +- gameprofilerfiller.push("moving"); if (worldserver != null && resourcekey == LevelStem.OVERWORLD && worldserver.getTypeKey() == LevelStem.NETHER) { // CraftBukkit - empty to fall through to null to event this.enteredNetherPosition = this.position(); } -@@ -1387,8 +1386,6 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple - worldserver = ((CraftWorld) exit.getWorld()).getHandle(); - // CraftBukkit end -- worldserver1.getProfiler().pop(); -- worldserver1.getProfiler().push("placing"); +- gameprofilerfiller.pop(); +- gameprofilerfiller.push("placing"); // CraftBukkit start this.isChangingDimension = true; // CraftBukkit - Set teleport invulnerability only if player changing worlds LevelData worlddata = worldserver.getLevelData(); -@@ -1405,7 +1402,6 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple - this.connection.teleport(exit); // CraftBukkit - use internal teleport without event +@@ -1668,7 +1661,6 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple + this.connection.internalTeleport(PositionMoveRotation.of(teleportTarget), teleportTarget.relatives()); // CraftBukkit - use internal teleport without event this.connection.resetPosition(); worldserver.addDuringTeleport(this); -- worldserver1.getProfiler().pop(); +- gameprofilerfiller.pop(); this.triggerDimensionChangeTriggers(worldserver1); + this.stopUsingItem(); this.connection.send(new ClientboundPlayerAbilitiesPacket(this.getAbilities())); - playerlist.sendLevelInfo(this, worldserver); diff --git a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java -index 7174f8c89a7cdcf40ff28f6636ecfb23b13ccdaa..edbca98fb87abdd345ca14331e4121ef1ec41e50 100644 +index b0bc66dc7248aae691dcab68b925b52a1695e63f..d777e5914148103dbdbfef7c8e4f8e012fa58b6d 100644 --- a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java -@@ -248,7 +248,6 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack +@@ -30,7 +30,6 @@ import net.minecraft.server.MinecraftServer; + import net.minecraft.server.level.ClientInformation; + import net.minecraft.server.level.ServerPlayer; + import net.minecraft.util.VisibleForDebug; +-import net.minecraft.util.profiling.Profiler; + import net.minecraft.util.thread.BlockableEventLoop; + import org.slf4j.Logger; + +@@ -255,7 +254,6 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack } protected void keepConnectionAlive() { -- this.server.getProfiler().push("keepAlive"); +- Profiler.get().push("keepAlive"); // Paper start - give clients a longer time to respond to pings as per pre 1.12.2 timings // This should effectively place the keepalive handling back to "as it was" before 1.12.2 long currentTime = Util.getMillis(); -@@ -266,7 +265,6 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack +@@ -272,8 +270,6 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack + } } // Paper end - give clients a longer time to respond to pings as per pre 1.12.2 timings - -- this.server.getProfiler().pop(); +- +- Profiler.get().pop(); } private boolean checkIfClosed(long time) { -diff --git a/src/main/java/net/minecraft/server/packs/resources/PreparableReloadListener.java b/src/main/java/net/minecraft/server/packs/resources/PreparableReloadListener.java -index 60d33ac7ab7b610e9d5104ac9c7029ba4fc26cdf..55dc48bd8e32cd392a4d44e5c8b278c226782de0 100644 ---- a/src/main/java/net/minecraft/server/packs/resources/PreparableReloadListener.java -+++ b/src/main/java/net/minecraft/server/packs/resources/PreparableReloadListener.java -@@ -5,14 +5,18 @@ import java.util.concurrent.Executor; - import net.minecraft.util.profiling.ProfilerFiller; +diff --git a/src/main/java/net/minecraft/server/packs/resources/ProfiledReloadInstance.java b/src/main/java/net/minecraft/server/packs/resources/ProfiledReloadInstance.java +index 5a2b07340c63577f6d32c0658ce5f9b616c82f91..cac2ac26242e6901080fc0a92684d2f4a11b0c47 100644 +--- a/src/main/java/net/minecraft/server/packs/resources/ProfiledReloadInstance.java ++++ b/src/main/java/net/minecraft/server/packs/resources/ProfiledReloadInstance.java +@@ -9,8 +9,6 @@ import java.util.concurrent.TimeUnit; + import java.util.concurrent.atomic.AtomicLong; + import net.minecraft.Util; + import net.minecraft.util.Unit; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + import org.slf4j.Logger; - public interface PreparableReloadListener { -+ // Gale start - Purpur - remove vanilla profiler -+ default CompletableFuture reload(PreparableReloadListener.PreparationBarrier synchronizer, ResourceManager manager, ProfilerFiller prepareProfiler, ProfilerFiller applyProfiler, Executor prepareExecutor, Executor applyExecutor) { -+ return this.reload(synchronizer, manager, prepareExecutor, applyExecutor); -+ } -+ - CompletableFuture reload( - PreparableReloadListener.PreparationBarrier synchronizer, - ResourceManager manager, -- ProfilerFiller prepareProfiler, -- ProfilerFiller applyProfiler, - Executor prepareExecutor, - Executor applyExecutor - ); -+ // Gale end - Purpur - remove vanilla profiler + public class ProfiledReloadInstance extends SimpleReloadInstance { +@@ -51,12 +49,9 @@ public class ProfiledReloadInstance extends SimpleReloadInstance executor.execute(() -> { +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push(string); + long l = Util.getNanos(); + runnable.run(); + atomicLong.addAndGet(Util.getNanos() - l); +- profilerFiller.pop(); + }); + } - default String getName() { - return this.getClass().getSimpleName(); diff --git a/src/main/java/net/minecraft/server/packs/resources/ReloadableResourceManager.java b/src/main/java/net/minecraft/server/packs/resources/ReloadableResourceManager.java index f0257e295d9e856391b8e881370610c06fab9fba..7b327b59374474f68b189cefbf97d4a4b4478472 100644 --- a/src/main/java/net/minecraft/server/packs/resources/ReloadableResourceManager.java @@ -1122,337 +1200,356 @@ index f0257e295d9e856391b8e881370610c06fab9fba..7b327b59374474f68b189cefbf97d4a4 @Override diff --git a/src/main/java/net/minecraft/server/packs/resources/ResourceManagerReloadListener.java b/src/main/java/net/minecraft/server/packs/resources/ResourceManagerReloadListener.java -index f14113eef226e906c0d21641e74a27471254909d..649e8a76e8964786ddb91bd69dd10ddb641ac547 100644 +index d2d82e4f22bfeac8881b6815e4bef56c254fded9..fd5d678dd2d514ab7b60c4378e05182be38f52c4 100644 --- a/src/main/java/net/minecraft/server/packs/resources/ResourceManagerReloadListener.java +++ b/src/main/java/net/minecraft/server/packs/resources/ResourceManagerReloadListener.java -@@ -3,26 +3,19 @@ package net.minecraft.server.packs.resources; +@@ -3,20 +3,13 @@ package net.minecraft.server.packs.resources; import java.util.concurrent.CompletableFuture; import java.util.concurrent.Executor; import net.minecraft.util.Unit; +-import net.minecraft.util.profiling.Profiler; -import net.minecraft.util.profiling.ProfilerFiller; public interface ResourceManagerReloadListener extends PreparableReloadListener { -+ // Gale start - Purpur - remove vanilla profiler @Override default CompletableFuture reload( - PreparableReloadListener.PreparationBarrier synchronizer, - ResourceManager manager, -- ProfilerFiller prepareProfiler, -- ProfilerFiller applyProfiler, - Executor prepareExecutor, - Executor applyExecutor + PreparableReloadListener.PreparationBarrier synchronizer, ResourceManager manager, Executor prepareExecutor, Executor applyExecutor ) { - return synchronizer.wait(Unit.INSTANCE).thenRunAsync(() -> { -- applyProfiler.startTick(); -- applyProfiler.push("listener"); +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push("listener"); - this.onResourceManagerReload(manager); -- applyProfiler.pop(); -- applyProfiler.endTick(); +- profilerFiller.pop(); - }, applyExecutor); -+ return synchronizer.wait(Unit.INSTANCE).thenRunAsync(() -> this.onResourceManagerReload(manager), applyExecutor); ++ return synchronizer.wait(Unit.INSTANCE).thenRunAsync(() -> this.onResourceManagerReload(manager), applyExecutor); // Gale - Purpur - remove vanilla profiler } -+ // Gale end - Purpur - remove vanilla profiler void onResourceManagerReload(ResourceManager manager); - } diff --git a/src/main/java/net/minecraft/server/packs/resources/SimplePreparableReloadListener.java b/src/main/java/net/minecraft/server/packs/resources/SimplePreparableReloadListener.java -index 298e3eddd600f0b2e48ce2d4080cf68adff59a3a..6b3c57fc1231cd37e17a58137bb78411e4018c83 100644 +index 0aaab6a2a10bf012c9d275f7cee2095c8fbb8809..0d8f20035e051af8143dea154593f8a6fc3235f2 100644 --- a/src/main/java/net/minecraft/server/packs/resources/SimplePreparableReloadListener.java +++ b/src/main/java/net/minecraft/server/packs/resources/SimplePreparableReloadListener.java -@@ -2,6 +2,7 @@ package net.minecraft.server.packs.resources; +@@ -2,7 +2,8 @@ package net.minecraft.server.packs.resources; import java.util.concurrent.CompletableFuture; import java.util.concurrent.Executor; +-import net.minecraft.util.profiling.Profiler; ++ +import net.minecraft.util.profiling.InactiveProfiler; import net.minecraft.util.profiling.ProfilerFiller; public abstract class SimplePreparableReloadListener implements PreparableReloadListener { -@@ -9,14 +10,12 @@ public abstract class SimplePreparableReloadListener implements PreparableRel +@@ -10,9 +11,9 @@ public abstract class SimplePreparableReloadListener implements PreparableRel public final CompletableFuture reload( - PreparableReloadListener.PreparationBarrier synchronizer, - ResourceManager manager, -- ProfilerFiller prepareProfiler, -- ProfilerFiller applyProfiler, - Executor prepareExecutor, - Executor applyExecutor + PreparableReloadListener.PreparationBarrier synchronizer, ResourceManager manager, Executor prepareExecutor, Executor applyExecutor ) { -- return CompletableFuture.supplyAsync(() -> this.prepare(manager, prepareProfiler), prepareExecutor) +- return CompletableFuture.supplyAsync(() -> this.prepare(manager, Profiler.get()), prepareExecutor) + return CompletableFuture.supplyAsync(() -> this.prepare(manager, InactiveProfiler.INSTANCE), prepareExecutor) // Gale - Purpur - remove vanilla profiler .thenCompose(synchronizer::wait) -- .thenAcceptAsync(prepared -> this.apply((T)prepared, manager, applyProfiler), applyExecutor); +- .thenAcceptAsync(prepared -> this.apply((T)prepared, manager, Profiler.get()), applyExecutor); + .thenAcceptAsync(prepared -> this.apply((T)prepared, manager, InactiveProfiler.INSTANCE), applyExecutor); // Gale - Purpur - remove vanilla profiler } protected abstract T prepare(ResourceManager manager, ProfilerFiller profiler); -diff --git a/src/main/java/net/minecraft/tags/TagManager.java b/src/main/java/net/minecraft/tags/TagManager.java -index 2188274de5d1fe1aa5419be6247da6a3a2414a3b..3c60eb7a77eb302d0402dfa599a88cae80d6346d 100644 ---- a/src/main/java/net/minecraft/tags/TagManager.java -+++ b/src/main/java/net/minecraft/tags/TagManager.java -@@ -32,8 +32,6 @@ public class TagManager implements PreparableReloadListener { - public CompletableFuture reload( - PreparableReloadListener.PreparationBarrier synchronizer, - ResourceManager manager, -- ProfilerFiller prepareProfiler, -- ProfilerFiller applyProfiler, - Executor prepareExecutor, - Executor applyExecutor - ) { diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 4b54d0ea31062972e68ee8fafe3cfaf68f65a5cd..1d997cf3ef35ec428477d57d3b03fc57bca36407 100644 +index 341c324d15996a74b113f8879d7da737a1be86a1..ca4ce69ecad2291d196c4126e4cbde69554dd50c 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -858,7 +858,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -84,8 +84,6 @@ import net.minecraft.tags.FluidTags; + import net.minecraft.tags.TagKey; + import net.minecraft.util.Mth; + import net.minecraft.util.RandomSource; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + import net.minecraft.world.InteractionHand; + import net.minecraft.world.InteractionResult; + import net.minecraft.world.Nameable; +@@ -924,9 +922,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess // CraftBukkit end public void baseTick() { -- this.level().getProfiler().push("entityBaseTick"); +- ProfilerFiller gameprofilerfiller = Profiler.get(); +- +- gameprofilerfiller.push("entityBaseTick"); if (firstTick && this instanceof net.minecraft.world.entity.NeutralMob neutralMob) neutralMob.tickInitialPersistentAnger(level); // Paper - Prevent entity loading causing async lookups this.inBlockState = null; if (this.isPassenger() && this.getVehicle().isRemoved()) { -@@ -922,8 +921,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess - if (!this.level().isClientSide && this instanceof Leashable) { - Leashable.tickLeash((Entity & Leashable) this); // CraftBukkit - decompile error +@@ -994,8 +989,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess + Leashable.tickLeash(worldserver, (Entity & Leashable) this); // CraftBukkit - decompile error + } } - -- this.level().getProfiler().pop(); +- gameprofilerfiller.pop(); } public void setSharedFlagOnFire(boolean onFire) { -@@ -1138,7 +1135,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -1221,9 +1214,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess } } -- this.level().getProfiler().push("move"); +- ProfilerFiller gameprofilerfiller = Profiler.get(); +- +- gameprofilerfiller.push("move"); if (this.stuckSpeedMultiplier.lengthSqr() > 1.0E-7D) { movement = movement.multiply(this.stuckSpeedMultiplier); this.stuckSpeedMultiplier = Vec3.ZERO; -@@ -1147,7 +1143,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -1232,7 +1222,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess // Paper start - ignore movement changes while inactive. - if (isTemporarilyActive && !(this instanceof ItemEntity) && movement == getDeltaMovement() && movementType == MoverType.SELF) { + if (isTemporarilyActive && !(this instanceof ItemEntity) && movement == getDeltaMovement() && type == MoverType.SELF) { setDeltaMovement(Vec3.ZERO); -- this.level.getProfiler().pop(); +- gameprofilerfiller.pop(); return; } // Paper end -@@ -1168,8 +1163,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -1253,8 +1242,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess this.setPos(this.getX() + vec3d1.x, this.getY() + vec3d1.y, this.getZ() + vec3d1.z); } -- this.level().getProfiler().pop(); -- this.level().getProfiler().push("rest"); +- gameprofilerfiller.pop(); +- gameprofilerfiller.push("rest"); boolean flag = !Mth.equal(movement.x, vec3d1.x); boolean flag1 = !Mth.equal(movement.z, vec3d1.z); -@@ -1187,9 +1180,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess - BlockState iblockdata = this.level().getBlockState(blockposition); +@@ -1276,7 +1263,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess + } - this.checkFallDamage(vec3d1.y, this.onGround(), iblockdata, blockposition); -- if (this.isRemoved()) { -- this.level().getProfiler().pop(); -- } else { -+ if (!this.isRemoved()) { + if (this.isRemoved()) { +- gameprofilerfiller.pop(); + } else { if (this.horizontalCollision) { Vec3 vec3d2 = this.getDeltaMovement(); +@@ -1325,7 +1311,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess + float f = this.getBlockSpeedFactor(); -@@ -1290,8 +1281,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess - if (this.isOnFire() && (this.isInPowderSnow || this.isInWaterRainOrBubble())) { - this.setRemainingFireTicks(-this.getFireImmuneTicks()); - } -- -- this.level().getProfiler().pop(); + this.setDeltaMovement(this.getDeltaMovement().multiply((double) f, 1.0D, (double) f)); +- gameprofilerfiller.pop(); } } // Paper start - detailed watchdog information -@@ -3264,7 +3253,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -3471,9 +3456,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess this.processPortalCooldown(); if (this.portalProcess != null) { if (this.portalProcess.processPortalTeleportation(worldserver, this, this.canUsePortal(false))) { -- worldserver.getProfiler().push("portal"); +- ProfilerFiller gameprofilerfiller = Profiler.get(); +- +- gameprofilerfiller.push("portal"); this.setPortalCooldown(); - DimensionTransition dimensiontransition = this.portalProcess.getPortalDestination(worldserver, this); + TeleportTransition teleporttransition = this.portalProcess.getPortalDestination(worldserver, this); -@@ -3276,7 +3264,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -3484,8 +3466,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess + this.teleport(teleporttransition); } } - -- worldserver.getProfiler().pop(); +- +- gameprofilerfiller.pop(); } else if (this.portalProcess.hasExpired()) { this.portalProcess = null; } -@@ -3779,7 +3766,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess - } - } +@@ -4007,16 +3987,12 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess + entity.teleport(this.calculatePassengerTransition(teleportTarget, entity)); + } -- worldserver.getProfiler().push("changeDimension"); - Entity entity2 = worldserver1.dimension() == worldserver.dimension() ? this : this.getType().create(worldserver1); +- ProfilerFiller gameprofilerfiller = Profiler.get(); +- +- gameprofilerfiller.push("teleportSameDimension"); + this.teleportSetPosition(PositionMoveRotation.of(teleportTarget), teleportTarget.relatives()); + if (!teleportTarget.asPassenger()) { + this.sendTeleportTransitionToRidingPlayers(teleportTarget); + } - if (entity2 != null) { -@@ -3815,7 +3801,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess - teleportTarget.postDimensionTransition().onTransition(entity2); - } + teleportTarget.postTeleportTransition().onTransition(this); +- gameprofilerfiller.pop(); + return this; + } -- worldserver.getProfiler().pop(); - return entity2; +@@ -4038,12 +4014,8 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess } } + +- ProfilerFiller gameprofilerfiller = Profiler.get(); +- +- gameprofilerfiller.push("teleportCrossDimension"); + entity = this.getType().create(world, EntitySpawnReason.DIMENSION_TRAVEL); + if (entity == null) { +- gameprofilerfiller.pop(); + return null; + } else { + // Paper start - Fix item duplication and teleport issues +@@ -4069,7 +4041,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess + + world.resetEmptyTime(); + teleportTarget.postTeleportTransition().onTransition(entity); +- gameprofilerfiller.pop(); + return entity; + } + } diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index 2aa6374cd4a96efd85899be8cd3172a8257bfe6b..2994230ba5252b6af4d54a351d78536c07e0a48e 100644 +index 9c61225a728a2ca91a1c71dead75fc7cd93668b6..74ee200081f372e66e1d2a5a291fff42758ba965 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -440,7 +440,6 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -73,8 +73,6 @@ import net.minecraft.tags.FluidTags; + import net.minecraft.tags.ItemTags; + import net.minecraft.tags.TagKey; + import net.minecraft.util.Mth; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + import net.minecraft.world.Difficulty; + import net.minecraft.world.InteractionHand; + import net.minecraft.world.damagesource.CombatRules; +@@ -452,9 +450,7 @@ public abstract class LivingEntity extends Entity implements Attackable { } super.baseTick(); -- this.level().getProfiler().push("livingEntityBaseTick"); +- ProfilerFiller gameprofilerfiller = Profiler.get(); + +- gameprofilerfiller.push("livingEntityBaseTick"); if (this.fireImmune() || this.level().isClientSide) { this.clearFire(); } -@@ -545,7 +544,6 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -561,7 +557,6 @@ public abstract class LivingEntity extends Entity implements Attackable { this.yHeadRotO = this.yHeadRot; this.yRotO = this.getYRot(); this.xRotO = this.getXRot(); -- this.level().getProfiler().pop(); +- gameprofilerfiller.pop(); } @Override -@@ -3205,10 +3203,7 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -3315,12 +3310,8 @@ public abstract class LivingEntity extends Entity implements Attackable { } this.run += (f3 - this.run) * 0.3F; -- this.level().getProfiler().push("headTurn"); +- ProfilerFiller gameprofilerfiller = Profiler.get(); + +- gameprofilerfiller.push("headTurn"); f2 = this.tickHeadTurn(f1, f2); -- this.level().getProfiler().pop(); -- this.level().getProfiler().push("rangeChecks"); +- gameprofilerfiller.pop(); +- gameprofilerfiller.push("rangeChecks"); // Paper start - stop large pitch and yaw changes from crashing the server this.yRotO += Math.round((this.getYRot() - this.yRotO) / 360.0F) * 360.0F; -@@ -3220,7 +3215,6 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -3332,7 +3323,6 @@ public abstract class LivingEntity extends Entity implements Attackable { this.yHeadRotO += Math.round((this.yHeadRot - this.yHeadRotO) / 360.0F) * 360.0F; // Paper end -- this.level().getProfiler().pop(); +- gameprofilerfiller.pop(); this.animStep += f2; if (this.isFallFlying()) { ++this.fallFlyTicks; -@@ -3460,19 +3454,14 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -3562,21 +3552,15 @@ public abstract class LivingEntity extends Entity implements Attackable { } this.setDeltaMovement(d0, d1, d2); -- this.level().getProfiler().push("ai"); +- ProfilerFiller gameprofilerfiller = Profiler.get(); + +- gameprofilerfiller.push("ai"); if (this.isImmobile()) { this.jumping = false; this.xxa = 0.0F; this.zza = 0.0F; } else if (this.isEffectiveAi()) { -- this.level().getProfiler().push("newAi"); +- gameprofilerfiller.push("newAi"); this.serverAiStep(); -- this.level().getProfiler().pop(); +- gameprofilerfiller.pop(); } -- this.level().getProfiler().pop(); -- this.level().getProfiler().push("jump"); +- gameprofilerfiller.pop(); +- gameprofilerfiller.push("jump"); if (this.jumping && this.isAffectedByFluids()) { double d3; -@@ -3499,8 +3488,6 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -3603,8 +3587,6 @@ public abstract class LivingEntity extends Entity implements Attackable { this.noJumpDelay = 0; } -- this.level().getProfiler().pop(); -- this.level().getProfiler().push("travel"); +- gameprofilerfiller.pop(); +- gameprofilerfiller.push("travel"); this.xxa *= 0.98F; this.zza *= 0.98F; - this.updateFallFlying(); -@@ -3525,8 +3512,6 @@ public abstract class LivingEntity extends Entity implements Attackable { - this.travel(vec3d1); + if (this.isFallFlying()) { +@@ -3637,8 +3619,6 @@ public abstract class LivingEntity extends Entity implements Attackable { } -- this.level().getProfiler().pop(); -- this.level().getProfiler().push("freezing"); + this.calculateEntityAnimation(this instanceof FlyingAnimal); +- gameprofilerfiller.pop(); +- gameprofilerfiller.push("freezing"); if (!this.level().isClientSide && !this.isDeadOrDying() && !this.freezeLocked) { // Paper - Freeze Tick Lock API int i = this.getTicksFrozen(); -@@ -3543,15 +3528,12 @@ public abstract class LivingEntity extends Entity implements Attackable { - this.hurt(this.damageSources().freeze(), 1.0F); +@@ -3659,15 +3639,13 @@ public abstract class LivingEntity extends Entity implements Attackable { + } } -- this.level().getProfiler().pop(); -- this.level().getProfiler().push("push"); +- gameprofilerfiller.pop(); +- gameprofilerfiller.push("push"); if (this.autoSpinAttackTicks > 0) { --this.autoSpinAttackTicks; this.checkAutoSpinAttack(axisalignedbb, this.getBoundingBox()); } this.pushEntities(); -- this.level().getProfiler().pop(); +- gameprofilerfiller.pop(); ++ // Paper start - Add EntityMoveEvent if (((ServerLevel) this.level()).hasEntityMoveEvent && !(this instanceof net.minecraft.world.entity.player.Player)) { if (this.xo != this.getX() || this.yo != this.getY() || this.zo != this.getZ() || this.yRotO != this.getYRot() || this.xRotO != this.getXRot()) { diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java -index 763abeea3f14f15c27d600e0bdae44b387687bb4..427e2711b942a61b491b2fe9fc1d02e67d446ad0 100644 +index dbd321f3dc3cc80737830db63aed47a6935e8e89..3ccc39e142f946e3fc34753fdc91a2cb62f9bd2d 100644 --- a/src/main/java/net/minecraft/world/entity/Mob.java +++ b/src/main/java/net/minecraft/world/entity/Mob.java -@@ -34,7 +34,6 @@ import net.minecraft.sounds.SoundEvent; +@@ -34,8 +34,6 @@ import net.minecraft.sounds.SoundEvent; import net.minecraft.tags.TagKey; import net.minecraft.util.Mth; import net.minecraft.util.RandomSource; +-import net.minecraft.util.profiling.Profiler; -import net.minecraft.util.profiling.ProfilerFiller; import net.minecraft.world.Difficulty; import net.minecraft.world.DifficultyInstance; import net.minecraft.world.InteractionHand; -@@ -158,8 +157,10 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab - this.pathfindingMalus = Maps.newEnumMap(PathType.class); - this.restrictCenter = BlockPos.ZERO; - this.restrictRadius = -1.0F; -- this.goalSelector = new GoalSelector(world.getProfilerSupplier()); -- this.targetSelector = new GoalSelector(world.getProfilerSupplier()); -+ // Gale start - Purpur - remove vanilla profiler -+ this.goalSelector = new GoalSelector(); -+ this.targetSelector = new GoalSelector(); -+ // Gale end - Purpur - remove vanilla profiler - this.lookControl = new LookControl(this); - this.moveControl = new MoveControl(this); - this.jumpControl = new JumpControl(this); -@@ -366,13 +367,10 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab +@@ -369,15 +367,11 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab @Override public void baseTick() { super.baseTick(); -- this.level().getProfiler().push("mobBaseTick"); +- ProfilerFiller gameprofilerfiller = Profiler.get(); + +- gameprofilerfiller.push("mobBaseTick"); if (this.isAlive() && this.random.nextInt(1000) < this.ambientSoundTime++) { this.resetAmbientSoundTime(); this.playAmbientSound(); } - -- this.level().getProfiler().pop(); +- gameprofilerfiller.pop(); } @Override -@@ -676,7 +674,6 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab +@@ -670,9 +664,7 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab @Override public void aiStep() { super.aiStep(); -- this.level().getProfiler().push("looting"); - if (!this.level().isClientSide && this.canPickUpLoot() && this.isAlive() && !this.dead && this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { - Vec3i baseblockposition = this.getPickupReach(); - List list = this.level().getEntitiesOfClass(ItemEntity.class, this.getBoundingBox().inflate((double) baseblockposition.getX(), (double) baseblockposition.getY(), (double) baseblockposition.getZ())); -@@ -695,8 +692,6 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab +- ProfilerFiller gameprofilerfiller = Profiler.get(); + +- gameprofilerfiller.push("looting"); + Level world = this.level(); + + if (world instanceof ServerLevel worldserver) { +@@ -695,8 +687,6 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab } } } - -- this.level().getProfiler().pop(); +- gameprofilerfiller.pop(); } protected Vec3i getPickupReach() { -@@ -920,44 +915,23 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab +@@ -918,44 +908,24 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab return; } // Paper end - Allow nerfed mobs to jump and float -- ProfilerFiller gameprofilerfiller = this.level().getProfiler(); +- ProfilerFiller gameprofilerfiller = Profiler.get(); - gameprofilerfiller.push("sensing"); this.sensing.tick(); - gameprofilerfiller.pop(); ++ int i = this.tickCount + this.getId(); if (i % 2 != 0 && this.tickCount > 1) { @@ -1475,7 +1572,7 @@ index 763abeea3f14f15c27d600e0bdae44b387687bb4..427e2711b942a61b491b2fe9fc1d02e6 this.navigation.tick(); - gameprofilerfiller.pop(); - gameprofilerfiller.push("mob tick"); - this.customServerAiStep(); + this.customServerAiStep((ServerLevel) this.level()); - gameprofilerfiller.pop(); - gameprofilerfiller.push("controls"); - gameprofilerfiller.push("move"); @@ -1490,44 +1587,29 @@ index 763abeea3f14f15c27d600e0bdae44b387687bb4..427e2711b942a61b491b2fe9fc1d02e6 } diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java b/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java -index 9bdbf3e9453bc3ce96d52d04b8cde0d05f7356d8..6fd5f65d8fb8830e000af6556c4009befa65b66f 100644 +index 29ae74339a4831ccef3d01e8054931715ba192ad..7ac88cb8704f84f1d932dff0fee927dfab8cad6a 100644 --- a/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java +++ b/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java -@@ -8,7 +8,6 @@ import java.util.Map; +@@ -7,8 +7,6 @@ import java.util.EnumSet; + import java.util.Map; import java.util.Set; import java.util.function.Predicate; - import java.util.function.Supplier; +-import net.minecraft.util.profiling.Profiler; -import net.minecraft.util.profiling.ProfilerFiller; public class GoalSelector { private static final WrappedGoal NO_GOAL = new WrappedGoal(Integer.MAX_VALUE, new Goal() { -@@ -24,14 +23,11 @@ public class GoalSelector { - }; - private final Map lockedFlags = new EnumMap<>(Goal.Flag.class); - private final Set availableGoals = new ObjectLinkedOpenHashSet<>(); -- private final Supplier profiler; - private static final Goal.Flag[] GOAL_FLAG_VALUES = Goal.Flag.values(); // Paper - remove streams from pathfindergoalselector - private final ca.spottedleaf.moonrise.common.set.OptimizedSmallEnumSet goalTypes = new ca.spottedleaf.moonrise.common.set.OptimizedSmallEnumSet<>(Goal.Flag.class); // Paper - remove streams from pathfindergoalselector - private int curRate; - -- public GoalSelector(Supplier profiler) { -- this.profiler = profiler; -- } -+ public GoalSelector() {} // Gale - Purpur - remove vanilla profiler - - public void addGoal(int priority, Goal goal) { - this.availableGoals.add(new WrappedGoal(priority, goal)); -@@ -87,9 +83,6 @@ public class GoalSelector { +@@ -82,9 +80,6 @@ public class GoalSelector { } public void tick() { -- ProfilerFiller profilerFiller = this.profiler.get(); +- ProfilerFiller profilerFiller = Profiler.get(); - profilerFiller.push("goalCleanup"); - for (WrappedGoal wrappedGoal : this.availableGoals) { if (wrappedGoal.isRunning() && (goalContainsAnyFlags(wrappedGoal, this.goalTypes) || !wrappedGoal.canContinueToUse())) { // Paper - Perf: optimize goal types by removing streams wrappedGoal.stop(); -@@ -97,8 +90,6 @@ public class GoalSelector { +@@ -92,8 +87,6 @@ public class GoalSelector { } this.lockedFlags.entrySet().removeIf(entry -> !entry.getValue().isRunning()); @@ -1536,7 +1618,7 @@ index 9bdbf3e9453bc3ce96d52d04b8cde0d05f7356d8..6fd5f65d8fb8830e000af6556c4009be for (WrappedGoal wrappedGoal2 : this.availableGoals) { // Paper start -@@ -118,21 +109,15 @@ public class GoalSelector { +@@ -113,21 +106,15 @@ public class GoalSelector { } } @@ -1545,7 +1627,7 @@ index 9bdbf3e9453bc3ce96d52d04b8cde0d05f7356d8..6fd5f65d8fb8830e000af6556c4009be } public void tickRunningGoals(boolean tickAll) { -- ProfilerFiller profilerFiller = this.profiler.get(); +- ProfilerFiller profilerFiller = Profiler.get(); - profilerFiller.push("goalTick"); - for (WrappedGoal wrappedGoal : this.availableGoals) { @@ -1559,445 +1641,616 @@ index 9bdbf3e9453bc3ce96d52d04b8cde0d05f7356d8..6fd5f65d8fb8830e000af6556c4009be public Set getAvailableGoals() { diff --git a/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java b/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java -index 2e9991e6b3c05584002744a2ee2579b1dba218b2..aea01c46bf59ed811356180436fc0789e354d981 100644 +index 48c0de870a5bbf647309e69361dfb10ab56c65ab..79342566ae54b5a8ccd8cab01b8282fada5b7bab 100644 --- a/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java +++ b/src/main/java/net/minecraft/world/entity/ai/navigation/PathNavigation.java -@@ -172,12 +172,10 @@ public abstract class PathNavigation { +@@ -10,8 +10,6 @@ import net.minecraft.core.Vec3i; + import net.minecraft.network.protocol.game.DebugPackets; + import net.minecraft.tags.BlockTags; + import net.minecraft.util.Mth; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + import net.minecraft.world.entity.Entity; + import net.minecraft.world.entity.Mob; + import net.minecraft.world.entity.ai.attributes.Attributes; +@@ -188,13 +186,10 @@ public abstract class PathNavigation { } } // Paper end - EntityPathfindEvent -- this.level.getProfiler().push("pathfind"); +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push("pathfind"); BlockPos blockPos = useHeadPos ? this.mob.blockPosition().above() : this.mob.blockPosition(); int i = (int)(followRange + (float)range); PathNavigationRegion pathNavigationRegion = new PathNavigationRegion(this.level, blockPos.offset(-i, -i, -i), blockPos.offset(i, i, i)); Path path = this.pathFinder.findPath(pathNavigationRegion, this.mob, positions, followRange, distance, this.maxVisitedNodesMultiplier); -- this.level.getProfiler().pop(); +- profilerFiller.pop(); if (path != null && path.getTarget() != null) { this.targetPos = path.getTarget(); this.reachRange = distance; 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 51772f03a3469b11e7166ec6f3a1b9c64a606221..ed440b9a84ac0e4619c075491515fa072d6aebec 100644 +index 116b1e251ffe68bae5c404d0823c2bc7c1afddf6..ed440b9a84ac0e4619c075491515fa072d6aebec 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 -@@ -26,9 +26,7 @@ public class Sensing { +@@ -2,8 +2,6 @@ package net.minecraft.world.entity.ai.sensing; + + import it.unimi.dsi.fastutil.ints.IntOpenHashSet; + import it.unimi.dsi.fastutil.ints.IntSet; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + import net.minecraft.world.entity.Entity; + import net.minecraft.world.entity.Mob; + +@@ -28,10 +26,7 @@ public class Sensing { } else if (this.unseen.contains(i)) { return false; } else { -- this.mob.level().getProfiler().push("hasLineOfSight"); +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push("hasLineOfSight"); boolean bl = this.mob.hasLineOfSight(entity); -- this.mob.level().getProfiler().pop(); +- profilerFiller.pop(); if (bl) { this.seen.add(i); } else { diff --git a/src/main/java/net/minecraft/world/entity/animal/allay/Allay.java b/src/main/java/net/minecraft/world/entity/animal/allay/Allay.java -index 69986f75d3cf729204cca0c7e5428536af31f695..a6b8c6540886af41ef1bccbd76784fe327e8277b 100644 +index 05c3d43fafc781e2c2d762dd5f509753df8da3b3..3a89c8bb4fbbe5a3a219e2fbc823c3abe529d1f2 100644 --- a/src/main/java/net/minecraft/world/entity/animal/allay/Allay.java +++ b/src/main/java/net/minecraft/world/entity/animal/allay/Allay.java -@@ -219,12 +219,8 @@ public class Allay extends PathfinderMob implements InventoryCarrier, VibrationS +@@ -31,8 +31,6 @@ import net.minecraft.tags.GameEventTags; + import net.minecraft.tags.ItemTags; + import net.minecraft.tags.TagKey; + import net.minecraft.util.Mth; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + import net.minecraft.world.InteractionHand; + import net.minecraft.world.InteractionResult; + import net.minecraft.world.SimpleContainer; +@@ -221,14 +219,8 @@ public class Allay extends PathfinderMob implements InventoryCarrier, VibrationS @Override - protected void customServerAiStep() { -- this.level().getProfiler().push("allayBrain"); - this.getBrain().tick((ServerLevel) this.level(), this); -- this.level().getProfiler().pop(); -- this.level().getProfiler().push("allayActivityUpdate"); + protected void customServerAiStep(ServerLevel world) { +- ProfilerFiller gameprofilerfiller = Profiler.get(); +- +- gameprofilerfiller.push("allayBrain"); + this.getBrain().tick(world, this); +- gameprofilerfiller.pop(); +- gameprofilerfiller.push("allayActivityUpdate"); AllayAi.updateActivity(this); -- this.level().getProfiler().pop(); - super.customServerAiStep(); +- gameprofilerfiller.pop(); + super.customServerAiStep(world); } diff --git a/src/main/java/net/minecraft/world/entity/animal/armadillo/Armadillo.java b/src/main/java/net/minecraft/world/entity/animal/armadillo/Armadillo.java -index 729fd2d52dd48e25ee7a077a3ffafc80ecef7c9f..8ed9c15e90889a056382092c64eae406e5603ec0 100644 +index c1ef714096159608752d744b98f615cd45fe459a..844a5a61428234adcc12e7e8af8f2781a4ad4be8 100644 --- a/src/main/java/net/minecraft/world/entity/animal/armadillo/Armadillo.java +++ b/src/main/java/net/minecraft/world/entity/animal/armadillo/Armadillo.java -@@ -135,12 +135,8 @@ public class Armadillo extends Animal { +@@ -23,8 +23,6 @@ import net.minecraft.util.ByIdMap; + import net.minecraft.util.RandomSource; + import net.minecraft.util.StringRepresentable; + import net.minecraft.util.TimeUtil; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + import net.minecraft.world.InteractionHand; + import net.minecraft.world.InteractionResult; + import net.minecraft.world.damagesource.DamageSource; +@@ -135,14 +133,8 @@ public class Armadillo extends Animal { @Override - protected void customServerAiStep() { -- this.level().getProfiler().push("armadilloBrain"); - ((Brain) this.brain).tick((ServerLevel) this.level(), this); // CraftBukkit - decompile error -- this.level().getProfiler().pop(); -- this.level().getProfiler().push("armadilloActivityUpdate"); + protected void customServerAiStep(ServerLevel world) { +- ProfilerFiller gameprofilerfiller = Profiler.get(); +- +- gameprofilerfiller.push("armadilloBrain"); + ((Brain) this.brain).tick(world, this); // CraftBukkit - decompile error +- gameprofilerfiller.pop(); +- gameprofilerfiller.push("armadilloActivityUpdate"); ArmadilloAi.updateActivity(this); -- this.level().getProfiler().pop(); +- gameprofilerfiller.pop(); if (this.isAlive() && !this.isBaby() && --this.scuteTime <= 0) { - this.playSound(SoundEvents.ARMADILLO_SCUTE_DROP, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F); this.forceDrops = true; // CraftBukkit + if (this.dropFromGiftLootTable(world, BuiltInLootTables.ARMADILLO_SHED, this::spawnAtLocation)) { diff --git a/src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java b/src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java -index 01a0731e92d39c8718538244e34a271fb8717fc2..1147bf32f6efe02e51c838eb371f11c6430a80a9 100644 +index 31b10cd404b672d7ce21c2107d8f83e32de26ef4..22dbc237498d765bc9a13f6c5924769122406c8a 100644 --- a/src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java +++ b/src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java -@@ -271,12 +271,8 @@ public class Axolotl extends Animal implements LerpingModel, VariantHolder, B @Override - protected void customServerAiStep() { -- this.level().getProfiler().push("axolotlBrain"); - this.getBrain().tick((ServerLevel) this.level(), this); -- this.level().getProfiler().pop(); -- this.level().getProfiler().push("axolotlActivityUpdate"); + protected void customServerAiStep(ServerLevel world) { +- ProfilerFiller gameprofilerfiller = Profiler.get(); +- +- gameprofilerfiller.push("axolotlBrain"); + this.getBrain().tick(world, this); +- gameprofilerfiller.pop(); +- gameprofilerfiller.push("axolotlActivityUpdate"); AxolotlAi.updateActivity(this); -- this.level().getProfiler().pop(); +- gameprofilerfiller.pop(); if (!this.isNoAi()) { Optional optional = this.getBrain().getMemory(MemoryModuleType.PLAY_DEAD_TICKS); diff --git a/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java b/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java -index 8941752e4600ccd11b3fa1147b2e414785589eed..c841a7c4d73a416d4722b4d409167ddba3304ae8 100644 +index f3c884ab9c09f04dd01cabf2ee9de3b5b620563d..002e8b5a7037e48a7d9bd84c321b152f40fe1fce 100644 --- a/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java +++ b/src/main/java/net/minecraft/world/entity/animal/camel/Camel.java -@@ -143,14 +143,10 @@ public class Camel extends AbstractHorse implements PlayerRideableJumping, Saddl +@@ -17,8 +17,6 @@ import net.minecraft.sounds.SoundSource; + import net.minecraft.tags.BlockTags; + import net.minecraft.tags.ItemTags; + import net.minecraft.util.Mth; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + import net.minecraft.world.DifficultyInstance; + import net.minecraft.world.InteractionHand; + import net.minecraft.world.InteractionResult; +@@ -143,16 +141,10 @@ public class Camel extends AbstractHorse { @Override - protected void customServerAiStep() { -- this.level().getProfiler().push("camelBrain"); + protected void customServerAiStep(ServerLevel world) { +- ProfilerFiller gameprofilerfiller = Profiler.get(); +- +- gameprofilerfiller.push("camelBrain"); Brain behaviorcontroller = (Brain) this.getBrain(); // CraftBukkit - decompile error - behaviorcontroller.tick((ServerLevel) this.level(), this); -- this.level().getProfiler().pop(); -- this.level().getProfiler().push("camelActivityUpdate"); + behaviorcontroller.tick(world, this); +- gameprofilerfiller.pop(); +- gameprofilerfiller.push("camelActivityUpdate"); CamelAi.updateActivity(this); -- this.level().getProfiler().pop(); - super.customServerAiStep(); +- gameprofilerfiller.pop(); + super.customServerAiStep(world); } diff --git a/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java b/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java -index 816977990639ec0559b652fc9666afd5046f0a5d..22b84f4d84ca749a2094627b4dd4f4718f60cc74 100644 +index 36846ba6b6c7494c745ebd8b221479a9d02ff318..1a71f1d094271b5ce798210562000f6d0160eaa6 100644 --- a/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java +++ b/src/main/java/net/minecraft/world/entity/animal/frog/Frog.java -@@ -183,12 +183,8 @@ public class Frog extends Animal implements VariantHolder> { +@@ -28,8 +28,6 @@ import net.minecraft.tags.ItemTags; + import net.minecraft.util.Mth; + import net.minecraft.util.RandomSource; + import net.minecraft.util.Unit; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + import net.minecraft.world.DifficultyInstance; + import net.minecraft.world.damagesource.DamageSource; + import net.minecraft.world.entity.AgeableMob; +@@ -186,13 +184,8 @@ public class Frog extends Animal implements VariantHolder> { @Override - protected void customServerAiStep() { -- this.level().getProfiler().push("frogBrain"); - this.getBrain().tick((ServerLevel)this.level(), this); -- this.level().getProfiler().pop(); -- this.level().getProfiler().push("frogActivityUpdate"); + protected void customServerAiStep(ServerLevel world) { +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push("frogBrain"); + this.getBrain().tick(world, this); +- profilerFiller.pop(); +- profilerFiller.push("frogActivityUpdate"); FrogAi.updateActivity(this); -- this.level().getProfiler().pop(); - super.customServerAiStep(); +- profilerFiller.pop(); + super.customServerAiStep(world); } diff --git a/src/main/java/net/minecraft/world/entity/animal/frog/Tadpole.java b/src/main/java/net/minecraft/world/entity/animal/frog/Tadpole.java -index 43046f4a0cff620834ac4647efdcde227185b2ff..ab27bfb8b5a036eb13e77c8baeaa47e86a9ed2d6 100644 +index 48ac8c3f6e00c3c2dc67b6c994be7c0ac6dfcf81..76ecf98d91a368cd223f09bb0c56a50320999735 100644 --- a/src/main/java/net/minecraft/world/entity/animal/frog/Tadpole.java +++ b/src/main/java/net/minecraft/world/entity/animal/frog/Tadpole.java -@@ -85,12 +85,8 @@ public class Tadpole extends AbstractFish { +@@ -12,8 +12,6 @@ import net.minecraft.server.level.ServerLevel; + import net.minecraft.sounds.SoundEvent; + import net.minecraft.sounds.SoundEvents; + import net.minecraft.tags.ItemTags; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + import net.minecraft.world.InteractionHand; + import net.minecraft.world.InteractionResult; + import net.minecraft.world.damagesource.DamageSource; +@@ -85,14 +83,8 @@ public class Tadpole extends AbstractFish { @Override - protected void customServerAiStep() { -- this.level().getProfiler().push("tadpoleBrain"); - this.getBrain().tick((ServerLevel) this.level(), this); -- this.level().getProfiler().pop(); -- this.level().getProfiler().push("tadpoleActivityUpdate"); + protected void customServerAiStep(ServerLevel world) { +- ProfilerFiller gameprofilerfiller = Profiler.get(); +- +- gameprofilerfiller.push("tadpoleBrain"); + this.getBrain().tick(world, this); +- gameprofilerfiller.pop(); +- gameprofilerfiller.push("tadpoleActivityUpdate"); TadpoleAi.updateActivity(this); -- this.level().getProfiler().pop(); - super.customServerAiStep(); +- gameprofilerfiller.pop(); + super.customServerAiStep(world); } diff --git a/src/main/java/net/minecraft/world/entity/animal/goat/Goat.java b/src/main/java/net/minecraft/world/entity/animal/goat/Goat.java -index 376bcbc189008464f4d518c1e07643431ba96306..a6b6dd1715f7cb278b66381cbb0dd9d7069ce6ed 100644 +index 76aca47d8638d5c37c57d3a59fa7f8ceaa5a53b4..f480ee1d0cde254d9621b85b4064771bdab2d3a3 100644 --- a/src/main/java/net/minecraft/world/entity/animal/goat/Goat.java +++ b/src/main/java/net/minecraft/world/entity/animal/goat/Goat.java -@@ -192,12 +192,8 @@ public class Goat extends Animal { +@@ -20,8 +20,6 @@ import net.minecraft.tags.ItemTags; + import net.minecraft.tags.TagKey; + import net.minecraft.util.Mth; + import net.minecraft.util.RandomSource; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + import net.minecraft.world.DifficultyInstance; + import net.minecraft.world.InteractionHand; + import net.minecraft.world.InteractionResult; +@@ -194,14 +192,8 @@ public class Goat extends Animal { @Override - protected void customServerAiStep() { -- this.level().getProfiler().push("goatBrain"); - this.getBrain().tick((ServerLevel) this.level(), this); -- this.level().getProfiler().pop(); -- this.level().getProfiler().push("goatActivityUpdate"); + protected void customServerAiStep(ServerLevel world) { +- ProfilerFiller gameprofilerfiller = Profiler.get(); +- +- gameprofilerfiller.push("goatBrain"); + this.getBrain().tick(world, this); +- gameprofilerfiller.pop(); +- gameprofilerfiller.push("goatActivityUpdate"); GoatAi.updateActivity(this); -- this.level().getProfiler().pop(); - super.customServerAiStep(); +- gameprofilerfiller.pop(); + super.customServerAiStep(world); } diff --git a/src/main/java/net/minecraft/world/entity/animal/sniffer/Sniffer.java b/src/main/java/net/minecraft/world/entity/animal/sniffer/Sniffer.java -index fadd341ff398886a4da102eefa1beb95a63bbd6d..fbc6474ce3960e6675dabaaedb6801d99ccdb1aa 100644 +index af2f6e690fc51d319b77d081466c2dc7a1d8fe19..b61b41f542bd52965a9fbd79644038c68e7dea98 100644 --- a/src/main/java/net/minecraft/world/entity/animal/sniffer/Sniffer.java +++ b/src/main/java/net/minecraft/world/entity/animal/sniffer/Sniffer.java -@@ -477,11 +477,8 @@ public class Sniffer extends Animal { +@@ -30,8 +30,6 @@ import net.minecraft.tags.BlockTags; + import net.minecraft.tags.ItemTags; + import net.minecraft.util.ByIdMap; + import net.minecraft.util.Mth; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + import net.minecraft.world.InteractionHand; + import net.minecraft.world.InteractionResult; + import net.minecraft.world.damagesource.DamageSource; +@@ -467,13 +465,8 @@ public class Sniffer extends Animal { @Override - protected void customServerAiStep() { -- this.level().getProfiler().push("snifferBrain"); - this.getBrain().tick((ServerLevel) this.level(), this); -- this.level().getProfiler().popPush("snifferActivityUpdate"); + protected void customServerAiStep(ServerLevel world) { +- ProfilerFiller gameprofilerfiller = Profiler.get(); +- +- gameprofilerfiller.push("snifferBrain"); + this.getBrain().tick(world, this); +- gameprofilerfiller.popPush("snifferActivityUpdate"); SnifferAi.updateActivity(this); -- this.level().getProfiler().pop(); - super.customServerAiStep(); +- gameprofilerfiller.pop(); + super.customServerAiStep(world); } diff --git a/src/main/java/net/minecraft/world/entity/monster/Zoglin.java b/src/main/java/net/minecraft/world/entity/monster/Zoglin.java -index aa458ede5bd645ebf524238179edb33f41bd683f..0d447c8a141a7d7fcaf9218571bf0513dd28269e 100644 +index 35b0c5c322864e2f5ae5a412296072f268adcd05..50b559a92b54c0be7624b1aebc70537573c58666 100644 --- a/src/main/java/net/minecraft/world/entity/monster/Zoglin.java +++ b/src/main/java/net/minecraft/world/entity/monster/Zoglin.java -@@ -233,9 +233,7 @@ public class Zoglin extends Monster implements Enemy, HoglinBase { +@@ -15,8 +15,6 @@ import net.minecraft.network.syncher.SynchedEntityData; + import net.minecraft.server.level.ServerLevel; + import net.minecraft.sounds.SoundEvent; + import net.minecraft.sounds.SoundEvents; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + import net.minecraft.util.valueproviders.UniformInt; + import net.minecraft.world.DifficultyInstance; + import net.minecraft.world.damagesource.DamageSource; +@@ -248,10 +246,7 @@ public class Zoglin extends Monster implements HoglinBase { @Override - protected void customServerAiStep() { -- this.level().getProfiler().push("zoglinBrain"); - this.getBrain().tick((ServerLevel)this.level(), this); -- this.level().getProfiler().pop(); + protected void customServerAiStep(ServerLevel world) { +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push("zoglinBrain"); + this.getBrain().tick(world, this); +- profilerFiller.pop(); this.updateActivity(); } diff --git a/src/main/java/net/minecraft/world/entity/monster/breeze/Breeze.java b/src/main/java/net/minecraft/world/entity/monster/breeze/Breeze.java -index ee9098f311b5db7251fcaf3ca199ae51ec1f2a2a..afe1e0518be486c7e3c3103fc66980b5c234c1ac 100644 +index a16fd9c4679e874ad2d499f3c00c2ddfd780a7a5..5214b332acce9ad4096776bb4f0d263ec70dbc7b 100644 --- a/src/main/java/net/minecraft/world/entity/monster/breeze/Breeze.java +++ b/src/main/java/net/minecraft/world/entity/monster/breeze/Breeze.java -@@ -228,11 +228,8 @@ public class Breeze extends Monster { +@@ -12,8 +12,6 @@ import net.minecraft.sounds.SoundEvent; + import net.minecraft.sounds.SoundEvents; + import net.minecraft.sounds.SoundSource; + import net.minecraft.tags.EntityTypeTags; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + import net.minecraft.world.damagesource.DamageSource; + import net.minecraft.world.entity.AnimationState; + import net.minecraft.world.entity.Entity; +@@ -235,12 +233,8 @@ public class Breeze extends Monster { @Override - protected void customServerAiStep() { -- this.level().getProfiler().push("breezeBrain"); - this.getBrain().tick((ServerLevel)this.level(), this); -- this.level().getProfiler().popPush("breezeActivityUpdate"); + protected void customServerAiStep(ServerLevel world) { +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push("breezeBrain"); + this.getBrain().tick(world, this); +- profilerFiller.popPush("breezeActivityUpdate"); BreezeAi.updateActivity(this); -- this.level().getProfiler().pop(); - super.customServerAiStep(); +- profilerFiller.pop(); + super.customServerAiStep(world); + } + +diff --git a/src/main/java/net/minecraft/world/entity/monster/creaking/Creaking.java b/src/main/java/net/minecraft/world/entity/monster/creaking/Creaking.java +index 7b5f9284972b3a6bd8125891b23f73438e875c08..444e67eb9fa1fabff2304896bdd71772747dc437 100644 +--- a/src/main/java/net/minecraft/world/entity/monster/creaking/Creaking.java ++++ b/src/main/java/net/minecraft/world/entity/monster/creaking/Creaking.java +@@ -13,8 +13,6 @@ import net.minecraft.network.syncher.SynchedEntityData; + import net.minecraft.server.level.ServerLevel; + import net.minecraft.sounds.SoundEvent; + import net.minecraft.sounds.SoundEvents; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + import net.minecraft.world.damagesource.DamageSource; + import net.minecraft.world.entity.AnimationState; + import net.minecraft.world.entity.Entity; +@@ -121,10 +119,7 @@ public class Creaking extends Monster { + + @Override + protected void customServerAiStep(ServerLevel world) { +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push("creakingBrain"); + this.getBrain().tick((ServerLevel)this.level(), this); +- profilerFiller.pop(); + CreakingAi.updateActivity(this); } diff --git a/src/main/java/net/minecraft/world/entity/monster/hoglin/Hoglin.java b/src/main/java/net/minecraft/world/entity/monster/hoglin/Hoglin.java -index d5e0c493f4c348724958193795ceb987765a465f..8453c20a4b5f3a1205d0530b5c3b9f2c38a234a2 100644 +index 6ea90e54759dbeab025e0a1896ee834ea9986427..7d2d3838c0ab2d13b301142aa633f76cd4e598e7 100644 --- a/src/main/java/net/minecraft/world/entity/monster/hoglin/Hoglin.java +++ b/src/main/java/net/minecraft/world/entity/monster/hoglin/Hoglin.java -@@ -155,9 +155,7 @@ public class Hoglin extends Animal implements Enemy, HoglinBase { +@@ -16,8 +16,6 @@ import net.minecraft.sounds.SoundEvents; + import net.minecraft.sounds.SoundSource; + import net.minecraft.tags.ItemTags; + import net.minecraft.util.RandomSource; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + import net.minecraft.world.DifficultyInstance; + import net.minecraft.world.InteractionHand; + import net.minecraft.world.InteractionResult; +@@ -158,10 +156,7 @@ public class Hoglin extends Animal implements Enemy, HoglinBase { @Override - protected void customServerAiStep() { -- this.level().getProfiler().push("hoglinBrain"); - this.getBrain().tick((ServerLevel)this.level(), this); -- this.level().getProfiler().pop(); + protected void customServerAiStep(ServerLevel world) { +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push("hoglinBrain"); + this.getBrain().tick(world, this); +- profilerFiller.pop(); HoglinAi.updateActivity(this); if (this.isConverting()) { this.timeInOverworld++; diff --git a/src/main/java/net/minecraft/world/entity/monster/piglin/Piglin.java b/src/main/java/net/minecraft/world/entity/monster/piglin/Piglin.java -index bc58323801ee16fe9b63c21332144ec002a902f2..37452ff83fe07c9fa14a337cbf5018bfc7543f5a 100644 +index e04d2c5e75dc774fe893a552474fdb8045c32693..ad987660373cf1fd0edb778fa4203e3948b12fd4 100644 --- a/src/main/java/net/minecraft/world/entity/monster/piglin/Piglin.java +++ b/src/main/java/net/minecraft/world/entity/monster/piglin/Piglin.java -@@ -295,9 +295,7 @@ public class Piglin extends AbstractPiglin implements CrossbowAttackMob, Invento +@@ -6,8 +6,6 @@ import java.util.List; + import javax.annotation.Nullable; + import net.minecraft.util.RandomSource; + import net.minecraft.util.VisibleForDebug; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + import net.minecraft.world.DifficultyInstance; + import net.minecraft.world.InteractionHand; + import net.minecraft.world.InteractionResult; +@@ -306,11 +304,7 @@ public class Piglin extends AbstractPiglin implements CrossbowAttackMob, Invento @Override - protected void customServerAiStep() { -- this.level().getProfiler().push("piglinBrain"); - this.getBrain().tick((ServerLevel) this.level(), this); -- this.level().getProfiler().pop(); + protected void customServerAiStep(ServerLevel world) { +- ProfilerFiller gameprofilerfiller = Profiler.get(); +- +- gameprofilerfiller.push("piglinBrain"); + this.getBrain().tick(world, this); +- gameprofilerfiller.pop(); PiglinAi.updateActivity(this); - super.customServerAiStep(); + super.customServerAiStep(world); } diff --git a/src/main/java/net/minecraft/world/entity/monster/piglin/PiglinBrute.java b/src/main/java/net/minecraft/world/entity/monster/piglin/PiglinBrute.java -index fcadd7f28ccb81bbb36e97d8b8d8a8ba3f3d6a16..072c28e309d1d18cb3e3e719aec23d77dd966b47 100644 +index 24eaeb93284fe1a573026b85818a93a34fd9e1ec..0cab5d5aa80f9ca8c34f982f0b81044328ba2d8f 100644 --- a/src/main/java/net/minecraft/world/entity/monster/piglin/PiglinBrute.java +++ b/src/main/java/net/minecraft/world/entity/monster/piglin/PiglinBrute.java -@@ -106,9 +106,7 @@ public class PiglinBrute extends AbstractPiglin { +@@ -8,8 +8,6 @@ import net.minecraft.server.level.ServerLevel; + import net.minecraft.sounds.SoundEvent; + import net.minecraft.sounds.SoundEvents; + import net.minecraft.util.RandomSource; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + import net.minecraft.world.DifficultyInstance; + import net.minecraft.world.damagesource.DamageSource; + import net.minecraft.world.entity.EntitySpawnReason; +@@ -115,10 +113,7 @@ public class PiglinBrute extends AbstractPiglin { @Override - protected void customServerAiStep() { -- this.level().getProfiler().push("piglinBruteBrain"); - this.getBrain().tick((ServerLevel)this.level(), this); -- this.level().getProfiler().pop(); + protected void customServerAiStep(ServerLevel world) { +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push("piglinBruteBrain"); + this.getBrain().tick(world, this); +- profilerFiller.pop(); PiglinBruteAi.updateActivity(this); PiglinBruteAi.maybePlayActivitySound(this); - super.customServerAiStep(); + super.customServerAiStep(world); diff --git a/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java b/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java -index 38bf417a9ad4647f4af24d969f3bf4fed9c4bad7..1cb55c9240dfa46cf117ac5b8923b064a96788c3 100644 +index 6180019da58b19d2595da508aed3196af922d587..9d9d58ab055b5bccedd6ebc9f6853ca8206cde65 100644 --- a/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java +++ b/src/main/java/net/minecraft/world/entity/monster/warden/Warden.java -@@ -276,9 +276,7 @@ public class Warden extends Monster implements VibrationSystem { - protected void customServerAiStep() { - ServerLevel worldserver = (ServerLevel) this.level(); +@@ -32,8 +32,6 @@ import net.minecraft.tags.TagKey; + import net.minecraft.util.Mth; + import net.minecraft.util.RandomSource; + import net.minecraft.util.Unit; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + import net.minecraft.world.DifficultyInstance; + import net.minecraft.world.damagesource.DamageSource; + import net.minecraft.world.effect.MobEffectInstance; +@@ -277,11 +275,7 @@ public class Warden extends Monster implements VibrationSystem { -- worldserver.getProfiler().push("wardenBrain"); - this.getBrain().tick(worldserver, this); -- this.level().getProfiler().pop(); - super.customServerAiStep(); + @Override + protected void customServerAiStep(ServerLevel world) { +- ProfilerFiller gameprofilerfiller = Profiler.get(); +- +- gameprofilerfiller.push("wardenBrain"); + this.getBrain().tick(world, this); +- gameprofilerfiller.pop(); + super.customServerAiStep(world); if ((this.tickCount + this.getId()) % 120 == 0) { - Warden.applyDarknessAround(worldserver, this.position(), this, 20); + Warden.applyDarknessAround(world, this.position(), this, 20); diff --git a/src/main/java/net/minecraft/world/entity/npc/Villager.java b/src/main/java/net/minecraft/world/entity/npc/Villager.java -index 7e1871401ec5e3e9a85232053490259f132aec0a..ba49442ed0b7c05c50dbc2a640f5759e391902f2 100644 +index b7a34f1c4d7b5ef3f7a843d152e33c839dcdedd5..08c780e9e1e167b84f70dce691bb564c8420b286 100644 --- a/src/main/java/net/minecraft/world/entity/npc/Villager.java +++ b/src/main/java/net/minecraft/world/entity/npc/Villager.java -@@ -254,9 +254,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler +@@ -38,8 +38,6 @@ import net.minecraft.stats.Stats; + import net.minecraft.tags.ItemTags; + import net.minecraft.util.Mth; + import net.minecraft.util.SpawnUtil; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + import net.minecraft.world.Difficulty; + import net.minecraft.world.DifficultyInstance; + import net.minecraft.world.InteractionHand; +@@ -252,11 +250,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler } - protected void customServerAiStep(final boolean inactive) { - // Paper end -- this.level().getProfiler().push("villagerBrain"); - if (!inactive) this.getBrain().tick((ServerLevel) this.level(), this); // Paper -- this.level().getProfiler().pop(); + protected void customServerAiStep(ServerLevel world, final boolean inactive) { + // Paper end - EAR 2 +- ProfilerFiller gameprofilerfiller = Profiler.get(); +- +- gameprofilerfiller.push("villagerBrain"); + if (!inactive) this.getBrain().tick(world, this); +- gameprofilerfiller.pop(); if (this.assignProfessionWhenSpawned) { this.assignProfessionWhenSpawned = false; } -diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java -index f696afd7e241bf1966a2d505b5d59bff824b43e4..94e0a6cdf5c340dd11374e890963d043a440650a 100644 ---- a/src/main/java/net/minecraft/world/level/Explosion.java -+++ b/src/main/java/net/minecraft/world/level/Explosion.java -@@ -647,7 +647,6 @@ public class Explosion { - } - - if (flag1) { -- this.level.getProfiler().push("explosion_blocks"); - List> list = new ArrayList(); - - Util.shuffle(this.toBlow, this.level.random); -@@ -722,7 +721,6 @@ public class Explosion { - Block.popResource(this.level, (BlockPos) pair.getSecond(), (ItemStack) pair.getFirst()); - } - -- this.level.getProfiler().pop(); - } - - if (this.fire) { diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index 32cd737206dd9f2bcfdacfe17dc0621ee34b589a..9dfc38c1b062c8ad52ecff4b0731f0650c1ebeef 100644 +index c0e4b996715dec16dd181b7dac87c361a16a1f7f..38408c004bdf8e31ad8665f75205a0f42ef1ff99 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -133,7 +133,6 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl - private final RandomSource threadSafeRandom = RandomSource.createThreadSafe(); - private final Holder dimensionTypeRegistration; - public final WritableLevelData levelData; -- private final Supplier profiler; - public final boolean isClientSide; - private final WorldBorder worldBorder; - private final BiomeManager biomeManager; -@@ -229,7 +228,6 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -34,8 +34,6 @@ import net.minecraft.util.AbortableIterationConsumer; + import net.minecraft.util.Mth; + import net.minecraft.util.RandomSource; + import net.minecraft.util.StringRepresentable; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + import net.minecraft.world.DifficultyInstance; + import net.minecraft.world.TickRateManager; + import net.minecraft.world.damagesource.DamageSource; +@@ -230,7 +228,6 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl @Override public final List getEntitiesOfClass(final Class entityClass, final AABB boundingBox, final Predicate predicate) { -- this.getProfiler().incrementCounter("getEntities"); +- Profiler.get().incrementCounter("getEntities"); final List ret = new java.util.ArrayList<>(); ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemLevel)this).moonrise$getEntityLookup().getEntities(entityClass, null, boundingBox, ret, predicate); -@@ -239,7 +237,6 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -240,7 +237,6 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl @Override public final List moonrise$getHardCollidingEntities(final Entity entity, final AABB box, final Predicate predicate) { -- this.getProfiler().incrementCounter("getEntities"); +- Profiler.get().incrementCounter("getEntities"); final List ret = new java.util.ArrayList<>(); ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemLevel)this).moonrise$getEntityLookup().getHardCollidingEntities(entity, box, ret, predicate); -@@ -688,7 +685,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl - } - // Paper end - optimise random ticking - -- protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, RegistryAccess iregistrycustom, Holder holder, Supplier 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 paperWorldConfigCreator, java.util.function.Function galeWorldConfigCreator, java.util.concurrent.Executor executor) { // Paper - create paper world config & Anti-Xray // Gale - Gale configuration -+ protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, RegistryAccess iregistrycustom, Holder holder, 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 paperWorldConfigCreator, java.util.function.Function galeWorldConfigCreator, java.util.concurrent.Executor executor) { // Paper - create paper world config & Anti-Xray // Gale - Gale configuration // Gale - Purpur - remove vanilla profiler - this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot - this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper - create paper world config - this.galeConfig = galeWorldConfigCreator.apply(this.spigotConfig); // Gale - Gale configuration -@@ -703,7 +700,6 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl - } - - // CraftBukkit end -- this.profiler = supplier; - this.levelData = worlddatamutable; - this.dimensionTypeRegistration = holder; - final DimensionType dimensionmanager = (DimensionType) holder.value(); -@@ -1371,9 +1367,6 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -1445,9 +1441,6 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl } protected void tickBlockEntities() { -- ProfilerFiller gameprofilerfiller = this.getProfiler(); +- ProfilerFiller gameprofilerfiller = Profiler.get(); - - gameprofilerfiller.push("blockEntities"); - this.timings.tileEntityPending.startTiming(); // Spigot this.tickingBlockEntities = true; if (!this.pendingBlockEntityTickers.isEmpty()) { -@@ -1416,7 +1409,6 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl - this.timings.tileEntityTick.stopTiming(); // Spigot + this.blockEntityTickers.addAll(this.pendingBlockEntityTickers); +@@ -1485,7 +1478,6 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl + this.blockEntityTickers.removeAll(toRemove); // Paper - Fix MC-117075 + this.tickingBlockEntities = false; - co.aikar.timings.TimingHistory.tileEntityTicks += this.blockEntityTickers.size(); // Paper - gameprofilerfiller.pop(); this.spigotConfig.currentPrimedTnt = 0; // Spigot } -@@ -1645,7 +1637,6 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -1655,7 +1647,6 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl @Override public List getEntities(@Nullable Entity except, AABB box, Predicate predicate) { -- this.getProfiler().incrementCounter("getEntities"); - // Paper start - rewrite chunk system - final List ret = new java.util.ArrayList<>(); +- Profiler.get().incrementCounter("getEntities"); + List list = Lists.newArrayList(); -@@ -1671,8 +1662,6 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl + // Paper start - rewrite chunk system +@@ -1685,8 +1676,6 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl public void getEntities(final EntityTypeTest entityTypeTest, final AABB boundingBox, final Predicate predicate, final List into, final int maxCount) { -- this.getProfiler().incrementCounter("getEntities"); +- Profiler.get().incrementCounter("getEntities"); - if (entityTypeTest instanceof net.minecraft.world.entity.EntityType byType) { if (maxCount != Integer.MAX_VALUE) { ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemLevel)this).moonrise$getEntityLookup().getEntities(byType, boundingBox, into, predicate, maxCount); -@@ -1966,11 +1955,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl - } - - public ProfilerFiller getProfiler() { -- return (ProfilerFiller) this.profiler.get(); -+ return net.minecraft.util.profiling.InactiveProfiler.INSTANCE; // Gale - Purpur - remove vanilla profiler - } - - public Supplier getProfilerSupplier() { -- return this.profiler; -+ return () -> net.minecraft.util.profiling.InactiveProfiler.INSTANCE; // Gale - Purpur - remove vanilla profiler - } - - @Override diff --git a/src/main/java/net/minecraft/world/level/NaturalSpawner.java b/src/main/java/net/minecraft/world/level/NaturalSpawner.java -index 743a33ae2814c513b84b1a60e50a3c24527568f8..f636037bb443e35872fcd50483e88b3597b6ad67 100644 +index 5297798c2be1ba85569c2b92ed221956bf75477a..3c7da8e11aad02d2b87c8913762e2f3f6040257b 100644 --- a/src/main/java/net/minecraft/world/level/NaturalSpawner.java +++ b/src/main/java/net/minecraft/world/level/NaturalSpawner.java -@@ -127,7 +127,6 @@ public final class NaturalSpawner { +@@ -24,8 +24,6 @@ import net.minecraft.tags.BlockTags; + import net.minecraft.util.Mth; + import net.minecraft.util.RandomSource; + import net.minecraft.util.VisibleForDebug; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + import net.minecraft.util.random.WeightedRandomList; + import net.minecraft.world.entity.Entity; + import net.minecraft.world.entity.EntitySpawnReason; +@@ -163,9 +161,6 @@ public final class NaturalSpawner { } - public static void spawnForChunk(ServerLevel world, LevelChunk chunk, NaturalSpawner.SpawnState info, boolean spawnAnimals, boolean spawnMonsters, boolean rareSpawn) { -- world.getProfiler().push("spawner"); - world.timings.mobSpawn.startTiming(); // Spigot - MobCategory[] aenumcreaturetype = NaturalSpawner.SPAWNING_CATEGORIES; - int i = aenumcreaturetype.length; -@@ -181,7 +180,6 @@ public final class NaturalSpawner { - } + public static void spawnForChunk(ServerLevel world, LevelChunk chunk, NaturalSpawner.SpawnState info, List spawnableGroups) { +- ProfilerFiller gameprofilerfiller = Profiler.get(); +- +- gameprofilerfiller.push("spawner"); + Iterator iterator = spawnableGroups.iterator(); - world.timings.mobSpawn.stopTiming(); // Spigot -- world.getProfiler().pop(); + while (iterator.hasNext()) { +@@ -210,8 +205,6 @@ public final class NaturalSpawner { + // Paper end - Optional per player mob spawns + } + } +- +- gameprofilerfiller.pop(); } // Paper start - Add mobcaps commands -diff --git a/src/main/java/net/minecraft/world/level/PathNavigationRegion.java b/src/main/java/net/minecraft/world/level/PathNavigationRegion.java -index c5454b92ca2565461c799d7340160f9fb72c1b0f..a1a4b99167919bedb8a45c3b81889f58f2abfbcc 100644 ---- a/src/main/java/net/minecraft/world/level/PathNavigationRegion.java -+++ b/src/main/java/net/minecraft/world/level/PathNavigationRegion.java -@@ -8,7 +8,6 @@ import net.minecraft.core.BlockPos; +diff --git a/src/main/java/net/minecraft/world/level/ServerExplosion.java b/src/main/java/net/minecraft/world/level/ServerExplosion.java +index bbbd451ff184be8fa13bd93d53c89a9502f9951a..4de71492339c3d31a34f1fa2aa75e8b216485ef0 100644 +--- a/src/main/java/net/minecraft/world/level/ServerExplosion.java ++++ b/src/main/java/net/minecraft/world/level/ServerExplosion.java +@@ -15,8 +15,6 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Holder; - import net.minecraft.core.SectionPos; - import net.minecraft.core.registries.Registries; --import net.minecraft.util.profiling.ProfilerFiller; import net.minecraft.server.level.ServerLevel; + import net.minecraft.util.Mth; +-import net.minecraft.util.profiling.Profiler; +-import net.minecraft.util.profiling.ProfilerFiller; + import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; - import net.minecraft.world.level.biome.Biome; -@@ -151,8 +150,4 @@ public class PathNavigationRegion implements BlockGetter, CollisionGetter { - public int getHeight() { - return this.level.getHeight(); - } + import net.minecraft.world.entity.EntityType; +@@ -683,11 +681,7 @@ public class ServerExplosion implements Explosion { + + this.hurtEntities(); + if (this.interactsWithBlocks()) { +- ProfilerFiller gameprofilerfiller = Profiler.get(); - -- public ProfilerFiller getProfiler() { -- return this.level.getProfiler(); -- } - } +- gameprofilerfiller.push("explosion_blocks"); + this.interactWithBlocks(list); +- gameprofilerfiller.pop(); + } + + if (this.fire) { 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 7c11853c5090fbc4fa5b3e73a69acf166158fdec..3720b1d9456376523c8c15fa753176e479f77483 100644 +index 4640baec5bed6c2d53cc0f8ca1d273cc115abe9b..09a6d7410bc029889ce4b89ab149a52f31468b9b 100644 --- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java +++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java -@@ -25,7 +25,6 @@ import net.minecraft.network.FriendlyByteBuf; +@@ -25,8 +25,6 @@ import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.protocol.game.ClientboundLevelChunkPacketData; import net.minecraft.server.level.FullChunkStatus; import net.minecraft.server.level.ServerLevel; +-import net.minecraft.util.profiling.Profiler; -import net.minecraft.util.profiling.ProfilerFiller; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.Level; -@@ -381,13 +380,8 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p +@@ -405,13 +403,8 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p } - if (LightEngine.hasDifferentLightProperties(this, blockposition, iblockdata1, iblockdata)) { -- ProfilerFiller gameprofilerfiller = this.level.getProfiler(); + if (LightEngine.hasDifferentLightProperties(iblockdata1, iblockdata)) { +- ProfilerFiller gameprofilerfiller = Profiler.get(); - - gameprofilerfiller.push("updateSkyLightSources"); // Paper - rewrite chunk system @@ -2007,17 +2260,17 @@ index 7c11853c5090fbc4fa5b3e73a69acf166158fdec..3720b1d9456376523c8c15fa753176e4 } boolean flag3 = iblockdata1.hasBlockEntity(); -@@ -1023,9 +1017,6 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p +@@ -1058,9 +1051,6 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p if (LevelChunk.this.isTicking(blockposition)) { try { -- ProfilerFiller gameprofilerfiller = LevelChunk.this.level.getProfiler(); +- ProfilerFiller gameprofilerfiller = Profiler.get(); - - gameprofilerfiller.push(this::getType); - this.blockEntity.tickTimer.startTiming(); // Spigot BlockState iblockdata = LevelChunk.this.getBlockState(blockposition); -@@ -1041,8 +1032,6 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p + if (this.blockEntity.getType().isValid(iblockdata)) { +@@ -1075,8 +1065,6 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p } // Paper end - Remove the Block Entity if it's invalid } @@ -2027,80 +2280,55 @@ index 7c11853c5090fbc4fa5b3e73a69acf166158fdec..3720b1d9456376523c8c15fa753176e4 if (throwable instanceof ThreadDeath) throw throwable; // Paper // Paper start - Prevent block entity and entity crashes diff --git a/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java b/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java -index 18bbb3f8f99849333ff4bc020c8ce758a69312a5..f890c27c960b6511b7961f380b23e9ca8f86ba0e 100644 +index cc7d94144e39f7dace7b569b4567def98396e8f9..d7ac3a6a1d7d5561aae153ecb1455b8972d9a61d 100644 --- a/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java +++ b/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java -@@ -12,7 +12,6 @@ import java.util.function.Function; +@@ -12,9 +12,6 @@ import java.util.function.Function; import java.util.stream.Collectors; import javax.annotation.Nullable; import net.minecraft.core.BlockPos; +-import net.minecraft.util.profiling.Profiler; -import net.minecraft.util.profiling.ProfilerFiller; - import net.minecraft.util.profiling.metrics.MetricCategory; +-import net.minecraft.util.profiling.metrics.MetricCategory; import net.minecraft.world.entity.Mob; import net.minecraft.world.level.PathNavigationRegion; -@@ -44,7 +43,7 @@ public class PathFinder { - map.add(new java.util.AbstractMap.SimpleEntry<>(this.nodeEvaluator.getTarget(pos.getX(), pos.getY(), pos.getZ()), pos)); - } - // Paper end - Perf: remove streams and optimize collection -- Path path = this.findPath(world.getProfiler(), node, map, followRange, distance, rangeMultiplier); -+ Path path = this.findPath(node, map, followRange, distance, rangeMultiplier); // Gale - Purpur - remove vanilla profiler - this.nodeEvaluator.done(); - return path; - } -@@ -52,9 +51,7 @@ public class PathFinder { +@@ -58,9 +55,6 @@ public class PathFinder { @Nullable // Paper start - Perf: remove streams and optimize collection -- private Path findPath(ProfilerFiller profiler, Node startNode, List> positions, float followRange, int distance, float rangeMultiplier) { -- profiler.push("find_path"); -- profiler.markForCharting(MetricCategory.PATH_FINDING); -+ private Path findPath(Node startNode, List> positions, float followRange, int distance, float rangeMultiplier) { // Gale - Purpur - remove vanilla profiler + private Path findPath(Node startNode, List> positions, float followRange, int distance, float rangeMultiplier) { +- ProfilerFiller profilerFiller = Profiler.get(); +- profilerFiller.push("find_path"); +- profilerFiller.markForCharting(MetricCategory.PATH_FINDING); // Set set = positions.keySet(); startNode.g = 0.0F; startNode.h = this.getBestH(startNode, positions); // Paper - optimize collection -@@ -122,7 +119,6 @@ public class PathFinder { +@@ -128,7 +122,6 @@ public class PathFinder { if (best == null || comparator.compare(path, best) < 0) best = path; } -- profiler.pop(); +- profilerFiller.pop(); return best; // Paper end - Perf: remove streams and optimize collection } diff --git a/src/main/java/net/minecraft/world/ticks/LevelTicks.java b/src/main/java/net/minecraft/world/ticks/LevelTicks.java -index 7a69564572357a7acc043e35b9c113beeb738951..6e24b2c1b9ac9f1be02a6cc88085cbbcbfee1a02 100644 +index 778e6476c86d823dc8efe603a95e589e8b2ea9d9..97f304e287603dbe44080182665ef4454df2c66f 100644 --- a/src/main/java/net/minecraft/world/ticks/LevelTicks.java +++ b/src/main/java/net/minecraft/world/ticks/LevelTicks.java -@@ -24,14 +24,12 @@ import net.minecraft.Util; +@@ -23,8 +23,6 @@ import net.minecraft.Util; import net.minecraft.core.BlockPos; import net.minecraft.core.SectionPos; import net.minecraft.core.Vec3i; +-import net.minecraft.util.profiling.Profiler; -import net.minecraft.util.profiling.ProfilerFiller; import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.levelgen.structure.BoundingBox; - public class LevelTicks implements LevelTickAccess { - private static final Comparator> CONTAINER_DRAIN_ORDER = (a, b) -> ScheduledTick.INTRA_TICK_DRAIN_ORDER.compare(a.peek(), b.peek()); - private final LongPredicate tickCheck; -- private final Supplier profiler; - private final Long2ObjectMap> allContainers = new Long2ObjectOpenHashMap<>(); - private final Long2LongMap nextTickForContainer = Util.make(new Long2LongOpenHashMap(), map -> map.defaultReturnValue(Long.MAX_VALUE)); - private final Queue> containersToTick = new PriorityQueue<>(CONTAINER_DRAIN_ORDER); -@@ -44,9 +42,8 @@ public class LevelTicks implements LevelTickAccess { - } - }; - -- public LevelTicks(LongPredicate tickingFutureReadyPredicate, Supplier profilerGetter) { -+ public LevelTicks(LongPredicate tickingFutureReadyPredicate) { // Gale - Purpur - remove vanilla profiler - this.tickCheck = tickingFutureReadyPredicate; -- this.profiler = profilerGetter; - } - - public void addContainer(ChunkPos pos, LevelChunkTicks scheduler) { -@@ -81,20 +78,13 @@ public class LevelTicks implements LevelTickAccess { +@@ -79,20 +77,13 @@ public class LevelTicks implements LevelTickAccess { } public void tick(long time, int maxTicks, BiConsumer ticker) { -- ProfilerFiller profilerFiller = this.profiler.get(); +- ProfilerFiller profilerFiller = Profiler.get(); - profilerFiller.push("collect"); - this.collectTicks(time, maxTicks, profilerFiller); - profilerFiller.popPush("run"); diff --git a/patches/server/0013-Faster-floating-point-positive-modulo.patch b/patches/server/0013-Faster-floating-point-positive-modulo.patch index cb10d8b..ffe7f06 100644 --- a/patches/server/0013-Faster-floating-point-positive-modulo.patch +++ b/patches/server/0013-Faster-floating-point-positive-modulo.patch @@ -7,7 +7,7 @@ License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) Gale - https://galemc.org diff --git a/src/main/java/net/minecraft/util/Mth.java b/src/main/java/net/minecraft/util/Mth.java -index 3468b7fbc7440f220fce8039f237658a593df296..cb8cde3c1b65329f92b7c78e529e128f5a408fd6 100644 +index 6b21782ad18cd5dbd1b9a59e5dc12c670c2a42fb..34bfbbabe3dfbf033f4a4e22a049323213fb23f3 100644 --- a/src/main/java/net/minecraft/util/Mth.java +++ b/src/main/java/net/minecraft/util/Mth.java @@ -149,14 +149,26 @@ public class Mth { @@ -40,10 +40,10 @@ index 3468b7fbc7440f220fce8039f237658a593df296..cb8cde3c1b65329f92b7c78e529e128f return a % b == 0; } diff --git a/src/main/java/net/minecraft/world/level/levelgen/blending/Blender.java b/src/main/java/net/minecraft/world/level/levelgen/blending/Blender.java -index ef73772bd3f9484efbcd521a86a34c6ec3fd0d14..45f6f74bcae3e3f27809d2ff3973b98edb169f0f 100644 +index d058e71d6047bbd9256f6c71bb21966cfc056a7d..079edef073e751f38063b42515df893cecd2fcc4 100644 --- a/src/main/java/net/minecraft/world/level/levelgen/blending/Blender.java +++ b/src/main/java/net/minecraft/world/level/levelgen/blending/Blender.java -@@ -148,7 +148,7 @@ public class Blender { +@@ -146,7 +146,7 @@ public class Blender { private static double heightToOffset(double height) { double d = 1.0; double e = height + 0.5; diff --git a/patches/server/0014-Simpler-ShapelessRecipe-comparison-for-vanilla.patch b/patches/server/0014-Simpler-ShapelessRecipe-comparison-for-vanilla.patch index 81df9ee..683cd44 100644 --- a/patches/server/0014-Simpler-ShapelessRecipe-comparison-for-vanilla.patch +++ b/patches/server/0014-Simpler-ShapelessRecipe-comparison-for-vanilla.patch @@ -37,26 +37,26 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . 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 213ee4aa988dd4c2a5a7be99b1d13f67338e5209..a51f21995b66e08b33e8645297c25e1f979d0e73 100644 +index 6ec7b234b468755835107be40d0080222c0b9263..4e09c158a3e767754abc0df9410c736016ef0704 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,15 @@ public class ShapelessRecipe extends io.papermc.paper.inventory.recipe.RecipeBoo - final CraftingBookCategory category; - final ItemStack result; - final NonNullList ingredients; +@@ -31,8 +31,15 @@ public class ShapelessRecipe implements CraftingRecipe { + final List ingredients; + @Nullable + private PlacementInfo placementInfo; + private final boolean isBukkit; // Gale - Airplane - simpler ShapelessRecipe comparison for vanilla - public ShapelessRecipe(String group, CraftingBookCategory category, ItemStack result, NonNullList ingredients) { + public ShapelessRecipe(String group, CraftingBookCategory category, ItemStack result, List ingredients) { + // Gale start - Airplane - simpler ShapelessRecipe comparison for vanilla + this(group, category, result, ingredients, false); + } -+ public ShapelessRecipe(String group, CraftingBookCategory category, ItemStack result, NonNullList ingredients, boolean isBukkit) { ++ public ShapelessRecipe(String group, CraftingBookCategory category, ItemStack result, List ingredients, boolean isBukkit) { + this.isBukkit = isBukkit; + // Gale end - Airplane - simpler ShapelessRecipe comparison for vanilla this.group = group; this.category = category; this.result = result; -@@ -76,6 +83,29 @@ public class ShapelessRecipe extends io.papermc.paper.inventory.recipe.RecipeBoo +@@ -80,6 +87,29 @@ public class ShapelessRecipe implements CraftingRecipe { } public boolean matches(CraftingInput input, Level world) { @@ -83,18 +83,18 @@ index 213ee4aa988dd4c2a5a7be99b1d13f67338e5209..a51f21995b66e08b33e8645297c25e1f + } + // Gale end - Airplane - simpler ShapelessRecipe comparison for vanilla + - // Paper start - unwrap ternary & better exact choice recipes - if (input.ingredientCount() != this.ingredients.size()) { - return false; + return input.ingredientCount() != this.ingredients.size() ? false : (input.size() == 1 && this.ingredients.size() == 1 ? ((Ingredient) this.ingredients.getFirst()).test(input.getItem(0)) : input.stackedContents().canCraft((Recipe) this, (StackedContents.Output) null)); + } + diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java -index 96d772eb02f79f8c478f5e6f065e387aa7665b18..0d27792dcc3deb4cc7835512f4156b490223358d 100644 +index 7c989318dc7ad89bb0d9143fcaac1e4bba6f5907..a90b294a99072ab576e61ddacb60a036cb7f0f5a 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java -@@ -45,6 +45,6 @@ public class CraftShapelessRecipe extends ShapelessRecipe implements CraftRecipe - data.set(i, this.toNMS(ingred.get(i), true)); +@@ -44,6 +44,6 @@ public class CraftShapelessRecipe extends ShapelessRecipe implements CraftRecipe + data.add(this.toNMS(i, true)); } -- MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftNamespacedKey.toMinecraft(this.getKey()), new net.minecraft.world.item.crafting.ShapelessRecipe(this.getGroup(), CraftRecipe.getCategory(this.getCategory()), CraftItemStack.asNMSCopy(this.getResult()), data))); -+ MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftNamespacedKey.toMinecraft(this.getKey()), new net.minecraft.world.item.crafting.ShapelessRecipe(this.getGroup(), CraftRecipe.getCategory(this.getCategory()), CraftItemStack.asNMSCopy(this.getResult()), data, true))); // Gale - Airplane - simpler ShapelessRecipe comparison for vanilla +- MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftRecipe.toMinecraft(this.getKey()), new net.minecraft.world.item.crafting.ShapelessRecipe(this.getGroup(), CraftRecipe.getCategory(this.getCategory()), CraftItemStack.asNMSCopy(this.getResult()), data))); ++ MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftRecipe.toMinecraft(this.getKey()), new net.minecraft.world.item.crafting.ShapelessRecipe(this.getGroup(), CraftRecipe.getCategory(this.getCategory()), CraftItemStack.asNMSCopy(this.getResult()), data, true))); // Gale - Airplane - simpler ShapelessRecipe comparison for vanilla } } diff --git a/patches/server/0015-Reduce-projectile-chunk-loading.patch b/patches/server/0015-Reduce-projectile-chunk-loading.patch index 0f4e2b8..e75ab5a 100644 --- a/patches/server/0015-Reduce-projectile-chunk-loading.patch +++ b/patches/server/0015-Reduce-projectile-chunk-loading.patch @@ -31,10 +31,10 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . 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 5f7d152f41eb85f17bcded4bc8099b998e5a338b..bf1e1e7561b674ace6bfd601a5c1ddfcd203ac04 100644 +index 6c2d4d6f3a36ab452dfd3c33f66e54f152906639..507a7f2116b020a5af4b8fff15b73dba9904874f 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java +++ b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java -@@ -52,6 +52,45 @@ public abstract class Projectile extends Entity implements TraceableEntity { +@@ -58,6 +58,45 @@ public abstract class Projectile extends Entity implements TraceableEntity { super(type, world); } diff --git a/patches/server/0016-Predict-Halloween.patch b/patches/server/0016-Predict-Halloween.patch index 788ae7f..951cce5 100644 --- a/patches/server/0016-Predict-Halloween.patch +++ b/patches/server/0016-Predict-Halloween.patch @@ -7,10 +7,10 @@ License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) Gale - https://galemc.org 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 dc27ddf5131e7398a5390a5187261d4c7fb6ccaa..c888ca771efa7a570b8302d48e69fbb69bf98bd9 100644 +index 60c2868f255d372226e0c1389caaa5477bbef41e..46ec05c0ec7c794481e996dd9f51c396a5f75f97 100644 --- a/src/main/java/net/minecraft/world/entity/ambient/Bat.java +++ b/src/main/java/net/minecraft/world/entity/ambient/Bat.java -@@ -239,12 +239,60 @@ public class Bat extends AmbientCreature { +@@ -242,12 +242,60 @@ public class Bat extends AmbientCreature { } } diff --git a/patches/server/0017-Optimize-random-calls-in-chunk-ticking.patch b/patches/server/0017-Optimize-random-calls-in-chunk-ticking.patch index f6431ae..d904c19 100644 --- a/patches/server/0017-Optimize-random-calls-in-chunk-ticking.patch +++ b/patches/server/0017-Optimize-random-calls-in-chunk-ticking.patch @@ -52,54 +52,55 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index 3b3684d202e460a80b3e6e97afbaa4c84c4e3b3b..39b187dc90f79dbfff55be697b8cb4d404b290fc 100644 +index ebed376154ce30bf75fcdc2bd23c4dab251e1719..01a6e1fd4d7271f5a223765dab7976efcdf1fd92 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java +++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -@@ -441,6 +441,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon - - // Paper - chunk tick iteration optimisations +@@ -471,6 +471,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon + this.lastInhabitedUpdate = i; + if (!this.level.isDebug()) { + this.level.resetIceAndSnowTick(); // Gale - Airplane - optimize random calls in chunk ticking - reset ice & snow tick random if (this.level.tickRateManager().runsNormally()) { - this.level.timings.countNaturalMobs.startTiming(); // Paper - timings - int k = this.distanceManager.getNaturalSpawnChunkCount(); + List list = this.tickingChunks; + diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index 7aa13de4b3778e6708ed46ddcedde100f585a40f..bad5725292cf549d2cd4f62bc3c77c321df24294 100644 +index 3401602c57337e96012c2768b38f523ca7dd6798..e54fa5dc8587cad486e1e509d803ee5e2fd27712 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java -@@ -834,13 +834,15 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf. +@@ -887,6 +887,8 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe } // Paper end - optimise random ticking + private int currentIceAndSnowTick = 0; protected void resetIceAndSnowTick() { this.currentIceAndSnowTick = this.random.nextInt(16); } // Gale - Airplane - optimize random calls in chunk ticking + public void tickChunk(LevelChunk chunk, int randomTickSpeed) { + final ca.spottedleaf.moonrise.common.util.SimpleRandom simpleRandom = this.simpleRandom; // Paper - optimise random ticking ChunkPos chunkcoordintpair = chunk.getPos(); - boolean flag = this.isRaining(); +@@ -894,7 +896,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe int j = chunkcoordintpair.getMinBlockX(); int k = chunkcoordintpair.getMinBlockZ(); -- if (!this.paperConfig().environment.disableThunder && flag && this.isThundering() && this.spigotConfig.thunderChance > 0 && this.random.nextInt(this.spigotConfig.thunderChance) == 0) { // Spigot // Paper - Option to 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 - Option to disable thunder // Gale - Airplane - optimize random calls in chunk ticking - replace random with shouldDoLightning +- if (!this.paperConfig().environment.disableThunder && flag && this.isThundering() && this.spigotConfig.thunderChance > 0 && simpleRandom.nextInt(this.spigotConfig.thunderChance) == 0) { // Spigot // Paper - Option to disable thunder // Paper - optimise random ticking ++ if (!this.paperConfig().environment.disableThunder && flag && this.isThundering() && this.spigotConfig.thunderChance > 0 /*&& simpleRandom.nextInt(this.spigotConfig.thunderChance) == 0*/ && chunk.shouldDoLightning(this.simpleRandom)) { // Spigot // Paper - Option to disable thunder // Paper - optimise random ticking // Gale - Airplane - optimize random calls in chunk ticking - replace random with shouldDoLightning BlockPos blockposition = this.findLightningTargetAround(this.getBlockRandomPos(j, 0, k, 15)); if (this.isRainingAt(blockposition)) { -@@ -868,7 +870,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf. +@@ -922,7 +924,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe } } - if (!this.paperConfig().environment.disableIceAndSnow) { // Paper - Option to disable ice and snow + if (!this.paperConfig().environment.disableIceAndSnow && (this.currentIceAndSnowTick++ & 15) == 0) { // Paper - Option to disable ice and snow // Gale - Airplane - optimize random calls in chunk ticking - optimize further random ticking for (int l = 0; l < randomTickSpeed; ++l) { - if (this.random.nextInt(48) == 0) { + if (simpleRandom.nextInt(48) == 0) { // Paper - optimise random ticking this.tickPrecipitation(this.getBlockRandomPos(j, 0, k, 15)); 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 36540053590c30a902b9986dcf2e74375157822d..f23ed06a943646f45e1291f35ab3025e1dfa6b49 100644 +index 09a6d7410bc029889ce4b89ab149a52f31468b9b..e7c9fc8b7f15cd299b32ad9bf2cdeb0d04f1a3ee 100644 --- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java +++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java -@@ -85,6 +85,18 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p - private final LevelChunkTicks blockTicks; +@@ -86,6 +86,18 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p private final LevelChunkTicks fluidTicks; + private LevelChunk.UnsavedListener unsavedListener; + // 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; @@ -116,7 +117,7 @@ index 36540053590c30a902b9986dcf2e74375157822d..f23ed06a943646f45e1291f35ab3025e public LevelChunk(Level world, ChunkPos pos) { this(world, pos, UpgradeData.EMPTY, new LevelChunkTicks<>(), new LevelChunkTicks<>(), 0L, (LevelChunkSection[]) null, (LevelChunk.PostLoadProcessor) null, (BlendingData) null); } -@@ -116,6 +128,8 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p +@@ -119,6 +131,8 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p this.debug = !empty && this.level.isDebug(); this.defaultBlockState = empty ? VOID_AIR_BLOCKSTATE : AIR_BLOCKSTATE; // Paper end - get block chunk optimisation diff --git a/patches/server/0018-Reduce-enderman-teleport-chunk-lookups.patch b/patches/server/0018-Reduce-enderman-teleport-chunk-lookups.patch index d19e37f..4435ed4 100644 --- a/patches/server/0018-Reduce-enderman-teleport-chunk-lookups.patch +++ b/patches/server/0018-Reduce-enderman-teleport-chunk-lookups.patch @@ -31,21 +31,20 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . 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 828c51477cd8f35d591367b30bf4feef6a250292..7b05ef99702af0e8a7d2a652984c4f8c15eefed8 100644 +index 48dcd2bc12ce1d08cc5195bff5460dc0dd9902d3..b14935c32409ccc4e65e7d642342e113142443f8 100644 --- a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java +++ b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java -@@ -320,11 +320,17 @@ public class EnderMan extends Monster implements NeutralMob { +@@ -307,11 +307,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).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).blocksMotion()) { -+ // Gale end - Airplane - single chunk lookup ++ + while (blockposition_mutableblockposition.getY() > this.level().getMinY() && !this.level().getBlockState(blockposition_mutableblockposition).blocksMotion()) { blockposition_mutableblockposition.move(Direction.DOWN); } diff --git a/patches/server/0020-Remove-iterators-from-Inventory-contains.patch b/patches/server/0020-Remove-iterators-from-Inventory-contains.patch index fb4df48..db25b5d 100644 --- a/patches/server/0020-Remove-iterators-from-Inventory-contains.patch +++ b/patches/server/0020-Remove-iterators-from-Inventory-contains.patch @@ -31,10 +31,10 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . 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 6e66141dca61f777b354854b5d0bac2570b8bf3b..06104744bb778a922adaaee2d91252cd37080f8f 100644 +index ad82e5aeb565b23c3ec565fa60e1f31d1710bd4e..5bf4164f0b9a3d4e6b8e9de87d80683c98a21298 100644 --- a/src/main/java/net/minecraft/world/entity/player/Inventory.java +++ b/src/main/java/net/minecraft/world/entity/player/Inventory.java -@@ -643,6 +643,8 @@ public class Inventory implements Container, Nameable { +@@ -649,6 +649,8 @@ public class Inventory implements Container, Nameable { } public boolean contains(ItemStack stack) { @@ -43,7 +43,7 @@ index 6e66141dca61f777b354854b5d0bac2570b8bf3b..06104744bb778a922adaaee2d91252cd Iterator iterator = this.compartments.iterator(); while (iterator.hasNext()) { -@@ -679,25 +681,34 @@ public class Inventory implements Container, Nameable { +@@ -685,25 +687,34 @@ public class Inventory implements Container, Nameable { return false; } @@ -89,24 +89,24 @@ index 6e66141dca61f777b354854b5d0bac2570b8bf3b..06104744bb778a922adaaee2d91252cd public void replaceWith(Inventory other) { for (int i = 0; i < this.getContainerSize(); ++i) { diff --git a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java -index 17f33c83c6033564d6bf4fbd388b0b847c68adb3..73e546cc828850365dae0131bf8d997f58473823 100644 +index ae321b3b8d98e42ef07fd1f0f738c1a2b428f6db..b15b0c8057e61c6aef05c0865e2c3e06adcf938b 100644 --- a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java +++ b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java -@@ -295,7 +295,7 @@ public class MapItemSavedData extends SavedData { +@@ -294,7 +294,7 @@ public class MapItemSavedData extends SavedData { Predicate predicate = MapItemSavedData.mapMatcher(stack); - if (!player.getInventory().contains(predicate)) { -+ if (!player.getInventory().containsMatchedMap(predicate)) { ++ if (!player.getInventory().containsMatchedMap(predicate)) { // Gale - Airplane - remove iterators from Inventory#contains this.removeDecoration(player.getName().getString()); } @@ -303,7 +303,7 @@ public class MapItemSavedData extends SavedData { - MapItemSavedData.HoldingPlayer worldmap_worldmaphumantracker1 = (MapItemSavedData.HoldingPlayer) this.carriedBy.get(i); - String s = worldmap_worldmaphumantracker1.player.getName().getString(); + Player entityhuman1 = worldmap_worldmaphumantracker1.player; + String s = entityhuman1.getName().getString(); -- if (!worldmap_worldmaphumantracker1.player.isRemoved() && (worldmap_worldmaphumantracker1.player.getInventory().contains(predicate) || stack.isFramed())) { -+ if (!worldmap_worldmaphumantracker1.player.isRemoved() && (worldmap_worldmaphumantracker1.player.getInventory().containsMatchedMap(predicate) || stack.isFramed())) { - if (!stack.isFramed() && worldmap_worldmaphumantracker1.player.level().dimension() == this.dimension && this.trackingPosition) { - this.addDecoration(MapDecorationTypes.PLAYER, worldmap_worldmaphumantracker1.player.level(), s, worldmap_worldmaphumantracker1.player.getX(), worldmap_worldmaphumantracker1.player.getZ(), (double) worldmap_worldmaphumantracker1.player.getYRot(), (Component) null); +- if (!entityhuman1.isRemoved() && (entityhuman1.getInventory().contains(predicate) || stack.isFramed())) { ++ if (!entityhuman1.isRemoved() && (entityhuman1.getInventory().containsMatchedMap(predicate) || stack.isFramed())) { // Gale - Airplane - remove iterators from Inventory#contains + if (!stack.isFramed() && entityhuman1.level().dimension() == this.dimension && this.trackingPosition) { + this.addDecoration(MapDecorationTypes.PLAYER, entityhuman1.level(), s, entityhuman1.getX(), entityhuman1.getZ(), (double) entityhuman1.getYRot(), (Component) null); } diff --git a/patches/server/0021-Check-targeting-range-before-getting-visibility.patch b/patches/server/0021-Check-targeting-range-before-getting-visibility.patch index e9f9fb1..b070364 100644 --- a/patches/server/0021-Check-targeting-range-before-getting-visibility.patch +++ b/patches/server/0021-Check-targeting-range-before-getting-visibility.patch @@ -31,26 +31,26 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . 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 aecb0ad814586bfc5e56755ee14379a69388b38c..4addcfe248dd4705be7e67551b258ce86c57e194 100644 +index 52982c1e6a4da36392569c791853279f5f9ac31a..b51a04d3e006bc770006cff790791bc0f6bee77d 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 -@@ -76,9 +76,18 @@ public class TargetingConditions { +@@ -75,9 +75,18 @@ public class TargetingConditions { } if (this.range > 0.0) { -- double d = this.testInvisible ? targetEntity.getVisibilityPercent(baseEntity) : 1.0; -- double e = Math.max((this.useFollowRange ? this.getFollowRange(baseEntity) : this.range) * d, 2.0); // Paper - Fix MC-145656 +- double d = this.testInvisible ? target.getVisibilityPercent(tester) : 1.0; +- double e = Math.max(this.range * d, 2.0); + // 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; + double f = tester.distanceToSqr(target.getX(), target.getY(), target.getZ()); ++ double followRangeRaw = 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 - Fix MC-145656 ++ double d = this.testInvisible ? target.getVisibilityPercent(tester) : 1.0; ++ double e = Math.max(followRangeRaw * d, 2.0); + // Gale end - Airplane - check targeting range before getting visibility if (f > e * e) { return false; diff --git a/patches/server/0022-Print-stack-trace-for-plugins-not-shutting-down-task.patch b/patches/server/0022-Print-stack-trace-for-plugins-not-shutting-down-task.patch index 715ca95..3e5f891 100644 --- a/patches/server/0022-Print-stack-trace-for-plugins-not-shutting-down-task.patch +++ b/patches/server/0022-Print-stack-trace-for-plugins-not-shutting-down-task.patch @@ -31,10 +31,10 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index b1c1e600100ac31ecb20473b8ad2853676dff84a..84b8de571361f2087ac5106726c9e69377183089 100644 +index 9009da78ba2d7751b974123ce76a37af98189b6a..b7342208b5d72f82c6d095cac379356d57f97486 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -1166,6 +1166,13 @@ public final class CraftServer implements Server { +@@ -1168,6 +1168,13 @@ public final class CraftServer implements Server { plugin.getPluginMeta().getDisplayName(), "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." )); diff --git a/patches/server/0024-Cache-on-climbable-check.patch b/patches/server/0023-Cache-on-climbable-check.patch similarity index 83% rename from patches/server/0024-Cache-on-climbable-check.patch rename to patches/server/0023-Cache-on-climbable-check.patch index a69dd04..5954a8f 100644 --- a/patches/server/0024-Cache-on-climbable-check.patch +++ b/patches/server/0023-Cache-on-climbable-check.patch @@ -31,18 +31,10 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index 2463746163a8e08527fc55beb467aedf4ed5cd68..ec25ae1dbbf623025c3e7e14143b9b6b60a68ff6 100644 +index 74ee200081f372e66e1d2a5a291fff42758ba965..4c299ce47caafaa233355cb71aab8d622008f346 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -157,7 +157,6 @@ import org.bukkit.event.entity.EntityTeleportEvent; - import org.bukkit.event.player.PlayerItemConsumeEvent; - // CraftBukkit end - --import co.aikar.timings.MinecraftTimings; // Paper - - public abstract class LivingEntity extends Entity implements Attackable { - -@@ -2063,6 +2062,20 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -2109,6 +2109,20 @@ public abstract class LivingEntity extends Entity implements Attackable { return this.lastClimbablePos; } @@ -64,10 +56,10 @@ index 2463746163a8e08527fc55beb467aedf4ed5cd68..ec25ae1dbbf623025c3e7e14143b9b6b if (this.isSpectator()) { return false; diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java -index bf2d18f74b0f0da7c3c30310c74224a1c0853564..f83c2b35cc279666686be3af558473b5d93bf7cd 100644 +index 133bcf639a45bd7fa1a2d02410ea3e8568265007..f8a57248da47cf8cfb47dc92b36c191338c8d598 100644 --- a/src/main/java/org/spigotmc/ActivationRange.java +++ b/src/main/java/org/spigotmc/ActivationRange.java -@@ -298,7 +298,7 @@ public class ActivationRange +@@ -294,7 +294,7 @@ public class ActivationRange if ( entity instanceof LivingEntity ) { LivingEntity living = (LivingEntity) entity; diff --git a/patches/server/0023-Improve-fluid-direction-caching.patch b/patches/server/0023-Improve-fluid-direction-caching.patch deleted file mode 100644 index 65f0f6a..0000000 --- a/patches/server/0023-Improve-fluid-direction-caching.patch +++ /dev/null @@ -1,276 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Martijn Muijsers -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) -Gale - https://galemc.org - -This patch is based on the following patch: -"Improve fluid direction caching" -By: Paul Sauve -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 . - -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..bf6a36c933b686f0e34591dff3d43b3797c29b2b ---- /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: -+ *
    -+ *
  • Store 200 entries
  • -+ *
  • Look for the flag in the cache
  • -+ *
  • If it exists, move to front of cache
  • -+ *
  • If it doesn't exist, remove last entry in cache and insert in front
  • -+ *
-+ * This class accomplishes something similar, however has a few different -+ * requirements put into place to make this more optimize: -+ *
    -+ *
  • -+ * maxDistance is the most amount of entries to be checked, instead -+ * of having to check the entire list. -+ *
  • -+ *
  • -+ * 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. -+ *
  • -+ *
-+ * 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 { -+ -+ private static class FluidDirectionEntry { -+ 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 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 1c0712295695727ee9c4d430d4157b8e17cbd71f..0eac7bc0c56ac17c900737271a965cfc1ccd03d2 100644 ---- a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java -+++ b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java -@@ -45,6 +45,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> OCCLUSION_CACHE = ThreadLocal.withInitial(() -> { - Object2ByteLinkedOpenHashMap object2bytelinkedopenhashmap = new Object2ByteLinkedOpenHashMap(200) { - protected void rehash(int i) {} -@@ -53,6 +55,14 @@ public abstract class FlowingFluid extends Fluid { - object2bytelinkedopenhashmap.defaultReturnValue((byte) 127); - return object2bytelinkedopenhashmap; - }); -+ */ -+ -+ private static final ThreadLocal> 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 shapes = Maps.newIdentityHashMap(); - - public FlowingFluid() {} -@@ -240,6 +250,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()) { -@@ -247,9 +259,16 @@ public abstract class FlowingFluid extends Fluid { - } else { - object2bytelinkedopenhashmap = null; - } -+ */ -+ gg.airplane.structs.FluidDirectionCache 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); -@@ -260,11 +279,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(); -@@ -272,6 +302,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; - } diff --git a/patches/server/0025-Make-EntityCollisionContext-a-live-representation.patch b/patches/server/0024-Make-EntityCollisionContext-a-live-representation.patch similarity index 90% rename from patches/server/0025-Make-EntityCollisionContext-a-live-representation.patch rename to patches/server/0024-Make-EntityCollisionContext-a-live-representation.patch index 9dfbedb..070ee51 100644 --- a/patches/server/0025-Make-EntityCollisionContext-a-live-representation.patch +++ b/patches/server/0024-Make-EntityCollisionContext-a-live-representation.patch @@ -40,10 +40,10 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . 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 88a4a72bb390947dc17e5da09a99b2d1b3ac4621..9343195e5e7444a1926db656707df961a5b8ea55 100644 +index a94fbedaf0297c006c561a145913bb91f2d0a817..121d155be5213cb4d9a4258b4b9a27ca3f335209 100644 --- a/src/main/java/net/minecraft/world/phys/shapes/EntityCollisionContext.java +++ b/src/main/java/net/minecraft/world/phys/shapes/EntityCollisionContext.java -@@ -17,23 +17,33 @@ public class EntityCollisionContext implements CollisionContext { +@@ -19,23 +19,33 @@ public class EntityCollisionContext implements CollisionContext { return defaultValue; } }; @@ -71,14 +71,14 @@ index 88a4a72bb390947dc17e5da09a99b2d1b3ac4621..9343195e5e7444a1926db656707df961 } @Deprecated - protected EntityCollisionContext(Entity entity) { + protected EntityCollisionContext(Entity entity, boolean collidesWithFluid) { + // Gale start - Airplane - make EntityCollisionContext a live representation - remove unneeded things + /* this( entity.isDescending(), entity.getY(), -@@ -41,26 +51,41 @@ public class EntityCollisionContext implements CollisionContext { - entity instanceof LivingEntity ? ((LivingEntity)entity)::canStandOnFluid : fluidState -> false, +@@ -43,16 +53,31 @@ public class EntityCollisionContext implements CollisionContext { + collidesWithFluid ? state -> true : (entity instanceof LivingEntity ? ((LivingEntity)entity)::canStandOnFluid : state -> false), entity ); + */ @@ -110,6 +110,9 @@ index 88a4a72bb390947dc17e5da09a99b2d1b3ac4621..9343195e5e7444a1926db656707df961 + // Gale end - Airplane - make EntityCollisionContext a live representation } + @Override +@@ -62,12 +87,12 @@ public class EntityCollisionContext implements CollisionContext { + @Override public boolean isDescending() { - return this.descending; diff --git a/patches/server/0026-Better-checking-for-useless-move-packets.patch b/patches/server/0025-Better-checking-for-useless-move-packets.patch similarity index 52% rename from patches/server/0026-Better-checking-for-useless-move-packets.patch rename to patches/server/0025-Better-checking-for-useless-move-packets.patch index 4d3cfcd..c1df304 100644 --- a/patches/server/0026-Better-checking-for-useless-move-packets.patch +++ b/patches/server/0025-Better-checking-for-useless-move-packets.patch @@ -31,22 +31,22 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java -index 8ea2f24695f5dad55e21f238b69442513e7a90c6..20b5a81d50397438b3200322f31b62db44ebdb3b 100644 +index 90eb4927fa51ce3df86aa7b6c71f49150a03e337..bf813380d5767ce05cdeca7084e6f19aa106803a 100644 --- a/src/main/java/net/minecraft/server/level/ServerEntity.java +++ b/src/main/java/net/minecraft/server/level/ServerEntity.java -@@ -193,6 +193,7 @@ public class ServerEntity { - boolean flag6 = k < -32768L || k > 32767L || l < -32768L || l > 32767L || i1 < -32768L || i1 > 32767L; +@@ -207,6 +207,7 @@ public class ServerEntity { + boolean flag5 = i < -32768L || i > 32767L || j < -32768L || j > 32767L || k < -32768L || k > 32767L; - if (!this.forceStateResync && !flag6 && this.teleportDelay <= 400 && !this.wasRiding && this.wasOnGround == this.entity.onGround()) { // Paper - fix desync when a player is added to the tracker -+ 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.onGround()); -@@ -206,6 +207,7 @@ public class ServerEntity { - flag4 = true; - flag5 = true; - } -+ } // Gale - Airplane - better checking for useless move packets - } else { - this.wasOnGround = this.entity.onGround(); - this.teleportDelay = 0; + if (!this.forceStateResync && !flag5 && this.teleportDelay <= 400 && !this.wasRiding && this.wasOnGround == this.entity.onGround()) { // Paper - fix desync when a player is added to the tracker ++ if (flag2 || flag || this.entity instanceof AbstractArrow) { // Gale - Airplane - better checking for useless move packets + if ((!flag2 || !flag) && !(this.entity instanceof AbstractArrow)) { + if (flag2) { + packet1 = new ClientboundMoveEntityPacket.Pos(this.entity.getId(), (short) ((int) i), (short) ((int) j), (short) ((int) k), this.entity.onGround()); +@@ -220,6 +221,7 @@ public class ServerEntity { + flag3 = true; + flag4 = true; + } ++ } // Gale - Airplane - better checking for useless move packets + } else { + this.wasOnGround = this.entity.onGround(); + this.teleportDelay = 0; diff --git a/patches/server/0029-Block-goal-does-not-load-chunks.patch b/patches/server/0026-Block-goal-does-not-load-chunks.patch similarity index 100% rename from patches/server/0029-Block-goal-does-not-load-chunks.patch rename to patches/server/0026-Block-goal-does-not-load-chunks.patch diff --git a/patches/server/0027-Inline-level-height.patch b/patches/server/0027-Inline-level-height.patch deleted file mode 100644 index 4b49f4a..0000000 --- a/patches/server/0027-Inline-level-height.patch +++ /dev/null @@ -1,66 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Martijn Muijsers -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) -Gale - https://galemc.org - -This patch is based on the following patch: -"Ensure level height is inlined" -By: Paul Sauve -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 . - -diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index abebc41e69a41cbf940ffd10dae4815202b525dc..a48b1639ffa83ae2d1e614d32a339f08366da57c 100644 ---- a/src/main/java/net/minecraft/world/level/Level.java -+++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -685,6 +685,15 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl - } - // Paper end - optimise random ticking - -+ // Gale start - Airplane - inline level height -+ private final int minBuildHeight, levelHeightAccessorMinSection, height, maxBuildHeight, levelHeightAccessorMaxSection; -+ @Override public final int getMaxBuildHeight() { return this.maxBuildHeight; } -+ @Override public final int getMinSection() { return this.levelHeightAccessorMinSection; } -+ @Override public final int getMaxSection() { return this.levelHeightAccessorMaxSection; } -+ @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 resourcekey, RegistryAccess iregistrycustom, Holder holder, 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 paperWorldConfigCreator, java.util.function.Function galeWorldConfigCreator, java.util.concurrent.Executor executor) { // Paper - create paper world config & Anti-Xray // Gale - Gale configuration // Gale - Purpur - remove vanilla profiler - this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot - this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper - create paper world config -@@ -704,6 +713,13 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl - this.dimensionTypeRegistration = holder; - final DimensionType dimensionmanager = (DimensionType) holder.value(); - -+ // Gale start - Airplane - inline level height -+ this.minBuildHeight = LevelAccessor.super.getMinBuildHeight(); -+ this.levelHeightAccessorMinSection = LevelAccessor.super.getMinSection(); -+ this.height = LevelAccessor.super.getHeight(); -+ this.maxBuildHeight = LevelAccessor.super.getMaxBuildHeight(); -+ this.levelHeightAccessorMaxSection = LevelAccessor.super.getMaxSection(); -+ // Gale end - Airplane - inline level height - this.dimension = resourcekey; - this.isClientSide = flag; - if (dimensionmanager.coordinateScale() != 1.0D) { diff --git a/patches/server/0030-Reduce-entity-allocations.patch b/patches/server/0027-Reduce-entity-allocations.patch similarity index 94% rename from patches/server/0030-Reduce-entity-allocations.patch rename to patches/server/0027-Reduce-entity-allocations.patch index dcfbf94..19dbe4e 100644 --- a/patches/server/0030-Reduce-entity-allocations.patch +++ b/patches/server/0027-Reduce-entity-allocations.patch @@ -31,7 +31,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 3a5f832578abbf3ead4d5bd99eee1438a2e74b35..e26d98cb34e9fd2c599ce72d8c83f1431f4bf991 100644 +index ca4ce69ecad2291d196c4126e4cbde69554dd50c..5e939e377c35fe69d66ecb79266dcfc429e34f5c 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java @@ -445,6 +445,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -43,7 +43,7 @@ index 3a5f832578abbf3ead4d5bd99eee1438a2e74b35..e26d98cb34e9fd2c599ce72d8c83f143 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 69992ebc999ea3ff9e47e4e049bcc514c01150ca..f9f6745d45aaba4a7106f80d403dcf9ae40e1d6c 100644 +index 94d04a20f97405e02d7cccaabadc7a7e86e336f7..edd791da70fd7e18c42133dcd771f212cb25abab 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 @@ -23,9 +23,11 @@ public class AttributeMap { diff --git a/patches/server/0028-Remove-streams-and-iterators-from-range-check.patch b/patches/server/0028-Remove-streams-and-iterators-from-range-check.patch deleted file mode 100644 index 61dee1c..0000000 --- a/patches/server/0028-Remove-streams-and-iterators-from-range-check.patch +++ /dev/null @@ -1,77 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Martijn Muijsers -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) -Gale - https://galemc.org - -This patch is based on the following patch: -"Remove streams and iterators from range check" -By: Paul Sauve -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 . - -diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java -index 62bd7523e0d7d2dfdce1ee9edb2249c755f1ade3..a9b6f3ceb45ecd6bcc6d6acc097a5d12aeaae620 100644 ---- a/src/main/java/net/minecraft/server/level/ChunkMap.java -+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java -@@ -1275,8 +1275,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 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()) { -@@ -1288,6 +1310,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); - } diff --git a/todos.txt b/todos.txt new file mode 100644 index 0000000..3d36553 --- /dev/null +++ b/todos.txt @@ -0,0 +1,4 @@ +## TODOs +Check chunk sys threads in gale metrics +Check to use simple random by default in tick chunk opt (add back move random patch) +check fluid cache \ No newline at end of file