diff --git a/.github/workflows/auto-update.yml b/.github/workflows/auto-update.yml index 71d98ba..ed63e02 100644 --- a/.github/workflows/auto-update.yml +++ b/.github/workflows/auto-update.yml @@ -11,7 +11,7 @@ jobs: uses: actions/checkout@v3 with: path: 'SparklyPaper' - ref: 'ver/1.21.1' + ref: 'ver/1.21.3' token: ${{ secrets.LORITTA_PAT }} - name: Checkout Paper Repository @@ -19,7 +19,7 @@ jobs: with: path: 'Paper' repository: "PaperMC/Paper" - ref: 'ver/1.21.1' + ref: 'master' token: ${{ secrets.LORITTA_PAT }} - name: Get Paper Latest Commit Hash diff --git a/build.gradle.kts b/build.gradle.kts index d923c62..2497302 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,7 +3,7 @@ plugins { `maven-publish` // In general, keep this version in sync with upstream. Sometimes a newer version than upstream might work, but an older version is extremely likely to break. - id("io.papermc.paperweight.patcher") version "1.7.1" + id("io.papermc.paperweight.patcher") version "1.7.5" } val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/" diff --git a/gradle.properties b/gradle.properties index 61257cc..5438045 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,8 +1,8 @@ group=net.sparklypower.sparklypaper -version=1.21.1-R0.1-SNAPSHOT +version=1.21.3-R0.1-SNAPSHOT -mcVersion=1.21.1 -paperRef=b48403bd69f534ffd43fe2afb4e8e1f1ffa95fe1 +mcVersion=1.21.3 +paperRef=a63013cf48e46e2ec056c7ace60e018ec9be208e org.gradle.caching=true org.gradle.parallel=true diff --git a/patches/api/0004-Parallel-world-ticking.patch b/patches/api/0004-Parallel-world-ticking.patch deleted file mode 100644 index 54a49b4..0000000 --- a/patches/api/0004-Parallel-world-ticking.patch +++ /dev/null @@ -1,79 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: MrPowerGamerBR -Date: Thu, 23 Nov 2023 12:08:39 -0300 -Subject: [PATCH] Parallel world ticking - - -diff --git a/src/main/java/co/aikar/timings/Timings.java b/src/main/java/co/aikar/timings/Timings.java -index e81d0bc309de877ed2b5da6122f55c162e9b5f10..718cbe97a2bc0e415ffaaf0aaa174ac1fbe71b4f 100644 ---- a/src/main/java/co/aikar/timings/Timings.java -+++ b/src/main/java/co/aikar/timings/Timings.java -@@ -55,6 +55,7 @@ public final class Timings { - private static int historyInterval = -1; - private static int historyLength = -1; - private static boolean warnedAboutDeprecationOnEnable; -+ private static boolean warnedAboutParallelWorldTickingOnEnable; // SparklyPaper - parallel world ticking - - private Timings() {} - -@@ -145,6 +146,12 @@ public final class Timings { - * @param enabled Should timings be reported - */ - public static void setTimingsEnabled(boolean enabled) { -+ // SparklyPaper - parallel world ticking -+ if (enabled) { -+ warnAboutParallelWorldTickingOnEnable(); -+ return; -+ } -+ // SparklyPaper end - timingsEnabled = enabled; - warnAboutDeprecationOnEnable(); - reset(); -@@ -174,6 +181,34 @@ public final class Timings { - .build(); - } - -+ // SparklyPaper start - parallel world ticking -+ private static void warnAboutParallelWorldTickingOnEnable() { -+ if (!warnedAboutParallelWorldTickingOnEnable) { -+ Bukkit.getLogger().warning(PlainTextComponentSerializer.plainText().serialize(parallelWorldTickingMessage())); -+ warnedAboutParallelWorldTickingOnEnable = true; -+ } -+ } -+ -+ public static Component parallelWorldTickingMessage() { -+ return Component.text() -+ .color(TextColor.color(0xf3ef91)) -+ .append(Component.text("[!] The timings profiler attempted to be enabled, but was disabled because timings is not compatible with " + Bukkit.getName() + "'s Parallel World Ticking feature.")) -+ .append(Component.newline()) -+ .append( -+ Component.text(" We recommend installing the spark profiler as a replacement: ") -+ .append( -+ Component.text() -+ .content("https://spark.lucko.me/") -+ .clickEvent(ClickEvent.openUrl("https://spark.lucko.me/"))) -+ ) -+ .append(Component.newline()) -+ .append( -+ Component.text(" Or, if you really need timings, get a build without the Parallel World Ticking feature") -+ ) -+ .build(); -+ } -+ // SparklyPaper end -+ - /** - *

Sets whether or not the Timings should monitor at Verbose level.

- * -diff --git a/src/main/java/org/bukkit/command/SimpleCommandMap.java b/src/main/java/org/bukkit/command/SimpleCommandMap.java -index 5df19bd701c67506689fc7f49d91f99ebfbc83f0..b38edfa6eca2138ebeffe8647b7b5c6b3206d85a 100644 ---- a/src/main/java/org/bukkit/command/SimpleCommandMap.java -+++ b/src/main/java/org/bukkit/command/SimpleCommandMap.java -@@ -39,7 +39,7 @@ public class SimpleCommandMap implements CommandMap { - register("bukkit", new VersionCommand("version")); - register("bukkit", new ReloadCommand("reload")); - //register("bukkit", new PluginsCommand("plugins")); // Paper -- register("bukkit", new co.aikar.timings.TimingsCommand("timings")); // Paper -+ // register("bukkit", new co.aikar.timings.TimingsCommand("timings")); // Paper // SparklyPaper - parallel world ticking - } - - public void setFallbackCommands() { diff --git a/patches/api/0005-SPARKLYPOWER-Add-custom-blocks.patch b/patches/api/0004-SPARKLYPOWER-Add-custom-blocks.patch similarity index 90% rename from patches/api/0005-SPARKLYPOWER-Add-custom-blocks.patch rename to patches/api/0004-SPARKLYPOWER-Add-custom-blocks.patch index 3975e41..6f77214 100644 --- a/patches/api/0005-SPARKLYPOWER-Add-custom-blocks.patch +++ b/patches/api/0004-SPARKLYPOWER-Add-custom-blocks.patch @@ -5,7 +5,7 @@ Subject: [PATCH] SPARKLYPOWER Add custom blocks diff --git a/src/main/java/com/destroystokyo/paper/MaterialTags.java b/src/main/java/com/destroystokyo/paper/MaterialTags.java -index be212b4fbeabab32a4dab6ae554768c368efaa88..fc885e551b1e8393569ec1391ee3decdce8d7efb 100644 +index 41eaa8159f8c028faa118300e95f6a0fb9cfe989..5b5ddb19b39d5201da422f9b10e2491ab9334925 100644 --- a/src/main/java/com/destroystokyo/paper/MaterialTags.java +++ b/src/main/java/com/destroystokyo/paper/MaterialTags.java @@ -83,6 +83,7 @@ public class MaterialTags { @@ -33,10 +33,10 @@ index be212b4fbeabab32a4dab6ae554768c368efaa88..fc885e551b1e8393569ec1391ee3decd /** diff --git a/src/main/java/org/bukkit/Material.java b/src/main/java/org/bukkit/Material.java -index 77a15a99e441bd81650806142581bd5b24f30e10..d001e142857f2bd1db3c916587f79e872ec53687 100644 +index c7ce8fa1ff9feda66d5a4e497112a24ff51c9d2b..b121cf287460b9256eb6c26fae98d831b9bc7eea 100644 --- a/src/main/java/org/bukkit/Material.java +++ b/src/main/java/org/bukkit/Material.java -@@ -3680,6 +3680,22 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla +@@ -3843,6 +3843,22 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla BIG_DRIPLEAF_STEM(13167, Dripleaf.class), POTTED_AZALEA_BUSH(20430), POTTED_FLOWERING_AZALEA_BUSH(10609), diff --git a/patches/server/0001-new-fork-who-dis-Rebrand-to-SparklyPaper-and-Build-C.patch b/patches/server/0001-new-fork-who-dis-Rebrand-to-SparklyPaper-and-Build-C.patch index 5b1dd0f..2cfecee 100644 --- a/patches/server/0001-new-fork-who-dis-Rebrand-to-SparklyPaper-and-Build-C.patch +++ b/patches/server/0001-new-fork-who-dis-Rebrand-to-SparklyPaper-and-Build-C.patch @@ -5,7 +5,7 @@ Subject: [PATCH] new fork who dis - Rebrand to SparklyPaper and Build Changes diff --git a/build.gradle.kts b/build.gradle.kts -index de0474b8dce58cb419c00b7614d7dd66be832a02..a7482b87f8a015c6eb1cdf52f2b655632fa281d2 100644 +index faf3e3fd72e8c915e7a4803dacbe1bb576c6663e..144c7a15a51f0d22f3c35412fa7aa395d092bebc 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,6 +3,8 @@ import java.time.Instant @@ -17,8 +17,8 @@ index de0474b8dce58cb419c00b7614d7dd66be832a02..a7482b87f8a015c6eb1cdf52f2b65563 `maven-publish` } -@@ -13,7 +15,12 @@ configurations.named(log4jPlugins.compileClasspathConfigurationName) { - val alsoShade: Configuration by configurations.creating +@@ -25,7 +27,12 @@ abstract class MockitoAgentProvider : CommandLineArgumentProvider { + // Paper end - configure mockito agent that is needed in newer java versions dependencies { - implementation(project(":paper-api")) @@ -29,9 +29,9 @@ index de0474b8dce58cb419c00b7614d7dd66be832a02..a7482b87f8a015c6eb1cdf52f2b65563 + implementation("com.charleskorn.kaml:kaml:0.55.0") + // SparklyPaper end // Paper start - implementation("org.jline:jline-terminal-jansi:3.21.0") - implementation("net.minecrell:terminalconsoleappender:1.3.0") -@@ -80,7 +87,12 @@ tasks.jar { + implementation("org.jline:jline-terminal-ffm:3.27.1") // use ffm on java 22+ + implementation("org.jline:jline-terminal-jni:3.27.1") // fall back to jni on java 21 +@@ -94,7 +101,12 @@ tasks.jar { val mcVersion = rootProject.providers.gradleProperty("mcVersion").get() val build = System.getenv("BUILD_NUMBER") ?: null val gitHash = git("rev-parse", "--short=7", "HEAD").getText().trim() @@ -45,7 +45,7 @@ index de0474b8dce58cb419c00b7614d7dd66be832a02..a7482b87f8a015c6eb1cdf52f2b65563 val date = git("show", "-s", "--format=%ci", gitHash).getText().trim() // Paper val gitBranch = git("rev-parse", "--abbrev-ref", "HEAD").getText().trim() // Paper attributes( -@@ -91,8 +103,8 @@ tasks.jar { +@@ -105,8 +117,8 @@ tasks.jar { "Specification-Title" to "Paper", "Specification-Version" to project.version, "Specification-Vendor" to "Paper Team", diff --git a/patches/server/0002-SparklyPaper-config-files.patch b/patches/server/0002-SparklyPaper-config-files.patch index bedbbea..b126823 100644 --- a/patches/server/0002-SparklyPaper-config-files.patch +++ b/patches/server/0002-SparklyPaper-config-files.patch @@ -5,10 +5,10 @@ Subject: [PATCH] SparklyPaper config files diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -index dd56c8e041116ef3602a9f89c998c8208ab89b51..b7c39d2e93abbc5f988271d738490de68ce50b3b 100644 +index 17a158ff6ce6520b69a5a0032ba4c05449dd0cf8..bb8975cd3d3b1c57f313ad31b5e767fa93ad8e13 100644 --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -@@ -238,6 +238,15 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -235,6 +235,15 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface io.papermc.paper.command.PaperCommands.registerCommands(this); // Paper - setup /paper command this.server.spark.registerCommandBeforePlugins(this.server); // Paper - spark com.destroystokyo.paper.Metrics.PaperMetrics.startMetrics(); // Paper - start metrics @@ -25,19 +25,19 @@ index dd56c8e041116ef3602a9f89c998c8208ab89b51..b7c39d2e93abbc5f988271d738490de6 this.setPvpAllowed(dedicatedserverproperties.pvp); diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index 507671476c3d2d92a2fdb05be24443af27d26dcf..350a703f9973c35f8e2af977b87fbfe19ac0b799 100644 +index 2cc264f577fdd81d02783e0d6146bea9728789c7..8433caa61a973d81a5eedc44428926e999c21a03 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -173,6 +173,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -174,6 +174,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl // Paper end - add paper world config public final com.destroystokyo.paper.antixray.ChunkPacketBlockController chunkPacketBlockController; // Paper - Anti-Xray + public net.sparklypower.sparklypaper.configs.SparklyPaperConfig.SparklyPaperWorldConfig sparklyPaperConfig; // SparklyPaper - public final co.aikar.timings.WorldTimingsHandler timings; // Paper public static BlockPos lastPhysicsProblem; // Spigot private org.spigotmc.TickLimiter entityLimiter; -@@ -687,6 +688,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl - protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, RegistryAccess iregistrycustom, Holder holder, Supplier supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function paperWorldConfigCreator, java.util.concurrent.Executor executor) { // Paper - create paper world config & Anti-Xray + private org.spigotmc.TickLimiter tileLimiter; +@@ -842,6 +843,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl + // Paper end - getblock optimisations - cache world height/sections this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper - create paper world config + this.sparklyPaperConfig = net.sparklypower.sparklypaper.configs.SparklyPaperConfigUtils.INSTANCE.getWorldSettings(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // SparklyPaper @@ -116,7 +116,7 @@ index 0000000000000000000000000000000000000000..bc0ec96f91f7c9ab9f9a865a50f69707 + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index c7df339aeb62ee627edaf1bb4c8474b61e357ba6..146f6c79ffbe45e016661d27cd1bf3cf78c92aea 100644 +index cac8592e3a2f438fe9ca167a4fdcd65152bbb2de..e6ee056e828d3ce410db000be160164d1a6f1dc4 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -111,6 +111,7 @@ import net.minecraft.world.level.storage.PlayerDataStorage; @@ -127,15 +127,15 @@ index c7df339aeb62ee627edaf1bb4c8474b61e357ba6..146f6c79ffbe45e016661d27cd1bf3cf import org.bukkit.BanList; import org.bukkit.Bukkit; import org.bukkit.ChatColor; -@@ -1072,6 +1073,7 @@ public final class CraftServer implements Server { +@@ -1074,6 +1075,7 @@ public final class CraftServer implements Server { org.spigotmc.SpigotConfig.init((File) this.console.options.valueOf("spigot-settings")); // Spigot this.console.paperConfigurations.reloadConfigs(this.console); + net.sparklypower.sparklypaper.configs.SparklyPaperConfigUtils.INSTANCE.init((File) console.options.valueOf("sparklypaper-settings")); // SparklyPaper for (ServerLevel world : this.console.getAllLevels()) { // world.serverLevelData.setDifficulty(config.difficulty); // Paper - per level difficulty - world.setSpawnSettings(world.serverLevelData.getDifficulty() != Difficulty.PEACEFUL && config.spawnMonsters, config.spawnAnimals); // Paper - per level difficulty (from MinecraftServer#setDifficulty(ServerLevel, Difficulty, boolean)) -@@ -1087,6 +1089,7 @@ public final class CraftServer implements Server { + world.setSpawnSettings(world.serverLevelData.getDifficulty() != Difficulty.PEACEFUL && config.spawnMonsters); // Paper - per level difficulty (from MinecraftServer#setDifficulty(ServerLevel, Difficulty, boolean)) +@@ -1089,6 +1091,7 @@ public final class CraftServer implements Server { } } world.spigotConfig.init(); // Spigot @@ -143,7 +143,7 @@ index c7df339aeb62ee627edaf1bb4c8474b61e357ba6..146f6c79ffbe45e016661d27cd1bf3cf } Plugin[] pluginClone = pluginManager.getPlugins().clone(); // Paper -@@ -1104,6 +1107,7 @@ public final class CraftServer implements Server { +@@ -1106,6 +1109,7 @@ public final class CraftServer implements Server { org.spigotmc.SpigotConfig.registerCommands(); // Spigot io.papermc.paper.command.PaperCommands.registerCommands(this.console); // Paper this.spark.registerCommandBeforePlugins(this); // Paper - spark @@ -152,7 +152,7 @@ index c7df339aeb62ee627edaf1bb4c8474b61e357ba6..146f6c79ffbe45e016661d27cd1bf3cf this.ignoreVanillaPermissions = this.commandsConfiguration.getBoolean("ignore-vanilla-permissions"); diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java -index b3ba6bccdbb08af27916f0c611c60b2595b90164..bbd6e3b1bcec18e653313270136530ed82ea1448 100644 +index be0d38544395a9b3befb898bb961f34e32fe9509..522efbfaedb20fe3650c6ebe3c1678ee5c0f236a 100644 --- a/src/main/java/org/bukkit/craftbukkit/Main.java +++ b/src/main/java/org/bukkit/craftbukkit/Main.java @@ -176,6 +176,14 @@ public class Main { diff --git a/patches/server/0003-Rewrite-framed-map-tracker-ticking.patch b/patches/server/0003-Rewrite-framed-map-tracker-ticking.patch index 9177e12..5eeb51e 100644 --- a/patches/server/0003-Rewrite-framed-map-tracker-ticking.patch +++ b/patches/server/0003-Rewrite-framed-map-tracker-ticking.patch @@ -11,10 +11,10 @@ now is just updating dirty map/decoration data. When no bukkit renderers are added to the map, we also re-use the same packet for all players who are tracking it which avoids a lot of work. diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java -index 8ea2f24695f5dad55e21f238b69442513e7a90c6..e8781c8857d4b8b241515c811a4686feda437abb 100644 +index 90eb4927fa51ce3df86aa7b6c71f49150a03e337..9938d359de5b179ff486390288d481d6ece1ecf3 100644 --- a/src/main/java/net/minecraft/server/level/ServerEntity.java +++ b/src/main/java/net/minecraft/server/level/ServerEntity.java -@@ -124,27 +124,40 @@ public class ServerEntity { +@@ -128,27 +128,40 @@ public class ServerEntity { Entity entity = this.entity; @@ -60,7 +60,7 @@ index 8ea2f24695f5dad55e21f238b69442513e7a90c6..e8781c8857d4b8b241515c811a4686fe } } -@@ -383,6 +396,19 @@ public class ServerEntity { +@@ -421,6 +434,19 @@ public class ServerEntity { } } @@ -81,31 +81,31 @@ index 8ea2f24695f5dad55e21f238b69442513e7a90c6..e8781c8857d4b8b241515c811a4686fe public Vec3 getPositionBase() { diff --git a/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java b/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java -index 5b7245cd99593ee90e17c97e0104f3aba9ae05ea..03432d084f8ed0cb7716d612b35f740943dcc4c0 100644 +index bbdaaa1cc0b4aed28bc39385508d221055b99d4d..7562147721fc8c6aa6c435f027a1757cf5b61818 100644 --- a/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java +++ b/src/main/java/net/minecraft/world/entity/decoration/ItemFrame.java -@@ -419,6 +419,16 @@ public class ItemFrame extends HangingEntity { - } - this.setItem(ItemStack.fromBukkitCopy(event.getItemStack())); - // Paper end - Add PlayerItemFrameChangeEvent -+ // Paper start - add decoration and mark everything dirty for other players who are already tracking this frame -+ final ItemStack item = this.getItem(); -+ if (item.is(Items.FILLED_MAP)) { -+ final MapItemSavedData data = MapItem.getSavedData(item, this.level()); -+ if (data != null) { -+ data.addFrameDecoration(this); -+ data.markAllDirty(); -+ } -+ } -+ // Paper end - this.gameEvent(GameEvent.BLOCK_CHANGE, player); - itemstack.consume(1, player); +@@ -175,6 +175,16 @@ public class ItemFrame extends HangingEntity { + this.setItem(ItemStack.fromBukkitCopy(event.getItemStack()), false); } + // Paper end - Add PlayerItemFrameChangeEvent ++ // Paper start - add decoration and mark everything dirty for other players who are already tracking this frame ++ final ItemStack item = this.getItem(); ++ if (item.is(Items.FILLED_MAP)) { ++ final MapItemSavedData data = MapItem.getSavedData(item, this.level()); ++ if (data != null) { ++ data.addFrameDecoration(this); ++ data.markAllDirty(); ++ } ++ } ++ // Paper end + this.dropItem(world, source.getEntity(), false); + this.gameEvent(GameEvent.BLOCK_CHANGE, source.getEntity()); + this.playSound(this.getRemoveItemSound(), 1.0F, 1.0F); diff --git a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java -index 6794466051dd4b725d579b2136c37844995a648e..95b2078d24c83e56760bc8be404df603a15b37c5 100644 +index ae321b3b8d98e42ef07fd1f0f738c1a2b428f6db..3515ce1e69b35cc8072b833e4f95632c7aa53bc1 100644 --- a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java +++ b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java -@@ -80,6 +80,16 @@ public class MapItemSavedData extends SavedData { +@@ -81,6 +81,16 @@ public class MapItemSavedData extends SavedData { private final Map frameMarkers = Maps.newHashMap(); private int trackedDecorationCount; private org.bukkit.craftbukkit.map.RenderData vanillaRender = new org.bukkit.craftbukkit.map.RenderData(); // Paper @@ -122,7 +122,7 @@ index 6794466051dd4b725d579b2136c37844995a648e..95b2078d24c83e56760bc8be404df603 // CraftBukkit start public final CraftMapView mapView; -@@ -351,7 +361,7 @@ public class MapItemSavedData extends SavedData { +@@ -370,7 +380,7 @@ public class MapItemSavedData extends SavedData { --this.trackedDecorationCount; } @@ -131,15 +131,15 @@ index 6794466051dd4b725d579b2136c37844995a648e..95b2078d24c83e56760bc8be404df603 } public static void addTargetDecoration(ItemStack stack, BlockPos pos, String id, Holder decorationType) { -@@ -433,6 +443,7 @@ public class MapItemSavedData extends SavedData { +@@ -407,6 +417,7 @@ public class MapItemSavedData extends SavedData { + } + + this.setDecorationsDirty(); ++ if (mapicon.renderOnFrame()) this.dirtyFrameDecorations = true; // Paper } - this.setDecorationsDirty(); -+ if (mapicon.renderOnFrame()) this.dirtyFrameDecorations = true; // Paper } - - } -@@ -446,6 +457,20 @@ public class MapItemSavedData extends SavedData { +@@ -478,6 +489,20 @@ public class MapItemSavedData extends SavedData { public void setColorsDirty(int x, int z) { this.setDirty(); @@ -160,15 +160,15 @@ index 6794466051dd4b725d579b2136c37844995a648e..95b2078d24c83e56760bc8be404df603 Iterator iterator = this.carriedBy.iterator(); while (iterator.hasNext()) { -@@ -528,6 +553,7 @@ public class MapItemSavedData extends SavedData { - public void removedFromFrame(BlockPos pos, int id) { +@@ -561,6 +586,7 @@ public class MapItemSavedData extends SavedData { this.removeDecoration(MapItemSavedData.getFrameKey(id)); this.frameMarkers.remove(MapFrame.frameId(pos)); + this.setDirty(); + this.dirtyFrameDecorations = true; // Paper } public boolean updateColor(int x, int z, byte color) { -@@ -589,6 +615,93 @@ public class MapItemSavedData extends SavedData { +@@ -622,6 +648,93 @@ public class MapItemSavedData extends SavedData { return "frame-" + id; } diff --git a/patches/server/0004-Skip-distanceToSqr-call-in-ServerEntity-sendChanges-.patch b/patches/server/0004-Skip-distanceToSqr-call-in-ServerEntity-sendChanges-.patch index 9ea8558..3b1f7de 100644 --- a/patches/server/0004-Skip-distanceToSqr-call-in-ServerEntity-sendChanges-.patch +++ b/patches/server/0004-Skip-distanceToSqr-call-in-ServerEntity-sendChanges-.patch @@ -9,22 +9,22 @@ The "distanceToSqr" call is a bit expensive, so avoiding it is pretty nice, arou We could also check if the x,y,z coordinates are equal, but for now, let's just keep the identity check, which also helps us since Minecraft's code does reuse the original delta movement Vec3 object diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java -index e8781c8857d4b8b241515c811a4686feda437abb..aafa06b3730fa3826941cbec7177b58fbd672040 100644 +index 9938d359de5b179ff486390288d481d6ece1ecf3..ff5bf212e194dd0914c06e636a8268e8e8f6fff8 100644 --- a/src/main/java/net/minecraft/server/level/ServerEntity.java +++ b/src/main/java/net/minecraft/server/level/ServerEntity.java -@@ -229,6 +229,7 @@ public class ServerEntity { +@@ -243,6 +243,7 @@ public class ServerEntity { - if ((this.trackDelta || this.entity.hasImpulse || this.entity instanceof LivingEntity && ((LivingEntity) this.entity).isFallFlying()) && this.tickCount > 0) { - Vec3 vec3d1 = this.entity.getDeltaMovement(); + if ((this.trackDelta || this.entity.hasImpulse || this.entity instanceof LivingEntity && ((LivingEntity) this.entity).isFallFlying()) && this.tickCount > 0) { + Vec3 vec3d1 = this.entity.getDeltaMovement(); + if (vec3d1 != this.lastSentMovement) { // SparklyPaper start - skip distanceToSqr call in ServerEntity#sendChanges if the delta movement hasn't changed - double d0 = vec3d1.distanceToSqr(this.lastSentMovement); + double d0 = vec3d1.distanceToSqr(this.lastSentMovement); - if (d0 > 1.0E-7D || d0 > 0.0D && vec3d1.lengthSqr() == 0.0D) { -@@ -243,6 +244,7 @@ public class ServerEntity { - this.broadcast.accept(new ClientboundSetEntityMotionPacket(this.entity.getId(), this.lastSentMovement)); + if (d0 > 1.0E-7D || d0 > 0.0D && vec3d1.lengthSqr() == 0.0D) { +@@ -257,6 +258,7 @@ public class ServerEntity { + this.broadcast.accept(new ClientboundSetEntityMotionPacket(this.entity.getId(), this.lastSentMovement)); + } } - } + } // SparklyPaper end - } + } - if (packet1 != null) { + if (packet1 != null) { diff --git a/patches/server/0005-Skip-MapItem-update-if-the-map-does-not-have-the-Cra.patch b/patches/server/0005-Skip-MapItem-update-if-the-map-does-not-have-the-Cra.patch index fd2105c..476296d 100644 --- a/patches/server/0005-Skip-MapItem-update-if-the-map-does-not-have-the-Cra.patch +++ b/patches/server/0005-Skip-MapItem-update-if-the-map-does-not-have-the-Cra.patch @@ -9,10 +9,10 @@ Optimizes "image in map" maps, without requiring the map to be locked, which som This has the disadvantage that the vanilla map data will never be updated while the CraftMapRenderer is not present, but that's not a huuuge problem for us diff --git a/src/main/java/net/minecraft/world/item/MapItem.java b/src/main/java/net/minecraft/world/item/MapItem.java -index ce461b1a8d7fab87ae28e30205f6fab67f1808b6..7891187eb974c3fb5ebe831ab01db6ab4c5be3bf 100644 +index 571f2540a1e9422025efe651167e26b44b437daa..70dd7d49807d8290b3a306550c2e1999c7e3553e 100644 --- a/src/main/java/net/minecraft/world/item/MapItem.java +++ b/src/main/java/net/minecraft/world/item/MapItem.java -@@ -276,7 +276,7 @@ public class MapItem extends ComplexItem { +@@ -275,7 +275,7 @@ public class MapItem extends Item { mapItemSavedData.tickCarriedBy(player, stack); } diff --git a/patches/server/0008-Skip-EntityScheduler-s-executeTick-checks-if-there-i.patch b/patches/server/0008-Skip-EntityScheduler-s-executeTick-checks-if-there-i.patch index 308533b..dca339a 100644 --- a/patches/server/0008-Skip-EntityScheduler-s-executeTick-checks-if-there-i.patch +++ b/patches/server/0008-Skip-EntityScheduler-s-executeTick-checks-if-there-i.patch @@ -73,21 +73,21 @@ index c03608fec96b51e1867f43d8f42e5aefb1520e46..15b21fa3907db1b77ed5b5d1050a37f4 throw new IllegalStateException("Ticking retired scheduler"); } diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 696d075ca2883f3c37e35f983c4d020e5db89d16..1a7daaebdfd616e1417eb6aade727ca23fa77b18 100644 +index 663b4ecd520e82aa108d44f2d5c2a20cfc7bc01f..bca2e29e2e2bb4d79e6d3d0eef76a14fcde52022 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -322,7 +322,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop pluginsBlockingSleep = new ArrayList<>(); // Paper - API to allow/disallow tick sleeping - + public final Set entitiesWithScheduledTasks = java.util.concurrent.ConcurrentHashMap.newKeySet(); // SparklyPaper - skip EntityScheduler's executeTick checks if there isn't any tasks to be run (concurrent because plugins may schedule tasks async) + public static S spin(Function serverFactory) { AtomicReference atomicreference = new AtomicReference(); Thread thread = new ca.spottedleaf.moonrise.common.util.TickThread(() -> { // Paper - rewrite chunk system -@@ -1725,6 +1726,18 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { - for (final Entity entity : level.moonrise$getEntityLookup().getAllCopy()) { // Paper - rewrite chunk system + for (final Entity entity : level.getEntities().getAll()) { if (entity.isRemoved()) { -@@ -1736,6 +1749,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 0 && world.paperConfig().tickRates.wetFarmland != 1 && (world.paperConfig().tickRates.wetFarmland < 1 || (net.minecraft.server.MinecraftServer.currentTick + pos.hashCode()) % world.paperConfig().tickRates.wetFarmland != 0)) { return; } // Paper - Configurable random tick rates for blocks if (i == 0 && world.paperConfig().tickRates.dryFarmland != 1 && (world.paperConfig().tickRates.dryFarmland < 1 || (net.minecraft.server.MinecraftServer.currentTick + pos.hashCode()) % world.paperConfig().tickRates.dryFarmland != 0)) { return; } // Paper - Configurable random tick rates for blocks -@@ -151,7 +164,7 @@ public class FarmBlock extends Block { +@@ -153,7 +166,7 @@ public class FarmBlock extends Block { return world.getBlockState(pos.above()).is(BlockTags.MAINTAINS_FARMLAND); } @@ -109,7 +109,7 @@ index d59e33e7326489c6d55d316d0130f22235f4c63c..3a2c875f8131fc4a30807a69f426b6ac int xOff = pos.getX(); int yOff = pos.getY(); diff --git a/src/main/java/net/minecraft/world/level/block/StemBlock.java b/src/main/java/net/minecraft/world/level/block/StemBlock.java -index 924d80eb41d9a71d1e521c40742557251cf51832..e79ab379ac4ed5cde82a144a83c0326c8b3a6349 100644 +index 76109aceb24a4719d49c1a55e3621cf2a63bbe16..4b46fbb7a03de8f2616a398c6fa3794da60a1eea 100644 --- a/src/main/java/net/minecraft/world/level/block/StemBlock.java +++ b/src/main/java/net/minecraft/world/level/block/StemBlock.java @@ -73,6 +73,56 @@ public class StemBlock extends BushBlock implements BonemealableBlock { @@ -144,7 +144,7 @@ index 924d80eb41d9a71d1e521c40742557251cf51832..e79ab379ac4ed5cde82a144a83c0326c + BlockState iblockdata1 = world.getBlockState(blockposition1.below()); + + if (world.getBlockState(blockposition1).isAir() && (iblockdata1.is(Blocks.FARMLAND) || iblockdata1.is(BlockTags.DIRT))) { -+ Registry iregistry = world.registryAccess().registryOrThrow(Registries.BLOCK); ++ Registry iregistry = world.registryAccess().get(Registries.BLOCK).get().value(); + Optional optional = iregistry.getOptional(this.fruit); + Optional optional1 = iregistry.getOptional(this.attachedStem); + diff --git a/patches/server/0010-Spooky-month-optimizations.patch b/patches/server/0010-Spooky-month-optimizations.patch index 05d0f24..5a0b415 100644 --- a/patches/server/0010-Spooky-month-optimizations.patch +++ b/patches/server/0010-Spooky-month-optimizations.patch @@ -10,12 +10,12 @@ Caches when Bat's spooky season starts and ends, and when Skeleton and Zombies h Avoids unnecessary date checks, even tho that this shouldn't really improve performance that much... unless you have a lot of bats/zombies/skeletons spawning. diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 1a7daaebdfd616e1417eb6aade727ca23fa77b18..3ad7a0a6b698ed2ff040fe1015b59e897a173811 100644 +index bca2e29e2e2bb4d79e6d3d0eef76a14fcde52022..ae085afa4d532c13a02321407d9f5059e4a3e567 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -323,7 +323,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop pluginsBlockingSleep = new ArrayList<>(); // Paper - API to allow/disallow tick sleeping public final Set entitiesWithScheduledTasks = java.util.concurrent.ConcurrentHashMap.newKeySet(); // SparklyPaper - skip EntityScheduler's executeTick checks if there isn't any tasks to be run (concurrent because plugins may schedule tasks async) - + public net.sparklypower.sparklypaper.HalloweenManager halloweenManager = new net.sparklypower.sparklypaper.HalloweenManager(); // SparklyPaper - Spooky month optimizations @@ -24,10 +24,10 @@ index 1a7daaebdfd616e1417eb6aade727ca23fa77b18..3ad7a0a6b698ed2ff040fe1015b59e89 AtomicReference atomicreference = new AtomicReference(); Thread thread = new ca.spottedleaf.moonrise.common.util.TickThread(() -> { // Paper - rewrite chunk system diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -index b7c39d2e93abbc5f988271d738490de68ce50b3b..1395e8f98bd87a060fb609c65a3311c220f5e9a8 100644 +index bb8975cd3d3b1c57f313ad31b5e767fa93ad8e13..e49e8e98ebbd3c8ba8a784f1626132699209b4e3 100644 --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -@@ -247,6 +247,10 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -244,6 +244,10 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface } net.sparklypower.sparklypaper.SparklyPaperCommands.INSTANCE.registerCommands(this); // SparklyPaper end @@ -39,10 +39,10 @@ index b7c39d2e93abbc5f988271d738490de68ce50b3b..1395e8f98bd87a060fb609c65a3311c2 this.setPvpAllowed(dedicatedserverproperties.pvp); diff --git a/src/main/java/net/minecraft/world/entity/ambient/Bat.java b/src/main/java/net/minecraft/world/entity/ambient/Bat.java -index dc27ddf5131e7398a5390a5187261d4c7fb6ccaa..6c8664c9cf75a88007e43348059fad7e5c60f963 100644 +index 60c2868f255d372226e0c1389caaa5477bbef41e..64b601a5275374ae8038eaa63f2dddfbb09f593a 100644 --- a/src/main/java/net/minecraft/world/entity/ambient/Bat.java +++ b/src/main/java/net/minecraft/world/entity/ambient/Bat.java -@@ -229,7 +229,7 @@ public class Bat extends AmbientCreature { +@@ -232,7 +232,7 @@ public class Bat extends AmbientCreature { int i = world.getMaxLocalRawBrightness(pos); byte b0 = 4; @@ -51,7 +51,7 @@ index dc27ddf5131e7398a5390a5187261d4c7fb6ccaa..6c8664c9cf75a88007e43348059fad7e b0 = 7; } else if (random.nextBoolean()) { return false; -@@ -239,6 +239,8 @@ public class Bat extends AmbientCreature { +@@ -242,6 +242,8 @@ public class Bat extends AmbientCreature { } } @@ -60,7 +60,7 @@ index dc27ddf5131e7398a5390a5187261d4c7fb6ccaa..6c8664c9cf75a88007e43348059fad7e private static boolean isHalloween() { LocalDate localdate = LocalDate.now(); int i = localdate.get(ChronoField.DAY_OF_MONTH); -@@ -246,6 +248,7 @@ public class Bat extends AmbientCreature { +@@ -249,6 +251,7 @@ public class Bat extends AmbientCreature { return j == 10 && i >= 20 || j == 11 && i <= 3; } @@ -69,10 +69,10 @@ index dc27ddf5131e7398a5390a5187261d4c7fb6ccaa..6c8664c9cf75a88007e43348059fad7e private void setupAnimationStates() { if (this.isResting()) { 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 3b5cf6ffb74d11bea5eb21bd66d679734ff5000c..97bdeb56fee6fb4ae924973730e34dbf933eef68 100644 +index 32670a3cb4b54b66d655197e3fde834d2b2b6d34..68818edaf2762c0610377814aa6cb065fe72d290 100644 --- a/src/main/java/net/minecraft/world/entity/monster/AbstractSkeleton.java +++ b/src/main/java/net/minecraft/world/entity/monster/AbstractSkeleton.java -@@ -157,10 +157,12 @@ public abstract class AbstractSkeleton extends Monster implements RangedAttackMo +@@ -159,10 +159,12 @@ public abstract class AbstractSkeleton extends Monster implements RangedAttackMo this.setCanPickUpLoot(this.level().paperConfig().entities.behavior.mobsCanAlwaysPickUpLoot.skeletons || randomsource.nextFloat() < 0.55F * difficulty.getSpecialMultiplier()); // Paper - Add world settings for mobs picking up loot if (this.getItemBySlot(EquipmentSlot.HEAD).isEmpty()) { LocalDate localdate = LocalDate.now(); @@ -89,10 +89,10 @@ index 3b5cf6ffb74d11bea5eb21bd66d679734ff5000c..97bdeb56fee6fb4ae924973730e34dbf 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 2b43337ac63d051718a2074fcc46e128a1d65129..896e253f349b0cf21fda0d798aca8a70942c8f86 100644 +index a12461907278cfbfa3b1c0aa74b9f07a31768b8a..558f885fc0d9d1da54bcb9cfc65efb6ceba77fde 100644 --- a/src/main/java/net/minecraft/world/entity/monster/Zombie.java +++ b/src/main/java/net/minecraft/world/entity/monster/Zombie.java -@@ -550,10 +550,11 @@ public class Zombie extends Monster { +@@ -563,10 +563,11 @@ public class Zombie extends Monster { if (this.getItemBySlot(EquipmentSlot.HEAD).isEmpty()) { LocalDate localdate = LocalDate.now(); diff --git a/patches/server/0011-Optimize-canSee-checks.patch b/patches/server/0011-Optimize-canSee-checks.patch index 4f63854..a545ba9 100644 --- a/patches/server/0011-Optimize-canSee-checks.patch +++ b/patches/server/0011-Optimize-canSee-checks.patch @@ -14,10 +14,10 @@ This seems stupid, but it does seem that it improves the performance a bit, and We also create a "canSee" method tailored for "ChunkMap#updatePlayer()", a method without the equals check (the "updatePlayer()" already checks if the entity is the same entity) because the CraftPlayer's `equals()` check is a *bit* expensive compared to only checking the object's identity, and because the identity has already been check, we don't need to check it twice. diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java -index af8cb316ac169aa8d98a88765b85bb013b9ba961..250f8ba3c77830ea0978fdeeb7748336ca150939 100644 +index 5b3a886c624b36557cbfaccdc3fb05a46a4ba36a..f0fbc31f5acd49fa233e92d595060cf0382d7522 100644 --- a/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java -@@ -1258,7 +1258,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1295,7 +1295,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider // Paper end - Configurable entity tracking range by Y // CraftBukkit start - respect vanish API @@ -27,10 +27,10 @@ index af8cb316ac169aa8d98a88765b85bb013b9ba961..250f8ba3c77830ea0978fdeeb7748336 } // CraftBukkit end diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 42d7660efe5baa6f796f2a7606686c765b6f2478..d047114737164e12491223bc68a141efc1c389fe 100644 +index d0010dfd22463986bf3be9b3ee015ce92735753e..3a8ffed79f1db9b2e2b3306bf7e456102787b492 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -@@ -200,7 +200,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -205,7 +205,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { private boolean hasPlayedBefore = false; private final ConversationTracker conversationTracker = new ConversationTracker(); private final Set channels = new HashSet(); @@ -39,7 +39,7 @@ index 42d7660efe5baa6f796f2a7606686c765b6f2478..d047114737164e12491223bc68a141ef private final Set unlistedEntities = new HashSet<>(); // Paper - Add Listing API for Player private static final WeakHashMap> pluginWeakReferences = new WeakHashMap<>(); private int hash = 0; -@@ -2252,9 +2252,16 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -2262,9 +2262,16 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public boolean canSee(org.bukkit.entity.Entity entity) { diff --git a/patches/server/0012-Revert-Fix-MC-117075-Block-entity-unload-lag-spike.patch b/patches/server/0012-Revert-Fix-MC-117075-Block-entity-unload-lag-spike.patch index 269f90a..2cdcbf7 100644 --- a/patches/server/0012-Revert-Fix-MC-117075-Block-entity-unload-lag-spike.patch +++ b/patches/server/0012-Revert-Fix-MC-117075-Block-entity-unload-lag-spike.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Revert "Fix MC-117075: Block entity unload lag spike" This reverts commit f3453b204569ea865cc1d1302edb6d125e7f0cb3. diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index e086114c3d4b1d8ed46eec98e4b66cfc21451139..2d44c17a63b12df0e3c5b39cb9a80924470a8428 100644 +index 8433caa61a973d81a5eedc44428926e999c21a03..db9eb10c33848ca5b342bf00e4a05738210d26b0 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -1387,8 +1387,6 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -1458,8 +1458,6 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl int tickedEntities = 0; // Paper - rewrite chunk system int tilesThisCycle = 0; @@ -18,7 +18,7 @@ index e086114c3d4b1d8ed46eec98e4b66cfc21451139..2d44c17a63b12df0e3c5b39cb9a80924 for (tileTickPosition = 0; tileTickPosition < this.blockEntityTickers.size(); tileTickPosition++) { // Paper - Disable tick limiters this.tileTickPosition = (this.tileTickPosition < this.blockEntityTickers.size()) ? this.tileTickPosition : 0; TickingBlockEntity tickingblockentity = (TickingBlockEntity) this.blockEntityTickers.get(this.tileTickPosition); -@@ -1397,7 +1395,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -1468,7 +1466,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl if (tickingblockentity.isRemoved()) { // Spigot start tilesThisCycle--; @@ -27,11 +27,11 @@ index e086114c3d4b1d8ed46eec98e4b66cfc21451139..2d44c17a63b12df0e3c5b39cb9a80924 // Spigot end } else if (flag && this.shouldTickBlocksAt(tickingblockentity.getPos())) { tickingblockentity.tick(); -@@ -1408,7 +1406,6 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -1479,7 +1477,6 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl // Paper end - rewrite chunk system } } - this.blockEntityTickers.removeAll(toRemove); // Paper - Fix MC-117075 - this.timings.tileEntityTick.stopTiming(); // Spigot this.tickingBlockEntities = false; + gameprofilerfiller.pop(); diff --git a/patches/server/0013-Fix-MC-117075-TE-Unload-Lag-Spike.patch b/patches/server/0013-Fix-MC-117075-TE-Unload-Lag-Spike.patch index 49e6f3b..4ba92e3 100644 --- a/patches/server/0013-Fix-MC-117075-TE-Unload-Lag-Spike.patch +++ b/patches/server/0013-Fix-MC-117075-TE-Unload-Lag-Spike.patch @@ -8,10 +8,10 @@ We replaced the `blockEntityTickers` list with a custom list based on fastutil's This is WAY FASTER than using `removeAll` with a list of entries to be removed, because we don't need to calculate the identity of each block entity to be removed, and we can jump directly to where the search should begin, giving a performance boost for small removals (because we don't need to loop thru the entire list to find what element should be removed) and a performance boost for big removals (no need to calculate the identity of each block entity). diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index 2d44c17a63b12df0e3c5b39cb9a80924470a8428..32b782bab750351caddafe6d6327e406bb26fb93 100644 +index db9eb10c33848ca5b342bf00e4a05738210d26b0..1e20c525cd0c75079fe971ae830120c69fee362e 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -116,7 +116,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -118,7 +118,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl public static final int TICKS_PER_DAY = 24000; public static final int MAX_ENTITY_SPAWN_Y = 20000000; public static final int MIN_ENTITY_SPAWN_Y = -20000000; @@ -20,7 +20,7 @@ index 2d44c17a63b12df0e3c5b39cb9a80924470a8428..32b782bab750351caddafe6d6327e406 protected final NeighborUpdater neighborUpdater; private final List pendingBlockEntityTickers = Lists.newArrayList(); private boolean tickingBlockEntities; -@@ -1395,7 +1395,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -1466,7 +1466,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl if (tickingblockentity.isRemoved()) { // Spigot start tilesThisCycle--; @@ -29,15 +29,15 @@ index 2d44c17a63b12df0e3c5b39cb9a80924470a8428..32b782bab750351caddafe6d6327e406 // Spigot end } else if (flag && this.shouldTickBlocksAt(tickingblockentity.getPos())) { tickingblockentity.tick(); -@@ -1406,7 +1406,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -1477,7 +1477,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl // Paper end - rewrite chunk system } } - + this.blockEntityTickers.removeMarkedEntries(); // SparklyPaper - optimize block entity removals - this.timings.tileEntityTick.stopTiming(); // Spigot this.tickingBlockEntities = false; - co.aikar.timings.TimingHistory.tileEntityTicks += this.blockEntityTickers.size(); // Paper + gameprofilerfiller.pop(); + this.spigotConfig.currentPrimedTnt = 0; // Spigot diff --git a/src/main/java/net/sparklypower/sparklypaper/BlockEntityTickersList.java b/src/main/java/net/sparklypower/sparklypaper/BlockEntityTickersList.java new file mode 100644 index 0000000000000000000000000000000000000000..7affec7e343c39a83390ae13ce23f3bfa0db1eb6 diff --git a/patches/server/0014-Optimize-tickBlockEntities.patch b/patches/server/0014-Optimize-tickBlockEntities.patch index d904a76..105fe10 100644 --- a/patches/server/0014-Optimize-tickBlockEntities.patch +++ b/patches/server/0014-Optimize-tickBlockEntities.patch @@ -12,10 +12,10 @@ But here's the thing: We don't care if we have a small performance penalty if th And finally, we also cache the chunk's coordinate key when creating the block entity, which is actually "free" because we just reuse the already cached chunk coordinate key from the chunk! diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index 32b782bab750351caddafe6d6327e406bb26fb93..38d73f50360685a573740e811f186d7fa582003c 100644 +index 1e20c525cd0c75079fe971ae830120c69fee362e..97b31dffbaf965e86ad706a1bba7586cd3514ead 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -1387,6 +1387,10 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -1458,6 +1458,10 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl int tickedEntities = 0; // Paper - rewrite chunk system int tilesThisCycle = 0; @@ -26,7 +26,7 @@ index 32b782bab750351caddafe6d6327e406bb26fb93..38d73f50360685a573740e811f186d7f for (tileTickPosition = 0; tileTickPosition < this.blockEntityTickers.size(); tileTickPosition++) { // Paper - Disable tick limiters this.tileTickPosition = (this.tileTickPosition < this.blockEntityTickers.size()) ? this.tileTickPosition : 0; TickingBlockEntity tickingblockentity = (TickingBlockEntity) this.blockEntityTickers.get(this.tileTickPosition); -@@ -1397,13 +1401,25 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -1468,13 +1472,25 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl tilesThisCycle--; this.blockEntityTickers.markAsRemoved(this.tileTickPosition); // this.blockEntityTickers.remove(this.tileTickPosition--); // SparklyPaper - optimize block entity removals // Spigot end @@ -65,10 +65,10 @@ index 28e3b73507b988f7234cbf29c4024c88180d0aef..427cf73383155c52bca8fb4b32f43029 + long getChunkCoordinateKey(); // SparklyPaper - optimize tickBlockEntities } diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java -index 7c11853c5090fbc4fa5b3e73a69acf166158fdec..d7fe57e9a5aa59a7a9d611bcaa6152e72ec4c300 100644 +index 4640baec5bed6c2d53cc0f8ca1d273cc115abe9b..b4c16fe7c9215b5610b7e7488c29b497b5357ecc 100644 --- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java +++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java -@@ -74,6 +74,13 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p +@@ -75,6 +75,13 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p public String getType() { return ""; } @@ -82,7 +82,7 @@ index 7c11853c5090fbc4fa5b3e73a69acf166158fdec..d7fe57e9a5aa59a7a9d611bcaa6152e7 }; private final Map tickersInLevel; public boolean loaded; -@@ -952,7 +959,7 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p +@@ -981,7 +988,7 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p } private TickingBlockEntity createTicker(T blockEntity, BlockEntityTicker blockEntityTicker) { @@ -91,7 +91,7 @@ index 7c11853c5090fbc4fa5b3e73a69acf166158fdec..d7fe57e9a5aa59a7a9d611bcaa6152e7 } @FunctionalInterface -@@ -1003,6 +1010,13 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p +@@ -1038,6 +1045,13 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p public String toString() { return String.valueOf(this.ticker) + " "; } @@ -105,7 +105,7 @@ index 7c11853c5090fbc4fa5b3e73a69acf166158fdec..d7fe57e9a5aa59a7a9d611bcaa6152e7 } private class BoundTickingBlockEntity implements TickingBlockEntity { -@@ -1010,10 +1024,12 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p +@@ -1045,10 +1059,12 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p private final T blockEntity; private final BlockEntityTicker ticker; private boolean loggedInvalidBlockState; @@ -119,7 +119,7 @@ index 7c11853c5090fbc4fa5b3e73a69acf166158fdec..d7fe57e9a5aa59a7a9d611bcaa6152e7 } @Override -@@ -1081,5 +1097,12 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p +@@ -1112,5 +1128,12 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p return "Level ticker for " + s + "@" + String.valueOf(this.getPos()); } diff --git a/patches/server/0015-Track-how-much-MSPT-each-world-used.patch b/patches/server/0015-Track-how-much-MSPT-each-world-used.patch index de87eed..9d62329 100644 --- a/patches/server/0015-Track-how-much-MSPT-each-world-used.patch +++ b/patches/server/0015-Track-how-much-MSPT-each-world-used.patch @@ -56,13 +56,13 @@ index 8b5293b0c696ef21d0101493ffa41b60bf0bc86b..601198a33adb29316b0617d5390d1620 } diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 3ad7a0a6b698ed2ff040fe1015b59e897a173811..f91374c44c392f9d28799fbf3538f99258d727b4 100644 +index ae085afa4d532c13a02321407d9f5059e4a3e567..712ca8371188fceb99e1e3a898e5f8067e5a8a5a 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -1817,7 +1817,16 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop WorldDataServer public ServerLevel(MinecraftServer minecraftserver, Executor executor, LevelStorageSource.LevelStorageAccess convertable_conversionsession, PrimaryLevelData iworlddataserver, ResourceKey resourcekey, LevelStem worlddimension, ChunkProgressListener worldloadlistener, boolean flag, long i, List list, boolean flag1, @Nullable RandomSequences randomsequences, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider) { - // IRegistryCustom.Dimension iregistrycustom_dimension = minecraftserver.registryAccess(); // CraftBukkit - decompile error + super(iworlddataserver, resourcekey, minecraftserver.registryAccess(), worlddimension.type(), false, flag, i, minecraftserver.getMaxChainedNeighborUpdates(), gen, biomeProvider, env, spigotConfig -> minecraftserver.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(convertable_conversionsession.levelDirectory.path(), iworlddataserver.getLevelName(), resourcekey.location(), spigotConfig, minecraftserver.registryAccess(), iworlddataserver.getGameRules())), executor); // Paper - create paper world configs; Async-Anti-Xray: Pass executor diff --git a/patches/server/0018-Helpful-NMS-packet-changes.patch b/patches/server/0018-Helpful-NMS-packet-changes.patch index d476f6b..c171ca7 100644 --- a/patches/server/0018-Helpful-NMS-packet-changes.patch +++ b/patches/server/0018-Helpful-NMS-packet-changes.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Helpful NMS packet changes Some nice changes to the packet internals to make packet sending and manipulation easier for us to avoid Reflection and JVM internals (ooo theUnsafe spooky) usage diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundAddEntityPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundAddEntityPacket.java -index 792b9a72a610cc512a8920d61013b6ba02f71e47..6e273098d9f2c0a78e9e98d7bbd8ed4c8de4ebc1 100644 +index f66e40326c510aa3267542b1a24ed75d1ed6d3f1..797640c4f26abb32a480a611820bbcd72e43d1ac 100644 --- a/src/main/java/net/minecraft/network/protocol/game/ClientboundAddEntityPacket.java +++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundAddEntityPacket.java @@ -22,7 +22,7 @@ public class ClientboundAddEntityPacket implements Packet> extraPackets = new java.util.ArrayList<>(); diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundRotateHeadPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundRotateHeadPacket.java -index 9a18277754fc1657e862b2ff4c077a54a4e24977..81bce96598dcfcc919e435ce47b9dc9c195c32fa 100644 +index ab44c24ce5f4570dee9d84b4216299bedfa800d8..99fbb958b82a3398564febb1e87e3ef4efca5b1a 100644 --- a/src/main/java/net/minecraft/network/protocol/game/ClientboundRotateHeadPacket.java +++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundRotateHeadPacket.java -@@ -19,6 +19,13 @@ public class ClientboundRotateHeadPacket implements Packet { final ArrayDeque pendingFullLoadUpdate = ChunkHolderManager.this.pendingFullLoadUpdate; for (int i = 0, len = changedFullStatus.size(); i < len; ++i) { -@@ -1037,7 +1037,7 @@ public final class ChunkHolderManager { +@@ -1056,7 +1056,7 @@ public final class ChunkHolderManager { // note: never call while inside the chunk system, this will absolutely break everything public void processUnloads() { @@ -296,7 +296,7 @@ index 58d3d1a47e9f2423c467bb329c2d5f4b58a8b5ef..0055e299220c8e0f4fa8ce13d61db36f if (BLOCK_TICKET_UPDATES.get() == Boolean.TRUE) { throw new IllegalStateException("Cannot unload chunks recursively"); -@@ -1316,7 +1316,7 @@ public final class ChunkHolderManager { +@@ -1338,7 +1338,7 @@ public final class ChunkHolderManager { List changedFullStatus = null; @@ -306,10 +306,10 @@ index 58d3d1a47e9f2423c467bb329c2d5f4b58a8b5ef..0055e299220c8e0f4fa8ce13d61db36f boolean ret = false; final boolean canProcessFullUpdates = processFullUpdates & isTickThread; diff --git a/src/main/java/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java b/src/main/java/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java -index 6df0db8b4cdab23494ea34236949ece4989110a3..62943b954835fb30ce916c1a17fed39620a7882d 100644 +index ddb264443f2e38b6348226016f9139727c588898..5a5451dda717656e02f11c71646f7afeeb0c2232 100644 --- a/src/main/java/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java +++ b/src/main/java/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java -@@ -63,7 +63,7 @@ public class BoatDispenseItemBehavior extends DefaultDispenseItemBehavior { +@@ -54,7 +54,7 @@ public class BoatDispenseItemBehavior extends DefaultDispenseItemBehavior { CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(d1, d2 + d4, d3)); @@ -319,7 +319,7 @@ index 6df0db8b4cdab23494ea34236949ece4989110a3..62943b954835fb30ce916c1a17fed396 } diff --git a/src/main/java/net/minecraft/core/dispenser/DefaultDispenseItemBehavior.java b/src/main/java/net/minecraft/core/dispenser/DefaultDispenseItemBehavior.java -index 39c96f5db6e90a470404c6387fa0c1d5531822e5..08fba180a1d9c6e2b96b049122ed24cac62528fd 100644 +index 8aae1d113e84dfad9f2b6f0bcd203ca6c68bc5ce..7fca48f233e98b63a5d8c9094561380866f3d0a2 100644 --- a/src/main/java/net/minecraft/core/dispenser/DefaultDispenseItemBehavior.java +++ b/src/main/java/net/minecraft/core/dispenser/DefaultDispenseItemBehavior.java @@ -87,7 +87,7 @@ public class DefaultDispenseItemBehavior implements DispenseItemBehavior { @@ -332,10 +332,10 @@ index 39c96f5db6e90a470404c6387fa0c1d5531822e5..08fba180a1d9c6e2b96b049122ed24ca } diff --git a/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java b/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java -index 60d3319016beb4f60cbc26dde165f64cf7577602..fed5a27daf1074207f3a79745e97c899a95d976f 100644 +index 0d12605dc84dad49faa18bf1fd058c3c168623ee..1a240c6ac7980df94fc40ce8fc6c3c6096db8eef 100644 --- a/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java +++ b/src/main/java/net/minecraft/core/dispenser/DispenseItemBehavior.java -@@ -115,7 +115,7 @@ public interface DispenseItemBehavior { +@@ -111,7 +111,7 @@ public interface DispenseItemBehavior { CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0)); @@ -344,7 +344,7 @@ index 60d3319016beb4f60cbc26dde165f64cf7577602..fed5a27daf1074207f3a79745e97c899 worldserver.getCraftServer().getPluginManager().callEvent(event); } -@@ -174,7 +174,7 @@ public interface DispenseItemBehavior { +@@ -170,7 +170,7 @@ public interface DispenseItemBehavior { CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0)); @@ -353,7 +353,7 @@ index 60d3319016beb4f60cbc26dde165f64cf7577602..fed5a27daf1074207f3a79745e97c899 worldserver.getCraftServer().getPluginManager().callEvent(event); } -@@ -229,7 +229,7 @@ public interface DispenseItemBehavior { +@@ -225,7 +225,7 @@ public interface DispenseItemBehavior { CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); BlockDispenseArmorEvent event = new BlockDispenseArmorEvent(block, craftItem.clone(), (org.bukkit.craftbukkit.entity.CraftLivingEntity) list.get(0).getBukkitEntity()); @@ -362,16 +362,7 @@ index 60d3319016beb4f60cbc26dde165f64cf7577602..fed5a27daf1074207f3a79745e97c899 world.getCraftServer().getPluginManager().callEvent(event); } -@@ -285,7 +285,7 @@ public interface DispenseItemBehavior { - CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); - - BlockDispenseArmorEvent event = new BlockDispenseArmorEvent(block, craftItem.clone(), (org.bukkit.craftbukkit.entity.CraftLivingEntity) entityhorseabstract.getBukkitEntity()); -- if (!DispenserBlock.eventFired) { -+ if (!DispenserBlock.eventFired.get()) { // SparklyPaper - parallel world ticking - world.getCraftServer().getPluginManager().callEvent(event); - } - -@@ -359,7 +359,7 @@ public interface DispenseItemBehavior { +@@ -280,7 +280,7 @@ public interface DispenseItemBehavior { CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); BlockDispenseArmorEvent event = new BlockDispenseArmorEvent(block, craftItem.clone(), (org.bukkit.craftbukkit.entity.CraftLivingEntity) entityhorsechestedabstract.getBukkitEntity()); @@ -380,7 +371,7 @@ index 60d3319016beb4f60cbc26dde165f64cf7577602..fed5a27daf1074207f3a79745e97c899 world.getCraftServer().getPluginManager().callEvent(event); } -@@ -431,7 +431,7 @@ public interface DispenseItemBehavior { +@@ -354,7 +354,7 @@ public interface DispenseItemBehavior { CraftItemStack craftItem = CraftItemStack.asCraftMirror(stack.copyWithCount(1)); // Paper - single item in event BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(x, y, z)); @@ -389,7 +380,7 @@ index 60d3319016beb4f60cbc26dde165f64cf7577602..fed5a27daf1074207f3a79745e97c899 worldserver.getCraftServer().getPluginManager().callEvent(event); } -@@ -496,7 +496,7 @@ public interface DispenseItemBehavior { +@@ -419,7 +419,7 @@ public interface DispenseItemBehavior { CraftItemStack craftItem = CraftItemStack.asCraftMirror(stack.copyWithCount(1)); // Paper - single item in event BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ())); @@ -398,7 +389,7 @@ index 60d3319016beb4f60cbc26dde165f64cf7577602..fed5a27daf1074207f3a79745e97c899 worldserver.getCraftServer().getPluginManager().callEvent(event); } -@@ -534,7 +534,7 @@ public interface DispenseItemBehavior { +@@ -457,7 +457,7 @@ public interface DispenseItemBehavior { CraftItemStack craftItem = CraftItemStack.asCraftMirror(stack); // Paper - ignore stack size on damageable items BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0)); @@ -407,7 +398,7 @@ index 60d3319016beb4f60cbc26dde165f64cf7577602..fed5a27daf1074207f3a79745e97c899 worldserver.getCraftServer().getPluginManager().callEvent(event); } -@@ -596,7 +596,7 @@ public interface DispenseItemBehavior { +@@ -519,7 +519,7 @@ public interface DispenseItemBehavior { CraftItemStack craftItem = CraftItemStack.asCraftMirror(stack.copyWithCount(1)); // Paper - single item in event BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0)); @@ -416,7 +407,7 @@ index 60d3319016beb4f60cbc26dde165f64cf7577602..fed5a27daf1074207f3a79745e97c899 worldserver.getCraftServer().getPluginManager().callEvent(event); } -@@ -625,8 +625,8 @@ public interface DispenseItemBehavior { +@@ -548,8 +548,8 @@ public interface DispenseItemBehavior { // CraftBukkit start worldserver.captureTreeGeneration = false; if (worldserver.capturedBlockStates.size() > 0) { @@ -427,7 +418,7 @@ index 60d3319016beb4f60cbc26dde165f64cf7577602..fed5a27daf1074207f3a79745e97c899 Location location = CraftLocation.toBukkit(blockposition, worldserver.getWorld()); List blocks = new java.util.ArrayList<>(worldserver.capturedBlockStates.values()); worldserver.capturedBlockStates.clear(); -@@ -665,7 +665,7 @@ public interface DispenseItemBehavior { +@@ -588,7 +588,7 @@ public interface DispenseItemBehavior { CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector((double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D)); @@ -436,7 +427,7 @@ index 60d3319016beb4f60cbc26dde165f64cf7577602..fed5a27daf1074207f3a79745e97c899 worldserver.getCraftServer().getPluginManager().callEvent(event); } -@@ -722,7 +722,7 @@ public interface DispenseItemBehavior { +@@ -631,7 +631,7 @@ public interface DispenseItemBehavior { CraftItemStack craftItem = CraftItemStack.asCraftMirror(stack.copyWithCount(1)); // Paper - single item in event BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ())); @@ -445,7 +436,7 @@ index 60d3319016beb4f60cbc26dde165f64cf7577602..fed5a27daf1074207f3a79745e97c899 worldserver.getCraftServer().getPluginManager().callEvent(event); } -@@ -771,7 +771,7 @@ public interface DispenseItemBehavior { +@@ -680,7 +680,7 @@ public interface DispenseItemBehavior { CraftItemStack craftItem = CraftItemStack.asCraftMirror(stack.copyWithCount(1)); // Paper - single item in event BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ())); @@ -454,7 +445,7 @@ index 60d3319016beb4f60cbc26dde165f64cf7577602..fed5a27daf1074207f3a79745e97c899 worldserver.getCraftServer().getPluginManager().callEvent(event); } -@@ -833,7 +833,7 @@ public interface DispenseItemBehavior { +@@ -742,7 +742,7 @@ public interface DispenseItemBehavior { CraftItemStack craftItem = CraftItemStack.asCraftMirror(stack.copyWithCount(1)); // Paper - only single item in event BlockDispenseEvent event = new BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockposition.getX(), blockposition.getY(), blockposition.getZ())); @@ -463,8 +454,8 @@ index 60d3319016beb4f60cbc26dde165f64cf7577602..fed5a27daf1074207f3a79745e97c899 worldserver.getCraftServer().getPluginManager().callEvent(event); } -@@ -915,7 +915,7 @@ public interface DispenseItemBehavior { - CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); +@@ -824,7 +824,7 @@ public interface DispenseItemBehavior { + CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); // Paper - ignore stack size on damageable items BlockDispenseEvent event = new BlockDispenseArmorEvent(block, craftItem.clone(), (org.bukkit.craftbukkit.entity.CraftLivingEntity) list.get(0).getBukkitEntity()); - if (!DispenserBlock.eventFired) { @@ -472,11 +463,37 @@ index 60d3319016beb4f60cbc26dde165f64cf7577602..fed5a27daf1074207f3a79745e97c899 world.getCraftServer().getPluginManager().callEvent(event); } +diff --git a/src/main/java/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.java b/src/main/java/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.java +index bf8c511739265c6a9cd277752e844481598f8966..d087b35b212e8bda1f6d8be35ed73fc759718c5e 100644 +--- a/src/main/java/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.java ++++ b/src/main/java/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.java +@@ -50,7 +50,7 @@ public class EquipmentDispenseItemBehavior extends DefaultDispenseItemBehavior { + CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); + + BlockDispenseArmorEvent event = new BlockDispenseArmorEvent(block, craftItem.clone(), (org.bukkit.craftbukkit.entity.CraftLivingEntity) entityliving.getBukkitEntity()); +- if (!DispenserBlock.eventFired) { ++ if (!DispenserBlock.eventFired.get()) { + world.getCraftServer().getPluginManager().callEvent(event); + } + +diff --git a/src/main/java/net/minecraft/core/dispenser/MinecartDispenseItemBehavior.java b/src/main/java/net/minecraft/core/dispenser/MinecartDispenseItemBehavior.java +index 3588896b7413be73ade6b3f8fd111d02c48ec550..913ef6c348af35053c93a37bc0ec719563740d56 100644 +--- a/src/main/java/net/minecraft/core/dispenser/MinecartDispenseItemBehavior.java ++++ b/src/main/java/net/minecraft/core/dispenser/MinecartDispenseItemBehavior.java +@@ -74,7 +74,7 @@ public class MinecartDispenseItemBehavior extends DefaultDispenseItemBehavior { + CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); + + BlockDispenseEvent event = new BlockDispenseEvent(block2, craftItem.clone(), new org.bukkit.util.Vector(vec3d1.x, vec3d1.y, vec3d1.z)); +- if (!DispenserBlock.eventFired) { ++ if (!DispenserBlock.eventFired.get()) { + worldserver.getCraftServer().getPluginManager().callEvent(event); + } + diff --git a/src/main/java/net/minecraft/core/dispenser/ProjectileDispenseBehavior.java b/src/main/java/net/minecraft/core/dispenser/ProjectileDispenseBehavior.java -index e37d2d29f3ba67cfe28abe4847a3dca07121f0be..1635ae6106ee751704cbaaddcd7b3ad606fa6ae9 100644 +index 54c72cf472e06e214eb61bd8615a0bb27690c807..e4bce6bd878be3405691062db2f05492f67cfafb 100644 --- a/src/main/java/net/minecraft/core/dispenser/ProjectileDispenseBehavior.java +++ b/src/main/java/net/minecraft/core/dispenser/ProjectileDispenseBehavior.java -@@ -45,7 +45,7 @@ public class ProjectileDispenseBehavior extends DefaultDispenseItemBehavior { +@@ -43,7 +43,7 @@ public class ProjectileDispenseBehavior extends DefaultDispenseItemBehavior { CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector((double) enumdirection.getStepX(), (double) enumdirection.getStepY(), (double) enumdirection.getStepZ())); @@ -486,7 +503,7 @@ index e37d2d29f3ba67cfe28abe4847a3dca07121f0be..1635ae6106ee751704cbaaddcd7b3ad6 } diff --git a/src/main/java/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java b/src/main/java/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java -index 44b79a7c2f8b95a484d1999fa2167ce588f7985b..5a2d9bbb702ba5844d2f9d36f3a5740c50edf938 100644 +index 65ed3d77a51b8299517e0c165403b0c5ac413475..f999c33552c611df733da93dcb9699b15fa54a92 100644 --- a/src/main/java/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java +++ b/src/main/java/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java @@ -41,7 +41,7 @@ public class ShearsDispenseItemBehavior extends OptionalDispenseItemBehavior { @@ -499,7 +516,7 @@ index 44b79a7c2f8b95a484d1999fa2167ce588f7985b..5a2d9bbb702ba5844d2f9d36f3a5740c } diff --git a/src/main/java/net/minecraft/core/dispenser/ShulkerBoxDispenseBehavior.java b/src/main/java/net/minecraft/core/dispenser/ShulkerBoxDispenseBehavior.java -index cb308808906a8cdb127df8284e106e00553473ca..323d41e2bed5e83a26dfe4c88dfce7ed87cdfb4c 100644 +index 8f9fde5489c0e1d0a91203536caddec5a9c96f6c..84617a7d6fae4a67f07d50a8e9410e359725b675 100644 --- a/src/main/java/net/minecraft/core/dispenser/ShulkerBoxDispenseBehavior.java +++ b/src/main/java/net/minecraft/core/dispenser/ShulkerBoxDispenseBehavior.java @@ -37,7 +37,7 @@ public class ShulkerBoxDispenseBehavior extends OptionalDispenseItemBehavior { @@ -512,11 +529,243 @@ index cb308808906a8cdb127df8284e106e00553473ca..323d41e2bed5e83a26dfe4c88dfce7ed } diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index f91374c44c392f9d28799fbf3538f99258d727b4..774595417ed7ddf67634cca04c58a6967b685cda 100644 +index 712ca8371188fceb99e1e3a898e5f8067e5a8a5a..6a477b1fe16c0ee0f560027f72404a6ae2d75ec3 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -324,6 +324,9 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop pluginsBlockingSleep = new ArrayList<>(); // Paper - API to allow/disallow tick sleeping public final Set entitiesWithScheduledTasks = java.util.concurrent.ConcurrentHashMap.newKeySet(); // SparklyPaper - skip EntityScheduler's executeTick checks if there isn't any tasks to be run (concurrent because plugins may schedule tasks async) public net.sparklypower.sparklypaper.HalloweenManager halloweenManager = new net.sparklypower.sparklypaper.HalloweenManager(); // SparklyPaper - Spooky month optimizations + // SparklyPaper - parallel world ticking @@ -525,7 +774,7 @@ index f91374c44c392f9d28799fbf3538f99258d727b4..774595417ed7ddf67634cca04c58a696 public static S spin(Function serverFactory) { AtomicReference atomicreference = new AtomicReference(); -@@ -1793,52 +1796,65 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 0; // Paper - BlockPhysicsEvent ++ worldserver.hasEntityMoveEvent = io.papermc.paper.event.entity.EntityMoveEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - Add EntityMoveEvent ++ net.minecraft.world.level.block.entity.HopperBlockEntity.skipHopperEvents = worldserver.paperConfig().hopper.disableMoveEvent || org.bukkit.event.inventory.InventoryMoveItemEvent.getHandlerList().getRegisteredListeners().length == 0; // Paper - Perf: Optimize Hoppers + worldserver.updateLagCompensationTick(); // Paper - lag compensation -+ worldserver.hasPhysicsEvent = org.bukkit.event.block.BlockPhysicsEvent.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 -+ worldserver.hasEntityMoveEvent = io.papermc.paper.event.entity.EntityMoveEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper + +- gameprofilerfiller.push(() -> { +- String s = String.valueOf(worldserver); ++ gameprofilerfiller.push(() -> { ++ String s = String.valueOf(worldserver); + +- return s + " " + String.valueOf(worldserver.dimension().location()); +- }); +- /* Drop global time updates +- if (this.tickCount % 20 == 0) { +- gameprofilerfiller.push("timeSync"); +- this.synchronizeTime(worldserver); +- gameprofilerfiller.pop(); +- } +- // CraftBukkit end */ +- +- gameprofilerfiller.push("tick"); ++ return s + " " + String.valueOf(worldserver.dimension().location()); ++ }); ++ /* Drop global time updates ++ if (this.tickCount % 20 == 0) { ++ gameprofilerfiller.push("timeSync"); ++ this.synchronizeTime(worldserver); ++ gameprofilerfiller.pop(); ++ } ++ // CraftBukkit end */ ++ ++ gameprofilerfiller.push("tick"); + + serverLevelTickingSemaphore.acquire(); + tasks.add( @@ -552,7 +829,6 @@ index f91374c44c392f9d28799fbf3538f99258d727b4..774595417ed7ddf67634cca04c58a696 + ca.spottedleaf.moonrise.common.util.TickThread.ServerLevelTickThread currentThread = (ca.spottedleaf.moonrise.common.util.TickThread.ServerLevelTickThread) Thread.currentThread(); + currentThread.currentlyTickingServerLevel = worldserver; + -+ worldserver.timings.doTick.startTiming(); // Spigot + long i = Util.getNanos(); // SparklyPaper - track world's MSPT + worldserver.tick(shouldKeepTicking); + // SparklyPaper start - track world's MSPT @@ -563,44 +839,18 @@ index f91374c44c392f9d28799fbf3538f99258d727b4..774595417ed7ddf67634cca04c58a696 + worldserver.tickTimes10s.add(this.tickCount, j); + worldserver.tickTimes60s.add(this.tickCount, j); + // SparklyPaper end -+ worldserver.timings.doTick.stopTiming(); // Spigot + } catch (Throwable throwable) { -+ // Spigot Start -+ CrashReport crashreport; -+ try { -+ crashreport = CrashReport.forThrowable(throwable, "Exception ticking world"); - -- this.profiler.push(() -> { -- String s = String.valueOf(worldserver); -+ } catch (Throwable t) { -+ if (throwable instanceof ThreadDeath) { -+ throw (ThreadDeath) throwable; -+ } // Paper -+ throw new RuntimeException("Error generating crash report", t); -+ } -+ // Spigot End ++ CrashReport crashreport = CrashReport.forThrowable(throwable, "Exception ticking world"); ++ + worldserver.fillReportDetails(crashreport); + throw new ReportedException(crashreport); + } finally { + serverLevelTickingSemaphore.release(); - -- return s + " " + String.valueOf(worldserver.dimension().location()); -- }); -- /* Drop global time updates -- if (this.tickCount % 20 == 0) { -- this.profiler.push("timeSync"); -- this.synchronizeTime(worldserver); -- this.profiler.pop(); + } + }, worldserver) + ); - } -- // CraftBukkit end */ -- -- this.profiler.push("tick"); -- + - try { -- worldserver.timings.doTick.startTiming(); // Spigot - long i = Util.getNanos(); // SparklyPaper - track world's MSPT - worldserver.tick(shouldKeepTicking); - // SparklyPaper start - track world's MSPT @@ -611,18 +861,21 @@ index f91374c44c392f9d28799fbf3538f99258d727b4..774595417ed7ddf67634cca04c58a696 - worldserver.tickTimes10s.add(this.tickCount, j); - worldserver.tickTimes60s.add(this.tickCount, j); - // SparklyPaper end -- worldserver.timings.doTick.stopTiming(); // Spigot - } catch (Throwable throwable) { - CrashReport crashreport = CrashReport.forThrowable(throwable, "Exception ticking world"); ++ while (!tasks.isEmpty()) { ++ tasks.pop().get(); ++ } - worldserver.fillReportDetails(crashreport); - throw new ReportedException(crashreport); -+ while (!tasks.isEmpty()) { -+ tasks.pop().get(); ++ gameprofilerfiller.pop(); ++ gameprofilerfiller.pop(); ++ worldserver.explosionDensityCache.clear(); // Paper - Optimize explosions } - -- this.profiler.pop(); -- this.profiler.pop(); +- gameprofilerfiller.pop(); +- gameprofilerfiller.pop(); - worldserver.explosionDensityCache.clear(); // Paper - Optimize explosions + } catch (java.lang.InterruptedException | java.util.concurrent.ExecutionException e) { + throw new RuntimeException(e); // Propagate exception @@ -630,8 +883,8 @@ index f91374c44c392f9d28799fbf3538f99258d727b4..774595417ed7ddf67634cca04c58a696 + // SparklyPaper end this.isIteratingOverLevels = false; // Paper - Throw exception on world create while being ticked - this.profiler.popPush("connection"); -@@ -1932,6 +1948,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop, ServerLevel> oldLevels = this.levels; Map, ServerLevel> newLevels = Maps.newLinkedHashMap(oldLevels); newLevels.remove(level.dimension()); @@ -640,26 +893,10 @@ index f91374c44c392f9d28799fbf3538f99258d727b4..774595417ed7ddf67634cca04c58a696 } // CraftBukkit end diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -index 1395e8f98bd87a060fb609c65a3311c220f5e9a8..df3270b9c57c96660e8402fcd927e890b50d848a 100644 +index e49e8e98ebbd3c8ba8a784f1626132699209b4e3..d952d42b8faee38f9d55fe578c0308916d31680c 100644 --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -@@ -18,6 +18,7 @@ import java.util.Collections; - import java.util.List; - import java.util.Locale; - import java.util.Optional; -+import java.util.concurrent.TimeUnit; - import java.util.function.BooleanSupplier; - import javax.annotation.Nullable; - import net.minecraft.DefaultUncaughtExceptionHandler; -@@ -57,6 +58,7 @@ import net.minecraft.world.level.GameRules; - import net.minecraft.world.level.GameType; - import net.minecraft.world.level.block.entity.SkullBlockEntity; - import net.minecraft.world.level.storage.LevelStorageSource; -+import net.sparklypower.sparklypaper.configs.SparklyPaperConfigUtils; - import org.slf4j.Logger; - - // CraftBukkit start -@@ -246,6 +248,8 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -243,6 +243,8 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface return false; } net.sparklypower.sparklypaper.SparklyPaperCommands.INSTANCE.registerCommands(this); @@ -668,24 +905,20 @@ index 1395e8f98bd87a060fb609c65a3311c220f5e9a8..df3270b9c57c96660e8402fcd927e890 // SparklyPaper end // SparklyPaper start - Spooky month optimizations halloweenManager.startHalloweenEpochTask(); -diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -index dcb5651d1d9b10b40430fb2f713beedf68336704..e395ff78b651f74f1582b8ae581908f58b64b2cc 100644 ---- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java -+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java -@@ -515,7 +515,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon - this.level.tickChunk(chunk1, l); - // Paper start - rewrite chunk system - if ((++chunksTicked & 7L) == 0L) { -- ((ca.spottedleaf.moonrise.patches.chunk_system.server.ChunkSystemMinecraftServer)this.level.getServer()).moonrise$executeMidTickTasks(); -+ // ((ca.spottedleaf.moonrise.patches.chunk_system.server.ChunkSystemMinecraftServer)this.level.getServer()).moonrise$executeMidTickTasks(); // SparklyPaper - parallel world ticking (only run mid-tick at the end of each tick / fixes concurrency bugs related to executeMidTickTasks) // Paper - } - // Paper end - rewrite chunk system - } diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index 7d3d46d693a0d0dd1c1932c29b18e98555d4e3da..0688f00a7facdc9f93bf9c47c3285826229b7ab4 100644 +index be488eb582f15996921eab5d63bcc73655e61a0b..7bed72ff80fbb088edaf790419bce3929568b5b0 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java -@@ -222,6 +222,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf. +@@ -200,7 +200,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe + private final MinecraftServer server; + public final PrimaryLevelData serverLevelData; // CraftBukkit - type + private int lastSpawnChunkRadius; +- final EntityTickList entityTickList = new EntityTickList(); ++ final EntityTickList entityTickList = new EntityTickList(this); + // Paper - rewrite chunk system + private final GameEventDispatcher gameEventDispatcher; + public boolean noSave; +@@ -224,6 +224,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe private final StructureCheck structureCheck; private final boolean tickTime; private final RandomSequences randomSequences; @@ -693,24 +926,15 @@ index 7d3d46d693a0d0dd1c1932c29b18e98555d4e3da..0688f00a7facdc9f93bf9c47c3285826 // CraftBukkit start public final LevelStorageSource.LevelStorageAccess convertable; -@@ -515,7 +516,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf. - this.uuid = WorldUUID.getUUID(convertable_conversionsession.levelDirectory.path().toFile()); - // CraftBukkit end - this.players = Lists.newArrayList(); -- this.entityTickList = new EntityTickList(); -+ this.entityTickList = new EntityTickList(this); - this.blockTicks = new LevelTicks<>(this::isPositionTickingWithEntitiesLoaded, this.getProfilerSupplier()); - this.fluidTicks = new LevelTicks<>(this::isPositionTickingWithEntitiesLoaded, this.getProfilerSupplier()); - this.pathTypesByPosCache = new PathTypeCache(); -@@ -596,6 +597,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf. - this.chunkTaskScheduler = new ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ChunkTaskScheduler((ServerLevel)(Object)this, ca.spottedleaf.moonrise.common.util.MoonriseCommon.WORKER_POOL); +@@ -682,6 +683,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe + this.chunkDataController = new ca.spottedleaf.moonrise.patches.chunk_system.io.datacontroller.ChunkDataController((ServerLevel)(Object)this, this.chunkTaskScheduler); // Paper end - rewrite chunk system this.getCraftServer().addWorld(this.getWorld()); // CraftBukkit + this.tickExecutor = java.util.concurrent.Executors.newSingleThreadExecutor(new net.sparklypower.sparklypaper.ServerLevelTickExecutorThreadFactory(getWorld().getName())); // SparklyPaper - parallel world ticking } // Paper start -@@ -1185,7 +1187,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf. +@@ -1251,7 +1253,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe } // Paper start - rewrite chunk system if ((++this.tickedBlocksOrFluids & 7L) != 0L) { @@ -719,7 +943,7 @@ index 7d3d46d693a0d0dd1c1932c29b18e98555d4e3da..0688f00a7facdc9f93bf9c47c3285826 } // Paper end - rewrite chunk system -@@ -1199,7 +1201,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf. +@@ -1265,7 +1267,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe } // Paper start - rewrite chunk system if ((++this.tickedBlocksOrFluids & 7L) != 0L) { @@ -728,7 +952,7 @@ index 7d3d46d693a0d0dd1c1932c29b18e98555d4e3da..0688f00a7facdc9f93bf9c47c3285826 } // Paper end - rewrite chunk system -@@ -1510,6 +1512,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf. +@@ -1558,6 +1560,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe } private void addPlayer(ServerPlayer player) { @@ -736,7 +960,7 @@ index 7d3d46d693a0d0dd1c1932c29b18e98555d4e3da..0688f00a7facdc9f93bf9c47c3285826 Entity entity = (Entity) this.getEntities().get(player.getUUID()); if (entity != null) { -@@ -1523,7 +1526,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf. +@@ -1571,7 +1574,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe // CraftBukkit start private boolean addEntity(Entity entity, CreatureSpawnEvent.SpawnReason spawnReason) { @@ -746,10 +970,10 @@ index 7d3d46d693a0d0dd1c1932c29b18e98555d4e3da..0688f00a7facdc9f93bf9c47c3285826 // Paper start - extra debug info if (entity.valid) { diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java -index c396580a9cfd86ff261bed439bb4662ae88010b5..d20178a37b0bdd2e8acfa22adf78682e7fd0f6b1 100644 +index 2e8ecf3bbb9f9ceba6f896738fa1ab8e2bd0fed6..020545ee8a73dcb4682067467f3dad425e2a01b3 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java -@@ -332,6 +332,7 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple +@@ -359,6 +359,7 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple return this.viewDistanceHolder; } // Paper end - rewrite chunk system @@ -757,7 +981,7 @@ index c396580a9cfd86ff261bed439bb4662ae88010b5..d20178a37b0bdd2e8acfa22adf78682e public ServerPlayer(MinecraftServer server, ServerLevel world, GameProfile profile, ClientInformation clientOptions) { super(world, world.getSharedSpawnPos(), world.getSharedSpawnAngle(), profile); -@@ -758,6 +759,7 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple +@@ -986,6 +987,7 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple @Override public void tick() { @@ -765,15 +989,15 @@ index c396580a9cfd86ff261bed439bb4662ae88010b5..d20178a37b0bdd2e8acfa22adf78682e // CraftBukkit start if (this.joining) { this.joining = false; -@@ -1357,6 +1359,7 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple - teleportTarget.postDimensionTransition().onTransition(this); +@@ -1629,6 +1631,7 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple + teleportTarget.postTeleportTransition().onTransition(this); return this; } else { + ca.spottedleaf.moonrise.common.util.TickThread.ensureOnlyTickThread("Cannot change dimension of a player off-main, from world " + serverLevel().getWorld().getName() + " to world " + worldserver.getWorld().getName()); // SparklyPaper - parallel world ticking (additional concurrency issues logs) // CraftBukkit start /* this.isChangingDimension = true; -@@ -1727,6 +1730,12 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple +@@ -1996,6 +1999,12 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple return OptionalInt.empty(); } else { // CraftBukkit start @@ -786,7 +1010,7 @@ index c396580a9cfd86ff261bed439bb4662ae88010b5..d20178a37b0bdd2e8acfa22adf78682e this.containerMenu = container; if (!this.isImmobile()) this.connection.send(new ClientboundOpenScreenPacket(container.containerId, container.getType(), Objects.requireNonNullElseGet(title, container::getTitle))); // Paper - Add titleOverride to InventoryOpenEvent // CraftBukkit end -@@ -1790,6 +1799,11 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple +@@ -2059,6 +2068,11 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple } @Override public void closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason reason) { @@ -799,7 +1023,7 @@ index c396580a9cfd86ff261bed439bb4662ae88010b5..d20178a37b0bdd2e8acfa22adf78682e // Paper end - Inventory close reason this.connection.send(new ClientboundContainerClosePacket(this.containerMenu.containerId)); diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index 5e2c4969e77c669acbb4a13c07033cb267c3d586..fd9a8dc0e552375802b17b52ae81ffe266d4c322 100644 +index 30de3d1a7792c38ae946f19cb0e14637919b5001..0ea2d2b32aacdbfca80c0c626520bd863601bbd2 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java @@ -137,7 +137,7 @@ public abstract class PlayerList { @@ -828,7 +1052,7 @@ index 5e2c4969e77c669acbb4a13c07033cb267c3d586..fd9a8dc0e552375802b17b52ae81ffe2 player.isRealPlayer = true; // Paper player.loginTime = System.currentTimeMillis(); // Paper - Replace OfflinePlayer#getLastPlayed GameProfile gameprofile = player.getGameProfile(); -@@ -806,6 +807,13 @@ public abstract class PlayerList { +@@ -769,6 +770,13 @@ public abstract class PlayerList { } public ServerPlayer respawn(ServerPlayer entityplayer, boolean flag, Entity.RemovalReason entity_removalreason, RespawnReason reason, Location location) { @@ -842,7 +1066,7 @@ index 5e2c4969e77c669acbb4a13c07033cb267c3d586..fd9a8dc0e552375802b17b52ae81ffe2 entityplayer.stopRiding(); // CraftBukkit this.players.remove(entityplayer); this.playersByName.remove(entityplayer.getScoreboardName().toLowerCase(java.util.Locale.ROOT)); // Spigot -@@ -818,6 +826,7 @@ public abstract class PlayerList { +@@ -781,6 +789,7 @@ public abstract class PlayerList { ServerPlayer entityplayer1 = entityplayer; Level fromWorld = entityplayer.level(); entityplayer.wonGame = false; @@ -851,10 +1075,10 @@ index 5e2c4969e77c669acbb4a13c07033cb267c3d586..fd9a8dc0e552375802b17b52ae81ffe2 entityplayer1.connection = entityplayer.connection; diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 4b54d0ea31062972e68ee8fafe3cfaf68f65a5cd..d9cf7b115e1e8492229a45a71ed9259e5b6f8ba3 100644 +index ed5b00620527c1776722d25b1b45f1544802a341..8ef7f08488413737f8dbc9048d9aec57bb14fe99 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -851,7 +851,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -926,7 +926,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess // CraftBukkit start public void postTick() { // No clean way to break out of ticking once the entity has been copied to a new world, so instead we move the portalling later in the tick cycle @@ -863,19 +1087,19 @@ index 4b54d0ea31062972e68ee8fafe3cfaf68f65a5cd..d9cf7b115e1e8492229a45a71ed9259e this.handlePortal(); } } -@@ -3996,6 +3996,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess - this.teleportPassengers(); - this.setYHeadRot(yaw); - } else { -+ ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread(world, "Cannot teleport entity to another world off-main, from world " + level.getWorld().getName() + " to world " + world.getWorld().getName()); // SparklyPaper - parallel world ticking (additional concurrency issues logs) - this.unRide(); - Entity entity = this.getType().create(world); +@@ -4030,6 +4030,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess + } + + private Entity teleportCrossDimension(ServerLevel world, TeleportTransition teleportTarget) { ++ ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread(world, "Cannot teleport entity to another world off-main, from world " + level.getWorld().getName() + " to world " + world.getWorld().getName()); // SparklyPaper - parallel world ticking (additional concurrency issues logs) + List list = this.getPassengers(); + List list1 = new ArrayList(list.size()); diff --git a/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java b/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java -index dd4218e108f87f3305b76fbc8d88f488b447c609..1f980e8336ad51056aed827ab43f634d60e4c7a1 100644 +index 4680f77a275d8d2b226018db89a571ac25998dd8..42b00ada65878545e464aa169698288982d46def 100644 --- a/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java +++ b/src/main/java/net/minecraft/world/inventory/AbstractContainerMenu.java -@@ -102,8 +102,14 @@ public abstract class AbstractContainerMenu { +@@ -106,8 +106,14 @@ public abstract class AbstractContainerMenu { this.title = title; } // CraftBukkit end @@ -890,24 +1114,11 @@ index dd4218e108f87f3305b76fbc8d88f488b447c609..1f980e8336ad51056aed827ab43f634d this.carried = ItemStack.EMPTY; this.remoteSlots = NonNullList.create(); this.remoteDataSlots = new IntArrayList(); -diff --git a/src/main/java/net/minecraft/world/item/ArmorItem.java b/src/main/java/net/minecraft/world/item/ArmorItem.java -index 647a4601deace52f8d855f512a73671f82b4762a..5b09aeb13537bb59017160cb4f4bffcc664ac80e 100644 ---- a/src/main/java/net/minecraft/world/item/ArmorItem.java -+++ b/src/main/java/net/minecraft/world/item/ArmorItem.java -@@ -68,7 +68,7 @@ public class ArmorItem extends Item implements Equipable { - CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); - - BlockDispenseArmorEvent event = new BlockDispenseArmorEvent(block, craftItem.clone(), (org.bukkit.craftbukkit.entity.CraftLivingEntity) entityliving.getBukkitEntity()); -- if (!DispenserBlock.eventFired) { -+ if (!DispenserBlock.eventFired.get()) { // SparklyPaper - parallel world ticking - world.getCraftServer().getPluginManager().callEvent(event); - } - diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java -index eec0ec43590be7e8ae5b530a7404c98b5e23cb53..e8f20a0f2c36bac5a00b1f57b5547bf3c340dbfe 100644 +index 33e7d2884195677c4d6340d8b84c1dd85c636ec1..02a719aaf7c860efbb51aed7d21cc83e14aef602 100644 --- a/src/main/java/net/minecraft/world/item/ItemStack.java +++ b/src/main/java/net/minecraft/world/item/ItemStack.java -@@ -442,8 +442,8 @@ public final class ItemStack implements DataComponentHolder { +@@ -445,8 +445,8 @@ public final class ItemStack implements DataComponentHolder { if (enuminteractionresult.consumesAction() && world.captureTreeGeneration && world.capturedBlockStates.size() > 0) { world.captureTreeGeneration = false; Location location = CraftLocation.toBukkit(blockposition, world.getWorld()); @@ -918,32 +1129,19 @@ index eec0ec43590be7e8ae5b530a7404c98b5e23cb53..e8f20a0f2c36bac5a00b1f57b5547bf3 List blocks = new java.util.ArrayList<>(world.capturedBlockStates.values()); world.capturedBlockStates.clear(); StructureGrowEvent structureEvent = null; -diff --git a/src/main/java/net/minecraft/world/item/MinecartItem.java b/src/main/java/net/minecraft/world/item/MinecartItem.java -index d524fcc191cb95d6ec7f12ae7fceeb8077bb08fc..451e5719613fc31bacf49c37978d4e49ea2dfad5 100644 ---- a/src/main/java/net/minecraft/world/item/MinecartItem.java -+++ b/src/main/java/net/minecraft/world/item/MinecartItem.java -@@ -71,7 +71,7 @@ public class MinecartItem extends Item { - CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1); - - BlockDispenseEvent event = new BlockDispenseEvent(block2, craftItem.clone(), new org.bukkit.util.Vector(d0, d1 + d3, d2)); -- if (!DispenserBlock.eventFired) { -+ if (!DispenserBlock.eventFired.get()) { // SparklyPaper - parallel world ticking - worldserver.getCraftServer().getPluginManager().callEvent(event); - } - diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index 7a50e3ecebee3c09052a52bb70504618bb3952e7..f1a2ff5252f19d8e69ab1e4200283a5049dc1e67 100644 +index 97b31dffbaf965e86ad706a1bba7586cd3514ead..43ae7091a3603908eb6c68c8b10c72b0bbb99428 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -174,6 +174,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -175,6 +175,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl public final com.destroystokyo.paper.antixray.ChunkPacketBlockController chunkPacketBlockController; // Paper - Anti-Xray public net.sparklypower.sparklypaper.configs.SparklyPaperConfig.SparklyPaperWorldConfig sparklyPaperConfig; // SparklyPaper + public com.destroystokyo.paper.util.RedstoneWireTurbo turbo = new com.destroystokyo.paper.util.RedstoneWireTurbo((net.minecraft.world.level.block.RedStoneWireBlock) net.minecraft.world.level.block.Blocks.REDSTONE_WIRE); // SparklyPaper - parallel world ticking (moved to world) - public final co.aikar.timings.WorldTimingsHandler timings; // Paper public static BlockPos lastPhysicsProblem; // Spigot private org.spigotmc.TickLimiter entityLimiter; -@@ -1016,6 +1017,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl + private org.spigotmc.TickLimiter tileLimiter; +@@ -1088,6 +1089,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl @Override public boolean setBlock(BlockPos pos, BlockState state, int flags, int maxUpdateDepth) { @@ -951,7 +1149,7 @@ index 7a50e3ecebee3c09052a52bb70504618bb3952e7..f1a2ff5252f19d8e69ab1e4200283a50 // CraftBukkit start - tree generation if (this.captureTreeGeneration) { // Paper start - Protect Bedrock and End Portal/Frames from being destroyed -@@ -1416,7 +1418,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -1487,7 +1489,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl tickingblockentity.tick(); // Paper start - rewrite chunk system if ((++tickedEntities & 7) == 0) { @@ -960,7 +1158,7 @@ index 7a50e3ecebee3c09052a52bb70504618bb3952e7..f1a2ff5252f19d8e69ab1e4200283a50 } // Paper end - rewrite chunk system } // SparklyPaper end -@@ -1442,7 +1444,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -1511,7 +1513,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl entity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD); // Paper end - Prevent block entity and entity crashes } @@ -969,7 +1167,7 @@ index 7a50e3ecebee3c09052a52bb70504618bb3952e7..f1a2ff5252f19d8e69ab1e4200283a50 } // Paper start - Option to prevent armor stands from doing entity lookups @Override -@@ -1559,6 +1561,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -1569,6 +1571,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl @Nullable public BlockEntity getBlockEntity(BlockPos blockposition, boolean validate) { @@ -977,7 +1175,7 @@ index 7a50e3ecebee3c09052a52bb70504618bb3952e7..f1a2ff5252f19d8e69ab1e4200283a50 // Paper start - Perf: Optimize capturedTileEntities lookup net.minecraft.world.level.block.entity.BlockEntity blockEntity; if (!this.capturedTileEntities.isEmpty() && (blockEntity = this.capturedTileEntities.get(blockposition)) != null) { -@@ -1570,6 +1573,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -1580,6 +1583,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl } public void setBlockEntity(BlockEntity blockEntity) { @@ -985,16 +1183,16 @@ index 7a50e3ecebee3c09052a52bb70504618bb3952e7..f1a2ff5252f19d8e69ab1e4200283a50 BlockPos blockposition = blockEntity.getBlockPos(); if (!this.isOutsideBuildHeight(blockposition)) { -@@ -1655,6 +1659,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -1665,6 +1669,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl @Override public List getEntities(@Nullable Entity except, AABB box, Predicate predicate) { + ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread((ServerLevel)this, box, "Cannot getEntities asynchronously"); // SparklyPaper - parallel world ticking (additional concurrency issues logs) - this.getProfiler().incrementCounter("getEntities"); - // Paper start - rewrite chunk system - final List ret = new java.util.ArrayList<>(); -@@ -1965,8 +1970,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl - public abstract RecipeManager getRecipeManager(); + Profiler.get().incrementCounter("getEntities"); + List list = Lists.newArrayList(); + +@@ -1991,8 +1996,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl + public abstract RecipeAccess recipeAccess(); public BlockPos getBlockRandomPos(int x, int y, int z, int l) { - this.randValue = this.randValue * 3 + 1013904223; @@ -1004,12 +1202,12 @@ index 7a50e3ecebee3c09052a52bb70504618bb3952e7..f1a2ff5252f19d8e69ab1e4200283a50 return new BlockPos(x + (i1 & 15), y + (i1 >> 16 & l), z + (i1 >> 8 & 15)); } diff --git a/src/main/java/net/minecraft/world/level/block/DispenserBlock.java b/src/main/java/net/minecraft/world/level/block/DispenserBlock.java -index e1021d8be840f378568f28639c259182055c78ac..d8728bed4aaff697af2f4051afbe779481ae61dd 100644 +index 5a6c153fa2873aecba0d0d02be2cc2a514f445e3..1f8f05c02072cdfc69be0b2d7d33fd9d363a9539 100644 --- a/src/main/java/net/minecraft/world/level/block/DispenserBlock.java +++ b/src/main/java/net/minecraft/world/level/block/DispenserBlock.java -@@ -51,7 +51,8 @@ public class DispenserBlock extends BaseEntityBlock { - object2objectopenhashmap.defaultReturnValue(DispenserBlock.DEFAULT_BEHAVIOR); - }); +@@ -52,7 +52,8 @@ public class DispenserBlock extends BaseEntityBlock { + private static final DefaultDispenseItemBehavior DEFAULT_BEHAVIOR = new DefaultDispenseItemBehavior(); + public static final Map DISPENSER_REGISTRY = new IdentityHashMap(); private static final int TRIGGER_DURATION = 4; - public static boolean eventFired = false; // CraftBukkit + // public static boolean eventFired = false; // CraftBukkit // SparklyPaper - parallel world ticking @@ -1017,7 +1215,7 @@ index e1021d8be840f378568f28639c259182055c78ac..d8728bed4aaff697af2f4051afbe7794 @Override public MapCodec codec() { -@@ -110,7 +111,7 @@ public class DispenserBlock extends BaseEntityBlock { +@@ -109,7 +110,7 @@ public class DispenserBlock extends BaseEntityBlock { if (idispensebehavior != DispenseItemBehavior.NOOP) { if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockPreDispenseEvent(world, pos, itemstack, i)) return; // Paper - Add BlockPreDispenseEvent @@ -1027,7 +1225,7 @@ index e1021d8be840f378568f28639c259182055c78ac..d8728bed4aaff697af2f4051afbe7794 } diff --git a/src/main/java/net/minecraft/world/level/block/FungusBlock.java b/src/main/java/net/minecraft/world/level/block/FungusBlock.java -index 454f95ba814b375e97189430b498c0e7486fbd94..8f5dc8a06a4d58cbc5f5ee27e0d0b384405e2c94 100644 +index ba5fff8892593a921f57cd55ad60cd6744ab4cf1..21b11b120a240ac39ef5d18a3401cb268dbfe6b1 100644 --- a/src/main/java/net/minecraft/world/level/block/FungusBlock.java +++ b/src/main/java/net/minecraft/world/level/block/FungusBlock.java @@ -76,9 +76,9 @@ public class FungusBlock extends BushBlock implements BonemealableBlock { @@ -1043,7 +1241,7 @@ index 454f95ba814b375e97189430b498c0e7486fbd94..8f5dc8a06a4d58cbc5f5ee27e0d0b384 // CraftBukkit end ((ConfiguredFeature) holder.value()).place(world, world.getChunkSource().getGenerator(), random, pos); diff --git a/src/main/java/net/minecraft/world/level/block/MushroomBlock.java b/src/main/java/net/minecraft/world/level/block/MushroomBlock.java -index 1172d85c5c26ab2142343d91149766e5993cb36a..54a5533761329237c3bf4304e2b0b652e62f5877 100644 +index 7900856c9e86afe907c00c9ac31bec93ece50abe..4e6adc7a8fd97613cb75d40fa38d504494bbe53b 100644 --- a/src/main/java/net/minecraft/world/level/block/MushroomBlock.java +++ b/src/main/java/net/minecraft/world/level/block/MushroomBlock.java @@ -105,7 +105,7 @@ public class MushroomBlock extends BushBlock implements BonemealableBlock { @@ -1056,10 +1254,10 @@ index 1172d85c5c26ab2142343d91149766e5993cb36a..54a5533761329237c3bf4304e2b0b652 return true; } else { diff --git a/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java b/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java -index c131734cad123a35456d18f8a161f77a4ac9ac99..b55be930980864ac7d8fdc44384b0106a6ca3619 100644 +index 21f2c61023fadcce30452a02f067cd5d87e5d8dc..056bd2cb7898f691940cdcb85d124948ac49c7d1 100644 --- a/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java +++ b/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java -@@ -260,7 +260,7 @@ public class RedStoneWireBlock extends Block { +@@ -292,7 +292,7 @@ public class RedStoneWireBlock extends Block { // Paper start - Optimize redstone (Eigencraft) // The bulk of the new functionality is found in RedstoneWireTurbo.java @@ -1068,24 +1266,24 @@ index c131734cad123a35456d18f8a161f77a4ac9ac99..b55be930980864ac7d8fdc44384b0106 /* * Modified version of pre-existing updateSurroundingRedstone, which is called from -@@ -269,7 +269,7 @@ public class RedStoneWireBlock extends Block { - */ - private void updateSurroundingRedstone(Level worldIn, BlockPos pos, BlockState state, BlockPos source) { - if (worldIn.paperConfig().misc.redstoneImplementation == io.papermc.paper.configuration.WorldConfiguration.Misc.RedstoneImplementation.EIGENCRAFT) { +@@ -308,7 +308,7 @@ public class RedStoneWireBlock extends Block { + if (orientation != null) { + source = pos.relative(orientation.getFront().getOpposite()); + } - turbo.updateSurroundingRedstone(worldIn, pos, state, source); + worldIn.turbo.updateSurroundingRedstone(worldIn, pos, state, source); // turbo.updateSurroundingRedstone(worldIn, pos, state, source); // SparklyPaper - parallel world ticking return; } - updatePowerStrength(worldIn, pos, state); -@@ -360,7 +360,7 @@ public class RedStoneWireBlock extends Block { + updatePowerStrength(worldIn, pos, state, orientation, blockAdded); +@@ -336,7 +336,7 @@ public class RedStoneWireBlock extends Block { // [Space Walker] suppress shape updates and emit those manually to // bypass the new neighbor update stack. - if (worldIn.setBlock(pos1, state, Block.UPDATE_KNOWN_SHAPE | Block.UPDATE_CLIENTS)) -- turbo.updateNeighborShapes(worldIn, pos1, state); -+ worldIn.turbo.updateNeighborShapes(worldIn, pos1, state); // turbo.updateNeighborShapes(worldIn, pos1, state); // SparklyPaper - parallel world ticking + if (level.setBlock(pos, state, Block.UPDATE_KNOWN_SHAPE | Block.UPDATE_CLIENTS)) { +- turbo.updateNeighborShapes(level, pos, state); ++ level.turbo.updateNeighborShapes(level, pos, state); + } } } - diff --git a/src/main/java/net/minecraft/world/level/block/SaplingBlock.java b/src/main/java/net/minecraft/world/level/block/SaplingBlock.java index d262a5a6da57ef9ba9a6fe0dfbc88f577105e74f..15db3fb971a944e856b3cde86035d290673c0c1a 100644 --- a/src/main/java/net/minecraft/world/level/block/SaplingBlock.java @@ -1111,7 +1309,7 @@ index d262a5a6da57ef9ba9a6fe0dfbc88f577105e74f..15db3fb971a944e856b3cde86035d290 java.util.List blocks = new java.util.ArrayList<>(world.capturedBlockStates.values()); world.capturedBlockStates.clear(); diff --git a/src/main/java/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java -index 2ddf349fde5b310ec3f74baee1f3d33e09d5286c..fe9c3479b61f79ed8ce3659d4e1ead8c9598ea8b 100644 +index 1f29b2419914ca9257db6553f01b7e7ec49bfc18..8297c5be8c35fc6762c433aa072a78bf5fd666da 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java @@ -82,6 +82,12 @@ public abstract class BaseContainerBlockEntity extends BlockEntity implements Co @@ -1128,7 +1326,7 @@ index 2ddf349fde5b310ec3f74baee1f3d33e09d5286c..fe9c3479b61f79ed8ce3659d4e1ead8c final org.bukkit.block.Block block = org.bukkit.craftbukkit.block.CraftBlock.at(blockEntity.getLevel(), blockEntity.getBlockPos()); net.kyori.adventure.text.Component lockedMessage = net.kyori.adventure.text.Component.translatable("container.isLocked", io.papermc.paper.adventure.PaperAdventure.asAdventure(containerName)); diff --git a/src/main/java/net/minecraft/world/level/block/entity/SculkCatalystBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/SculkCatalystBlockEntity.java -index a74732902c0494c67e6acf2fc04581ff9c46b832..fe9d7f0f800222c6eaafa903562c6106c09e84f2 100644 +index 4729befa12732a9fd65cce243b33b3b479026c41..a8113ee6b5a2e74182ba973231912ca636db5039 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/SculkCatalystBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/SculkCatalystBlockEntity.java @@ -46,9 +46,9 @@ public class SculkCatalystBlockEntity extends BlockEntity implements GameEventLi @@ -1144,10 +1342,10 @@ index a74732902c0494c67e6acf2fc04581ff9c46b832..fe9d7f0f800222c6eaafa903562c6106 @Override diff --git a/src/main/java/net/minecraft/world/level/block/grower/TreeGrower.java b/src/main/java/net/minecraft/world/level/block/grower/TreeGrower.java -index 597599138f69c9ee05dc7657c51c25336337875e..c9876514091f5cd0fc9c24b4f1577b1aef9f24e6 100644 +index 2fec480b6ca12a95013d920852db58722579caf1..5566c6a2992ac3aa0a9f9cd62f87d401c0a73179 100644 --- a/src/main/java/net/minecraft/world/level/block/grower/TreeGrower.java +++ b/src/main/java/net/minecraft/world/level/block/grower/TreeGrower.java -@@ -174,51 +174,53 @@ public final class TreeGrower { +@@ -175,55 +175,57 @@ public final class TreeGrower { // CraftBukkit start private void setTreeType(Holder> holder) { ResourceKey> worldgentreeabstract = holder.unwrapKey().get(); @@ -1215,6 +1413,12 @@ index 597599138f69c9ee05dc7657c51c25336337875e..c9876514091f5cd0fc9c24b4f1577b1a } else if (worldgentreeabstract == TreeFeatures.CHERRY || worldgentreeabstract == TreeFeatures.CHERRY_BEES_005) { - SaplingBlock.treeType = TreeType.CHERRY; + treeType = TreeType.CHERRY; + } else if (worldgentreeabstract == TreeFeatures.PALE_OAK) { +- SaplingBlock.treeType = TreeType.PALE_OAK; ++ treeType = TreeType.PALE_OAK; + } else if (worldgentreeabstract == TreeFeatures.PALE_OAK_CREAKING) { +- SaplingBlock.treeType = TreeType.PALE_OAK_CREAKING; ++ treeType = TreeType.PALE_OAK_CREAKING; } else { throw new IllegalArgumentException("Unknown tree generator " + worldgentreeabstract); } @@ -1223,10 +1427,10 @@ index 597599138f69c9ee05dc7657c51c25336337875e..c9876514091f5cd0fc9c24b4f1577b1a // CraftBukkit end 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 d7fe57e9a5aa59a7a9d611bcaa6152e72ec4c300..ca31e6bbb3a7af56b0cd08eaffc1c0e60042b8eb 100644 +index b4c16fe7c9215b5610b7e7488c29b497b5357ecc..9771f4ff6083868442fa142ef5c6c9a31397407f 100644 --- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java +++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java -@@ -359,6 +359,7 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p +@@ -382,6 +382,7 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p @Nullable public BlockState setBlockState(BlockPos blockposition, BlockState iblockdata, boolean flag, boolean doPlace) { @@ -1275,16 +1479,17 @@ index d8b4196adf955f8d414688dc451caac2d9c609d9..56089483da1313d2da90c1921af33c2d // (by dfl iterator() is configured to not iterate over new entries) final ca.spottedleaf.moonrise.common.list.IteratorSafeOrderedReferenceSet.Iterator iterator = this.entities.iterator(); diff --git a/src/main/java/net/minecraft/world/level/saveddata/maps/MapIndex.java b/src/main/java/net/minecraft/world/level/saveddata/maps/MapIndex.java -index 763b315b1d761bc3bd82d9b847ed3f64fd5ce991..b67dddabbae835cbe7261768fb14bfac4ad6c921 100644 +index 84f4664950e0cef7bd823bfc74f37cefce620d9e..b0c3b64da7aed676a5614c442948bbe96c3d2d73 100644 --- a/src/main/java/net/minecraft/world/level/saveddata/maps/MapIndex.java +++ b/src/main/java/net/minecraft/world/level/saveddata/maps/MapIndex.java @@ -34,17 +34,21 @@ public class MapIndex extends SavedData { @Override - public CompoundTag save(CompoundTag nbt, HolderLookup.Provider registryLookup) { + public CompoundTag save(CompoundTag nbt, HolderLookup.Provider registries) { + synchronized (this.usedAuxIds) { // SparklyPaper start - make map data thread-safe for (Entry entry : this.usedAuxIds.object2IntEntrySet()) { - nbt.putInt(entry.getKey(), entry.getIntValue()); +- nbt.putInt(entry.getKey(), entry.getIntValue()); ++ nbt.putInt(entry.getKey(), entry.getIntValue()); } + } // SparklyPaper end - make map data thread-safe @@ -1301,10 +1506,10 @@ index 763b315b1d761bc3bd82d9b847ed3f64fd5ce991..b67dddabbae835cbe7261768fb14bfac } } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index 33e4818ba5a90d78d69baad9f6b1be1b1382e9f3..9ef3b66934e49cb492fd45cec50943ff4c7d2031 100644 +index 8f234b46c24a0ae08aa5f8190c5b27e1f62dfbab..12f780b349e825747c2441d9636ae1dc667312e5 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -@@ -474,7 +474,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -458,7 +458,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { } private boolean unloadChunk0(int x, int z, boolean save) { @@ -1313,7 +1518,7 @@ index 33e4818ba5a90d78d69baad9f6b1be1b1382e9f3..9ef3b66934e49cb492fd45cec50943ff if (!this.isChunkLoaded(x, z)) { return true; } -@@ -495,6 +495,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -481,6 +481,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { if (!unloadChunk0(x, z, false)) { return false; } @@ -1321,7 +1526,7 @@ index 33e4818ba5a90d78d69baad9f6b1be1b1382e9f3..9ef3b66934e49cb492fd45cec50943ff warnUnsafeChunk("regenerating a faraway chunk", x, z); // Paper final long chunkKey = ChunkCoordIntPair.pair(x, z); -@@ -516,6 +517,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -502,6 +503,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public boolean refreshChunk(int x, int z) { @@ -1329,7 +1534,7 @@ index 33e4818ba5a90d78d69baad9f6b1be1b1382e9f3..9ef3b66934e49cb492fd45cec50943ff ChunkHolder playerChunk = this.world.getChunkSource().chunkMap.getVisibleChunkIfPresent(ChunkPos.asLong(x, z)); if (playerChunk == null) return false; -@@ -576,7 +578,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -562,7 +564,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public boolean loadChunk(int x, int z, boolean generate) { @@ -1338,7 +1543,7 @@ index 33e4818ba5a90d78d69baad9f6b1be1b1382e9f3..9ef3b66934e49cb492fd45cec50943ff warnUnsafeChunk("loading a faraway chunk", x, z); // Paper ChunkAccess chunk = this.world.getChunkSource().getChunk(x, z, generate || isChunkGenerated(x, z) ? ChunkStatus.FULL : ChunkStatus.EMPTY, true); // Paper -@@ -828,6 +830,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -814,6 +816,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public boolean generateTree(Location loc, TreeType type, BlockChangeDelegate delegate) { @@ -1346,23 +1551,15 @@ index 33e4818ba5a90d78d69baad9f6b1be1b1382e9f3..9ef3b66934e49cb492fd45cec50943ff this.world.captureTreeGeneration = true; this.world.captureBlockStates = true; boolean grownTree = this.generateTree(loc, type); -@@ -938,6 +941,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { - - @Override - public boolean createExplosion(double x, double y, double z, float power, boolean setFire, boolean breakBlocks, Entity source) { +@@ -929,6 +932,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { + } + public boolean createExplosion(double x, double y, double z, float power, boolean setFire, boolean breakBlocks, Entity source, Consumer configurator) { + // Paper end - expand explosion API + ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread(this.world, x, z, "Cannot create explosion asynchronously"); // SparklyPaper - parallel world ticking (additional concurrency issues logs) net.minecraft.world.level.Level.ExplosionInteraction explosionType; if (!breakBlocks) { explosionType = net.minecraft.world.level.Level.ExplosionInteraction.NONE; // Don't break blocks -@@ -952,6 +956,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { - // Paper start - @Override - public boolean createExplosion(Entity source, Location loc, float power, boolean setFire, boolean breakBlocks, boolean excludeSourceFromDamage) { -+ ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread(world, loc.getX(), loc.getZ(), "Cannot create explosion asynchronously"); // SparklyPaper - parallel world ticking (additional concurrency issues logs) - return !world.explode(source != null ? ((org.bukkit.craftbukkit.entity.CraftEntity) source).getHandle() : null, loc.getX(), loc.getY(), loc.getZ(), power, setFire, breakBlocks ? net.minecraft.world.level.Level.ExplosionInteraction.MOB : net.minecraft.world.level.Level.ExplosionInteraction.NONE, explosion -> { - explosion.excludeSourceFromDamage = excludeSourceFromDamage; - }).wasCanceled; -@@ -1030,6 +1035,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1020,6 +1024,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public int getHighestBlockYAt(int x, int z, org.bukkit.HeightMap heightMap) { @@ -1370,7 +1567,7 @@ index 33e4818ba5a90d78d69baad9f6b1be1b1382e9f3..9ef3b66934e49cb492fd45cec50943ff warnUnsafeChunk("getting a faraway chunk", x >> 4, z >> 4); // Paper // Transient load for this tick return this.world.getChunk(x >> 4, z >> 4).getHeight(CraftHeightMap.toNMS(heightMap), x, z); -@@ -1060,6 +1066,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1050,6 +1055,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void setBiome(int x, int y, int z, Holder bb) { BlockPos pos = new BlockPos(x, 0, z); @@ -1378,25 +1575,16 @@ index 33e4818ba5a90d78d69baad9f6b1be1b1382e9f3..9ef3b66934e49cb492fd45cec50943ff if (this.world.hasChunkAt(pos)) { net.minecraft.world.level.chunk.LevelChunk chunk = this.world.getChunkAt(pos); -@@ -2329,6 +2336,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -2322,6 +2328,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public void sendGameEvent(Entity sourceEntity, org.bukkit.GameEvent gameEvent, Vector position) { + ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread(this.world, position.getX(), position.getZ(), "Cannot send game event asynchronously"); // SparklyPaper - parallel world ticking (additional concurrency issues logs) - getHandle().gameEvent(sourceEntity != null ? ((CraftEntity) sourceEntity).getHandle(): null, net.minecraft.core.registries.BuiltInRegistries.GAME_EVENT.getHolder(org.bukkit.craftbukkit.util.CraftNamespacedKey.toMinecraft(gameEvent.getKey())).orElseThrow(), org.bukkit.craftbukkit.util.CraftVector.toBlockPos(position)); + getHandle().gameEvent(sourceEntity != null ? ((CraftEntity) sourceEntity).getHandle(): null, net.minecraft.core.registries.BuiltInRegistries.GAME_EVENT.get(org.bukkit.craftbukkit.util.CraftNamespacedKey.toMinecraft(gameEvent.getKey())).orElseThrow(), org.bukkit.craftbukkit.util.CraftVector.toBlockPos(position)); } // Paper end -@@ -2454,7 +2462,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { - // Paper start - public java.util.concurrent.CompletableFuture getChunkAtAsync(int x, int z, boolean gen, boolean urgent) { - warnUnsafeChunk("getting a faraway chunk async", x, z); // Paper -- if (Bukkit.isPrimaryThread()) { -+ if (ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(this.getHandle(), x, z)) { // SparklyPaper - parallel world ticking - net.minecraft.world.level.chunk.LevelChunk immediate = this.world.getChunkSource().getChunkAtIfLoadedImmediately(x, z); - if (immediate != null) { - return java.util.concurrent.CompletableFuture.completedFuture(new CraftChunk(immediate)); diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java -index ac11f18690434922179b61ffcc3036dea025b0cb..59b8136ebd0100f0f8e6ded002486b37415ddc73 100644 +index 5cb69d0b822e11a99a96aef4f59986d083b079f4..78f9c3f3b068f638570942961ad41969abc9c028 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java @@ -75,6 +75,11 @@ public class CraftBlock implements Block { @@ -1566,7 +1754,7 @@ index ac11f18690434922179b61ffcc3036dea025b0cb..59b8136ebd0100f0f8e6ded002486b37 this.getNMS().tick(level, this.position, level.random); } diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java -index 440b4c13121e3ac2bab937a83d20cc3fbf69bda1..7166ac09eaa855768e414904d3232bc3c92179e4 100644 +index 04ae258a2f8e98421340d29d5cceedec045171b7..3e90f16d303a8f3d1e2b01e7cbd62cbd991d3f06 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java @@ -25,7 +25,7 @@ public abstract class CraftBlockEntityState extends Craft @@ -1615,10 +1803,10 @@ index fa63a6cfcfcc4eee4503a82d85333c139c8c8b2b..9856860ee2987738bbcad5d752670e30 net.minecraft.world.item.ItemStack nms = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(item); diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java -index b7ff7af2513204b151340538d50a65c850bdb75f..45f9b2594e449926d7f00f64bf12fef2ea0a1393 100644 +index 56453454cbd4b9e9270fc833f8ab38d5fa7a3763..ad507c36d89ce8639fbedbb1df0da66bdc96affa 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java -@@ -247,8 +247,8 @@ public final class CraftBlockStates { +@@ -249,8 +249,8 @@ public final class CraftBlockStates { net.minecraft.world.level.block.state.BlockState blockData = craftBlock.getNMS(); BlockEntity tileEntity = craftBlock.getHandle().getBlockEntity(blockPosition); // Paper start - block state snapshots @@ -1629,7 +1817,7 @@ index b7ff7af2513204b151340538d50a65c850bdb75f..45f9b2594e449926d7f00f64bf12fef2 try { // Paper end CraftBlockState blockState = CraftBlockStates.getBlockState(world, blockPosition, blockData, tileEntity); -@@ -256,7 +256,7 @@ public final class CraftBlockStates { +@@ -258,7 +258,7 @@ public final class CraftBlockStates { return blockState; // Paper start } finally { @@ -1639,10 +1827,10 @@ index b7ff7af2513204b151340538d50a65c850bdb75f..45f9b2594e449926d7f00f64bf12fef2 // Paper end } diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -index beddb6a64e0ba5112d369794a066ca6b9f2ac303..5e29381a1077b1c997dfba4c9bedf85d6e583ca7 100644 +index 85926a55066ac793b2e4cfe3502f9ab201df91a3..122bcd352c01ba1a635c34a148bab25548301ee6 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -@@ -953,7 +953,7 @@ public class CraftEventFactory { +@@ -951,7 +951,7 @@ public class CraftEventFactory { return CraftEventFactory.handleBlockSpreadEvent(world, source, target, block, 2); } @@ -1651,7 +1839,7 @@ index beddb6a64e0ba5112d369794a066ca6b9f2ac303..5e29381a1077b1c997dfba4c9bedf85d public static boolean handleBlockSpreadEvent(LevelAccessor world, BlockPos source, BlockPos target, net.minecraft.world.level.block.state.BlockState block, int flag) { // Suppress during worldgen -@@ -965,7 +965,7 @@ public class CraftEventFactory { +@@ -963,7 +963,7 @@ public class CraftEventFactory { CraftBlockState state = CraftBlockStates.getBlockState(world, target, flag); state.setData(block); @@ -1660,7 +1848,7 @@ index beddb6a64e0ba5112d369794a066ca6b9f2ac303..5e29381a1077b1c997dfba4c9bedf85d Bukkit.getPluginManager().callEvent(event); if (!event.isCancelled()) { -@@ -2243,7 +2243,7 @@ public class CraftEventFactory { +@@ -2247,7 +2247,7 @@ public class CraftEventFactory { CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemStack.copyWithCount(1)); org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(bukkitBlock, craftItem.clone(), CraftVector.toBukkit(to)); diff --git a/patches/server/0024-SPARKLYPOWER-Add-custom-blocks.patch b/patches/server/0024-SPARKLYPOWER-Add-custom-blocks.patch index 6e26dcf..994e3c1 100644 --- a/patches/server/0024-SPARKLYPOWER-Add-custom-blocks.patch +++ b/patches/server/0024-SPARKLYPOWER-Add-custom-blocks.patch @@ -5,83 +5,78 @@ Subject: [PATCH] SPARKLYPOWER Add custom blocks 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 223259e7a09ada681b6181c898f6857888594f85..ad5ad428b72f696a68a9ed1436bede7135c534e5 100644 +index 66a07f7cbf1c1d6ecbe055cbf4f63eb07d93e90c..2738ccd47cbb7d26a6c92c2d86b1735003df9e2e 100644 --- a/src/main/java/net/minecraft/world/level/block/Blocks.java +++ b/src/main/java/net/minecraft/world/level/block/Blocks.java -@@ -41,9 +41,9 @@ import net.minecraft.world.level.material.PushReaction; - - public class Blocks { - private static final BlockBehaviour.StatePredicate NOT_CLOSED_SHULKER = (state, world, pos) -> !( -- world.getBlockEntity(pos) instanceof ShulkerBoxBlockEntity shulkerBoxBlockEntity -- ) -- || shulkerBoxBlockEntity.isClosed(); -+ world.getBlockEntity(pos) instanceof ShulkerBoxBlockEntity shulkerBoxBlockEntity -+ ) -+ || shulkerBoxBlockEntity.isClosed(); - public static final Block AIR = register("air", new AirBlock(BlockBehaviour.Properties.of().replaceable().noCollission().noLootTable().air())); - public static final Block STONE = register( - "stone", -@@ -7623,6 +7623,48 @@ public class Blocks { - .explosionResistance(1200.0F) - ) +@@ -6725,10 +6725,55 @@ public class Blocks { + .pushReaction(PushReaction.DESTROY) + .requiredFeatures(FeatureFlags.WINTER_DROP) ); + // SparklyPaper start - SparklyPower Survival custom blocks + // Blocks' strength should be synced with the replaced block on the client side! + public static final Block SPARKLYPOWER_RAINBOW_WOOL = register( -+ "sparklypower_rainbow_wool", new Block(BlockBehaviour.Properties.of().mapColor(MapColor.TERRACOTTA_RED).strength(0.5F).sound(SoundType.GRASS)) ++ "sparklypower_rainbow_wool", ++ Block::new, ++ BlockBehaviour.Properties.of().mapColor(MapColor.TERRACOTTA_RED).strength(0.5F).sound(SoundType.GRASS) + ); + public static final Block SPARKLYPOWER_RAINBOW_CONCRETE = register( -+ "sparklypower_rainbow_concrete", new Block(BlockBehaviour.Properties.of().mapColor(MapColor.TERRACOTTA_RED).strength(0.5F).sound(SoundType.GRASS)) ++ "sparklypower_rainbow_concrete", ++ Block::new, ++ BlockBehaviour.Properties.of().mapColor(MapColor.TERRACOTTA_RED).strength(0.5F).sound(SoundType.GRASS) + ); + public static final Block SPARKLYPOWER_RAINBOW_TERRACOTTA = register( -+ "sparklypower_rainbow_terracotta", new Block(BlockBehaviour.Properties.of().mapColor(MapColor.TERRACOTTA_RED).strength(0.5F).sound(SoundType.GRASS)) ++ "sparklypower_rainbow_terracotta", ++ Block::new, ++ BlockBehaviour.Properties.of().mapColor(MapColor.TERRACOTTA_RED).strength(0.5F).sound(SoundType.GRASS) + ); + public static final Block SPARKLYPOWER_ASPHALT_SERVER = register( -+ "sparklypower_asphalt_server", new Block( -+ BlockBehaviour.Properties.of() -+ .mapColor(MapColor.COLOR_BLACK) -+ .instrument(NoteBlockInstrument.BASEDRUM) -+ .requiresCorrectToolForDrops() -+ .strength(1.5F, 6.0F) -+ ) ++ "sparklypower_asphalt_server", ++ Block::new, ++ BlockBehaviour.Properties.of() ++ .mapColor(MapColor.COLOR_BLACK) ++ .instrument(NoteBlockInstrument.BASEDRUM) ++ .requiresCorrectToolForDrops() ++ .strength(1.5F, 6.0F) + ); + public static final Block SPARKLYPOWER_ASPHALT_SERVER_SLAB = register( + "sparklypower_asphalt_server_slab", -+ new SlabBlock( -+ BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_BLACK).instrument(NoteBlockInstrument.BASEDRUM).requiresCorrectToolForDrops().strength(2.0F, 6.0F) -+ ) ++ SlabBlock::new, ++ BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_BLACK).instrument(NoteBlockInstrument.BASEDRUM).requiresCorrectToolForDrops().strength(2.0F, 6.0F) + ); + public static final Block SPARKLYPOWER_ASPHALT_PLAYER = register( -+ "sparklypower_asphalt_player", new Block( -+ BlockBehaviour.Properties.of() -+ .mapColor(MapColor.COLOR_BLACK) -+ .instrument(NoteBlockInstrument.BASEDRUM) -+ .requiresCorrectToolForDrops() -+ .strength(1.5F, 6.0F) -+ ) ++ "sparklypower_asphalt_player", ++ Block::new, ++ BlockBehaviour.Properties.of() ++ .mapColor(MapColor.COLOR_BLACK) ++ .instrument(NoteBlockInstrument.BASEDRUM) ++ .requiresCorrectToolForDrops() ++ .strength(1.5F, 6.0F) + ); + public static final Block SPARKLYPOWER_ASPHALT_PLAYER_SLAB = register( + "sparklypower_asphalt_player_slab", -+ new SlabBlock( -+ BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_BLACK).instrument(NoteBlockInstrument.BASEDRUM).requiresCorrectToolForDrops().strength(2.0F, 6.0F) -+ ) ++ SlabBlock::new, ++ BlockBehaviour.Properties.of().mapColor(MapColor.COLOR_BLACK).instrument(NoteBlockInstrument.BASEDRUM).requiresCorrectToolForDrops().strength(2.0F, 6.0F) + ); + // SparklyPaper end private static ToIntFunction litBlockEmission(int litLevel) { - return state -> state.getValue(BlockStateProperties.LIT) ? litLevel : 0; +- return state -> state.getValue(BlockStateProperties.LIT) ? litLevel : 0; +- } ++ return state -> state.getValue(BlockStateProperties.LIT) ? litLevel : 0; } + + private static Function waterloggedMapColor(MapColor mapColor) { + return state -> state.getValue(BlockStateProperties.WATERLOGGED) ? MapColor.WATER : mapColor; diff --git a/src/test/java/org/bukkit/craftbukkit/legacy/LegacyTest.java b/src/test/java/org/bukkit/craftbukkit/legacy/LegacyTest.java -index b441eac617347131f2c58ae5092428eb0538c839..cb5d89b0fb8d9a579438387d5d317d662d0f1e0c 100644 +index 91926be355af20bba86be4c569cf7f972c79fbb5..26aa9cf0288055d5c8d9165ddc2ad3707b950ea4 100644 --- a/src/test/java/org/bukkit/craftbukkit/legacy/LegacyTest.java +++ b/src/test/java/org/bukkit/craftbukkit/legacy/LegacyTest.java -@@ -126,7 +126,9 @@ public class LegacyTest { - Material.FLOW_ARMOR_TRIM_SMITHING_TEMPLATE, Material.BOLT_ARMOR_TRIM_SMITHING_TEMPLATE, Material.FLOW_POTTERY_SHERD, Material.GUSTER_POTTERY_SHERD, Material.SCRAPE_POTTERY_SHERD, Material.BREEZE_ROD, Material.OMINOUS_TRIAL_KEY, Material.OMINOUS_BOTTLE, - // 1.21 - Material.MUSIC_DISC_CREATOR, Material.MUSIC_DISC_CREATOR_MUSIC_BOX, Material.MUSIC_DISC_PRECIPICE, -- // -+ // SparklyPaper start - custom blocks -+ Material.SPARKLYPOWER_RAINBOW_WOOL, Material.SPARKLYPOWER_RAINBOW_CONCRETE, Material.SPARKLYPOWER_RAINBOW_TERRACOTTA, Material.SPARKLYPOWER_ASPHALT_SERVER, Material.SPARKLYPOWER_ASPHALT_SERVER_SLAB, Material.SPARKLYPOWER_ASPHALT_PLAYER, Material.SPARKLYPOWER_ASPHALT_PLAYER_SLAB, -+ // SparklyPaper end +@@ -132,6 +132,9 @@ public class LegacyTest { + Material.CREAKING_SPAWN_EGG, Material.PALE_HANGING_MOSS, Material.PALE_MOSS_BLOCK, Material.PALE_MOSS_CARPET, Material.PALE_OAK_BOAT, Material.PALE_OAK_BUTTON, Material.PALE_OAK_CHEST_BOAT, Material.PALE_OAK_DOOR, Material.PALE_OAK_FENCE, + Material.PALE_OAK_FENCE_GATE, Material.PALE_OAK_HANGING_SIGN, Material.PALE_OAK_LEAVES, Material.PALE_OAK_LOG, Material.PALE_OAK_PLANKS, Material.PALE_OAK_PRESSURE_PLATE, Material.PALE_OAK_SAPLING, Material.PALE_OAK_SIGN, Material.PALE_OAK_SLAB, + Material.PALE_OAK_STAIRS, Material.PALE_OAK_TRAPDOOR, Material.PALE_OAK_WALL_SIGN, Material.PALE_OAK_WALL_HANGING_SIGN, Material.PALE_OAK_WOOD, Material.POTTED_PALE_OAK_SAPLING, Material.STRIPPED_PALE_OAK_LOG, Material.STRIPPED_PALE_OAK_WOOD, ++ // SparklyPower custom blocks ++ Material.SPARKLYPOWER_RAINBOW_WOOL, Material.SPARKLYPOWER_RAINBOW_CONCRETE, Material.SPARKLYPOWER_RAINBOW_TERRACOTTA, Material.SPARKLYPOWER_ASPHALT_PLAYER, Material.SPARKLYPOWER_ASPHALT_SERVER, Material.SPARKLYPOWER_ASPHALT_PLAYER_SLAB, ++ Material.SPARKLYPOWER_ASPHALT_SERVER_SLAB, + // Material.LEGACY_AIR, Material.LEGACY_DEAD_BUSH, Material.LEGACY_BURNING_FURNACE, Material.LEGACY_WALL_SIGN, Material.LEGACY_REDSTONE_TORCH_OFF, Material.LEGACY_SKULL, Material.LEGACY_REDSTONE_COMPARATOR_ON, Material.LEGACY_WALL_BANNER, Material.LEGACY_MONSTER_EGG)); - private final Set INVERSION_FAILS = new HashSet<>(Arrays.asList(Material.LEGACY_DOUBLE_STEP, Material.LEGACY_GLOWING_REDSTONE_ORE, Material.LEGACY_DIODE_BLOCK_ON, Material.LEGACY_REDSTONE_LAMP_ON, Material.LEGACY_WOOD_DOUBLE_STEP,