diff options
author | Spottedleaf <[email protected]> | 2023-05-27 20:34:33 +0200 |
---|---|---|
committer | Nassim Jahnke <[email protected]> | 2023-05-27 20:34:33 +0200 |
commit | f9f90791e43f396ed12be5e0e8867691fc87dbe7 (patch) | |
tree | 680e34aedb188fe60a0c7178ff24d81ff023f6e5 | |
parent | 90a0835f43f23aeddf5e2013b3f25d5e4490c8f8 (diff) | |
download | Paper-f9f90791e43f396ed12be5e0e8867691fc87dbe7.tar.gz Paper-f9f90791e43f396ed12be5e0e8867691fc87dbe7.zip |
Pull a few Folia patches
4 files changed, 94 insertions, 2 deletions
diff --git a/patches/server/0432-incremental-chunk-and-player-saving.patch b/patches/server/0432-incremental-chunk-and-player-saving.patch index f7c986b53a..dbca41fb93 100644 --- a/patches/server/0432-incremental-chunk-and-player-saving.patch +++ b/patches/server/0432-incremental-chunk-and-player-saving.patch @@ -127,7 +127,7 @@ index 2c052d0a8c6d58ad8eae41c22c753327342e90f1..5b6ecebcb4585877a2761eb17f481004 private static final int NEUTRAL_MOB_DEATH_NOTIFICATION_RADII_Y = 10; public ServerGamePacketListenerImpl connection; diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java -index 0e2a84148e721a8f799f0746e379c16a5f7f0dd3..9fefab398072721e3b0aebea0146d82f9046c203 100644 +index 0e2a84148e721a8f799f0746e379c16a5f7f0dd3..5abcdc6901de56e4ba264f395b5ff0aac1b84c23 100644 --- a/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java @@ -528,6 +528,7 @@ public abstract class PlayerList { @@ -156,7 +156,7 @@ index 0e2a84148e721a8f799f0746e379c16a5f7f0dd3..9fefab398072721e3b0aebea0146d82f + ServerPlayer entityplayer = this.players.get(i); + if (interval == -1 || now - entityplayer.lastSave >= interval) { + this.save(entityplayer); -+ if (interval != -1 && io.papermc.paper.configuration.GlobalConfiguration.get().playerAutoSave.maxPerTick() != -1 && ++numSaved >= io.papermc.paper.configuration.GlobalConfiguration.get().playerAutoSave.maxPerTick()) { break; } ++ if (interval != -1 && ++numSaved >= io.papermc.paper.configuration.GlobalConfiguration.get().playerAutoSave.maxPerTick()) { break; } + } + // Paper end } diff --git a/patches/server/0981-Fix-concurrenct-access-to-lookups-field-in-RegistryO.patch b/patches/server/0981-Fix-concurrenct-access-to-lookups-field-in-RegistryO.patch new file mode 100644 index 0000000000..4879c51f2a --- /dev/null +++ b/patches/server/0981-Fix-concurrenct-access-to-lookups-field-in-RegistryO.patch @@ -0,0 +1,30 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Spottedleaf <[email protected]> +Date: Mon, 15 May 2023 00:20:59 -0700 +Subject: [PATCH] Fix concurrenct access to lookups field in RegistryOps + +The concurrent access occurs on the Netty IO threads when +serializing packets. Thus, it seems it was an oversight of +the implementator of this function as there are typically +more than one Netty IO thread. + +Fixes https://github.com/PaperMC/Folia/issues/11 + +diff --git a/src/main/java/net/minecraft/resources/RegistryOps.java b/src/main/java/net/minecraft/resources/RegistryOps.java +index 7709eeac907c4895a264cec0a3d453aa8b194c18..4495802efec958095bcfd41487b30c3c799d7b36 100644 +--- a/src/main/java/net/minecraft/resources/RegistryOps.java ++++ b/src/main/java/net/minecraft/resources/RegistryOps.java +@@ -19,11 +19,11 @@ public class RegistryOps<T> extends DelegatingOps<T> { + + private static RegistryOps.RegistryInfoLookup memoizeLookup(final RegistryOps.RegistryInfoLookup registryInfoGetter) { + return new RegistryOps.RegistryInfoLookup() { +- private final Map<ResourceKey<? extends Registry<?>>, Optional<? extends RegistryOps.RegistryInfo<?>>> lookups = new HashMap<>(); ++ private final Map<ResourceKey<? extends Registry<?>>, Optional<? extends RegistryOps.RegistryInfo<?>>> lookups = new java.util.concurrent.ConcurrentHashMap<>(); // Paper - fix concurrent access to lookups field + + @Override + public <T> Optional<RegistryOps.RegistryInfo<T>> lookup(ResourceKey<? extends Registry<? extends T>> registryRef) { +- return this.lookups.computeIfAbsent(registryRef, registryInfoGetter::lookup); ++ return (Optional<RegistryOps.RegistryInfo<T>>)this.lookups.computeIfAbsent(registryRef, registryInfoGetter::lookup); // Paper - fix concurrent access to lookups field + } + }; + } diff --git a/patches/server/0982-Optimise-recalcBlockCounts-for-empty-sections.patch b/patches/server/0982-Optimise-recalcBlockCounts-for-empty-sections.patch new file mode 100644 index 0000000000..7380d66f2b --- /dev/null +++ b/patches/server/0982-Optimise-recalcBlockCounts-for-empty-sections.patch @@ -0,0 +1,37 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Spottedleaf <[email protected]> +Date: Mon, 15 May 2023 20:25:26 -0700 +Subject: [PATCH] Optimise recalcBlockCounts() for empty sections + +In 1.18, every chunk section is initialised to a non-null value +and recalcBlockCounts() is invoked for each section. +However, in a standard world, most sections are empty. In such cases, +recalcBlockCounts() would iterate over ever position - even though +the block data would all be air. To avoid this, we skip +searching the section unless the palette indicates there _could_ be +a non-air block state or non-empty fluid state. + +Chunk loading initially showed that recalcBlockCounts() over +sections with a ZeroBitStorage data to to take ~20% of the process, +now it takes <1%. + +diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java +index 1b80a91fa36c59a31b57ef7ef4a68eacbb0f17f5..cf2c053a0e82928c7a7cf99abe1bbd1eb7824507 100644 +--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java ++++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java +@@ -244,6 +244,7 @@ public class LevelChunkSection { + this.nonEmptyBlockCount = 0; + this.tickingBlockCount = 0; + this.tickingFluidCount = 0; ++ if (this.maybeHas((BlockState state) -> !state.isAir() || !state.getFluidState().isEmpty())) { // Paper - do not run forEachLocation on clearly empty sections + this.states.forEachLocation((BlockState iblockdata, int i) -> { + FluidState fluid = iblockdata.getFluidState(); + +@@ -263,6 +264,7 @@ public class LevelChunkSection { + } + + }); ++ } // Paper - do not run forEachLocation on clearly empty sections + // Paper end + this.initBlockCollisionData(); // Paper + } diff --git a/patches/server/0983-Fix-destroying-beehive-without-any-players-nearby-th.patch b/patches/server/0983-Fix-destroying-beehive-without-any-players-nearby-th.patch new file mode 100644 index 0000000000..0a231f55e6 --- /dev/null +++ b/patches/server/0983-Fix-destroying-beehive-without-any-players-nearby-th.patch @@ -0,0 +1,25 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Spottedleaf <[email protected]> +Date: Mon, 3 Apr 2023 21:14:19 -0700 +Subject: [PATCH] Fix destroying beehive without any players nearby throwing an + exception + +If the player moves out of range by the time the block is destroyed, +then the exception would throw and remove the player from the world + +diff --git a/src/main/java/net/minecraft/world/level/block/BeehiveBlock.java b/src/main/java/net/minecraft/world/level/block/BeehiveBlock.java +index ca6cf92b96d68ba8b34e90edda2a93e11214c91b..d5dd280fbbd87438c72d439a73ea827b9fbe20b0 100644 +--- a/src/main/java/net/minecraft/world/level/block/BeehiveBlock.java ++++ b/src/main/java/net/minecraft/world/level/block/BeehiveBlock.java +@@ -98,6 +98,11 @@ public class BeehiveBlock extends BaseEntityBlock { + + if (!list.isEmpty()) { + List<Player> list1 = world.getEntitiesOfClass(Player.class, (new AABB(pos)).inflate(8.0D, 6.0D, 8.0D)); ++ // Paper start - if there are no players nearby, then nextInt() will throw ++ if (list1.isEmpty()) { ++ return; ++ } ++ // Paper end - if there are no players nearby, then nextInt() will throw + int i = list1.size(); + Iterator iterator = list.iterator(); + |