mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 15:30:19 +01:00
Pull a few Folia patches
This commit is contained in:
parent
90a0835f43
commit
f9f90791e4
4 changed files with 94 additions and 2 deletions
|
@ -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
|
||||
}
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
||||
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
|
||||
}
|
||||
};
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
||||
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
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
||||
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();
|
||||
|
Loading…
Reference in a new issue