diff --git a/build.gradle.kts b/build.gradle.kts index c16e4dea..c4cc6c4e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -62,13 +62,13 @@ paperweight { remapRepo.set("https://maven.fabricmc.net/") decompileRepo.set("https://maven.quiltmc.org/") - useStandardUpstream("Pufferfish") { - url.set(github("pufferfish-gg", "Pufferfish")) - ref.set(providers.gradleProperty("pufferfishCommit")) + useStandardUpstream("Gale") { + url.set(github("GaleMC", "Gale")) + ref.set(providers.gradleProperty("galeCommit")) withStandardPatcher { - apiSourceDirPath.set("pufferfish-api") - serverSourceDirPath.set("pufferfish-server") + apiSourceDirPath.set("gale-api") + serverSourceDirPath.set("gale-server") apiPatchDir.set(layout.projectDirectory.dir("patches/api")) apiOutputDir.set(layout.projectDirectory.dir("Leaf-API")) diff --git a/gradle.properties b/gradle.properties index 9fbbc0c7..24434bdd 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,7 @@ group = org.dreeam.leaf version = 1.19.3-R0.1-SNAPSHOT -pufferfishCommit = 315157103cc37bf5381cbd19ab43db7f19e6b347 +galeCommit = f1503a7be737f1d0c2da33b3138dad4e786541a3 org.gradle.caching = true org.gradle.parallel = true diff --git a/patches/api/0001-Leaf-config-files.patch b/patches/api/0001-Leaf-config-files.patch index e1c0b1d2..4ad28a38 100644 --- a/patches/api/0001-Leaf-config-files.patch +++ b/patches/api/0001-Leaf-config-files.patch @@ -5,11 +5,11 @@ Subject: [PATCH] Leaf config files diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java -index 2204336d8800311b65e894739ab1b27273e7c6f2..39808c0cc23a97f707366378f28ba64b80e6acbb 100644 +index 4c519dbd706cac728f31a7ccd99cc1e165812599..425ee736dbaacc0e633740b27723b9f62007be44 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java -@@ -1971,6 +1971,14 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi - } +@@ -2014,6 +2014,14 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi + // Paper end + // Leaf start diff --git a/patches/api/0002-Bump-Dependencies.patch b/patches/api/0002-Bump-Dependencies.patch index 3c1fbd8d..e5da7574 100644 --- a/patches/api/0002-Bump-Dependencies.patch +++ b/patches/api/0002-Bump-Dependencies.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Bump Dependencies diff --git a/build.gradle.kts b/build.gradle.kts -index a995ecc3b1d6181c58d5b4a0a6a893178bdc40aa..991698f8daff823d64a09c369e1ee8a8b2023478 100644 +index e19c9544c346e7f505cfdd379be7f8f059d9e53d..3075ae381824f8b46d17f40022f23d58f9e50c12 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -24,14 +24,14 @@ configurations.api { @@ -26,16 +26,14 @@ index a995ecc3b1d6181c58d5b4a0a6a893178bdc40aa..991698f8daff823d64a09c369e1ee8a8 apiAndDocs(platform("net.kyori:adventure-bom:$adventureVersion")) apiAndDocs("net.kyori:adventure-api") apiAndDocs("net.kyori:adventure-text-minimessage") -@@ -39,20 +39,20 @@ dependencies { +@@ -39,19 +39,19 @@ dependencies { apiAndDocs("net.kyori:adventure-text-serializer-legacy") apiAndDocs("net.kyori:adventure-text-serializer-plain") apiAndDocs("net.kyori:adventure-text-logger-slf4j") - api("org.apache.logging.log4j:log4j-api:2.17.1") - api("org.slf4j:slf4j-api:1.8.0-beta4") -- api("io.sentry:sentry:5.4.0") // Pufferfish + api("org.apache.logging.log4j:log4j-api:2.19.0") + api("org.slf4j:slf4j-api:1.8.0-beta4") // Leaf TODO - Bump later, need to fix breaking compatibility -+ api("io.sentry:sentry:6.13.0") // Pufferfish - implementation("org.ow2.asm:asm:9.2") - implementation("org.ow2.asm:asm-commons:9.2") @@ -57,7 +55,7 @@ index a995ecc3b1d6181c58d5b4a0a6a893178bdc40aa..991698f8daff823d64a09c369e1ee8a8 compileOnly(annotations) testCompileOnly(annotations) -@@ -64,8 +64,8 @@ dependencies { +@@ -63,8 +63,8 @@ dependencies { testImplementation("org.apache.commons:commons-lang3:3.12.0") testImplementation("junit:junit:4.13.2") @@ -68,7 +66,7 @@ index a995ecc3b1d6181c58d5b4a0a6a893178bdc40aa..991698f8daff823d64a09c369e1ee8a8 } configure { -@@ -108,9 +108,9 @@ tasks.withType { +@@ -110,9 +110,9 @@ tasks.withType { options.use() options.isDocFilesSubDirs = true options.links( @@ -80,7 +78,7 @@ index a995ecc3b1d6181c58d5b4a0a6a893178bdc40aa..991698f8daff823d64a09c369e1ee8a8 // Paper start //"https://javadoc.io/doc/net.md-5/bungeecord-chat/1.16-R0.4/", // don't link to bungee chat "https://jd.adventure.kyori.net/api/$adventureVersion/", -@@ -147,6 +147,9 @@ val scanJar = tasks.register("scanJarForBadCalls", io.papermc.paperweight.tasks. +@@ -152,6 +152,9 @@ val scanJar = tasks.register("scanJarForBadCalls", io.papermc.paperweight.tasks. jarToScan.set(tasks.jar.flatMap { it.archiveFile }) classpath.from(configurations.compileClasspath) } diff --git a/patches/api/0003-Purpur-Lagging-threshold.patch b/patches/api/0003-Purpur-Lagging-threshold.patch index a6b7dd8b..9a0fe977 100644 --- a/patches/api/0003-Purpur-Lagging-threshold.patch +++ b/patches/api/0003-Purpur-Lagging-threshold.patch @@ -27,14 +27,13 @@ index ac9b690fcccb60b587e5345f12f1383afd0a73a1..0a4320b32485db84a0be16535b406f04 + // Purpur end } diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java -index 39808c0cc23a97f707366378f28ba64b80e6acbb..8eb8a788dc3dbc0d5ac24089a57c730089fd8dbe 100644 +index 425ee736dbaacc0e633740b27723b9f62007be44..236aa2c1841eef6ca723a809b1632894bebf0b67 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java -@@ -2147,4 +2147,13 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi - */ - @NotNull org.bukkit.potion.PotionBrewer getPotionBrewer(); - // Paper end -+ +@@ -2216,4 +2216,12 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi + long getLastTickOversleepTime(); + // Gale end - YAPFA - last tick time - API + + // Purpur start + /** + * Check if server is lagging according to laggy threshold setting diff --git a/patches/api/0008-KTP-Optimize-Spigot-event-bus.patch b/patches/api/0008-KTP-Optimize-Spigot-event-bus.patch index b994fbc2..59b71ac3 100644 --- a/patches/api/0008-KTP-Optimize-Spigot-event-bus.patch +++ b/patches/api/0008-KTP-Optimize-Spigot-event-bus.patch @@ -24,12 +24,12 @@ index 3b3d9642a8d63798dc28f2f8df77f0466451cbff..8d3605f25e97a375971705c737bc7bac } } diff --git a/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/src/main/java/org/bukkit/plugin/SimplePluginManager.java -index c077e7c883613fcb6e559b4e4776e794caa3b363..ba869354adc59db2fc547c481c1ed4d5d0af23b7 100644 +index 7903554958f567c7b566a47fa4b49852a837898e..730394fd53fdaa90133ee399f86e76da8ccc08e6 100644 --- a/src/main/java/org/bukkit/plugin/SimplePluginManager.java +++ b/src/main/java/org/bukkit/plugin/SimplePluginManager.java -@@ -656,11 +656,15 @@ public final class SimplePluginManager implements PluginManager { - @Override - public void callEvent(@NotNull Event event) { +@@ -662,11 +662,15 @@ public final class SimplePluginManager implements PluginManager { + // Gale end - JettPack - skip events without listeners + // Paper - replace callEvent by merging to below method - if (event.isAsynchronous() && server.isPrimaryThread()) { + // KTP start - optimize spigot event bus @@ -43,5 +43,5 @@ index c077e7c883613fcb6e559b4e4776e794caa3b363..ba869354adc59db2fc547c481c1ed4d5 } + // KTP end - optimize spigot event bus - HandlerList handlers = event.getHandlers(); - RegisteredListener[] listeners = handlers.getRegisteredListeners(); + for (RegisteredListener registration : listeners) { + if (!registration.getPlugin().isEnabled()) { diff --git a/patches/api/0009-KeYi-Add-Java19-Support-for-SIMD.patch b/patches/api/0009-KeYi-Add-Java19-Support-for-SIMD.patch deleted file mode 100644 index 4f178a67..00000000 --- a/patches/api/0009-KeYi-Add-Java19-Support-for-SIMD.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com> -Date: Thu, 27 Oct 2022 18:47:33 -0400 -Subject: [PATCH] KeYi: Add Java19 Support for SIMD - -Original license: MIT -Original project: https://github.com/KeYiMC/KeYi - -diff --git a/src/main/java/gg/pufferfish/pufferfish/simd/SIMDChecker.java b/src/main/java/gg/pufferfish/pufferfish/simd/SIMDChecker.java -index ab5fea0b03224bf249352ce340e94704ff713345..42288a065acee7e3181364bfadb26d3c1dc6fdc2 100644 ---- a/src/main/java/gg/pufferfish/pufferfish/simd/SIMDChecker.java -+++ b/src/main/java/gg/pufferfish/pufferfish/simd/SIMDChecker.java -@@ -15,7 +15,7 @@ public class SIMDChecker { - @Deprecated - public static boolean canEnable(Logger logger) { - try { -- if (SIMDDetection.getJavaVersion() != 17 && SIMDDetection.getJavaVersion() != 18 && SIMDDetection.getJavaVersion() != 19) { -+ if (SIMDDetection.getJavaVersion() < 17) { // KeYi - Add Java19 Support for SIMD - return false; - } else { - SIMDDetection.testRun = true; -@@ -36,5 +36,4 @@ public class SIMDChecker { - } catch (NoClassDefFoundError | Exception ignored) {} // Basically, we don't do anything. This lets us detect if it's not functional and disable it. - return false; - } -- - } diff --git a/patches/api/0010-KeYi-Player-Skull-API.patch b/patches/api/0009-KeYi-Player-Skull-API.patch similarity index 90% rename from patches/api/0010-KeYi-Player-Skull-API.patch rename to patches/api/0009-KeYi-Player-Skull-API.patch index a76378ad..7f2f404e 100644 --- a/patches/api/0010-KeYi-Player-Skull-API.patch +++ b/patches/api/0009-KeYi-Player-Skull-API.patch @@ -7,7 +7,7 @@ Original license: MIT Original project: https://github.com/KeYiMC/KeYi diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java -index c68df5e5cc63b26da8623cf27e257ef07a61897d..17683d888d6aa55dcedaca59951aad011af006ed 100644 +index a9f50779740e7fcec98ac8a88742858776a1fe05..ffbdc96d4fad7d603c5510675357ca06e828fb44 100644 --- a/src/main/java/org/bukkit/entity/Player.java +++ b/src/main/java/org/bukkit/entity/Player.java @@ -3,6 +3,9 @@ package org.bukkit.entity; @@ -20,7 +20,7 @@ index c68df5e5cc63b26da8623cf27e257ef07a61897d..17683d888d6aa55dcedaca59951aad01 import com.destroystokyo.paper.ClientOption; // Paper import com.destroystokyo.paper.Title; // Paper import net.kyori.adventure.text.Component; -@@ -2946,4 +2949,23 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM +@@ -2956,4 +2959,23 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM @Override Spigot spigot(); // Spigot end diff --git a/patches/api/0011-Slice-Smooth-Teleports.patch b/patches/api/0010-Slice-Smooth-Teleports.patch similarity index 89% rename from patches/api/0011-Slice-Smooth-Teleports.patch rename to patches/api/0010-Slice-Smooth-Teleports.patch index 68595d2d..0d0146ca 100644 --- a/patches/api/0011-Slice-Smooth-Teleports.patch +++ b/patches/api/0010-Slice-Smooth-Teleports.patch @@ -7,10 +7,10 @@ Original license: MIT Original project: https://github.com/Cryptite/Slice diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java -index 17683d888d6aa55dcedaca59951aad011af006ed..119b97dab3c3477741191a8afdc3b72a0d9bd085 100644 +index ffbdc96d4fad7d603c5510675357ca06e828fb44..989563b2cd8318c7d84ea40a5eacd56a22087289 100644 --- a/src/main/java/org/bukkit/entity/Player.java +++ b/src/main/java/org/bukkit/entity/Player.java -@@ -2809,6 +2809,19 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM +@@ -2819,6 +2819,19 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM String getClientBrandName(); // Paper end diff --git a/patches/api/0012-MikuServer-Fix-threading-issue-in-event-system.patch b/patches/api/0011-MikuServer-Fix-threading-issue-in-event-system.patch similarity index 74% rename from patches/api/0012-MikuServer-Fix-threading-issue-in-event-system.patch rename to patches/api/0011-MikuServer-Fix-threading-issue-in-event-system.patch index a0e459d4..acc36410 100644 --- a/patches/api/0012-MikuServer-Fix-threading-issue-in-event-system.patch +++ b/patches/api/0011-MikuServer-Fix-threading-issue-in-event-system.patch @@ -7,7 +7,7 @@ Original license: MIT Original project: https://github.com/MikuMC/MikuServer diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java -index 8eb8a788dc3dbc0d5ac24089a57c730089fd8dbe..b4c6a3d57ea21aa9ebc05f6aaf6a1b750b04545c 100644 +index 236aa2c1841eef6ca723a809b1632894bebf0b67..3fa5b8740f6c5cbfd55dfc908225301d6d292c0b 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java @@ -113,6 +113,8 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi @@ -20,10 +20,10 @@ index 8eb8a788dc3dbc0d5ac24089a57c730089fd8dbe..b4c6a3d57ea21aa9ebc05f6aaf6a1b75 /** * Gets the version of game this server implements diff --git a/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/src/main/java/org/bukkit/plugin/SimplePluginManager.java -index ba869354adc59db2fc547c481c1ed4d5d0af23b7..d7064142c0aafbe17af263c4ecad6f1e879bb9d7 100644 +index 730394fd53fdaa90133ee399f86e76da8ccc08e6..14d05c364fe11941045e1f24bcc00c0e78d34fe7 100644 --- a/src/main/java/org/bukkit/plugin/SimplePluginManager.java +++ b/src/main/java/org/bukkit/plugin/SimplePluginManager.java -@@ -648,6 +648,8 @@ public final class SimplePluginManager implements PluginManager { +@@ -646,6 +646,8 @@ public final class SimplePluginManager implements PluginManager { } private void fireEvent(Event event) { callEvent(event); } // Paper - support old method incase plugin uses reflection @@ -32,7 +32,7 @@ index ba869354adc59db2fc547c481c1ed4d5d0af23b7..d7064142c0aafbe17af263c4ecad6f1e /** * Calls an event with the given details. * -@@ -666,6 +668,17 @@ public final class SimplePluginManager implements PluginManager { +@@ -672,6 +674,19 @@ public final class SimplePluginManager implements PluginManager { } // KTP end - optimize spigot event bus @@ -47,10 +47,12 @@ index ba869354adc59db2fc547c481c1ed4d5d0af23b7..d7064142c0aafbe17af263c4ecad6f1e + } + + private void callEventInternal(Event event) { - HandlerList handlers = event.getHandlers(); - RegisteredListener[] listeners = handlers.getRegisteredListeners(); - -@@ -687,7 +700,7 @@ public final class SimplePluginManager implements PluginManager { ++ HandlerList handlers = event.getHandlers(); ++ RegisteredListener[] listeners = handlers.getRegisteredListeners(); + for (RegisteredListener registration : listeners) { + if (!registration.getPlugin().isEnabled()) { + continue; +@@ -690,7 +705,7 @@ public final class SimplePluginManager implements PluginManager { plugin.getDescription().getAuthors(), plugin.getDescription().getFullName(), ex.getMessage() @@ -58,4 +60,4 @@ index ba869354adc59db2fc547c481c1ed4d5d0af23b7..d7064142c0aafbe17af263c4ecad6f1e + )); } } catch (Throwable ex) { - gg.pufferfish.pufferfish.sentry.SentryContext.setEventContext(event, registration); // Pufferfish + // Paper start - error reporting diff --git a/patches/server/0001-Rebrand.patch b/patches/server/0001-Rebrand.patch index 8316e8d4..f74361f3 100644 --- a/patches/server/0001-Rebrand.patch +++ b/patches/server/0001-Rebrand.patch @@ -5,679 +5,146 @@ Subject: [PATCH] Rebrand diff --git a/build.gradle.kts b/build.gradle.kts -index 04a1e3c9619b41f429bd598d55c9e0b5abaff920..c8f031712006d95c59027791be1bdcdc2bd836c4 100644 +index e01986477360b1dbe991af6667e726e8ac656246..ff8e0b3ed28ed0c02e436f19945e1b76d2d5333f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts -@@ -7,7 +7,7 @@ plugins { - } - +@@ -9,7 +9,7 @@ plugins { dependencies { -- implementation(project(":pufferfish-api")) // Pufferfish // Paper -+ implementation(project(":leaf-api")) // Paper // Pufferfish // Leaf - // Pufferfish start - implementation("io.papermc.paper:paper-mojangapi:1.19.2-R0.1-SNAPSHOT") { + // Gale start - project setup + // Depend on own API +- implementation(project(":gale-api")) ++ implementation(project(":leaf-api")) // Leaf + // Depend on Paper MojangAPI + implementation("io.papermc.paper:paper-mojangapi:1.19.3-R0.1-SNAPSHOT") { exclude("io.papermc.paper", "paper-api") -@@ -81,7 +81,7 @@ tasks.jar { +@@ -79,7 +79,7 @@ tasks.jar { attributes( "Main-Class" to "org.bukkit.craftbukkit.Main", "Implementation-Title" to "CraftBukkit", -- "Implementation-Version" to "git-Pufferfish-$implementationVersion", // Pufferfish -+ "Implementation-Version" to "git-Leaf-$implementationVersion", // Pufferfish // Leaf +- "Implementation-Version" to "git-Gale-$implementationVersion", // Gale - branding changes ++ "Implementation-Version" to "git-Leaf-$implementationVersion", // Gale - branding changes // Leaf "Implementation-Vendor" to date, // Paper "Specification-Title" to "Bukkit", "Specification-Version" to project.version, diff --git a/src/main/java/com/destroystokyo/paper/console/PaperConsole.java b/src/main/java/com/destroystokyo/paper/console/PaperConsole.java -index c5d5648f4ca603ef2b1df723b58f9caf4dd3c722..bf670b956b20d670f84f1ef76badaae7f0c20e5b 100644 +index e45e6b44b2a8f2cdae6e0048a812b92126aa17ca..b5f3f213da8a40d5184098af017c8e2669c3e58c 100644 --- a/src/main/java/com/destroystokyo/paper/console/PaperConsole.java +++ b/src/main/java/com/destroystokyo/paper/console/PaperConsole.java @@ -17,7 +17,7 @@ public final class PaperConsole extends SimpleTerminalConsole { @Override protected LineReader buildReader(LineReaderBuilder builder) { builder -- .appName("Paper") -+ .appName("Leaf") // Leaf +- .appName("Gale") // Gale - branding changes ++ .appName("Leaf") // Gale - branding changes // Leaf .variable(LineReader.HISTORY_FILE, java.nio.file.Paths.get(".console_history")) .completer(new ConsoleCommandCompleter(this.server)) .option(LineReader.Option.COMPLETE_IN_WORD, true); diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 68d16efaf9c2d997afabadcf1ee24c5de685b5b3..c69cb21f2ccf0f93a7ec17d4ee1ddb0ba5cfa5b2 100644 +index fe702a042cb132987e5135d2ed855484f9cef686..51704170ca171440e198a51b7fba563dca8debb6 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -924,7 +924,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop // Paper - Paper > // Spigot - Spigot > // CraftBukkit - cb > vanilla! -+ return "Leaf"; // Leaf - Leaf > // Pufferfish - Pufferfish > // Paper - Paper > // Spigot - Spigot > // CraftBukkit - cb > vanilla! +- return "Gale"; // Gale - branding changes - Gale > // Paper - Paper > // Spigot - Spigot > // CraftBukkit - cb > vanilla! ++ return "Leaf"; // Leaf - Leaf > // Gale - branding changes - Gale > // Paper - Paper > // Spigot - Spigot > // CraftBukkit - cb > vanilla! } public SystemReport fillSystemReport(SystemReport details) { diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 277e8a03ab270eabb6b8c31d0076f3310c91eef2..07b40f503358987339937bb8db5a3ee54c1b08c8 100644 +index a7bb3275b2da8308696b18fb527514f9c4859d35..7b92f58c01234ef44cfe5d2e0806a7718f0e61d8 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -261,7 +261,7 @@ import javax.annotation.Nullable; // Paper +@@ -266,7 +266,7 @@ import javax.annotation.Nullable; // Paper import javax.annotation.Nonnull; // Paper public final class CraftServer implements Server { -- private final String serverName = "Pufferfish"; // Paper // Pufferfish -+ private final String serverName = "Leaf"; // Paper // Pufferfish // Leaf +- private final String serverName = "Gale"; // Paper // Gale - branding changes ++ private final String serverName = "Leaf"; // Paper // Gale - branding changes // Leaf private final String serverVersion; private final String bukkitVersion = Versioning.getBukkitVersion(); private final Logger logger = Logger.getLogger("Minecraft"); diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java -index cdefb2025eedea7e204d70d568adaf1c1ec4c03c..38920d680d9b0d81013dcf16ce3dd7271eeafe4c 100644 +index 3997a7fec43e05b455644b4d58c68995fad541f4..1933207eb01305ff41822560c5987376b366133f 100644 --- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java +++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java @@ -504,7 +504,7 @@ public class CraftScheduler implements BukkitScheduler { this.parsePending(); } else { //this.debugTail = this.debugTail.setNext(new CraftAsyncDebugger(currentTick + CraftScheduler.RECENT_TICKS, task.getOwner(), task.getTaskClass())); // Paper -- task.getOwner().getLogger().log(Level.SEVERE, "Unexpected Async Task in the Sync Scheduler. Report this to Paper"); // Paper -+ task.getOwner().getLogger().log(Level.SEVERE, "Unexpected Async Task in the Sync Scheduler. Report this to Leaf"); // Paper // Leaf +- task.getOwner().getLogger().log(Level.SEVERE, "Unexpected Async Task in the Sync Scheduler. Report this to Gale"); // Paper // Gale - branding changes ++ task.getOwner().getLogger().log(Level.SEVERE, "Unexpected Async Task in the Sync Scheduler. Report this to Leaf"); // Paper // Gale - branding changes // Leaf // 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/Versioning.java b/src/main/java/org/bukkit/craftbukkit/util/Versioning.java -index 80553face9c70c2a3d897681e7761df85b22d464..3e14c02c2ed3d687c866087bf7477918f45e3719 100644 +index 0b5979723bb30f9011ac64c36d894aa41713ec9b..17e3ee3a73a2347e9f0baa0ed1640a3b0e75ed16 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java +++ b/src/main/java/org/bukkit/craftbukkit/util/Versioning.java @@ -11,7 +11,7 @@ public final class Versioning { public static String getBukkitVersion() { String result = "Unknown-Version"; -- InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("META-INF/maven/gg.pufferfish.pufferfish/pufferfish-api/pom.properties"); // Pufferfish -+ InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("META-INF/maven/org.dreeam.leaf/leaf-api/pom.properties"); // Pufferfish // Leaf +- InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("META-INF/maven/org.galemc.gale/gale-api/pom.properties"); // Gale - branding changes ++ InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("META-INF/maven/org.dreeam.leaf/leaf-api/pom.properties"); // Gale - branding changes // Leaf Properties properties = new Properties(); if (stream != null) { diff --git a/src/main/java/org/spigotmc/WatchdogThread.java b/src/main/java/org/spigotmc/WatchdogThread.java -index e9fa7faaa4451e36b3908cbcbbe0baf213abde96..6466e8bd54b38e4f432101c6d1a397db1066d341 100644 +index bcb144ec4a836b8b32f60726bcbee218a4f62742..9ab8f897471258383623cfe3ca9ff591ca40a56a 100644 --- a/src/main/java/org/spigotmc/WatchdogThread.java +++ b/src/main/java/org/spigotmc/WatchdogThread.java -@@ -155,14 +155,14 @@ public final class WatchdogThread extends io.papermc.paper.util.TickThread // Pa - if (isLongTimeout) { - // Paper end - log.log( Level.SEVERE, "------------------------------" ); -- log.log( Level.SEVERE, "The server has stopped responding! This is (probably) not a Paper bug." ); // Paper -+ log.log( Level.SEVERE, "The server has stopped responding! This is (probably) not a Leaf bug." ); // Paper // Leaf +@@ -161,15 +161,15 @@ public final class WatchdogThread extends ServerThread // Paper - rewrite chunk + We do not want people to report thread issues to Paper, + but we do want people to report thread issues to Gale. + */ +- log.log( Level.SEVERE, "The server has stopped responding! This is (probably) not a Paper bug. This could be a Gale bug." ); // Paper ++ log.log( Level.SEVERE, "The server has stopped responding! This is (probably) not a Paper bug. This could be a Leaf bug." ); // Paper // Leaf + // Gale end - branding changes log.log( Level.SEVERE, "If you see a plugin in the Server thread dump below, then please report it to that author" ); log.log( Level.SEVERE, "\t *Especially* if it looks like HTTP or MySQL operations are occurring" ); log.log( Level.SEVERE, "If you see a world save or edit, then it means you did far more than your server can handle at once" ); log.log( Level.SEVERE, "\t If this is the case, consider increasing timeout-time in spigot.yml but note that this will replace the crash with LARGE lag spikes" ); -- log.log( Level.SEVERE, "If you are unsure or still think this is a Paper bug, please report this to https://github.com/PaperMC/Paper/issues" ); -+ log.log( Level.SEVERE, "If you are unsure or still think this is a Leaf bug, please report this to https://github.com/Winds-Studio/Leaf/issues" ); // Leaf +- log.log( Level.SEVERE, "If you are unsure or think this is a Gale bug, please report this to https://github.com/GaleMC/Gale/issues - and if you think this is a Paper bug, please report this to https://github.com/PaperMC/Paper/issues" ); // Gale - branding changes ++ log.log( Level.SEVERE, "If you are unsure or think this is a Leaf bug, please report this to https://github.com/Winds-Studio/Leaf/issues - and if you think this is a Paper bug, please report this to https://github.com/PaperMC/Paper/issues" ); // Gale - branding changes // Leaf log.log( Level.SEVERE, "Be sure to include ALL relevant console errors and Minecraft crash reports" ); -- log.log( Level.SEVERE, "Paper version: " + Bukkit.getServer().getVersion() ); -+ log.log( Level.SEVERE, "Leaf version: " + Bukkit.getServer().getVersion() ); // Leaf +- log.log( Level.SEVERE, "Gale version: " + Bukkit.getServer().getVersion() ); // Gale - branding changes ++ log.log( Level.SEVERE, "Leaf version: " + Bukkit.getServer().getVersion() ); // Gale - branding changes // Leaf // if ( net.minecraft.world.level.Level.lastPhysicsProblem != null ) { -@@ -185,12 +185,12 @@ public final class WatchdogThread extends io.papermc.paper.util.TickThread // Pa - // Paper end - } else - { -- log.log(Level.SEVERE, "--- DO NOT REPORT THIS TO PAPER - THIS IS NOT A BUG OR A CRASH - " + Bukkit.getServer().getVersion() + " ---"); -+ log.log(Level.SEVERE, "--- DO NOT REPORT THIS TO LEAF - THIS IS NOT A BUG OR A CRASH - " + Bukkit.getServer().getVersion() + " ---"); // Leaf +@@ -197,13 +197,13 @@ public final class WatchdogThread extends ServerThread // Paper - rewrite chunk + We do not want people to report thread issues to Paper, + but we do want people to report thread issues to Gale. + */ +- log.log(Level.SEVERE, "--- DO NOT REPORT THIS TO PAPER - If you think this is a Gale bug, please report it at https://github.com/GaleMC/Gale/issues - THIS IS NOT A PAPER BUG OR CRASH - " + Bukkit.getServer().getVersion() + " ---"); ++ log.log(Level.SEVERE, "--- DO NOT REPORT THIS TO PAPER - If you think this is a Leaf bug, please report it at https://github.com/Winds-Studio/Leaf/issues - THIS IS NOT A PAPER BUG OR CRASH - " + Bukkit.getServer().getVersion() + " ---"); // Leaf + // Gale end - branding changes log.log(Level.SEVERE, "The server has not responded for " + (currentTime - lastTick) / 1000 + " seconds! Creating thread dump"); } // Paper end - Different message for short timeout log.log( Level.SEVERE, "------------------------------" ); -- log.log( Level.SEVERE, "Server thread dump (Look for plugins here before reporting to Paper!):" ); // Paper -+ log.log( Level.SEVERE, "Server thread dump (Look for plugins here before reporting to Leaf!):" ); // Paper // Leaf +- log.log( Level.SEVERE, "Server thread dump (Look for plugins here before reporting to Gale!):" ); // Paper // Gale - branding changes ++ log.log( Level.SEVERE, "Server thread dump (Look for plugins here before reporting to Leaf!):" ); // Paper // Gale - branding changes // Leaf io.papermc.paper.chunk.system.scheduling.ChunkTaskScheduler.dumpAllChunkLoadInfo(isLongTimeout); // Paper // Paper - rewrite chunk system this.dumpTickingInfo(); // Paper - log detailed tick information - WatchdogThread.dumpThread( ManagementFactory.getThreadMXBean().getThreadInfo( MinecraftServer.getServer().serverThread.getId(), Integer.MAX_VALUE ), log ); -@@ -206,7 +206,7 @@ public final class WatchdogThread extends io.papermc.paper.util.TickThread // Pa - WatchdogThread.dumpThread( thread, log ); - } - } else { -- log.log(Level.SEVERE, "--- DO NOT REPORT THIS TO PAPER - THIS IS NOT A BUG OR A CRASH ---"); -+ log.log(Level.SEVERE, "--- DO NOT REPORT THIS TO LEAF - THIS IS NOT A BUG OR A CRASH ---"); // Leaf + WatchdogThread.dumpThread( ManagementFactory.getThreadMXBean().getThreadInfo( MinecraftServer.serverThread.getId(), Integer.MAX_VALUE ), log ); // Gale - base thread pool +@@ -224,7 +224,7 @@ public final class WatchdogThread extends ServerThread // Paper - rewrite chunk + We do not want people to report thread issues to Paper, + but we do want people to report thread issues to Gale. + */ +- log.log(Level.SEVERE, "--- DO NOT REPORT THIS TO PAPER - If you think this is a Gale bug, please report it at https://github.com/GaleMC/Gale/issues - THIS IS NOT A PAPER BUG OR CRASH ---"); ++ log.log(Level.SEVERE, "--- DO NOT REPORT THIS TO PAPER - If you think this is a Leaf bug, please report it at https://github.com/Winds-Studio/Leaf/issues - THIS IS NOT A PAPER BUG OR CRASH ---"); // Leaf + // Gale end - branding changes } - log.log( Level.SEVERE, "------------------------------" ); -diff --git a/src/main/resources/logo.png b/src/main/resources/logo.png -index a7d785f60c884ee4ee487cc364402d66c3dc2ecc..9597d58066bdbca302d790e6c195204b7d878011 100644 -GIT binary patch -literal 13210 -zcmc&)1ydY6w_ae;A`29^#oe{ITXBjPcXzkNDekVtin|vp?oNTl-QBJC{eH#G%*mO^ -z#Lgr+^88Ryl0icuL;(N*XmYZWYX9+({}B@0e|c88LDhc@Xep*B1_0E@e|j^92LMpy -ztR*B=T-9X6!E#a(JnUb1c$hg@*Z~09AGzwD+R2Z&!kdrg7@FeCSM}+3K>!NMDx?vR -z&QDMhz&I3yB{~=uiK6)#2Qx=jV<31DMK(8br+}`_QY-<@x#R -z-`C%VIfrjk-qRQmOe~tjgP%5lFKS_e{L5tV%CZBaT@Y9t*)1R#bTIzM5`GW>xPtTc -z3UI3vd4s8S1i%8E7FnpUhPVHPbg0m10l^kw%aj6KwAvKtYu# -z1q-mZ1_q+j!XX0->4FD%#AzpBh#CPPnc_?n05BgcK!Ox|5)P~YSHL#cvsG^B6xJpS -z1Lz%3olO5a$N9M}b%xOM=4xw)eCLl{y|^(RJ;(xik0K{Mn-W|05KdtV6#yW7p6&bK -z6G=Ec*xNp^IJCRG8~piUd*w(WOn$xj@jC_<2mmQfU#=SN?=QhQ4a3yA_t=)}0ai5u -zR-4cIoKWNfU6dK0=V))fH&N2OLX{Cg5@M83pU$aG3cJ{LqlN!*ZaZ#82R!`O`T_O1 -z0yt-hW>)tWg}gf(J9yNn#T||V#n~Mm4=F!}!vf#q=x2Ah>c2DLL|tqDXj7q39QJNk -zOOzxZP2Isd4&=BdOM6F7_Cy0zg)8?ewIDW++w}%qz`#bMYtMNAL<4S_V+cPb0zj5r -z9Nv!rKyuG>yeK0KU^2aU7XbKug#Z0l3ZB9c5&$4s5X4X?hKSntxvCdEr;p@!FCMHh -zf}|)aRj(jO9AOVaj8cf7CPwhBmwy@9Tn9&3fSI)oYU*R>Lp$8U`W|%Zgoj{+pZ5p< -zcQ`UoYy=70n4CWn(*)R(2aVRrfa -zCHA}MO9FHR%n|h#^;?ELC8$9aZUNR^wEY(uVboB8>#Q3WhCU?ir|m3Z6R8lSNCnFtPUhC~PpYQ-s7^4#Vk`@oWX4)M%_3f0N-yal9+NdA0XIr{<+ -z6;}0#a%?X5Eb7T@T#4~w=Ay-!ENe^aM=RE2w+`g>5K^i1ne;i^BgEsw~5(a&!e(UPXN{;*#`4rleFEbpo2y^|CO|?aJKsE2G&uaIo$+^op?)mBJ -zrMpwEXf9LkJ-j@&Y*lWPxNrwYMS3Te41j~V^xNxu%@@>z2@I4xux%?OsDosT6QW#TG^=C{Mq9z -zzpAsV2RyRvH$U%uj;EiazgKryWj}j6LpjSjLpcBPVEjP+VE-^pGC_<*vLxUp;OFAz -zKH*{K^!v1Uo2$QkpuGQB%aX{l&^7m#8?W?h!Z=pCM>?LmeOXkQL%z>=>OSE`$6WLL -zeNlF2_FDCd{lfZ$(4c?it0GG_(WrjE(52Yj)uZ-~^Tcj$S$5f<+k`__0}lfogV!!n -z<;EPEyd^gK5$J&4R@b<%5x=mI`ODNXobZq^Y`#x^M0aU7#imd`@cO73I(=GtDX>swetg^9Fvok%*ZiBQ{v;}!Z -zJV{-rW4U2dA)o))8(1C?`myT@duW%%nX{MmEzQleW`FHxJKn+Z)Oen!pbocAf*)U4 -z23C55$bJY|T!j^1dB4m-kp%lDG&@XLs{3c`Pu2R?HhICMgIvwj2flRye~A~XaAj%t -zAx>mvHAe45f~0oJTSZODrH!iT73US^FDW@GIYnw{)@e|159``7pU2mZ{c3}#$MNMioD(JWhtiKq&^zik(+GM+Abr(1{Ej~`3DL)0{`gJAL -zskGHKF1LB8X|PvJqRH3BN+CCc2K@Co;5`-*7ARvAK_%Y?>UKgyS~m -zKG&OQse;}V@)SMz&h-7NL<-Bmd%oa$fepWMt0Y`sT1mGx$v2CcOaLK-F>ORaJua#GjODA;wyce9jTV__4m#ZWqw2-;x{iyJkX{)cQ-(@K= -zohO3lcA?N}_&9pIaTu?E_1o!=;?V?3-TJj!s76R8!0CNkwpP#a)ckS$TuZRV?N0Gj -zVD@r8@WrNg(e>}sUl#p*@2<W=#-kB4(SPm~LVHGQ9WuiCfn)%O#` -z7mSm@rjL5_Ui+;lqh6!wejSWUbmWMd-A -zWesK6(_;ae|GZCKD-So{cV53vYridDeR__b?y2!Ezje8+EU)DsrW_{wJ>@NQUHVo% -z1@*sdyX@E;?jp;idlUUoxt)D69WI+ueiT0R`*>r048472mf@TJPss$E%Bm>>06sJT -z03;Luc=@jias&XlvjG4nMgRbR1^|HPl+&Rq2mrvut0;Vv`me*kfB!x{KHlHo-`?I{ -zUtgb}pC29`?(gq!Zf>rwt}ZVx&(6+HPfw4Ijt&nG_xAR7c6PS5wl+66*VfjcQ0U6a -z%F@!(;^N}`{QS(!%=Gm1( -zTUuJ0o0}UN8tUrmYHMq&s;Vk0E6dBv%gV}%i;I8${8>;?ke{EQo12@Jm6e&9nVz1W -zl9G~~oSc}L7#9~86B82^6%`p784(c?8X6iL91MX#0s;d3{r!D?eZ9TCJv}|$-Q8VX -zU7eks9UUF*?Cfl8Y^<%VEi5d|%*;$oOpJ_-3=9nP_4Rdib+xs%H8nLgG&I!I)KpYd -zl$Dhg6cps;<>ln$q@|@LB_+kh#l^(LgoT9#1qJ!}`T6+xczJobxVShtIM~?OSXo(_ -zn3xzD8R_WgXlZGwsi`R`DZyYc85tP~2?-Gq5di@KE-vop&!4fdurM(((b3V-(9lp& -zP>_+45fBi7Kp-qEEDQ|He}b?I*$DVgBw=o9O6va=|KAh9-pWAyzXc&X$?CWQ0O$k% -zBbZc1bRqzNCSFcb?3-84xxbDp)o9|zA!ee^Bh0sLt2Ik936_Xrk7kRxkdGJznqzah -ziwmc4PEn1*@bP{RMH3}a=(1D -z&|*aJ%U%R_aG3DF7wg#&Bbu!|ou1+!pgaS@Ns3((VSm*HaZpg^QQjodC+i{Mj}OP& -ztW(24-;seiIG6#yS_?^7;yit%kn;MEDkH!Hz=G$|o`f7-`0YBzgo`)ObD3Q$ZoP~k -zs7{(p@o=KT^XlxExsy5i#c<41UOUKC#P0_Bo87kuYG<8rObT$yw+IDNe8LFK*4uus -zZ6zXYgc%s*TKfc+1jr)dkqtu5uE`9zGLRrtuJ<_@xsj+r)hj*UQ(|swyXobaGy9TQ -zA!``eVdSyIz8ocx)#!V|NG`z9*RuacKxNy(NT*N1JpLTJ>Tz117n7Sd@M2K&N*bl<@&~`3=F(TV(kyaz{i;Zw|xvrILWbgLG_L -zQjYTwQ>{D2P8c#l5SxtU;cx?~rfXPH5+*PDQwY2`EEuF``U#_Zf`6nlEcjEmDz2~{ -zcz~gq4{w}DsESKTejt2}2;%ok%#H$1Oj?Reh_FAy-r0%b`}E(GtxF~ -zv|cP%b87Zbc~JQGSpb58hXhj`D?6opux>N1Sy?vhUh7-H>i>f}shs&QjtF0MC>&!8?nDlWr& -zSsC+$?$mRqoD-8RG&?eFh*VQk%)4GsSo)?)npL-WUL>@+mpmB-IT=~dD>C{HZ<8PA -zT(k~MTHr!3@FTeedEXgx9DOOt9Y}BmUZnl^=Oa);u^QE9?W{X<2uHt^MUcQGwHjO% -z!qyKR%x6CIm--w;HNm)6XRpe60!>b7QP&iJX$IeIqT+6wKbXLRk>@)YAGq80Y{5{--z -zdUTSsK26d8)bI{R{m-gW^jkyhhnd<%QQviY0uJVR_mXv%{J -zWJ-IQ4~A!p=iApvClQuYwlJq37y;9w0JfAC%Gtti90aIQT6rK(Wh02##KgoxP2wPXL?bH+CxGu(bqnr5#2SFV_n?~BG!e;}4; -zAO#jU0rcnJ~; -zK3vX>Q06d9t!w*+JL1>lL1biT3I{&wGL$gJC7Gzb4NrlsY%Ks@S#FN-LxXeSe0RYy<5L^ph#j70FpNfGWMq -z292pJSU;S0(AlUj;Un2le{CJj{c$q7Z@hia?N1vAo0xRhb-#K@BlA#!ktQC_hClVZ -z{d7{=&Y)htmZvqj5euzk?dHFCz!3b+3RcMq!^zk8OBk^@6%as_noefJ$~wjZoU~xF -z_o@h4hw6CpJoJZ;`Ql7V%7*QP^*31;IyLIng;k_ab_1`Wta<+~DKEoQ@4Eox2p~CD -z*0K`yjn!5AMo>5!xB~*@6fa7~%=#3 -zU@OB91zyo5zT2H*u%hsagt5*yo2rqwJXz5lUI>cNA{*;ZrgO$Xtt_PYsE*??(M=}7 -z!Kjn|zXem?%?_clKif+dx>oN%Q1dEv1sx@Uu`-G5J$7G()L>^oP}zziqVvcVw>iixpF=Ps{6B -zuQ5j}{LBk6xiS90($ya|`Bu**41tAe^=_0<)MZHlzI6M0ug- -z4efyaE$C!Nkh3Gg9NKD+W#E8lW6ZR0CKhAarf@Cib*y`SD;D&4Kf?Ou?dUYN;w#`f -zcEvIYw#uX-n*kXxJHYU>(528UR29lvEFggo%R_9Oy1{N -z)9Q#23hWK4muc)VVEnzt@CER8E*J{I0taa+X4P_{JYVx+0Y|ph=0>u7uk0Fk%4`X0 -zYr%j>IVZ?S)9=SDGGhc-Qw+;L?PEjIEA2iI7+mpagN&D~9a?MDkjTjI1UZ3R_vQyy -zrky+6ajkL;M##Heo=ZuiVPTmw7MY{T*;A;uJuYrm5D~;t6C_=XIr4>; -zmu;`5dT`;u@`46+%X}S+6?kLKO2d8kD2zN{>oUB9p}^*c!Rw`$%zi4=5a!o~DA -zL2;T(zT`Gpx3dWCb4Vt@nvPG9lQ$8fz6=$v@L?L+a*uu-QztN^$I2V`>s;jH1Hpwn -z?YPl-zTJ$RO69&u0C`FqHtLSw@iWh48@qJjUga#zr -ze`DB}Z=Z8(8jtBcnwans%w~41y5woXEWT_(#s`0`u^>6Dxr1)$e#Pf*=1QBaa!kM9 -ze^Po33_oqrmephsOpz_a+Rlj_7+$TmY5qq4ca?%mSb+16T3BRx|ny -zshR_a*%;?s-D5hg6nv$RVHFThATs#UJ5E8-#CLrVhjugF7h%84KuYYgfQ`Xs|Er=_ -z7W7jfVm7A5%#0gDozK%wn?GjJ1>)hN$eJ_Jz9<_PKRf9s^F&?(6*iLnghLX6cSX^n -z+D;y6m0sL4eoum)5P&fnK0#hqY{t!jShD1!bL$TV_DHnOYCsH%HiaW9hi(v*J-vk2)bk@|=F2Rlp8)^hr=RBS$lhNa5Ch*kKcE2)Thbe&>$hGN5Yr!?MzQ7j| -zfwYnB`S+qCaXsBWBO42j+gtfYGRs8kmSy{vnkAgNx~kNwQ!Ina!9aDeLcz?!caBZI -zHES_hJWng}{9=We$w?|W#(ccIb7Bo*8nG4u^4r73xU-N@1#6imbX~2XaZpR}MVlAK -zX(XG<=<)2@$+JObDhi6zu&Jq^KtioFmj9~?+xXVZjsic+M43SL@L(yT$>dxVgMKZa -z0oiS+YGA+~PS@#WzvfKbqtDSrY!Ilx-Gg -zR-$6>Y)w+ZOjtl -zFXi3spSe!tazAZarF+?8Rq9Ez^f)JJ=KNl4Y_zd -zVDfNh`B>vN0a4S|{GOw#u-CDiCW?uW8MbZU1+E -zqRWOXDNiXzX-c?Gs>Z#kS<8W6NKx@~40M5|^;Kk;6|1d98d<=q&)&N&x)s5QIcXPr -zc0#$eRc|lqMC^z*cKWkyXh^@QQsv?=t%^zMvRy(e1S2ErbUc}#Hq^cioq;N|sF4>n -zzdxgYov-P+0Ky$v_u2YrYPV<$oUnCu-jCDp2<1GR+!p*CRXLR+Cq;%2p8aM2=`>w? -zK3A#Jpi+}4RcUw@j8c-GE=w7z$03djFYmBzKrJMYt-%BW6d~B+UFK+mbrHUFgu|DZ5@^KC^uh;}?6BLz> -zKIGbq11nZKxCQHrQ7Zp_I_p?riOg}YjnaZ)fcg=nt*ii_iAewxqIdTDVU?Bg80JWq -zis3WF`pchWPp&^}2$D(0nm<1rp${96w#J -ztP~I0n%NA8O*MN?P<+;S?hhZXE#K4|0;!1(U(WfT63ha@eDz$vUyfe_`junc9W5fa -z_^4#HgGBjA -z=fTq}`c(9AGM-NDU(FGMZ^pI71=g5}8!|zLX33X-_w7lI%7}YiHKI?5F$++w-pq15 -zQ)R8ejL~T~sWyEXZexwVPcu!5!OzQ&u1b5v(2e<8sEAdCM$}U+eyntFcQ_a=K}hz@ -z0bPD7Q%_`%v&7d5TMgZTajQ7*40l6D{-G_IX))hv-TKrA!N<4`YnME5Z1JoN$hBmp -z83~6WHv;f5$pRR-g+v-2Rsx?M^3j`uFWfR}1}nb_mb=`qo+3JkVarQtb;+OCIE-Zn -zJ$2KDmElP@W+qpwSHr?Y1E0NvSd>h`#h)jtFmvCIwndJn<9eP?K&q*pgf*Zu{cfTv -z?QbW#8k?l&U0gsc3VvdUy7fA4ef -z9B@5o?zgVpsIxy|0KRS8K~UH|~Gu -zxWR|j9m0a)8Yh99sm=_&poSFAc)8f$TbH~3UEzhD1&UHxT3~19pWERGnU~Q@Ts$2e -z7!*+!dm48og=(to#vca8_N@5T{{?*G0 -zlgGf#*Y80{eG1zvE8AyftcJwCe{OA3XVNoOOsr0;=#P^AjuIL;osF8dE~0*v(9^WT|Kv5d}(j_q<_zHw^6ln;@QmgIwixAJ^`6I$@NyZN|3A!hKW|{wG=t -zoD*dZ4f~rj)V&ZWjjwXOUv9WR#nZByHoTYX8@AFOBfnyN*?TUPPXK_I5%$5Cu)RIq -zO#_0fB6AtJNW%N1&avxJhT%HYt#3r%zZl7yV#J0oMTLz)VKBQtg^sM**;RLUsozt< -z>EaQU%*}-uZab1c3S@<{L+&#AvB$qUzt~+K=gEY_M1>-qcLXi8C18f9M#3#-k~H -zAUQ%}Won8HU0-BZNlfpLwV|sbvgUu9xXmPI2>EQ5)Q%V*l%KI3&fHEa-%##X@6pXf -zy6s?f$itx80{!nNkJrPeh>~G!a)1$x~g;B!_! -znYgLt?%Ir0xI)N@K;Uu>xSb8#f`>To?E}LyP%3t^wk2ChIk`L`7<%ztsjA+{lp2dc -zul7ic1oNPG0B-zS+&Jl;UL7s~4l~aHfBenF^L>p|MISq@kF>D;(QQ-zN8B(BPX7B- -z(Z8hEoxNwRY&47Gbc}=sjSXAh^htV3q#!T1X8p>?=!ttolMgvDca$&z@0)0}Yd((7meDa~unt -z?6;%gTjPb+kL%O;jbP*UqT+ -zwL^77jqppC&&-_8t$I#2RB4@@SDKCGf8Cvh82ZpchjY8(ze#h_3I4lQV>rzfezj>` -zQP&EN1Xx3L<{bNq`~<7wJ}07H -zSR9#yKjnW0c|oLtA49dBMP~EJD -zXKnKj@EG^_S5&;$^FWYNqJKQ_x_`xRKS~d(_`P!)Ec(XRR$qF!llii3jCd!{q!ZF? -z+!8_d{xp2sgVT@;059a6ah0}CKP6>Sx8L<$Ag -zTPzo9+t>(_Bve)oL#L+%%@O1}4B%j~hP2Bg8fTkt*CifZzTgKDBrfdTg-EhI9;-5% -zH!dX!eV=qmAQy!Pwh77BZH<-KX#*+C6KA&zoe(NTydPY8_7d1#t~y?|L{S^%S*9>D -zUmi4f<&}OE{<*F%|8bZ8Y?yPFud51sU%hD>Tu1G;S$uA97K$TVDkB|%Z9C#;0OeZ~ -zvGoDo(kLbggJ7}MyNXFtKVOM90amFI~|vbs7PP? -z+CrR`_O);#spc?-b_==9^akfc`sLSQdP9RI2EU5RHjo2p^J6L&cgs5S5b*>1S=i2w -zmeSqAQ$I6VThfB?S$KQ)II -zg5rtw_UQo8-hqO>owrTP(`+Is41{2KPVGU9gVJzwi)OD5e{CBVUIE__R6-aJbP#jy -zk=_n30>~_56kRG}SnY=wTg02q?$+K>)7lMSg<0M|ngE8g>T2yVe2E|Nw2UNh8mk|q -z=@Q_4^4IpjvGw6$il0TjHGhXjp8|EQffCw^B9J%>`8Mn3C80Ii1NF?z^iyXu>jwS^pEci}%=dp#5gh@zRV+-3MwKm(}C^<#w_u@sZpOPC(U-~ejX_x -z`>7YX+E(;Gz{H(GM)WDv9R?w&n20!22S2vTFW|wYapndx?ry>BhTC%@eTJ=ICW?dx -zXC9$ev|HrN7_oS;z2aRybL7>f;&O@L*sq5I(k&?qZxGpB=X-p^RZgQ+zf~V47KZ9= -zGI%4n$yiTS4@klyT#0(nr4bT+9SA_K`qrwX{HfWab6Q4qBmA@I=RDc+#jf>W2?StT -z(DwfGH=tok_xgGz{%wuGceVlol|CyMGpG)BnOHF!imYzX^Pr(=K6`RvZi&H5T;GjcsVJD&-Hcv58*l$U{@K|R -zS-Z4(Os)d?5m#1q*5|xP$IOKofooAFzLMJiUR_i{izI3EMFrf>ii$-FAN=E+i(n#> -zMdNR^bzvd?T2JDCrxdj}F(D_EiXhFKFkhn;$Q@PCUg3_>0G -zY13U?VYjUqggCH1tunT!T9iBa=-OG?1Fa|BM)AE52@;DaaT#cFWW!P8gbaws4x*-8 -zFc@nLf4|8S!F0QtC_MHf`jf6#r>c`OPJ)=s=`slkh@!Mjs9&RZR-Wa`SLX=VW0{}q -zX*y)lF(Va3vLZ((wwDgPD|>vYdO<*}cL{-yL%L-)REcsU!Aw$;D1?%k -zscDa?>1lcUX>&p<`1=FVpQA@7%1WO|>vOep@;|tRh5WnS4+PH -zFu?ype%rHNTol0HHYG0Kztny~M>tjUA_5miPMm9f4;K>t=R}oJ-Ltk_;rr(fjTU+R -zmu(3w8!rtvn&=#gv|5owxr(-V{Za*vva&pP+59Wgg%R>BFM>(GEiYPdk#d?^`*&kc -z|61z-G-Gz2YI&g@o8t{PSTHkVnnH=1gjlB3NA!Wi_EXi`0y^MiHS{vSHS(&c=graZ -z>@6P7*TvgdmcNWB+fq?1+|ZU12tX<S)TUalSDf=YQ~qKV_K`jnwyhu -zOQMBz9ypM&Ide}$Jd*!jiQM?wqckLvrO>zHTd(irk5S?%Xo!RzwK7>@2{sZ1TEM_r -z+H1~K{XACzG7KW9A#byMA6a^J<+ZjUz_t2?0F -z298^%FiBOujZ#KP#$dt0KPWWn$9GOtby -zS{~hM59$Hf4l2y)QHJl_`P-M;W_o>+E_6blKkX;D3f%AL6smaYKcb=FZ{kG0?@gDP -zoyYX&-d3-pyd`C3yA@xVBBs+u7$Rr<2(plAlp)6X;n4cA+4Tss1%Jcn -zZsntDp0{55S|VSv{qzp-$`8ZcVz{&Bx#u!6m|QdpaWwIMh61w|rZY!eU%uitpZ~{Tstyfz{LJ4l^(U -zUAnKbD436p|K5nM{ERrk{WNU8%Vd!A?2=2q`vt3;lhN1W2Q^&co(e-|48u=_?sX;{ -zE -zz48#(Ii>N%SNbF=G8H7NQ0rD}(xV1V8ZW$fts^d@B7I7&YE!6^vIxJ*+>Qv4w5~r0 -zPP0oBU0nE4z-~M75!d~9tT{gI+6Agrt;1WHz83!f`LP`TL6s*E4Td}UxrOBLL -z>6p{m^%3LnbMIc{MIgVc{HBv0NumX(2@b}bKKjj39RRc{o3G&2BboLcj?{f@=dJE^ -z^gGoHj>M7#lE1yDhvq9?#qhi+Hn#Yay`7Xj_J>!ndQn{XzvqnH@oOUkZ$#cEo~B}c -z!N}c{C~7^rNt`X{SNfDcK4Q8DwAPvQ5It10V1J-x_fXATv`8m+@*Z4xNr`IXOZ^5U#Vq~aggtL -zpj~`V8}OuQZC#*ypt@f4c68emktTjn79)H4+lyF=aT)U6QSKk=o8wLo!q*HRn`6f5rV?*HD)IX5{c -zxpy-=`|Zxo_svGBD$Agwkf4A-AaprdNp;|J21vifLD%hMrT$lZeEex|7Xe0mqFAZArC{!qp)zJmbab@utqA`6 -z61Z~|e!k$IbXNT?PvGuuzT7G514$8e!}lsR>%nURMm+~pde``@(!O=ISt0%B93;Ez -za-qRi4n0Q>zQ2#2^_y08QOl3jT*!Ir5@<8VrFx(6f9sP|H8ttjftN;wrX>jP4BcG1;MfU5x^L`zc09u!bDBt#+ll=7@ -zB;}A$BKgu}V?#qfHvm`~pt%wG2y{MOc%B!8I`p|pc -zO#?sq!Zd&j8UPmvY4RQnfo>!6{a}GFV!}g@qu<3Wu$07X(O`vikNW$~q!ngF23Ls2 -z53p8js<-B_Qd?xX6rtq43Mdz(jOg2QXx#Wng_9^1^^~KqFNq{Kvb@Ap9}bf&xFA-C -z5+#cQ`#v$A=kd0O=agATcleBaxXf_(dnqbQz|cL9R&&Ni1omTs+6~YApmk)MCghxj -z1}mq&IU>1nEiF=q=PI`%jQbyRd=hVI83Sm{E-4uTc#w;NNwEW)C(C`xvWzY_%`_MmO -zD&g-sEaE)}6(&g)y-N&rNy;5@+{M`}!{60Y8wMgF5;HmO#B~hG`W$;7xLG*yF((rq -zxP6I#r#o`B3FppK{v(q1!C+YLFSfySDcHyoW!}EfzuCB1B|C5+oP}dtocnwkcNy1EZ6#5JX4=ePl&cu~0tMnt&79+I4%PaK>VqFx;r!QdNmnxlEqdU-QR%Nmu{aWP -zJxwXvt5fFTCOVgB)Zq -z%H0U=9q7Y0lu&1kc4zYT3*lHA@XJfoK>3WFM&WWf2u6^+wCm8##D$x@Gkw+t^HoO( -z4pxDRqg;$5S=t^k22H5^V3V0Qfy%Ogl8I%LD$52=7)J>Ki9Ej1HyEi_ujELlz8$-+?cdD1Zxi02kW0 -zaY=caFq4~s^R?zxcc3Z0X|az}Aww<{P$>6rk+5Di5J7$kWor0{Q&>+DWSBH^Gf`SP -zT{4}IOFh-hB7xwBdewq%de)q6QvxorV(()2>@j8i!kj)=^hN -zl_N{$9xTHHA;V&Zx#tX&1pOO;v^NiOP#_UK@J;;lp+OOhOOO2mlMdxM;Qv-mWG+^vzox|8t`w| -z=gPlM3)y6G*hfV1WwuMe>bO-vP9g`h5BqgO9x{ROBD;aPl>XDmvt(3PUxt|4RFRpK -z5OEtRz{(Oa_W_!Z4XHf#h;Z-~71XM7wlF*L!-#h_Uy2tGuy-rAZ)4{qE~feNkp}qf -zgvBtLkFPI~I7%C=OHZfPZz$j>L9)rb;l -z@J^dxncy52;wmHg=wC3|Xn6jPYCR7xc}~D0wNjoYxmoRh_zh=6@8coM1UQIa_z*1)cZPw4v40qoZQp-uy#DLv=oP -zX9b3vzFA2r8}|_AO8W1(OMG__0{1AUD&Z%&7-(>s+Z-X6Sv}G5QguIbZ3mYa--?09 -z;wNw?n=yAag4%m#w$$-YZ{(ZJUcwHfzu&!gykNjG)e}!=q8xy2_KS=ULsQwv45NK! -zVqqD8#S{vRjg4(Q6HM_F&tihNIQns<%DVjE$cv33ET>Dvc^#{z&#u&&9RgXO?ZLuebczKv#;! -zCS|2lIa37Bp#3RWj0$V3=I2>o40{(J^LD|EUH?!2;Z&HS*>7*V%{v1)wHaUP85mcX -z%q!K}Ntr*IzJD%++btJ;VQO*OjJL1t{GvR3cy@OC-~pe^bV?N`z0QKCr?Tom)4u%A -z3mi2k&eIgh0^rGI#Di+&3lrsy-r+}zwBkDQtswtPbkj!Y^l`{f!# -zLseC0M;DiifDa!({-G4{W$Wxsgv*(NX%HMyXhArVwY105dUHg?+=@6Sy8n@slS76x -zU7%PI8ToKm#qahfR;7kn#|t@9y(0EkooWBDqA1(mpO)>BBz))giBi8xVHlj#dR9U8 -zRo%`iBdlj8%_tRn^qa%T>{nsLLwTNld&WHLyfbPzv2W62m6q=Nsdxnk -z#{P==5!Lidx3bcr_qlUl%BX!xjywA?jv>FU^mJDa0zQT9Kw8RRHq>7B -zb~DXw0(oqBrOQunsm2ghWV2i1VmN{F?)U;0%*j{FEUxazAJ3)KSWomuhklkDi?5h*MTLDS5ma_Nk1sNZYzZ#$maGRyiXBzjG@(G__fuyBl(^A>s&{jF+J%5| -zv#7nD1XK806#_U_4#N2ANAxznk%;U$Y$z#{K*O07mADqx6LjACqwP<`HFV#C6Q*wx -z8JVP_qGF}V7B?^8)f*2F5AON7v$L~Kr?2}oPai_kG!_6MI(U`LS~+Mo*CSyrw>pPE -zllqxy -z^&rnDn4XA@AUY7~`1lwTCrm8KlVRqX&!kZFH&;i9@=R}UDxNSh*)Iq2U+#9}@ag1t -z%KUOEw0DXT)>hQoLTprY^z=BC=8NAyi3pZWT7A`?;rI<3%65Nqb93%pJ=!+dNtB>W -z7f3O-e-S7ZBgBntcyt~wOG_p$AU2zlGH8=%TEm+z8kLYReEMTkIo#2YiA=iKWrH); -zS%uT3xAyyY=!U)0Evpgx{{38MPR2nN<3913M<0O#YCO=TSt^4IzV3^D%2zC>t_OO} -z_h~AVOk+IIi$Ov;-g93a4j@WaekCC#HFm2_Vu9s)8-GbYtr{LgrxnSIN^PW9)!jYX -z?%-yssA~&R3F)C)wj5i|@!atCx?Qy%P1QEGSZm;iUNai`-F(8a%y+_a>CMzx$XEKx -z>sW|JbN36s+Y{4SZsrspH%UH=+Q6J`c&_-JLGL&5|$XUA1vFOC+rgoc&xT{dFT&pMaEBKwyD;plX0>2nla;jTlQ{!fn2M=Ak*=K*g% -zBm0-$ly1~}CT-5gv){jex9)7&b8u!a+vYHXU>=NF2>g3+_rN{(LUMGwRWKk49sS$v -zazyX8zZ1hwZ|U*5{fK@i@hRl*U%Q2cg+!iIfb)6W%S5F{91qinEZE%~4Gl>rBw9S< -zMP5$exl1jESyt}d~jo?hf`z^32b!}UGtJH+w9(0UrI#~Ei*ii&6z(AVE?(}k_A -zE9Z@mj7HF-ch46I0ipe3gapRj{=zk_J1E^b_JwdrhKi4ytBuwP)m>e$@9v`A{1N{h -zwUN6H=_W+h(a?rGaQ%%LP5C4)XiZ*`1uUwgqWvk`LyDD!Ps#Q5oI($KDJ%8n5kBi- -zghsLx`~mf<>WT)6-cJBbp|htk1NfkZ@e#B4@l?UH7!MDMpO?1NETGk_Eg{z!N3!D< -zWg8gtgS%b(0Bg7dw9u35xq)1vNdnM8iu7Eje*u?#sZ~%^q*HDaZC?5z4ZzhSA%ndS -z4&$M&7(|(9nWY%QShCnuN0 -z`n9&UeypypUgx;R+x;XM#8uDM{p`9~j<49)^dotHJVO*A@HL&g7F={FP#trj@{dzm -zeQUiqRWJ&pkKkA1O-|vOf8O1UQ$$0lIExffio|}F@ROV#MXcPH$ -z?$$kxAF@B#KT}u;R@SVyIO>1sw1!i?C(_013w9@?8$bKaLQi34zC$g*^}F&(%NEO6 -zQzD-^6}HQMnGJ{h$J*)HjSxjblWegsW&rLC8Ov_r_20jLjUS$Ptnm|p9fK%r0j+4; -z57^mjL&lISh8>DC;eB$B69$h4XxE3qU4T&zUpDeV@4g>or%D-x@qhie>6mqD959ck74(h?S0BA0}YQ18d?hr6}%}y{%ZNJ^-(?=Op~; -z#2-UNh)jH9>RXmvPJ(Y!8(uhyW|sFpyvv)AaNeljHj^Fx+RC -z!`@c->W1C^FUKHmG2w_atkdsMnzY+l!CV8havQ8-Gu)<8t{#V*2Pwp4h?ayXsi5Z> -zo!guta>TA~iv#iJpQkN>#)QF%As@2WgU&V_Y^qm#E*O}M_ijJfFWq}ts)-l4>D)kCqJJ@MG2$69ph0jzwI8ry1u8D@CyinC$oT?7S*Z}Eg -zYs}PWLqr4u@)w}#!{cMx;KxO6W2H6~3k$laJjAt+C{0mmCRnfs=OJYbh}HMh&e`#> -zj;jrpjqKCh41OK{FOS`@_sPP$iCm46G^EMNk8(l-1f>!gEV+4vMVRZ#8infUenP+k -zL^tBOHF^=)k&U-Tw{gfijqQ&^ -z-RHHII5yp}2|o8pTsf6x7$teW9Em!~iy2DN?D@|U)g%I6VG%JBO$|~;c~1Q^3|x`1 -z6HRbq1#~Ke)wWpALcc&@P;m+*sGavR0{aOx3=IwUE3YPWAwV45pzD$~02inxi7(6X -z$zk683M=_r#M*+6fQ)&FK0y|lm7JLwS)K=t&ZJk!U_-y%_o@fhr{s37MUEQOF*M)3 -zB$;4>Zx;Xk*(hwFjb>1iJ1f*D#nyWL{=>{2|9*^vCNN!%bF8Oe<`xz#s;jFz?;I}4M3lL;!fy_;J-E96Of+;sG%K=fZdR)99pJ}fM( -zq%(s8UrsEL{NrdF`!#RY+VjFyPpE_vtqPMM!MQ+QnE)+_g9Z^{4^;k&Sa^=w*yuxB_*Z!U%!3{_9Qr)Jfz4IeS#io4oj_Kqhq`HCUub|Ke!v$1-$v=kc+O#rlCej?%dhY -zxxKUTsFPG1nfoFp3%7@gh9S?vM0N27#*fpJyaX;Vy{!pt*}!9_mX9uC#J5RyjknW2Dm3dCvZYU -zSW?0kvI9!o2un}*%`AYhr^CQT1aZF=-Nt^atn@Kt%b2!hT(pK!|MclbBv3-<+6{>_ -z8toMfWc9rpOk(8|KW>Z-k>Fr(xc_+q9ocf`8!_n}XYUrW?Ax|*_|=5m*4F0V+46wJ -z1IGS^Z5t=0Zj86J2MfJc -zUq#WKCfhoB<;P2&&`*_G4^_0uqDR20m!>T8ay_rxSzA&9_v5##g6tzXTkx+KRfz32 -z9vvpp?+YxHTxDthCBu7)&Q052y4s9*$M4_2w-OdPyK?F-EBoUuSsIk@@(!gA*A_!0 -z2eu1y;-Q$Ut(M>8FCOtw?vZR-%*ly^x)<95vK@P0tJoZws@+M*NGhg_NU`!}DZnWBHQz%*@6))$BWN;EM0xAF+B4Mph#S??J?K+&viwPmes*n^HGDL9iBf -zCk|mDu46wwughN!isu&G((DO>Ws`(VLY?^#w=RONxUgFGby--Y=5NJ|(>qXOS`;lZhmXyMEyBdVM@jJh71E-})~`?t4w8^Kwy) -z<+KACjs!F^TS-;FT24_iWF+=l(nR}j7U#;Vd -z)IT3=b&}A}1PUKFa6DKfgHkJci!~7u?a%k9h7Rri^{y`|;;xNDoQbV}+oJ=LdApL}|77o@C= -z;~aed)XpbrMtt1x3gHPWxbliQH4nKBCew{9 -z*-_PTyn~`1VrwKcc4ZrhI^!MsZ{D0O0%O2!SHHi^Dfyr9*x*DGFKwc()b;q6nM*M7 -zvA$x_?$BMJJHN5HIn9Ps{_7-sn79~BZegaa5V;s(BA<5BnU?^AeJHXtd)cIj_UCjA -zW|N@MjV~vrJz{sE0Dzv}tXxUDQAXm)1(kX7C_ZVFX%!TlZ850i(P1A0BxaJu)#LcH -zoxMFRzxoxw$bM=B6gpuMD#vcsa^00?%=D+T9-dQqV*=zD|)W!3BLun2&^n)~$ -z2_^{i9~sGXOAsF_S=k&4mWJ@`mD+G%MiPTlhuomboeFNwHb(< -zVpVR!mwf;JmpO3JL|B%L-!;@7TG}+`HZA;-{VIlQGY|T=f|!9!S=!c?sq5|KeEQ*~ -zm!1xeZcJPbSsfjU9e>K|=Ni<+YgrIG!|5@|Z>4bjx+`1j^O-{QK8XARf -zUG$nLRiTEtt;)9F30rvw>nj)@vCF{$d7>o2n>}~Y2^^C79l@s`uXRZOcuy>^%2@t- -zRGv={pKlDXFUgvG_^DWGR==il1rIzn{$p4r(FVOQxZi!_*Ksfl2hR{Aj>01RbFAM= -zpr0wzMwlOwlkt4|JLK)$>VL+{4nv>^`yMa)T;(9f*B(9;{T+)_=M4dN>M&&hS-#(G -z)-sW(WxVkHR)`x#g)25Lu7qnN;~Q-bvKDZ=;^fyLy@okDpvt&ZU{!U)WVtmnp -zAN-CzM{jPFWep9NAKDDq@=kynkGi_GQ@Z2y_Wn)xc_q3-&+9`qdGy_{PF-2c^$)%x -zd0sonEJhtG*2|P*Q-f_3`Akk96HzBz2 -z!5tnJaCcA2hGQrSw*{F)epvfYX?7toP=O0dN -zizY2w`>O@4Vqff!dBhQ^><#TjMP}loM9ProiD-Og@$V=*zQ|Avg0D!+96lr^u(1fl -z3J52PHoJYDdvdiIW?q?JIC*r?88VruLx#bp0lys39v$(c6uC*j}2IFFh -zViOX|K+DH18cd9%Rgjs$*sXuoW<>p^Fv-7CV|zpgTUnj812pyyX-nhA4TZ^UyYY9; -z?}BOarTT1q;0xSTjV_DPWE11?Y2+wSA*ybzebDoy8JwhznKa6SvYxE$WswX7Z6pG$ -zsA2GgHFFL3^zA@XTYK{a+6$Q8di%@1-|q9U15y+~R-L7Kwx8*xr(FP{g*JDPa`e((jSl#~?Rx=3ne(nLfeP9k0grubJK -zU4euzZqt~$Cl%k^{-!e6YQZi|D3#+MUS}VsYZ)0S>y@)kyqRI?A_esvAu-{`1Uq@! -zC+b`wnMK&<_mitl+k@e*$*{&S>vayX*>D>Q5sw2FZ?l(8ff%(8lo<^mBMrwQXOXe+ -z*7sZdWzBTIwZO$y^F)qZL1XbOMY<@M_a56y{({Vg@YN<_y}toq41V%~w=+4ZQvg)X -zVw~l$z-sId^nKU%dlk7W(mG}eS&KV2BdYqNJnX-p=YrG&&`_m0fzA_|iKD${5?oL* -zdS$heR@%Q+(3!!T&k;tIN|v2j=UI))rgkvyC7MTTrKP3g>Fma@_R0`GE5(tL%sS$7 -zG41ag%(Y(xZ5cjlk=R~(3XC+$25r*Fo=G5OhGgR}i!nDoG?^sult?Eo*x$x6CH-3L@LtZ0dfq!Bbbw-S}RwlN%lpH8c=4l2qH -z1wRszHSPh~=esnWvXD8B{D4<}?}6cA+@Ob1760Is6`g!zl@WL(L&={LA}SxAt0>Tw -z%b7i^&yNKM;(vGcNwuxAK{g|S3Y1&pH_6U1G -z3M4zx5FU=O;=l_?VzQ-~bx~xN1axPgYI0am3d25BjYmfSTX7Q}==Vcryl6@Se0(Jv -zxKW_o%H`jdnC7QXlkFbCsACHN1Dx=0gf<~@PW-&<=`1Hd)@#ypH7%OpalDj-P=ts+3^~yWs~TV}BD20HjkW6zc1L -z0#HzMkn3JV%7N-18_@tgE82*YnmEzxirriDSx#_|<|q1vL{k}7>^mRzO(ueTSN2~H -zG}kxp)Qn!&)><3|e>62+GXSpQKcemfqU!&BHZ5Ca;DT<63bBM&uV1BDS?MM$M;x8w>gShAPMxJM^BbMZn}Unm{OC9^4x3%% -zlmX8!km-u$N4fQXQ>jRe`7)3+RFGjhz -z18zf(Fo2<>YV^7LJO^UTZ2Ivd#mpN}o?7pBV&q=f%ID>haV7M8R3jsF*@a%iwIy>| -zsZ!-y{!%&j7`B?W8TcF4NH-RHH1xZ{;7BsA<#APu!;cND)te)FhoXz$BIU}2&^7WP -zT}TX>ZO58$VNPuh6JV7~s(W$vAj`^%AtUamex3YdVl3~4+pqk?G)qUibNMrj0*M25 -zY>5Ac|Dnv6xBQmV#$3JA?&HTN(lYl~J}@$l{*TY^kORrCB)3dDO}^^v!dcLf^CHty -zanjllIQeSLmpuG+h&ae`r*v!C*0A&W^a&q>93?BAXzG7n -z2*3TGPIcN`-_hY9&oaiv#fiv~>}7`T`4=pInEqWX*3e8+yPm^9h-tr&ts55$l+388 -zW)~F}2JH!}VLbQ>?6~H@&k`MnSsTeVj0TRVP4jGbP*!!CwM6`Z11c)yI2w$+R0zxo -zT|obYS1&&`{>>Z9(jnVU&=yI*%PGe*f78ie*_9oap?sd7fx7{r^WT>=XHF -zl`f{=UJEn2?tRw`Fem?eRE6#*nOes(ebRcmaK3~a3{a3EyE1zXSF0p7I_iDJ&%;3V -zU;AS}e?*mH#Yh2P9E3QBigIqu2iXf=@t)2+I~f*_E^JtEP1@IR{CBfTj%T}E3e#n% -zUa{@vU?D$l4DEANwkkK@ruP4ta)E*e^KLGg%$PizyPmHvKNMWtuJQ6sPXY=(1m#>W -z7V?9E!Vj}>a|KfQx5ESpH+q6$@gAp-P#~lbz`aj1_?xinN>3o8b2-Z3w>UZ3QZ}W0 -zWg-!>p>AADDcU^4;0*L4UFgB0QLlXd^y1E&4>txV!T|!`RwjZGl`;-4ZgFf>luHIy -zZ8d8Rh{I3r!g-ht6mAZxMB6VxRqnA0UY`h|mJZy2 -z17BazT$jMKFL3J6Ue_HL1^)4s%$Jj~Qx~1HG#tS@kwL(KP_ZI3dWz0SH(sqj#-*TNGsIWqPj>cj?!GyWvfdEiNOu4$>MIqL=F&Cc0{g*~L5 -zA1wt)=_zMFUkCT5$l!G{1-Y9QtGQ#qm5E(3fYPms_EP*sSVI)bfXN|uNO`BqVuCvd -zv)z8IGRgtM1<_trndVhQ^xA)wn~*W~#d*X@E=W)jcQWI8+?kdzHe;DZ`%+JE%gE}m -z6H=FO8rJxM{N90S=Gi!Mel)TyanxPa;E}C?hJl@e9UWad->;S|v;axgFjrY$z3(rV{MiJ}3M)t;Q?P5wZy0e3G{dcDO7n}3slDXLMrB$;#*W@Qv)D$=?Xs$F(8eTcyGIQ~IWgD%Gn&E>F9y#o>cR-7spE;Rur<_E~Pu)e0I -z#&y1|@8D~8c55<|KMf;&x;hg!A%VOZ38_+uk`jH4#=b9M&xcpxV-7cMN{jXVRnKSe -zlKJJ%=VBV{$DNeI1QkiA;DfdVT?$;O#22z6v6bTK9)fjrfIh!Hq__l~KzuNqT{&kA -zKs@YV6^1ZLGjTgR%(=NHS-DvWnnP)NM#qbHINqmQdCE5??co$3nuikqgm=s7*#Kd*+j_weKrZjMeLeHEoiJm>zuDRU` -zh~ggr^knneWU!Nn}AQt=0Id6Hk; -z4bJqse|V$H`stT?NS0yreYvaZ9YF!fw+N}{3#yXRU!C7?exl35BDC%+!jDMGT^DN# -zN9FGd#5t#;$h}5UgQ?q-Gr15>C6=nLUszle9<+_!!oi_m@_L^-R>_Qty7_g|C%m|5 -z-7^5X5V_ARi?h9_LW%2vByD3X_IvUktqBv{%SYXO1&;e&O#Ll_cfC`Wv1u+l_#RI< -zQ5Kly0;P`%TXaQN(heOg~>V&L{d+ZDA%eq-UKo#1)$rkjSm=nzAE2r -z5--RyKhxfXoGVU3^ab{5XGlyL1+26foG)4HZvN -zG@&I3h0fnK5lIjcrg*XxPy1(gK3_TN`&VYnxP;C|j$~0rT$0f|*#=OzM^NbE-1T5D -z%Csnt)n!sx3N#b(8G&+G3W~Q_B#StA6jZZ=p#wuu`DrAMXm{T@#S;ku4Dme@{Njmk -zCtrh3z6O>o)~o{&Htx+6kn*)$NNBH-biu^aYtWUq -z(G>4rCEKr#tO>!x8A@%W@6g)Xs%2Hq!y#Mbb@9R2@GDWi&!{jhZvzQ1D9nMuPoOS+ -z+cj{9nx5X{jJOIavbFf)Kz5Jnbe5Bu#(XE-z$j&iaP%c9W59OoT0~|N#D*(N2kz={ -zs(|)nH!_+_g1)#ZH2xk>ZTG#6WN#qa3BxZM{NWxq`*#$H255k6Ky?hw*hSA6`c_fl -zT@Ua%E5Ez3;~`kQFmrC#$Nlvc_Uy3#yzhd-6UYuuIwgIBZZC-`dwOBJbfurL(FfhH -z{YkjE+9OrOveY`{t{sGw&51YO1@{iO4)Ki=!Z5#q=m_Hi)_j0`>?;t2j);vv%BUif -z;wpTZdLQLsGvZ()DCdxYudn^Pt;BZ}Rin$4F8h{R`HxT2z`uc&aMXIQOvwgA5%{&) -zFW52MiN!$!EXgx}Px~e1!EMp;#&kY65oDho95j~!qD%YJr`+aK4jCJ4UJ^;q>w@Lf -zvDfg|M`S^@DGxu+7aR3Cx#;%?advj&1~L-m -zJqCP9&TW3migV*`Z$#)Qa>3>Jf)g9D6Ki28P@iX(uso)hic8Dp1F< -zeF;(n8Po8A*~^T{De(J)Z2nqLl@Vv3yoSlGwq0aeOg4ymI(KIkTeur-=J-yp9z?qe)it6gq-wl@I -z0D-_I{|T<5kwD9uH3yf1GWXp5*8eOgJf*q0IRoK|+r{}Fug&0WpNDKMTC@(Xc)9K8 -zy`lByMn!1fnY)1KYP(0Je1)c~WilUuh<&Q8^OE?L9Q^xK*Y@M$`6D6TDCZ^@l8{|} -zxmmNw)mng$hYBii+&ZqedxWT0dnV#LG4zC%+kzcK+-??vEHT>Q-T8zu|s_1IbA#OV)^+1pg1OmmZn` - diff --git a/patches/server/0002-Leaf-Config.patch b/patches/server/0002-Leaf-Config.patch index 9b7686a7..33e0e2f9 100644 --- a/patches/server/0002-Leaf-Config.patch +++ b/patches/server/0002-Leaf-Config.patch @@ -4,42 +4,73 @@ Date: Wed, 12 Oct 2022 10:42:15 -0400 Subject: [PATCH] Leaf Config +diff --git a/build.gradle.kts b/build.gradle.kts +index ff8e0b3ed28ed0c02e436f19945e1b76d2d5333f..038ea85f4c9c1fcd0c4d3127944dfc81ed831d4f 100644 +--- a/build.gradle.kts ++++ b/build.gradle.kts +@@ -48,6 +48,13 @@ dependencies { + runtimeOnly("org.apache.maven.resolver:maven-resolver-connector-basic:1.7.3") + runtimeOnly("org.apache.maven.resolver:maven-resolver-transport-http:1.7.3") + ++ // Pufferfish start ++ implementation("org.yaml:snakeyaml:1.33") ++ implementation("me.carleslc.Simple-YAML:Simple-Yaml:1.8.3") { ++ exclude(group = "org.yaml", module = "snakeyaml") ++ } ++ // Pufferfish end ++ + testImplementation("io.github.classgraph:classgraph:4.8.47") // Paper - mob goal test + testImplementation("junit:junit:4.13.2") + testImplementation("org.hamcrest:hamcrest-library:1.3") diff --git a/src/main/java/co/aikar/timings/TimingsExport.java b/src/main/java/co/aikar/timings/TimingsExport.java -index 2cc44fbf8e5bd436b6d4e19f6c06b351e750cb31..00f30e047beefe914543718009947ecc60c21790 100644 +index 781fc0a92f73be73b9313e7bc4eeb2f2ed6ff8ea..b40c03e42e02bca29fe8b107d9382db6e49c1d1e 100644 --- a/src/main/java/co/aikar/timings/TimingsExport.java +++ b/src/main/java/co/aikar/timings/TimingsExport.java -@@ -242,7 +242,8 @@ public class TimingsExport extends Thread { - pair("spigot", mapAsJSON(Bukkit.spigot().getSpigotConfig(), null)), +@@ -307,8 +307,9 @@ public class TimingsExport extends Thread { pair("bukkit", mapAsJSON(Bukkit.spigot().getBukkitConfig(), null)), - pair("paper", mapAsJSON(Bukkit.spigot().getPaperConfig(), null)), // Pufferfish -- pair("pufferfish", mapAsJSON(gg.pufferfish.pufferfish.PufferfishConfig.getConfigCopy(), null)) // Pufferfish -+ pair("pufferfish", mapAsJSON(gg.pufferfish.pufferfish.PufferfishConfig.getConfigCopy(), null)), // Pufferfish + // Gale start - Gale configuration - include in timings + pair("paper", mapAsJSON(Bukkit.spigot().getPaperConfig(), null)), +- pair("gale", mapAsJSON(Bukkit.spigot().getGaleConfig(), null)) ++ pair("gale", mapAsJSON(Bukkit.spigot().getGaleConfig(), null)), + // Gale end - Gale configuration - include in timings + pair("leaf", mapAsJSON(org.dreeam.leaf.LeafConfig.getConfigCopy(), null)) // Leaf )); new TimingsExport(listeners, parent, history).start(); diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index c69cb21f2ccf0f93a7ec17d4ee1ddb0ba5cfa5b2..3bed5eb755e97149a9651ca007564275e0eaf2d1 100644 +index 51704170ca171440e198a51b7fba563dca8debb6..108245311279757c17b543b8bb0fcafd31c5eaf8 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -1656,7 +1656,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop // Pufferfish - Pufferfish > // Paper - Paper > // Spigot - Spigot > // CraftBukkit - cb > vanilla! -+ return org.dreeam.leaf.LeafConfig.serverModName; // Leaf - Leaf > // Pufferfish - Pufferfish > // Paper - Paper > // Spigot - Spigot > // CraftBukkit - cb > vanilla! +- return "Leaf"; // Leaf - Leaf > // Gale - branding changes - Gale > // Paper - Paper > // Spigot - Spigot > // CraftBukkit - cb > vanilla! ++ return org.dreeam.leaf.LeafConfig.serverModName; // Leaf - Leaf > // Gale - branding changes - Gale > // Paper - Paper > // Spigot - Spigot > // CraftBukkit - cb > vanilla! } public SystemReport fillSystemReport(SystemReport details) { diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -index 673fb3955291407be37dc78be4eec9bf2018128b..a7023765e3c82e70574069af00227e3cf6f98e65 100644 +index b49b2fe152b70c8020ba2edc48d46cc4fe8d525e..9eee6da2d5eb3cce22ab0b7fc842485503d03070 100644 --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -@@ -223,6 +223,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -227,6 +227,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface + com.destroystokyo.paper.VersionHistoryManager.INSTANCE.getClass(); // load version history now + io.papermc.paper.brigadier.PaperBrigadierProviderImpl.INSTANCE.getClass(); // init PaperBrigadierProvider // Paper end - gg.pufferfish.pufferfish.PufferfishConfig.load(); // Pufferfish - gg.pufferfish.pufferfish.PufferfishCommand.init(); // Pufferfish ++<<<<<<< HEAD + + // Gale start - CPU core estimation + if (GaleGlobalConfiguration.get().logToConsole.cpuCoresEstimation) { +@@ -247,6 +248,11 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface + LOGGER.warn("If you would like to disable this message, set simd.warn-if-disabled to false in gale-global.yml"); + } + // Gale start - Pufferfish - SIMD support ++======= ++ gg.pufferfish.pufferfish.PufferfishConfig.load(); // Pufferfish ++ gg.pufferfish.pufferfish.PufferfishCommand.init(); // Pufferfish + org.dreeam.leaf.LeafConfig.load(); // Leaf ++>>>>>>> Leaf Config this.setPvpAllowed(dedicatedserverproperties.pvp); this.setFlightAllowed(dedicatedserverproperties.allowFlight); diff --git a/patches/server/0003-Bump-Dependencies.patch b/patches/server/0003-Bump-Dependencies.patch index 1ff80162..8720c5f7 100644 --- a/patches/server/0003-Bump-Dependencies.patch +++ b/patches/server/0003-Bump-Dependencies.patch @@ -5,25 +5,19 @@ Subject: [PATCH] Bump Dependencies diff --git a/build.gradle.kts b/build.gradle.kts -index b52c4f00f4a10c0f748182e39c9c1daeb0c4904b..6e7ff4c213a05d0858c057cd1d81f0de77e3d926 100644 +index 038ea85f4c9c1fcd0c4d3127944dfc81ed831d4f..cc4c8d671a27c5cca17f2881603099e14c86c232 100644 --- a/build.gradle.kts +++ b/build.gradle.kts -@@ -9,12 +9,12 @@ plugins { - dependencies { - implementation(project(":leaf-api")) // Paper // Pufferfish // Leaf - // Pufferfish start -- implementation("io.papermc.paper:paper-mojangapi:1.19.2-R0.1-SNAPSHOT") { -+ implementation("io.papermc.paper:paper-mojangapi:1.19.3-R0.1-SNAPSHOT") { - exclude("io.papermc.paper", "paper-api") - } - // Pufferfish end +@@ -17,7 +17,7 @@ dependencies { + // Gale end - project setup + implementation("io.projectreactor.tools:blockhound:1.0.7.RELEASE") // Gale - base thread pool - watch for blocking base threads // Paper start - implementation("org.jline:jline-terminal-jansi:3.21.0") + implementation("org.jline:jline-terminal-jansi:3.22.0") implementation("net.minecrell:terminalconsoleappender:1.3.0") /* Required to add the missing Log4j2Plugins.dat file from log4j-core -@@ -22,40 +22,40 @@ dependencies { +@@ -25,28 +25,28 @@ dependencies { all its classes to check if they are plugins. Scanning takes about 1-2 seconds so adding this speeds up the server start. */ @@ -61,14 +55,10 @@ index b52c4f00f4a10c0f748182e39c9c1daeb0c4904b..6e7ff4c213a05d0858c057cd1d81f0de + runtimeOnly("org.apache.maven.resolver:maven-resolver-transport-http:1.7.3") // Leaf TODO - Bump later, need to fix breaking compatibility // Pufferfish start -- implementation("org.yaml:snakeyaml:1.32") -- implementation ("me.carleslc.Simple-YAML:Simple-Yaml:1.8.2") { -+ implementation("org.yaml:snakeyaml:1.33") -+ implementation ("me.carleslc.Simple-YAML:Simple-Yaml:1.8.3") { - exclude(group="org.yaml", module="snakeyaml") + implementation("org.yaml:snakeyaml:1.33") +@@ -55,9 +55,9 @@ dependencies { } // Pufferfish end - implementation("com.github.technove:Flare:34637f3f87") // Pufferfish - flare - testImplementation("io.github.classgraph:classgraph:4.8.47") // Paper - mob goal test + testImplementation("io.github.classgraph:classgraph:4.8.154") // Paper - mob goal test @@ -78,7 +68,7 @@ index b52c4f00f4a10c0f748182e39c9c1daeb0c4904b..6e7ff4c213a05d0858c057cd1d81f0de implementation("io.netty:netty-all:4.1.87.Final"); // Paper - Bump netty } -@@ -206,3 +206,6 @@ tasks.registerRunTask("runDev") { +@@ -214,3 +214,6 @@ tasks.registerRunTask("runDev") { description = "Spin up a non-relocated Mojang-mapped test server" classpath(sourceSets.main.map { it.runtimeClasspath }) } diff --git a/patches/server/0004-Remove-Mojang-username-check.patch b/patches/server/0004-Remove-Mojang-username-check.patch index 5cddb3de..5c3fcf57 100644 --- a/patches/server/0004-Remove-Mojang-username-check.patch +++ b/patches/server/0004-Remove-Mojang-username-check.patch @@ -5,26 +5,30 @@ Subject: [PATCH] Remove Mojang username check diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -index f3b340fc6be9878d677a76673450aac3e0b73d4b..3011018c8fa221f515cf670dea9791f8c4ea1f69 100644 +index 9b924f0793d8231244c160a5bc7ac8e1a35bad34..0057ccf67eeff26330753cb769db0532063d8d5d 100644 --- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -@@ -36,6 +36,7 @@ import net.minecraft.util.Crypt; +@@ -37,6 +37,7 @@ import net.minecraft.util.Crypt; import net.minecraft.util.CryptException; import net.minecraft.util.RandomSource; import org.apache.commons.lang3.Validate; +import org.dreeam.leaf.LeafConfig; + import org.galemc.gale.configuration.GaleGlobalConfiguration; import org.slf4j.Logger; - // CraftBukkit start -@@ -237,7 +238,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, - @Override +@@ -243,10 +244,10 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, public void handleHello(ServerboundHelloPacket packet) { - Validate.validState(this.state == ServerLoginPacketListenerImpl.State.HELLO, "Unexpected hello packet", new Object[0]); -- Validate.validState(ServerLoginPacketListenerImpl.isValidUsername(packet.name()), "Invalid characters in username", new Object[0]); -+ if (!LeafConfig.removeMojangUsernameCheck) Validate.validState(ServerLoginPacketListenerImpl.isValidUsername(packet.name()), "Invalid characters in username", new Object[0]); // Leaf - Remove Mojang's username check + // Gale start - JettPack - reduce array allocations + Validate.validState(this.state == ServerLoginPacketListenerImpl.State.HELLO, "Unexpected hello packet", ArrayConstants.emptyObjectArray); +- Validate.validState(ServerLoginPacketListenerImpl.isValidUsername(packet.name()), "Invalid characters in username", ArrayConstants.emptyObjectArray); ++ if (!LeafConfig.removeMojangUsernameCheck) Validate.validState(ServerLoginPacketListenerImpl.isValidUsername(packet.name()), "Invalid characters in username", ArrayConstants.emptyObjectArray); // Leaf - Remove Mojang's username check + // Gale end - JettPack - reduce array allocations // Paper start - validate usernames - if (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode() && io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.performUsernameValidation) { +- if (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode() && io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.performUsernameValidation) { ++ if (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode() && io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.performUsernameValidation || !LeafConfig.removeMojangUsernameCheck) { // Leaf - Remove Mojang's username check if (!this.iKnowThisMayNotBeTheBestIdeaButPleaseDisableUsernameValidation && !validateUsername(packet.name())) { + ServerLoginPacketListenerImpl.this.disconnect("Failed to verify username!"); + return; diff --git a/src/main/java/org/dreeam/leaf/LeafConfig.java b/src/main/java/org/dreeam/leaf/LeafConfig.java index 770553ef8976d76067396276792ea23a7ab7d51d..7870c85030144831936d692dde4fff7bedd692da 100644 --- a/src/main/java/org/dreeam/leaf/LeafConfig.java diff --git a/patches/server/0005-Remove-Spigot-Check-for-Broken-BungeeCord-Configurat.patch b/patches/server/0005-Remove-Spigot-Check-for-Broken-BungeeCord-Configurat.patch index 11584715..1297abbc 100644 --- a/patches/server/0005-Remove-Spigot-Check-for-Broken-BungeeCord-Configurat.patch +++ b/patches/server/0005-Remove-Spigot-Check-for-Broken-BungeeCord-Configurat.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Remove Spigot Check for Broken BungeeCord Configurations diff --git a/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java -index e7ff7ad3bf4dd17fdd34202ec3aef8e9512bc36d..a00c7ba6d2161ce91ade78e3d53c8d57f86e9c99 100644 +index 8e68d1373a519cc12bf83de6aadcb24cbbd34af6..a5776ef739b1bf8c8efed0a97d0939e271c8ba72 100644 --- a/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java -@@ -9,6 +9,7 @@ import net.minecraft.network.protocol.handshake.ClientIntentionPacket; +@@ -10,6 +10,7 @@ import net.minecraft.network.protocol.handshake.ClientIntentionPacket; import net.minecraft.network.protocol.handshake.ServerHandshakePacketListener; import net.minecraft.network.protocol.login.ClientboundLoginDisconnectPacket; import net.minecraft.server.MinecraftServer; @@ -16,7 +16,7 @@ index e7ff7ad3bf4dd17fdd34202ec3aef8e9512bc36d..a00c7ba6d2161ce91ade78e3d53c8d57 // CraftBukkit start import java.net.InetAddress; -@@ -139,7 +140,9 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL +@@ -135,7 +136,9 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL { connection.spoofedProfile = ServerHandshakePacketListenerImpl.gson.fromJson(split[3], com.mojang.authlib.properties.Property[].class); } diff --git a/patches/server/0007-Remove-UseItemOnPacket-Too-Far-Check.patch b/patches/server/0007-Remove-UseItemOnPacket-Too-Far-Check.patch index 0dd48412..8e4344ee 100644 --- a/patches/server/0007-Remove-UseItemOnPacket-Too-Far-Check.patch +++ b/patches/server/0007-Remove-UseItemOnPacket-Too-Far-Check.patch @@ -7,18 +7,18 @@ This Check is added in 1.17.x -> 1.18.x update by Mojang. By removing this check, it enable hackers to use some modules of hack clients. diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 34540b4ebad2ec430fa12e1e5d9d6e4a79df91de..84cb548e89350d9127b18f69e47d1f7433bcb1ee 100644 +index 93a533bdeb5108f5c3e758f8062de083283fd075..5a656751b101d914afd5b07d70e60b50009ed215 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -182,6 +182,7 @@ import net.minecraft.world.phys.Vec3; - import net.minecraft.world.phys.shapes.BooleanOp; - import net.minecraft.world.phys.shapes.Shapes; - import net.minecraft.world.phys.shapes.VoxelShape; +@@ -188,6 +188,7 @@ import org.bukkit.craftbukkit.util.permissions.CraftDefaultPermissions; + import org.galemc.gale.configuration.GaleGlobalConfiguration; + import org.galemc.gale.executor.queue.BaseTaskQueues; + import org.galemc.gale.executor.queue.ScheduledServerThreadTaskQueues; +import org.dreeam.leaf.LeafConfig; import org.slf4j.Logger; // CraftBukkit start -@@ -1948,7 +1949,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -1979,7 +1980,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic Vec3 vec3d2 = vec3d.subtract(vec3d1); double d0 = 1.0000001D; diff --git a/patches/server/0008-Purpur-Fix-decompile-errors.patch b/patches/server/0008-Purpur-Fix-decompile-errors.patch index 017f0d34..d6bd6cec 100644 --- a/patches/server/0008-Purpur-Fix-decompile-errors.patch +++ b/patches/server/0008-Purpur-Fix-decompile-errors.patch @@ -19,32 +19,6 @@ index 0c5caad2a5bfc14450cf8d37f988ee176e8d1450..05a0a890a719a957d9aea736d6c0e85b this.setVariant(holder); this.direction = Direction.from2DDataValue(nbt.getByte("facing")); super.readAdditionalSaveData(nbt); -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 5956a7759964f5e4939f062e93714fba64f53141..0ca82175ec91ca8b3418c0931682c972666c47f8 100644 ---- a/src/main/java/net/minecraft/world/entity/monster/Zoglin.java -+++ b/src/main/java/net/minecraft/world/entity/monster/Zoglin.java -@@ -182,7 +182,7 @@ public class Zoglin extends Monster implements Enemy, HoglinBase { - - @Override - public Brain getBrain() { -- return super.getBrain(); -+ return (Brain) super.getBrain(); // Purpur - decompile error - } - - protected void updateActivity() { -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 ac75c54e897565e340b66823caeed92ba1d1641a..769e4fbaac01a4fe3a45bd9cab5c63b61fc69f53 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 -@@ -70,7 +70,7 @@ public class PiglinBrute extends AbstractPiglin { - - @Override - public Brain getBrain() { -- return super.getBrain(); -+ return (Brain) super.getBrain(); // Purpur - decompile error - } - - @Override diff --git a/src/main/java/net/minecraft/world/level/block/Blocks.java b/src/main/java/net/minecraft/world/level/block/Blocks.java index 42f46d338886e2892ee4219d19be4dc97f61616f..fdd3aa81644087bff33a47c5f98e14ca0452f3ef 100644 --- a/src/main/java/net/minecraft/world/level/block/Blocks.java diff --git a/patches/server/0009-Purpur-Implement-TPSBar.patch b/patches/server/0009-Purpur-Implement-TPSBar.patch index cb971e58..331def97 100644 --- a/patches/server/0009-Purpur-Implement-TPSBar.patch +++ b/patches/server/0009-Purpur-Implement-TPSBar.patch @@ -54,10 +54,10 @@ index ae5dd08de75a7ed231295f306fd0974da3988249..b8d49f7607c646216d42f4e047997d47 if (this.source.acceptsSuccess() && !this.silent) { this.source.sendSystemMessage(message); diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java -index 330f6c79417378da855326b4da665f9d240e748d..564830a1d511716ab977923ba43fa38c475f484f 100644 +index c7083450b3466d80611b5efdac78b31ac2e70cf5..0e8700ccc884957f08fa382723a3784d94da0f0e 100644 --- a/src/main/java/net/minecraft/commands/Commands.java +++ b/src/main/java/net/minecraft/commands/Commands.java -@@ -215,6 +215,7 @@ public class Commands { +@@ -214,6 +214,7 @@ public class Commands { SetPlayerIdleTimeoutCommand.register(this.dispatcher); StopCommand.register(this.dispatcher); WhitelistCommand.register(this.dispatcher); @@ -66,10 +66,10 @@ index 330f6c79417378da855326b4da665f9d240e748d..564830a1d511716ab977923ba43fa38c if (environment.includeIntegrated) { diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 3bed5eb755e97149a9651ca007564275e0eaf2d1..ab0a4a36241bee59b142df65736003c69dcb3dd4 100644 +index 108245311279757c17b543b8bb0fcafd31c5eaf8..590d697eb0b1e61d3b910ac5276598e6428189fe 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -1022,6 +1022,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop>>>>>> Leaf Config + + this.setPvpAllowed(dedicatedserverproperties.pvp); + this.setFlightAllowed(dedicatedserverproperties.allowFlight); +@@ -364,6 +360,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface + DedicatedServer.LOGGER.info("JMX monitoring enabled"); } - if (gg.pufferfish.pufferfish.PufferfishConfig.enableAsyncMobSpawning) mobSpawnExecutor.start(); // Pufferfish + BossBarTask.startAll(); // Purpur return true; } } diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java -index 7d6d3c8556033d289fdadc489e73fba478fce41a..d4ae8fc06ac5931273e6ced45158d8a3144a0bdf 100644 +index e6c2eff84ac596825a11574cf89956e70a344562..66082298aea31d17c8e9a85e3cca1951b2d53f87 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java -@@ -268,6 +268,7 @@ public class ServerPlayer extends Player { +@@ -269,6 +269,7 @@ public class ServerPlayer extends Player { public final com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet cachedSingleHashSet; // Paper public PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper public org.bukkit.event.player.PlayerQuitEvent.QuitReason quitReason = null; // Paper - there are a lot of changes to do if we change all methods leading to the event @@ -109,7 +129,7 @@ index 7d6d3c8556033d289fdadc489e73fba478fce41a..d4ae8fc06ac5931273e6ced45158d8a3 public ServerPlayer(MinecraftServer server, ServerLevel world, GameProfile profile) { super(world, world.getSharedSpawnPos(), world.getSharedSpawnAngle(), profile); -@@ -506,6 +507,7 @@ public class ServerPlayer extends Player { +@@ -507,6 +508,7 @@ public class ServerPlayer extends Player { } } @@ -117,7 +137,7 @@ index 7d6d3c8556033d289fdadc489e73fba478fce41a..d4ae8fc06ac5931273e6ced45158d8a3 } @Override -@@ -572,6 +574,7 @@ public class ServerPlayer extends Player { +@@ -573,6 +575,7 @@ public class ServerPlayer extends Player { } this.getBukkitEntity().setExtraData(nbt); // CraftBukkit @@ -125,7 +145,7 @@ index 7d6d3c8556033d289fdadc489e73fba478fce41a..d4ae8fc06ac5931273e6ced45158d8a3 } // CraftBukkit start - World fallback code, either respawn location or global spawn -@@ -2548,4 +2551,14 @@ public class ServerPlayer extends Player { +@@ -2551,4 +2554,14 @@ public class ServerPlayer extends Player { return (CraftPlayer) super.getBukkitEntity(); } // CraftBukkit end @@ -141,26 +161,26 @@ index 7d6d3c8556033d289fdadc489e73fba478fce41a..d4ae8fc06ac5931273e6ced45158d8a3 + // Purpur end } diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index 4b754f6eae683248d7fe11d6d6cb168d5dd696a2..866042589daa1d3e85645293375bd1dfc34c1982 100644 +index 0cbef825129b173a5244a195ea68444c216c0b1b..56a585f9b05e7b38900899be2fe439ac20205bc8 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java -@@ -100,6 +100,7 @@ import net.minecraft.world.scores.Objective; - import net.minecraft.world.scores.PlayerTeam; - import net.minecraft.world.scores.Scoreboard; // Paper +@@ -105,6 +105,7 @@ import net.minecraft.world.scores.Scoreboard; // Paper import net.minecraft.world.scores.Team; + import org.galemc.gale.configuration.GaleGlobalConfiguration; + import org.galemc.gale.executor.queue.ScheduledServerThreadTaskQueues; +import org.dreeam.leaf.tasks.BossBarTask; import org.slf4j.Logger; // CraftBukkit start -@@ -455,6 +456,7 @@ public abstract class PlayerList { +@@ -521,6 +522,7 @@ public abstract class PlayerList { scoreboard.addPlayerToTeam(player.getScoreboardName(), collideRuleTeam); } // Paper end + BossBarTask.addToAll(player); // Purpur // CraftBukkit - Moved from above, added world + if (GaleGlobalConfiguration.get().logToConsole.playerLoginLocations) { // Gale - JettPack - make logging login location configurable PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ([{}]{}, {}, {})", player.getName().getString(), s1, player.getId(), worldserver1.serverLevelData.getLevelName(), player.getX(), player.getY(), player.getZ()); - } -@@ -564,6 +566,8 @@ public abstract class PlayerList { +@@ -636,6 +638,8 @@ public abstract class PlayerList { } public net.kyori.adventure.text.Component remove(ServerPlayer entityplayer, net.kyori.adventure.text.Component leaveMessage) { // Paper end diff --git a/patches/server/0010-Purpur-Add-compass-command.patch b/patches/server/0010-Purpur-Add-compass-command.patch index f158d811..e29d6385 100644 --- a/patches/server/0010-Purpur-Add-compass-command.patch +++ b/patches/server/0010-Purpur-Add-compass-command.patch @@ -7,10 +7,10 @@ Original license: MIT Original project: https://github.com/PurpurMC/Purpur diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java -index 564830a1d511716ab977923ba43fa38c475f484f..2c5afab3cc0c66a2e63c1f647a033ca1a58f9e39 100644 +index 0e8700ccc884957f08fa382723a3784d94da0f0e..66242833210ae89cbca7448cd4e7cf1fa774bcf0 100644 --- a/src/main/java/net/minecraft/commands/Commands.java +++ b/src/main/java/net/minecraft/commands/Commands.java -@@ -216,6 +216,7 @@ public class Commands { +@@ -215,6 +215,7 @@ public class Commands { StopCommand.register(this.dispatcher); WhitelistCommand.register(this.dispatcher); org.dreeam.leaf.commands.TPSBarCommand.register(this.dispatcher); // Purpur @@ -19,10 +19,10 @@ index 564830a1d511716ab977923ba43fa38c475f484f..2c5afab3cc0c66a2e63c1f647a033ca1 if (environment.includeIntegrated) { diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java -index d4ae8fc06ac5931273e6ced45158d8a3144a0bdf..336691038e2b1a68e1cd40d7015d42acceb2b069 100644 +index 66082298aea31d17c8e9a85e3cca1951b2d53f87..d1fd3eb9e51ace68d3ffc24579cdf95ebdaea039 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java -@@ -269,6 +269,7 @@ public class ServerPlayer extends Player { +@@ -270,6 +270,7 @@ public class ServerPlayer extends Player { public PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper public org.bukkit.event.player.PlayerQuitEvent.QuitReason quitReason = null; // Paper - there are a lot of changes to do if we change all methods leading to the event private boolean tpsBar = false; // Purpur @@ -30,7 +30,7 @@ index d4ae8fc06ac5931273e6ced45158d8a3144a0bdf..336691038e2b1a68e1cd40d7015d42ac public ServerPlayer(MinecraftServer server, ServerLevel world, GameProfile profile) { super(world, world.getSharedSpawnPos(), world.getSharedSpawnAngle(), profile); -@@ -508,6 +509,7 @@ public class ServerPlayer extends Player { +@@ -509,6 +510,7 @@ public class ServerPlayer extends Player { } if (nbt.contains("Purpur.TPSBar")) { this.tpsBar = nbt.getBoolean("Purpur.TPSBar"); } // Purpur @@ -38,7 +38,7 @@ index d4ae8fc06ac5931273e6ced45158d8a3144a0bdf..336691038e2b1a68e1cd40d7015d42ac } @Override -@@ -575,6 +577,7 @@ public class ServerPlayer extends Player { +@@ -576,6 +578,7 @@ public class ServerPlayer extends Player { this.getBukkitEntity().setExtraData(nbt); // CraftBukkit nbt.putBoolean("Purpur.TPSBar", this.tpsBar); // Purpur @@ -46,7 +46,7 @@ index d4ae8fc06ac5931273e6ced45158d8a3144a0bdf..336691038e2b1a68e1cd40d7015d42ac } // CraftBukkit start - World fallback code, either respawn location or global spawn -@@ -2560,5 +2563,13 @@ public class ServerPlayer extends Player { +@@ -2563,5 +2566,13 @@ public class ServerPlayer extends Player { public void tpsBar(boolean tpsBar) { this.tpsBar = tpsBar; } diff --git a/patches/server/0011-Purpur-Implement-ram-and-rambar-commands.patch b/patches/server/0011-Purpur-Implement-ram-and-rambar-commands.patch index 212eb831..4947946a 100644 --- a/patches/server/0011-Purpur-Implement-ram-and-rambar-commands.patch +++ b/patches/server/0011-Purpur-Implement-ram-and-rambar-commands.patch @@ -7,10 +7,10 @@ Original license: MIT Original project: https://github.com/PurpurMC/Purpur diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java -index 2c5afab3cc0c66a2e63c1f647a033ca1a58f9e39..8ee8ff15f4511684261ff7a9417baa2ccd313b69 100644 +index 66242833210ae89cbca7448cd4e7cf1fa774bcf0..ff19fcd83295c6936dd83c7780d5757071ca44a5 100644 --- a/src/main/java/net/minecraft/commands/Commands.java +++ b/src/main/java/net/minecraft/commands/Commands.java -@@ -217,6 +217,8 @@ public class Commands { +@@ -216,6 +216,8 @@ public class Commands { WhitelistCommand.register(this.dispatcher); org.dreeam.leaf.commands.TPSBarCommand.register(this.dispatcher); // Purpur org.dreeam.leaf.commands.CompassCommand.register(this.dispatcher); // Purpur @@ -20,10 +20,10 @@ index 2c5afab3cc0c66a2e63c1f647a033ca1a58f9e39..8ee8ff15f4511684261ff7a9417baa2c if (environment.includeIntegrated) { diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java -index 336691038e2b1a68e1cd40d7015d42acceb2b069..cdcd1358ab8781c261c97aec03bb96118eb577f7 100644 +index d1fd3eb9e51ace68d3ffc24579cdf95ebdaea039..1b92480529c4436efe3d3b293a7af1fa95457a9d 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java -@@ -270,6 +270,7 @@ public class ServerPlayer extends Player { +@@ -271,6 +271,7 @@ public class ServerPlayer extends Player { public org.bukkit.event.player.PlayerQuitEvent.QuitReason quitReason = null; // Paper - there are a lot of changes to do if we change all methods leading to the event private boolean tpsBar = false; // Purpur private boolean compassBar = false; // Purpur @@ -31,7 +31,7 @@ index 336691038e2b1a68e1cd40d7015d42acceb2b069..cdcd1358ab8781c261c97aec03bb9611 public ServerPlayer(MinecraftServer server, ServerLevel world, GameProfile profile) { super(world, world.getSharedSpawnPos(), world.getSharedSpawnAngle(), profile); -@@ -508,6 +509,7 @@ public class ServerPlayer extends Player { +@@ -509,6 +510,7 @@ public class ServerPlayer extends Player { } } @@ -39,7 +39,7 @@ index 336691038e2b1a68e1cd40d7015d42acceb2b069..cdcd1358ab8781c261c97aec03bb9611 if (nbt.contains("Purpur.TPSBar")) { this.tpsBar = nbt.getBoolean("Purpur.TPSBar"); } // Purpur if (nbt.contains("Purpur.CompassBar")) { this.compassBar = nbt.getBoolean("Purpur.CompassBar"); } // Purpur } -@@ -576,6 +578,7 @@ public class ServerPlayer extends Player { +@@ -577,6 +579,7 @@ public class ServerPlayer extends Player { } this.getBukkitEntity().setExtraData(nbt); // CraftBukkit @@ -47,7 +47,7 @@ index 336691038e2b1a68e1cd40d7015d42acceb2b069..cdcd1358ab8781c261c97aec03bb9611 nbt.putBoolean("Purpur.TPSBar", this.tpsBar); // Purpur nbt.putBoolean("Purpur.CompassBar", this.compassBar); // Purpur } -@@ -2571,5 +2574,14 @@ public class ServerPlayer extends Player { +@@ -2574,5 +2577,14 @@ public class ServerPlayer extends Player { public void compassBar(boolean compassBar) { this.compassBar = compassBar; } diff --git a/patches/server/0012-Purpur-Lagging-threshold.patch b/patches/server/0012-Purpur-Lagging-threshold.patch index 15883ff5..88498b10 100644 --- a/patches/server/0012-Purpur-Lagging-threshold.patch +++ b/patches/server/0012-Purpur-Lagging-threshold.patch @@ -7,18 +7,18 @@ Original license: MIT Original project: https://github.com/PurpurMC/Purpur diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index ab0a4a36241bee59b142df65736003c69dcb3dd4..411fae7132b1d1763712594a18cff10d612cef7e 100644 +index 590d697eb0b1e61d3b910ac5276598e6428189fe..fe25f51ee708c76bcf66e3280bb235713c99f79c 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -305,6 +305,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop= this.maxPlayers && !this.canBypassPlayerLimit(gameprofile) ? IChatBaseComponent.translatable("multiplayer.disconnect.server_full") : null; diff --git a/patches/server/0019-Purpur-Halloween-options-and-optimizations.patch b/patches/server/0019-Purpur-Halloween-options-and-optimizations.patch deleted file mode 100644 index dbec437a..00000000 --- a/patches/server/0019-Purpur-Halloween-options-and-optimizations.patch +++ /dev/null @@ -1,79 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: DoctaEnkoda -Date: Mon, 13 Sep 2021 04:48:21 +0200 -Subject: [PATCH] Purpur: Halloween options and optimizations - -Original license: MIT -Original project: https://github.com/PurpurMC/Purpur - -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 1572a81ce1718964d795f2a2a411402f88901c73..ae2c84af8baaf1bba9b0debe3774321417d77413 100644 ---- a/src/main/java/net/minecraft/world/entity/ambient/Bat.java -+++ b/src/main/java/net/minecraft/world/entity/ambient/Bat.java -@@ -246,7 +246,7 @@ public class Bat extends AmbientCreature { - int i = world.getMaxLocalRawBrightness(pos); - byte b0 = 4; - -- if (Bat.isHalloween()) { -+ if (Bat.isHalloweenSeason(world.getMinecraftWorld())) { // Purpur - b0 = 7; - } else if (random.nextBoolean()) { - return false; -@@ -260,6 +260,7 @@ public class Bat extends AmbientCreature { - private static boolean isSpookySeason = false; - private static final int ONE_HOUR = 20 * 60 * 60; - private static int lastSpookyCheck = -ONE_HOUR; -+ public static boolean isHalloweenSeason(Level level) { return org.dreeam.leaf.LeafConfig.forceHalloweenSeason || isHalloween(); } // Purpur - private static boolean isHalloween() { - if (net.minecraft.server.MinecraftServer.currentTick - lastSpookyCheck > ONE_HOUR) { - LocalDate localdate = LocalDate.now(); -diff --git a/src/main/java/net/minecraft/world/entity/monster/AbstractSkeleton.java b/src/main/java/net/minecraft/world/entity/monster/AbstractSkeleton.java -index b8abee145fc92faddef98da913eca7715b6bfc03..41de63fdcfe48c2a77f2d04e5bffbca41c98afe3 100644 ---- a/src/main/java/net/minecraft/world/entity/monster/AbstractSkeleton.java -+++ b/src/main/java/net/minecraft/world/entity/monster/AbstractSkeleton.java -@@ -158,11 +158,7 @@ public abstract class AbstractSkeleton extends Monster implements RangedAttackMo - this.reassessWeaponGoal(); - this.setCanPickUpLoot(this.level.paperConfig().entities.behavior.mobsCanAlwaysPickUpLoot.skeletons || randomsource.nextFloat() < 0.55F * difficulty.getSpecialMultiplier()); // Paper - if (this.getItemBySlot(EquipmentSlot.HEAD).isEmpty()) { -- LocalDate localdate = LocalDate.now(); -- int i = localdate.get(ChronoField.DAY_OF_MONTH); -- int j = localdate.get(ChronoField.MONTH_OF_YEAR); -- -- if (j == 10 && i == 31 && randomsource.nextFloat() < 0.25F) { -+ if (net.minecraft.world.entity.ambient.Bat.isHalloweenSeason(world.getMinecraftWorld()) && this.random.nextFloat() < org.dreeam.leaf.LeafConfig.chanceHeadHalloweenOnEntity) { // Purpur - this.setItemSlot(EquipmentSlot.HEAD, new ItemStack(randomsource.nextFloat() < 0.1F ? Blocks.JACK_O_LANTERN : Blocks.CARVED_PUMPKIN)); - this.armorDropChances[EquipmentSlot.HEAD.getIndex()] = 0.0F; - } -diff --git a/src/main/java/net/minecraft/world/entity/monster/Zombie.java b/src/main/java/net/minecraft/world/entity/monster/Zombie.java -index 9976205537cfe228735687f1e9c52c74ac025690..dfe4c6d2bf9bee2e019635d02f01dc08f99c160e 100644 ---- a/src/main/java/net/minecraft/world/entity/monster/Zombie.java -+++ b/src/main/java/net/minecraft/world/entity/monster/Zombie.java -@@ -559,11 +559,7 @@ public class Zombie extends Monster { - } - - if (this.getItemBySlot(EquipmentSlot.HEAD).isEmpty()) { -- LocalDate localdate = LocalDate.now(); -- int i = localdate.get(ChronoField.DAY_OF_MONTH); -- int j = localdate.get(ChronoField.MONTH_OF_YEAR); -- -- if (j == 10 && i == 31 && randomsource.nextFloat() < 0.25F) { -+ if (net.minecraft.world.entity.ambient.Bat.isHalloweenSeason(world.getMinecraftWorld()) && this.random.nextFloat() < org.dreeam.leaf.LeafConfig.chanceHeadHalloweenOnEntity) { // Purpur - this.setItemSlot(EquipmentSlot.HEAD, new ItemStack(randomsource.nextFloat() < 0.1F ? Blocks.JACK_O_LANTERN : Blocks.CARVED_PUMPKIN)); - this.armorDropChances[EquipmentSlot.HEAD.getIndex()] = 0.0F; - } -diff --git a/src/main/java/org/dreeam/leaf/LeafConfig.java b/src/main/java/org/dreeam/leaf/LeafConfig.java -index 040c1f584c525990ec844cba9f01df5b33fa2a37..2855f8c4684cb9afee1bd8a4c2ae82d45ef1ea2b 100644 ---- a/src/main/java/org/dreeam/leaf/LeafConfig.java -+++ b/src/main/java/org/dreeam/leaf/LeafConfig.java -@@ -256,4 +256,11 @@ public class LeafConfig { - advancementOnlyBroadcastToAffectedPlayer = getBoolean("settings.broadcasts.advancement.only-broadcast-to-affected-player", advancementOnlyBroadcastToAffectedPlayer); - deathMessageOnlyBroadcastToAffectedPlayer = getBoolean("settings.broadcasts.death.only-broadcast-to-affected-player", deathMessageOnlyBroadcastToAffectedPlayer); - } -+ -+ public static boolean forceHalloweenSeason = false; -+ public static float chanceHeadHalloweenOnEntity = 0.25F; -+ private static void halloweenSetting() { -+ forceHalloweenSeason = getBoolean("gameplay-mechanics.halloween.force", forceHalloweenSeason); -+ chanceHeadHalloweenOnEntity = (float) getDouble("gameplay-mechanics.halloween.head-chance", chanceHeadHalloweenOnEntity); -+ } - } diff --git a/patches/server/0020-Purpur-Persistent-BlockEntity-Lore-and-DisplayName.patch b/patches/server/0019-Purpur-Persistent-BlockEntity-Lore-and-DisplayName.patch similarity index 91% rename from patches/server/0020-Purpur-Persistent-BlockEntity-Lore-and-DisplayName.patch rename to patches/server/0019-Purpur-Persistent-BlockEntity-Lore-and-DisplayName.patch index f62cbd51..8b0bd2a6 100644 --- a/patches/server/0020-Purpur-Persistent-BlockEntity-Lore-and-DisplayName.patch +++ b/patches/server/0019-Purpur-Persistent-BlockEntity-Lore-and-DisplayName.patch @@ -40,10 +40,10 @@ index b0204af850ee182773ad458208cccd946ad148d5..f74e420b1791df528a30a1213bb0076b @Nullable diff --git a/src/main/java/net/minecraft/world/level/block/Block.java b/src/main/java/net/minecraft/world/level/block/Block.java -index 7b71073027f4cf79736546500ededdfbb83d968e..98c9c1899a311e76179f72fa1c43830fb5b9c521 100644 +index 39981cd0003eb7ee416d887ffec70fb049599320..a5a1773109123c3499d6b2b02b76805d66764ec5 100644 --- a/src/main/java/net/minecraft/world/level/block/Block.java +++ b/src/main/java/net/minecraft/world/level/block/Block.java -@@ -63,6 +63,13 @@ import net.minecraft.world.phys.shapes.Shapes; +@@ -65,6 +65,13 @@ import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; import org.slf4j.Logger; @@ -57,7 +57,7 @@ index 7b71073027f4cf79736546500ededdfbb83d968e..98c9c1899a311e76179f72fa1c43830f public class Block extends BlockBehaviour implements ItemLike { private static final Logger LOGGER = LogUtils.getLogger(); -@@ -325,7 +332,7 @@ public class Block extends BlockBehaviour implements ItemLike { +@@ -328,7 +335,7 @@ public class Block extends BlockBehaviour implements ItemLike { public static void dropResources(BlockState state, LevelAccessor world, BlockPos pos, @Nullable BlockEntity blockEntity) { if (world instanceof ServerLevel) { Block.getDrops(state, (ServerLevel) world, pos, blockEntity).forEach((itemstack) -> { @@ -66,7 +66,7 @@ index 7b71073027f4cf79736546500ededdfbb83d968e..98c9c1899a311e76179f72fa1c43830f }); state.spawnAfterBreak((ServerLevel) world, pos, ItemStack.EMPTY, true); } -@@ -341,7 +348,7 @@ public class Block extends BlockBehaviour implements ItemLike { +@@ -344,7 +351,7 @@ public class Block extends BlockBehaviour implements ItemLike { io.papermc.paper.event.block.BlockBreakBlockEvent event = new io.papermc.paper.event.block.BlockBreakBlockEvent(org.bukkit.craftbukkit.block.CraftBlock.at(world, pos), org.bukkit.craftbukkit.block.CraftBlock.at(world, source), items); event.callEvent(); for (var drop : event.getDrops()) { @@ -75,7 +75,7 @@ index 7b71073027f4cf79736546500ededdfbb83d968e..98c9c1899a311e76179f72fa1c43830f } state.spawnAfterBreak(world.getMinecraftWorld(), pos, ItemStack.EMPTY, true); } -@@ -352,13 +359,53 @@ public class Block extends BlockBehaviour implements ItemLike { +@@ -355,13 +362,53 @@ public class Block extends BlockBehaviour implements ItemLike { public static void dropResources(BlockState state, Level world, BlockPos pos, @Nullable BlockEntity blockEntity, Entity entity, ItemStack stack) { if (world instanceof ServerLevel) { Block.getDrops(state, (ServerLevel) world, pos, blockEntity, entity, stack).forEach((itemstack1) -> { @@ -198,12 +198,12 @@ index 58986bc0677c5ea1ad54d7d6d4efa5c2ea233aea..59d616137088af46d4494171fe96ba01 + // Purpur end } diff --git a/src/main/java/org/dreeam/leaf/LeafConfig.java b/src/main/java/org/dreeam/leaf/LeafConfig.java -index 2855f8c4684cb9afee1bd8a4c2ae82d45ef1ea2b..f87f4f19738dfe8b58d3dbf0c27933fd3ec93883 100644 +index 040c1f584c525990ec844cba9f01df5b33fa2a37..414516ee3596bcde783900200823e8ed00dae6fe 100644 --- a/src/main/java/org/dreeam/leaf/LeafConfig.java +++ b/src/main/java/org/dreeam/leaf/LeafConfig.java -@@ -263,4 +263,9 @@ public class LeafConfig { - forceHalloweenSeason = getBoolean("gameplay-mechanics.halloween.force", forceHalloweenSeason); - chanceHeadHalloweenOnEntity = (float) getDouble("gameplay-mechanics.halloween.head-chance", chanceHeadHalloweenOnEntity); +@@ -256,4 +256,9 @@ public class LeafConfig { + advancementOnlyBroadcastToAffectedPlayer = getBoolean("settings.broadcasts.advancement.only-broadcast-to-affected-player", advancementOnlyBroadcastToAffectedPlayer); + deathMessageOnlyBroadcastToAffectedPlayer = getBoolean("settings.broadcasts.death.only-broadcast-to-affected-player", deathMessageOnlyBroadcastToAffectedPlayer); } + + public static boolean persistentTileEntityDisplayNames = false; diff --git a/patches/server/0021-Purpur-Add-more-logger-output-for-invalid-movement-k.patch b/patches/server/0020-Purpur-Add-more-logger-output-for-invalid-movement-k.patch similarity index 91% rename from patches/server/0021-Purpur-Add-more-logger-output-for-invalid-movement-k.patch rename to patches/server/0020-Purpur-Add-more-logger-output-for-invalid-movement-k.patch index 49170394..cc4d2ffa 100644 --- a/patches/server/0021-Purpur-Add-more-logger-output-for-invalid-movement-k.patch +++ b/patches/server/0020-Purpur-Add-more-logger-output-for-invalid-movement-k.patch @@ -7,10 +7,10 @@ Original license: MIT Original project: https://github.com/PurpurMC/Purpur diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 84cb548e89350d9127b18f69e47d1f7433bcb1ee..86e5e0caf3b341d5556665e5f5fd7d158d639118 100644 +index 5a656751b101d914afd5b07d70e60b50009ed215..4f131ca1977475513ee43120f06b7c026f49e91e 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -809,6 +809,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -837,6 +837,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic if (packet.getId() == this.awaitingTeleport) { if (this.awaitingPositionFromClient == null) { this.disconnect(Component.translatable("multiplayer.disconnect.invalid_player_movement"), org.bukkit.event.player.PlayerKickEvent.Cause.INVALID_PLAYER_MOVEMENT); // Paper - kick event cause @@ -18,7 +18,7 @@ index 84cb548e89350d9127b18f69e47d1f7433bcb1ee..86e5e0caf3b341d5556665e5f5fd7d15 return; } -@@ -1370,8 +1371,16 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -1401,8 +1402,16 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic @Override public void handleMovePlayer(ServerboundMovePlayerPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel()); diff --git a/patches/server/0022-Purpur-Log-skipped-entity-s-position.patch b/patches/server/0021-Purpur-Log-skipped-entity-s-position.patch similarity index 87% rename from patches/server/0022-Purpur-Log-skipped-entity-s-position.patch rename to patches/server/0021-Purpur-Log-skipped-entity-s-position.patch index 20be5dee..4828690b 100644 --- a/patches/server/0022-Purpur-Log-skipped-entity-s-position.patch +++ b/patches/server/0021-Purpur-Log-skipped-entity-s-position.patch @@ -7,10 +7,10 @@ Original license: MIT Original project: https://github.com/PurpurMC/Purpur diff --git a/src/main/java/net/minecraft/world/entity/EntityType.java b/src/main/java/net/minecraft/world/entity/EntityType.java -index 3e0d38ed6959d5d9f7dbae8d604acb9299b8621d..f7e8b6e1872a397c96afc938754726b0d4e493b4 100644 +index 41ff954010c11d524ffb90abd22c29a1d8d8f5a0..675da6794923cfefbe41034247a71ef929e2802c 100644 --- a/src/main/java/net/minecraft/world/entity/EntityType.java +++ b/src/main/java/net/minecraft/world/entity/EntityType.java -@@ -583,6 +583,12 @@ public class EntityType implements FeatureElement, EntityTypeT +@@ -581,6 +581,12 @@ public class EntityType implements FeatureElement, EntityTypeT entity.load(nbt); }, () -> { EntityType.LOGGER.warn("Skipping Entity with id {}", nbt.getString("id")); diff --git a/patches/server/0025-Purpur-Lobotomize-stuck-villagers.patch b/patches/server/0022-Purpur-Lobotomize-stuck-villagers.patch similarity index 84% rename from patches/server/0025-Purpur-Lobotomize-stuck-villagers.patch rename to patches/server/0022-Purpur-Lobotomize-stuck-villagers.patch index 74c28fa4..872b9c58 100644 --- a/patches/server/0025-Purpur-Lobotomize-stuck-villagers.patch +++ b/patches/server/0022-Purpur-Lobotomize-stuck-villagers.patch @@ -7,18 +7,18 @@ Original license: MIT Original project: https://github.com/PurpurMC/Purpur 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 76a9da8209d557b913c49ccd281bf147b9ac4fa4..a39d038b5198c9244e2225e0fe383f3c96b49a08 100644 +index 825cdb927925a35a53e399ee647ea0738e67a5c9..d9197a989435dacb954692c4b6b9175062f268d8 100644 --- a/src/main/java/net/minecraft/world/entity/npc/Villager.java +++ b/src/main/java/net/minecraft/world/entity/npc/Villager.java -@@ -139,6 +139,8 @@ public class Villager extends AbstractVillager implements ReputationEventHandler +@@ -141,6 +141,8 @@ public class Villager extends AbstractVillager implements ReputationEventHandler }, MemoryModuleType.MEETING_POINT, (entityvillager, holder) -> { return holder.is(PoiTypes.MEETING); }); + private boolean isLobotomized = false; public boolean isLobotomized() { return this.isLobotomized; } // Purpur + private int notLobotomizedCount = 0; // Purpur - public long nextGolemPanic = -1; // Pufferfish - + public Villager(EntityType entityType, Level world) { + this(entityType, world, VillagerType.PLAINS); @@ -155,6 +157,47 @@ public class Villager extends AbstractVillager implements ReputationEventHandler this.setVillagerData(this.getVillagerData().setType(type).setProfession(VillagerProfession.NONE)); } @@ -67,10 +67,11 @@ index 76a9da8209d557b913c49ccd281bf147b9ac4fa4..a39d038b5198c9244e2225e0fe383f3c @Override public Brain getBrain() { return (Brain) super.getBrain(); // CraftBukkit - decompile error -@@ -250,12 +293,27 @@ public class Villager extends AbstractVillager implements ReputationEventHandler +@@ -248,7 +291,24 @@ public class Villager extends AbstractVillager implements ReputationEventHandler + @Override protected void customServerAiStep() { mobTick(false); } protected void mobTick(boolean inactive) { - this.level.getProfiler().push("villagerBrain"); +- if (!inactive) this.getBrain().tick((ServerLevel) this.level, this); // Paper + // Purpur start + if (org.dreeam.leaf.LeafConfig.villagerLobotomizeEnabled) { + // treat as inactive if lobotomized @@ -80,21 +81,18 @@ index 76a9da8209d557b913c49ccd281bf147b9ac4fa4..a39d038b5198c9244e2225e0fe383f3c + this.isLobotomized = false; + } + // Purpur end - // Pufferfish start - if (!inactive) { - if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish - this.getBrain().tick((ServerLevel) this.level, this); // Paper - } - // Pufferfish end ++ if (!inactive) { ++ this.getBrain().tick((ServerLevel) this.level, this); // Paper ++ } + // Purpur start + else if (this.isLobotomized && shouldRestock()) { + // make sure we restock if needed when lobotomized + restock(); + } + // Purpur end - this.level.getProfiler().pop(); if (this.assignProfessionWhenSpawned) { this.assignProfessionWhenSpawned = false; + } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java index a1a8ac55e572156671e47317ba061855be79e5ac..ec3fb8865211bd7625103c37af7b96df37163a07 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftVillager.java @@ -112,12 +110,12 @@ index a1a8ac55e572156671e47317ba061855be79e5ac..ec3fb8865211bd7625103c37af7b96df + // Purpur end } diff --git a/src/main/java/org/dreeam/leaf/LeafConfig.java b/src/main/java/org/dreeam/leaf/LeafConfig.java -index 558c8d64305fe7266e916c51177142c2f6cb19c4..5ee72a675550520ba14e6f5b7375ba7fee326ef1 100644 +index 414516ee3596bcde783900200823e8ed00dae6fe..55879146faa26d3ed58693627f8dfe9126bf5171 100644 --- a/src/main/java/org/dreeam/leaf/LeafConfig.java +++ b/src/main/java/org/dreeam/leaf/LeafConfig.java -@@ -273,4 +273,11 @@ public class LeafConfig { - private static void sandSettings() { - fixSandDuping = getBoolean("blocks.sand.fix-duping", fixSandDuping); +@@ -261,4 +261,11 @@ public class LeafConfig { + private static void tileentitySetting() { + persistentTileEntityDisplayNames = getBoolean("gameplay-mechanics.persistent-tileentity-display-names-and-lore", persistentTileEntityDisplayNames); } + + public static boolean villagerLobotomizeEnabled = false; diff --git a/patches/server/0026-Purpur-Option-to-disable-kick-for-out-of-order-chat.patch b/patches/server/0023-Purpur-Option-to-disable-kick-for-out-of-order-chat.patch similarity index 84% rename from patches/server/0026-Purpur-Option-to-disable-kick-for-out-of-order-chat.patch rename to patches/server/0023-Purpur-Option-to-disable-kick-for-out-of-order-chat.patch index 50bfcade..0e07ed47 100644 --- a/patches/server/0026-Purpur-Option-to-disable-kick-for-out-of-order-chat.patch +++ b/patches/server/0023-Purpur-Option-to-disable-kick-for-out-of-order-chat.patch @@ -7,10 +7,10 @@ Original license: MIT Original project: https://github.com/PurpurMC/Purpur diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 1d6e9d696b7d288db4557540bd1556478849f8c8..38995416ecbfb8067069926cc0e9be1734851206 100644 +index 4f131ca1977475513ee43120f06b7c026f49e91e..9305f5d0f1323604ae2bc7cee7c19d0304874883 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -2369,7 +2369,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -2405,7 +2405,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic do { instant1 = (Instant) this.lastChatTimeStamp.get(); if (timestamp.isBefore(instant1)) { @@ -20,10 +20,10 @@ index 1d6e9d696b7d288db4557540bd1556478849f8c8..38995416ecbfb8067069926cc0e9be17 } while (!this.lastChatTimeStamp.compareAndSet(instant1, timestamp)); diff --git a/src/main/java/org/dreeam/leaf/LeafConfig.java b/src/main/java/org/dreeam/leaf/LeafConfig.java -index 5ee72a675550520ba14e6f5b7375ba7fee326ef1..dcac5cf6eb0992b3b3d51222f328b7f87936322a 100644 +index 55879146faa26d3ed58693627f8dfe9126bf5171..e0d5e00b4291e66b27a3a0c1701af3c4e7b3db26 100644 --- a/src/main/java/org/dreeam/leaf/LeafConfig.java +++ b/src/main/java/org/dreeam/leaf/LeafConfig.java -@@ -280,4 +280,9 @@ public class LeafConfig { +@@ -268,4 +268,9 @@ public class LeafConfig { villagerLobotomizeEnabled = getBoolean("mobs.villager.lobotomize.enabled", villagerLobotomizeEnabled); villagerLobotomizeCheckInterval = getInt("mobs.villager.lobotomize.check-interval", villagerLobotomizeCheckInterval); } diff --git a/patches/server/0023-Purpur-Skip-events-if-there-s-no-listeners.patch b/patches/server/0023-Purpur-Skip-events-if-there-s-no-listeners.patch deleted file mode 100644 index b0ad8848..00000000 --- a/patches/server/0023-Purpur-Skip-events-if-there-s-no-listeners.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: William Blake Galbreath -Date: Sat, 4 Apr 2020 03:07:59 -0500 -Subject: [PATCH] Purpur: Skip events if there's no listeners - -Original license: MIT -Original project: https://github.com/PurpurMC/Purpur - -diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java -index 8ee8ff15f4511684261ff7a9417baa2ccd313b69..31e44f59bd34ae79dd1147263e446e6d6e9f8c66 100644 ---- a/src/main/java/net/minecraft/commands/Commands.java -+++ b/src/main/java/net/minecraft/commands/Commands.java -@@ -429,6 +429,7 @@ public class Commands { - private void runSync(ServerPlayer player, Collection bukkit, RootCommandNode rootcommandnode) { - // Paper end - Async command map building - new com.destroystokyo.paper.event.brigadier.AsyncPlayerSendCommandsEvent(player.getBukkitEntity(), (RootCommandNode) rootcommandnode, false).callEvent(); // Paper -+ if (PlayerCommandSendEvent.getHandlerList().getRegisteredListeners().length > 0) { // Purpur - skip all this crap if there's nothing listening - PlayerCommandSendEvent event = new PlayerCommandSendEvent(player.getBukkitEntity(), new LinkedHashSet<>(bukkit)); - event.getPlayer().getServer().getPluginManager().callEvent(event); - -@@ -439,6 +440,7 @@ public class Commands { - } - } - // CraftBukkit end -+ } // Purpur - skip event - player.connection.send(new ClientboundCommandsPacket(rootcommandnode)); - } - diff --git a/patches/server/0030-KeYi-Use-a-faster-random-implementation.patch b/patches/server/0024-KeYi-Use-a-faster-random-implementation.patch similarity index 96% rename from patches/server/0030-KeYi-Use-a-faster-random-implementation.patch rename to patches/server/0024-KeYi-Use-a-faster-random-implementation.patch index 80fe7ec2..cea4aba3 100644 --- a/patches/server/0030-KeYi-Use-a-faster-random-implementation.patch +++ b/patches/server/0024-KeYi-Use-a-faster-random-implementation.patch @@ -426,10 +426,10 @@ index e5ea9f27a1936ed9e329e74317c91c5df89b9fbd..89a41d396162a1c2eb2df5192b0d888b private long lastFill = -1; private long nextRefill = -1; diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java -index 1fcdd47ee804db8d6649b603fd95c5273f40801d..2e922bb844bc147224a60ef2aae33a0125e6ca4a 100644 +index bca581f2a192015f5461e5bf776234687e5ae9fc..87161a2a3f611abdefdb2ef475a3cb64261339b8 100644 --- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java +++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java -@@ -53,6 +53,10 @@ import net.minecraft.world.level.material.Fluids; +@@ -52,6 +52,10 @@ import net.minecraft.world.level.material.Fluids; import net.minecraft.world.ticks.LevelChunkTicks; import net.minecraft.world.ticks.TickContainerAccess; import org.slf4j.Logger; @@ -440,9 +440,9 @@ index 1fcdd47ee804db8d6649b603fd95c5273f40801d..2e922bb844bc147224a60ef2aae33a01 public class LevelChunk extends ChunkAccess { -@@ -932,7 +936,7 @@ public class LevelChunk extends ChunkAccess { +@@ -931,7 +935,7 @@ public class LevelChunk extends ChunkAccess { if (this.needsDecoration) { - //try (co.aikar.timings.Timing ignored = this.level.timings.chunkLoadPopulate.startTiming()) { // Paper // Purpur + try (co.aikar.timings.Timing ignored = this.level.timings.chunkLoadPopulate.startTiming()) { // Paper this.needsDecoration = false; - java.util.Random random = new java.util.Random(); + Random random = new FastRandom(); @@ -471,18 +471,18 @@ index dcfe090c269d4cbcc2eb1b6f85392848bb34656c..ef8909c9c13c8f46ec6d452f0d14c9a1 } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index f8d321e925bf2708e51590542325c1bdc67d5964..ace7e9f66c3583fc51f06bd9963ed55968d40c0f 100644 +index 9eae3862abb5f1d7755a8e777fd4bf9a6f8e321d..ee86c8d45c6cbbc0de3039e7d319eb26a8c8f918 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -@@ -134,6 +134,7 @@ import org.bukkit.util.Consumer; - import org.bukkit.util.RayTraceResult; +@@ -132,6 +132,7 @@ import org.bukkit.util.RayTraceResult; import org.bukkit.util.StructureSearchResult; import org.bukkit.util.Vector; + import org.galemc.gale.executor.queue.ScheduledServerThreadTaskQueues; +import cc.keyimc.keyi.utils.FastRandom; // KeYi public class CraftWorld extends CraftRegionAccessor implements World { public static final int CUSTOM_DIMENSION_OFFSET = 10; -@@ -226,7 +227,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -224,7 +225,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { } // Paper end diff --git a/patches/server/0024-Purpur-Add-toggle-for-sand-duping-fix.patch b/patches/server/0024-Purpur-Add-toggle-for-sand-duping-fix.patch deleted file mode 100644 index b86fe6de..00000000 --- a/patches/server/0024-Purpur-Add-toggle-for-sand-duping-fix.patch +++ /dev/null @@ -1,44 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: William Blake Galbreath -Date: Fri, 4 Jun 2021 09:13:54 -0500 -Subject: [PATCH] Purpur: Add toggle for sand duping fix - -Original license: MIT -Original project: https://github.com/PurpurMC/Purpur - -diff --git a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java -index eacb8a407fe99af2c13f23c12b5544696bda8890..2e4476c3a563ee8899e2ea3d7f064a7d0114260d 100644 ---- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java -+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java -@@ -130,7 +130,7 @@ public class FallingBlockEntity extends Entity { - @Override - public void tick() { - // Paper start - fix sand duping -- if (this.isRemoved()) { -+ if (org.dreeam.leaf.LeafConfig.fixSandDuping && this.isRemoved()) { // Purpur - return; - } - // Paper end - fix sand duping -@@ -147,7 +147,7 @@ public class FallingBlockEntity extends Entity { - this.move(MoverType.SELF, this.getDeltaMovement()); - - // Paper start - fix sand duping -- if (this.isRemoved()) { -+ if (org.dreeam.leaf.LeafConfig.fixSandDuping && this.isRemoved()) { // Purpur - return; - } - // Paper end - fix sand duping -diff --git a/src/main/java/org/dreeam/leaf/LeafConfig.java b/src/main/java/org/dreeam/leaf/LeafConfig.java -index f87f4f19738dfe8b58d3dbf0c27933fd3ec93883..558c8d64305fe7266e916c51177142c2f6cb19c4 100644 ---- a/src/main/java/org/dreeam/leaf/LeafConfig.java -+++ b/src/main/java/org/dreeam/leaf/LeafConfig.java -@@ -268,4 +268,9 @@ public class LeafConfig { - private static void tileentitySetting() { - persistentTileEntityDisplayNames = getBoolean("gameplay-mechanics.persistent-tileentity-display-names-and-lore", persistentTileEntityDisplayNames); - } -+ -+ public static boolean fixSandDuping = true; -+ private static void sandSettings() { -+ fixSandDuping = getBoolean("blocks.sand.fix-duping", fixSandDuping); -+ } - } diff --git a/patches/server/0031-KeYi-Player-Skull-API.patch b/patches/server/0025-KeYi-Player-Skull-API.patch similarity index 92% rename from patches/server/0031-KeYi-Player-Skull-API.patch rename to patches/server/0025-KeYi-Player-Skull-API.patch index 76fe5012..41efefc3 100644 --- a/patches/server/0031-KeYi-Player-Skull-API.patch +++ b/patches/server/0025-KeYi-Player-Skull-API.patch @@ -7,7 +7,7 @@ Original license: MIT Original project: https://github.com/KeYiMC/KeYi diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 7c43de6ad6bd7259c6bcb2a55e312e8abfcf546b..472d9281199cb9cd8edafc6d2309e5e296a014cd 100644 +index d274e9373f7507dd38f2e0162c8a683b1ddde04e..7052b1fb5a2bf6099c92eeeab8c83098d97792c7 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -26,6 +26,9 @@ import java.util.Optional; @@ -28,7 +28,7 @@ index 7c43de6ad6bd7259c6bcb2a55e312e8abfcf546b..472d9281199cb9cd8edafc6d2309e5e2 import org.bukkit.map.MapCursor; import org.bukkit.map.MapView; import org.bukkit.metadata.MetadataValue; -@@ -3029,4 +3033,28 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -3036,4 +3040,28 @@ public class CraftPlayer extends CraftHumanEntity implements Player { return this.spigot; } // Spigot end diff --git a/patches/server/0032-Carpet-Fixes-Optimized-getBiome-method.patch b/patches/server/0026-Carpet-Fixes-Optimized-getBiome-method.patch similarity index 100% rename from patches/server/0032-Carpet-Fixes-Optimized-getBiome-method.patch rename to patches/server/0026-Carpet-Fixes-Optimized-getBiome-method.patch diff --git a/patches/server/0033-Carpet-Fixes-Use-optimized-RecipeManager.patch b/patches/server/0027-Carpet-Fixes-Use-optimized-RecipeManager.patch similarity index 100% rename from patches/server/0033-Carpet-Fixes-Use-optimized-RecipeManager.patch rename to patches/server/0027-Carpet-Fixes-Use-optimized-RecipeManager.patch diff --git a/patches/server/0027-Purpur-Remove-Timings.patch b/patches/server/0027-Purpur-Remove-Timings.patch deleted file mode 100644 index b7359eb8..00000000 --- a/patches/server/0027-Purpur-Remove-Timings.patch +++ /dev/null @@ -1,954 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: BillyGalbreath -Date: Fri, 1 Jul 2022 04:03:37 -0500 -Subject: [PATCH] Purpur: Remove Timings - -Original license: MIT -Original project: https://github.com/PurpurMC/Purpur - -diff --git a/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkHolderManager.java b/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkHolderManager.java -index e5d9c6f2cbe11c2ded6d8ad111fa6a8b2086dfba..830d863cd9665d58875bfa5ca2bcd22f89ab2d49 100644 ---- a/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkHolderManager.java -+++ b/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkHolderManager.java -@@ -915,9 +915,9 @@ public final class ChunkHolderManager { - } - - public boolean processTicketUpdates() { -- co.aikar.timings.MinecraftTimings.distanceManagerTick.startTiming(); try { // Paper - add timings for distance manager -+ //co.aikar.timings.MinecraftTimings.distanceManagerTick.startTiming(); try { // Paper - add timings for distance manager // Purpur - return this.processTicketUpdates(true, true, null); -- } finally { co.aikar.timings.MinecraftTimings.distanceManagerTick.stopTiming(); } // Paper - add timings for distance manager -+ //} finally { co.aikar.timings.MinecraftTimings.distanceManagerTick.stopTiming(); } // Paper - add timings for distance manager // Purpur - } - - private static final ThreadLocal> CURRENT_TICKET_UPDATE_SCHEDULING = new ThreadLocal<>(); -diff --git a/src/main/java/io/papermc/paper/chunk/system/scheduling/NewChunkHolder.java b/src/main/java/io/papermc/paper/chunk/system/scheduling/NewChunkHolder.java -index 8013dd333e27aa5fd0beb431fa32491eec9f5246..e42eb93fd9f6f51ff5bb4b14a2304d4ffcdd8441 100644 ---- a/src/main/java/io/papermc/paper/chunk/system/scheduling/NewChunkHolder.java -+++ b/src/main/java/io/papermc/paper/chunk/system/scheduling/NewChunkHolder.java -@@ -1750,7 +1750,7 @@ public final class NewChunkHolder { - boolean canSavePOI = !(chunk instanceof LevelChunk levelChunk && levelChunk.mustNotSave) && (poi != null && poi.isDirty()); - boolean canSaveEntities = entities != null; - -- try (co.aikar.timings.Timing ignored = this.world.timings.chunkSave.startTiming()) { // Paper -+ //try (co.aikar.timings.Timing ignored = this.world.timings.chunkSave.startTiming()) { // Paper // Purpur - if (canSaveChunk) { - canSaveChunk = this.saveChunk(chunk, unloading); - } -@@ -1764,7 +1764,7 @@ public final class NewChunkHolder { - this.lastEntityUnload = null; - } - } -- } -+ //} // Purpur - - return executedUnloadTask | canSaveChunk | canSaveEntities | canSavePOI ? new SaveStat(executedUnloadTask || canSaveChunk, canSaveEntities, canSavePOI): null; - } -diff --git a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java -index 01bdf134fc21220ab7ecca51f2dcd51c0b466bba..6bf14183a3fcd2b3d166752ce33240d2ff1ffa7c 100644 ---- a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java -+++ b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java -@@ -67,14 +67,14 @@ public class GlobalConfiguration extends ConfigurationPart { - - @Override - public void postProcess() { -- // Pufferfish start -+ /*// Pufferfish start // Purpur - if (enabled && !reallyEnabled) { - Bukkit.getLogger().log(Level.WARNING, "[Pufferfish] To improve performance, timings have been disabled by default"); - Bukkit.getLogger().log(Level.WARNING, "[Pufferfish] You can still use timings by using /timings on, but they will not start on server startup unless you set timings.really-enabled to true in paper.yml"); - Bukkit.getLogger().log(Level.WARNING, "[Pufferfish] If you would like to disable this message, either set timings.really-enabled to true or timings.enabled to false."); - } - enabled = reallyEnabled; -- // Pufferfish end -+ */// Pufferfish end // Purpur - MinecraftTimings.processConfig(this); - } - } -diff --git a/src/main/java/net/minecraft/network/protocol/PacketUtils.java b/src/main/java/net/minecraft/network/protocol/PacketUtils.java -index 27d4aa45e585842c04491839826d405d6f447f0e..767623a35dda71d77c65602e10ef2b3f0ae743f1 100644 ---- a/src/main/java/net/minecraft/network/protocol/PacketUtils.java -+++ b/src/main/java/net/minecraft/network/protocol/PacketUtils.java -@@ -47,8 +47,9 @@ public class PacketUtils { - if (MinecraftServer.getServer().hasStopped() || (listener instanceof ServerGamePacketListenerImpl && ((ServerGamePacketListenerImpl) listener).processedDisconnect)) return; // CraftBukkit, MC-142590 - if (listener.getConnection().isConnected()) { - co.aikar.timings.Timing timing = co.aikar.timings.MinecraftTimings.getPacketTiming(packet); // Paper - timings -- try (co.aikar.timings.Timing ignored = timing.startTiming()) { // Paper - timings -+ //try (co.aikar.timings.Timing ignored = timing.startTiming()) { // Paper - timings // Purpur - packet.handle(listener); -+ /* // Purpur - } catch (Exception exception) { - net.minecraft.network.Connection networkmanager = listener.getConnection(); - String playerIP = io.papermc.paper.configuration.GlobalConfiguration.get().logging.logPlayerIpAddresses ? String.valueOf(networkmanager.getRemoteAddress()) : ""; // Paper -@@ -60,7 +61,7 @@ public class PacketUtils { - net.minecraft.network.chat.Component error = net.minecraft.network.chat.Component.literal("Packet processing error"); - networkmanager.send(new net.minecraft.network.protocol.game.ClientboundDisconnectPacket(error), net.minecraft.network.PacketSendListener.thenRun(() -> networkmanager.disconnect(error))); - networkmanager.setReadOnly(); -- } -+ } */ // Purpur - } else { - PacketUtils.LOGGER.debug("Ignoring packet due to disconnection: {}", packet); - } -diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 75daffc4eaa831708f1ccfa5370ddf1871998033..a0e94d7a3ae1b6d28811324d24dff7ac5c6d4c16 100644 ---- a/src/main/java/net/minecraft/server/MinecraftServer.java -+++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -1393,15 +1393,15 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { - return !this.canOversleep(); - }); -- isOversleep = false;MinecraftTimings.serverOversleep.stopTiming(); -+ //isOversleep = false;MinecraftTimings.serverOversleep.stopTiming(); // Purpur - // Paper end - new com.destroystokyo.paper.event.server.ServerTickStartEvent(this.tickCount+1).callEvent(); // Paper - -@@ -1453,9 +1453,9 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop list = Lists.newArrayList(); - List list1 = this.level.players(); - ObjectIterator objectiterator = this.entityMap.values().iterator(); -- level.timings.tracker1.startTiming(); // Paper -+ //level.timings.tracker1.startTiming(); // Paper // Purpur - - ChunkMap.TrackedEntity playerchunkmap_entitytracker; - -@@ -1307,17 +1307,17 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider - playerchunkmap_entitytracker.serverEntity.sendChanges(); - } - } -- level.timings.tracker1.stopTiming(); // Paper -+ //level.timings.tracker1.stopTiming(); // Paper // Purpur - - if (!list.isEmpty()) { - objectiterator = this.entityMap.values().iterator(); - -- level.timings.tracker2.startTiming(); // Paper -+ //level.timings.tracker2.startTiming(); // Paper // Purpur - while (objectiterator.hasNext()) { - playerchunkmap_entitytracker = (ChunkMap.TrackedEntity) objectiterator.next(); - playerchunkmap_entitytracker.updatePlayers(list); - } -- level.timings.tracker2.stopTiming(); // Paper -+ //level.timings.tracker2.stopTiming(); // Paper // Purpur - } - - } -diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index c6f5d6756fa0e068a462d9c0ded12e0771abba37..2c23321c826d929981df51f2cc60cdcdb649a43f 100644 ---- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java -+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -@@ -450,10 +450,10 @@ public class ServerChunkCache extends ChunkSource { - io.papermc.paper.chunk.system.scheduling.ChunkTaskScheduler.pushChunkWait(this.level, x1, z1); // Paper - rewrite chunk system - // Paper end - com.destroystokyo.paper.io.SyncLoadFinder.logSyncLoad(this.level, x1, z1); // Paper - sync load info -- this.level.timings.syncChunkLoad.startTiming(); // Paper -+ //this.level.timings.syncChunkLoad.startTiming(); // Paper // Purpur - chunkproviderserver_b.managedBlock(completablefuture::isDone); - io.papermc.paper.chunk.system.scheduling.ChunkTaskScheduler.popChunkWait(); // Paper - async chunk debug // Paper - rewrite chunk system -- this.level.timings.syncChunkLoad.stopTiming(); // Paper -+ //this.level.timings.syncChunkLoad.stopTiming(); // Paper // Purpur - } // Paper - ichunkaccess = (ChunkAccess) ((Either) completablefuture.join()).map((ichunkaccess1) -> { - return ichunkaccess1; -@@ -601,17 +601,17 @@ public class ServerChunkCache extends ChunkSource { - - public void save(boolean flush) { - this.runDistanceManagerUpdates(); -- try (co.aikar.timings.Timing timed = level.timings.chunkSaveData.startTiming()) { // Paper - Timings -+ //try (co.aikar.timings.Timing timed = level.timings.chunkSaveData.startTiming()) { // Paper - Timings // Purpur - this.chunkMap.saveAllChunks(flush); -- } // Paper - Timings -+ //} // Paper - Timings // Purpur - } - - // Paper start - duplicate save, but call incremental - public void saveIncrementally() { - this.runDistanceManagerUpdates(); -- try (co.aikar.timings.Timing timed = level.timings.chunkSaveData.startTiming()) { // Paper - Timings -+ //try (co.aikar.timings.Timing timed = level.timings.chunkSaveData.startTiming()) { // Paper - Timings // Purpur - this.chunkMap.saveIncrementally(); -- } // Paper - Timings -+ //} // Paper - Timings // Purpur - } - // Paper end - -@@ -641,22 +641,22 @@ public class ServerChunkCache extends ChunkSource { - @Override - public void tick(BooleanSupplier shouldKeepTicking, boolean tickChunks) { - this.level.getProfiler().push("purge"); -- this.level.timings.doChunkMap.startTiming(); // Spigot -+ //this.level.timings.doChunkMap.startTiming(); // Spigot // Purpur - this.distanceManager.purgeStaleTickets(); - this.runDistanceManagerUpdates(); -- this.level.timings.doChunkMap.stopTiming(); // Spigot -+ //this.level.timings.doChunkMap.stopTiming(); // Spigot // Purpur - this.level.getProfiler().popPush("chunks"); - if (tickChunks) { -- this.level.timings.chunks.startTiming(); // Paper - timings -+ //this.level.timings.chunks.startTiming(); // Paper - timings // Purpur - this.chunkMap.playerChunkManager.tick(); // Paper - this is mostly is to account for view distance changes - this.tickChunks(); -- this.level.timings.chunks.stopTiming(); // Paper - timings -+ //this.level.timings.chunks.stopTiming(); // Paper - timings // Purpur - } - -- this.level.timings.doChunkUnload.startTiming(); // Spigot -+ //this.level.timings.doChunkUnload.startTiming(); // Spigot // Purpur - this.level.getProfiler().popPush("unload"); - this.chunkMap.tick(shouldKeepTicking); -- this.level.timings.doChunkUnload.stopTiming(); // Spigot -+ //this.level.timings.doChunkUnload.stopTiming(); // Spigot // Purpur - this.level.getProfiler().pop(); - this.clearCache(); - } -@@ -711,7 +711,7 @@ public class ServerChunkCache extends ChunkSource { - boolean flag1 = level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) != 0L && worlddata.getGameTime() % level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) == 0L; // CraftBukkit - - gameprofilerfiller.push("naturalSpawnCount"); -- this.level.timings.countNaturalMobs.startTiming(); // Paper - timings -+ //this.level.timings.countNaturalMobs.startTiming(); // Paper - timings // Purpur - int l = this.distanceManager.getNaturalSpawnChunkCount(); - // Paper start - per player mob spawning - NaturalSpawner.SpawnState spawnercreature_d; // moved down -@@ -732,12 +732,12 @@ public class ServerChunkCache extends ChunkSource { - // Pufferfish end - } - // Paper end -- this.level.timings.countNaturalMobs.stopTiming(); // Paper - timings -+ //this.level.timings.countNaturalMobs.stopTiming(); // Paper - timings // Purpur - - //this.lastSpawnState = spawnercreature_d; // Pufferfish - this is managed asynchronously - gameprofilerfiller.popPush("filteringLoadedChunks"); - // Paper - moved down -- this.level.timings.chunkTicks.startTiming(); // Paper -+ //this.level.timings.chunkTicks.startTiming(); // Paper // Purpur - - // Paper - moved down - -@@ -791,17 +791,17 @@ public class ServerChunkCache extends ChunkSource { - } - } - // Paper end - optimise chunk tick iteration -- this.level.timings.chunkTicks.stopTiming(); // Paper -+ //this.level.timings.chunkTicks.stopTiming(); // Paper // Purpur - gameprofilerfiller.popPush("customSpawners"); - if (flag2) { -- try (co.aikar.timings.Timing ignored = this.level.timings.miscMobSpawning.startTiming()) { // Paper - timings -+ //try (co.aikar.timings.Timing ignored = this.level.timings.miscMobSpawning.startTiming()) { // Paper - timings // Purpur - this.level.tickCustomSpawners(this.spawnEnemies, this.spawnFriendlies); -- } // Paper - timings -+ //} // Paper - timings // Purpur - } - gameprofilerfiller.pop(); - // Paper start - use set of chunks requiring updates, rather than iterating every single one loaded - gameprofilerfiller.popPush("broadcast"); -- this.level.timings.broadcastChunkUpdates.startTiming(); // Paper - timing -+ //this.level.timings.broadcastChunkUpdates.startTiming(); // Paper - timing // Purpur - if (!this.chunkMap.needsChangeBroadcasting.isEmpty()) { - ReferenceOpenHashSet copy = this.chunkMap.needsChangeBroadcasting.clone(); - this.chunkMap.needsChangeBroadcasting.clear(); -@@ -813,7 +813,7 @@ public class ServerChunkCache extends ChunkSource { - } - } - } -- this.level.timings.broadcastChunkUpdates.stopTiming(); // Paper - timing -+ //this.level.timings.broadcastChunkUpdates.stopTiming(); // Paper - timing // Purpur - gameprofilerfiller.pop(); - // Paper end - use set of chunks requiring updates, rather than iterating every single one loaded - // Paper start - controlled flush for entity tracker packets -diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index 53198ebfa30273c5ddc1bb4324f5174ff99f688d..deef2fafed137d90cbd14a71d3e7bb1210348af9 100644 ---- a/src/main/java/net/minecraft/server/level/ServerLevel.java -+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java -@@ -666,7 +666,7 @@ public class ServerLevel extends Level implements WorldGenLevel { - this.updateSkyBrightness(); - this.tickTime(); - gameprofilerfiller.popPush("tickPending"); -- timings.scheduledBlocks.startTiming(); // Paper -+ //timings.scheduledBlocks.startTiming(); // Paper // Purpur - if (!this.isDebug()) { - j = this.getGameTime(); - gameprofilerfiller.push("blockTicks"); -@@ -675,20 +675,20 @@ public class ServerLevel extends Level implements WorldGenLevel { - this.fluidTicks.tick(j, 65536, this::tickFluid); - gameprofilerfiller.pop(); - } -- timings.scheduledBlocks.stopTiming(); // Paper -+ //timings.scheduledBlocks.stopTiming(); // Paper // Purpur - - gameprofilerfiller.popPush("raid"); -- this.timings.raids.startTiming(); // Paper - timings -+ //this.timings.raids.startTiming(); // Paper - timings // Purpur - this.raids.tick(); -- this.timings.raids.stopTiming(); // Paper - timings -+ //this.timings.raids.stopTiming(); // Paper - timings // Purpur - gameprofilerfiller.popPush("chunkSource"); -- this.timings.chunkProviderTick.startTiming(); // Paper - timings -+ //this.timings.chunkProviderTick.startTiming(); // Paper - timings // Purpur - this.getChunkSource().tick(shouldKeepTicking, true); -- this.timings.chunkProviderTick.stopTiming(); // Paper - timings -+ //this.timings.chunkProviderTick.stopTiming(); // Paper - timings // Purpur - gameprofilerfiller.popPush("blockEvents"); -- timings.doSounds.startTiming(); // Spigot -+ //timings.doSounds.startTiming(); // Spigot // Purpur - this.runBlockEvents(); -- timings.doSounds.stopTiming(); // Spigot -+ //timings.doSounds.stopTiming(); // Spigot // Purpur - this.handlingTick = false; - gameprofilerfiller.pop(); - boolean flag = true || !this.players.isEmpty() || !this.getForcedChunks().isEmpty(); // CraftBukkit - this prevents entity cleanup, other issues on servers with no players -@@ -699,7 +699,7 @@ public class ServerLevel extends Level implements WorldGenLevel { - - if (flag || this.emptyTime++ < 300) { - gameprofilerfiller.push("entities"); -- timings.tickEntities.startTiming(); // Spigot -+ //timings.tickEntities.startTiming(); // Spigot // Purpur - if (this.dragonFight != null) { - gameprofilerfiller.push("dragonFight"); - this.dragonFight.tick(); -@@ -707,7 +707,7 @@ public class ServerLevel extends Level implements WorldGenLevel { - } - - org.spigotmc.ActivationRange.activateEntities(this); // Spigot -- timings.entityTick.startTiming(); // Spigot -+ //timings.entityTick.startTiming(); // Spigot // Purpur - this.entityTickList.forEach((entity) -> { - entity.activatedPriorityReset = false; // Pufferfish - DAB - if (!entity.isRemoved()) { -@@ -748,8 +748,8 @@ public class ServerLevel extends Level implements WorldGenLevel { - } - } - }); -- timings.entityTick.stopTiming(); // Spigot -- timings.tickEntities.stopTiming(); // Spigot -+ //timings.entityTick.stopTiming(); // Spigot // Purpur -+ //timings.tickEntities.stopTiming(); // Spigot // Purpur - gameprofilerfiller.pop(); - this.tickBlockEntities(); - } -@@ -902,7 +902,7 @@ public class ServerLevel extends Level implements WorldGenLevel { - - // Paper start - optimise random block ticking - gameprofilerfiller.popPush("randomTick"); -- timings.chunkTicksBlocks.startTiming(); // Paper -+ //timings.chunkTicksBlocks.startTiming(); // Paper // Purpur - if (randomTickSpeed > 0) { - LevelChunkSection[] sections = chunk.getSections(); - int minSection = io.papermc.paper.util.WorldUtil.getMinSection(this); -@@ -936,7 +936,7 @@ public class ServerLevel extends Level implements WorldGenLevel { - } - } - // Paper end - optimise random block ticking -- timings.chunkTicksBlocks.stopTiming(); // Paper -+ //timings.chunkTicksBlocks.stopTiming(); // Paper // Purpur - gameprofilerfiller.pop(); - } - -@@ -1211,8 +1211,8 @@ public class ServerLevel extends Level implements WorldGenLevel { - // Spigot end - // Paper start- timings - final boolean isActive = org.spigotmc.ActivationRange.checkIfActive(entity); -- timer = isActive ? entity.getType().tickTimer.startTiming() : entity.getType().inactiveTickTimer.startTiming(); // Paper -- try { -+ //timer = isActive ? entity.getType().tickTimer.startTiming() : entity.getType().inactiveTickTimer.startTiming(); // Paper // Purpur -+ //try { // Purpur - // Paper end - timings - entity.setOldPosAndRot(); - ProfilerFiller gameprofilerfiller = this.getProfiler(); -@@ -1228,7 +1228,7 @@ public class ServerLevel extends Level implements WorldGenLevel { - entity.postTick(); // CraftBukkit - } else { entity.inactiveTick(); } // Paper - EAR 2 - this.getProfiler().pop(); -- } finally { timer.stopTiming(); } // Paper - timings -+ //} finally { timer.stopTiming(); } // Paper - timings // Purpur - Iterator iterator = entity.getPassengers().iterator(); - - while (iterator.hasNext()) { -@@ -1251,8 +1251,8 @@ public class ServerLevel extends Level implements WorldGenLevel { - if (passenger instanceof Player || this.entityTickList.contains(passenger)) { - // Paper - EAR 2 - final boolean isActive = org.spigotmc.ActivationRange.checkIfActive(passenger); -- co.aikar.timings.Timing timer = isActive ? passenger.getType().passengerTickTimer.startTiming() : passenger.getType().passengerInactiveTickTimer.startTiming(); // Paper -- try { -+ //co.aikar.timings.Timing timer = isActive ? passenger.getType().passengerTickTimer.startTiming() : passenger.getType().passengerInactiveTickTimer.startTiming(); // Paper // Purpur -+ //try { // Purpur - // Paper end - passenger.setOldPosAndRot(); - ++passenger.tickCount; -@@ -1282,7 +1282,7 @@ public class ServerLevel extends Level implements WorldGenLevel { - this.tickPassenger(passenger, entity2); - } - -- } finally { timer.stopTiming(); }// Paper - EAR2 timings -+ //} finally { timer.stopTiming(); }// Paper - EAR2 timings // Purpur - } - } else { - passenger.stopRiding(); -@@ -1302,14 +1302,14 @@ public class ServerLevel extends Level implements WorldGenLevel { - org.bukkit.Bukkit.getPluginManager().callEvent(new org.bukkit.event.world.WorldSaveEvent(getWorld())); - } - -- try (co.aikar.timings.Timing ignored = this.timings.worldSave.startTiming()) { -+ //try (co.aikar.timings.Timing ignored = this.timings.worldSave.startTiming()) { // Purpur - if (doFull) { - this.saveLevelData(); - } - -- this.timings.worldSaveChunks.startTiming(); // Paper -+ //this.timings.worldSaveChunks.startTiming(); // Paper // Purpur - if (!this.noSave()) chunkproviderserver.saveIncrementally(); -- this.timings.worldSaveChunks.stopTiming(); // Paper -+ //this.timings.worldSaveChunks.stopTiming(); // Paper // Purpur - - // Copied from save() - // CraftBukkit start - moved from MinecraftServer.saveChunks -@@ -1321,7 +1321,7 @@ public class ServerLevel extends Level implements WorldGenLevel { - this.convertable.saveDataTag(this.server.registryAccess(), this.serverLevelData, this.server.getPlayerList().getSingleplayerData()); - } - // CraftBukkit end -- } -+ //} // Purpur - } - // Paper end - -@@ -1335,7 +1335,7 @@ public class ServerLevel extends Level implements WorldGenLevel { - - if (!savingDisabled) { - org.bukkit.Bukkit.getPluginManager().callEvent(new org.bukkit.event.world.WorldSaveEvent(getWorld())); // CraftBukkit -- try (co.aikar.timings.Timing ignored = timings.worldSave.startTiming()) { // Paper -+ //try (co.aikar.timings.Timing ignored = timings.worldSave.startTiming()) { // Paper // Purpur // Purpur - if (progressListener != null) { - progressListener.progressStartNoAbort(Component.translatable("menu.savingLevel")); - } -@@ -1345,11 +1345,11 @@ public class ServerLevel extends Level implements WorldGenLevel { - progressListener.progressStage(Component.translatable("menu.savingChunks")); - } - -- timings.worldSaveChunks.startTiming(); // Paper -+ //timings.worldSaveChunks.startTiming(); // Paper // Purpur - if (!close) chunkproviderserver.save(flush); // Paper - rewrite chunk system - if (close) chunkproviderserver.close(true); // Paper - rewrite chunk system -- timings.worldSaveChunks.stopTiming(); // Paper -- }// Paper -+ //timings.worldSaveChunks.stopTiming(); // Paper // Purpur -+ //}// Paper // Purpur - // Paper - rewrite chunk system - entity saving moved into ChunkHolder - - } else if (close) { chunkproviderserver.close(false); } // Paper - rewrite chunk system -diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 38995416ecbfb8067069926cc0e9be1734851206..fc5f3f6e8dcddc3dfe5cf66bfaa25eeafc8ecb53 100644 ---- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -2506,7 +2506,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic - } - } - // Paper End -- co.aikar.timings.MinecraftTimings.playerCommandTimer.startTiming(); // Paper -+ //co.aikar.timings.MinecraftTimings.playerCommandTimer.startTiming(); // Paper // Purpur - if ( org.spigotmc.SpigotConfig.logCommands ) // Spigot - this.LOGGER.info(this.player.getScoreboardName() + " issued server command: " + s); - -@@ -2516,7 +2516,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic - this.cserver.getPluginManager().callEvent(event); - - if (event.isCancelled()) { -- co.aikar.timings.MinecraftTimings.playerCommandTimer.stopTiming(); // Paper -+ //co.aikar.timings.MinecraftTimings.playerCommandTimer.stopTiming(); // Paper // Purpur - return; - } - -@@ -2529,7 +2529,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic - java.util.logging.Logger.getLogger(ServerGamePacketListenerImpl.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - return; - } finally { -- co.aikar.timings.MinecraftTimings.playerCommandTimer.stopTiming(); // Paper -+ //co.aikar.timings.MinecraftTimings.playerCommandTimer.stopTiming(); // Paper // Purpur - } - } - // CraftBukkit end -diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index e1a60b9e380448e1594516ec078e89cc7f74db2a..c0278a87a77d14c7598e6d431b63bbd5c7d863af 100644 ---- a/src/main/java/net/minecraft/server/players/PlayerList.java -+++ b/src/main/java/net/minecraft/server/players/PlayerList.java -@@ -1203,7 +1203,7 @@ public abstract class PlayerList { - - public void saveAll(int interval) { - io.papermc.paper.util.MCUtil.ensureMain("Save Players" , () -> { // Paper - Ensure main -- MinecraftTimings.savePlayers.startTiming(); // Paper -+ //MinecraftTimings.savePlayers.startTiming(); // Paper // Purpur - int numSaved = 0; - long now = MinecraftServer.currentTick; - for (int i = 0; i < this.players.size(); ++i) { -@@ -1214,7 +1214,7 @@ public abstract class PlayerList { - } - // Paper end - } -- MinecraftTimings.savePlayers.stopTiming(); // Paper -+ //MinecraftTimings.savePlayers.stopTiming(); // Paper // Purpur - return null; }); // Paper - ensure main - } - -diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/Behavior.java b/src/main/java/net/minecraft/world/entity/ai/behavior/Behavior.java -index 57ef7fbba3028c28231abf7b7ae78aa019323536..651c156dc8a5aad04d461add02e22147af657d07 100644 ---- a/src/main/java/net/minecraft/world/entity/ai/behavior/Behavior.java -+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/Behavior.java -@@ -58,9 +58,9 @@ public abstract class Behavior implements BehaviorContro - this.status = Behavior.Status.RUNNING; - int i = this.minDuration + world.getRandom().nextInt(this.maxDuration + 1 - this.minDuration); - this.endTimestamp = time + (long)i; -- this.timing.startTiming(); // Paper - behavior timings -+ //this.timing.startTiming(); // Paper - behavior timings // Purpur - this.start(world, entity, time); -- this.timing.stopTiming(); // Paper - behavior timings -+ //this.timing.stopTiming(); // Paper - behavior timings // Purpur - return true; - } else { - return false; -@@ -72,13 +72,13 @@ public abstract class Behavior implements BehaviorContro - - @Override - public final void tickOrStop(ServerLevel world, E entity, long time) { -- this.timing.startTiming(); // Paper - behavior timings -+ //this.timing.startTiming(); // Paper - behavior timings // Purpur - if (!this.timedOut(time) && this.canStillUse(world, entity, time)) { - this.tick(world, entity, time); - } else { - this.doStop(world, entity, time); - } -- this.timing.stopTiming(); // Paper - behavior timings -+ //this.timing.stopTiming(); // Paper - behavior timings // Purpur - - } - -diff --git a/src/main/java/net/minecraft/world/entity/ai/sensing/Sensor.java b/src/main/java/net/minecraft/world/entity/ai/sensing/Sensor.java -index fcdb9bde8e1605e30dde3e580491522d4b62cdc0..7094701d213c73ba47ace806962244c10fdf4dda 100644 ---- a/src/main/java/net/minecraft/world/entity/ai/sensing/Sensor.java -+++ b/src/main/java/net/minecraft/world/entity/ai/sensing/Sensor.java -@@ -46,10 +46,10 @@ public abstract class Sensor { - if (--this.timeToTick <= 0L) { - // Paper start - configurable sensor tick rate and timings - this.timeToTick = java.util.Objects.requireNonNullElse(world.paperConfig().tickRates.sensor.get(entity.getType(), this.configKey), this.scanRate); -- this.timing.startTiming(); -+ //this.timing.startTiming(); // Purpur - // Paper end - this.doTick(world, entity); -- this.timing.stopTiming(); // Paper - sensor timings -+ //this.timing.stopTiming(); // Paper - sensor timings // Purpur - } - - } -diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index 62aff29485f124880739e7d2b5fb0d8a9d957741..e61e52a34bb237bf7b1e28ba8087d1b2cd5f2f89 100644 ---- a/src/main/java/net/minecraft/world/level/Level.java -+++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -968,15 +968,15 @@ public abstract class Level implements LevelAccessor, AutoCloseable { - ProfilerFiller gameprofilerfiller = this.getProfiler(); - - gameprofilerfiller.push("blockEntities"); -- timings.tileEntityPending.startTiming(); // Spigot -+ //timings.tileEntityPending.startTiming(); // Spigot // Purpur - this.tickingBlockEntities = true; - if (!this.pendingBlockEntityTickers.isEmpty()) { - this.blockEntityTickers.addAll(this.pendingBlockEntityTickers); - this.pendingBlockEntityTickers.clear(); - } -- timings.tileEntityPending.stopTiming(); // Spigot -+ //timings.tileEntityPending.stopTiming(); // Spigot // Purpur - -- timings.tileEntityTick.startTiming(); // Spigot -+ //timings.tileEntityTick.startTiming(); // Spigot // Purpur - // Spigot start - // Iterator iterator = this.blockEntityTickers.iterator(); - int tilesThisCycle = 0; -@@ -1009,7 +1009,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { - } - this.blockEntityTickers.removeAll(toRemove); - -- timings.tileEntityTick.stopTiming(); // Spigot -+ //timings.tileEntityTick.stopTiming(); // Spigot // Purpur - this.tickingBlockEntities = false; - co.aikar.timings.TimingHistory.tileEntityTicks += this.blockEntityTickers.size(); // Paper - gameprofilerfiller.pop(); -diff --git a/src/main/java/net/minecraft/world/level/NaturalSpawner.java b/src/main/java/net/minecraft/world/level/NaturalSpawner.java -index 5521418fa307b3eeb4f02a10c39f05b360d1d06e..31cab107a606409af5c1fe56cd0956d707637cc0 100644 ---- a/src/main/java/net/minecraft/world/level/NaturalSpawner.java -+++ b/src/main/java/net/minecraft/world/level/NaturalSpawner.java -@@ -133,7 +133,7 @@ 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 -+ //world.timings.mobSpawn.startTiming(); // Spigot // Purpur - MobCategory[] aenumcreaturetype = NaturalSpawner.SPAWNING_CATEGORIES; - int i = aenumcreaturetype.length; - -@@ -188,7 +188,7 @@ public final class NaturalSpawner { - } - } - -- world.timings.mobSpawn.stopTiming(); // Spigot -+ //world.timings.mobSpawn.stopTiming(); // Spigot // Purpur - world.getProfiler().pop(); - } - -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 de7a5f3812a017131fd1b32fbeff10e325b1cd2e..f64225897d659127dd87293b26b58653cefda0c3 100644 ---- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java -+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java -@@ -930,7 +930,7 @@ public class LevelChunk extends ChunkAccess { - this.chunkHolder.getEntityChunk().callEntitiesLoadEvent(); // Paper - rewrite chunk system - - if (this.needsDecoration) { -- try (co.aikar.timings.Timing ignored = this.level.timings.chunkLoadPopulate.startTiming()) { // Paper -+ //try (co.aikar.timings.Timing ignored = this.level.timings.chunkLoadPopulate.startTiming()) { // Paper // Purpur - this.needsDecoration = false; - java.util.Random random = new java.util.Random(); - random.setSeed(this.level.getSeed()); -@@ -950,7 +950,7 @@ public class LevelChunk extends ChunkAccess { - } - } - server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkPopulateEvent(this.bukkitChunk)); -- } // Paper -+ //} // Paper // Purpur - } - } - } -@@ -1310,7 +1310,7 @@ public class LevelChunk extends ChunkAccess { - ProfilerFiller gameprofilerfiller = LevelChunk.this.level.getProfiler(); - - gameprofilerfiller.push(this::getType); -- this.blockEntity.tickTimer.startTiming(); // Spigot -+ //this.blockEntity.tickTimer.startTiming(); // Spigot // Purpur - BlockState iblockdata = LevelChunk.this.getBlockState(blockposition); - - if (this.blockEntity.getType().isValid(iblockdata)) { -@@ -1332,7 +1332,7 @@ public class LevelChunk extends ChunkAccess { - // Paper end - // Spigot start - } finally { -- this.blockEntity.tickTimer.stopTiming(); -+ //this.blockEntity.tickTimer.stopTiming(); // Purpur - // Spigot end - } - } -diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java -index 38920d680d9b0d81013dcf16ce3dd7271eeafe4c..4f01386675b4faf94589b4ae5f65a93737ab3240 100644 ---- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java -+++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java -@@ -516,10 +516,10 @@ public class CraftScheduler implements BukkitScheduler { - this.runners.remove(task.getTaskId()); - } - } -- MinecraftTimings.bukkitSchedulerFinishTimer.startTiming(); // Paper -+ //MinecraftTimings.bukkitSchedulerFinishTimer.startTiming(); // Paper // Purpur - this.pending.addAll(temp); - temp.clear(); -- MinecraftTimings.bukkitSchedulerFinishTimer.stopTiming(); // Paper -+ //MinecraftTimings.bukkitSchedulerFinishTimer.stopTiming(); // Paper // Purpur - //this.debugHead = this.debugHead.getNextHead(currentTick); // Paper - } - -@@ -563,7 +563,7 @@ public class CraftScheduler implements BukkitScheduler { - } - - void parsePending() { // Paper -- if (!this.isAsyncScheduler) MinecraftTimings.bukkitSchedulerPendingTimer.startTiming(); // Paper -+ //if (!this.isAsyncScheduler) MinecraftTimings.bukkitSchedulerPendingTimer.startTiming(); // Paper // Purpur - CraftTask head = this.head; - CraftTask task = head.getNext(); - CraftTask lastTask = head; -@@ -582,7 +582,7 @@ public class CraftScheduler implements BukkitScheduler { - task.setNext(null); - } - this.head = lastTask; -- if (!this.isAsyncScheduler) MinecraftTimings.bukkitSchedulerPendingTimer.stopTiming(); // Paper -+ //if (!this.isAsyncScheduler) MinecraftTimings.bukkitSchedulerPendingTimer.stopTiming(); // Paper // Purpur - } - - private boolean isReady(final int currentTick) { -diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java -index 3f45bab0e9f7b3697e6d9d1092a1e6e579f7066f..4f1cf281c4bf68c37982d390da8779dea78dab18 100644 ---- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java -+++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftTask.java -@@ -96,13 +96,13 @@ public class CraftTask implements BukkitTask, Runnable { // Spigot - - @Override - public void run() { -- try (Timing ignored = timings.startTiming()) { // Paper -+ //try (Timing ignored = timings.startTiming()) { // Paper // Purpur - if (this.rTask != null) { - this.rTask.run(); - } else { - this.cTask.accept(this); - } -- } // Paper -+ //} // Paper // Purpur - } - - long getCreatedAt() { -diff --git a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardManager.java b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardManager.java -index 138407c2d4b0bc55ddb9aac5d2aa3edadda090fb..a6e9e503a496c18e2501b03ec84f4600c134a50c 100644 ---- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardManager.java -+++ b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardManager.java -@@ -115,7 +115,7 @@ public final class CraftScoreboardManager implements ScoreboardManager { - public void getScoreboardScores(ObjectiveCriteria criteria, String name, Consumer consumer) { - // Paper start - add timings for scoreboard search - // plugins leaking scoreboards will make this very expensive, let server owners debug it easily -- co.aikar.timings.MinecraftTimings.scoreboardScoreSearch.startTimingIfSync(); -+ //co.aikar.timings.MinecraftTimings.scoreboardScoreSearch.startTimingIfSync(); // Purpur - try { - // Paper end - add timings for scoreboard search - for (CraftScoreboard scoreboard : this.scoreboards) { -@@ -123,7 +123,7 @@ public final class CraftScoreboardManager implements ScoreboardManager { - board.forAllObjectives(criteria, name, (score) -> consumer.accept(score)); - } - } finally { // Paper start - add timings for scoreboard search -- co.aikar.timings.MinecraftTimings.scoreboardScoreSearch.stopTimingIfSync(); -+ //co.aikar.timings.MinecraftTimings.scoreboardScoreSearch.stopTimingIfSync(); // Purpur - } - // Paper end - add timings for scoreboard search - } -diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java -index 63d3fcc45be732a4cd2dc8b5347d860fd6577bdd..57a27fb05235db8c056492885055fdbe36bee7d1 100644 ---- a/src/main/java/org/spigotmc/ActivationRange.java -+++ b/src/main/java/org/spigotmc/ActivationRange.java -@@ -169,7 +169,7 @@ public class ActivationRange - */ - public static void activateEntities(Level world) - { -- MinecraftTimings.entityActivationCheckTimer.startTiming(); -+ //MinecraftTimings.entityActivationCheckTimer.startTiming(); // Purpur - final int miscActivationRange = world.spigotConfig.miscActivationRange; - final int raiderActivationRange = world.spigotConfig.raiderActivationRange; - final int animalActivationRange = world.spigotConfig.animalActivationRange; -@@ -242,7 +242,7 @@ public class ActivationRange - } - // Paper end - } -- MinecraftTimings.entityActivationCheckTimer.stopTiming(); -+ //MinecraftTimings.entityActivationCheckTimer.stopTiming(); // Purpur - } - - /** diff --git a/patches/server/0038-Petal-Reduce-sensor-work.patch b/patches/server/0028-Petal-Reduce-sensor-work.patch similarity index 74% rename from patches/server/0038-Petal-Reduce-sensor-work.patch rename to patches/server/0028-Petal-Reduce-sensor-work.patch index 86416131..c2c5bf25 100644 --- a/patches/server/0038-Petal-Reduce-sensor-work.patch +++ b/patches/server/0028-Petal-Reduce-sensor-work.patch @@ -10,19 +10,17 @@ this patch is focused around the sensors used for ai delete the line of sight cache less often and use a faster nearby comparison diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java -index 2db9ce11dc52b8fb737e3344265e2a40d07ffc26..29fa9ad2223de668c15a5e5b433704b2c4765610 100644 +index 27fc50571305132c86497fcb1d5b1bb514610a4e..f1a33fd186fa9c10ac99b7b0e6379902a10dfb14 100644 --- a/src/main/java/net/minecraft/world/entity/Mob.java +++ b/src/main/java/net/minecraft/world/entity/Mob.java -@@ -873,10 +873,10 @@ public abstract class Mob extends LivingEntity { +@@ -867,8 +867,8 @@ public abstract class Mob extends LivingEntity { return; } // Paper end -+ int i = this.level.getServer().getTickCount() + this.getId(); // petal - move up - //this.level.getProfiler().push("sensing"); // Purpur - this.sensing.tick(); -+ if (i % 10 == 0) this.sensing.tick(); // petal - only refresh line of sight cache every half second - //this.level.getProfiler().pop(); // Purpur - int i = this.level.getServer().getTickCount() + this.getId(); ++ int i = this.level.getServer().getTickCount() + this.getId(); // petal - move up ++ if (i % 10 == 0) this.sensing.tick(); // petal - only refresh line of sight cache every half second if (i % 2 != 0 && this.tickCount > 1) { - //this.level.getProfiler().push("targetSelector"); // Purpur + this.targetSelector.tickRunningGoals(false); diff --git a/patches/server/0028-Purpur-Remove-Mojang-Profiler.patch b/patches/server/0028-Purpur-Remove-Mojang-Profiler.patch deleted file mode 100644 index 9643965b..00000000 --- a/patches/server/0028-Purpur-Remove-Mojang-Profiler.patch +++ /dev/null @@ -1,1859 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: BillyGalbreath -Date: Sat, 16 Jul 2022 21:37:10 -0500 -Subject: [PATCH] Purpur: Remove Mojang Profiler - -Original license: MIT -Original project: https://github.com/PurpurMC/Purpur - -diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java -index 31e44f59bd34ae79dd1147263e446e6d6e9f8c66..b516177c3a10abd30d099823717339456ad517fc 100644 ---- a/src/main/java/net/minecraft/commands/Commands.java -+++ b/src/main/java/net/minecraft/commands/Commands.java -@@ -144,7 +144,7 @@ public class Commands { - CloneCommands.register(this.dispatcher, commandRegistryAccess); - DataCommands.register(this.dispatcher); - DataPackCommand.register(this.dispatcher); -- DebugCommand.register(this.dispatcher); -+ //DebugCommand.register(this.dispatcher); // Purpur - DefaultGameModeCommands.register(this.dispatcher); - DifficultyCommand.register(this.dispatcher); - EffectCommands.register(this.dispatcher, commandRegistryAccess); -@@ -304,9 +304,9 @@ public class Commands { - public int performCommand(ParseResults parseresults, String s, String label) { // CraftBukkit - CommandSourceStack commandlistenerwrapper = (CommandSourceStack) parseresults.getContext().getSource(); - -- commandlistenerwrapper.getServer().getProfiler().push(() -> { -+ /*commandlistenerwrapper.getServer().getProfiler().push(() -> { // Purpur - return "/" + s; -- }); -+ });*/ // Purpur - - byte b0; - -@@ -369,7 +369,7 @@ public class Commands { - b0 = 0; - } - } finally { -- commandlistenerwrapper.getServer().getProfiler().pop(); -+ //commandlistenerwrapper.getServer().getProfiler().pop(); // Purpur - } - - return b0; -diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index a0e94d7a3ae1b6d28811324d24dff7ac5c6d4c16..3b7e4b724e86518ea57f5ed5ef0b8b3741d10f6f 100644 ---- a/src/main/java/net/minecraft/server/MinecraftServer.java -+++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -337,13 +337,13 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { -+ //this.metricsRecorder = InactiveMetricsRecorder.INSTANCE; // Purpur -+ //this.profiler = this.metricsRecorder.getProfiler(); // Purpur -+ /*this.onMetricsRecordingStopped = (methodprofilerresults) -> { // Purpur - this.stopRecordingMetrics(); -- }; -- this.onMetricsRecordingFinished = (path) -> { -- }; -+ };*/ // Purpur -+ //this.onMetricsRecordingFinished = (path) -> { // Purpur -+ //}; // Purpur - this.status = new ServerStatus(); - this.random = RandomSource.create(); - this.port = -1; -@@ -935,9 +935,9 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 0 && this.tickCount % autosavePeriod == 0; - try { - this.isSaving = true; -@@ -1449,7 +1449,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 0; // Paper - net.minecraft.world.level.block.entity.HopperBlockEntity.skipHopperEvents = worldserver.paperConfig().hopper.disableMoveEvent || org.bukkit.event.inventory.InventoryMoveItemEvent.getHandlerList().getRegisteredListeners().length == 0; // Paper - -- this.profiler.push(() -> { -+ /*this.profiler.push(() -> { // Purpur - return worldserver + " " + worldserver.dimension().location(); -- }); -+ });*/ // Purpur - /* Drop global time updates - if (this.tickCount % 20 == 0) { -- this.profiler.push("timeSync"); -+ //this.profiler.push("timeSync"); // Purpur - this.playerList.broadcastAll(new PacketPlayOutUpdateTime(worldserver.getGameTime(), worldserver.getDayTime(), worldserver.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)), worldserver.dimension()); -- this.profiler.pop(); -+ //this.profiler.pop(); // Purpur - } - // CraftBukkit end */ - -- this.profiler.push("tick"); -+ //this.profiler.push("tick"); // Purpur - - try { - //worldserver.timings.doTick.startTiming(); // Spigot // Purpur -@@ -1566,17 +1566,17 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { - this.executeBlocking(() -> { - this.saveDebugReport(path.resolve("server")); -@@ -2501,40 +2501,40 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop resultConsumer, Consumer dumpConsumer) { -- this.onMetricsRecordingStopped = (methodprofilerresults) -> { -+ /*this.onMetricsRecordingStopped = (methodprofilerresults) -> { // Purpur - this.stopRecordingMetrics(); - resultConsumer.accept(methodprofilerresults); - }; - this.onMetricsRecordingFinished = dumpConsumer; -- this.willStartRecordingMetrics = true; -+ this.willStartRecordingMetrics = true;*/ // Purpur - } - - public void stopRecordingMetrics() { -- this.metricsRecorder = InactiveMetricsRecorder.INSTANCE; -+ //this.metricsRecorder = InactiveMetricsRecorder.INSTANCE; // Purpur - } - - public void finishRecordingMetrics() { -- this.metricsRecorder.end(); -+ //this.metricsRecorder.end(); // Purpur - } - - public void cancelRecordingMetrics() { -- this.metricsRecorder.cancel(); -- this.profiler = this.metricsRecorder.getProfiler(); -+ //this.metricsRecorder.cancel(); // Purpur -+ //this.profiler = this.metricsRecorder.getProfiler(); // Purpur - } - - public Path getWorldPath(LevelResource worldSavePath) { -@@ -2583,15 +2583,15 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop functions, ResourceLocation label) { -- ProfilerFiller gameprofilerfiller = this.server.getProfiler(); -+ //ProfilerFiller gameprofilerfiller = this.server.getProfiler(); // Purpur - - Objects.requireNonNull(label); -- gameprofilerfiller.push(label::toString); -+ //gameprofilerfiller.push(label::toString); // Purpur - Iterator iterator = functions.iterator(); - - while (iterator.hasNext()) { -@@ -69,7 +69,7 @@ public class ServerFunctionManager { - this.execute(customfunction, this.getGameLoopSender()); - } - -- this.server.getProfiler().pop(); -+ //this.server.getProfiler().pop(); // Purpur - } - - public int execute(CommandFunction function, CommandSourceStack source) { -@@ -177,10 +177,10 @@ public class ServerFunctionManager { - - try { - ServerFunctionManager.QueuedCommand customfunctiondata_b = (ServerFunctionManager.QueuedCommand) this.commandQueue.removeFirst(); -- ProfilerFiller gameprofilerfiller = ServerFunctionManager.this.server.getProfiler(); -+ //ProfilerFiller gameprofilerfiller = ServerFunctionManager.this.server.getProfiler(); // Purpur - - Objects.requireNonNull(customfunctiondata_b); -- gameprofilerfiller.push(customfunctiondata_b::toString); -+ //gameprofilerfiller.push(customfunctiondata_b::toString); // Purpur - this.depth = customfunctiondata_b.depth; - customfunctiondata_b.execute(ServerFunctionManager.this, this.commandQueue, i, this.tracer); - if (!this.nestedCalls.isEmpty()) { -@@ -192,7 +192,7 @@ public class ServerFunctionManager { - this.nestedCalls.clear(); - } - } finally { -- ServerFunctionManager.this.server.getProfiler().pop(); -+ //ServerFunctionManager.this.server.getProfiler().pop(); // Purpur - } - - ++j; -diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java -index eb4f2c5c9453f59abbc7c9b9629ab0d43a4c5da6..beb7c22cb63021f26c06f91050361e1b25fcc72d 100644 ---- a/src/main/java/net/minecraft/server/level/ChunkMap.java -+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java -@@ -618,20 +618,20 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider - } - - protected void tick(BooleanSupplier shouldKeepTicking) { -- ProfilerFiller gameprofilerfiller = this.level.getProfiler(); -+ //ProfilerFiller gameprofilerfiller = this.level.getProfiler(); // Purpur - - //try (Timing ignored = this.level.timings.poiUnload.startTiming()) { // Paper // Purpur -- gameprofilerfiller.push("poi"); -+ //gameprofilerfiller.push("poi"); // Purpur - this.poiManager.tick(shouldKeepTicking); - //} // Paper // Purpur -- gameprofilerfiller.popPush("chunk_unload"); -+ //gameprofilerfiller.popPush("chunk_unload"); // Purpur - if (!this.level.noSave()) { - //try (Timing ignored = this.level.timings.chunkUnload.startTiming()) { // Paper // Purpur - this.processUnloads(shouldKeepTicking); - //} // Paper // Purpur - } - -- gameprofilerfiller.pop(); -+ //gameprofilerfiller.pop(); // Purpur - } - - 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 2c23321c826d929981df51f2cc60cdcdb649a43f..0ae45cf5a084fd412305e8b2f5dabe608b4eb1c1 100644 ---- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java -+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -@@ -431,16 +431,16 @@ public class ServerChunkCache extends ChunkSource { - return ifLoaded; - } - // Paper end -- ProfilerFiller gameprofilerfiller = this.level.getProfiler(); -+ //ProfilerFiller gameprofilerfiller = this.level.getProfiler(); // Purpur - -- gameprofilerfiller.incrementCounter("getChunk"); -+ //gameprofilerfiller.incrementCounter("getChunk"); // Purpur - long k = ChunkPos.asLong(x, z); - - ChunkAccess ichunkaccess; - - // Paper - rewrite chunk system - there are no correct callbacks to remove items from cache in the new chunk system - -- gameprofilerfiller.incrementCounter("getChunkCacheMiss"); -+ //gameprofilerfiller.incrementCounter("getChunkCacheMiss"); // Purpur - CompletableFuture> completablefuture = this.getChunkFutureMainThread(x, z, leastStatus, create, true); // Paper - ServerChunkCache.MainThreadExecutor chunkproviderserver_b = this.mainThreadProcessor; - -@@ -628,24 +628,24 @@ public class ServerChunkCache extends ChunkSource { - // CraftBukkit start - modelled on below - public void purgeUnload() { - if (true) return; // Paper - tickets will be removed later, this behavior isn't really well accounted for by the chunk system -- this.level.getProfiler().push("purge"); -+ //this.level.getProfiler().push("purge"); // Purpur - this.distanceManager.purgeStaleTickets(); - this.runDistanceManagerUpdates(); -- this.level.getProfiler().popPush("unload"); -+ //this.level.getProfiler().popPush("unload"); // Purpur - this.chunkMap.tick(() -> true); -- this.level.getProfiler().pop(); -+ //this.level.getProfiler().pop(); // Purpur - this.clearCache(); - } - // CraftBukkit end - - @Override - public void tick(BooleanSupplier shouldKeepTicking, boolean tickChunks) { -- this.level.getProfiler().push("purge"); -+ //this.level.getProfiler().push("purge"); // Purpur - //this.level.timings.doChunkMap.startTiming(); // Spigot // Purpur - this.distanceManager.purgeStaleTickets(); - this.runDistanceManagerUpdates(); - //this.level.timings.doChunkMap.stopTiming(); // Spigot // Purpur -- this.level.getProfiler().popPush("chunks"); -+ //this.level.getProfiler().popPush("chunks"); // Purpur - if (tickChunks) { - //this.level.timings.chunks.startTiming(); // Paper - timings // Purpur - this.chunkMap.playerChunkManager.tick(); // Paper - this is mostly is to account for view distance changes -@@ -654,10 +654,10 @@ public class ServerChunkCache extends ChunkSource { - } - - //this.level.timings.doChunkUnload.startTiming(); // Spigot // Purpur -- this.level.getProfiler().popPush("unload"); -+ //this.level.getProfiler().popPush("unload"); // Purpur - this.chunkMap.tick(shouldKeepTicking); - //this.level.timings.doChunkUnload.stopTiming(); // Spigot // Purpur -- this.level.getProfiler().pop(); -+ //this.level.getProfiler().pop(); // Purpur - this.clearCache(); - } - -@@ -703,14 +703,14 @@ public class ServerChunkCache extends ChunkSource { - } - // Paper end - optimize isOutisdeRange - LevelData worlddata = this.level.getLevelData(); -- ProfilerFiller gameprofilerfiller = this.level.getProfiler(); -+ //ProfilerFiller gameprofilerfiller = this.level.getProfiler(); // Purpur - -- gameprofilerfiller.push("pollingChunks"); -+ //gameprofilerfiller.push("pollingChunks"); // Purpur - this.level.resetIceAndSnowTick(); // Pufferfish - reset ice & snow tick random - int k = this.level.getGameRules().getInt(GameRules.RULE_RANDOMTICKING); - boolean flag1 = level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) != 0L && worlddata.getGameTime() % level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) == 0L; // CraftBukkit - -- gameprofilerfiller.push("naturalSpawnCount"); -+ //gameprofilerfiller.push("naturalSpawnCount"); // Purpur - //this.level.timings.countNaturalMobs.startTiming(); // Paper - timings // Purpur - int l = this.distanceManager.getNaturalSpawnChunkCount(); - // Paper start - per player mob spawning -@@ -735,13 +735,13 @@ public class ServerChunkCache extends ChunkSource { - //this.level.timings.countNaturalMobs.stopTiming(); // Paper - timings // Purpur - - //this.lastSpawnState = spawnercreature_d; // Pufferfish - this is managed asynchronously -- gameprofilerfiller.popPush("filteringLoadedChunks"); -+ //gameprofilerfiller.popPush("filteringLoadedChunks"); // Purpur - // Paper - moved down - //this.level.timings.chunkTicks.startTiming(); // Paper // Purpur - - // Paper - moved down - -- gameprofilerfiller.popPush("spawnAndTick"); -+ //gameprofilerfiller.popPush("spawnAndTick"); // Purpur - boolean flag2 = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && !this.level.players().isEmpty(); // CraftBukkit - - // Paper - only shuffle if per-player mob spawning is disabled -@@ -792,15 +792,15 @@ public class ServerChunkCache extends ChunkSource { - } - // Paper end - optimise chunk tick iteration - //this.level.timings.chunkTicks.stopTiming(); // Paper // Purpur -- gameprofilerfiller.popPush("customSpawners"); -+ //gameprofilerfiller.popPush("customSpawners"); // Purpur - if (flag2) { - //try (co.aikar.timings.Timing ignored = this.level.timings.miscMobSpawning.startTiming()) { // Paper - timings // Purpur - this.level.tickCustomSpawners(this.spawnEnemies, this.spawnFriendlies); - //} // Paper - timings // Purpur - } -- gameprofilerfiller.pop(); -+ //gameprofilerfiller.pop(); // Purpur - // Paper start - use set of chunks requiring updates, rather than iterating every single one loaded -- gameprofilerfiller.popPush("broadcast"); -+ //gameprofilerfiller.popPush("broadcast"); // Purpur - //this.level.timings.broadcastChunkUpdates.startTiming(); // Paper - timing // Purpur - if (!this.chunkMap.needsChangeBroadcasting.isEmpty()) { - ReferenceOpenHashSet copy = this.chunkMap.needsChangeBroadcasting.clone(); -@@ -814,7 +814,7 @@ public class ServerChunkCache extends ChunkSource { - } - } - //this.level.timings.broadcastChunkUpdates.stopTiming(); // Paper - timing // Purpur -- gameprofilerfiller.pop(); -+ //gameprofilerfiller.pop(); // Purpur - // Paper end - use set of chunks requiring updates, rather than iterating every single one loaded - // Paper start - controlled flush for entity tracker packets - List disabledFlushes = new java.util.ArrayList<>(this.level.players.size()); -@@ -1029,7 +1029,7 @@ public class ServerChunkCache extends ChunkSource { - - @Override - protected void doRunTask(Runnable task) { -- ServerChunkCache.this.level.getProfiler().incrementCounter("runTask"); -+ //ServerChunkCache.this.level.getProfiler().incrementCounter("runTask"); // Purpur - 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 deef2fafed137d90cbd14a71d3e7bb1210348af9..03b8ef3409fd5f7a4d4b06e13cf8eb22b3bbf8a1 100644 ---- a/src/main/java/net/minecraft/server/level/ServerLevel.java -+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java -@@ -633,12 +633,12 @@ public class ServerLevel extends Level implements WorldGenLevel { - } - } - // Paper end - optimise checkDespawn -- ProfilerFiller gameprofilerfiller = this.getProfiler(); -+ //ProfilerFiller gameprofilerfiller = this.getProfiler(); // Purpur - - this.handlingTick = true; -- gameprofilerfiller.push("world border"); -+ //gameprofilerfiller.push("world border"); // Purpur - this.getWorldBorder().tick(); -- gameprofilerfiller.popPush("weather"); -+ //gameprofilerfiller.popPush("weather"); // Purpur - this.advanceWeatherCycle(); - int i = this.getGameRules().getInt(GameRules.RULE_PLAYERS_SLEEPING_PERCENTAGE); - long j; -@@ -665,32 +665,32 @@ public class ServerLevel extends Level implements WorldGenLevel { - - this.updateSkyBrightness(); - this.tickTime(); -- gameprofilerfiller.popPush("tickPending"); -+ //gameprofilerfiller.popPush("tickPending"); // Purpur - //timings.scheduledBlocks.startTiming(); // Paper // Purpur - if (!this.isDebug()) { - j = this.getGameTime(); -- gameprofilerfiller.push("blockTicks"); -+ //gameprofilerfiller.push("blockTicks"); // Purpur - this.blockTicks.tick(j, 65536, this::tickBlock); -- gameprofilerfiller.popPush("fluidTicks"); -+ //gameprofilerfiller.popPush("fluidTicks"); // Purpur - this.fluidTicks.tick(j, 65536, this::tickFluid); -- gameprofilerfiller.pop(); -+ //gameprofilerfiller.pop(); // Purpur - } - //timings.scheduledBlocks.stopTiming(); // Paper // Purpur - -- gameprofilerfiller.popPush("raid"); -+ //gameprofilerfiller.popPush("raid"); // Purpur - //this.timings.raids.startTiming(); // Paper - timings // Purpur - this.raids.tick(); - //this.timings.raids.stopTiming(); // Paper - timings // Purpur -- gameprofilerfiller.popPush("chunkSource"); -+ //gameprofilerfiller.popPush("chunkSource"); // Purpur - //this.timings.chunkProviderTick.startTiming(); // Paper - timings // Purpur - this.getChunkSource().tick(shouldKeepTicking, true); - //this.timings.chunkProviderTick.stopTiming(); // Paper - timings // Purpur -- gameprofilerfiller.popPush("blockEvents"); -+ //gameprofilerfiller.popPush("blockEvents"); // Purpur - //timings.doSounds.startTiming(); // Spigot // Purpur - this.runBlockEvents(); - //timings.doSounds.stopTiming(); // Spigot // Purpur - this.handlingTick = false; -- gameprofilerfiller.pop(); -+ //gameprofilerfiller.pop(); // Purpur - boolean flag = true || !this.players.isEmpty() || !this.getForcedChunks().isEmpty(); // CraftBukkit - this prevents entity cleanup, other issues on servers with no players - - if (flag) { -@@ -698,12 +698,12 @@ public class ServerLevel extends Level implements WorldGenLevel { - } - - if (flag || this.emptyTime++ < 300) { -- gameprofilerfiller.push("entities"); -+ //gameprofilerfiller.push("entities"); // Purpur - //timings.tickEntities.startTiming(); // Spigot // Purpur - if (this.dragonFight != null) { -- gameprofilerfiller.push("dragonFight"); -+ //gameprofilerfiller.push("dragonFight"); // Purpur - this.dragonFight.tick(); -- gameprofilerfiller.pop(); -+ //gameprofilerfiller.pop(); // Purpur - } - - org.spigotmc.ActivationRange.activateEntities(this); // Spigot -@@ -714,9 +714,9 @@ public class ServerLevel extends Level implements WorldGenLevel { - if (false && this.shouldDiscardEntity(entity)) { // CraftBukkit - We prevent spawning in general, so this butchering is not needed - entity.discard(); - } else { -- gameprofilerfiller.push("checkDespawn"); -+ //gameprofilerfiller.push("checkDespawn"); // Purpur - entity.checkDespawn(); -- gameprofilerfiller.pop(); -+ //gameprofilerfiller.pop(); // Purpur - if (true || this.chunkSource.chunkMap.getDistanceManager().inEntityTickingRange(entity.chunkPosition().toLong())) { // Paper - now always true if in the ticking list - Entity entity1 = entity.getVehicle(); - -@@ -728,7 +728,7 @@ public class ServerLevel extends Level implements WorldGenLevel { - entity.stopRiding(); - } - -- gameprofilerfiller.push("tick"); -+ //gameprofilerfiller.push("tick"); // Purpur - // Pufferfish start - copied from this.guardEntityTick - try { - this.tickNonPassenger(entity); // Pufferfish - changed -@@ -743,20 +743,19 @@ public class ServerLevel extends Level implements WorldGenLevel { - // Paper end - } - // Pufferfish end -- gameprofilerfiller.pop(); -+ //gameprofilerfiller.pop(); // Purpur - } - } - } - }); - //timings.entityTick.stopTiming(); // Spigot // Purpur - //timings.tickEntities.stopTiming(); // Spigot // Purpur -- gameprofilerfiller.pop(); -+ //gameprofilerfiller.pop(); // Purpur - this.tickBlockEntities(); - } - -- gameprofilerfiller.push("entityManagement"); -+ //gameprofilerfiller.push("entityManagement"); // Purpur - //this.entityManager.tick(); // Paper - rewrite chunk system -- gameprofilerfiller.pop(); - } - - @Override -@@ -817,9 +816,9 @@ public class ServerLevel extends Level implements WorldGenLevel { - boolean flag = this.isRaining(); - int j = chunkcoordintpair.getMinBlockX(); - int k = chunkcoordintpair.getMinBlockZ(); -- ProfilerFiller gameprofilerfiller = this.getProfiler(); -+ //ProfilerFiller gameprofilerfiller = this.getProfiler(); // Purpur - -- gameprofilerfiller.push("thunder"); -+ //gameprofilerfiller.push("thunder"); // Purpur - final BlockPos.MutableBlockPos blockposition = this.chunkTickMutablePosition; // Paper - use mutable to reduce allocation rate, final to force compile fail on change - - if (!this.paperConfig().environment.disableThunder && flag && this.isThundering() && this.spigotConfig.thunderChance > 0 && /*this.random.nextInt(this.spigotConfig.thunderChance) == 0 &&*/ chunk.shouldDoLightning(this.random)) { // Spigot // Paper - disable thunder // Pufferfish - replace random with shouldDoLightning -@@ -849,7 +848,7 @@ public class ServerLevel extends Level implements WorldGenLevel { - } - } - -- gameprofilerfiller.popPush("iceandsnow"); -+ //gameprofilerfiller.popPush("iceandsnow"); // Purpur - int l; - - if (!this.paperConfig().environment.disableIceAndSnow && (this.currentIceAndSnowTick++ & 15) == 0) { // Paper - Disable ice and snow // Paper - optimise random ticking // Pufferfish - optimize further random ticking -@@ -901,7 +900,7 @@ public class ServerLevel extends Level implements WorldGenLevel { - } - - // Paper start - optimise random block ticking -- gameprofilerfiller.popPush("randomTick"); -+ //gameprofilerfiller.popPush("randomTick"); // Purpur - //timings.chunkTicksBlocks.startTiming(); // Paper // Purpur - if (randomTickSpeed > 0) { - LevelChunkSection[] sections = chunk.getSections(); -@@ -937,7 +936,7 @@ public class ServerLevel extends Level implements WorldGenLevel { - } - // Paper end - optimise random block ticking - //timings.chunkTicksBlocks.stopTiming(); // Paper // Purpur -- gameprofilerfiller.pop(); -+ //gameprofilerfiller.pop(); // Purpur - } - - public Optional findLightningRod(BlockPos pos) { -@@ -1215,19 +1214,19 @@ public class ServerLevel extends Level implements WorldGenLevel { - //try { // Purpur - // Paper end - timings - entity.setOldPosAndRot(); -- ProfilerFiller gameprofilerfiller = this.getProfiler(); -+ //ProfilerFiller gameprofilerfiller = this.getProfiler(); // Purpur - - ++entity.tickCount; -- this.getProfiler().push(() -> { -+ /*this.getProfiler().push(() -> { // Purpur - return BuiltInRegistries.ENTITY_TYPE.getKey(entity.getType()).toString(); -- }); -- gameprofilerfiller.incrementCounter("tickNonPassenger"); -+ });*/ // Purpur -+ //gameprofilerfiller.incrementCounter("tickNonPassenger"); // Purpur - if (isActive) { // Paper - EAR 2 - TimingHistory.activatedEntityTicks++; - entity.tick(); - entity.postTick(); // CraftBukkit - } else { entity.inactiveTick(); } // Paper - EAR 2 -- this.getProfiler().pop(); -+ //this.getProfiler().pop(); // Purpur - //} finally { timer.stopTiming(); } // Paper - timings // Purpur - Iterator iterator = entity.getPassengers().iterator(); - -@@ -1256,12 +1255,12 @@ public class ServerLevel extends Level implements WorldGenLevel { - // Paper end - passenger.setOldPosAndRot(); - ++passenger.tickCount; -- ProfilerFiller gameprofilerfiller = this.getProfiler(); -+ //ProfilerFiller gameprofilerfiller = this.getProfiler(); // Purpur - -- gameprofilerfiller.push(() -> { -+ /*gameprofilerfiller.push(() -> { // Purpur - return BuiltInRegistries.ENTITY_TYPE.getKey(passenger.getType()).toString(); -- }); -- gameprofilerfiller.incrementCounter("tickPassenger"); -+ });*/ // Purpur -+ //gameprofilerfiller.incrementCounter("tickPassenger"); // Purpur - // Paper start - EAR 2 - if (isActive) { - passenger.rideTick(); -@@ -1273,7 +1272,7 @@ public class ServerLevel extends Level implements WorldGenLevel { - vehicle.positionRider(passenger); - } - // Paper end - EAR 2 -- gameprofilerfiller.pop(); -+ //gameprofilerfiller.pop(); // Purpur - Iterator iterator = passenger.getPassengers().iterator(); - - 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 d46f33d9bc99484297270f88e68c1519922cb7db..36cbcf3ca6412d98c9f7a002c5935bb99419fcca 100644 ---- a/src/main/java/net/minecraft/server/level/ServerPlayer.java -+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java -@@ -1159,7 +1159,7 @@ public class ServerPlayer extends Player { - PortalInfo shapedetectorshape = this.findDimensionEntryPoint(worldserver); - - if (shapedetectorshape != null) { -- worldserver1.getProfiler().push("moving"); -+ //worldserver1.getProfiler().push("moving"); // Purpur - worldserver = shapedetectorshape.world; // CraftBukkit - if (worldserver == null) { } else // CraftBukkit - empty to fall through to null to event - if (resourcekey == LevelStem.OVERWORLD && worldserver.getTypeKey() == LevelStem.NETHER) { // CraftBukkit -@@ -1182,8 +1182,8 @@ public class ServerPlayer extends Player { - worldserver = ((CraftWorld) exit.getWorld()).getHandle(); - // CraftBukkit end - -- worldserver1.getProfiler().pop(); -- worldserver1.getProfiler().push("placing"); -+ //worldserver1.getProfiler().pop(); // Purpur -+ //worldserver1.getProfiler().push("placing"); // Purpur - if (true) { // CraftBukkit - this.isChangingDimension = true; // CraftBukkit - Set teleport invulnerability only if player changing worlds - -@@ -1201,7 +1201,7 @@ public class ServerPlayer extends Player { - this.connection.teleport(exit); // CraftBukkit - use internal teleport without event - this.connection.resetPosition(); - worldserver.addDuringPortalTeleport(this); -- worldserver1.getProfiler().pop(); -+ //worldserver1.getProfiler().pop(); // Purpur - this.triggerDimensionChangeTriggers(worldserver1); - this.connection.send(new ClientboundPlayerAbilitiesPacket(this.getAbilities())); - playerlist.sendLevelInfo(this, worldserver); -diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index fc5f3f6e8dcddc3dfe5cf66bfaa25eeafc8ecb53..b2d7db36a801464c3be6fd27ee8b6e11e8426240 100644 ---- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -391,7 +391,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic - this.aboveGroundVehicleTickCount = 0; - } - -- this.server.getProfiler().push("keepAlive"); -+ //this.server.getProfiler().push("keepAlive"); // Purpur - // 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(); -@@ -412,7 +412,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic - } - // Paper end - -- this.server.getProfiler().pop(); -+ //this.server.getProfiler().pop(); // Purpur - // CraftBukkit start - for (int spam; (spam = this.chatSpamTickCount.get()) > 0 && !this.chatSpamTickCount.compareAndSet(spam, spam - 1); ) ; - if (tabSpamLimiter.get() > 0) tabSpamLimiter.getAndDecrement(); // Paper - split to seperate variable -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 9ddbfcf80d9a381dace78a62880f85a4d767e0eb..7383c7d3820dce06108eaafd236a7c6c06a10a42 100644 ---- a/src/main/java/net/minecraft/server/packs/resources/ResourceManagerReloadListener.java -+++ b/src/main/java/net/minecraft/server/packs/resources/ResourceManagerReloadListener.java -@@ -9,11 +9,11 @@ public interface ResourceManagerReloadListener extends PreparableReloadListener - @Override - default CompletableFuture reload(PreparableReloadListener.PreparationBarrier synchronizer, ResourceManager manager, ProfilerFiller prepareProfiler, ProfilerFiller applyProfiler, Executor prepareExecutor, Executor applyExecutor) { - return synchronizer.wait(Unit.INSTANCE).thenRunAsync(() -> { -- applyProfiler.startTick(); -- applyProfiler.push("listener"); -+ //applyProfiler.startTick(); // Purpur -+ //applyProfiler.push("listener"); // Purpur - this.onResourceManagerReload(manager); -- applyProfiler.pop(); -- applyProfiler.endTick(); -+ //applyProfiler.pop(); // Purpur -+ //applyProfiler.endTick(); // Purpur - }, applyExecutor); - } - -diff --git a/src/main/java/net/minecraft/util/profiling/ActiveProfiler.java b/src/main/java/net/minecraft/util/profiling/ActiveProfiler.java -index 6d96da16f25e2359e053c45270310886e168f828..de024b88e7328c25748f59288fb7ff575fce1fdc 100644 ---- a/src/main/java/net/minecraft/util/profiling/ActiveProfiler.java -+++ b/src/main/java/net/minecraft/util/profiling/ActiveProfiler.java -@@ -55,7 +55,7 @@ public class ActiveProfiler implements ProfileCollector { - this.started = true; - this.path = ""; - this.paths.clear(); -- this.push("root"); -+ //this.push("root"); // Purpur - } - } - -@@ -64,7 +64,7 @@ public class ActiveProfiler implements ProfileCollector { - if (!this.started) { - LOGGER.error("Profiler tick already ended - missing startTick()?"); - } else { -- this.pop(); -+ //this.pop(); // Purpur - this.started = false; - if (!this.path.isEmpty()) { - LOGGER.error("Profiler tick ended before path was fully popped (remainder: '{}'). Mismatched push/pop?", LogUtils.defer(() -> { -@@ -93,7 +93,7 @@ public class ActiveProfiler implements ProfileCollector { - - @Override - public void push(Supplier locationGetter) { -- this.push(locationGetter.get()); -+ //this.push(locationGetter.get()); // Purpur - } - - @Override -@@ -132,14 +132,14 @@ public class ActiveProfiler implements ProfileCollector { - - @Override - public void popPush(String location) { -- this.pop(); -- this.push(location); -+ //this.pop(); // Purpur -+ //this.push(location); // Purpur - } - - @Override - public void popPush(Supplier locationGetter) { -- this.pop(); -- this.push(locationGetter); -+ //this.pop(); // Purpur -+ //this.push(locationGetter); // Purpur - } - - private ActiveProfiler.PathEntry getCurrentEntry() { -diff --git a/src/main/java/net/minecraft/util/profiling/ProfilerFiller.java b/src/main/java/net/minecraft/util/profiling/ProfilerFiller.java -index 5725c6593480fada65facc29664a00a8cc073512..ccb1f998ae3122d1856d77149ff7e7dffeedc71a 100644 ---- a/src/main/java/net/minecraft/util/profiling/ProfilerFiller.java -+++ b/src/main/java/net/minecraft/util/profiling/ProfilerFiller.java -@@ -6,32 +6,44 @@ import net.minecraft.util.profiling.metrics.MetricCategory; - public interface ProfilerFiller { - String ROOT = "root"; - -+ @io.papermc.paper.annotation.DoNotUse // Purpur - void startTick(); - -+ @io.papermc.paper.annotation.DoNotUse // Purpur - void endTick(); - -+ @io.papermc.paper.annotation.DoNotUse // Purpur - void push(String location); - -+ @io.papermc.paper.annotation.DoNotUse // Purpur - void push(Supplier locationGetter); - -+ @io.papermc.paper.annotation.DoNotUse // Purpur - void pop(); - -+ @io.papermc.paper.annotation.DoNotUse // Purpur - void popPush(String location); - -+ @io.papermc.paper.annotation.DoNotUse // Purpur - void popPush(Supplier locationGetter); - -+ @io.papermc.paper.annotation.DoNotUse // Purpur - void markForCharting(MetricCategory type); - -+ @io.papermc.paper.annotation.DoNotUse // Purpur - default void incrementCounter(String marker) { -- this.incrementCounter(marker, 1); -+ //this.incrementCounter(marker, 1); // Purpur - } - -+ @io.papermc.paper.annotation.DoNotUse // Purpur - void incrementCounter(String marker, int i); - -+ @io.papermc.paper.annotation.DoNotUse // Purpur - default void incrementCounter(Supplier markerGetter) { -- this.incrementCounter(markerGetter, 1); -+ //this.incrementCounter(markerGetter, 1); // Purpur - } - -+ @io.papermc.paper.annotation.DoNotUse // Purpur - void incrementCounter(Supplier markerGetter, int i); - - static ProfilerFiller tee(final ProfilerFiller a, final ProfilerFiller b) { -@@ -41,62 +53,62 @@ public interface ProfilerFiller { - return b == InactiveProfiler.INSTANCE ? a : new ProfilerFiller() { - @Override - public void startTick() { -- a.startTick(); -- b.startTick(); -+ //a.startTick(); // Purpur -+ //b.startTick(); // Purpur - } - - @Override - public void endTick() { -- a.endTick(); -- b.endTick(); -+ //a.endTick(); // Purpur -+ //b.endTick(); // Purpur - } - - @Override - public void push(String location) { -- a.push(location); -- b.push(location); -+ //a.push(location); // Purpur -+ //b.push(location); // Purpur - } - - @Override - public void push(Supplier locationGetter) { -- a.push(locationGetter); -- b.push(locationGetter); -+ //a.push(locationGetter); // Purpur -+ //b.push(locationGetter); // Purpur - } - - @Override - public void markForCharting(MetricCategory type) { -- a.markForCharting(type); -- b.markForCharting(type); -+ //a.markForCharting(type); // Purpur -+ //b.markForCharting(type); // Purpur - } - - @Override - public void pop() { -- a.pop(); -- b.pop(); -+ //a.pop(); // Purpur -+ //b.pop(); // Purpur - } - - @Override - public void popPush(String location) { -- a.popPush(location); -- b.popPush(location); -+ //a.popPush(location); // Purpur -+ //b.popPush(location); // Purpur - } - - @Override - public void popPush(Supplier locationGetter) { -- a.popPush(locationGetter); -- b.popPush(locationGetter); -+ //a.popPush(locationGetter); // Purpur -+ //b.popPush(locationGetter); // Purpur - } - - @Override - public void incrementCounter(String marker, int i) { -- a.incrementCounter(marker, i); -- b.incrementCounter(marker, i); -+ //a.incrementCounter(marker, i); // Purpur -+ //b.incrementCounter(marker, i); // Purpur - } - - @Override - public void incrementCounter(Supplier markerGetter, int i) { -- a.incrementCounter(markerGetter, i); -- b.incrementCounter(markerGetter, i); -+ //a.incrementCounter(markerGetter, i); // Purpur -+ //b.incrementCounter(markerGetter, i); // Purpur - } - }; - } -diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index ebc7034d68a1c732ba5b89c95e79660d5505a74c..78423f4e97025cafd62037c6505f89faeed8a1f0 100644 ---- a/src/main/java/net/minecraft/world/entity/Entity.java -+++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -822,7 +822,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { - return; - } - // Pufferfish end - entity TTL -- this.level.getProfiler().push("entityBaseTick"); -+ //this.level.getProfiler().push("entityBaseTick"); // Purpur - if (firstTick && this instanceof net.minecraft.world.entity.NeutralMob neutralMob) neutralMob.tickInitialPersistentAnger(level); // Paper - Update last hurt when ticking - this.feetBlockState = null; - if (this.isPassenger() && this.getVehicle().isRemoved()) { -@@ -883,7 +883,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { - } - - this.firstTick = false; -- this.level.getProfiler().pop(); -+ //this.level.getProfiler().pop(); // Purpur - } - - public void setSharedFlagOnFire(boolean onFire) { -@@ -1057,7 +1057,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { - } - } - -- this.level.getProfiler().push("move"); -+ //this.level.getProfiler().push("move"); // Purpur - if (this.stuckSpeedMultiplier.lengthSqr() > 1.0E-7D) { - movement = movement.multiply(this.stuckSpeedMultiplier); - this.stuckSpeedMultiplier = Vec3.ZERO; -@@ -1066,7 +1066,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { - // Paper start - ignore movement changes while inactive. - if (isTemporarilyActive && !(this instanceof ItemEntity || this instanceof net.minecraft.world.entity.vehicle.AbstractMinecart) && movement == getDeltaMovement() && movementType == MoverType.SELF) { - setDeltaMovement(Vec3.ZERO); -- this.level.getProfiler().pop(); -+ //this.level.getProfiler().pop(); // Purpur - return; - } - // Paper end -@@ -1087,8 +1087,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { - this.setPos(this.getX() + vec3d1.x, this.getY() + vec3d1.y, this.getZ() + vec3d1.z); - } - -- this.level.getProfiler().pop(); -- this.level.getProfiler().push("rest"); -+ //this.level.getProfiler().pop(); // Purpur -+ //this.level.getProfiler().push("rest"); // Purpur - boolean flag = !Mth.equal(movement.x, vec3d1.x); - boolean flag1 = !Mth.equal(movement.z, vec3d1.z); - -@@ -1107,7 +1107,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { - - this.checkFallDamage(vec3d1.y, this.onGround, iblockdata, blockposition); - if (this.isRemoved()) { -- this.level.getProfiler().pop(); -+ //this.level.getProfiler().pop(); // Purpur - } else { - if (this.horizontalCollision) { - Vec3 vec3d2 = this.getDeltaMovement(); -@@ -1248,7 +1248,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { - this.setRemainingFireTicks(-this.getFireImmuneTicks()); - } - -- this.level.getProfiler().pop(); -+ //this.level.getProfiler().pop(); // Purpur - } - } - // Paper start - detailed watchdog information -@@ -2928,7 +2928,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { - ServerLevel worldserver1 = minecraftserver.getLevel(resourcekey); - - if (true && !this.isPassenger() && this.portalTime++ >= i) { // CraftBukkit -- this.level.getProfiler().push("portal"); -+ //this.level.getProfiler().push("portal"); // Purpur - this.portalTime = i; - // Paper start - io.papermc.paper.event.entity.EntityPortalReadyEvent event = new io.papermc.paper.event.entity.EntityPortalReadyEvent(this.getBukkitEntity(), worldserver1 == null ? null : worldserver1.getWorld(), org.bukkit.PortalType.NETHER); -@@ -2946,7 +2946,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { - } - } // Paper - // CraftBukkit end -- this.level.getProfiler().pop(); -+ //this.level.getProfiler().pop(); // Purpur - } - - this.isInsidePortal = false; -@@ -3411,14 +3411,14 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { - } - // Paper end - if (this.level instanceof ServerLevel && !this.isRemoved()) { -- this.level.getProfiler().push("changeDimension"); -+ //this.level.getProfiler().push("changeDimension"); // Purpur - // CraftBukkit start - // this.decouple(); - if (worldserver == null) { - return null; - } - // CraftBukkit end -- this.level.getProfiler().push("reposition"); -+ //this.level.getProfiler().push("reposition"); // Purpur - PortalInfo shapedetectorshape = (location == null) ? this.findDimensionEntryPoint(worldserver) : new PortalInfo(new Vec3(location.x(), location.y(), location.z()), Vec3.ZERO, this.yRot, this.xRot, worldserver, null); // CraftBukkit - - if (shapedetectorshape == null) { -@@ -3452,7 +3452,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { - this.unRide(); - // CraftBukkit end - -- this.level.getProfiler().popPush("reloading"); -+ //this.level.getProfiler().popPush("reloading"); // Purpur - // Paper start - Change lead drop timing to prevent dupe - if (this instanceof Mob) { - ((Mob) this).dropLeash(true, true); // Paper drop lead -@@ -3475,10 +3475,10 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { - } - - this.removeAfterChangingDimensions(); -- this.level.getProfiler().pop(); -+ //this.level.getProfiler().pop(); // Purpur - ((ServerLevel) this.level).resetEmptyTime(); - worldserver.resetEmptyTime(); -- this.level.getProfiler().pop(); -+ //this.level.getProfiler().pop(); // Purpur - return entity; - } - } else { -diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index 413652284e229a51e3eefe47f239e8fa9a09ccb2..40dbf933504a46aa358ca4280c578fabf0651315 100644 ---- a/src/main/java/net/minecraft/world/entity/LivingEntity.java -+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -392,7 +392,7 @@ public abstract class LivingEntity extends Entity { - } - - super.baseTick(); -- this.level.getProfiler().push("livingEntityBaseTick"); -+ //this.level.getProfiler().push("livingEntityBaseTick"); // Purpur - if (this.fireImmune() || this.level.isClientSide) { - this.clearFire(); - } -@@ -494,7 +494,7 @@ public abstract class LivingEntity extends Entity { - this.yHeadRotO = this.yHeadRot; - this.yRotO = this.getYRot(); - this.xRotO = this.getXRot(); -- this.level.getProfiler().pop(); -+ //this.level.getProfiler().pop(); // Purpur - } - - public boolean canSpawnSoulSpeedParticle() { -@@ -3062,10 +3062,10 @@ public abstract class LivingEntity extends Entity { - } - - this.run += (f3 - this.run) * 0.3F; -- this.level.getProfiler().push("headTurn"); -+ //this.level.getProfiler().push("headTurn"); // Purpur - f2 = this.tickHeadTurn(f1, f2); -- this.level.getProfiler().pop(); -- this.level.getProfiler().push("rangeChecks"); -+ //this.level.getProfiler().pop(); // Purpur -+ //this.level.getProfiler().push("rangeChecks"); // Purpur - - // Paper start - stop large pitch and yaw changes from crashing the server - this.yRotO += Math.round((this.getYRot() - this.yRotO) / 360.0F) * 360.0F; -@@ -3077,7 +3077,7 @@ public abstract class LivingEntity extends Entity { - this.yHeadRotO += Math.round((this.yHeadRot - this.yHeadRotO) / 360.0F) * 360.0F; - // Paper end - -- this.level.getProfiler().pop(); -+ //this.level.getProfiler().pop(); // Purpur - this.animStep += f2; - if (this.isFallFlying()) { - ++this.fallFlyTicks; -@@ -3374,19 +3374,19 @@ public abstract class LivingEntity extends Entity { - } - - this.setDeltaMovement(d4, d5, d6); -- this.level.getProfiler().push("ai"); -+ //this.level.getProfiler().push("ai"); // Purpur - if (this.isImmobile()) { - this.jumping = false; - this.xxa = 0.0F; - this.zza = 0.0F; - } else if (this.isEffectiveAi()) { -- this.level.getProfiler().push("newAi"); -+ //this.level.getProfiler().push("newAi"); // Purpur - this.serverAiStep(); -- this.level.getProfiler().pop(); -+ //this.level.getProfiler().pop(); // Purpur - } - -- this.level.getProfiler().pop(); -- this.level.getProfiler().push("jump"); -+ //this.level.getProfiler().pop(); // Purpur -+ //this.level.getProfiler().push("jump"); // Purpur - if (this.jumping && this.isAffectedByFluids()) { - double d7; - -@@ -3413,8 +3413,8 @@ public abstract class LivingEntity extends Entity { - this.noJumpDelay = 0; - } - -- this.level.getProfiler().pop(); -- this.level.getProfiler().push("travel"); -+ //this.level.getProfiler().pop(); // Purpur -+ //this.level.getProfiler().push("travel"); // Purpur - this.xxa *= 0.98F; - this.zza *= 0.98F; - this.updateFallFlying(); -@@ -3423,8 +3423,8 @@ public abstract class LivingEntity extends Entity { - // SpigotTimings.timerEntityAIMove.startTiming(); // Spigot // Paper - this.travel(new Vec3((double) this.xxa, (double) this.yya, (double) this.zza)); - // SpigotTimings.timerEntityAIMove.stopTiming(); // Spigot // Paper -- this.level.getProfiler().pop(); -- this.level.getProfiler().push("freezing"); -+ //this.level.getProfiler().pop(); // Purpur -+ //this.level.getProfiler().push("freezing"); // Purpur - boolean flag1 = this.getType().is(EntityTypeTags.FREEZE_HURTS_EXTRA_TYPES); - int i; - -@@ -3444,15 +3444,15 @@ public abstract class LivingEntity extends Entity { - this.hurt(DamageSource.FREEZE, (float) i); - } - -- this.level.getProfiler().pop(); -- this.level.getProfiler().push("push"); -+ //this.level.getProfiler().pop(); // Purpur -+ //this.level.getProfiler().push("push"); // Purpur - if (this.autoSpinAttackTicks > 0) { - --this.autoSpinAttackTicks; - this.checkAutoSpinAttack(axisalignedbb, this.getBoundingBox()); - } - - this.pushEntities(); -- this.level.getProfiler().pop(); -+ //this.level.getProfiler().pop(); // Purpur - // Paper start - if (((ServerLevel) this.level).hasEntityMoveEvent && !(this instanceof net.minecraft.world.entity.player.Player)) { - if (this.xo != 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 94b45579dc371ee980565aed2f5dee78ebd44427..2db9ce11dc52b8fb737e3344265e2a40d07ffc26 100644 ---- a/src/main/java/net/minecraft/world/entity/Mob.java -+++ b/src/main/java/net/minecraft/world/entity/Mob.java -@@ -329,13 +329,13 @@ public abstract class Mob extends LivingEntity { - @Override - public void baseTick() { - super.baseTick(); -- this.level.getProfiler().push("mobBaseTick"); -+ //this.level.getProfiler().push("mobBaseTick"); // Purpur - if (this.isAlive() && this.random.nextInt(1000) < this.ambientSoundTime++) { - this.resetAmbientSoundTime(); - this.playAmbientSound(); - } - -- this.level.getProfiler().pop(); -+ //this.level.getProfiler().pop(); // Purpur - } - - @Override -@@ -640,7 +640,7 @@ public abstract class Mob extends LivingEntity { - @Override - public void aiStep() { - super.aiStep(); -- this.level.getProfiler().push("looting"); -+ //this.level.getProfiler().push("looting"); // Purpur - 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())); -@@ -660,7 +660,7 @@ public abstract class Mob extends LivingEntity { - } - } - -- this.level.getProfiler().pop(); -+ //this.level.getProfiler().pop(); // Purpur - } - - protected Vec3i getPickupReach() { -@@ -873,46 +873,46 @@ public abstract class Mob extends LivingEntity { - return; - } - // Paper end -- this.level.getProfiler().push("sensing"); -+ //this.level.getProfiler().push("sensing"); // Purpur - this.sensing.tick(); -- this.level.getProfiler().pop(); -+ //this.level.getProfiler().pop(); // Purpur - int i = this.level.getServer().getTickCount() + this.getId(); - - if (i % 2 != 0 && this.tickCount > 1) { -- this.level.getProfiler().push("targetSelector"); -+ //this.level.getProfiler().push("targetSelector"); // Purpur - if (this.targetSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking - this.targetSelector.tickRunningGoals(false); -- this.level.getProfiler().pop(); -- this.level.getProfiler().push("goalSelector"); -+ //this.level.getProfiler().pop(); // Purpur -+ //this.level.getProfiler().push("goalSelector"); // Purpur - if (this.goalSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking - this.goalSelector.tickRunningGoals(false); -- this.level.getProfiler().pop(); -+ //this.level.getProfiler().pop(); // Purpur - } else { -- this.level.getProfiler().push("targetSelector"); -+ //this.level.getProfiler().push("targetSelector"); // Purpur - if (this.targetSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking - this.targetSelector.tick(); -- this.level.getProfiler().pop(); -- this.level.getProfiler().push("goalSelector"); -+ //this.level.getProfiler().pop(); // Purpur -+ //this.level.getProfiler().push("goalSelector"); // Purpur - if (this.goalSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking - this.goalSelector.tick(); -- this.level.getProfiler().pop(); -+ //this.level.getProfiler().pop(); // Purpur - } - -- this.level.getProfiler().push("navigation"); -+ //this.level.getProfiler().push("navigation"); // Purpur - this.navigation.tick(); -- this.level.getProfiler().pop(); -- this.level.getProfiler().push("mob tick"); -+ //this.level.getProfiler().pop(); // Purpur -+ //this.level.getProfiler().push("mob tick"); // Purpur - this.customServerAiStep(); -- this.level.getProfiler().pop(); -- this.level.getProfiler().push("controls"); -- this.level.getProfiler().push("move"); -+ //this.level.getProfiler().pop(); // Purpur -+ //this.level.getProfiler().push("controls"); // Purpur -+ //this.level.getProfiler().push("move"); // Purpur - this.moveControl.tick(); -- this.level.getProfiler().popPush("look"); -+ //this.level.getProfiler().popPush("look"); // Purpur - this.lookControl.tick(); -- this.level.getProfiler().popPush("jump"); -+ //this.level.getProfiler().popPush("jump"); // Purpur - this.jumpControl.tick(); -- this.level.getProfiler().pop(); -- this.level.getProfiler().pop(); -+ //this.level.getProfiler().pop(); // Purpur -+ //this.level.getProfiler().pop(); // Purpur - this.sendDebugPackets(); - } - -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 1635818fc4b1788c0d397085239df6dd75b210ab..02978315bc2b828cc603ce7478408f3f82c249c2 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 -@@ -105,8 +105,8 @@ public class GoalSelector { - } - - public void tick() { -- ProfilerFiller profilerFiller = this.profiler.get(); -- profilerFiller.push("goalCleanup"); -+ //ProfilerFiller profilerFiller = this.profiler.get(); // Purpur -+ //profilerFiller.push("goalCleanup"); // Purpur - - for(WrappedGoal wrappedGoal : this.availableGoals) { - if (wrappedGoal.isRunning() && (goalContainsAnyFlags(wrappedGoal, this.goalTypes) || !wrappedGoal.canContinueToUse())) { -@@ -123,8 +123,8 @@ public class GoalSelector { - } - } - -- profilerFiller.pop(); -- profilerFiller.push("goalUpdate"); -+ //profilerFiller.pop(); // Purpur -+ //profilerFiller.push("goalUpdate"); // Purpur - - for(WrappedGoal wrappedGoal2 : this.availableGoals) { - // Paper start -@@ -144,13 +144,13 @@ public class GoalSelector { - } - } - -- profilerFiller.pop(); -+ //profilerFiller.pop(); // Purpur - this.tickRunningGoals(true); - } - - public void tickRunningGoals(boolean tickAll) { -- ProfilerFiller profilerFiller = this.profiler.get(); -- profilerFiller.push("goalTick"); -+ //ProfilerFiller profilerFiller = this.profiler.get(); // Purpur -+ //profilerFiller.push("goalTick"); // Purpur - - for(WrappedGoal wrappedGoal : this.availableGoals) { - if (wrappedGoal.isRunning() && (tickAll || wrappedGoal.requiresUpdateEveryTick())) { -@@ -158,7 +158,7 @@ public class GoalSelector { - } - } - -- profilerFiller.pop(); -+ //profilerFiller.pop(); // Purpur - } - - 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 97257b450e848f53fdb9b5b7affa57b03ea5f459..2f2d9bb31194618ef5bba39cd1cbe7c4919e82c5 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 -@@ -171,12 +171,12 @@ public abstract class PathNavigation { - } - } - // Paper end -- this.level.getProfiler().push("pathfind"); -+ //this.level.getProfiler().push("pathfind"); // Purpur - 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(); -+ //this.level.getProfiler().pop(); // Purpur - 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 288c6627906d07c0d223eacd84ae4eb31a349998..9babe636176da3c40598eb5bdac0919a1704eaa0 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,9 @@ public class Sensing { - } else if (this.unseen.contains(i)) { - return false; - } else { -- this.mob.level.getProfiler().push("hasLineOfSight"); -+ //this.mob.level.getProfiler().push("hasLineOfSight"); // Purpur - boolean bl = this.mob.hasLineOfSight(entity); -- this.mob.level.getProfiler().pop(); -+ //this.mob.level.getProfiler().pop(); // Purpur - 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 c66a214dfbde7fd8e7a68efaa82ac260178f297f..fc94b19804bdb5eb6518378c61d8e047e16af2a8 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 -@@ -231,13 +231,13 @@ public class Allay extends PathfinderMob implements InventoryCarrier { - private int behaviorTick = 0; // Pufferfish - @Override - protected void customServerAiStep() { -- this.level.getProfiler().push("allayBrain"); -+ //this.level.getProfiler().push("allayBrain"); // Purpur - if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish - this.getBrain().tick((ServerLevel) this.level, this); -- this.level.getProfiler().pop(); -- this.level.getProfiler().push("allayActivityUpdate"); -+ //this.level.getProfiler().pop(); // Purpur -+ //this.level.getProfiler().push("allayActivityUpdate"); // Purpur - AllayAi.updateActivity(this); -- this.level.getProfiler().pop(); -+ //this.level.getProfiler().pop(); // Purpur - super.customServerAiStep(); - } - -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 02219f5ca614fefffa1ceb3c7036dfe1c90c8676..10eeef777154a91da4bb2c337079b080521e175a 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 -@@ -288,13 +288,13 @@ public class Axolotl extends Animal implements LerpingModel, VariantHolder 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 d9104d996c854cce1ff167706c93747cd69c3969..cbd9c33f65bedf5ba9187d7707f9d206f433703d 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 -@@ -146,13 +146,13 @@ public class Camel extends AbstractHorse implements PlayerRideableJumping, Rider - - @Override - protected void customServerAiStep() { -- this.level.getProfiler().push("camelBrain"); -+ //this.level.getProfiler().push("camelBrain"); // Purpur - Brain brain = (Brain) this.getBrain(); // Paper - decompile fix - brain.tick((ServerLevel)this.level, this); -- this.level.getProfiler().pop(); -- this.level.getProfiler().push("camelActivityUpdate"); -+ //this.level.getProfiler().pop(); // Purpur -+ //this.level.getProfiler().push("camelActivityUpdate"); // Purpur - CamelAi.updateActivity(this); -- this.level.getProfiler().pop(); -+ //this.level.getProfiler().pop(); // Purpur - super.customServerAiStep(); - } - -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 0a051c7e7f5a172a9b906de04ef2a0419eda26eb..6d91017a8580f17c7203f0d8cb465ef3c94329c3 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 -@@ -180,13 +180,13 @@ public class Frog extends Animal implements VariantHolder { - private int behaviorTick = 0; // Pufferfish - @Override - protected void customServerAiStep() { -- this.level.getProfiler().push("frogBrain"); -+ //this.level.getProfiler().push("frogBrain"); // Purpur - if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish - this.getBrain().tick((ServerLevel)this.level, this); -- this.level.getProfiler().pop(); -- this.level.getProfiler().push("frogActivityUpdate"); -+ //this.level.getProfiler().pop(); // Purpur -+ //this.level.getProfiler().push("frogActivityUpdate"); // Purpur - FrogAi.updateActivity(this); -- this.level.getProfiler().pop(); -+ //this.level.getProfiler().pop(); // Purpur - super.customServerAiStep(); - } - -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 e591b0a09f5a8475b3ec9cd28bd5d5b69809ed73..a9fde4ac03db139997e8c60f75d003b783d5a1d9 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 -@@ -80,13 +80,13 @@ public class Tadpole extends AbstractFish { - private int behaviorTick = 0; // Pufferfish - @Override - protected void customServerAiStep() { -- this.level.getProfiler().push("tadpoleBrain"); -+ //this.level.getProfiler().push("tadpoleBrain"); // Purpur - if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish - this.getBrain().tick((ServerLevel) this.level, this); -- this.level.getProfiler().pop(); -- this.level.getProfiler().push("tadpoleActivityUpdate"); -+ //this.level.getProfiler().pop(); // Purpur -+ //this.level.getProfiler().push("tadpoleActivityUpdate"); // Purpur - TadpoleAi.updateActivity(this); -- this.level.getProfiler().pop(); -+ //this.level.getProfiler().pop(); // Purpur - super.customServerAiStep(); - } - -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 0f365b9dbb160d90ddf5fcd40895305df48ce916..afb46f8a7d6a960529286c51aa3b21e0cb967e77 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 -@@ -191,13 +191,13 @@ public class Goat extends Animal { - private int behaviorTick = 0; // Pufferfish - @Override - protected void customServerAiStep() { -- this.level.getProfiler().push("goatBrain"); -+ //this.level.getProfiler().push("goatBrain"); // Purpur - if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish - this.getBrain().tick((ServerLevel) this.level, this); -- this.level.getProfiler().pop(); -- this.level.getProfiler().push("goatActivityUpdate"); -+ //this.level.getProfiler().pop(); // Purpur -+ //this.level.getProfiler().push("goatActivityUpdate"); // Purpur - GoatAi.updateActivity(this); -- this.level.getProfiler().pop(); -+ //this.level.getProfiler().pop(); // Purpur - super.customServerAiStep(); - } - -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 0ca82175ec91ca8b3418c0931682c972666c47f8..8a53e2fe5821393a905a75b5f18f7101c43d92dd 100644 ---- a/src/main/java/net/minecraft/world/entity/monster/Zoglin.java -+++ b/src/main/java/net/minecraft/world/entity/monster/Zoglin.java -@@ -198,9 +198,9 @@ public class Zoglin extends Monster implements Enemy, HoglinBase { - - @Override - protected void customServerAiStep() { -- this.level.getProfiler().push("zoglinBrain"); -+ //this.level.getProfiler().push("zoglinBrain"); // Purpur - this.getBrain().tick((ServerLevel)this.level, this); -- this.level.getProfiler().pop(); -+ //this.level.getProfiler().pop(); // Purpur - this.updateActivity(); - } - -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 daa2224b021c966751eb39f269ffbfe6e7f3d426..effd71f6f741f7f0d0a3a512d4293a6ae620e3cc 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 -@@ -129,10 +129,10 @@ public class Hoglin extends Animal implements Enemy, HoglinBase { - private int behaviorTick; // Pufferfish - @Override - protected void customServerAiStep() { -- this.level.getProfiler().push("hoglinBrain"); -+ //this.level.getProfiler().push("hoglinBrain"); // Purpur - if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish - this.getBrain().tick((ServerLevel)this.level, this); -- this.level.getProfiler().pop(); -+ //this.level.getProfiler().pop(); // Purpur - 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 b401fb4f276ca81b4bb18426ee56abed8a9f7a7b..5349361f1b8af4434a9dd75e5401264a0604889a 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 -@@ -311,10 +311,10 @@ public class Piglin extends AbstractPiglin implements CrossbowAttackMob, Invento - private int behaviorTick; // Pufferfish - @Override - protected void customServerAiStep() { -- this.level.getProfiler().push("piglinBrain"); -+ //this.level.getProfiler().push("piglinBrain"); // Purpur - if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish - this.getBrain().tick((ServerLevel) this.level, this); -- this.level.getProfiler().pop(); -+ //this.level.getProfiler().pop(); // Purpur - PiglinAi.updateActivity(this); - super.customServerAiStep(); - } -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 769e4fbaac01a4fe3a45bd9cab5c63b61fc69f53..3aa20d9dfd887d3ffa3c243bbe6bf3217b0ccd1f 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 -@@ -85,9 +85,9 @@ public class PiglinBrute extends AbstractPiglin { - - @Override - protected void customServerAiStep() { -- this.level.getProfiler().push("piglinBruteBrain"); -+ //this.level.getProfiler().push("piglinBruteBrain"); // Purpur - this.getBrain().tick((ServerLevel)this.level, this); -- this.level.getProfiler().pop(); -+ //this.level.getProfiler().pop(); // Purpur - PiglinBruteAi.updateActivity(this); - PiglinBruteAi.maybePlayActivitySound(this); - super.customServerAiStep(); -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 904826ea563bd2eb469f403df459def62cc1b5e6..c2a5d93fc2cb437d13f41735daceca00b6602a10 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 -@@ -275,10 +275,10 @@ public class Warden extends Monster implements VibrationListener.VibrationListen - protected void customServerAiStep() { - ServerLevel worldserver = (ServerLevel) this.level; - -- worldserver.getProfiler().push("wardenBrain"); -+ //worldserver.getProfiler().push("wardenBrain"); // Purpur - if (this.behaviorTick++ % this.activatedPriority == 0) // Pufferfish - this.getBrain().tick(worldserver, this); -- this.level.getProfiler().pop(); -+ //this.level.getProfiler().pop(); // Purpur - super.customServerAiStep(); - if ((this.tickCount + this.getId()) % 120 == 0) { - Warden.applyDarknessAround(worldserver, 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 a39d038b5198c9244e2225e0fe383f3c96b49a08..2d222e383d48a1a32eebdb722d770b4fc6c0aca7 100644 ---- a/src/main/java/net/minecraft/world/entity/npc/Villager.java -+++ b/src/main/java/net/minecraft/world/entity/npc/Villager.java -@@ -292,7 +292,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler - @Override - protected void customServerAiStep() { mobTick(false); } - protected void mobTick(boolean inactive) { -- this.level.getProfiler().push("villagerBrain"); -+ //this.level.getProfiler().push("villagerBrain"); // Purpur - // Purpur start - if (org.dreeam.leaf.LeafConfig.villagerLobotomizeEnabled) { - // treat as inactive if lobotomized -@@ -314,7 +314,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler - restock(); - } - // Purpur end -- this.level.getProfiler().pop(); -+ //this.level.getProfiler().pop(); // Purpur - 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 a213f4098859858a73ddd601bbe8c7511972e0d5..c0d39afe5b80159ed9aaca4ddd4763d707882f2e 100644 ---- a/src/main/java/net/minecraft/world/level/Explosion.java -+++ b/src/main/java/net/minecraft/world/level/Explosion.java -@@ -360,7 +360,7 @@ public class Explosion { - if (!iblockdata.isAir() && iblockdata.isDestroyable()) { // Paper - BlockPos blockposition1 = blockposition.immutable(); - -- this.level.getProfiler().push("explosion_blocks"); -+ //this.level.getProfiler().push("explosion_blocks"); // Purpur - if (block.dropFromExplosion(this)) { - Level world = this.level; - -@@ -382,7 +382,7 @@ public class Explosion { - - this.level.setBlock(blockposition, Blocks.AIR.defaultBlockState(), 3); - block.wasExploded(this.level, blockposition, this); -- this.level.getProfiler().pop(); -+ //this.level.getProfiler().pop(); // Purpur - } - } - -diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index e61e52a34bb237bf7b1e28ba8087d1b2cd5f2f89..958e0ee29915bddde2cb8ebfd578448b83e2b149 100644 ---- a/src/main/java/net/minecraft/world/level/Level.java -+++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -664,9 +664,9 @@ public abstract class Level implements LevelAccessor, AutoCloseable { - BlockState iblockdata2 = this.getBlockState(pos); - - if ((flags & 128) == 0 && iblockdata2 != iblockdata1 && (iblockdata2.getLightBlock(this, pos) != iblockdata1.getLightBlock(this, pos) || iblockdata2.getLightEmission() != iblockdata1.getLightEmission() || iblockdata2.useShapeForLightOcclusion() || iblockdata1.useShapeForLightOcclusion())) { -- this.getProfiler().push("queueCheckLight"); -+ //this.getProfiler().push("queueCheckLight"); // Purpur - this.getChunkSource().getLightEngine().checkBlock(pos); -- this.getProfiler().pop(); -+ //this.getProfiler().pop(); // Purpur - } - - /* -@@ -965,9 +965,9 @@ public abstract class Level implements LevelAccessor, AutoCloseable { - } - - protected void tickBlockEntities() { -- ProfilerFiller gameprofilerfiller = this.getProfiler(); -+ //ProfilerFiller gameprofilerfiller = this.getProfiler(); // Purpur - -- gameprofilerfiller.push("blockEntities"); -+ //gameprofilerfiller.push("blockEntities"); // Purpur - //timings.tileEntityPending.startTiming(); // Spigot // Purpur - this.tickingBlockEntities = true; - if (!this.pendingBlockEntityTickers.isEmpty()) { -@@ -1012,7 +1012,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { - //timings.tileEntityTick.stopTiming(); // Spigot // Purpur - this.tickingBlockEntities = false; - co.aikar.timings.TimingHistory.tileEntityTicks += this.blockEntityTickers.size(); // Paper -- gameprofilerfiller.pop(); -+ //gameprofilerfiller.pop(); // Purpur - spigotConfig.currentPrimedTnt = 0; // Spigot - } - -@@ -1205,7 +1205,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { - - @Override - public List getEntities(@Nullable Entity except, AABB box, Predicate predicate) { -- this.getProfiler().incrementCounter("getEntities"); -+ //this.getProfiler().incrementCounter("getEntities"); // Purpur - List list = Lists.newArrayList(); - ((ServerLevel)this).getEntityLookup().getEntities(except, box, list, predicate); // Paper - optimise this call - return list; -@@ -1224,7 +1224,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { - } - - public void getEntities(EntityTypeTest filter, AABB box, Predicate predicate, List result, int limit) { -- this.getProfiler().incrementCounter("getEntities"); -+ //this.getProfiler().incrementCounter("getEntities"); // Purpur - // Paper start - optimise this call - //TODO use limit - if (filter instanceof net.minecraft.world.entity.EntityType entityTypeTest) { -@@ -1553,7 +1553,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { - } - - public ProfilerFiller getProfiler() { -- if (gg.pufferfish.pufferfish.PufferfishConfig.disableMethodProfiler) return net.minecraft.util.profiling.InactiveProfiler.INSTANCE; // Pufferfish -+ if (true || gg.pufferfish.pufferfish.PufferfishConfig.disableMethodProfiler) return net.minecraft.util.profiling.InactiveProfiler.INSTANCE; // Pufferfish // Purpur - return (ProfilerFiller) this.profiler.get(); - } - -diff --git a/src/main/java/net/minecraft/world/level/NaturalSpawner.java b/src/main/java/net/minecraft/world/level/NaturalSpawner.java -index 31cab107a606409af5c1fe56cd0956d707637cc0..fbb735915759ea59660daa809e23849a60fa5974 100644 ---- a/src/main/java/net/minecraft/world/level/NaturalSpawner.java -+++ b/src/main/java/net/minecraft/world/level/NaturalSpawner.java -@@ -132,7 +132,7 @@ 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.getProfiler().push("spawner"); // Purpur - //world.timings.mobSpawn.startTiming(); // Spigot // Purpur - MobCategory[] aenumcreaturetype = NaturalSpawner.SPAWNING_CATEGORIES; - int i = aenumcreaturetype.length; -@@ -189,7 +189,7 @@ public final class NaturalSpawner { - } - - //world.timings.mobSpawn.stopTiming(); // Spigot // Purpur -- world.getProfiler().pop(); -+ //world.getProfiler().pop(); // Purpur - } - - // Paper start -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 f64225897d659127dd87293b26b58653cefda0c3..1fcdd47ee804db8d6649b603fd95c5273f40801d 100644 ---- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java -+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java -@@ -1307,9 +1307,9 @@ public class LevelChunk extends ChunkAccess { - - if (LevelChunk.this.isTicking(blockposition)) { - try { -- ProfilerFiller gameprofilerfiller = LevelChunk.this.level.getProfiler(); -+ //ProfilerFiller gameprofilerfiller = LevelChunk.this.level.getProfiler(); // Purpur - -- gameprofilerfiller.push(this::getType); -+ //gameprofilerfiller.push(this::getType); // Purpur - //this.blockEntity.tickTimer.startTiming(); // Spigot // Purpur - BlockState iblockdata = LevelChunk.this.getBlockState(blockposition); - -@@ -1321,7 +1321,7 @@ public class LevelChunk extends ChunkAccess { - LevelChunk.LOGGER.warn("Block entity {} @ {} state {} invalid for ticking:", new Object[]{LogUtils.defer(this::getType), LogUtils.defer(this::getPos), iblockdata}); - } - -- gameprofilerfiller.pop(); -+ //gameprofilerfiller.pop(); // Purpur - } catch (Throwable throwable) { - if (throwable instanceof ThreadDeath) throw throwable; // Paper - // Paper start - Prevent tile 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 d23481453717f715124156b5d83f6448f720d049..a8af51a25b0f99c3a64d9150fdfcd6b818aa7581 100644 ---- a/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java -+++ b/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java -@@ -53,8 +53,8 @@ public class PathFinder { - @Nullable - // Paper start - 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); -+ //profiler.push("find_path"); // Purpur -+ //profiler.markForCharting(MetricCategory.PATH_FINDING); // Purpur - // Set set = positions.keySet(); - startNode.g = 0.0F; - startNode.h = this.getBestH(startNode, positions); // Paper - 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 7f1ac2cb29eb84833c0895442d611dfa0504527e..5dea8414964e0d2d1fb15a6baa27227e9722bfc7 100644 ---- a/src/main/java/net/minecraft/world/ticks/LevelTicks.java -+++ b/src/main/java/net/minecraft/world/ticks/LevelTicks.java -@@ -86,20 +86,20 @@ public class LevelTicks implements LevelTickAccess { - } - - public void tick(long time, int maxTicks, BiConsumer ticker) { -- ProfilerFiller profilerFiller = this.profiler.get(); -- profilerFiller.push("collect"); -- this.collectTicks(time, maxTicks, profilerFiller); -- profilerFiller.popPush("run"); -- profilerFiller.incrementCounter("ticksToRun", this.toRunThisTick.size()); -+ //ProfilerFiller profilerFiller = this.profiler.get(); // Purpur -+ //profilerFiller.push("collect"); // Purpur -+ this.collectTicks(time, maxTicks, null); // Purpur -+ //profilerFiller.popPush("run"); // Purpur -+ //profilerFiller.incrementCounter("ticksToRun", this.toRunThisTick.size()); // Purpur - this.runCollectedTicks(ticker); -- profilerFiller.popPush("cleanup"); -+ //profilerFiller.popPush("cleanup"); // Purpur - this.cleanupAfterTick(); -- profilerFiller.pop(); -+ //profilerFiller.pop(); // Purpur - } - - private void collectTicks(long time, int maxTicks, ProfilerFiller profiler) { - this.sortContainersToTick(time); -- profiler.incrementCounter("containersToTick", this.containersToTick.size()); -+ //profiler.incrementCounter("containersToTick", this.containersToTick.size()); // Purpur - this.drainContainers(time, maxTicks); - this.rescheduleLeftoverContainers(); - } diff --git a/patches/server/0039-Akarin-Save-Json-list-asynchronously.patch b/patches/server/0029-Akarin-Save-Json-list-asynchronously.patch similarity index 93% rename from patches/server/0039-Akarin-Save-Json-list-asynchronously.patch rename to patches/server/0029-Akarin-Save-Json-list-asynchronously.patch index 32c115b5..0cf5585f 100644 --- a/patches/server/0039-Akarin-Save-Json-list-asynchronously.patch +++ b/patches/server/0029-Akarin-Save-Json-list-asynchronously.patch @@ -8,19 +8,18 @@ Original license: GPL v3 Original project: https://github.com/Akarin-project/Akarin diff --git a/src/main/java/net/minecraft/server/players/StoredUserList.java b/src/main/java/net/minecraft/server/players/StoredUserList.java -index 4fd709a550bf8da1e996894a1ca6b91206c31e9e..b43a7c3aea930805ea917176d4a7b5564be084cb 100644 +index 5dee29939421333caa51e1a659d8ad9f9c0358c9..1f629ec713333fae303b4b31422a880fc858172b 100644 --- a/src/main/java/net/minecraft/server/players/StoredUserList.java +++ b/src/main/java/net/minecraft/server/players/StoredUserList.java -@@ -23,6 +23,8 @@ import java.util.Map; - import java.util.Objects; - import java.util.stream.Stream; +@@ -24,6 +24,7 @@ import java.util.stream.Stream; import javax.annotation.Nullable; -+ + + import me.titaniumtown.ArrayConstants; +import io.papermc.paper.util.MCUtil; import net.minecraft.Util; import net.minecraft.util.GsonHelper; import org.slf4j.Logger; -@@ -148,37 +150,43 @@ public abstract class StoredUserList> { +@@ -149,37 +150,43 @@ public abstract class StoredUserList> { } public void save() throws IOException { diff --git a/patches/server/0029-KeYi-Do-not-save-firework-entities-or-the-server-may.patch b/patches/server/0029-KeYi-Do-not-save-firework-entities-or-the-server-may.patch deleted file mode 100644 index f612fe7a..00000000 --- a/patches/server/0029-KeYi-Do-not-save-firework-entities-or-the-server-may.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: nostalgic853 -Date: Mon, 24 Oct 2022 10:25:40 +0800 -Subject: [PATCH] KeYi: Do not save firework entities or the server may be - laggy - -Original license: MIT -Original project: https://github.com/KeYiMC/KeYi - -diff --git a/src/main/java/net/minecraft/world/entity/projectile/FireworkRocketEntity.java b/src/main/java/net/minecraft/world/entity/projectile/FireworkRocketEntity.java -index 5406925cd66f46ab8744123c670d72cea7bfc3a1..0b664dfef68b1e3905c9d8451602abf9cd9eafe6 100644 ---- a/src/main/java/net/minecraft/world/entity/projectile/FireworkRocketEntity.java -+++ b/src/main/java/net/minecraft/world/entity/projectile/FireworkRocketEntity.java -@@ -358,4 +358,11 @@ public class FireworkRocketEntity extends Projectile implements ItemSupplier { - public boolean isAttackable() { - return false; - } -+ -+ // KeYi start -+ @Override -+ public boolean shouldBeSaved() { -+ return false; -+ } -+ // KeYi end - } diff --git a/patches/server/0040-Slice-Smooth-Teleports.patch b/patches/server/0030-Slice-Smooth-Teleports.patch similarity index 91% rename from patches/server/0040-Slice-Smooth-Teleports.patch rename to patches/server/0030-Slice-Smooth-Teleports.patch index 9a9a7beb..89454f28 100644 --- a/patches/server/0040-Slice-Smooth-Teleports.patch +++ b/patches/server/0030-Slice-Smooth-Teleports.patch @@ -7,10 +7,10 @@ Original license: MIT Original project: https://github.com/Cryptite/Slice diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java -index b5aaddaf2ef9e7639cbdc682d06330945be3c432..b157f887092b4ca9642548eadd9a633bb74ec14d 100644 +index 2c2262a2babd4fd5ca22b4630c1f0ae5e3a1a9ab..27c3c32b2bbc0ba1420ecae635d42e9df054256a 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java -@@ -268,6 +268,7 @@ public class ServerPlayer extends Player { +@@ -269,6 +269,7 @@ public class ServerPlayer extends Player { public final com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet cachedSingleHashSet; // Paper public PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper public org.bukkit.event.player.PlayerQuitEvent.QuitReason quitReason = null; // Paper - there are a lot of changes to do if we change all methods leading to the event @@ -19,10 +19,10 @@ index b5aaddaf2ef9e7639cbdc682d06330945be3c432..b157f887092b4ca9642548eadd9a633b private boolean compassBar = false; // Purpur private boolean ramBar = false; // Purpur diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index c0278a87a77d14c7598e6d431b63bbd5c7d863af..54d9b2c1dcab93b37c02aeda146aef088f20dff0 100644 +index 94f3d84a1a89e1f1c720d6e7f19e93b1b0b5a865..e77d9b23ae797cc1b2d04028695bfa27d9f02076 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java -@@ -901,12 +901,12 @@ public abstract class PlayerList { +@@ -975,12 +975,12 @@ public abstract class PlayerList { int i = flag ? 1 : 0; // CraftBukkit start LevelData worlddata = worldserver1.getLevelData(); @@ -38,7 +38,7 @@ index c0278a87a77d14c7598e6d431b63bbd5c7d863af..54d9b2c1dcab93b37c02aeda146aef08 // entityplayer1.connection.teleport(entityplayer1.getX(), entityplayer1.getY(), entityplayer1.getZ(), entityplayer1.getYRot(), entityplayer1.getXRot()); diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 472d9281199cb9cd8edafc6d2309e5e296a014cd..3ef7fec22de7727b8627802e305aa68340798e70 100644 +index 7052b1fb5a2bf6099c92eeeab8c83098d97792c7..581bcd14e6a186bac1389dbbb25eca3625790db4 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -1192,6 +1192,15 @@ public class CraftPlayer extends CraftHumanEntity implements Player { diff --git a/patches/server/0034-Patina-Don-t-create-new-random-instance.patch b/patches/server/0034-Patina-Don-t-create-new-random-instance.patch deleted file mode 100644 index 8dce1dea..00000000 --- a/patches/server/0034-Patina-Don-t-create-new-random-instance.patch +++ /dev/null @@ -1,46 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: foss-mc <69294560+foss-mc@users.noreply.github.com> -Date: Thu, 1 Jul 2021 12:17:44 +0000 -Subject: [PATCH] Patina: Don't create new random instance - -Original license: GPL v3 -Original project: https://github.com/PatinaMC/Patina - -Original code by PatinaMC, licensed under GNU General Public License v3.0 -You can find the original code on https://github.com/PatinaMC/Patina - -diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java -index 36cbcf3ca6412d98c9f7a002c5935bb99419fcca..b5aaddaf2ef9e7639cbdc682d06330945be3c432 100644 ---- a/src/main/java/net/minecraft/server/level/ServerPlayer.java -+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java -@@ -393,7 +393,7 @@ public class ServerPlayer extends Player { - long l = k * k; - int i1 = l > 2147483647L ? Integer.MAX_VALUE : (int) l; - int j1 = this.getCoprime(i1); -- int k1 = RandomSource.create().nextInt(i1); -+ int k1 = worldserver.random.nextInt(i1); // Patina - don't create new random instance - - for (int l1 = 0; l1 < i1; ++l1) { - int i2 = (k1 + j1 * l1) % i1; -@@ -430,7 +430,7 @@ public class ServerPlayer extends Player { - long l = k * k; - int i1 = l > 2147483647L ? Integer.MAX_VALUE : (int) l; - int j1 = this.getCoprime(i1); -- int k1 = RandomSource.create().nextInt(i1); -+ int k1 = world.random.nextInt(i1); // Patina - don't create new random instance - - for (int l1 = 0; l1 < i1; ++l1) { - int i2 = (k1 + j1 * l1) % i1; -diff --git a/src/main/java/net/minecraft/server/rcon/thread/QueryThreadGs4.java b/src/main/java/net/minecraft/server/rcon/thread/QueryThreadGs4.java -index 1ef089dbf83de35d875c00efdf468c397be56978..c345f10cbf7f3451edc604f97cdf959d70639e17 100644 ---- a/src/main/java/net/minecraft/server/rcon/thread/QueryThreadGs4.java -+++ b/src/main/java/net/minecraft/server/rcon/thread/QueryThreadGs4.java -@@ -349,7 +349,7 @@ public class QueryThreadGs4 extends GenericThread { - this.identBytes[2] = bs[5]; - this.identBytes[3] = bs[6]; - this.ident = new String(this.identBytes, StandardCharsets.UTF_8); -- this.challenge = RandomSource.create().nextInt(16777216); -+ this.challenge = java.util.concurrent.ThreadLocalRandom.current().nextInt(16777216); // Patina - don't create new random instance - this.challengeBytes = String.format(Locale.ROOT, "\t%s%d\u0000", this.ident, this.challenge).getBytes(StandardCharsets.UTF_8); - } - diff --git a/patches/server/0035-Yatopia-Smarter-statistics-ticking.patch b/patches/server/0035-Yatopia-Smarter-statistics-ticking.patch deleted file mode 100644 index 5af06eb3..00000000 --- a/patches/server/0035-Yatopia-Smarter-statistics-ticking.patch +++ /dev/null @@ -1,52 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Mykyta Komarnytskyy -Date: Sat, 24 Oct 2020 21:03:53 -0500 -Subject: [PATCH] Yatopia: Smarter statistics ticking - -Original license: MIT -Original project: https://github.com/YatopiaMC/Yatopia - -In vanilla, statistics that count time spent for an action (i.e. time played or sneak time) are incremented every tick. This is retarded. With this patch and a configured interval of 20, the statistics are only ticked every 20th tick and are incremented by 20 ticks at a time. This means a lot less ticking with the same accurate counting. -With an interval of 20, this patch saves roughly 3ms per tick on a server w/ 80 players online. - -Original code by YatopiaMC, licensed under MIT -You can find the original code on https://github.com/YatopiaMC/Yatopia - -diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java -index 61597ebe2f9faff43994c475074b87d11905e582..f61f1388aa93b98a3df407973f643f5f03e71652 100644 ---- a/src/main/java/net/minecraft/world/entity/player/Player.java -+++ b/src/main/java/net/minecraft/world/entity/player/Player.java -@@ -278,19 +278,21 @@ public abstract class Player extends LivingEntity { - this.moveCloak(); - if (!this.level.isClientSide) { - this.foodData.tick(this); -- this.awardStat(Stats.PLAY_TIME); -- this.awardStat(Stats.TOTAL_WORLD_TIME); -- if (this.isAlive()) { -- this.awardStat(Stats.TIME_SINCE_DEATH); -- } -- -- if (this.isDiscrete()) { -- this.awardStat(Stats.CROUCH_TIME); -- } -- -- if (!this.isSleeping()) { -- this.awardStat(Stats.TIME_SINCE_REST); -+ // Mirai start -+ if (tickCount % 20 == 0) { -+ this.awardStat(Stats.PLAY_TIME, 20); -+ this.awardStat(Stats.TOTAL_WORLD_TIME, 20); -+ if (this.isAlive()) { -+ this.awardStat(Stats.TIME_SINCE_DEATH, 20); -+ } -+ if (this.isDiscrete()) { -+ this.awardStat(Stats.CROUCH_TIME, 20); -+ } -+ if (!this.isSleeping()) { -+ this.awardStat(Stats.TIME_SINCE_REST, 20); -+ } - } -+ // Mirai end - } - - int i = 29999999; diff --git a/patches/server/0036-Mirai-Fast-speed-check.patch b/patches/server/0036-Mirai-Fast-speed-check.patch deleted file mode 100644 index e159b343..00000000 --- a/patches/server/0036-Mirai-Fast-speed-check.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: nostalgic853 -Date: Sat, 22 Oct 2022 09:58:38 +0800 -Subject: [PATCH] Mirai: Fast speed check - -Original license: GPL v3 -Original project: https://github.com/etil2jz/Mirai - -Original code by NFT-Worlds, licensed under GNU General Public License v3.0 -You can find the original code on https://github.com/NFT-Worlds/Server - -This patch was took from Mirai. (https://github.com/etil2jz/Mirai) - -etil2jz's note: -NFT-Worlds is related to Stellar devs, known for countless paid forks mostly taking open source patches, -doing questionable/buggy ones, and claiming breathtaking performance improvements. Never ever pay for -any of those Spigot forks! - -diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 78423f4e97025cafd62037c6505f89faeed8a1f0..1f8210cd90d9e0ae3feaba2e10ff8073836cdfd3 100644 ---- a/src/main/java/net/minecraft/world/entity/Entity.java -+++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -1194,7 +1194,14 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { - } - - this.tryCheckInsideBlocks(); -- float f2 = this.getBlockSpeedFactor(); -+ // KeYi start - Fast speed check -+ float f2; -+ if (this.getDeltaMovement().x == 0 && this.getDeltaMovement().z == 0) { -+ f2 = 1; -+ } else { -+ f2 = this.getBlockSpeedFactor(); -+ } -+ // KeYi end - - this.setDeltaMovement(this.getDeltaMovement().multiply((double) f2, 1.0D, (double) f2)); - // Paper start - remove expensive streams from here diff --git a/patches/server/0037-VMP-Skip-entity-move-if-no-movement.patch b/patches/server/0037-VMP-Skip-entity-move-if-no-movement.patch deleted file mode 100644 index 2a41924f..00000000 --- a/patches/server/0037-VMP-Skip-entity-move-if-no-movement.patch +++ /dev/null @@ -1,42 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: nostalgic853 -Date: Mon, 24 Oct 2022 11:01:36 +0800 -Subject: [PATCH] VMP: Skip entity move if no movement - -Original license: MIT -Original project: https://github.com/RelativityMC/VMP-fabric - -diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 1f8210cd90d9e0ae3feaba2e10ff8073836cdfd3..8f3f7a4c2429dd3c9060a1d2f412e41a5448bf4c 100644 ---- a/src/main/java/net/minecraft/world/entity/Entity.java -+++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -398,6 +398,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { - private UUID originWorld; - public boolean freezeLocked = false; // Paper - Freeze Tick Lock API - public boolean collidingWithWorldBorder; // Paper -+ private boolean boundingBoxChanged = false; // KeYi - - public void setOrigin(@javax.annotation.Nonnull Location location) { - this.origin = location.toVector(); -@@ -1034,6 +1035,13 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { - // Paper end - detailed watchdog information - - public void move(MoverType movementType, Vec3 movement) { -+ // KeYi start -+ if (!boundingBoxChanged && movement.equals(Vec3.ZERO)) { -+ boundingBoxChanged = false; -+ return; -+ } -+ // KeYi end -+ - // Paper start - detailed watchdog information - io.papermc.paper.util.TickThread.ensureTickThread("Cannot move an entity off-main"); - synchronized (this.posLock) { -@@ -3824,6 +3832,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { - } - - public final void setBoundingBox(AABB boundingBox) { -+ if (!this.bb.equals(boundingBox)) boundingBoxChanged = true; // KeYi - // CraftBukkit start - block invalid bounding boxes - double minX = boundingBox.minX, - minY = boundingBox.minY, diff --git a/patches/server/0041-MikuServer-Async-entity-traveling.patch b/patches/server/0041-MikuServer-Async-entity-traveling.patch deleted file mode 100644 index 823d2dbe..00000000 --- a/patches/server/0041-MikuServer-Async-entity-traveling.patch +++ /dev/null @@ -1,791 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: wangxyper -Date: Fri, 27 Jan 2023 19:38:48 +0800 -Subject: [PATCH] MikuServer: Async entity traveling - -Original license: MIT -Original project: https://github.com/MikuMC/MikuServer - -diff --git a/src/main/java/co/m2ek4u/aoame/AnotherTickThread.java b/src/main/java/co/m2ek4u/aoame/AnotherTickThread.java -new file mode 100644 -index 0000000000000000000000000000000000000000..d5fe52beb25e7a95549cdf0ae19edf6029f10642 ---- /dev/null -+++ b/src/main/java/co/m2ek4u/aoame/AnotherTickThread.java -@@ -0,0 +1,13 @@ -+package co.m2ek4u.aoame; -+ -+import io.papermc.paper.util.TickThread; -+ -+public class AnotherTickThread extends TickThread { -+ public AnotherTickThread(String name) { -+ super(name); -+ } -+ -+ public AnotherTickThread(Runnable run, String name) { -+ super(run, name); -+ } -+} -diff --git a/src/main/java/co/m2ek4u/aoame/CallbackExecutor.java b/src/main/java/co/m2ek4u/aoame/CallbackExecutor.java -new file mode 100644 -index 0000000000000000000000000000000000000000..b861405a7626ba8fa677c455bf6507253b33c157 ---- /dev/null -+++ b/src/main/java/co/m2ek4u/aoame/CallbackExecutor.java -@@ -0,0 +1,99 @@ -+package co.m2ek4u.aoame; -+ -+import org.jetbrains.annotations.NotNull; -+import java.util.Queue; -+import java.util.concurrent.*; -+import java.util.concurrent.atomic.AtomicBoolean; -+import java.util.concurrent.locks.LockSupport; -+ -+public class CallbackExecutor extends ThreadPoolExecutor { -+ private final AtomicBoolean isSubmittingStarted = new AtomicBoolean(false); -+ private final Queue submittedTasks = new ConcurrentLinkedDeque<>(); -+ -+ public CallbackExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, @NotNull TimeUnit unit, @NotNull BlockingQueue workQueue) { -+ super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue); -+ } -+ -+ public CallbackExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, @NotNull TimeUnit unit, @NotNull BlockingQueue workQueue, @NotNull ThreadFactory threadFactory) { -+ super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, threadFactory); -+ } -+ -+ public CallbackExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, @NotNull TimeUnit unit, @NotNull BlockingQueue workQueue, @NotNull RejectedExecutionHandler handler) { -+ super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, handler); -+ } -+ -+ public CallbackExecutor(int corePoolSize, int maximumPoolSize, long keepAliveTime, @NotNull TimeUnit unit, @NotNull BlockingQueue workQueue, @NotNull ThreadFactory threadFactory, @NotNull RejectedExecutionHandler handler) { -+ super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, threadFactory, handler); -+ } -+ -+ public void startSubmitting(){ -+ if (this.isSubmittingStarted.get()){ -+ throw new IllegalStateException(); -+ } -+ this.isSubmittingStarted.set(true); -+ } -+ -+ public void awaitSubmittingEnd(){ -+ while (this.isSubmittingStarted.get()){ -+ LockSupport.parkNanos(this,1); -+ } -+ } -+ -+ public void executeWithCallBack(Runnable command,Runnable callBack){ -+ if (this.isSubmittingStarted.get()){ -+ TaskEntry newTask = new TaskEntry(command,callBack); -+ this.execute(newTask::runMainTask); -+ this.submittedTasks.add(newTask); -+ return; -+ } -+ throw new IllegalStateException(); -+ } -+ -+ public boolean isSubmittingStarted(){ -+ return this.isSubmittingStarted.get(); -+ } -+ -+ public void stopSubmitting(){ -+ if (!this.isSubmittingStarted.get()){ -+ throw new IllegalStateException(); -+ } -+ this.isSubmittingStarted.set(false); -+ TaskEntry task; -+ while ((task = this.submittedTasks.poll())!=null){ -+ while (!task.runSubTask()){ -+ LockSupport.parkNanos(this,1); -+ } -+ } -+ } -+ -+ private static class TaskEntry{ -+ private final Runnable mainTask; -+ private final Runnable subTask; -+ private volatile boolean mainTaskFinished = false; -+ -+ public TaskEntry(Runnable mainTask,Runnable subTask){ -+ this.mainTask = mainTask; -+ this.subTask = subTask; -+ } -+ -+ public void runMainTask(){ -+ try { -+ this.mainTask.run(); -+ }finally { -+ this.mainTaskFinished = true; -+ } -+ } -+ -+ public boolean runSubTask(){ -+ if (!this.mainTaskFinished){ -+ return false; -+ } -+ try { -+ this.subTask.run(); -+ }catch (Exception e){ -+ e.printStackTrace(); -+ } -+ return true; -+ } -+ } -+} -diff --git a/src/main/java/com/destroystokyo/paper/util/maplist/EntityList.java b/src/main/java/com/destroystokyo/paper/util/maplist/EntityList.java -index 0133ea6feb1ab88f021f66855669f58367e7420b..b128433d2888a98bce55052e821626c0478748dd 100644 ---- a/src/main/java/com/destroystokyo/paper/util/maplist/EntityList.java -+++ b/src/main/java/com/destroystokyo/paper/util/maplist/EntityList.java -@@ -1,6 +1,9 @@ - package com.destroystokyo.paper.util.maplist; - - import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; -+import it.unimi.dsi.fastutil.objects.ObjectArrayList; -+import it.unimi.dsi.fastutil.objects.ObjectList; -+import it.unimi.dsi.fastutil.objects.ObjectLists; - import net.minecraft.world.entity.Entity; - import java.util.Arrays; - import java.util.Iterator; -@@ -12,117 +15,42 @@ import java.util.NoSuchElementException; - */ - public final class EntityList implements Iterable { - -- protected final Int2IntOpenHashMap entityToIndex = new Int2IntOpenHashMap(2, 0.8f); -- { -- this.entityToIndex.defaultReturnValue(Integer.MIN_VALUE); -- } -- -- protected static final Entity[] EMPTY_LIST = new Entity[0]; -- -- protected Entity[] entities = EMPTY_LIST; -- protected int count; -+ private final ObjectList objectList = ObjectLists.synchronize(new ObjectArrayList<>()); - - public int size() { -- return this.count; -+ return this.objectList.size(); - } - - public boolean contains(final Entity entity) { -- return this.entityToIndex.containsKey(entity.getId()); -+ return this.objectList.contains(entity); - } - - public boolean remove(final Entity entity) { -- final int index = this.entityToIndex.remove(entity.getId()); -- if (index == Integer.MIN_VALUE) { -- return false; -- } -- -- // move the entity at the end to this index -- final int endIndex = --this.count; -- final Entity end = this.entities[endIndex]; -- if (index != endIndex) { -- // not empty after this call -- this.entityToIndex.put(end.getId(), index); // update index -- } -- this.entities[index] = end; -- this.entities[endIndex] = null; -- -- return true; -+ return this.objectList.remove(entity); - } - - public boolean add(final Entity entity) { -- final int count = this.count; -- final int currIndex = this.entityToIndex.putIfAbsent(entity.getId(), count); -- -- if (currIndex != Integer.MIN_VALUE) { -- return false; // already in this list -- } -- -- Entity[] list = this.entities; -- -- if (list.length == count) { -- // resize required -- list = this.entities = Arrays.copyOf(list, (int)Math.max(4L, count * 2L)); // overflow results in negative -- } -- -- list[count] = entity; -- this.count = count + 1; -- -- return true; -+ return this.objectList.add(entity); - } - - public Entity getChecked(final int index) { -- if (index < 0 || index >= this.count) { -- throw new IndexOutOfBoundsException("Index: " + index + " is out of bounds, size: " + this.count); -- } -- return this.entities[index]; -+ return this.objectList.get(index); - } - - public Entity getUnchecked(final int index) { -- return this.entities[index]; -+ return this.objectList.get(index); - } - - public Entity[] getRawData() { -- return this.entities; -+ return this.objectList.toArray(Entity[]::new); - } - - public void clear() { -- this.entityToIndex.clear(); -- Arrays.fill(this.entities, 0, this.count, null); -- this.count = 0; -+ this.objectList.clear(); - } - - @Override - public Iterator iterator() { -- return new Iterator() { -- -- Entity lastRet; -- int current; -- -- @Override -- public boolean hasNext() { -- return this.current < EntityList.this.count; -- } -- -- @Override -- public Entity next() { -- if (this.current >= EntityList.this.count) { -- throw new NoSuchElementException(); -- } -- return this.lastRet = EntityList.this.entities[this.current++]; -- } -- -- @Override -- public void remove() { -- final Entity lastRet = this.lastRet; -- -- if (lastRet == null) { -- throw new IllegalStateException(); -- } -- this.lastRet = null; -- -- EntityList.this.remove(lastRet); -- --this.current; -- } -- }; -+ return this.objectList.iterator(); - } - } -diff --git a/src/main/java/io/papermc/paper/chunk/system/entity/EntityLookup.java b/src/main/java/io/papermc/paper/chunk/system/entity/EntityLookup.java -index 61c170555c8854b102c640b0b6a615f9f732edbf..ec90ff5c2581706180498b74dbbf960d52d47209 100644 ---- a/src/main/java/io/papermc/paper/chunk/system/entity/EntityLookup.java -+++ b/src/main/java/io/papermc/paper/chunk/system/entity/EntityLookup.java -@@ -6,8 +6,14 @@ import io.papermc.paper.util.CoordinateUtils; - import io.papermc.paper.util.TickThread; - import io.papermc.paper.util.WorldUtil; - import io.papermc.paper.world.ChunkEntitySlices; -+import it.unimi.dsi.fastutil.ints.Int2ReferenceMap; -+import it.unimi.dsi.fastutil.ints.Int2ReferenceMaps; - import it.unimi.dsi.fastutil.ints.Int2ReferenceOpenHashMap; -+import it.unimi.dsi.fastutil.longs.Long2ObjectMap; -+import it.unimi.dsi.fastutil.longs.Long2ObjectMaps; - import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; -+import it.unimi.dsi.fastutil.objects.Object2ReferenceMap; -+import it.unimi.dsi.fastutil.objects.Object2ReferenceMaps; - import it.unimi.dsi.fastutil.objects.Object2ReferenceOpenHashMap; - import net.minecraft.core.BlockPos; - import io.papermc.paper.chunk.system.ChunkSystem; -@@ -26,11 +32,8 @@ import net.minecraft.world.phys.AABB; - import org.jetbrains.annotations.NotNull; - import org.jetbrains.annotations.Nullable; - import org.slf4j.Logger; --import java.util.ArrayList; --import java.util.Iterator; --import java.util.List; --import java.util.NoSuchElementException; --import java.util.UUID; -+ -+import java.util.*; - import java.util.concurrent.locks.StampedLock; - import java.util.function.Consumer; - import java.util.function.Predicate; -@@ -46,15 +49,15 @@ public final class EntityLookup implements LevelEntityGetter { - public final ServerLevel world; - - private final StampedLock stateLock = new StampedLock(); -- protected final Long2ObjectOpenHashMap regions = new Long2ObjectOpenHashMap<>(128, 0.5f); -+ protected final Long2ObjectMap regions = Long2ObjectMaps.synchronize(new Long2ObjectOpenHashMap<>(128, 0.5f)); - - private final int minSection; // inclusive - private final int maxSection; // inclusive - private final LevelCallback worldCallback; - - private final StampedLock entityByLock = new StampedLock(); -- private final Int2ReferenceOpenHashMap entityById = new Int2ReferenceOpenHashMap<>(); -- private final Object2ReferenceOpenHashMap entityByUUID = new Object2ReferenceOpenHashMap<>(); -+ private final Map entityById = Int2ReferenceMaps.synchronize(new Int2ReferenceOpenHashMap<>()); -+ private final Object2ReferenceMap entityByUUID = Object2ReferenceMaps.synchronize(new Object2ReferenceOpenHashMap<>()); - private final EntityList accessibleEntities = new EntityList(); - - public EntityLookup(final ServerLevel world, final LevelCallback worldCallback) { -@@ -208,8 +211,8 @@ public final class EntityLookup implements LevelEntityGetter { - public void get(final AABB box, final Consumer action) { - List entities = new ArrayList<>(); - this.getEntitiesWithoutDragonParts(null, box, entities, null); -- for (int i = 0, len = entities.size(); i < len; ++i) { -- action.accept(entities.get(i)); -+ for (Entity entity : entities) { -+ action.accept(entity); - } - } - -@@ -217,8 +220,8 @@ public final class EntityLookup implements LevelEntityGetter { - public void get(final EntityTypeTest filter, final AABB box, final AbortableIterationConsumer action) { - List entities = new ArrayList<>(); - this.getEntitiesWithoutDragonParts(null, box, entities, null); -- for (int i = 0, len = entities.size(); i < len; ++i) { -- final U casted = filter.tryCast(entities.get(i)); -+ for (Entity entity : entities) { -+ final U casted = filter.tryCast(entity); - if (casted != null && action.accept(casted).shouldAbort()) { - break; - } -@@ -231,14 +234,14 @@ public final class EntityLookup implements LevelEntityGetter { - - if (entity.updatingSectionStatus) { - // recursive status update -- LOGGER.error("Cannot recursively update entity chunk status for entity " + entity, new Throwable()); -+ LOGGER.warn("Cannot recursively update entity chunk status for entity " + entity); - return; - } - - final boolean entityStatusUpdateBefore = slices == null ? false : slices.startPreventingStatusUpdates(); - - if (entityStatusUpdateBefore) { -- LOGGER.error("Cannot update chunk status for entity " + entity + " since entity chunk (" + slices.chunkX + "," + slices.chunkZ + ") is receiving update", new Throwable()); -+ LOGGER.warn("Cannot update chunk status for entity " + entity + " since entity chunk (" + slices.chunkX + "," + slices.chunkZ + ") is receiving update"); - return; - } - -@@ -347,7 +350,7 @@ public final class EntityLookup implements LevelEntityGetter { - } - - if (entity.updatingSectionStatus) { -- LOGGER.warn("Entity " + entity + " is currently prevented from being added/removed to world since it is processing section status updates", new Throwable()); -+ LOGGER.warn("Entity " + entity + " is currently prevented from being added/removed to world since it is processing section status updates"); - return false; - } - -diff --git a/src/main/java/io/papermc/paper/util/CachedLists.java b/src/main/java/io/papermc/paper/util/CachedLists.java -index e08f4e39db4ee3fed62e37364d17dcc5c5683504..22a5470862acfa470c9acd97c96fea29aede0b68 100644 ---- a/src/main/java/io/papermc/paper/util/CachedLists.java -+++ b/src/main/java/io/papermc/paper/util/CachedLists.java -@@ -1,5 +1,6 @@ - package io.papermc.paper.util; - -+import com.google.common.collect.Lists; - import net.minecraft.world.entity.Entity; - import net.minecraft.world.phys.AABB; - import org.bukkit.Bukkit; -@@ -8,50 +9,18 @@ import java.util.List; - - public final class CachedLists { - -- // Paper start - optimise collisions -- static final UnsafeList TEMP_COLLISION_LIST = new UnsafeList<>(1024); -- static boolean tempCollisionListInUse; -- -- public static UnsafeList getTempCollisionList() { -- if (!Bukkit.isPrimaryThread() || tempCollisionListInUse) { -- return new UnsafeList<>(16); -- } -- tempCollisionListInUse = true; -- return TEMP_COLLISION_LIST; -- } -- -- public static void returnTempCollisionList(List list) { -- if (list != TEMP_COLLISION_LIST) { -- return; -- } -- ((UnsafeList)list).setSize(0); -- tempCollisionListInUse = false; -+ public static List getTempCollisionList() { -+ return Lists.newCopyOnWriteArrayList(); - } - -- static final UnsafeList TEMP_GET_ENTITIES_LIST = new UnsafeList<>(1024); -- static boolean tempGetEntitiesListInUse; -+ public static void returnTempCollisionList(List list) {} - -- public static UnsafeList getTempGetEntitiesList() { -- if (!Bukkit.isPrimaryThread() || tempGetEntitiesListInUse) { -- return new UnsafeList<>(16); -- } -- tempGetEntitiesListInUse = true; -- return TEMP_GET_ENTITIES_LIST; -+ public static List getTempGetEntitiesList() { -+ return Lists.newCopyOnWriteArrayList(); - } - -- public static void returnTempGetEntitiesList(List list) { -- if (list != TEMP_GET_ENTITIES_LIST) { -- return; -- } -- ((UnsafeList)list).setSize(0); -- tempGetEntitiesListInUse = false; -- } -+ public static void returnTempGetEntitiesList(List list) {} - // Paper end - optimise collisions - -- public static void reset() { -- // Paper start - optimise collisions -- TEMP_COLLISION_LIST.completeReset(); -- TEMP_GET_ENTITIES_LIST.completeReset(); -- // Paper end - optimise collisions -- } -+ public static void reset() {} - } -diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 3b7e4b724e86518ea57f5ed5ef0b8b3741d10f6f..9601de5775667c2d94e07b89bb7605b1e03d413d 100644 ---- a/src/main/java/net/minecraft/server/MinecraftServer.java -+++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -1,5 +1,7 @@ - package net.minecraft.server; - -+import co.m2ek4u.aoame.AnotherTickThread; -+import co.m2ek4u.aoame.CallbackExecutor; - import com.google.common.base.Splitter; - import com.google.common.collect.ImmutableList; - import co.aikar.timings.Timings; -@@ -41,9 +43,8 @@ import java.util.Map.Entry; - import java.util.Objects; - import java.util.Optional; - import java.util.Set; --import java.util.concurrent.CompletableFuture; --import java.util.concurrent.Executor; --import java.util.concurrent.RejectedExecutionException; -+import java.util.concurrent.*; -+import java.util.concurrent.atomic.AtomicInteger; - import java.util.concurrent.atomic.AtomicReference; - import java.util.function.BooleanSupplier; - import java.util.function.Consumer; -@@ -284,6 +285,20 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop(), -+ task -> { -+ AnotherTickThread worker = new AnotherTickThread(task,"Entity-Async-Worker # "+threadId.getAndIncrement()); -+ worker.setDaemon(true); -+ return worker; -+ } -+ ); -+ - // CraftBukkit start - public final WorldLoader.DataLoadContext worldLoader; - public org.bukkit.craftbukkit.CraftServer server; -@@ -1333,17 +1348,12 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop= 5000000000L) { - this.lastServerStatus = i; -@@ -1522,11 +1536,9 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 0; // Paper -- worldserver.hasEntityMoveEvent = io.papermc.paper.event.entity.EntityMoveEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper -+ for (ServerLevel worldserver : this.getAllLevels()) { -+ worldserver.hasPhysicsEvent = org.bukkit.event.block.BlockPhysicsEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper -+ worldserver.hasEntityMoveEvent = io.papermc.paper.event.entity.EntityMoveEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - net.minecraft.world.level.block.entity.HopperBlockEntity.skipHopperEvents = worldserver.paperConfig().hopper.disableMoveEvent || org.bukkit.event.inventory.InventoryMoveItemEvent.getHandlerList().getRegisteredListeners().length == 0; // Paper - - /*this.profiler.push(() -> { // Purpur -@@ -1557,7 +1569,9 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop> onLoad) { -- if (Thread.currentThread() != this.thread) { -+ if (Thread.currentThread() != this.thread && !(Thread.currentThread() instanceof AnotherTickThread)) { - this.getChunkSource().mainThreadProcessor.execute(() -> { - this.loadChunksForMoveAsync(axisalignedbb, priority, onLoad); - }); -diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index 40dbf933504a46aa358ca4280c578fabf0651315..619730e2013b4c8907ba7b7e6927b57b4ac76ec7 100644 ---- a/src/main/java/net/minecraft/world/entity/LivingEntity.java -+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -44,6 +44,7 @@ import net.minecraft.network.syncher.EntityDataAccessor; - import net.minecraft.network.syncher.EntityDataSerializers; - import net.minecraft.network.syncher.SynchedEntityData; - import net.minecraft.resources.ResourceLocation; -+import net.minecraft.server.MinecraftServer; - import net.minecraft.server.level.ServerChunkCache; - import net.minecraft.server.level.ServerLevel; - import net.minecraft.server.level.ServerPlayer; -@@ -3420,51 +3421,102 @@ public abstract class LivingEntity extends Entity { - this.updateFallFlying(); - AABB axisalignedbb = this.getBoundingBox(); - -- // SpigotTimings.timerEntityAIMove.startTiming(); // Spigot // Paper -- this.travel(new Vec3((double) this.xxa, (double) this.yya, (double) this.zza)); -- // SpigotTimings.timerEntityAIMove.stopTiming(); // Spigot // Paper -- //this.level.getProfiler().pop(); // Purpur -- //this.level.getProfiler().push("freezing"); // Purpur -- boolean flag1 = this.getType().is(EntityTypeTags.FREEZE_HURTS_EXTRA_TYPES); -- int i; -+ if (this instanceof net.minecraft.world.entity.player.Player) { -+ // SpigotTimings.timerEntityAIMove.startTiming(); // Spigot // Paper -+ this.travel(new Vec3((double) this.xxa, (double) this.yya, (double) this.zza)); -+ // SpigotTimings.timerEntityAIMove.stopTiming(); // Spigot // Paper -+ //this.level.getProfiler().pop(); // Purpur -+ //this.level.getProfiler().push("freezing"); // Purpur -+ boolean flag1 = this.getType().is(EntityTypeTags.FREEZE_HURTS_EXTRA_TYPES); -+ int i; - -- if (!this.level.isClientSide && !this.isDeadOrDying() && !freezeLocked) { // Paper - Freeze Tick Lock API -- i = this.getTicksFrozen(); -- if (this.isInPowderSnow && this.canFreeze()) { -- this.setTicksFrozen(Math.min(this.getTicksRequiredToFreeze(), i + 1)); -- } else { -- this.setTicksFrozen(Math.max(0, i - 2)); -+ if (!this.level.isClientSide && !this.isDeadOrDying() && !freezeLocked) { // Paper - Freeze Tick Lock API -+ i = this.getTicksFrozen(); -+ if (this.isInPowderSnow && this.canFreeze()) { -+ this.setTicksFrozen(Math.min(this.getTicksRequiredToFreeze(), i + 1)); -+ } else { -+ this.setTicksFrozen(Math.max(0, i - 2)); -+ } - } -- } - -- this.removeFrost(); -- this.tryAddFrost(); -- if (!this.level.isClientSide && this.tickCount % 40 == 0 && this.isFullyFrozen() && this.canFreeze()) { -- i = flag1 ? 5 : 1; -- this.hurt(DamageSource.FREEZE, (float) i); -- } -+ this.removeFrost(); -+ this.tryAddFrost(); -+ if (!this.level.isClientSide && this.tickCount % 40 == 0 && this.isFullyFrozen() && this.canFreeze()) { -+ i = flag1 ? 5 : 1; -+ this.hurt(DamageSource.FREEZE, (float) i); -+ } - -- //this.level.getProfiler().pop(); // Purpur -- //this.level.getProfiler().push("push"); // Purpur -- if (this.autoSpinAttackTicks > 0) { -- --this.autoSpinAttackTicks; -- this.checkAutoSpinAttack(axisalignedbb, this.getBoundingBox()); -- } -+ //this.level.getProfiler().pop(); // Purpur -+ //this.level.getProfiler().push("push"); // Purpur -+ if (this.autoSpinAttackTicks > 0) { -+ --this.autoSpinAttackTicks; -+ this.checkAutoSpinAttack(axisalignedbb, this.getBoundingBox()); -+ } - -- this.pushEntities(); -- //this.level.getProfiler().pop(); // Purpur -- // Paper start -- if (((ServerLevel) this.level).hasEntityMoveEvent && !(this instanceof net.minecraft.world.entity.player.Player)) { -- if (this.xo != getX() || this.yo != this.getY() || this.zo != this.getZ() || this.yRotO != this.getYRot() || this.xRotO != this.getXRot()) { -- Location from = new Location(this.level.getWorld(), this.xo, this.yo, this.zo, this.yRotO, this.xRotO); -- Location to = new Location (this.level.getWorld(), this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot()); -- io.papermc.paper.event.entity.EntityMoveEvent event = new io.papermc.paper.event.entity.EntityMoveEvent(this.getBukkitLivingEntity(), from, to.clone()); -- if (!event.callEvent()) { -- absMoveTo(from.getX(), from.getY(), from.getZ(), from.getYaw(), from.getPitch()); -- } else if (!to.equals(event.getTo())) { -- absMoveTo(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ(), event.getTo().getYaw(), event.getTo().getPitch()); -+ this.pushEntities(); -+ //this.level.getProfiler().pop(); // Purpur -+ // Paper start -+ if (((ServerLevel) this.level).hasEntityMoveEvent && !(this instanceof net.minecraft.world.entity.player.Player)) { -+ if (this.xo != getX() || this.yo != this.getY() || this.zo != this.getZ() || this.yRotO != this.getYRot() || this.xRotO != this.getXRot()) { -+ Location from = new Location(this.level.getWorld(), this.xo, this.yo, this.zo, this.yRotO, this.xRotO); -+ Location to = new Location(this.level.getWorld(), this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot()); -+ io.papermc.paper.event.entity.EntityMoveEvent event = new io.papermc.paper.event.entity.EntityMoveEvent(this.getBukkitLivingEntity(), from, to.clone()); -+ if (!event.callEvent()) { -+ absMoveTo(from.getX(), from.getY(), from.getZ(), from.getYaw(), from.getPitch()); -+ } else if (!to.equals(event.getTo())) { -+ absMoveTo(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ(), event.getTo().getYaw(), event.getTo().getPitch()); -+ } - } - } -+ } else { -+ MinecraftServer.getServer().asyncExecutor.executeWithCallBack(() -> { -+ // SpigotTimings.timerEntityAIMove.startTiming(); // Spigot // Paper -+ this.travel(new Vec3((double) this.xxa, (double) this.yya, (double) this.zza)); -+ // SpigotTimings.timerEntityAIMove.stopTiming(); // Spigot // Paper -+ //this.level.getProfiler().pop(); // Purpur -+ //this.level.getProfiler().push("freezing"); // Purpur -+ boolean flag1 = this.getType().is(EntityTypeTags.FREEZE_HURTS_EXTRA_TYPES); -+ int i; -+ -+ if (!this.level.isClientSide && !this.isDeadOrDying() && !freezeLocked) { // Paper - Freeze Tick Lock API -+ i = this.getTicksFrozen(); -+ if (this.isInPowderSnow && this.canFreeze()) { -+ this.setTicksFrozen(Math.min(this.getTicksRequiredToFreeze(), i + 1)); -+ } else { -+ this.setTicksFrozen(Math.max(0, i - 2)); -+ } -+ } -+ -+ this.removeFrost(); -+ this.tryAddFrost(); -+ if (!this.level.isClientSide && this.tickCount % 40 == 0 && this.isFullyFrozen() && this.canFreeze()) { -+ i = flag1 ? 5 : 1; -+ this.hurt(DamageSource.FREEZE, (float) i); -+ } -+ -+ //this.level.getProfiler().pop(); // Purpur -+ //this.level.getProfiler().push("push"); // Purpur -+ if (this.autoSpinAttackTicks > 0) { -+ --this.autoSpinAttackTicks; -+ this.checkAutoSpinAttack(axisalignedbb, this.getBoundingBox()); -+ } -+ -+ this.pushEntities(); -+ //this.level.getProfiler().pop(); // Purpur -+ }, () -> { -+ if (((ServerLevel) this.level).hasEntityMoveEvent && !(this instanceof net.minecraft.world.entity.player.Player)) { -+ if (this.xo != getX() || this.yo != this.getY() || this.zo != this.getZ() || this.yRotO != this.getYRot() || this.xRotO != this.getXRot()) { -+ Location from = new Location(this.level.getWorld(), this.xo, this.yo, this.zo, this.yRotO, this.xRotO); -+ Location to = new Location(this.level.getWorld(), this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot()); -+ io.papermc.paper.event.entity.EntityMoveEvent event = new io.papermc.paper.event.entity.EntityMoveEvent(this.getBukkitLivingEntity(), from, to.clone()); -+ if (!event.callEvent()) { -+ absMoveTo(from.getX(), from.getY(), from.getZ(), from.getYaw(), from.getPitch()); -+ } else if (!to.equals(event.getTo())) { -+ absMoveTo(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ(), event.getTo().getYaw(), event.getTo().getPitch()); -+ } -+ } -+ } -+ }); - } - // Paper end - if (!this.level.isClientSide && this.isSensitiveToWater() && this.isInWaterRainOrBubble()) { -diff --git a/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiSection.java b/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiSection.java -index 9f138bc471b5c2a4fa813ff943dbe34018b8df74..5c8a90f8536c9291df5891d8c75de963b75ec4bd 100644 ---- a/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiSection.java -+++ b/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiSection.java -@@ -7,6 +7,7 @@ import com.mojang.logging.LogUtils; - import com.mojang.serialization.Codec; - import com.mojang.serialization.codecs.RecordCodecBuilder; - import it.unimi.dsi.fastutil.shorts.Short2ObjectMap; -+import it.unimi.dsi.fastutil.shorts.Short2ObjectMaps; - import it.unimi.dsi.fastutil.shorts.Short2ObjectOpenHashMap; - import java.util.List; - import java.util.Map; -@@ -25,8 +26,9 @@ import org.slf4j.Logger; - - public class PoiSection { - private static final Logger LOGGER = LogUtils.getLogger(); -- private final Short2ObjectMap records = new Short2ObjectOpenHashMap<>(); -- private final Map, Set> byType = Maps.newHashMap(); public final Map, Set> getData() { return this.byType; } // Paper - public accessor -+ private final Short2ObjectMap records = Short2ObjectMaps.synchronize(new Short2ObjectOpenHashMap<>()); -+ private final Map, Set> byType = Maps.newConcurrentMap(); -+ public final Map, Set> getData() { return this.byType; } // Paper - public accessor - private final Runnable setDirty; - private boolean isValid; - public final Optional noAllocateOptional = Optional.of(this); // Paper - rewrite chunk system -diff --git a/src/main/java/net/minecraft/world/level/levelgen/LegacyRandomSource.java b/src/main/java/net/minecraft/world/level/levelgen/LegacyRandomSource.java -index daa03360dd7044f10b20f36023b305dc7e0bb7df..f11cf0c0701247692075da2f2db7602e72ef1ec8 100644 ---- a/src/main/java/net/minecraft/world/level/levelgen/LegacyRandomSource.java -+++ b/src/main/java/net/minecraft/world/level/levelgen/LegacyRandomSource.java -@@ -19,17 +19,17 @@ public class LegacyRandomSource implements BitRandomSource { - } - - @Override -- public RandomSource fork() { -+ public synchronized RandomSource fork() { - return new LegacyRandomSource(this.nextLong()); - } - - @Override -- public PositionalRandomFactory forkPositional() { -+ public synchronized PositionalRandomFactory forkPositional() { - return new LegacyRandomSource.LegacyPositionalRandomFactory(this.nextLong()); - } - - @Override -- public void setSeed(long seed) { -+ public synchronized void setSeed(long seed) { - if (!this.seed.compareAndSet(this.seed.get(), (seed ^ 25214903917L) & 281474976710655L)) { - throw ThreadingDetector.makeThreadingException("LegacyRandomSource", (Thread)null); - } else { -@@ -38,7 +38,7 @@ public class LegacyRandomSource implements BitRandomSource { - } - - @Override -- public int next(int bits) { -+ public synchronized int next(int bits) { - long l = this.seed.get(); - long m = l * 25214903917L + 11L & 281474976710655L; - if (!this.seed.compareAndSet(l, m)) { -@@ -49,7 +49,7 @@ public class LegacyRandomSource implements BitRandomSource { - } - - @Override -- public double nextGaussian() { -+ public synchronized double nextGaussian() { - return this.gaussianSource.nextGaussian(); - } - diff --git a/patches/server/0042-MikuServer-Async-entity-ai.patch b/patches/server/0042-MikuServer-Async-entity-ai.patch deleted file mode 100644 index f73e3fac..00000000 --- a/patches/server/0042-MikuServer-Async-entity-ai.patch +++ /dev/null @@ -1,620 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: wangxyper -Date: Fri, 27 Jan 2023 19:43:43 +0800 -Subject: [PATCH] MikuServer: Async entity ai - -Original license: MIT -Original project: https://github.com/MikuMC/MikuServer - -diff --git a/src/main/java/io/papermc/paper/util/maplist/IteratorSafeOrderedReferenceSet.java b/src/main/java/io/papermc/paper/util/maplist/IteratorSafeOrderedReferenceSet.java -index 0fd814f1d65c111266a2b20f86561839a4cef755..fe4d76875462ac9d408c972b968647af78f2ed14 100644 ---- a/src/main/java/io/papermc/paper/util/maplist/IteratorSafeOrderedReferenceSet.java -+++ b/src/main/java/io/papermc/paper/util/maplist/IteratorSafeOrderedReferenceSet.java -@@ -94,7 +94,7 @@ public final class IteratorSafeOrderedReferenceSet { - return 1.0 - ((double)this.indexMap.size() / (double)this.listSize); - } - -- public int createRawIterator() { -+ public synchronized int createRawIterator() { - if (this.allowSafeIteration()) { - ++this.iteratorCount; - } -@@ -105,7 +105,7 @@ public final class IteratorSafeOrderedReferenceSet { - } - } - -- public int advanceRawIterator(final int index) { -+ public synchronized int advanceRawIterator(final int index) { - final E[] elements = this.listElements; - int ret = index + 1; - for (int len = this.listSize; ret < len; ++ret) { -@@ -117,7 +117,7 @@ public final class IteratorSafeOrderedReferenceSet { - return -1; - } - -- public void finishRawIterator() { -+ public synchronized void finishRawIterator() { - if (this.allowSafeIteration() && --this.iteratorCount == 0) { - if (this.getFragFactor() >= this.maxFragFactor) { - this.defrag(); -@@ -125,7 +125,7 @@ public final class IteratorSafeOrderedReferenceSet { - } - } - -- public boolean remove(final E element) { -+ public synchronized boolean remove(final E element) { - final int index = this.indexMap.removeInt(element); - if (index >= 0) { - if (this.firstInvalidIndex < 0 || index < this.firstInvalidIndex) { -@@ -144,11 +144,11 @@ public final class IteratorSafeOrderedReferenceSet { - return false; - } - -- public boolean contains(final E element) { -+ public synchronized boolean contains(final E element) { - return this.indexMap.containsKey(element); - } - -- public boolean add(final E element) { -+ public synchronized boolean add(final E element) { - final int listSize = this.listSize; - - final int previous = this.indexMap.putIfAbsent(element, listSize); -@@ -223,30 +223,30 @@ public final class IteratorSafeOrderedReferenceSet { - //this.check(); - } - -- public E rawGet(final int index) { -+ public synchronized E rawGet(final int index) { - return this.listElements[index]; - } - -- public int size() { -+ public synchronized int size() { - // always returns the correct amount - listSize can be different - return this.indexMap.size(); - } - -- public IteratorSafeOrderedReferenceSet.Iterator iterator() { -+ public synchronized IteratorSafeOrderedReferenceSet.Iterator iterator() { - return this.iterator(0); - } - -- public IteratorSafeOrderedReferenceSet.Iterator iterator(final int flags) { -+ public synchronized IteratorSafeOrderedReferenceSet.Iterator iterator(final int flags) { - if (this.allowSafeIteration()) { - ++this.iteratorCount; - } - return new BaseIterator<>(this, true, (flags & ITERATOR_FLAG_SEE_ADDITIONS) != 0 ? Integer.MAX_VALUE : this.listSize); - } - -- public java.util.Iterator unsafeIterator() { -+ public synchronized java.util.Iterator unsafeIterator() { - return this.unsafeIterator(0); - } -- public java.util.Iterator unsafeIterator(final int flags) { -+ public synchronized java.util.Iterator unsafeIterator(final int flags) { - return new BaseIterator<>(this, false, (flags & ITERATOR_FLAG_SEE_ADDITIONS) != 0 ? Integer.MAX_VALUE : this.listSize); - } - -@@ -273,7 +273,7 @@ public final class IteratorSafeOrderedReferenceSet { - } - - @Override -- public boolean hasNext() { -+ public synchronized boolean hasNext() { - if (this.finished) { - return false; - } -@@ -297,7 +297,7 @@ public final class IteratorSafeOrderedReferenceSet { - } - - @Override -- public E next() { -+ public synchronized E next() { - if (!this.hasNext()) { - throw new NoSuchElementException(); - } -@@ -310,7 +310,7 @@ public final class IteratorSafeOrderedReferenceSet { - } - - @Override -- public void remove() { -+ public synchronized void remove() { - final E lastReturned = this.lastReturned; - if (lastReturned == null) { - throw new IllegalStateException(); -@@ -320,7 +320,7 @@ public final class IteratorSafeOrderedReferenceSet { - } - - @Override -- public void finishedIterating() { -+ public synchronized void finishedIterating() { - if (this.finished || !this.canFinish) { - throw new IllegalStateException(); - } -diff --git a/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java b/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java -index f597d65d56964297eeeed6c7e77703764178fee0..b3bcafc8bafe1e4a1a2b690499b91e5316a604f1 100644 ---- a/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java -+++ b/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java -@@ -4,6 +4,7 @@ import com.destroystokyo.paper.util.maplist.EntityList; - import io.papermc.paper.chunk.system.entity.EntityLookup; - import io.papermc.paper.util.TickThread; - import it.unimi.dsi.fastutil.objects.Reference2ObjectMap; -+import it.unimi.dsi.fastutil.objects.Reference2ObjectMaps; - import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap; - import net.minecraft.nbt.CompoundTag; - import net.minecraft.server.level.ChunkHolder; -@@ -34,7 +35,7 @@ public final class ChunkEntitySlices { - - protected final EntityCollectionBySection allEntities; - protected final EntityCollectionBySection hardCollidingEntities; -- protected final Reference2ObjectOpenHashMap, EntityCollectionBySection> entitiesByClass; -+ protected final Reference2ObjectMap, EntityCollectionBySection> entitiesByClass; - protected final EntityList entities = new EntityList(); - - public ChunkHolder.FullChunkStatus status; -@@ -61,7 +62,7 @@ public final class ChunkEntitySlices { - - this.allEntities = new EntityCollectionBySection(this); - this.hardCollidingEntities = new EntityCollectionBySection(this); -- this.entitiesByClass = new Reference2ObjectOpenHashMap<>(); -+ this.entitiesByClass = Reference2ObjectMaps.synchronize(new Reference2ObjectOpenHashMap<>()); - - this.status = status; - } -@@ -209,7 +210,7 @@ public final class ChunkEntitySlices { - } - - for (final Iterator, EntityCollectionBySection>> iterator = -- this.entitiesByClass.reference2ObjectEntrySet().fastIterator(); iterator.hasNext();) { -+ this.entitiesByClass.reference2ObjectEntrySet().iterator(); iterator.hasNext();) { - final Reference2ObjectMap.Entry, EntityCollectionBySection> entry = iterator.next(); - - if (entry.getKey().isInstance(entity)) { -@@ -234,7 +235,7 @@ public final class ChunkEntitySlices { - } - - for (final Iterator, EntityCollectionBySection>> iterator = -- this.entitiesByClass.reference2ObjectEntrySet().fastIterator(); iterator.hasNext();) { -+ this.entitiesByClass.reference2ObjectEntrySet().iterator(); iterator.hasNext();) { - final Reference2ObjectMap.Entry, EntityCollectionBySection> entry = iterator.next(); - - if (entry.getKey().isInstance(entity)) { -@@ -312,11 +313,11 @@ public final class ChunkEntitySlices { - this.storage = (E[])(cap <= 0 ? EMPTY : new Entity[cap]); - } - -- public boolean isEmpty() { -+ public synchronized boolean isEmpty() { - return this.size == 0; - } - -- public int size() { -+ public synchronized int size() { - return this.size; - } - -@@ -328,7 +329,7 @@ public final class ChunkEntitySlices { - } - } - -- public void add(final E entity) { -+ public synchronized void add(final E entity) { - final int idx = this.size++; - if (idx >= this.storage.length) { - this.resize(); -@@ -338,7 +339,7 @@ public final class ChunkEntitySlices { - } - } - -- public int indexOf(final E entity) { -+ public synchronized int indexOf(final E entity) { - final E[] storage = this.storage; - - for (int i = 0, len = Math.min(this.storage.length, this.size); i < len; ++i) { -@@ -350,7 +351,7 @@ public final class ChunkEntitySlices { - return -1; - } - -- public boolean remove(final E entity) { -+ public synchronized boolean remove(final E entity) { - final int idx = this.indexOf(entity); - if (idx == -1) { - return false; -@@ -367,7 +368,7 @@ public final class ChunkEntitySlices { - return true; - } - -- public boolean has(final E entity) { -+ public synchronized boolean has(final E entity) { - return this.indexOf(entity) != -1; - } - } -@@ -388,7 +389,7 @@ public final class ChunkEntitySlices { - this.entitiesBySection = new BasicEntityList[sectionCount]; - } - -- public void addEntity(final Entity entity, final int sectionIndex) { -+ public synchronized void addEntity(final Entity entity, final int sectionIndex) { - BasicEntityList list = this.entitiesBySection[sectionIndex]; - - if (list != null && list.has(entity)) { -@@ -404,7 +405,7 @@ public final class ChunkEntitySlices { - ++this.count; - } - -- public void removeEntity(final Entity entity, final int sectionIndex) { -+ public synchronized void removeEntity(final Entity entity, final int sectionIndex) { - final BasicEntityList list = this.entitiesBySection[sectionIndex]; - - if (list == null || !list.remove(entity)) { -@@ -419,7 +420,7 @@ public final class ChunkEntitySlices { - } - } - -- public void getEntities(final Entity except, final AABB box, final List into, final Predicate predicate) { -+ public synchronized void getEntities(final Entity except, final AABB box, final List into, final Predicate predicate) { - if (this.count == 0) { - return; - } -@@ -457,7 +458,7 @@ public final class ChunkEntitySlices { - } - } - -- public void getEntitiesWithEnderDragonParts(final Entity except, final AABB box, final List into, -+ public synchronized void getEntitiesWithEnderDragonParts(final Entity except, final AABB box, final List into, - final Predicate predicate) { - if (this.count == 0) { - return; -@@ -508,7 +509,7 @@ public final class ChunkEntitySlices { - } - } - -- public void getEntitiesWithEnderDragonParts(final Entity except, final Class clazz, final AABB box, final List into, -+ public synchronized void getEntitiesWithEnderDragonParts(final Entity except, final Class clazz, final AABB box, final List into, - final Predicate predicate) { - if (this.count == 0) { - return; -@@ -559,7 +560,7 @@ public final class ChunkEntitySlices { - } - } - -- public void getEntities(final EntityType type, final AABB box, final List into, -+ public synchronized void getEntities(final EntityType type, final AABB box, final List into, - final Predicate predicate) { - if (this.count == 0) { - return; -diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java -index beb7c22cb63021f26c06f91050361e1b25fcc72d..07b2cd85956dda47ed0a026cd837c5b9498213ac 100644 ---- a/src/main/java/net/minecraft/server/level/ChunkMap.java -+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java -@@ -25,8 +25,8 @@ import it.unimi.dsi.fastutil.longs.Long2ObjectMap.Entry; - import it.unimi.dsi.fastutil.longs.LongIterator; - import it.unimi.dsi.fastutil.longs.LongOpenHashSet; - import it.unimi.dsi.fastutil.longs.LongSet; --import it.unimi.dsi.fastutil.objects.ObjectBidirectionalIterator; --import it.unimi.dsi.fastutil.objects.ObjectIterator; -+import it.unimi.dsi.fastutil.objects.*; -+ - import java.io.IOException; - import java.io.Writer; - import java.nio.file.Path; -@@ -52,6 +52,7 @@ import java.util.function.IntSupplier; - import java.util.function.Supplier; - import java.util.stream.Collectors; - import javax.annotation.Nullable; -+ - import net.minecraft.CrashReport; - import net.minecraft.CrashReportCategory; - import net.minecraft.ReportedException; -@@ -113,7 +114,6 @@ import org.bukkit.craftbukkit.generator.CustomChunkGenerator; - import org.bukkit.entity.Player; - // CraftBukkit end - --import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet; // Paper - - public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider { - -@@ -153,7 +153,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider - private final Queue unloadQueue; - int viewDistance; - public final com.destroystokyo.paper.util.misc.PlayerAreaMap playerMobDistanceMap; // Paper -- public final ReferenceOpenHashSet needsChangeBroadcasting = new ReferenceOpenHashSet<>(); -+ public final ReferenceSet needsChangeBroadcasting = ReferenceSets.synchronize(new ReferenceOpenHashSet<>()); - - // Paper - rewrite chunk system - // Paper start - optimise checkDespawn -diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index 0ae45cf5a084fd412305e8b2f5dabe608b4eb1c1..686852f5cb6303381c45a673a0daf79a2d3a9dfe 100644 ---- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java -+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -@@ -6,12 +6,7 @@ import com.mojang.datafixers.DataFixer; - import com.mojang.datafixers.util.Either; - import java.io.File; - import java.io.IOException; --import java.util.Arrays; --import java.util.Collections; --import java.util.Iterator; --import java.util.List; --import java.util.Objects; --import java.util.Optional; -+import java.util.*; - import java.util.concurrent.CompletableFuture; - import java.util.concurrent.Executor; - import java.util.function.BooleanSupplier; -@@ -803,7 +798,7 @@ public class ServerChunkCache extends ChunkSource { - //gameprofilerfiller.popPush("broadcast"); // Purpur - //this.level.timings.broadcastChunkUpdates.startTiming(); // Paper - timing // Purpur - if (!this.chunkMap.needsChangeBroadcasting.isEmpty()) { -- ReferenceOpenHashSet copy = this.chunkMap.needsChangeBroadcasting.clone(); -+ List copy = new ArrayList<>(this.chunkMap.needsChangeBroadcasting); - this.chunkMap.needsChangeBroadcasting.clear(); - for (ChunkHolder holder : copy) { - holder.broadcastChanges(holder.getFullChunkNowUnchecked()); // LevelChunks are NEVER unloaded -diff --git a/src/main/java/net/minecraft/util/ClassInstanceMultiMap.java b/src/main/java/net/minecraft/util/ClassInstanceMultiMap.java -index 50a9f33aa31e9273c7c52d4bb2b02f0f884f7ba5..b7cd7b4bb7a2fb58dd907428f7e03662ef5e5c29 100644 ---- a/src/main/java/net/minecraft/util/ClassInstanceMultiMap.java -+++ b/src/main/java/net/minecraft/util/ClassInstanceMultiMap.java -@@ -13,9 +13,9 @@ import java.util.Map; - import java.util.stream.Collectors; - - public class ClassInstanceMultiMap extends AbstractCollection { -- private final Map, List> byClass = Maps.newHashMap(); -+ private final Map, List> byClass = Maps.newConcurrentMap(); - private final Class baseClass; -- private final List allInstances = Lists.newArrayList(); -+ private final List allInstances = Lists.newCopyOnWriteArrayList(); - - public ClassInstanceMultiMap(Class elementType) { - this.baseClass = elementType; -@@ -23,7 +23,7 @@ public class ClassInstanceMultiMap extends AbstractCollection { - } - - @Override -- public boolean add(T object) { -+ public synchronized boolean add(T object) { - boolean bl = false; - - for(Map.Entry, List> entry : this.byClass.entrySet()) { -@@ -36,7 +36,7 @@ public class ClassInstanceMultiMap extends AbstractCollection { - } - - @Override -- public boolean remove(Object object) { -+ public synchronized boolean remove(Object object) { - boolean bl = false; - - for(Map.Entry, List> entry : this.byClass.entrySet()) { -@@ -50,32 +50,32 @@ public class ClassInstanceMultiMap extends AbstractCollection { - } - - @Override -- public boolean contains(Object object) { -+ public synchronized boolean contains(Object object) { - return this.find(object.getClass()).contains(object); - } - -- public Collection find(Class type) { -+ public synchronized Collection find(Class type) { - if (!this.baseClass.isAssignableFrom(type)) { - throw new IllegalArgumentException("Don't know how to search for " + type); - } else { - List list = this.byClass.computeIfAbsent(type, (typeClass) -> { - return this.allInstances.stream().filter(typeClass::isInstance).collect(Collectors.toList()); - }); -- return Collections.unmodifiableCollection(list); -+ return (Collection) Collections.unmodifiableCollection(list); - } - } - - @Override -- public Iterator iterator() { -+ public synchronized Iterator iterator() { - return (Iterator)(this.allInstances.isEmpty() ? Collections.emptyIterator() : Iterators.unmodifiableIterator(this.allInstances.iterator())); - } - -- public List getAllInstances() { -+ public synchronized List getAllInstances() { - return ImmutableList.copyOf(this.allInstances); - } - - @Override -- public int size() { -+ public synchronized int size() { - return this.allInstances.size(); - } - } -diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java -index 29fa9ad2223de668c15a5e5b433704b2c4765610..9071abd67c421a528514a6437a1b8dde02e068ed 100644 ---- a/src/main/java/net/minecraft/world/entity/Mob.java -+++ b/src/main/java/net/minecraft/world/entity/Mob.java -@@ -23,6 +23,7 @@ import net.minecraft.network.syncher.EntityDataAccessor; - import net.minecraft.network.syncher.EntityDataSerializers; - import net.minecraft.network.syncher.SynchedEntityData; - import net.minecraft.resources.ResourceLocation; -+import net.minecraft.server.MinecraftServer; - import net.minecraft.server.level.ServerLevel; - import net.minecraft.server.level.ServerPlayer; - import net.minecraft.sounds.SoundEvent; -@@ -216,12 +217,14 @@ public abstract class Mob extends LivingEntity { - public void inactiveTick() { - super.inactiveTick(); - boolean isThrottled = gg.pufferfish.pufferfish.PufferfishConfig.throttleInactiveGoalSelectorTick && _pufferfish_inactiveTickDisableCounter++ % 20 != 0; // Pufferfish - throttle inactive goal selector ticking -- if (this.goalSelector.inactiveTick(this.activatedPriority, true) && !isThrottled) { // Pufferfish - pass activated priroity // Pufferfish - throttle inactive goal selector ticking -- this.goalSelector.tick(); -- } -- if (this.targetSelector.inactiveTick(this.activatedPriority, true)) { // Pufferfish - pass activated priority -- this.targetSelector.tick(); -- } -+ MinecraftServer.getServer().asyncExecutor.executeWithCallBack(()->{ -+ if (this.goalSelector.inactiveTick(this.activatedPriority, true) && !isThrottled) { // Pufferfish - pass activated priroity // Pufferfish - throttle inactive goal selector ticking -+ this.goalSelector.tick(); -+ } -+ if (this.targetSelector.inactiveTick(this.activatedPriority, true)) { // Pufferfish - pass activated priority -+ this.targetSelector.tick(); -+ } -+ },()->{}); - } - // Paper end - -@@ -878,42 +881,43 @@ public abstract class Mob extends LivingEntity { - if (i % 10 == 0) this.sensing.tick(); // petal - only refresh line of sight cache every half second - //this.level.getProfiler().pop(); // Purpur - -- if (i % 2 != 0 && this.tickCount > 1) { -- //this.level.getProfiler().push("targetSelector"); // Purpur -- if (this.targetSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking -- this.targetSelector.tickRunningGoals(false); -+ MinecraftServer.getServer().asyncExecutor.executeWithCallBack(() -> { -+ if (i % 2 != 0 && this.tickCount > 1) { -+ //this.level.getProfiler().push("targetSelector"); // Purpur -+ if (this.targetSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking -+ this.targetSelector.tickRunningGoals(false); -+ //this.level.getProfiler().pop(); // Purpur -+ //this.level.getProfiler().push("goalSelector"); // Purpur -+ if (this.goalSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking -+ this.goalSelector.tickRunningGoals(false); -+ //this.level.getProfiler().pop(); // Purpur -+ } else { -+ //this.level.getProfiler().push("targetSelector"); // Purpur -+ if (this.targetSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking -+ this.targetSelector.tick(); -+ //this.level.getProfiler().pop(); // Purpur -+ //this.level.getProfiler().push("goalSelector"); // Purpur -+ if (this.goalSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking -+ this.goalSelector.tick(); -+ //this.level.getProfiler().pop(); // Purpur -+ } -+ -+ //this.level.getProfiler().push("navigation"); // Purpur -+ this.navigation.tick(); - //this.level.getProfiler().pop(); // Purpur -- //this.level.getProfiler().push("goalSelector"); // Purpur -- if (this.goalSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking -- this.goalSelector.tickRunningGoals(false); -+ //this.level.getProfiler().push("mob tick"); // Purpur -+ this.customServerAiStep(); - //this.level.getProfiler().pop(); // Purpur -- } else { -- //this.level.getProfiler().push("targetSelector"); // Purpur -- if (this.targetSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking -- this.targetSelector.tick(); -+ //this.level.getProfiler().push("controls"); // Purpur -+ //this.level.getProfiler().push("move"); // Purpur -+ this.moveControl.tick(); -+ //this.level.getProfiler().popPush("look"); // Purpur -+ this.lookControl.tick(); -+ //this.level.getProfiler().popPush("jump"); // Purpur -+ this.jumpControl.tick(); - //this.level.getProfiler().pop(); // Purpur -- //this.level.getProfiler().push("goalSelector"); // Purpur -- if (this.goalSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking -- this.goalSelector.tick(); - //this.level.getProfiler().pop(); // Purpur -- } -- -- //this.level.getProfiler().push("navigation"); // Purpur -- this.navigation.tick(); -- //this.level.getProfiler().pop(); // Purpur -- //this.level.getProfiler().push("mob tick"); // Purpur -- this.customServerAiStep(); -- //this.level.getProfiler().pop(); // Purpur -- //this.level.getProfiler().push("controls"); // Purpur -- //this.level.getProfiler().push("move"); // Purpur -- this.moveControl.tick(); -- //this.level.getProfiler().popPush("look"); // Purpur -- this.lookControl.tick(); -- //this.level.getProfiler().popPush("jump"); // Purpur -- this.jumpControl.tick(); -- //this.level.getProfiler().pop(); // Purpur -- //this.level.getProfiler().pop(); // Purpur -- this.sendDebugPackets(); -+ }, this::sendDebugPackets); - } - - protected void sendDebugPackets() { -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 2d222e383d48a1a32eebdb722d770b4fc6c0aca7..eb5257fabef397566e784247922fb27e61f96313 100644 ---- a/src/main/java/net/minecraft/world/entity/npc/Villager.java -+++ b/src/main/java/net/minecraft/world/entity/npc/Villager.java -@@ -274,16 +274,18 @@ public class Villager extends AbstractVillager implements ReputationEventHandler - if (this.getUnhappyCounter() > 0) { - this.setUnhappyCounter(this.getUnhappyCounter() - 1); - } -- if (this.isEffectiveAi()) { -- if (level.spigotConfig.tickInactiveVillagers) { -- this.customServerAiStep(); -- } else { -- this.mobTick(true); -+ MinecraftServer.getServer().asyncExecutor.executeWithCallBack(()->{ -+ if (this.isEffectiveAi()) { -+ if (level.spigotConfig.tickInactiveVillagers) { -+ this.customServerAiStep(); -+ } else { -+ this.mobTick(true); -+ } - } -- } -- maybeDecayGossip(); -+ },()->{ -+ maybeDecayGossip(); -+ }); - // Paper end -- - super.inactiveTick(); - } - // Spigot End -diff --git a/src/main/java/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java b/src/main/java/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java -index b1c594dc6a6b8a6c737b99272acab9e7dbd0ed63..4aedee56077159aaf613033b688d2be6833f1ad1 100644 ---- a/src/main/java/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java -+++ b/src/main/java/net/minecraft/world/level/redstone/CollectingNeighborUpdater.java -@@ -3,7 +3,10 @@ package net.minecraft.world.level.redstone; - import com.mojang.logging.LogUtils; - import java.util.ArrayDeque; - import java.util.ArrayList; -+import java.util.Deque; - import java.util.List; -+import java.util.concurrent.ConcurrentLinkedDeque; -+import java.util.concurrent.CopyOnWriteArrayList; - import javax.annotation.Nullable; - import net.minecraft.core.BlockPos; - import net.minecraft.core.Direction; -@@ -16,8 +19,8 @@ public class CollectingNeighborUpdater implements NeighborUpdater { - private static final Logger LOGGER = LogUtils.getLogger(); - private final Level level; - private final int maxChainedNeighborUpdates; -- private final ArrayDeque stack = new ArrayDeque<>(); -- private final List addedThisLayer = new ArrayList<>(); -+ private final Deque stack = new ConcurrentLinkedDeque<>(); -+ private final List addedThisLayer = new CopyOnWriteArrayList<>(); - private int count = 0; - - public CollectingNeighborUpdater(Level world, int maxChainDepth) { -@@ -26,22 +29,22 @@ public class CollectingNeighborUpdater implements NeighborUpdater { - } - - @Override -- public void shapeUpdate(Direction direction, BlockState neighborState, BlockPos pos, BlockPos neighborPos, int flags, int maxUpdateDepth) { -+ public synchronized void shapeUpdate(Direction direction, BlockState neighborState, BlockPos pos, BlockPos neighborPos, int flags, int maxUpdateDepth) { - this.addAndRun(pos, new CollectingNeighborUpdater.ShapeUpdate(direction, neighborState, pos.immutable(), neighborPos.immutable(), flags)); - } - - @Override -- public void neighborChanged(BlockPos pos, Block sourceBlock, BlockPos sourcePos) { -+ public synchronized void neighborChanged(BlockPos pos, Block sourceBlock, BlockPos sourcePos) { - this.addAndRun(pos, new CollectingNeighborUpdater.SimpleNeighborUpdate(pos, sourceBlock, sourcePos.immutable())); - } - - @Override -- public void neighborChanged(BlockState state, BlockPos pos, Block sourceBlock, BlockPos sourcePos, boolean notify) { -+ public synchronized void neighborChanged(BlockState state, BlockPos pos, Block sourceBlock, BlockPos sourcePos, boolean notify) { - this.addAndRun(pos, new CollectingNeighborUpdater.FullNeighborUpdate(state, pos.immutable(), sourceBlock, sourcePos.immutable(), notify)); - } - - @Override -- public void updateNeighborsAtExceptFromFacing(BlockPos pos, Block sourceBlock, @Nullable Direction except) { -+ public synchronized void updateNeighborsAtExceptFromFacing(BlockPos pos, Block sourceBlock, @Nullable Direction except) { - this.addAndRun(pos, new CollectingNeighborUpdater.MultiNeighborUpdate(pos.immutable(), sourceBlock, except)); - } - diff --git a/patches/server/0043-MikuServer-Concurrent-problems-fixes.patch b/patches/server/0043-MikuServer-Concurrent-problems-fixes.patch deleted file mode 100644 index 5ead6253..00000000 --- a/patches/server/0043-MikuServer-Concurrent-problems-fixes.patch +++ /dev/null @@ -1,1291 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: wangxyper -Date: Fri, 27 Jan 2023 19:52:49 +0800 -Subject: [PATCH] MikuServer: Concurrent problems fixes - -Original license: MIT -Original project: https://github.com/MikuMC/MikuServer - -diff --git a/src/main/java/io/papermc/paper/chunk/PlayerChunkLoader.java b/src/main/java/io/papermc/paper/chunk/PlayerChunkLoader.java -index 0b060183429f4c72ec767075538477b4302bbf0d..23c32a06dce8f0c45647c3619c98ba95290cfa7d 100644 ---- a/src/main/java/io/papermc/paper/chunk/PlayerChunkLoader.java -+++ b/src/main/java/io/papermc/paper/chunk/PlayerChunkLoader.java -@@ -7,9 +7,9 @@ import io.papermc.paper.util.CoordinateUtils; - import io.papermc.paper.util.IntervalledCounter; - import io.papermc.paper.util.TickThread; - import it.unimi.dsi.fastutil.longs.LongOpenHashSet; --import it.unimi.dsi.fastutil.objects.Reference2IntOpenHashMap; --import it.unimi.dsi.fastutil.objects.Reference2ObjectLinkedOpenHashMap; --import it.unimi.dsi.fastutil.objects.ReferenceLinkedOpenHashSet; -+import it.unimi.dsi.fastutil.longs.LongSet; -+import it.unimi.dsi.fastutil.longs.LongSets; -+import it.unimi.dsi.fastutil.objects.*; - import net.minecraft.network.protocol.game.ClientboundSetChunkCacheCenterPacket; - import net.minecraft.network.protocol.game.ClientboundSetChunkCacheRadiusPacket; - import net.minecraft.network.protocol.game.ClientboundSetSimulationDistancePacket; -@@ -22,10 +22,10 @@ import net.minecraft.world.level.chunk.LevelChunk; - import org.apache.commons.lang3.mutable.MutableObject; - import org.bukkit.craftbukkit.entity.CraftPlayer; - import org.bukkit.entity.Player; --import java.util.ArrayDeque; --import java.util.ArrayList; --import java.util.List; --import java.util.TreeSet; -+ -+import java.util.*; -+import java.util.concurrent.ConcurrentLinkedDeque; -+import java.util.concurrent.ConcurrentSkipListSet; - import java.util.concurrent.atomic.AtomicInteger; - - public final class PlayerChunkLoader { -@@ -76,10 +76,10 @@ public final class PlayerChunkLoader { - } - - protected final ChunkMap chunkMap; -- protected final Reference2ObjectLinkedOpenHashMap playerMap = new Reference2ObjectLinkedOpenHashMap<>(512, 0.7f); -- protected final ReferenceLinkedOpenHashSet chunkSendQueue = new ReferenceLinkedOpenHashSet<>(512, 0.7f); -+ protected final Reference2ObjectMap playerMap = Reference2ObjectMaps.synchronize(new Reference2ObjectLinkedOpenHashMap<>(512, 0.7f)); -+ protected final Deque chunkSendQueue = new ConcurrentLinkedDeque<>(); - -- protected final TreeSet chunkLoadQueue = new TreeSet<>((final PlayerLoaderData p1, final PlayerLoaderData p2) -> { -+ protected final NavigableSet chunkLoadQueue = new ConcurrentSkipListSet<>((final PlayerLoaderData p1, final PlayerLoaderData p2) -> { - if (p1 == p2) { - return 0; - } -@@ -109,7 +109,7 @@ public final class PlayerChunkLoader { - return Integer.compare(System.identityHashCode(p1), System.identityHashCode(p2)); - }); - -- protected final TreeSet chunkSendWaitQueue = new TreeSet<>((final PlayerLoaderData p1, final PlayerLoaderData p2) -> { -+ protected final NavigableSet chunkSendWaitQueue = new ConcurrentSkipListSet<>((final PlayerLoaderData p1, final PlayerLoaderData p2) -> { - if (p1 == p2) { - return 0; - } -@@ -308,8 +308,8 @@ public final class PlayerChunkLoader { - }); - } - -- protected final LongOpenHashSet isTargetedForPlayerLoad = new LongOpenHashSet(); -- protected final LongOpenHashSet chunkTicketTracker = new LongOpenHashSet(); -+ protected final LongSet isTargetedForPlayerLoad = LongSets.synchronize(new LongOpenHashSet()); -+ protected final LongSet chunkTicketTracker = LongSets.synchronize(new LongOpenHashSet()); - - public boolean isChunkNearPlayers(final int chunkX, final int chunkZ) { - final PooledLinkedHashSets.PooledObjectLinkedOpenHashSet playersInSendRange = this.broadcastMap.getObjectsInRange(chunkX, chunkZ); -@@ -373,7 +373,7 @@ public final class PlayerChunkLoader { - } - - return !(data.hasSentChunk(chunkX - 1, chunkZ) && data.hasSentChunk(chunkX + 1, chunkZ) && -- data.hasSentChunk(chunkX, chunkZ - 1) && data.hasSentChunk(chunkX, chunkZ + 1)); -+ data.hasSentChunk(chunkX, chunkZ - 1) && data.hasSentChunk(chunkX, chunkZ + 1)); - } - - protected int getMaxConcurrentChunkSends() { -@@ -518,22 +518,20 @@ public final class PlayerChunkLoader { - protected static final AtomicInteger concurrentChunkSends = new AtomicInteger(); - protected final Reference2IntOpenHashMap sendingChunkCounts = new Reference2IntOpenHashMap<>(); - private static long nextChunkSend; -+ - private void trySendChunks() { - final long time = System.nanoTime(); - if (time < nextChunkSend) { - return; - } -+ PlayerLoaderData data1; - // drain entries from wait queue -- while (!this.chunkSendWaitQueue.isEmpty()) { -- final PlayerLoaderData data = this.chunkSendWaitQueue.first(); -- -- if (data.nextChunkSendTarget > time) { -+ while ((data1 = this.chunkSendWaitQueue.pollFirst())!=null) { -+ if (data1.nextChunkSendTarget > time) { -+ this.chunkSendWaitQueue.add(data1); - break; - } -- -- this.chunkSendWaitQueue.pollFirst(); -- -- this.chunkSendQueue.add(data); -+ this.chunkSendQueue.add(data1); - } - - if (this.chunkSendQueue.isEmpty()) { -@@ -542,10 +540,9 @@ public final class PlayerChunkLoader { - - final int maxSends = this.getMaxConcurrentChunkSends(); - final long nextPlayerDeadline = this.getTargetSendPerPlayerAddend() + time; -- for (;;) { -- if (this.chunkSendQueue.isEmpty()) { -- break; -- } -+ final Deque tempCopy = new ArrayDeque<>(this.chunkSendQueue); -+ PlayerLoaderData data; -+ while ((data = tempCopy.pollFirst())!=null) { - final int currSends = concurrentChunkSends.get(); - if (currSends >= maxSends) { - break; -@@ -554,24 +551,17 @@ public final class PlayerChunkLoader { - if (!concurrentChunkSends.compareAndSet(currSends, currSends + 1)) { - continue; - } -- - // send chunk -- -- final PlayerLoaderData data = this.chunkSendQueue.removeFirst(); -- -+ this.chunkSendQueue.remove(data); - final ChunkPriorityHolder queuedSend = data.sendQueue.pollFirst(); - if (queuedSend == null) { - concurrentChunkSends.getAndDecrement(); // we never sent, so decrease - // stop iterating over players who have nothing to send -- if (this.chunkSendQueue.isEmpty()) { -- // nothing left -- break; -- } - continue; - } - - if (!this.isChunkPlayerLoaded(queuedSend.chunkX, queuedSend.chunkZ)) { -- throw new IllegalStateException(); -+ continue; - } - - data.nextChunkSendTarget = nextPlayerDeadline; -@@ -581,17 +571,18 @@ public final class PlayerChunkLoader { - this.sendingChunkCounts.addTo(data, 1); - } - -+ final PlayerLoaderData finalData = data; - data.sendChunk(queuedSend.chunkX, queuedSend.chunkZ, () -> { - synchronized (this.sendingChunkCounts) { -- final int count = this.sendingChunkCounts.getInt(data); -+ final int count = this.sendingChunkCounts.getInt(finalData); - if (count == 0) { - // disconnected, so we don't need to decrement: it will be decremented for us - return; - } - if (count == 1) { -- this.sendingChunkCounts.removeInt(data); -+ this.sendingChunkCounts.removeInt(finalData); - } else { -- this.sendingChunkCounts.put(data, count - 1); -+ this.sendingChunkCounts.put(finalData, count - 1); - } - } - -@@ -618,16 +609,12 @@ public final class PlayerChunkLoader { - final int maxLoads = this.getMaxChunkLoads(); - final long time = System.nanoTime(); - boolean updatedCounters = false; -- for (;;) { -- final PlayerLoaderData data = this.chunkLoadQueue.pollFirst(); -- -+ PlayerLoaderData data; -+ while ((data = this.chunkLoadQueue.pollFirst())!=null) { - data.lastChunkLoad = time; - - final ChunkPriorityHolder queuedLoad = data.loadQueue.peekFirst(); - if (queuedLoad == null) { -- if (this.chunkLoadQueue.isEmpty()) { -- break; -- } - continue; - } - -@@ -673,7 +660,7 @@ public final class PlayerChunkLoader { - - final int currentChunkLoads = this.concurrentChunkLoads; - if (currentChunkLoads >= maxLoads || (GlobalConfiguration.get().chunkLoading.globalMaxChunkLoadRate > 0 && (TICKET_ADDITION_COUNTER_SHORT.getRate() >= GlobalConfiguration.get().chunkLoading.globalMaxChunkLoadRate || TICKET_ADDITION_COUNTER_LONG.getRate() >= GlobalConfiguration.get().chunkLoading.globalMaxChunkLoadRate)) -- || (GlobalConfiguration.get().chunkLoading.playerMaxChunkLoadRate > 0.0 && (data.ticketAdditionCounterShort.getRate() >= GlobalConfiguration.get().chunkLoading.playerMaxChunkLoadRate || data.ticketAdditionCounterLong.getRate() >= GlobalConfiguration.get().chunkLoading.playerMaxChunkLoadRate))) { -+ || (GlobalConfiguration.get().chunkLoading.playerMaxChunkLoadRate > 0.0 && (data.ticketAdditionCounterShort.getRate() >= GlobalConfiguration.get().chunkLoading.playerMaxChunkLoadRate || data.ticketAdditionCounterLong.getRate() >= GlobalConfiguration.get().chunkLoading.playerMaxChunkLoadRate))) { - // don't poll, we didn't load it - this.chunkLoadQueue.add(data); - break; -@@ -736,12 +723,13 @@ public final class PlayerChunkLoader { - } - } - -+ - public void tickMidTick() { -- // try to send more chunks -- this.trySendChunks(); -+ // try to send more chunks -+ this.trySendChunks(); - -- // try to queue more chunks to load -- this.tryLoadChunks(); -+ // try to queue more chunks to load -+ this.tryLoadChunks(); - } - - static final class ChunkPriorityHolder { -@@ -786,11 +774,11 @@ public final class PlayerChunkLoader { - - // warning: modifications of this field must be aware that the loadQueue inside PlayerChunkLoader uses this field - // in a comparator! -- protected final ArrayDeque loadQueue = new ArrayDeque<>(); -- protected final LongOpenHashSet sentChunks = new LongOpenHashSet(); -- protected final LongOpenHashSet chunksToBeSent = new LongOpenHashSet(); -+ protected final Deque loadQueue = new ConcurrentLinkedDeque<>(); -+ protected final LongSet sentChunks = LongSets.synchronize(new LongOpenHashSet()); -+ protected final LongSet chunksToBeSent = LongSets.synchronize(new LongOpenHashSet()); - -- protected final TreeSet sendQueue = new TreeSet<>((final ChunkPriorityHolder p1, final ChunkPriorityHolder p2) -> { -+ protected final NavigableSet sendQueue = new ConcurrentSkipListSet<>((final ChunkPriorityHolder p1, final ChunkPriorityHolder p2) -> { - final int distanceCompare = Integer.compare(p1.manhattanDistanceToPlayer, p2.manhattanDistanceToPlayer); - if (distanceCompare != 0) { - return distanceCompare; -@@ -964,14 +952,14 @@ public final class PlayerChunkLoader { - && tickViewDistance == this.lastTickDistance - - && (this.usingLookingPriority ? ( -- // has our block stayed the same (this also accounts for chunk change)? -- Mth.floor(this.lastLocX) == Mth.floor(posX) -+ // has our block stayed the same (this also accounts for chunk change)? -+ Mth.floor(this.lastLocX) == Mth.floor(posX) - && Mth.floor(this.lastLocZ) == Mth.floor(posZ) -- ) : ( -- // has our chunk stayed the same -- (Mth.floor(this.lastLocX) >> 4) == (Mth.floor(posX) >> 4) -+ ) : ( -+ // has our chunk stayed the same -+ (Mth.floor(this.lastLocX) >> 4) == (Mth.floor(posX) >> 4) - && (Mth.floor(this.lastLocZ) >> 4) == (Mth.floor(posZ) >> 4) -- )) -+ )) - - // has our decision about look priority changed? - && this.usingLookingPriority == useLookPriority -diff --git a/src/main/java/io/papermc/paper/chunk/system/entity/EntityLookup.java b/src/main/java/io/papermc/paper/chunk/system/entity/EntityLookup.java -index ec90ff5c2581706180498b74dbbf960d52d47209..387d07868301877dd7fca5d8dfd21e1331f4793e 100644 ---- a/src/main/java/io/papermc/paper/chunk/system/entity/EntityLookup.java -+++ b/src/main/java/io/papermc/paper/chunk/system/entity/EntityLookup.java -@@ -6,14 +6,15 @@ import io.papermc.paper.util.CoordinateUtils; - import io.papermc.paper.util.TickThread; - import io.papermc.paper.util.WorldUtil; - import io.papermc.paper.world.ChunkEntitySlices; -+import it.unimi.dsi.fastutil.ints.Int2ReferenceArrayMap; - import it.unimi.dsi.fastutil.ints.Int2ReferenceMap; --import it.unimi.dsi.fastutil.ints.Int2ReferenceMaps; - import it.unimi.dsi.fastutil.ints.Int2ReferenceOpenHashMap; -+import it.unimi.dsi.fastutil.longs.Long2ObjectArrayMap; - import it.unimi.dsi.fastutil.longs.Long2ObjectMap; - import it.unimi.dsi.fastutil.longs.Long2ObjectMaps; - import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; -+import it.unimi.dsi.fastutil.objects.Object2ReferenceArrayMap; - import it.unimi.dsi.fastutil.objects.Object2ReferenceMap; --import it.unimi.dsi.fastutil.objects.Object2ReferenceMaps; - import it.unimi.dsi.fastutil.objects.Object2ReferenceOpenHashMap; - import net.minecraft.core.BlockPos; - import io.papermc.paper.chunk.system.ChunkSystem; -@@ -32,8 +33,13 @@ import net.minecraft.world.phys.AABB; - import org.jetbrains.annotations.NotNull; - import org.jetbrains.annotations.Nullable; - import org.slf4j.Logger; -- --import java.util.*; -+import java.util.ArrayList; -+import java.util.Iterator; -+import java.util.List; -+import java.util.NoSuchElementException; -+import java.util.UUID; -+import java.util.concurrent.locks.Lock; -+import java.util.concurrent.locks.ReentrantLock; - import java.util.concurrent.locks.StampedLock; - import java.util.function.Consumer; - import java.util.function.Predicate; -@@ -48,16 +54,16 @@ public final class EntityLookup implements LevelEntityGetter { - - public final ServerLevel world; - -- private final StampedLock stateLock = new StampedLock(); -- protected final Long2ObjectMap regions = Long2ObjectMaps.synchronize(new Long2ObjectOpenHashMap<>(128, 0.5f)); -+ private final StampedLock entityByLock = new StampedLock(); -+ private final Lock regionLoadLock = new ReentrantLock(true); -+ -+ protected final Long2ObjectMap regions = Long2ObjectMaps.synchronize(new Long2ObjectArrayMap<>()); - - private final int minSection; // inclusive - private final int maxSection; // inclusive - private final LevelCallback worldCallback; -- -- private final StampedLock entityByLock = new StampedLock(); -- private final Map entityById = Int2ReferenceMaps.synchronize(new Int2ReferenceOpenHashMap<>()); -- private final Object2ReferenceMap entityByUUID = Object2ReferenceMaps.synchronize(new Object2ReferenceOpenHashMap<>()); -+ private final Int2ReferenceMap entityById = new Int2ReferenceArrayMap<>(); -+ private final Object2ReferenceMap entityByUUID = new Object2ReferenceArrayMap<>(); - private final EntityList accessibleEntities = new EntityList(); - - public EntityLookup(final ServerLevel world, final LevelCallback worldCallback) { -@@ -108,7 +114,6 @@ public final class EntityLookup implements LevelEntityGetter { - if (attempt != 0L) { - try { - final Entity ret = this.entityByUUID.get(id); -- - if (this.entityByLock.validate(attempt)) { - return maskNonAccessible(ret); - } -@@ -169,12 +174,12 @@ public final class EntityLookup implements LevelEntityGetter { - } - - @Override -- public boolean hasNext() { -+ public synchronized boolean hasNext() { - return this.off < this.length; - } - - @Override -- public T next() { -+ public synchronized T next() { - if (this.off >= this.length) { - throw new NoSuchElementException(); - } -@@ -231,75 +236,50 @@ public final class EntityLookup implements LevelEntityGetter { - public void entityStatusChange(final Entity entity, final ChunkEntitySlices slices, final Visibility oldVisibility, final Visibility newVisibility, final boolean moved, - final boolean created, final boolean destroyed) { - TickThread.ensureTickThread(entity, "Entity status change must only happen on the main thread"); -- -- if (entity.updatingSectionStatus) { -- // recursive status update -- LOGGER.warn("Cannot recursively update entity chunk status for entity " + entity); -- return; -- } -- -- final boolean entityStatusUpdateBefore = slices == null ? false : slices.startPreventingStatusUpdates(); -- -- if (entityStatusUpdateBefore) { -- LOGGER.warn("Cannot update chunk status for entity " + entity + " since entity chunk (" + slices.chunkX + "," + slices.chunkZ + ") is receiving update"); -- return; -- } -- -+ final Boolean ticketBlockBefore = this.world.chunkTaskScheduler.chunkHolderManager.blockTicketUpdates(); - try { -- final Boolean ticketBlockBefore = this.world.chunkTaskScheduler.chunkHolderManager.blockTicketUpdates(); -- try { -- entity.updatingSectionStatus = true; -- try { -- if (created) { -- EntityLookup.this.worldCallback.onCreated(entity); -- } -+ if (created) { -+ EntityLookup.this.worldCallback.onCreated(entity); -+ } - -- if (oldVisibility == newVisibility) { -- if (moved && newVisibility.isAccessible()) { -- EntityLookup.this.worldCallback.onSectionChange(entity); -- } -- return; -- } -+ if (oldVisibility == newVisibility) { -+ if (moved && newVisibility.isAccessible()) { -+ EntityLookup.this.worldCallback.onSectionChange(entity); -+ } -+ return; -+ } - -- if (newVisibility.ordinal() > oldVisibility.ordinal()) { -- // status upgrade -- if (!oldVisibility.isAccessible() && newVisibility.isAccessible()) { -- this.accessibleEntities.add(entity); -- EntityLookup.this.worldCallback.onTrackingStart(entity); -- } -+ if (newVisibility.ordinal() > oldVisibility.ordinal()) { -+ // status upgrade -+ if (!oldVisibility.isAccessible() && newVisibility.isAccessible()) { -+ this.accessibleEntities.add(entity); -+ EntityLookup.this.worldCallback.onTrackingStart(entity); -+ } - -- if (!oldVisibility.isTicking() && newVisibility.isTicking()) { -- EntityLookup.this.worldCallback.onTickingStart(entity); -- } -- } else { -- // status downgrade -- if (oldVisibility.isTicking() && !newVisibility.isTicking()) { -- EntityLookup.this.worldCallback.onTickingEnd(entity); -- } -+ if (!oldVisibility.isTicking() && newVisibility.isTicking()) { -+ EntityLookup.this.worldCallback.onTickingStart(entity); -+ } -+ } else { -+ // status downgrade -+ if (oldVisibility.isTicking() && !newVisibility.isTicking()) { -+ EntityLookup.this.worldCallback.onTickingEnd(entity); -+ } - -- if (oldVisibility.isAccessible() && !newVisibility.isAccessible()) { -- this.accessibleEntities.remove(entity); -- EntityLookup.this.worldCallback.onTrackingEnd(entity); -- } -- } -+ if (oldVisibility.isAccessible() && !newVisibility.isAccessible()) { -+ this.accessibleEntities.remove(entity); -+ EntityLookup.this.worldCallback.onTrackingEnd(entity); -+ } -+ } - -- if (moved && newVisibility.isAccessible()) { -- EntityLookup.this.worldCallback.onSectionChange(entity); -- } -+ if (moved && newVisibility.isAccessible()) { -+ EntityLookup.this.worldCallback.onSectionChange(entity); -+ } - -- if (destroyed) { -- EntityLookup.this.worldCallback.onDestroyed(entity); -- } -- } finally { -- entity.updatingSectionStatus = false; -- } -- } finally { -- this.world.chunkTaskScheduler.chunkHolderManager.unblockTicketUpdates(ticketBlockBefore); -+ if (destroyed) { -+ EntityLookup.this.worldCallback.onDestroyed(entity); - } - } finally { -- if (slices != null) { -- slices.stopPreventingStatusUpdates(false); -- } -+ this.world.chunkTaskScheduler.chunkHolderManager.unblockTicketUpdates(ticketBlockBefore); - } - } - -@@ -349,11 +329,6 @@ public final class EntityLookup implements LevelEntityGetter { - return false; - } - -- if (entity.updatingSectionStatus) { -- LOGGER.warn("Entity " + entity + " is currently prevented from being added/removed to world since it is processing section status updates"); -- return false; -- } -- - if (fromDisk) { - ChunkSystem.onEntityPreAdd(this.world, entity); - if (entity.isRemoved()) { -@@ -401,7 +376,14 @@ public final class EntityLookup implements LevelEntityGetter { - if (!entity.isRemoved()) { - throw new IllegalStateException("Only call Entity#setRemoved to remove an entity"); - } -- final ChunkEntitySlices slices = this.getChunk(sectionX, sectionZ); -+ ChunkEntitySlices slices; -+ this.regionLoadLock.lock(); -+ try { -+ slices = this.getChunk(sectionX, sectionZ); -+ }finally { -+ this.regionLoadLock.unlock(); -+ } -+ - // all entities should be in a chunk - if (slices == null) { - LOGGER.warn("Cannot remove entity " + entity + " from null entity slices (" + sectionX + "," + sectionZ + ")"); -@@ -444,7 +426,15 @@ public final class EntityLookup implements LevelEntityGetter { - // ensure the old section is owned by this tick thread - TickThread.ensureTickThread(this.world, entity.sectionX, entity.sectionZ, "Cannot move entity off-main"); - -- final ChunkEntitySlices old = this.getChunk(entity.sectionX, entity.sectionZ); -+ ChunkEntitySlices old; -+ -+ this.regionLoadLock.lock(); -+ try { -+ old = this.getChunk(entity.sectionX, entity.sectionZ); -+ }finally { -+ this.regionLoadLock.unlock(); -+ } -+ - final ChunkEntitySlices slices = this.getOrCreateChunk(newSectionX, newSectionZ); - - if (!old.removeEntity(entity, entity.sectionY)) { -@@ -612,7 +602,7 @@ public final class EntityLookup implements LevelEntityGetter { - continue; - } - -- chunk.getEntities(type, box, (List)into, (Predicate)predicate); -+ chunk.getEntities(type, box, (List) into, (Predicate) predicate); - } - } - } -@@ -663,18 +653,22 @@ public final class EntityLookup implements LevelEntityGetter { - TickThread.ensureTickThread(this.world, chunkX, chunkZ, "Cannot load in entity section off-main"); - synchronized (this) { - final ChunkEntitySlices curr = this.getChunk(chunkX, chunkZ); -- if (curr != null) { -- this.removeChunk(chunkX, chunkZ); -- -- curr.mergeInto(slices); -- -- this.addChunk(chunkX, chunkZ, slices); -- } else { -- this.addChunk(chunkX, chunkZ, slices); -+ this.regionLoadLock.lock(); -+ try { -+ if (curr != null) { -+ this.removeChunk(chunkX, chunkZ); -+ curr.mergeInto(slices); -+ this.addChunk(chunkX, chunkZ, slices); -+ } else { -+ this.addChunk(chunkX, chunkZ, slices); -+ } -+ } finally { -+ this.regionLoadLock.unlock(); - } - } - } - -+ - public void entitySectionUnload(final int chunkX, final int chunkZ) { - TickThread.ensureTickThread(this.world, chunkX, chunkZ, "Cannot unload entity section off-main"); - this.removeChunk(chunkX, chunkZ); -@@ -702,27 +696,7 @@ public final class EntityLookup implements LevelEntityGetter { - - public ChunkSlicesRegion getRegion(final int regionX, final int regionZ) { - final long key = CoordinateUtils.getChunkKey(regionX, regionZ); -- final long attempt = this.stateLock.tryOptimisticRead(); -- if (attempt != 0L) { -- try { -- final ChunkSlicesRegion ret = this.regions.get(key); -- -- if (this.stateLock.validate(attempt)) { -- return ret; -- } -- } catch (final Error error) { -- throw error; -- } catch (final Throwable thr) { -- // ignore -- } -- } -- -- this.stateLock.readLock(); -- try { -- return this.regions.get(key); -- } finally { -- this.stateLock.tryUnlockRead(); -- } -+ return this.regions.get(key); - } - - private synchronized void removeChunk(final int chunkX, final int chunkZ) { -@@ -733,12 +707,7 @@ public final class EntityLookup implements LevelEntityGetter { - final int remaining = region.remove(relIndex); - - if (remaining == 0) { -- this.stateLock.writeLock(); -- try { -- this.regions.remove(key); -- } finally { -- this.stateLock.tryUnlockWrite(); -- } -+ this.regions.remove(key); - } - } - -@@ -752,12 +721,7 @@ public final class EntityLookup implements LevelEntityGetter { - } else { - region = new ChunkSlicesRegion(); - region.add(relIndex, slices); -- this.stateLock.writeLock(); -- try { -- this.regions.put(key, region); -- } finally { -- this.stateLock.tryUnlockWrite(); -- } -+ this.regions.put(key, region); - } - } - -@@ -834,9 +798,11 @@ public final class EntityLookup implements LevelEntityGetter { - public static final NoOpCallback INSTANCE = new NoOpCallback(); - - @Override -- public void onMove() {} -+ public void onMove() { -+ } - - @Override -- public void onRemove(final Entity.RemovalReason reason) {} -+ public void onRemove(final Entity.RemovalReason reason) { -+ } - } - } -diff --git a/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkHolderManager.java b/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkHolderManager.java -index 830d863cd9665d58875bfa5ca2bcd22f89ab2d49..15eeea40bb7a44470f6f3f0e2473cb451812eec1 100644 ---- a/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkHolderManager.java -+++ b/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkHolderManager.java -@@ -13,14 +13,10 @@ import io.papermc.paper.util.CoordinateUtils; - import io.papermc.paper.util.TickThread; - import io.papermc.paper.util.misc.Delayed8WayDistancePropagator2D; - import io.papermc.paper.world.ChunkEntitySlices; --import it.unimi.dsi.fastutil.longs.Long2IntLinkedOpenHashMap; --import it.unimi.dsi.fastutil.longs.Long2IntMap; --import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap; --import it.unimi.dsi.fastutil.longs.Long2ObjectMap; --import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; --import it.unimi.dsi.fastutil.longs.LongArrayList; --import it.unimi.dsi.fastutil.longs.LongIterator; -+import it.unimi.dsi.fastutil.longs.*; - import it.unimi.dsi.fastutil.objects.ObjectRBTreeSet; -+import it.unimi.dsi.fastutil.objects.ObjectSortedSet; -+import it.unimi.dsi.fastutil.objects.ObjectSortedSets; - import it.unimi.dsi.fastutil.objects.ReferenceLinkedOpenHashSet; - import net.minecraft.nbt.CompoundTag; - import io.papermc.paper.chunk.system.ChunkSystem; -@@ -39,13 +35,8 @@ import org.bukkit.plugin.Plugin; - import org.slf4j.Logger; - import java.io.IOException; - import java.text.DecimalFormat; --import java.util.ArrayDeque; --import java.util.ArrayList; --import java.util.Collection; --import java.util.Collections; --import java.util.Iterator; --import java.util.List; --import java.util.Objects; -+import java.util.*; -+import java.util.concurrent.ConcurrentLinkedDeque; - import java.util.concurrent.TimeUnit; - import java.util.concurrent.atomic.AtomicBoolean; - import java.util.concurrent.atomic.AtomicReference; -@@ -67,16 +58,16 @@ public final class ChunkHolderManager { - final ReentrantLock ticketLock = new ReentrantLock(); - - private final SWMRLong2ObjectHashTable chunkHolders = new SWMRLong2ObjectHashTable<>(16384, 0.25f); -- private final Long2ObjectOpenHashMap>> tickets = new Long2ObjectOpenHashMap<>(8192, 0.25f); -+ private final Long2ObjectMap>> tickets = Long2ObjectMaps.synchronize(new Long2ObjectOpenHashMap<>(8192, 0.25f)); - // what a disaster of a name - // this is a map of removal tick to a map of chunks and the number of tickets a chunk has that are to expire that tick -- private final Long2ObjectOpenHashMap removeTickToChunkExpireTicketCount = new Long2ObjectOpenHashMap<>(); -+ private final Long2ObjectMap removeTickToChunkExpireTicketCount = Long2ObjectMaps.synchronize(new Long2ObjectOpenHashMap<>()); - private final ServerLevel world; - private final ChunkTaskScheduler taskScheduler; - private long currentTick; - -- private final ArrayDeque pendingFullLoadUpdate = new ArrayDeque<>(); -- private final ObjectRBTreeSet autoSaveQueue = new ObjectRBTreeSet<>((final NewChunkHolder c1, final NewChunkHolder c2) -> { -+ private final Deque pendingFullLoadUpdate = new ConcurrentLinkedDeque<>(); -+ private final ObjectSortedSet autoSaveQueue = ObjectSortedSets.synchronize(new ObjectRBTreeSet<>((final NewChunkHolder c1, final NewChunkHolder c2) -> { - if (c1 == c2) { - return 0; - } -@@ -95,7 +86,7 @@ public final class ChunkHolderManager { - } - - return Long.compare(coord1, coord2); -- }); -+ })); - - public ChunkHolderManager(final ServerLevel world, final ChunkTaskScheduler taskScheduler) { - this.world = world; -@@ -311,7 +302,7 @@ public final class ChunkHolderManager { - public Long2ObjectOpenHashMap>> getTicketsCopy() { - this.ticketLock.lock(); - try { -- return this.tickets.clone(); -+ return new Long2ObjectOpenHashMap<>(this.tickets); - } finally { - this.ticketLock.unlock(); - } -@@ -784,7 +775,7 @@ public final class ChunkHolderManager { - } - if (!TickThread.isTickThread()) { - this.taskScheduler.scheduleChunkTask(() -> { -- final ArrayDeque pendingFullLoadUpdate = ChunkHolderManager.this.pendingFullLoadUpdate; -+ final Deque pendingFullLoadUpdate = ChunkHolderManager.this.pendingFullLoadUpdate; - for (int i = 0, len = changedFullStatus.size(); i < len; ++i) { - pendingFullLoadUpdate.add(changedFullStatus.get(i)); - } -@@ -792,7 +783,7 @@ public final class ChunkHolderManager { - ChunkHolderManager.this.processPendingFullUpdate(); - }, PrioritisedExecutor.Priority.HIGHEST); - } else { -- final ArrayDeque pendingFullLoadUpdate = this.pendingFullLoadUpdate; -+ final Deque pendingFullLoadUpdate = this.pendingFullLoadUpdate; - for (int i = 0, len = changedFullStatus.size(); i < len; ++i) { - pendingFullLoadUpdate.add(changedFullStatus.get(i)); - } -@@ -1039,7 +1030,7 @@ public final class ChunkHolderManager { - - // only call on tick thread - protected final boolean processPendingFullUpdate() { -- final ArrayDeque pendingFullLoadUpdate = this.pendingFullLoadUpdate; -+ final Deque pendingFullLoadUpdate = this.pendingFullLoadUpdate; - - boolean ret = false; - -diff --git a/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java b/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java -index b3bcafc8bafe1e4a1a2b690499b91e5316a604f1..b12c02962e9dad92ae79d762887c65db10765488 100644 ---- a/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java -+++ b/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java -@@ -2,7 +2,6 @@ package io.papermc.paper.world; - - import com.destroystokyo.paper.util.maplist.EntityList; - import io.papermc.paper.chunk.system.entity.EntityLookup; --import io.papermc.paper.util.TickThread; - import it.unimi.dsi.fastutil.objects.Reference2ObjectMap; - import it.unimi.dsi.fastutil.objects.Reference2ObjectMaps; - import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap; -@@ -21,8 +20,8 @@ import net.minecraft.world.phys.AABB; - import org.bukkit.craftbukkit.event.CraftEventFactory; - import java.util.ArrayList; - import java.util.Arrays; --import java.util.Iterator; - import java.util.List; -+import java.util.concurrent.locks.StampedLock; - import java.util.function.Predicate; - - public final class ChunkEntitySlices { -@@ -32,15 +31,15 @@ public final class ChunkEntitySlices { - public final int chunkX; - public final int chunkZ; - protected final ServerLevel world; -- -+ protected final StampedLock accessLock = new StampedLock(); //Hearse -- fix some entity can't be removed - protected final EntityCollectionBySection allEntities; - protected final EntityCollectionBySection hardCollidingEntities; - protected final Reference2ObjectMap, EntityCollectionBySection> entitiesByClass; - protected final EntityList entities = new EntityList(); - -- public ChunkHolder.FullChunkStatus status; -+ public volatile ChunkHolder.FullChunkStatus status; - -- protected boolean isTransient; -+ protected volatile boolean isTransient; - - public boolean isTransient() { - return this.isTransient; -@@ -67,8 +66,7 @@ public final class ChunkEntitySlices { - this.status = status; - } - -- // Paper start - optimise CraftChunk#getEntities -- public org.bukkit.entity.Entity[] getChunkEntities() { -+ private org.bukkit.entity.Entity[] getChunkEntitiesUnsafe(){ - List ret = new java.util.ArrayList<>(); - final Entity[] entities = this.entities.getRawData(); - for (int i = 0, size = Math.min(entities.length, this.entities.size()); i < size; ++i) { -@@ -81,11 +79,25 @@ public final class ChunkEntitySlices { - ret.add(bukkit); - } - } -- - return ret.toArray(new org.bukkit.entity.Entity[0]); - } - -- public CompoundTag save() { -+ // Paper start - optimise CraftChunk#getEntities -+ public org.bukkit.entity.Entity[] getChunkEntities() { -+ long id = this.accessLock.tryOptimisticRead(); -+ if (this.accessLock.validate(id)) { -+ return this.getChunkEntitiesUnsafe(); -+ } -+ -+ id = this.accessLock.readLock(); -+ try { -+ return this.getChunkEntitiesUnsafe(); -+ } finally { -+ this.accessLock.unlockRead(id); -+ } -+ } -+ -+ private CompoundTag saveUnsafe(){ - final int len = this.entities.size(); - if (len == 0) { - return null; -@@ -107,11 +119,36 @@ public final class ChunkEntitySlices { - return EntityStorage.saveEntityChunk(collectedEntities, new ChunkPos(this.chunkX, this.chunkZ), this.world); - } - -+ public CompoundTag save() { -+ long id = this.accessLock.tryOptimisticRead(); -+ if (this.accessLock.validate(id)){ -+ return this.saveUnsafe(); -+ } -+ id = this.accessLock.readLock(); -+ try { -+ return this.saveUnsafe(); -+ } finally { -+ this.accessLock.unlockRead(id); -+ } -+ } -+ - // returns true if this chunk has transient entities remaining - public boolean unload() { -- final int len = this.entities.size(); -- final Entity[] collectedEntities = Arrays.copyOf(this.entities.getRawData(), len); -- -+ Entity[] collectedEntities; -+ int len; -+ long id = this.accessLock.tryOptimisticRead(); -+ if (this.accessLock.validate(id)){ -+ len = this.entities.size(); -+ collectedEntities = Arrays.copyOf(this.entities.getRawData(), len); -+ }else { -+ id = this.accessLock.readLock(); -+ try { -+ len = this.entities.size(); -+ collectedEntities = Arrays.copyOf(this.entities.getRawData(), len); -+ } finally { -+ this.accessLock.unlockRead(id); -+ } -+ } - for (int i = 0; i < len; ++i) { - final Entity entity = collectedEntities[i]; - if (entity.isRemoved()) { -@@ -129,7 +166,6 @@ public final class ChunkEntitySlices { - } - } - } -- - return this.entities.size() != 0; - } - -@@ -141,53 +177,98 @@ public final class ChunkEntitySlices { - - final Entity[] rawData = this.entities.getRawData(); - final List collectedEntities = new ArrayList<>(len); -- for (int i = 0; i < len; ++i) { -- collectedEntities.add(rawData[i]); -- } -+ collectedEntities.addAll(Arrays.asList(rawData).subList(0, len)); - - return collectedEntities; - } - - public void callEntitiesLoadEvent() { -- CraftEventFactory.callEntitiesLoadEvent(this.world, new ChunkPos(this.chunkX, this.chunkZ), this.getAllEntities()); -+ long id = this.accessLock.tryOptimisticRead(); -+ if (this.accessLock.validate(id)){ -+ CraftEventFactory.callEntitiesLoadEvent(this.world, new ChunkPos(this.chunkX, this.chunkZ), this.getAllEntities()); -+ return; -+ } -+ id = this.accessLock.readLock(); -+ try { -+ CraftEventFactory.callEntitiesLoadEvent(this.world, new ChunkPos(this.chunkX, this.chunkZ), this.getAllEntities()); -+ } finally { -+ this.accessLock.unlockRead(id); -+ } - } - - public void callEntitiesUnloadEvent() { -- CraftEventFactory.callEntitiesUnloadEvent(this.world, new ChunkPos(this.chunkX, this.chunkZ), this.getAllEntities()); -+ long id = this.accessLock.tryOptimisticRead(); -+ if (this.accessLock.validate(id)){ -+ CraftEventFactory.callEntitiesUnloadEvent(this.world, new ChunkPos(this.chunkX, this.chunkZ), this.getAllEntities()); -+ return; -+ } -+ id = this.accessLock.readLock(); -+ try { -+ CraftEventFactory.callEntitiesUnloadEvent(this.world, new ChunkPos(this.chunkX, this.chunkZ), this.getAllEntities()); -+ } finally { -+ this.accessLock.unlockRead(id); -+ } - } - // Paper end - optimise CraftChunk#getEntities - - public boolean isEmpty() { -- return this.entities.size() == 0; -+ long id = this.accessLock.tryOptimisticRead(); -+ if (this.accessLock.validate(id)){ -+ return this.entities.size() == 0; -+ } -+ id = this.accessLock.readLock(); -+ try { -+ return this.entities.size() == 0; -+ } finally { -+ this.accessLock.unlockRead(id); -+ } - } - - public void mergeInto(final ChunkEntitySlices slices) { -- final Entity[] entities = this.entities.getRawData(); -- for (int i = 0, size = Math.min(entities.length, this.entities.size()); i < size; ++i) { -- final Entity entity = entities[i]; -+ final List cop = new ArrayList<>(); -+ long id = this.accessLock.tryOptimisticRead(); -+ if (this.accessLock.validate(id)){ -+ final Entity[] entities = this.entities.getRawData(); -+ for (int i = 0, size = Math.min(entities.length, this.entities.size()); i < size; ++i) { -+ final Entity entity = entities[i]; -+ cop.add(entity); -+ } -+ }else { -+ id = this.accessLock.readLock(); -+ try { -+ final Entity[] entities = this.entities.getRawData(); -+ for (int i = 0, size = Math.min(entities.length, this.entities.size()); i < size; ++i) { -+ final Entity entity = entities[i]; -+ cop.add(entity); -+ } -+ } finally { -+ this.accessLock.unlockRead(id); -+ } -+ } -+ for (Entity entity : cop){ - slices.addEntity(entity, entity.sectionY); - } - } - -- private boolean preventStatusUpdates; -- public boolean startPreventingStatusUpdates() { -- final boolean ret = this.preventStatusUpdates; -- this.preventStatusUpdates = true; -- return ret; -- } -- -- public void stopPreventingStatusUpdates(final boolean prev) { -- this.preventStatusUpdates = prev; -- } -- - public void updateStatus(final ChunkHolder.FullChunkStatus status, final EntityLookup lookup) { - this.status = status; - -- final Entity[] entities = this.entities.getRawData(); -+ Entity[] entities; -+ -+ long id = this.accessLock.tryOptimisticRead(); -+ if (this.accessLock.validate(id)){ -+ entities = Arrays.copyOf(this.entities.getRawData(), this.entities.getRawData().length); -+ }else { -+ id = this.accessLock.readLock(); -+ try { -+ entities = Arrays.copyOf(this.entities.getRawData(), this.entities.getRawData().length); -+ } finally { -+ this.accessLock.unlockRead(id); -+ } -+ } - -- for (int i = 0, size = this.entities.size(); i < size; ++i) { -- final Entity entity = entities[i]; - -+ for (final Entity entity : entities) { - final Visibility oldVisibility = EntityLookup.getEntityStatus(entity); - entity.chunkStatus = status; - final Visibility newVisibility = EntityLookup.getEntityStatus(entity); -@@ -197,70 +278,112 @@ public final class ChunkEntitySlices { - } - - public boolean addEntity(final Entity entity, final int chunkSection) { -- if (!this.entities.add(entity)) { -- return false; -- } -- entity.chunkStatus = this.status; -- final int sectionIndex = chunkSection - this.minSection; -- -- this.allEntities.addEntity(entity, sectionIndex); -+ long id = this.accessLock.writeLock(); -+ try { -+ if (!this.entities.add(entity)) { -+ return false; -+ } -+ entity.chunkStatus = this.status; -+ final int sectionIndex = chunkSection - this.minSection; - -- if (entity.hardCollides()) { -- this.hardCollidingEntities.addEntity(entity, sectionIndex); -- } -+ this.allEntities.addEntity(entity, sectionIndex); - -- for (final Iterator, EntityCollectionBySection>> iterator = -- this.entitiesByClass.reference2ObjectEntrySet().iterator(); iterator.hasNext();) { -- final Reference2ObjectMap.Entry, EntityCollectionBySection> entry = iterator.next(); -+ if (entity.hardCollides()) { -+ this.hardCollidingEntities.addEntity(entity, sectionIndex); -+ } - -- if (entry.getKey().isInstance(entity)) { -- entry.getValue().addEntity(entity, sectionIndex); -+ for (final Reference2ObjectMap.Entry, EntityCollectionBySection> entry : this.entitiesByClass.reference2ObjectEntrySet()) { -+ if (entry.getKey().isInstance(entity)) { -+ entry.getValue().addEntity(entity, sectionIndex); -+ } - } -+ } finally { -+ this.accessLock.unlockWrite(id); - } -- - return true; - } - - public boolean removeEntity(final Entity entity, final int chunkSection) { -- if (!this.entities.remove(entity)) { -- return false; -- } -- entity.chunkStatus = null; -- final int sectionIndex = chunkSection - this.minSection; -- -- this.allEntities.removeEntity(entity, sectionIndex); -+ long id = this.accessLock.writeLock(); -+ try { -+ if (!this.entities.remove(entity)) { -+ return false; -+ } -+ entity.chunkStatus = null; -+ final int sectionIndex = chunkSection - this.minSection; - -- if (entity.hardCollides()) { -- this.hardCollidingEntities.removeEntity(entity, sectionIndex); -- } -+ this.allEntities.removeEntity(entity, sectionIndex); - -- for (final Iterator, EntityCollectionBySection>> iterator = -- this.entitiesByClass.reference2ObjectEntrySet().iterator(); iterator.hasNext();) { -- final Reference2ObjectMap.Entry, EntityCollectionBySection> entry = iterator.next(); -+ if (entity.hardCollides()) { -+ this.hardCollidingEntities.removeEntity(entity, sectionIndex); -+ } - -- if (entry.getKey().isInstance(entity)) { -- entry.getValue().removeEntity(entity, sectionIndex); -+ for (final Reference2ObjectMap.Entry, EntityCollectionBySection> entry : this.entitiesByClass.reference2ObjectEntrySet()) { -+ if (entry.getKey().isInstance(entity)) { -+ entry.getValue().removeEntity(entity, sectionIndex); -+ } - } -+ } finally { -+ this.accessLock.unlockWrite(id); - } -- - return true; - } - - public void getHardCollidingEntities(final Entity except, final AABB box, final List into, final Predicate predicate) { -- this.hardCollidingEntities.getEntities(except, box, into, predicate); -+ long id = this.accessLock.tryOptimisticRead(); -+ if (this.accessLock.validate(id)){ -+ this.hardCollidingEntities.getEntities(except, box, into, predicate); -+ return; -+ } -+ id = this.accessLock.readLock(); -+ try { -+ this.hardCollidingEntities.getEntities(except, box, into, predicate); -+ } finally { -+ this.accessLock.unlockRead(id); -+ } - } - - public void getEntities(final Entity except, final AABB box, final List into, final Predicate predicate) { -- this.allEntities.getEntitiesWithEnderDragonParts(except, box, into, predicate); -+ long id = this.accessLock.tryOptimisticRead(); -+ if (this.accessLock.validate(id)){ -+ this.allEntities.getEntitiesWithEnderDragonParts(except, box, into, predicate); -+ return; -+ } -+ id = this.accessLock.readLock(); -+ try { -+ this.allEntities.getEntitiesWithEnderDragonParts(except, box, into, predicate); -+ } finally { -+ this.accessLock.unlockRead(id); -+ } - } - - public void getEntitiesWithoutDragonParts(final Entity except, final AABB box, final List into, final Predicate predicate) { -- this.allEntities.getEntities(except, box, into, predicate); -+ long id = this.accessLock.tryOptimisticRead(); -+ if (this.accessLock.validate(id)){ -+ this.allEntities.getEntities(except, box, into, predicate); -+ return; -+ } -+ id = this.accessLock.readLock(); -+ try { -+ this.allEntities.getEntities(except, box, into, predicate); -+ } finally { -+ this.accessLock.unlockRead(id); -+ } - } - - public void getEntities(final EntityType type, final AABB box, final List into, - final Predicate predicate) { -- this.allEntities.getEntities(type, box, (List)into, (Predicate)predicate); -+ long id = this.accessLock.tryOptimisticRead(); -+ if (this.accessLock.validate(id)){ -+ this.allEntities.getEntities(type, box, (List) into, (Predicate) predicate); -+ return; -+ } -+ id = this.accessLock.readLock(); -+ try { -+ this.allEntities.getEntities(type, box, (List) into, (Predicate) predicate); -+ } finally { -+ this.accessLock.unlockRead(id); -+ } - } - - protected EntityCollectionBySection initClass(final Class clazz) { -@@ -288,12 +411,28 @@ public final class ChunkEntitySlices { - - public void getEntities(final Class clazz, final Entity except, final AABB box, final List into, - final Predicate predicate) { -- EntityCollectionBySection collection = this.entitiesByClass.get(clazz); -- if (collection != null) { -- collection.getEntitiesWithEnderDragonParts(except, clazz, box, (List)into, (Predicate)predicate); -- } else { -- this.entitiesByClass.putIfAbsent(clazz, collection = this.initClass(clazz)); -- collection.getEntitiesWithEnderDragonParts(except, clazz, box, (List)into, (Predicate)predicate); -+ long id = this.accessLock.tryOptimisticRead(); -+ if (this.accessLock.validate(id)){ -+ EntityCollectionBySection collection = this.entitiesByClass.get(clazz); -+ if (collection != null) { -+ collection.getEntitiesWithEnderDragonParts(except, clazz, box, (List) into, (Predicate) predicate); -+ } else { -+ this.entitiesByClass.putIfAbsent(clazz, collection = this.initClass(clazz)); -+ collection.getEntitiesWithEnderDragonParts(except, clazz, box, (List) into, (Predicate) predicate); -+ } -+ return; -+ } -+ id = this.accessLock.readLock(); -+ try { -+ EntityCollectionBySection collection = this.entitiesByClass.get(clazz); -+ if (collection != null) { -+ collection.getEntitiesWithEnderDragonParts(except, clazz, box, (List) into, (Predicate) predicate); -+ } else { -+ this.entitiesByClass.putIfAbsent(clazz, collection = this.initClass(clazz)); -+ collection.getEntitiesWithEnderDragonParts(except, clazz, box, (List) into, (Predicate) predicate); -+ } -+ } finally { -+ this.accessLock.unlockRead(id); - } - } - -@@ -310,26 +449,26 @@ public final class ChunkEntitySlices { - } - - public BasicEntityList(final int cap) { -- this.storage = (E[])(cap <= 0 ? EMPTY : new Entity[cap]); -+ this.storage = (E[]) (cap <= 0 ? EMPTY : new Entity[cap]); - } - -- public synchronized boolean isEmpty() { -+ public boolean isEmpty() { - return this.size == 0; - } - -- public synchronized int size() { -+ public int size() { - return this.size; - } - - private void resize() { - if (this.storage == EMPTY) { -- this.storage = (E[])new Entity[DEFAULT_CAPACITY]; -+ this.storage = (E[]) new Entity[DEFAULT_CAPACITY]; - } else { - this.storage = Arrays.copyOf(this.storage, this.storage.length * 2); - } - } - -- public synchronized void add(final E entity) { -+ public void add(final E entity) { - final int idx = this.size++; - if (idx >= this.storage.length) { - this.resize(); -@@ -339,7 +478,7 @@ public final class ChunkEntitySlices { - } - } - -- public synchronized int indexOf(final E entity) { -+ public int indexOf(final E entity) { - final E[] storage = this.storage; - - for (int i = 0, len = Math.min(this.storage.length, this.size); i < len; ++i) { -@@ -351,7 +490,7 @@ public final class ChunkEntitySlices { - return -1; - } - -- public synchronized boolean remove(final E entity) { -+ public boolean remove(final E entity) { - final int idx = this.indexOf(entity); - if (idx == -1) { - return false; -@@ -368,7 +507,7 @@ public final class ChunkEntitySlices { - return true; - } - -- public synchronized boolean has(final E entity) { -+ public boolean has(final E entity) { - return this.indexOf(entity) != -1; - } - } -@@ -389,7 +528,7 @@ public final class ChunkEntitySlices { - this.entitiesBySection = new BasicEntityList[sectionCount]; - } - -- public synchronized void addEntity(final Entity entity, final int sectionIndex) { -+ public void addEntity(final Entity entity, final int sectionIndex) { - BasicEntityList list = this.entitiesBySection[sectionIndex]; - - if (list != null && list.has(entity)) { -@@ -405,7 +544,7 @@ public final class ChunkEntitySlices { - ++this.count; - } - -- public synchronized void removeEntity(final Entity entity, final int sectionIndex) { -+ public void removeEntity(final Entity entity, final int sectionIndex) { - final BasicEntityList list = this.entitiesBySection[sectionIndex]; - - if (list == null || !list.remove(entity)) { -@@ -420,7 +559,7 @@ public final class ChunkEntitySlices { - } - } - -- public synchronized void getEntities(final Entity except, final AABB box, final List into, final Predicate predicate) { -+ public void getEntities(final Entity except, final AABB box, final List into, final Predicate predicate) { - if (this.count == 0) { - return; - } -@@ -458,7 +597,7 @@ public final class ChunkEntitySlices { - } - } - -- public synchronized void getEntitiesWithEnderDragonParts(final Entity except, final AABB box, final List into, -+ public void getEntitiesWithEnderDragonParts(final Entity except, final AABB box, final List into, - final Predicate predicate) { - if (this.count == 0) { - return; -@@ -493,7 +632,7 @@ public final class ChunkEntitySlices { - } // else: continue to test the ender dragon parts - - if (entity instanceof EnderDragon) { -- for (final EnderDragonPart part : ((EnderDragon)entity).subEntities) { -+ for (final EnderDragonPart part : ((EnderDragon) entity).subEntities) { - if (part == except || !part.getBoundingBox().intersects(box)) { - continue; - } -@@ -509,7 +648,7 @@ public final class ChunkEntitySlices { - } - } - -- public synchronized void getEntitiesWithEnderDragonParts(final Entity except, final Class clazz, final AABB box, final List into, -+ public void getEntitiesWithEnderDragonParts(final Entity except, final Class clazz, final AABB box, final List into, - final Predicate predicate) { - if (this.count == 0) { - return; -@@ -544,7 +683,7 @@ public final class ChunkEntitySlices { - } // else: continue to test the ender dragon parts - - if (entity instanceof EnderDragon) { -- for (final EnderDragonPart part : ((EnderDragon)entity).subEntities) { -+ for (final EnderDragonPart part : ((EnderDragon) entity).subEntities) { - if (part == except || !part.getBoundingBox().intersects(box) || !clazz.isInstance(part)) { - continue; - } -@@ -560,7 +699,7 @@ public final class ChunkEntitySlices { - } - } - -- public synchronized void getEntities(final EntityType type, final AABB box, final List into, -+ public void getEntities(final EntityType type, final AABB box, final List into, - final Predicate predicate) { - if (this.count == 0) { - return; -@@ -590,11 +729,11 @@ public final class ChunkEntitySlices { - continue; - } - -- if (predicate != null && !predicate.test((T)entity)) { -+ if (predicate != null && !predicate.test((T) entity)) { - continue; - } - -- into.add((T)entity); -+ into.add((T) entity); - } - } - } diff --git a/patches/server/0044-MikuServer-Code-error-fix.patch b/patches/server/0044-MikuServer-Code-error-fix.patch deleted file mode 100644 index e00d59b3..00000000 --- a/patches/server/0044-MikuServer-Code-error-fix.patch +++ /dev/null @@ -1,306 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: wangxyper -Date: Fri, 27 Jan 2023 19:55:14 +0800 -Subject: [PATCH] MikuServer: Code error fix - -Original license: MIT -Original project: https://github.com/MikuMC/MikuServer - -diff --git a/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkHolderManager.java b/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkHolderManager.java -index 15eeea40bb7a44470f6f3f0e2473cb451812eec1..c256b6175f8b859883b849c6cd623f680b78be32 100644 ---- a/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkHolderManager.java -+++ b/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkHolderManager.java -@@ -2,7 +2,6 @@ package io.papermc.paper.chunk.system.scheduling; - - import ca.spottedleaf.concurrentutil.executor.standard.PrioritisedExecutor; - import ca.spottedleaf.concurrentutil.map.SWMRLong2ObjectHashTable; --import co.aikar.timings.Timing; - import com.google.common.collect.ImmutableList; - import com.google.gson.JsonArray; - import com.google.gson.JsonObject; -@@ -29,8 +28,6 @@ import net.minecraft.server.level.TicketType; - import net.minecraft.util.SortedArraySet; - import net.minecraft.util.Unit; - import net.minecraft.world.level.ChunkPos; --import net.minecraft.world.level.chunk.ChunkAccess; --import net.minecraft.world.level.chunk.ChunkStatus; - import org.bukkit.plugin.Plugin; - import org.slf4j.Logger; - import java.io.IOException; -diff --git a/src/main/java/io/papermc/paper/util/misc/Delayed26WayDistancePropagator3D.java b/src/main/java/io/papermc/paper/util/misc/Delayed26WayDistancePropagator3D.java -index 470402573bc31106d5a63e415b958fb7f9c36aa9..e831738a2988746fe4e065f6ded811a8bdf5dabe 100644 ---- a/src/main/java/io/papermc/paper/util/misc/Delayed26WayDistancePropagator3D.java -+++ b/src/main/java/io/papermc/paper/util/misc/Delayed26WayDistancePropagator3D.java -@@ -94,24 +94,42 @@ public final class Delayed26WayDistancePropagator3D { - - protected final void addToIncreaseWorkQueue(final long coordinate, final byte level) { - final Delayed8WayDistancePropagator2D.WorkQueue queue = this.levelIncreaseWorkQueues[level]; -- queue.queuedCoordinates.enqueue(coordinate); -- queue.queuedLevels.enqueue(level); -+ -+ final long id = queue.lock.writeLock(); -+ try { -+ queue.queuedCoordinates.add(coordinate); -+ queue.queuedLevels.add(level); -+ }finally { -+ queue.lock.unlockWrite(id); -+ } - - this.levelIncreaseWorkQueueBitset |= (1L << level); - } - - protected final void addToIncreaseWorkQueue(final long coordinate, final byte index, final byte level) { - final Delayed8WayDistancePropagator2D.WorkQueue queue = this.levelIncreaseWorkQueues[index]; -- queue.queuedCoordinates.enqueue(coordinate); -- queue.queuedLevels.enqueue(level); -+ -+ final long id = queue.lock.writeLock(); -+ try { -+ queue.queuedCoordinates.add(coordinate); -+ queue.queuedLevels.add(level); -+ }finally { -+ queue.lock.unlockWrite(id); -+ } - - this.levelIncreaseWorkQueueBitset |= (1L << index); - } - - protected final void addToRemoveWorkQueue(final long coordinate, final byte level) { - final Delayed8WayDistancePropagator2D.WorkQueue queue = this.levelRemoveWorkQueues[level]; -- queue.queuedCoordinates.enqueue(coordinate); -- queue.queuedLevels.enqueue(level); -+ -+ final long id = queue.lock.writeLock(); -+ try { -+ queue.queuedCoordinates.add(coordinate); -+ queue.queuedLevels.add(level); -+ }finally { -+ queue.lock.unlockWrite(id); -+ } - - this.levelRemoveWorkQueueBitset |= (1L << level); - } -@@ -163,9 +181,20 @@ public final class Delayed26WayDistancePropagator3D { - this.levelIncreaseWorkQueueBitset ^= (1L << queueIndex), queueIndex = 63 ^ Long.numberOfLeadingZeros(this.levelIncreaseWorkQueueBitset)) { - - final Delayed8WayDistancePropagator2D.WorkQueue queue = this.levelIncreaseWorkQueues[queueIndex]; -- while (!queue.queuedLevels.isEmpty()) { -- final long coordinate = queue.queuedCoordinates.removeFirstLong(); -- byte level = queue.queuedLevels.removeFirstByte(); -+ while (true) { -+ -+ long coordinate; -+ byte level; -+ final long id = queue.lock.writeLock(); -+ try { -+ if (queue.queuedLevels.isEmpty()){ -+ break; -+ } -+ coordinate = queue.queuedCoordinates.removeFirst(); -+ level = queue.queuedLevels.removeFirst(); -+ }finally { -+ queue.lock.unlockWrite(id); -+ } - - final boolean neighbourCheck = level < 0; - -@@ -232,9 +261,19 @@ public final class Delayed26WayDistancePropagator3D { - this.levelRemoveWorkQueueBitset ^= (1L << queueIndex), queueIndex = 63 ^ Long.numberOfLeadingZeros(this.levelRemoveWorkQueueBitset)) { - - final Delayed8WayDistancePropagator2D.WorkQueue queue = this.levelRemoveWorkQueues[queueIndex]; -- while (!queue.queuedLevels.isEmpty()) { -- final long coordinate = queue.queuedCoordinates.removeFirstLong(); -- final byte level = queue.queuedLevels.removeFirstByte(); -+ while (true) { -+ long coordinate; -+ byte level; -+ final long id = queue.lock.writeLock(); -+ try { -+ if (queue.queuedLevels.isEmpty()){ -+ break; -+ } -+ coordinate = queue.queuedCoordinates.removeFirst(); -+ level = queue.queuedLevels.removeFirst(); -+ }finally { -+ queue.lock.unlockWrite(id); -+ } - - final byte currentLevel = this.levels.removeIfGreaterOrEqual(coordinate, level); - if (currentLevel == 0) { -diff --git a/src/main/java/io/papermc/paper/util/misc/Delayed8WayDistancePropagator2D.java b/src/main/java/io/papermc/paper/util/misc/Delayed8WayDistancePropagator2D.java -index 808d1449ac44ae86a650932365081fbaf178d141..0fa95d81bafc7fe5c1bede7a0608b54795a78fa0 100644 ---- a/src/main/java/io/papermc/paper/util/misc/Delayed8WayDistancePropagator2D.java -+++ b/src/main/java/io/papermc/paper/util/misc/Delayed8WayDistancePropagator2D.java -@@ -1,12 +1,14 @@ - package io.papermc.paper.util.misc; - -+import io.papermc.paper.util.MCUtil; - import it.unimi.dsi.fastutil.HashCommon; --import it.unimi.dsi.fastutil.bytes.ByteArrayFIFOQueue; - import it.unimi.dsi.fastutil.longs.Long2ByteOpenHashMap; --import it.unimi.dsi.fastutil.longs.LongArrayFIFOQueue; - import it.unimi.dsi.fastutil.longs.LongIterator; - import it.unimi.dsi.fastutil.longs.LongLinkedOpenHashSet; --import io.papermc.paper.util.MCUtil; -+ -+import java.util.Deque; -+import java.util.concurrent.ConcurrentLinkedDeque; -+import java.util.concurrent.locks.StampedLock; - - public final class Delayed8WayDistancePropagator2D { - -@@ -356,24 +358,42 @@ public final class Delayed8WayDistancePropagator2D { - - protected final void addToIncreaseWorkQueue(final long coordinate, final byte level) { - final WorkQueue queue = this.levelIncreaseWorkQueues[level]; -- queue.queuedCoordinates.enqueue(coordinate); -- queue.queuedLevels.enqueue(level); -+ -+ final long id = queue.lock.writeLock(); -+ try { -+ queue.queuedCoordinates.add(coordinate); -+ queue.queuedLevels.add(level); -+ }finally { -+ queue.lock.unlockWrite(id); -+ } - - this.levelIncreaseWorkQueueBitset |= (1L << level); - } - - protected final void addToIncreaseWorkQueue(final long coordinate, final byte index, final byte level) { - final WorkQueue queue = this.levelIncreaseWorkQueues[index]; -- queue.queuedCoordinates.enqueue(coordinate); -- queue.queuedLevels.enqueue(level); -+ -+ final long id = queue.lock.writeLock(); -+ try { -+ queue.queuedCoordinates.add(coordinate); -+ queue.queuedLevels.add(level); -+ }finally { -+ queue.lock.unlockWrite(id); -+ } - - this.levelIncreaseWorkQueueBitset |= (1L << index); - } - - protected final void addToRemoveWorkQueue(final long coordinate, final byte level) { - final WorkQueue queue = this.levelRemoveWorkQueues[level]; -- queue.queuedCoordinates.enqueue(coordinate); -- queue.queuedLevels.enqueue(level); -+ -+ final long id = queue.lock.writeLock(); -+ try { -+ queue.queuedCoordinates.add(coordinate); -+ queue.queuedLevels.add(level); -+ }finally { -+ queue.lock.unlockWrite(id); -+ } - - this.levelRemoveWorkQueueBitset |= (1L << level); - } -@@ -425,9 +445,19 @@ public final class Delayed8WayDistancePropagator2D { - this.levelIncreaseWorkQueueBitset ^= (1L << queueIndex), queueIndex = 63 ^ Long.numberOfLeadingZeros(this.levelIncreaseWorkQueueBitset)) { - - final WorkQueue queue = this.levelIncreaseWorkQueues[queueIndex]; -- while (!queue.queuedLevels.isEmpty()) { -- final long coordinate = queue.queuedCoordinates.removeFirstLong(); -- byte level = queue.queuedLevels.removeFirstByte(); -+ while (true) { -+ byte level; -+ long coordinate; -+ final long id = queue.lock.writeLock(); -+ try { -+ if (queue.queuedLevels.isEmpty()){ -+ break; -+ } -+ coordinate = queue.queuedCoordinates.removeFirst(); -+ level = queue.queuedLevels.removeFirst(); -+ }finally { -+ queue.lock.unlockWrite(id); -+ } - - final boolean neighbourCheck = level < 0; - -@@ -491,9 +521,20 @@ public final class Delayed8WayDistancePropagator2D { - this.levelRemoveWorkQueueBitset ^= (1L << queueIndex), queueIndex = 63 ^ Long.numberOfLeadingZeros(this.levelRemoveWorkQueueBitset)) { - - final WorkQueue queue = this.levelRemoveWorkQueues[queueIndex]; -- while (!queue.queuedLevels.isEmpty()) { -- final long coordinate = queue.queuedCoordinates.removeFirstLong(); -- final byte level = queue.queuedLevels.removeFirstByte(); -+ while (true) { -+ long coordinate; -+ byte level; -+ -+ final long id = queue.lock.writeLock(); -+ try { -+ if (queue.queuedLevels.isEmpty()){ -+ break; -+ } -+ coordinate = queue.queuedCoordinates.removeFirst(); -+ level = queue.queuedLevels.removeFirst(); -+ }finally { -+ queue.lock.unlockWrite(id); -+ } - - final byte currentLevel = this.levels.removeIfGreaterOrEqual(coordinate, level); - if (currentLevel == 0) { -@@ -678,41 +719,9 @@ public final class Delayed8WayDistancePropagator2D { - } - - protected static final class WorkQueue { -- -- public final NoResizeLongArrayFIFODeque queuedCoordinates = new NoResizeLongArrayFIFODeque(); -- public final NoResizeByteArrayFIFODeque queuedLevels = new NoResizeByteArrayFIFODeque(); -- -+ public final Deque queuedCoordinates = new ConcurrentLinkedDeque<>(); -+ public final Deque queuedLevels = new ConcurrentLinkedDeque<>(); -+ public final StampedLock lock = new StampedLock(); - } - -- protected static final class NoResizeLongArrayFIFODeque extends LongArrayFIFOQueue { -- -- /** -- * Assumes non-empty. If empty, undefined behaviour. -- */ -- public long removeFirstLong() { -- // copied from superclass -- long t = this.array[this.start]; -- if (++this.start == this.length) { -- this.start = 0; -- } -- -- return t; -- } -- } -- -- protected static final class NoResizeByteArrayFIFODeque extends ByteArrayFIFOQueue { -- -- /** -- * Assumes non-empty. If empty, undefined behaviour. -- */ -- public byte removeFirstByte() { -- // copied from superclass -- byte t = this.array[this.start]; -- if (++this.start == this.length) { -- this.start = 0; -- } -- -- return t; -- } -- } - } -diff --git a/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java b/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java -index 8950b220b9a3512cd4667beb7bdec0e82e07edc6..91fe5898270495aa89586b74ebfd649ef1e0b342 100644 ---- a/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java -+++ b/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java -@@ -4,8 +4,7 @@ import com.mojang.datafixers.DataFixer; - import com.mojang.datafixers.util.Pair; - import it.unimi.dsi.fastutil.longs.Long2ByteMap; - import it.unimi.dsi.fastutil.longs.Long2ByteOpenHashMap; --import it.unimi.dsi.fastutil.longs.LongOpenHashSet; --import it.unimi.dsi.fastutil.longs.LongSet; -+ - import java.nio.file.Path; - import java.util.Comparator; - import java.util.List; diff --git a/patches/server/0045-MikuServer-Bug-fixes-in-CPS-and-Pathfinding.patch b/patches/server/0045-MikuServer-Bug-fixes-in-CPS-and-Pathfinding.patch deleted file mode 100644 index d87b7279..00000000 --- a/patches/server/0045-MikuServer-Bug-fixes-in-CPS-and-Pathfinding.patch +++ /dev/null @@ -1,254 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: wangxyper -Date: Fri, 27 Jan 2023 20:31:46 +0800 -Subject: [PATCH] MikuServer: Bug fixes in CPS and Pathfinding - -Original license: MIT -Original project: https://github.com/MikuMC/MikuServer - -diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index 686852f5cb6303381c45a673a0daf79a2d3a9dfe..d023e6347e78bde17c67ed299504a081fe895858 100644 ---- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java -+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -@@ -843,12 +843,11 @@ public class ServerChunkCache extends ChunkSource { - if (chunkMap.playerMobDistanceMap != null && _pufferfish_spawnCountsReady.getAndSet(false)) { - net.minecraft.server.MinecraftServer.getServer().mobSpawnExecutor.submit(() -> { - int mapped = distanceManager.getNaturalSpawnChunkCount(); -- io.papermc.paper.util.maplist.IteratorSafeOrderedReferenceSet.Iterator objectiterator = -- level.entityTickList.entities.iterator(io.papermc.paper.util.maplist.IteratorSafeOrderedReferenceSet.ITERATOR_FLAG_SEE_ADDITIONS); -+ Iterator objectiterator = -+ level.entityTickList.entities.iterator(); - gg.pufferfish.pufferfish.util.IterableWrapper wrappedIterator = - new gg.pufferfish.pufferfish.util.IterableWrapper<>(objectiterator); - lastSpawnState = NaturalSpawner.createState(mapped, wrappedIterator, this::getFullChunk, null, true); -- objectiterator.finishedIterating(); - _pufferfish_spawnCountsReady.set(true); - }); - } -@@ -1031,9 +1030,11 @@ public class ServerChunkCache extends ChunkSource { - @Override - // CraftBukkit start - process pending Chunk loadCallback() and unloadCallback() after each run task - public boolean pollTask() { -- ServerChunkCache.this.chunkMap.playerChunkManager.tickMidTick(); -- if (ServerChunkCache.this.runDistanceManagerUpdates()) { -- return true; -+ synchronized (this){ -+ ServerChunkCache.this.chunkMap.playerChunkManager.tickMidTick(); -+ if (ServerChunkCache.this.runDistanceManagerUpdates()) { -+ return true; -+ } - } - return super.pollTask() | ServerChunkCache.this.level.chunkTaskScheduler.executeMainThreadTask(); // Paper - rewrite chunk system - } -diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index 619730e2013b4c8907ba7b7e6927b57b4ac76ec7..f5aff6d724185e1ada8736bdb6dd12b143812e83 100644 ---- a/src/main/java/net/minecraft/world/entity/LivingEntity.java -+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -3029,7 +3029,7 @@ public abstract class LivingEntity extends Entity { - } - - if (!this.isRemoved()) { -- this.aiStep(); -+ MinecraftServer.getServer().asyncExecutor.executeWithCallBack(this::aiStep,()->{}); - } - - double d0 = this.getX() - this.xo; -diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java -index 9071abd67c421a528514a6437a1b8dde02e068ed..ed645b74bfc6e3cffe75cb4e30277cd5e98ca9c1 100644 ---- a/src/main/java/net/minecraft/world/entity/Mob.java -+++ b/src/main/java/net/minecraft/world/entity/Mob.java -@@ -881,43 +881,42 @@ public abstract class Mob extends LivingEntity { - if (i % 10 == 0) this.sensing.tick(); // petal - only refresh line of sight cache every half second - //this.level.getProfiler().pop(); // Purpur - -- MinecraftServer.getServer().asyncExecutor.executeWithCallBack(() -> { -- if (i % 2 != 0 && this.tickCount > 1) { -- //this.level.getProfiler().push("targetSelector"); // Purpur -- if (this.targetSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking -- this.targetSelector.tickRunningGoals(false); -- //this.level.getProfiler().pop(); // Purpur -- //this.level.getProfiler().push("goalSelector"); // Purpur -- if (this.goalSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking -- this.goalSelector.tickRunningGoals(false); -- //this.level.getProfiler().pop(); // Purpur -- } else { -- //this.level.getProfiler().push("targetSelector"); // Purpur -- if (this.targetSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking -- this.targetSelector.tick(); -- //this.level.getProfiler().pop(); // Purpur -- //this.level.getProfiler().push("goalSelector"); // Purpur -- if (this.goalSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking -- this.goalSelector.tick(); -- //this.level.getProfiler().pop(); // Purpur -- } -- -- //this.level.getProfiler().push("navigation"); // Purpur -- this.navigation.tick(); -+ if (i % 2 != 0 && this.tickCount > 1) { -+ //this.level.getProfiler().push("targetSelector"); // Purpur -+ if (this.targetSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking -+ this.targetSelector.tickRunningGoals(false); - //this.level.getProfiler().pop(); // Purpur -- //this.level.getProfiler().push("mob tick"); // Purpur -- this.customServerAiStep(); -+ //this.level.getProfiler().push("goalSelector"); // Purpur -+ if (this.goalSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking -+ this.goalSelector.tickRunningGoals(false); - //this.level.getProfiler().pop(); // Purpur -- //this.level.getProfiler().push("controls"); // Purpur -- //this.level.getProfiler().push("move"); // Purpur -- this.moveControl.tick(); -- //this.level.getProfiler().popPush("look"); // Purpur -- this.lookControl.tick(); -- //this.level.getProfiler().popPush("jump"); // Purpur -- this.jumpControl.tick(); -+ } else { -+ //this.level.getProfiler().push("targetSelector"); // Purpur -+ if (this.targetSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking -+ this.targetSelector.tick(); - //this.level.getProfiler().pop(); // Purpur -+ //this.level.getProfiler().push("goalSelector"); // Purpur -+ if (this.goalSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking -+ this.goalSelector.tick(); - //this.level.getProfiler().pop(); // Purpur -- }, this::sendDebugPackets); -+ } -+ -+ //this.level.getProfiler().push("navigation"); // Purpur -+ this.navigation.tick(); -+ //this.level.getProfiler().pop(); // Purpur -+ //this.level.getProfiler().push("mob tick"); // Purpur -+ this.customServerAiStep(); -+ //this.level.getProfiler().pop(); // Purpur -+ //this.level.getProfiler().push("controls"); // Purpur -+ //this.level.getProfiler().push("move"); // Purpur -+ this.moveControl.tick(); -+ //this.level.getProfiler().popPush("look"); // Purpur -+ this.lookControl.tick(); -+ //this.level.getProfiler().popPush("jump"); // Purpur -+ this.jumpControl.tick(); -+ //this.level.getProfiler().pop(); // Purpur -+ //this.level.getProfiler().pop(); // Purpur -+ this.sendDebugPackets(); - } - - protected void sendDebugPackets() { -diff --git a/src/main/java/net/minecraft/world/entity/Mob.java.rej b/src/main/java/net/minecraft/world/entity/Mob.java.rej -new file mode 100644 -index 0000000000000000000000000000000000000000..68eddcd9c30a0b4ab690fc54de481847107cef00 ---- /dev/null -+++ b/src/main/java/net/minecraft/world/entity/Mob.java.rej -@@ -0,0 +1,59 @@ -+diff a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java (rejected hunks) -+@@ -910,32 +910,31 @@ public abstract class Mob extends LivingEntity { -+ //this.level.getProfiler().pop(); // Purpur -+ int i = this.level.getServer().getTickCount() + this.getId(); -+ -+- MinecraftServer.getServer().asyncExecutor.executeWithCallBack(()->{ -+- if (i % 2 != 0 && this.tickCount > 1) { -+- //this.level.getProfiler().push("targetSelector"); // Purpur -+- if (this.targetSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking -+- this.targetSelector.tickRunningGoals(false); -+- //this.level.getProfiler().pop(); // Purpur -+- //this.level.getProfiler().push("goalSelector"); // Purpur -+- if (this.goalSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking -+- this.goalSelector.tickRunningGoals(false); -+- //this.level.getProfiler().pop(); // Purpur -+- } else { -+- //this.level.getProfiler().push("targetSelector"); // Purpur -+- if (this.targetSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking -+- this.targetSelector.tick(); -+- //this.level.getProfiler().pop(); // Purpur -+- //this.level.getProfiler().push("goalSelector"); // Purpur -+- if (this.goalSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking -+- this.goalSelector.tick(); -+- //this.level.getProfiler().pop(); // Purpur -+- } -+- this.navigation.tick(); -+- this.customServerAiStep(); -+- this.moveControl.tick(); -+- this.lookControl.tick(); -+- this.jumpControl.tick(); -+- }, this::sendDebugPackets); -++ if (i % 2 != 0 && this.tickCount > 1) { -++ //this.level.getProfiler().push("targetSelector"); // Purpur -++ if (this.targetSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking -++ this.targetSelector.tickRunningGoals(false); -++ //this.level.getProfiler().pop(); // Purpur -++ //this.level.getProfiler().push("goalSelector"); // Purpur -++ if (this.goalSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking -++ this.goalSelector.tickRunningGoals(false); -++ //this.level.getProfiler().pop(); // Purpur -++ } else { -++ //this.level.getProfiler().push("targetSelector"); // Purpur -++ if (this.targetSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking -++ this.targetSelector.tick(); -++ //this.level.getProfiler().pop(); // Purpur -++ //this.level.getProfiler().push("goalSelector"); // Purpur -++ if (this.goalSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking -++ this.goalSelector.tick(); -++ //this.level.getProfiler().pop(); // Purpur -++ } -++ this.navigation.tick(); -++ this.customServerAiStep(); -++ this.moveControl.tick(); -++ this.lookControl.tick(); -++ this.jumpControl.tick(); -++ this.sendDebugPackets(); -+ } -+ -+ protected void sendDebugPackets() { -diff --git a/src/main/java/net/minecraft/world/level/entity/EntityTickList.java b/src/main/java/net/minecraft/world/level/entity/EntityTickList.java -index 57fcf3910f45ce371ac2e237b277b1034caaac4e..13f5950bfffe49ffc3b9e57b5f6f674c70ba5e80 100644 ---- a/src/main/java/net/minecraft/world/level/entity/EntityTickList.java -+++ b/src/main/java/net/minecraft/world/level/entity/EntityTickList.java -@@ -1,14 +1,18 @@ - package net.minecraft.world.level.entity; - -+import com.google.common.collect.Lists; - import it.unimi.dsi.fastutil.ints.Int2ObjectLinkedOpenHashMap; - import it.unimi.dsi.fastutil.ints.Int2ObjectMap; - import it.unimi.dsi.fastutil.ints.Int2ObjectMaps; -+ -+import java.util.Iterator; -+import java.util.List; - import java.util.function.Consumer; - import javax.annotation.Nullable; - import net.minecraft.world.entity.Entity; - - public class EntityTickList { -- public final io.papermc.paper.util.maplist.IteratorSafeOrderedReferenceSet entities = new io.papermc.paper.util.maplist.IteratorSafeOrderedReferenceSet<>(true); // Paper - rewrite this, always keep this updated - why would we EVER tick an entity that's not ticking? // Pufferfish - private->public -+ public final List entities = Lists.newCopyOnWriteArrayList(); - - private void ensureActiveIsNotIterated() { - // Paper - replace with better logic, do not delay removals -@@ -36,13 +40,9 @@ public class EntityTickList { - // Paper start - replace with better logic, do not delay removals/additions - // To ensure nothing weird happens with dimension travelling, do not iterate over new entries... - // (by dfl iterator() is configured to not iterate over new entries) -- io.papermc.paper.util.maplist.IteratorSafeOrderedReferenceSet.Iterator iterator = this.entities.iterator(); -- try { -- while (iterator.hasNext()) { -- action.accept(iterator.next()); -- } -- } finally { -- iterator.finishedIterating(); -+ Iterator iterator = this.entities.iterator(); -+ while (iterator.hasNext()) { -+ action.accept(iterator.next()); - } - // Paper end - replace with better logic, do not delay removals/additions - } -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 a8af51a25b0f99c3a64d9150fdfcd6b818aa7581..cd2592552339a79361d2a4e7936731330e15f6fa 100644 ---- a/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java -+++ b/src/main/java/net/minecraft/world/level/pathfinder/PathFinder.java -@@ -31,7 +31,7 @@ public class PathFinder { - } - - @Nullable -- public Path findPath(PathNavigationRegion world, Mob mob, Set positions, float followRange, int distance, float rangeMultiplier) { -+ public synchronized Path findPath(PathNavigationRegion world, Mob mob, Set positions, float followRange, int distance, float rangeMultiplier) { - this.openSet.clear(); - this.nodeEvaluator.prepare(world, mob); - Node node = this.nodeEvaluator.getStart(); diff --git a/patches/server/0046-MikuServer-Fix-some-issue-in-Entity-sensing-and-aiSt.patch b/patches/server/0046-MikuServer-Fix-some-issue-in-Entity-sensing-and-aiSt.patch deleted file mode 100644 index 0b739b8f..00000000 --- a/patches/server/0046-MikuServer-Fix-some-issue-in-Entity-sensing-and-aiSt.patch +++ /dev/null @@ -1,627 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: wangxyper -Date: Sat, 28 Jan 2023 12:23:31 +0800 -Subject: [PATCH] MikuServer: Fix some issue in Entity sensing and aiStep - -Original license: MIT -Original project: https://github.com/MikuMC/MikuServer - -diff --git a/src/main/java/co/m2ek4u/aoame/CallbackExecutor.java b/src/main/java/co/mikumc/mikuserver/concurrent/CallbackExecutor.java -similarity index 98% -rename from src/main/java/co/m2ek4u/aoame/CallbackExecutor.java -rename to src/main/java/co/mikumc/mikuserver/concurrent/CallbackExecutor.java -index b861405a7626ba8fa677c455bf6507253b33c157..678b389ef829bcda55ea06f5f19b96c81f78bd9b 100644 ---- a/src/main/java/co/m2ek4u/aoame/CallbackExecutor.java -+++ b/src/main/java/co/mikumc/mikuserver/concurrent/CallbackExecutor.java -@@ -1,4 +1,4 @@ --package co.m2ek4u.aoame; -+package co.mikumc.mikuserver.concurrent; - - import org.jetbrains.annotations.NotNull; - import java.util.Queue; -diff --git a/src/main/java/co/m2ek4u/aoame/AnotherTickThread.java b/src/main/java/co/mikumc/mikuserver/utils/AnotherTickThread.java -similarity index 87% -rename from src/main/java/co/m2ek4u/aoame/AnotherTickThread.java -rename to src/main/java/co/mikumc/mikuserver/utils/AnotherTickThread.java -index d5fe52beb25e7a95549cdf0ae19edf6029f10642..8dd4423fb1477c901e88c07537ca736eb4f9a8cc 100644 ---- a/src/main/java/co/m2ek4u/aoame/AnotherTickThread.java -+++ b/src/main/java/co/mikumc/mikuserver/utils/AnotherTickThread.java -@@ -1,4 +1,4 @@ --package co.m2ek4u.aoame; -+package co.mikumc.mikuserver.utils; - - import io.papermc.paper.util.TickThread; - -diff --git a/src/main/java/co/mikumc/mikuserver/utils/EntityPositionCache.java b/src/main/java/co/mikumc/mikuserver/utils/EntityPositionCache.java -new file mode 100644 -index 0000000000000000000000000000000000000000..245fd68d040a46f58bebbbebe11ab6fa2072f08b ---- /dev/null -+++ b/src/main/java/co/mikumc/mikuserver/utils/EntityPositionCache.java -@@ -0,0 +1,60 @@ -+package co.mikumc.mikuserver.utils; -+ -+import net.minecraft.world.entity.Entity; -+import net.minecraft.world.entity.LivingEntity; -+import net.minecraft.world.phys.Vec3; -+import org.jetbrains.annotations.NotNull; -+ -+public class EntityPositionCache { -+ private final double x; -+ private final double y; -+ private final double z; -+ private final LivingEntity currentEntity; -+ -+ public EntityPositionCache(@NotNull LivingEntity entity){ -+ this.x = entity.getX(); -+ this.y = entity.getY(); -+ this.z = entity.getZ(); -+ this.currentEntity = entity; -+ } -+ -+ public LivingEntity getCurrentEntity() { -+ return this.currentEntity; -+ } -+ -+ public double getX() { -+ return this.x; -+ } -+ -+ public double getY() { -+ return this.y; -+ } -+ -+ public double getZ() { -+ return this.z; -+ } -+ -+ public double distanceToSqr(double x, double y, double z) { -+ double d3 = this.x - x; -+ double d4 = this.y - y; -+ double d5 = this.z - z; -+ -+ return d3 * d3 + d4 * d4 + d5 * d5; -+ } -+ -+ public double distanceToSqr(Entity entity) { -+ return this.distanceToSqr(entity.position()); -+ } -+ -+ public double distanceToSqr(Vec3 vector) { -+ double d0 = this.x - vector.x; -+ double d1 = this.y - vector.y; -+ double d2 = this.z - vector.z; -+ -+ return d0 * d0 + d1 * d1 + d2 * d2; -+ } -+ -+ public double distanceToSqr(EntityPositionCache entityPositionCache) { -+ return this.distanceToSqr(entityPositionCache.getX(),entityPositionCache.getY(),entityPositionCache.getZ()); -+ } -+} -diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 9601de5775667c2d94e07b89bb7605b1e03d413d..28af12b2e670ab2a2d4dc96f340da49da0071737 100644 ---- a/src/main/java/net/minecraft/server/MinecraftServer.java -+++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -1,12 +1,9 @@ - package net.minecraft.server; - --import co.m2ek4u.aoame.AnotherTickThread; --import co.m2ek4u.aoame.CallbackExecutor; -+import co.mikumc.mikuserver.utils.AnotherTickThread; -+import co.mikumc.mikuserver.concurrent.CallbackExecutor; - import com.google.common.base.Splitter; - import com.google.common.collect.ImmutableList; --import co.aikar.timings.Timings; --import com.destroystokyo.paper.event.server.PaperServerListPingEvent; --import com.google.common.base.Stopwatch; - import com.google.common.collect.Lists; - import com.google.common.collect.Maps; - import com.google.common.collect.Sets; -@@ -86,7 +83,6 @@ import net.minecraft.server.level.ServerChunkCache; - import net.minecraft.server.level.ServerLevel; - import net.minecraft.server.level.ServerPlayer; - import net.minecraft.server.level.ServerPlayerGameMode; --import net.minecraft.server.level.TicketType; - import net.minecraft.server.level.progress.ChunkProgressListener; - import net.minecraft.server.level.progress.ChunkProgressListenerFactory; - import net.minecraft.server.network.ServerConnectionListener; -@@ -110,17 +106,14 @@ import net.minecraft.util.NativeModuleLister; - import net.minecraft.util.ProgressListener; - import net.minecraft.util.RandomSource; - import net.minecraft.util.SignatureValidator; --import net.minecraft.util.Unit; - import net.minecraft.util.datafix.DataFixers; - import net.minecraft.util.profiling.EmptyProfileResults; - import net.minecraft.util.profiling.ProfileResults; - 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; - import net.minecraft.util.profiling.jfr.callback.ProfiledDuration; - import net.minecraft.util.profiling.metrics.profiling.ActiveMetricsRecorder; --import net.minecraft.util.profiling.metrics.profiling.InactiveMetricsRecorder; - import net.minecraft.util.profiling.metrics.profiling.MetricsRecorder; - import net.minecraft.util.profiling.metrics.profiling.ServerMetricsSamplersProvider; - import net.minecraft.util.profiling.metrics.storage.MetricsPersister; -@@ -184,12 +177,6 @@ import net.minecraft.world.level.levelgen.PatrolSpawner; - import net.minecraft.world.level.levelgen.PhantomSpawner; - import net.minecraft.world.level.levelgen.WorldDimensions; - import net.minecraft.world.level.levelgen.presets.WorldPresets; --import org.bukkit.Bukkit; --import org.bukkit.craftbukkit.CraftServer; --import org.bukkit.craftbukkit.Main; --import org.bukkit.craftbukkit.util.CraftChatMessage; --import org.bukkit.craftbukkit.util.LazyPlayerSet; --import org.bukkit.event.player.AsyncPlayerChatPreviewEvent; - import org.bukkit.event.server.ServerLoadEvent; - // CraftBukkit end - -diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index 824f26db01750866a2d9bbeefe17457f84d19504..32ce19ff00d6a31b7dc994d3320ad967f96d4f61 100644 ---- a/src/main/java/net/minecraft/server/level/ServerLevel.java -+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java -@@ -1,6 +1,6 @@ - package net.minecraft.server.level; - --import co.m2ek4u.aoame.AnotherTickThread; -+import co.mikumc.mikuserver.utils.AnotherTickThread; - import com.google.common.annotations.VisibleForTesting; - import co.aikar.timings.TimingHistory; // Paper - import com.google.common.collect.Lists; -@@ -51,7 +51,6 @@ import net.minecraft.core.particles.ParticleOptions; - import net.minecraft.core.registries.BuiltInRegistries; - import net.minecraft.core.registries.Registries; - import net.minecraft.network.chat.Component; --import net.minecraft.network.chat.MutableComponent; - import net.minecraft.network.protocol.Packet; - import net.minecraft.network.protocol.game.ClientboundBlockDestructionPacket; - import net.minecraft.network.protocol.game.ClientboundBlockEventPacket; -@@ -77,7 +76,6 @@ import net.minecraft.util.CsvOutput; - import net.minecraft.util.Mth; - import net.minecraft.util.ProgressListener; - import net.minecraft.util.Unit; --import net.minecraft.util.profiling.ProfilerFiller; - import net.minecraft.world.DifficultyInstance; - import net.minecraft.world.damagesource.DamageSource; - import net.minecraft.world.entity.Entity; -@@ -129,12 +127,10 @@ import net.minecraft.world.level.chunk.storage.EntityStorage; - import net.minecraft.world.level.dimension.BuiltinDimensionTypes; - import net.minecraft.world.level.dimension.LevelStem; - import net.minecraft.world.level.dimension.end.EndDragonFight; --import net.minecraft.world.level.entity.EntityPersistentStorage; - import net.minecraft.world.level.entity.EntityTickList; - import net.minecraft.world.level.entity.EntityTypeTest; - import net.minecraft.world.level.entity.LevelCallback; - import net.minecraft.world.level.entity.LevelEntityGetter; --import net.minecraft.world.level.entity.PersistentEntitySectionManager; - import net.minecraft.world.level.gameevent.DynamicGameEventListener; - import net.minecraft.world.level.gameevent.GameEvent; - import net.minecraft.world.level.gameevent.GameEventDispatcher; -@@ -161,16 +157,13 @@ import net.minecraft.world.phys.shapes.VoxelShape; - import net.minecraft.world.ticks.LevelTicks; - import org.slf4j.Logger; - import org.bukkit.Bukkit; --import org.bukkit.Location; - import org.bukkit.WeatherType; - import org.bukkit.craftbukkit.event.CraftEventFactory; - import org.bukkit.craftbukkit.generator.CustomWorldChunkManager; --import org.bukkit.craftbukkit.util.CraftNamespacedKey; - import org.bukkit.craftbukkit.util.WorldUUID; - import org.bukkit.event.entity.CreatureSpawnEvent; - import org.bukkit.event.server.MapInitializeEvent; - import org.bukkit.event.weather.LightningStrikeEvent; --import org.bukkit.event.world.GenericGameEvent; - import org.bukkit.event.world.TimeSkipEvent; - // CraftBukkit end - import it.unimi.dsi.fastutil.ints.IntArrayList; // Paper -@@ -994,7 +987,7 @@ public class ServerLevel extends Level implements WorldGenLevel { - if (this.canSleepThroughNights()) { - if (!this.getServer().isSingleplayer() || this.getServer().isPublished()) { - int i = this.getGameRules().getInt(GameRules.RULE_PLAYERS_SLEEPING_PERCENTAGE); -- MutableComponent ichatmutablecomponent; -+ Component ichatmutablecomponent; - - if (this.sleepStatus.areEnoughSleeping(i)) { - ichatmutablecomponent = Component.translatable("sleep.skipping_night"); -diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index f5aff6d724185e1ada8736bdb6dd12b143812e83..cb5a4e6a071977fcf82b6b0384735a4bec3564fc 100644 ---- a/src/main/java/net/minecraft/world/entity/LivingEntity.java -+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -3029,7 +3029,13 @@ public abstract class LivingEntity extends Entity { - } - - if (!this.isRemoved()) { -- MinecraftServer.getServer().asyncExecutor.executeWithCallBack(this::aiStep,()->{}); -+ //MikuServer start --async AI -+ if(this instanceof net.minecraft.world.entity.player.Player){ -+ this.aiStep(); //Skip player -+ }else { -+ MinecraftServer.getServer().asyncExecutor.executeWithCallBack(this::aiStep,()->{}); -+ } -+ //MikuServer end - } - - double d0 = this.getX() - this.xo; -@@ -3406,9 +3412,11 @@ public abstract class LivingEntity extends Entity { - this.jumpInLiquid(FluidTags.LAVA); - } else if ((this.onGround || flag && d7 <= d8) && this.noJumpDelay == 0) { - if (new com.destroystokyo.paper.event.entity.EntityJumpEvent(getBukkitLivingEntity()).callEvent()) { // Paper -- this.jumpFromGround(); -- this.noJumpDelay = 10; -- } else { this.setJumping(false); } // Paper - setJumping(false) stops a potential loop -+ this.jumpFromGround(); -+ this.noJumpDelay = 10; -+ } else { -+ this.setJumping(false); -+ } // Paper - setJumping(false) stops a potential loop - } - } else { - this.noJumpDelay = 0; -@@ -3421,102 +3429,51 @@ public abstract class LivingEntity extends Entity { - this.updateFallFlying(); - AABB axisalignedbb = this.getBoundingBox(); - -- if (this instanceof net.minecraft.world.entity.player.Player) { -- // SpigotTimings.timerEntityAIMove.startTiming(); // Spigot // Paper -- this.travel(new Vec3((double) this.xxa, (double) this.yya, (double) this.zza)); -- // SpigotTimings.timerEntityAIMove.stopTiming(); // Spigot // Paper -- //this.level.getProfiler().pop(); // Purpur -- //this.level.getProfiler().push("freezing"); // Purpur -- boolean flag1 = this.getType().is(EntityTypeTags.FREEZE_HURTS_EXTRA_TYPES); -- int i; -+ // SpigotTimings.timerEntityAIMove.startTiming(); // Spigot // Paper -+ this.travel(new Vec3((double) this.xxa, (double) this.yya, (double) this.zza)); -+ // SpigotTimings.timerEntityAIMove.stopTiming(); // Spigot // Paper -+ //this.level.getProfiler().pop(); // Purpur -+ //this.level.getProfiler().push("freezing"); // Purpur -+ boolean flag1 = this.getType().is(EntityTypeTags.FREEZE_HURTS_EXTRA_TYPES); -+ int i; - -- if (!this.level.isClientSide && !this.isDeadOrDying() && !freezeLocked) { // Paper - Freeze Tick Lock API -- i = this.getTicksFrozen(); -- if (this.isInPowderSnow && this.canFreeze()) { -- this.setTicksFrozen(Math.min(this.getTicksRequiredToFreeze(), i + 1)); -- } else { -- this.setTicksFrozen(Math.max(0, i - 2)); -- } -+ if (!this.level.isClientSide && !this.isDeadOrDying() && !freezeLocked) { // Paper - Freeze Tick Lock API -+ i = this.getTicksFrozen(); -+ if (this.isInPowderSnow && this.canFreeze()) { -+ this.setTicksFrozen(Math.min(this.getTicksRequiredToFreeze(), i + 1)); -+ } else { -+ this.setTicksFrozen(Math.max(0, i - 2)); - } -+ } - -- this.removeFrost(); -- this.tryAddFrost(); -- if (!this.level.isClientSide && this.tickCount % 40 == 0 && this.isFullyFrozen() && this.canFreeze()) { -- i = flag1 ? 5 : 1; -- this.hurt(DamageSource.FREEZE, (float) i); -- } -+ this.removeFrost(); -+ this.tryAddFrost(); -+ if (!this.level.isClientSide && this.tickCount % 40 == 0 && this.isFullyFrozen() && this.canFreeze()) { -+ i = flag1 ? 5 : 1; -+ this.hurt(DamageSource.FREEZE, (float) i); -+ } - -- //this.level.getProfiler().pop(); // Purpur -- //this.level.getProfiler().push("push"); // Purpur -- if (this.autoSpinAttackTicks > 0) { -- --this.autoSpinAttackTicks; -- this.checkAutoSpinAttack(axisalignedbb, this.getBoundingBox()); -- } -+ //this.level.getProfiler().pop(); // Purpur -+ //this.level.getProfiler().push("push"); // Purpur -+ if (this.autoSpinAttackTicks > 0) { -+ --this.autoSpinAttackTicks; -+ this.checkAutoSpinAttack(axisalignedbb, this.getBoundingBox()); -+ } - -- this.pushEntities(); -- //this.level.getProfiler().pop(); // Purpur -- // Paper start -- if (((ServerLevel) this.level).hasEntityMoveEvent && !(this instanceof net.minecraft.world.entity.player.Player)) { -- if (this.xo != getX() || this.yo != this.getY() || this.zo != this.getZ() || this.yRotO != this.getYRot() || this.xRotO != this.getXRot()) { -- Location from = new Location(this.level.getWorld(), this.xo, this.yo, this.zo, this.yRotO, this.xRotO); -- Location to = new Location(this.level.getWorld(), this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot()); -- io.papermc.paper.event.entity.EntityMoveEvent event = new io.papermc.paper.event.entity.EntityMoveEvent(this.getBukkitLivingEntity(), from, to.clone()); -- if (!event.callEvent()) { -- absMoveTo(from.getX(), from.getY(), from.getZ(), from.getYaw(), from.getPitch()); -- } else if (!to.equals(event.getTo())) { -- absMoveTo(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ(), event.getTo().getYaw(), event.getTo().getPitch()); -- } -+ this.pushEntities(); -+ //this.level.getProfiler().pop(); // Purpur -+ // Paper start -+ if (((ServerLevel) this.level).hasEntityMoveEvent && !(this instanceof net.minecraft.world.entity.player.Player)) { -+ if (this.xo != getX() || this.yo != this.getY() || this.zo != this.getZ() || this.yRotO != this.getYRot() || this.xRotO != this.getXRot()) { -+ Location from = new Location(this.level.getWorld(), this.xo, this.yo, this.zo, this.yRotO, this.xRotO); -+ Location to = new Location(this.level.getWorld(), this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot()); -+ io.papermc.paper.event.entity.EntityMoveEvent event = new io.papermc.paper.event.entity.EntityMoveEvent(this.getBukkitLivingEntity(), from, to.clone()); -+ if (!event.callEvent()) { -+ absMoveTo(from.getX(), from.getY(), from.getZ(), from.getYaw(), from.getPitch()); -+ } else if (!to.equals(event.getTo())) { -+ absMoveTo(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ(), event.getTo().getYaw(), event.getTo().getPitch()); - } - } -- } else { -- MinecraftServer.getServer().asyncExecutor.executeWithCallBack(() -> { -- // SpigotTimings.timerEntityAIMove.startTiming(); // Spigot // Paper -- this.travel(new Vec3((double) this.xxa, (double) this.yya, (double) this.zza)); -- // SpigotTimings.timerEntityAIMove.stopTiming(); // Spigot // Paper -- //this.level.getProfiler().pop(); // Purpur -- //this.level.getProfiler().push("freezing"); // Purpur -- boolean flag1 = this.getType().is(EntityTypeTags.FREEZE_HURTS_EXTRA_TYPES); -- int i; -- -- if (!this.level.isClientSide && !this.isDeadOrDying() && !freezeLocked) { // Paper - Freeze Tick Lock API -- i = this.getTicksFrozen(); -- if (this.isInPowderSnow && this.canFreeze()) { -- this.setTicksFrozen(Math.min(this.getTicksRequiredToFreeze(), i + 1)); -- } else { -- this.setTicksFrozen(Math.max(0, i - 2)); -- } -- } -- -- this.removeFrost(); -- this.tryAddFrost(); -- if (!this.level.isClientSide && this.tickCount % 40 == 0 && this.isFullyFrozen() && this.canFreeze()) { -- i = flag1 ? 5 : 1; -- this.hurt(DamageSource.FREEZE, (float) i); -- } -- -- //this.level.getProfiler().pop(); // Purpur -- //this.level.getProfiler().push("push"); // Purpur -- if (this.autoSpinAttackTicks > 0) { -- --this.autoSpinAttackTicks; -- this.checkAutoSpinAttack(axisalignedbb, this.getBoundingBox()); -- } -- -- this.pushEntities(); -- //this.level.getProfiler().pop(); // Purpur -- }, () -> { -- if (((ServerLevel) this.level).hasEntityMoveEvent && !(this instanceof net.minecraft.world.entity.player.Player)) { -- if (this.xo != getX() || this.yo != this.getY() || this.zo != this.getZ() || this.yRotO != this.getYRot() || this.xRotO != this.getXRot()) { -- Location from = new Location(this.level.getWorld(), this.xo, this.yo, this.zo, this.yRotO, this.xRotO); -- Location to = new Location(this.level.getWorld(), this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot()); -- io.papermc.paper.event.entity.EntityMoveEvent event = new io.papermc.paper.event.entity.EntityMoveEvent(this.getBukkitLivingEntity(), from, to.clone()); -- if (!event.callEvent()) { -- absMoveTo(from.getX(), from.getY(), from.getZ(), from.getYaw(), from.getPitch()); -- } else if (!to.equals(event.getTo())) { -- absMoveTo(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ(), event.getTo().getYaw(), event.getTo().getPitch()); -- } -- } -- } -- }); - } - // Paper end - if (!this.level.isClientSide && this.isSensitiveToWater() && this.isInWaterRainOrBubble()) { -diff --git a/src/main/java/net/minecraft/world/entity/Mob.java.rej b/src/main/java/net/minecraft/world/entity/Mob.java.rej -deleted file mode 100644 -index 68eddcd9c30a0b4ab690fc54de481847107cef00..0000000000000000000000000000000000000000 ---- a/src/main/java/net/minecraft/world/entity/Mob.java.rej -+++ /dev/null -@@ -1,59 +0,0 @@ --diff a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java (rejected hunks) --@@ -910,32 +910,31 @@ public abstract class Mob extends LivingEntity { -- //this.level.getProfiler().pop(); // Purpur -- int i = this.level.getServer().getTickCount() + this.getId(); -- --- MinecraftServer.getServer().asyncExecutor.executeWithCallBack(()->{ --- if (i % 2 != 0 && this.tickCount > 1) { --- //this.level.getProfiler().push("targetSelector"); // Purpur --- if (this.targetSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking --- this.targetSelector.tickRunningGoals(false); --- //this.level.getProfiler().pop(); // Purpur --- //this.level.getProfiler().push("goalSelector"); // Purpur --- if (this.goalSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking --- this.goalSelector.tickRunningGoals(false); --- //this.level.getProfiler().pop(); // Purpur --- } else { --- //this.level.getProfiler().push("targetSelector"); // Purpur --- if (this.targetSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking --- this.targetSelector.tick(); --- //this.level.getProfiler().pop(); // Purpur --- //this.level.getProfiler().push("goalSelector"); // Purpur --- if (this.goalSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking --- this.goalSelector.tick(); --- //this.level.getProfiler().pop(); // Purpur --- } --- this.navigation.tick(); --- this.customServerAiStep(); --- this.moveControl.tick(); --- this.lookControl.tick(); --- this.jumpControl.tick(); --- }, this::sendDebugPackets); --+ if (i % 2 != 0 && this.tickCount > 1) { --+ //this.level.getProfiler().push("targetSelector"); // Purpur --+ if (this.targetSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking --+ this.targetSelector.tickRunningGoals(false); --+ //this.level.getProfiler().pop(); // Purpur --+ //this.level.getProfiler().push("goalSelector"); // Purpur --+ if (this.goalSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking --+ this.goalSelector.tickRunningGoals(false); --+ //this.level.getProfiler().pop(); // Purpur --+ } else { --+ //this.level.getProfiler().push("targetSelector"); // Purpur --+ if (this.targetSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking --+ this.targetSelector.tick(); --+ //this.level.getProfiler().pop(); // Purpur --+ //this.level.getProfiler().push("goalSelector"); // Purpur --+ if (this.goalSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking --+ this.goalSelector.tick(); --+ //this.level.getProfiler().pop(); // Purpur --+ } --+ this.navigation.tick(); --+ this.customServerAiStep(); --+ this.moveControl.tick(); --+ this.lookControl.tick(); --+ this.jumpControl.tick(); --+ this.sendDebugPackets(); -- } -- -- protected void sendDebugPackets() { -diff --git a/src/main/java/net/minecraft/world/entity/ai/sensing/NearestLivingEntitySensor.java b/src/main/java/net/minecraft/world/entity/ai/sensing/NearestLivingEntitySensor.java -index d8cf99a3014a4b8152ae819fa663c2fdf34dce57..e14d02c04dde5030c0dff3faea9294c87c40910d 100644 ---- a/src/main/java/net/minecraft/world/entity/ai/sensing/NearestLivingEntitySensor.java -+++ b/src/main/java/net/minecraft/world/entity/ai/sensing/NearestLivingEntitySensor.java -@@ -1,9 +1,13 @@ - package net.minecraft.world.entity.ai.sensing; -- -+import co.mikumc.mikuserver.utils.EntityPositionCache; - import com.google.common.collect.ImmutableSet; - import java.util.Comparator; - import java.util.List; - import java.util.Set; -+import java.util.concurrent.atomic.AtomicBoolean; -+import com.google.common.collect.Lists; -+import it.unimi.dsi.fastutil.objects.ObjectArrayList; -+import it.unimi.dsi.fastutil.objects.ObjectLists; - import net.minecraft.server.level.ServerLevel; - import net.minecraft.world.entity.LivingEntity; - import net.minecraft.world.entity.ai.Brain; -@@ -12,16 +16,29 @@ import net.minecraft.world.entity.ai.memory.NearestVisibleLivingEntities; - import net.minecraft.world.phys.AABB; - - public class NearestLivingEntitySensor extends Sensor { -+ private final List entitiesCache = ObjectLists.synchronize(new ObjectArrayList<>()); -+ private final AtomicBoolean calling = new AtomicBoolean(false); -+ - @Override - protected void doTick(ServerLevel world, T entity) { -- AABB aABB = entity.getBoundingBox().inflate((double)this.radiusXZ(), (double)this.radiusY(), (double)this.radiusXZ()); -- List list = world.getEntitiesOfClass(LivingEntity.class, aABB, (e) -> { -- return e != entity && e.isAlive(); -- }); -- list.sort(Comparator.comparingDouble(entity::distanceToSqr)); -- Brain brain = entity.getBrain(); -- brain.setMemory(MemoryModuleType.NEAREST_LIVING_ENTITIES, list); -- brain.setMemory(MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, new NearestVisibleLivingEntities(entity, list)); -+ if (!this.calling.get()){ -+ this.calling.set(true); -+ try { -+ AABB aABB = entity.getBoundingBox().inflate(this.radiusXZ(), this.radiusY(), this.radiusXZ()); -+ this.entitiesCache.clear(); -+ this.entitiesCache.addAll(world.getEntitiesOfClass(LivingEntity.class, aABB, (e) -> e != entity && e.isAlive()).stream().map(EntityPositionCache::new).toList()); -+ final EntityPositionCache compareCache = new EntityPositionCache(entity); -+ this.entitiesCache.sort(Comparator.comparingDouble(compareCache::distanceToSqr)); -+ -+ Brain brain = entity.getBrain(); -+ final List list = Lists.newCopyOnWriteArrayList(); -+ list.addAll(this.entitiesCache.stream().map(EntityPositionCache::getCurrentEntity).toList()); -+ brain.setMemory(MemoryModuleType.NEAREST_LIVING_ENTITIES,list); -+ brain.setMemory(MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, new NearestVisibleLivingEntities(entity, list)); -+ }finally { -+ this.calling.set(false); -+ } -+ } - } - - protected int radiusXZ() { -diff --git a/src/main/java/net/minecraft/world/entity/ai/sensing/PlayerSensor.java b/src/main/java/net/minecraft/world/entity/ai/sensing/PlayerSensor.java -index 75d9c4f011b5a97def215784c92bb57bbb35d06b..2a3d5085b47824c310cfaa5feec3a50965f804b0 100644 ---- a/src/main/java/net/minecraft/world/entity/ai/sensing/PlayerSensor.java -+++ b/src/main/java/net/minecraft/world/entity/ai/sensing/PlayerSensor.java -@@ -1,11 +1,11 @@ - package net.minecraft.world.entity.ai.sensing; - -+import co.mikumc.mikuserver.utils.EntityPositionCache; - import com.google.common.collect.ImmutableSet; --import java.util.Comparator; --import java.util.List; --import java.util.Optional; --import java.util.Set; --import java.util.stream.Collectors; -+import java.util.*; -+import java.util.concurrent.atomic.AtomicBoolean; -+import it.unimi.dsi.fastutil.objects.ObjectArrayList; -+import it.unimi.dsi.fastutil.objects.ObjectLists; - import net.minecraft.server.level.ServerLevel; - import net.minecraft.world.entity.EntitySelector; - import net.minecraft.world.entity.LivingEntity; -@@ -14,6 +14,9 @@ import net.minecraft.world.entity.ai.memory.MemoryModuleType; - import net.minecraft.world.entity.player.Player; - - public class PlayerSensor extends Sensor { -+ private final List playerList = ObjectLists.synchronize(new ObjectArrayList<>()); -+ private final AtomicBoolean calling = new AtomicBoolean(); -+ - @Override - public Set> requires() { - return ImmutableSet.of(MemoryModuleType.NEAREST_PLAYERS, MemoryModuleType.NEAREST_VISIBLE_PLAYER, MemoryModuleType.NEAREST_VISIBLE_ATTACKABLE_PLAYER); -@@ -21,30 +24,51 @@ public class PlayerSensor extends Sensor { - - @Override - protected void doTick(ServerLevel world, LivingEntity entity) { -- // Paper start - remove streams -- List players = (List)world.getNearbyPlayers(entity, entity.getX(), entity.getY(), entity.getZ(), 16.0D, EntitySelector.NO_SPECTATORS); -- players.sort((e1, e2) -> Double.compare(entity.distanceToSqr(e1), entity.distanceToSqr(e2))); -- Brain brain = entity.getBrain(); -- -- brain.setMemory(MemoryModuleType.NEAREST_PLAYERS, players); -- -- Player firstTargetable = null; -- Player firstAttackable = null; -- for (int index = 0, len = players.size(); index < len; ++index) { -- Player player = players.get(index); -- if (firstTargetable == null && isEntityTargetable(entity, player)) { -- firstTargetable = player; -- } -- if (firstAttackable == null && isEntityAttackable(entity, player)) { -- firstAttackable = player; -- } -+ if (this.calling.get()){ -+ return; -+ } -+ -+ this.calling.set(true); -+ try { -+ // Paper start - remove streams -+ List playersPosCaches = new ArrayList<>(List.of(world -+ .getNearbyPlayers(entity, entity.getX(), entity.getY(), entity.getZ(), 16.0D, EntitySelector.NO_SPECTATORS) -+ .stream() -+ .map(EntityPositionCache::new) -+ .toArray(EntityPositionCache[]::new))); -+ -+ final EntityPositionCache entityPositionCache = new EntityPositionCache(entity); -+ -+ playersPosCaches.sort(Comparator.comparingDouble(entityPositionCache::distanceToSqr)); -+ -+ final List players = playersPosCaches -+ .stream() -+ .map(cache -> ((Player) cache.getCurrentEntity())) -+ .toList(); -+ -+ Brain brain = entity.getBrain(); -+ -+ brain.setMemory(MemoryModuleType.NEAREST_PLAYERS, players); -+ -+ Player firstTargetable = null; -+ Player firstAttackable = null; -+ for (Player player : players) { -+ if (firstTargetable == null && isEntityTargetable(entity, player)) { -+ firstTargetable = player; -+ } -+ if (firstAttackable == null && isEntityAttackable(entity, player)) { -+ firstAttackable = player; -+ } - -- if (firstAttackable != null && firstTargetable != null) { -- break; -+ if (firstAttackable != null && firstTargetable != null) { -+ break; -+ } - } -+ brain.setMemory(MemoryModuleType.NEAREST_VISIBLE_PLAYER, firstTargetable); -+ brain.setMemory(MemoryModuleType.NEAREST_VISIBLE_ATTACKABLE_PLAYER, Optional.ofNullable(firstAttackable)); -+ // Paper end - remove streams -+ }finally { -+ this.calling.set(false); - } -- brain.setMemory(MemoryModuleType.NEAREST_VISIBLE_PLAYER, firstTargetable); -- brain.setMemory(MemoryModuleType.NEAREST_VISIBLE_ATTACKABLE_PLAYER, Optional.ofNullable(firstAttackable)); -- // Paper end - remove streams - } - } diff --git a/patches/server/0047-MikuServer-Refactor-and-fix-a-CME-in-Gossip.patch b/patches/server/0047-MikuServer-Refactor-and-fix-a-CME-in-Gossip.patch deleted file mode 100644 index 8315a9d9..00000000 --- a/patches/server/0047-MikuServer-Refactor-and-fix-a-CME-in-Gossip.patch +++ /dev/null @@ -1,195 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: wangxyper -Date: Sat, 28 Jan 2023 12:47:47 +0800 -Subject: [PATCH] MikuServer: Refactor and fix a CME in Gossip - -Original license: MIT -Original project: https://github.com/MikuMC/MikuServer - -diff --git a/src/main/java/co/mikumc/mikuserver/PublicConstants.java b/src/main/java/co/mikumc/mikuserver/PublicConstants.java -new file mode 100644 -index 0000000000000000000000000000000000000000..c6da0ce6b7181d3fb9b6ea8c2a600741d92e8f18 ---- /dev/null -+++ b/src/main/java/co/mikumc/mikuserver/PublicConstants.java -@@ -0,0 +1,24 @@ -+package co.mikumc.mikuserver; -+ -+import co.mikumc.mikuserver.concurrent.CallbackExecutor; -+import co.mikumc.mikuserver.utils.AnotherTickThread; -+ -+import java.util.concurrent.LinkedBlockingQueue; -+import java.util.concurrent.TimeUnit; -+import java.util.concurrent.atomic.AtomicInteger; -+ -+public class PublicConstants { -+ public static final AtomicInteger threadId = new AtomicInteger(); -+ public static final CallbackExecutor asyncExecutor = new CallbackExecutor( -+ Runtime.getRuntime().availableProcessors(), -+ Runtime.getRuntime().availableProcessors(), -+ 50, -+ TimeUnit.MILLISECONDS, -+ new LinkedBlockingQueue<>(), -+ task -> { -+ AnotherTickThread worker = new AnotherTickThread(task,"MikuServer-Async-Worker # "+threadId.getAndIncrement()); -+ worker.setDaemon(true); -+ return worker; -+ } -+ ); -+} -diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 28af12b2e670ab2a2d4dc96f340da49da0071737..76bc84864c306ff14c28312d9a0e923e8589ebe0 100644 ---- a/src/main/java/net/minecraft/server/MinecraftServer.java -+++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -1,7 +1,6 @@ - package net.minecraft.server; - --import co.mikumc.mikuserver.utils.AnotherTickThread; --import co.mikumc.mikuserver.concurrent.CallbackExecutor; -+import co.mikumc.mikuserver.PublicConstants; - import com.google.common.base.Splitter; - import com.google.common.collect.ImmutableList; - import com.google.common.collect.Lists; -@@ -41,7 +40,6 @@ import java.util.Objects; - import java.util.Optional; - import java.util.Set; - import java.util.concurrent.*; --import java.util.concurrent.atomic.AtomicInteger; - import java.util.concurrent.atomic.AtomicReference; - import java.util.function.BooleanSupplier; - import java.util.function.Consumer; -@@ -271,21 +269,6 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop(), -- task -> { -- AnotherTickThread worker = new AnotherTickThread(task,"Entity-Async-Worker # "+threadId.getAndIncrement()); -- worker.setDaemon(true); -- return worker; -- } -- ); -- - // CraftBukkit start - public final WorldLoader.DataLoadContext worldLoader; - public org.bukkit.craftbukkit.CraftServer server; -@@ -1390,8 +1373,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop= 5000000000L) { - this.lastServerStatus = i; -diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index cb5a4e6a071977fcf82b6b0384735a4bec3564fc..3aac9b26d5e94b4c3cf8951f0806458be0920c57 100644 ---- a/src/main/java/net/minecraft/world/entity/LivingEntity.java -+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -1,5 +1,6 @@ - package net.minecraft.world.entity; - -+import co.mikumc.mikuserver.PublicConstants; - import com.destroystokyo.paper.event.player.PlayerArmorChangeEvent; // Paper - import com.google.common.base.Objects; - import com.google.common.collect.ImmutableList; -@@ -44,7 +45,6 @@ import net.minecraft.network.syncher.EntityDataAccessor; - import net.minecraft.network.syncher.EntityDataSerializers; - import net.minecraft.network.syncher.SynchedEntityData; - import net.minecraft.resources.ResourceLocation; --import net.minecraft.server.MinecraftServer; - import net.minecraft.server.level.ServerChunkCache; - import net.minecraft.server.level.ServerLevel; - import net.minecraft.server.level.ServerPlayer; -@@ -3033,7 +3033,7 @@ public abstract class LivingEntity extends Entity { - if(this instanceof net.minecraft.world.entity.player.Player){ - this.aiStep(); //Skip player - }else { -- MinecraftServer.getServer().asyncExecutor.executeWithCallBack(this::aiStep,()->{}); -+ PublicConstants.asyncExecutor.executeWithCallBack(this::aiStep,()->{}); - } - //MikuServer end - } -diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java -index ed645b74bfc6e3cffe75cb4e30277cd5e98ca9c1..70800e37d8d89fda17adefc6e1cb470413b24864 100644 ---- a/src/main/java/net/minecraft/world/entity/Mob.java -+++ b/src/main/java/net/minecraft/world/entity/Mob.java -@@ -1,5 +1,6 @@ - package net.minecraft.world.entity; - -+import co.mikumc.mikuserver.PublicConstants; - import com.google.common.collect.Maps; - import java.util.Arrays; - import java.util.Iterator; -@@ -23,7 +24,6 @@ import net.minecraft.network.syncher.EntityDataAccessor; - import net.minecraft.network.syncher.EntityDataSerializers; - import net.minecraft.network.syncher.SynchedEntityData; - import net.minecraft.resources.ResourceLocation; --import net.minecraft.server.MinecraftServer; - import net.minecraft.server.level.ServerLevel; - import net.minecraft.server.level.ServerPlayer; - import net.minecraft.sounds.SoundEvent; -@@ -217,7 +217,7 @@ public abstract class Mob extends LivingEntity { - public void inactiveTick() { - super.inactiveTick(); - boolean isThrottled = gg.pufferfish.pufferfish.PufferfishConfig.throttleInactiveGoalSelectorTick && _pufferfish_inactiveTickDisableCounter++ % 20 != 0; // Pufferfish - throttle inactive goal selector ticking -- MinecraftServer.getServer().asyncExecutor.executeWithCallBack(()->{ -+ PublicConstants.asyncExecutor.executeWithCallBack(()->{ - if (this.goalSelector.inactiveTick(this.activatedPriority, true) && !isThrottled) { // Pufferfish - pass activated priroity // Pufferfish - throttle inactive goal selector ticking - this.goalSelector.tick(); - } -diff --git a/src/main/java/net/minecraft/world/entity/ai/gossip/GossipContainer.java b/src/main/java/net/minecraft/world/entity/ai/gossip/GossipContainer.java -index 097007c1c25ba55d9916fc820dd1d1149d81f6f4..16eec12db529dd513e0971289a9326652369de58 100644 ---- a/src/main/java/net/minecraft/world/entity/ai/gossip/GossipContainer.java -+++ b/src/main/java/net/minecraft/world/entity/ai/gossip/GossipContainer.java -@@ -30,11 +30,11 @@ import org.slf4j.Logger; - public class GossipContainer { - private static final Logger LOGGER = LogUtils.getLogger(); - public static final int DISCARD_THRESHOLD = 2; -- public final Map gossips = Maps.newHashMap(); -+ public final Map gossips = Maps.newConcurrentMap(); - - @VisibleForDebug - public Map> getGossipEntries() { -- Map> map = Maps.newHashMap(); -+ Map> map = Maps.newConcurrentMap(); - this.gossips.keySet().forEach((uuid) -> { - GossipContainer.EntityGossips entityGossips = this.gossips.get(uuid); - map.put(uuid, entityGossips.entries); -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 eb5257fabef397566e784247922fb27e61f96313..69da89c25d23f071497eca9f26cd0fbc404035f5 100644 ---- a/src/main/java/net/minecraft/world/entity/npc/Villager.java -+++ b/src/main/java/net/minecraft/world/entity/npc/Villager.java -@@ -1,5 +1,6 @@ - package net.minecraft.world.entity.npc; - -+import co.mikumc.mikuserver.PublicConstants; - import com.google.common.annotations.VisibleForTesting; - import com.google.common.collect.ImmutableList; - import com.google.common.collect.ImmutableMap; -@@ -274,7 +275,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler - if (this.getUnhappyCounter() > 0) { - this.setUnhappyCounter(this.getUnhappyCounter() - 1); - } -- MinecraftServer.getServer().asyncExecutor.executeWithCallBack(()->{ -+ PublicConstants.asyncExecutor.executeWithCallBack(()->{ - if (this.isEffectiveAi()) { - if (level.spigotConfig.tickInactiveVillagers) { - this.customServerAiStep(); diff --git a/patches/server/0048-MikuServer-Add-shutdown-hook-to-async-executor-and-r.patch b/patches/server/0048-MikuServer-Add-shutdown-hook-to-async-executor-and-r.patch deleted file mode 100644 index f0797c73..00000000 --- a/patches/server/0048-MikuServer-Add-shutdown-hook-to-async-executor-and-r.patch +++ /dev/null @@ -1,53 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: wangxyper -Date: Sat, 28 Jan 2023 12:51:08 +0800 -Subject: [PATCH] MikuServer: Add shutdown hook to async executor and refactor - thread id counter - -Original license: MIT -Original project: https://github.com/MikuMC/MikuServer - -diff --git a/src/main/java/co/mikumc/mikuserver/PublicConstants.java b/src/main/java/co/mikumc/mikuserver/PublicConstants.java -index c6da0ce6b7181d3fb9b6ea8c2a600741d92e8f18..3f2e2e2be1d53b9257f99fb19a50491efc629925 100644 ---- a/src/main/java/co/mikumc/mikuserver/PublicConstants.java -+++ b/src/main/java/co/mikumc/mikuserver/PublicConstants.java -@@ -8,17 +8,22 @@ import java.util.concurrent.TimeUnit; - import java.util.concurrent.atomic.AtomicInteger; - - public class PublicConstants { -- public static final AtomicInteger threadId = new AtomicInteger(); -+ private static final AtomicInteger asyncWorkerThreadIdCounter = new AtomicInteger(); - public static final CallbackExecutor asyncExecutor = new CallbackExecutor( - Runtime.getRuntime().availableProcessors(), - Runtime.getRuntime().availableProcessors(), - 50, - TimeUnit.MILLISECONDS, - new LinkedBlockingQueue<>(), -- task -> { -- AnotherTickThread worker = new AnotherTickThread(task,"MikuServer-Async-Worker # "+threadId.getAndIncrement()); -- worker.setDaemon(true); -- return worker; -- } -+ task -> new AnotherTickThread(task,"MikuServer-Async-Worker # "+ asyncWorkerThreadIdCounter.getAndIncrement()) - ); -+ -+ static { -+ Runtime.getRuntime().addShutdownHook(new Thread(()->{ -+ if (asyncExecutor.isSubmittingStarted()){ -+ asyncExecutor.stopSubmitting(); -+ } -+ asyncExecutor.shutdownNow(); -+ })); -+ } - } -diff --git a/src/main/java/co/mikumc/mikuserver/utils/AnotherTickThread.java b/src/main/java/co/mikumc/mikuserver/utils/AnotherTickThread.java -index 8dd4423fb1477c901e88c07537ca736eb4f9a8cc..b3ea36c67e9eb5dafd1c7ff5abdf1233dfbd562b 100644 ---- a/src/main/java/co/mikumc/mikuserver/utils/AnotherTickThread.java -+++ b/src/main/java/co/mikumc/mikuserver/utils/AnotherTickThread.java -@@ -9,5 +9,6 @@ public class AnotherTickThread extends TickThread { - - public AnotherTickThread(Runnable run, String name) { - super(run, name); -+ this.setPriority(Thread.NORM_PRIORITY - 2); - } - } diff --git a/patches/server/0049-MikuServer-Fix-threading-issue-in-event-system.patch b/patches/server/0049-MikuServer-Fix-threading-issue-in-event-system.patch deleted file mode 100644 index 39ba20f5..00000000 --- a/patches/server/0049-MikuServer-Fix-threading-issue-in-event-system.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: wangxyper -Date: Sat, 28 Jan 2023 13:05:12 +0800 -Subject: [PATCH] MikuServer: Fix threading issue in event system - -Original license: MIT -Original project: https://github.com/MikuMC/MikuServer - -diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 96cde1f86ca073e7e9e5799bcb12a10adf9230b2..30509d85391ce2fb170751170f3d4310ef856aea 100644 ---- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java -+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -1,5 +1,6 @@ - package org.bukkit.craftbukkit; - -+import co.mikumc.mikuserver.utils.AnotherTickThread; - import com.google.common.base.Charsets; - import com.google.common.base.Function; - import com.google.common.base.Preconditions; -@@ -415,6 +416,11 @@ public final class CraftServer implements Server { - } - } - -+ @Override -+ public boolean isCurrentThreadWorker(){ -+ return Thread.currentThread() instanceof AnotherTickThread; -+ } -+ - private void saveCommandsConfig() { - try { - this.commandsConfiguration.save(this.getCommandsConfigFile()); diff --git a/patches/server/0050-MikuServer-Some-crash-issue-fixes.patch b/patches/server/0050-MikuServer-Some-crash-issue-fixes.patch deleted file mode 100644 index f7d321ec..00000000 --- a/patches/server/0050-MikuServer-Some-crash-issue-fixes.patch +++ /dev/null @@ -1,44 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: wangxyper -Date: Tue, 31 Jan 2023 09:17:46 +0800 -Subject: [PATCH] MikuServer: Some crash issue fixes - -Original license: MIT -Original project: https://github.com/MikuMC/MikuServer - -diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java -index 07b2cd85956dda47ed0a026cd837c5b9498213ac..7bcf64908bbd49131524e227b4f5ac274c175a55 100644 ---- a/src/main/java/net/minecraft/server/level/ChunkMap.java -+++ b/src/main/java/net/minecraft/server/level/ChunkMap.java -@@ -1500,7 +1500,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider - final Entity entity; - private final int range; - SectionPos lastSectionPos; -- public final Set seenBy = new ReferenceOpenHashSet<>(); // Paper - optimise map impl -+ public final Set seenBy = ReferenceSets.synchronize(new ReferenceOpenHashSet<>()); // Paper - optimise map impl //MikuServer - - public TrackedEntity(Entity entity, int i, int j, boolean flag) { - this.serverEntity = new ServerEntity(ChunkMap.this.level, entity, j, flag, this::broadcast, this.seenBy); // CraftBukkit -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 004091f2026f3c58d9bce49f1b07f6441df8da8a..7999e27d5dc86ff5d3d827fa2de1307317b46c70 100644 ---- a/src/main/java/net/minecraft/world/entity/player/Inventory.java -+++ b/src/main/java/net/minecraft/world/entity/player/Inventory.java -@@ -4,6 +4,9 @@ import com.google.common.collect.ImmutableList; - import java.util.Iterator; - import java.util.List; - import java.util.function.Predicate; -+ -+import it.unimi.dsi.fastutil.objects.ObjectArrayList; -+import it.unimi.dsi.fastutil.objects.ObjectLists; - import net.minecraft.CrashReport; - import net.minecraft.CrashReportCategory; - import net.minecraft.ReportedException; -@@ -49,7 +52,7 @@ public class Inventory implements Container, Nameable { - private int timesChanged; - - // CraftBukkit start - add fields and methods -- public List transaction = new java.util.ArrayList(); -+ public List transaction = ObjectLists.synchronize(new ObjectArrayList<>()); - private int maxStack = MAX_STACK; - - public List getContents() { diff --git a/patches/server/0051-Gale-Send-multiple-keep-alive-packets.patch b/patches/server/0051-Gale-Send-multiple-keep-alive-packets.patch deleted file mode 100644 index 84c02393..00000000 --- a/patches/server/0051-Gale-Send-multiple-keep-alive-packets.patch +++ /dev/null @@ -1,127 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Martijn Muijsers -Date: Fri, 11 Oct 2019 00:17:39 -0500 -Subject: [PATCH] Gale: Send multiple keep-alive packets - -Original license: GPL v3 -Original project: https://github.com/GaleMC/Gale - -License: MIT (https://opensource.org/licenses/MIT) -Gale - https://galemc.org - -This patch is based on the following patch: -"Alternative Keepalive Handling" -By: William Blake Galbreath -As part of: Purpur (https://github.com/PurpurMC/Purpur) -Licensed under: MIT (https://opensource.org/licenses/MIT) - -* Purpur copyright * - -MIT License - -Copyright (c) 2019-2022 PurpurMC - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -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/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index b2d7db36a801464c3be6fd27ee8b6e11e8426240..41b7f22e518afd93c2d2f2b71e644edea597382f 100644 ---- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -7,6 +7,8 @@ import com.mojang.brigadier.StringReader; - import com.mojang.logging.LogUtils; - import it.unimi.dsi.fastutil.ints.Int2ObjectMap.Entry; - import it.unimi.dsi.fastutil.ints.Int2ObjectMaps; -+import it.unimi.dsi.fastutil.longs.LongArrayList; -+import it.unimi.dsi.fastutil.longs.LongList; - import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; - import it.unimi.dsi.fastutil.objects.ObjectIterator; - import java.time.Duration; -@@ -260,6 +262,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic - private long keepAliveTime = Util.getMillis(); - private boolean keepAlivePending; - private long keepAliveChallenge; -+ private LongList keepAlives = new LongArrayList(); // Gale - Purpur - send multiple keep-alive packets - // CraftBukkit start - multithreaded fields - private final AtomicInteger chatSpamTickCount = new AtomicInteger(); - private final java.util.concurrent.atomic.AtomicInteger tabSpamLimiter = new java.util.concurrent.atomic.AtomicInteger(); // Paper - configurable tab spam limits -@@ -297,7 +300,10 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic - private final LastSeenMessagesValidator lastSeenMessages; - private final MessageSignatureCache messageSignatureCache; - private final FutureChain chatMessageChain; -- private static final long KEEPALIVE_LIMIT = Long.getLong("paper.playerconnection.keepalive", 30) * 1000; // Paper - provide property to set keepalive limit -+ // Gale start - Purpur - send multiple keep-alive packets -+ private static final long KEEPALIVE_LIMIT_IN_SECONDS = Long.getLong("paper.playerconnection.keepalive", 30); // Paper - provide property to set keepalive limit -+ private static final long KEEPALIVE_LIMIT = KEEPALIVE_LIMIT_IN_SECONDS * 1000; -+ // Gale end - Purpur - send multiple keep-alive packets - private static final int MAX_SIGN_LINE_LENGTH = Integer.getInteger("Paper.maxSignLength", 80); // Paper - - private String clientBrandName = null; // Paper - Brand name -@@ -397,6 +403,21 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic - long currentTime = Util.getMillis(); - long elapsedTime = currentTime - this.keepAliveTime; - -+ // Gale start - Purpur - send multiple keep-alive packets -+ if (LeafConfig.sendMultiple) { -+ if (elapsedTime >= 1000L) { // 1 second -+ if (!this.processedDisconnect && this.keepAlives.size() >= KEEPALIVE_LIMIT_IN_SECONDS) { -+ LOGGER.warn("{} was kicked due to keepalive timeout!", this.player.getScoreboardName()); -+ disconnect(Component.translatable("disconnect.timeout"), org.bukkit.event.player.PlayerKickEvent.Cause.TIMEOUT); -+ } else { -+ this.keepAliveTime = currentTime; // hijack this field for 1 second intervals -+ this.keepAlives.add(currentTime); // currentTime is ID -+ send(new ClientboundKeepAlivePacket(currentTime)); -+ } -+ } -+ } else -+ // Gale end - Purpur - send multiple keep-alive packets -+ - if (this.keepAlivePending) { - if (!this.processedDisconnect && elapsedTime >= KEEPALIVE_LIMIT) { // check keepalive limit, don't fire if already disconnected - ServerGamePacketListenerImpl.LOGGER.warn("{} was kicked due to keepalive timeout!", this.player.getScoreboardName()); // more info -@@ -3465,6 +3486,16 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic - - @Override - public void handleKeepAlive(ServerboundKeepAlivePacket packet) { -+ // Gale start - Purpur - send multiple keep-alive packets -+ if (LeafConfig.sendMultiple) { -+ long id = packet.getId(); -+ if (!this.keepAlives.isEmpty() && this.keepAlives.contains(id)) { -+ int ping = (int) (Util.getMillis() - id); -+ this.player.latency = (this.player.latency * 3 + ping) / 4; -+ this.keepAlives.clear(); // We got a valid response, let's roll with it and forget the rest -+ } -+ } else -+ // Gale end - Purpur - send multiple keep-alive packets - //PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel()); // CraftBukkit // Paper - This shouldn't be on the main thread - if (this.keepAlivePending && packet.getId() == this.keepAliveChallenge) { - int i = (int) (Util.getMillis() - this.keepAliveTime); -diff --git a/src/main/java/org/dreeam/leaf/LeafConfig.java b/src/main/java/org/dreeam/leaf/LeafConfig.java -index dcac5cf6eb0992b3b3d51222f328b7f87936322a..d8b0e6d0043adc1b9f07cb90cd23a665ae44ba26 100644 ---- a/src/main/java/org/dreeam/leaf/LeafConfig.java -+++ b/src/main/java/org/dreeam/leaf/LeafConfig.java -@@ -285,4 +285,9 @@ public class LeafConfig { - private static void networkSettings() { - kickForOutOfOrderChat = getBoolean("settings.network.kick-for-out-of-order-chat", kickForOutOfOrderChat); - } -+ -+ public static boolean sendMultiple = false; -+ private static void sendMultiple() { -+ sendMultiple = getBoolean("settings.send-Multiple-keepalive", sendMultiple); -+ } - }