From 95a2786276bded4dc9d2e595b826ffc047fb4130 Mon Sep 17 00:00:00 2001 From: MrPowerGamerBR Date: Sat, 2 Dec 2023 22:26:02 -0300 Subject: [PATCH] Update Upstream Yet another patch merged into Paper, yay! --- README.md | 9 +++--- .../0002-SparklyPaper-config-files.patch | 29 +++++++++---------- ...m-Land-moisture-tick-rate-when-the-b.patch | 20 ------------- ...r-call-in-ServerEntity-sendChanges-.patch} | 0 ...te-if-the-map-does-not-have-the-Cra.patch} | 0 ...ssues-when-using-imageToBytes-in-mu.patch} | 0 ...s-copy-when-requesting-player-stats.patch} | 0 ...ler-s-executeTick-checks-if-there-i.patch} | 0 ...> 0010-Blazingly-Simple-Farm-Checks.patch} | 17 ++++------- ... => 0011-Spooky-month-optimizations.patch} | 0 ...key-used-for-nearby-players-when-ti.patch} | 0 ...atch => 0013-Optimize-canSee-checks.patch} | 0 ...t-Fix-MC-117075-TE-Unload-Lag-Spike.patch} | 0 ...5-Fix-MC-117075-TE-Unload-Lag-Spike.patch} | 0 ... => 0016-Optimize-tickBlockEntities.patch} | 0 ...Track-how-much-MSPT-each-world-used.patch} | 0 ...atch => 0018-Parallel-world-ticking.patch} | 8 ++--- 17 files changed, 27 insertions(+), 56 deletions(-) delete mode 100644 patches/server/0005-Configurable-Farm-Land-moisture-tick-rate-when-the-b.patch rename patches/server/{0006-Skip-distanceToSqr-call-in-ServerEntity-sendChanges-.patch => 0005-Skip-distanceToSqr-call-in-ServerEntity-sendChanges-.patch} (100%) rename patches/server/{0007-Skip-MapItem-update-if-the-map-does-not-have-the-Cra.patch => 0006-Skip-MapItem-update-if-the-map-does-not-have-the-Cra.patch} (100%) rename patches/server/{0008-Fix-concurrency-issues-when-using-imageToBytes-in-mu.patch => 0007-Fix-concurrency-issues-when-using-imageToBytes-in-mu.patch} (100%) rename patches/server/{0009-Skip-dirty-stats-copy-when-requesting-player-stats.patch => 0008-Skip-dirty-stats-copy-when-requesting-player-stats.patch} (100%) rename patches/server/{0010-Skip-EntityScheduler-s-executeTick-checks-if-there-i.patch => 0009-Skip-EntityScheduler-s-executeTick-checks-if-there-i.patch} (100%) rename patches/server/{0011-Blazingly-Simple-Farm-Checks.patch => 0010-Blazingly-Simple-Farm-Checks.patch} (92%) rename patches/server/{0012-Spooky-month-optimizations.patch => 0011-Spooky-month-optimizations.patch} (100%) rename patches/server/{0013-Cache-coordinate-key-used-for-nearby-players-when-ti.patch => 0012-Cache-coordinate-key-used-for-nearby-players-when-ti.patch} (100%) rename patches/server/{0014-Optimize-canSee-checks.patch => 0013-Optimize-canSee-checks.patch} (100%) rename patches/server/{0015-Revert-Fix-MC-117075-TE-Unload-Lag-Spike.patch => 0014-Revert-Fix-MC-117075-TE-Unload-Lag-Spike.patch} (100%) rename patches/server/{0016-Fix-MC-117075-TE-Unload-Lag-Spike.patch => 0015-Fix-MC-117075-TE-Unload-Lag-Spike.patch} (100%) rename patches/server/{0017-Optimize-tickBlockEntities.patch => 0016-Optimize-tickBlockEntities.patch} (100%) rename patches/server/{0018-Track-how-much-MSPT-each-world-used.patch => 0017-Track-how-much-MSPT-each-world-used.patch} (100%) rename patches/server/{0019-Parallel-world-ticking.patch => 0018-Parallel-world-ticking.patch} (99%) diff --git a/README.md b/README.md index 31f7295..695207a 100644 --- a/README.md +++ b/README.md @@ -16,9 +16,6 @@ This does not include all patches included in SparklyPaper, only the patches han SparklyPaper's config file is `sparklypaper.yml`, the file is, by default, placed on the root of your server. -* Configurable Farm Land moisture tick rate when the block is already moisturised - * The `isNearWater` check is costly, especially if you have a lot of farm lands. If the block is already moistured, we can change the tick rate of it to avoid these expensive `isNearWater` checks. - * (Incompatible with the Blazingly Simple Farm Checks feature) * Skip `distanceToSqr` call in `ServerEntity#sendChanges` if the delta movement hasn't changed * The `distanceToSqr` call is a bit expensive, so avoiding it is pretty nice, around ~15% calls are skipped with this check. Currently, we only check if both Vec3 objects have the same identity, that means, if they are literally the same object. (that works because Minecraft's code reuses the Vec3 object when caching the current delta movement) * Skip `MapItem#update()` if the map does not have the default `CraftMapRenderer` present @@ -46,6 +43,7 @@ SparklyPaper's config file is `sparklypaper.yml`, the file is, by default, place * The growth speed of crops and stems are now fixed based on if the block below them is moist or not, instead of doing vanilla's behavior of "check all blocks nearby to see if at least one of them is moist" and "if the blocks nearby are of the same time, make them grow slower". * In my opinion: Who cares about the vanilla behavior lol, most players only care about farm land + crop = crop go brrrr * Another optimization is that crop behavior can be changed to skip from age zero to the last age directly, while still keeping the original growth duration of the crop. This way, useless block updates due to crop growth can be avoided! + * (Incompatible with Paper's Dry and Wet Farmland custom tick rates) * Spooky month optimizations * The quintessential patch that other performance forks also have for... some reason??? I thought that this optimization was too funny to not do it in SparklyPaper. * Caches when Bat's spooky season starts and ends, and when Skeleton and Zombies halloween starts and ends. The epoch is updated every 90 days. If your server is running for 90+ days straight without restarts, congratulations! @@ -88,7 +86,10 @@ These features were originally in SparklyPaper, but now they are in Paper, yay! * To avoid this, we can just... not check for the item's durability! Don't worry, the durability of the item is checked when it checks if both item metas are equal. * This is a leftover from when checking for the item's durability was "free" because the durability was stored in the `ItemStack` itself, this [was changed in Minecraft 1.13](https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/commits/f8b2086d60942eb2cd7ac25a2a1408cb790c222c#src/main/java/org/bukkit/inventory/ItemStack.java). * (The reason I found out that this had a performance impact was because the `getDurability()` was using 0.08ms each tick according to spark... yeah, sadly it ain't a super big crazy optimization, the performance impact would be bigger if you have more plugins using `isSimilar(...)` tho) - +* Configurable Farm Land moisture tick rate when the block is already moisturised (Merged in [Paper #9968](https://github.com/PaperMC/Paper/pull/9968)) + * The `isNearWater` check is costly, especially if you have a lot of farm lands. If the block is already moistured, we can change the tick rate of it to avoid these expensive `isNearWater` checks. + * (Incompatible with the Blazingly Simple Farm Checks feature) + We attempt to upstream everything that we know helps performance and makes the server go zoom, and not stuff that we only *hope* that it improves performance. I'm still learning after all. :) ## Support diff --git a/patches/server/0002-SparklyPaper-config-files.patch b/patches/server/0002-SparklyPaper-config-files.patch index b3de1cd..caedf80 100644 --- a/patches/server/0002-SparklyPaper-config-files.patch +++ b/patches/server/0002-SparklyPaper-config-files.patch @@ -225,13 +225,14 @@ index 0000000000000000000000000000000000000000..6398c7b40ba82ffc8588eca458ce92c2 \ No newline at end of file diff --git a/src/main/kotlin/net/sparklypower/sparklypaper/configs/SparklyPaperConfigUtils.kt b/src/main/kotlin/net/sparklypower/sparklypaper/configs/SparklyPaperConfigUtils.kt new file mode 100644 -index 0000000000000000000000000000000000000000..155ef71c119ebeb95fdfae9e681520b91874ba8e +index 0000000000000000000000000000000000000000..8b78f0e8b1de1a6a2506e686be9d71ced72352dd --- /dev/null +++ b/src/main/kotlin/net/sparklypower/sparklypaper/configs/SparklyPaperConfigUtils.kt -@@ -0,0 +1,56 @@ +@@ -0,0 +1,61 @@ +package net.sparklypower.sparklypaper.configs + +import com.charleskorn.kaml.Yaml ++import com.charleskorn.kaml.YamlConfiguration +import com.google.common.base.Throwables +import kotlinx.serialization.SerializationException +import kotlinx.serialization.decodeFromString @@ -241,7 +242,11 @@ index 0000000000000000000000000000000000000000..155ef71c119ebeb95fdfae9e681520b9 +import java.util.logging.Level + +object SparklyPaperConfigUtils { -+ val yaml = Yaml() ++ val yaml = Yaml( ++ configuration = YamlConfiguration( ++ strictMode = false ++ ) ++ ) + lateinit var config: SparklyPaperConfig + + fun init(configFile: File) { @@ -261,9 +266,6 @@ index 0000000000000000000000000000000000000000..155ef71c119ebeb95fdfae9e681520b9 + defaultGrowthSpeed = 1.0f, + moistGrowthSpeed = 5.0f, + skipMiddleAgingStagesForCrops = true -+ ), -+ SparklyPaperWorldConfig.TickRates( -+ farmWhenMoisturised = 1 + ) + ) + ) @@ -278,6 +280,9 @@ index 0000000000000000000000000000000000000000..155ef71c119ebeb95fdfae9e681520b9 + Bukkit.getLogger().log(Level.SEVERE, "Could not load sparklypaper.yml, please correct your syntax errors", e) + throw Throwables.propagate(e) + } ++ // Rewrite the config file to remove old fields and stuff ++ // TODO: Maybe handle this in another way? This feels kinda bad ++ configFile.writeText(yaml.encodeToString(loadedConfig)) + config = loadedConfig + } + @@ -288,10 +293,10 @@ index 0000000000000000000000000000000000000000..155ef71c119ebeb95fdfae9e681520b9 \ No newline at end of file diff --git a/src/main/kotlin/net/sparklypower/sparklypaper/configs/SparklyPaperWorldConfig.kt b/src/main/kotlin/net/sparklypower/sparklypaper/configs/SparklyPaperWorldConfig.kt new file mode 100644 -index 0000000000000000000000000000000000000000..d2c53262581710d2ca4b588331fe54458015bfe8 +index 0000000000000000000000000000000000000000..0909362629aa4f6cdfd4052b4b1dc847cbdb57d8 --- /dev/null +++ b/src/main/kotlin/net/sparklypower/sparklypaper/configs/SparklyPaperWorldConfig.kt -@@ -0,0 +1,31 @@ +@@ -0,0 +1,23 @@ +package net.sparklypower.sparklypaper.configs + +import kotlinx.serialization.SerialName @@ -303,8 +308,6 @@ index 0000000000000000000000000000000000000000..d2c53262581710d2ca4b588331fe5445 + val skipMapItemDataUpdatesIfMapDoesNotHaveCraftMapRenderer: Boolean, + @SerialName("blazingly-simple-farm-checks") + val blazinglySimpleFarmChecks: BlazinglySimpleFarmChecks, -+ @SerialName("tick-rates") -+ val tickRates: TickRates +) { + @Serializable + data class BlazinglySimpleFarmChecks( @@ -316,11 +319,5 @@ index 0000000000000000000000000000000000000000..d2c53262581710d2ca4b588331fe5445 + @SerialName("skip-middle-aging-stages-for-crops") + val skipMiddleAgingStagesForCrops: Boolean + ) -+ -+ @Serializable -+ data class TickRates( -+ @SerialName("farm-when-moisturised") -+ val farmWhenMoisturised: Int -+ ) +} \ No newline at end of file diff --git a/patches/server/0005-Configurable-Farm-Land-moisture-tick-rate-when-the-b.patch b/patches/server/0005-Configurable-Farm-Land-moisture-tick-rate-when-the-b.patch deleted file mode 100644 index c99afc9..0000000 --- a/patches/server/0005-Configurable-Farm-Land-moisture-tick-rate-when-the-b.patch +++ /dev/null @@ -1,20 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: MrPowerGamerBR -Date: Sun, 22 Oct 2023 10:47:22 -0300 -Subject: [PATCH] Configurable Farm Land moisture tick rate when the block is - already moisturised - -The isNearWater check is costly, especially if you have a lot of farm lands. If the block is already moistured, we can change the tick rate of it to avoid these expensive isNearWater checks - -diff --git a/src/main/java/net/minecraft/world/level/block/FarmBlock.java b/src/main/java/net/minecraft/world/level/block/FarmBlock.java -index 5946f06f63b5694034bd027984a4925b0831d439..590a573a9b5099d3062031dc54978993cdd912ad 100644 ---- a/src/main/java/net/minecraft/world/level/block/FarmBlock.java -+++ b/src/main/java/net/minecraft/world/level/block/FarmBlock.java -@@ -85,6 +85,7 @@ public class FarmBlock extends Block { - @Override - public void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) { - int i = (Integer) state.getValue(FarmBlock.MOISTURE); -+ if (i > 0 && world.sparklyPaperConfig.getTickRates().getFarmWhenMoisturised() != 1 && (world.sparklyPaperConfig.getTickRates().getFarmWhenMoisturised() < 1 || (net.minecraft.server.MinecraftServer.currentTick + pos.hashCode()) % world.sparklyPaperConfig.getTickRates().getFarmWhenMoisturised() != 0)) { return; } // SparklyPaper - - if (!FarmBlock.isNearWater(world, pos) && !world.isRainingAt(pos.above())) { - if (i > 0) { diff --git a/patches/server/0006-Skip-distanceToSqr-call-in-ServerEntity-sendChanges-.patch b/patches/server/0005-Skip-distanceToSqr-call-in-ServerEntity-sendChanges-.patch similarity index 100% rename from patches/server/0006-Skip-distanceToSqr-call-in-ServerEntity-sendChanges-.patch rename to patches/server/0005-Skip-distanceToSqr-call-in-ServerEntity-sendChanges-.patch diff --git a/patches/server/0007-Skip-MapItem-update-if-the-map-does-not-have-the-Cra.patch b/patches/server/0006-Skip-MapItem-update-if-the-map-does-not-have-the-Cra.patch similarity index 100% rename from patches/server/0007-Skip-MapItem-update-if-the-map-does-not-have-the-Cra.patch rename to patches/server/0006-Skip-MapItem-update-if-the-map-does-not-have-the-Cra.patch diff --git a/patches/server/0008-Fix-concurrency-issues-when-using-imageToBytes-in-mu.patch b/patches/server/0007-Fix-concurrency-issues-when-using-imageToBytes-in-mu.patch similarity index 100% rename from patches/server/0008-Fix-concurrency-issues-when-using-imageToBytes-in-mu.patch rename to patches/server/0007-Fix-concurrency-issues-when-using-imageToBytes-in-mu.patch diff --git a/patches/server/0009-Skip-dirty-stats-copy-when-requesting-player-stats.patch b/patches/server/0008-Skip-dirty-stats-copy-when-requesting-player-stats.patch similarity index 100% rename from patches/server/0009-Skip-dirty-stats-copy-when-requesting-player-stats.patch rename to patches/server/0008-Skip-dirty-stats-copy-when-requesting-player-stats.patch diff --git a/patches/server/0010-Skip-EntityScheduler-s-executeTick-checks-if-there-i.patch b/patches/server/0009-Skip-EntityScheduler-s-executeTick-checks-if-there-i.patch similarity index 100% rename from patches/server/0010-Skip-EntityScheduler-s-executeTick-checks-if-there-i.patch rename to patches/server/0009-Skip-EntityScheduler-s-executeTick-checks-if-there-i.patch diff --git a/patches/server/0011-Blazingly-Simple-Farm-Checks.patch b/patches/server/0010-Blazingly-Simple-Farm-Checks.patch similarity index 92% rename from patches/server/0011-Blazingly-Simple-Farm-Checks.patch rename to patches/server/0010-Blazingly-Simple-Farm-Checks.patch index d77c86b..9a81937 100644 --- a/patches/server/0011-Blazingly-Simple-Farm-Checks.patch +++ b/patches/server/0010-Blazingly-Simple-Farm-Checks.patch @@ -76,17 +76,10 @@ index 6365ddea0c23bc5d4009d98915f2b39aed2a0328..41a0a22bf28eec79bc6dd96622789a2f } diff --git a/src/main/java/net/minecraft/world/level/block/FarmBlock.java b/src/main/java/net/minecraft/world/level/block/FarmBlock.java -index 590a573a9b5099d3062031dc54978993cdd912ad..544131216aff2b2b54b8690d4321a194deab1589 100644 +index 502dcba14da9d3dcefc61fdc349a4e1e1d94b478..fc8d56f02e8b22261cf2f205b39dfa1aeea5a7ff 100644 --- a/src/main/java/net/minecraft/world/level/block/FarmBlock.java +++ b/src/main/java/net/minecraft/world/level/block/FarmBlock.java -@@ -1,6 +1,5 @@ - package net.minecraft.world.level.block; - --import java.util.Iterator; - import javax.annotation.Nullable; - import net.minecraft.core.BlockPos; - import net.minecraft.core.Direction; -@@ -85,6 +84,19 @@ public class FarmBlock extends Block { +@@ -85,6 +85,19 @@ public class FarmBlock extends Block { @Override public void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) { int i = (Integer) state.getValue(FarmBlock.MOISTURE); @@ -103,10 +96,10 @@ index 590a573a9b5099d3062031dc54978993cdd912ad..544131216aff2b2b54b8690d4321a194 + return; + } + // SparklyPaper end - if (i > 0 && world.sparklyPaperConfig.getTickRates().getFarmWhenMoisturised() != 1 && (world.sparklyPaperConfig.getTickRates().getFarmWhenMoisturised() < 1 || (net.minecraft.server.MinecraftServer.currentTick + pos.hashCode()) % world.sparklyPaperConfig.getTickRates().getFarmWhenMoisturised() != 0)) { return; } // SparklyPaper + if (i > 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 + 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 - if (!FarmBlock.isNearWater(world, pos) && !world.isRainingAt(pos.above())) { -@@ -142,7 +154,7 @@ public class FarmBlock extends Block { +@@ -143,7 +156,7 @@ public class FarmBlock extends Block { return world.getBlockState(pos.above()).is(BlockTags.MAINTAINS_FARMLAND); } diff --git a/patches/server/0012-Spooky-month-optimizations.patch b/patches/server/0011-Spooky-month-optimizations.patch similarity index 100% rename from patches/server/0012-Spooky-month-optimizations.patch rename to patches/server/0011-Spooky-month-optimizations.patch diff --git a/patches/server/0013-Cache-coordinate-key-used-for-nearby-players-when-ti.patch b/patches/server/0012-Cache-coordinate-key-used-for-nearby-players-when-ti.patch similarity index 100% rename from patches/server/0013-Cache-coordinate-key-used-for-nearby-players-when-ti.patch rename to patches/server/0012-Cache-coordinate-key-used-for-nearby-players-when-ti.patch diff --git a/patches/server/0014-Optimize-canSee-checks.patch b/patches/server/0013-Optimize-canSee-checks.patch similarity index 100% rename from patches/server/0014-Optimize-canSee-checks.patch rename to patches/server/0013-Optimize-canSee-checks.patch diff --git a/patches/server/0015-Revert-Fix-MC-117075-TE-Unload-Lag-Spike.patch b/patches/server/0014-Revert-Fix-MC-117075-TE-Unload-Lag-Spike.patch similarity index 100% rename from patches/server/0015-Revert-Fix-MC-117075-TE-Unload-Lag-Spike.patch rename to patches/server/0014-Revert-Fix-MC-117075-TE-Unload-Lag-Spike.patch diff --git a/patches/server/0016-Fix-MC-117075-TE-Unload-Lag-Spike.patch b/patches/server/0015-Fix-MC-117075-TE-Unload-Lag-Spike.patch similarity index 100% rename from patches/server/0016-Fix-MC-117075-TE-Unload-Lag-Spike.patch rename to patches/server/0015-Fix-MC-117075-TE-Unload-Lag-Spike.patch diff --git a/patches/server/0017-Optimize-tickBlockEntities.patch b/patches/server/0016-Optimize-tickBlockEntities.patch similarity index 100% rename from patches/server/0017-Optimize-tickBlockEntities.patch rename to patches/server/0016-Optimize-tickBlockEntities.patch diff --git a/patches/server/0018-Track-how-much-MSPT-each-world-used.patch b/patches/server/0017-Track-how-much-MSPT-each-world-used.patch similarity index 100% rename from patches/server/0018-Track-how-much-MSPT-each-world-used.patch rename to patches/server/0017-Track-how-much-MSPT-each-world-used.patch diff --git a/patches/server/0019-Parallel-world-ticking.patch b/patches/server/0018-Parallel-world-ticking.patch similarity index 99% rename from patches/server/0019-Parallel-world-ticking.patch rename to patches/server/0018-Parallel-world-ticking.patch index d58a81b..64e1fb2 100644 --- a/patches/server/0019-Parallel-world-ticking.patch +++ b/patches/server/0018-Parallel-world-ticking.patch @@ -2235,12 +2235,12 @@ index 0000000000000000000000000000000000000000..3d536f724ffdae462e3af39e85e4e391 +} \ No newline at end of file diff --git a/src/main/kotlin/net/sparklypower/sparklypaper/configs/SparklyPaperConfigUtils.kt b/src/main/kotlin/net/sparklypower/sparklypaper/configs/SparklyPaperConfigUtils.kt -index 155ef71c119ebeb95fdfae9e681520b91874ba8e..e1f898bd806f6bcdde477eb9af18cc4b2ff6446e 100644 +index 8b78f0e8b1de1a6a2506e686be9d71ced72352dd..ce608ca9640cdea0fe690ef61021355822284cf6 100644 --- a/src/main/kotlin/net/sparklypower/sparklypaper/configs/SparklyPaperConfigUtils.kt +++ b/src/main/kotlin/net/sparklypower/sparklypaper/configs/SparklyPaperConfigUtils.kt -@@ -12,6 +12,7 @@ import java.util.logging.Level - object SparklyPaperConfigUtils { - val yaml = Yaml() +@@ -17,6 +17,7 @@ object SparklyPaperConfigUtils { + ) + ) lateinit var config: SparklyPaperConfig + val logContainerCreationStacktraces = java.lang.Boolean.getBoolean("sparklypaper.logContainerCreationStacktraces")