aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorBjarne Koll <[email protected]>2024-05-28 11:45:03 +0200
committerGitHub <[email protected]>2024-05-28 11:45:03 +0200
commitb0c9b9c4d875cb191e552dc7f410cd34c7d9fdcb (patch)
tree10f1325fe36e48f330dd3720014aa1264d797726
parent23fe1166d4fa24ec81243f79e8dbb01dee4ab948 (diff)
downloadPaper-b0c9b9c4d875cb191e552dc7f410cd34c7d9fdcb.tar.gz
Paper-b0c9b9c4d875cb191e552dc7f410cd34c7d9fdcb.zip
Only remove worldgen block entity on changed block (#10794)
-rw-r--r--patches/server/0966-Fix-creation-of-invalid-block-entity-during-world-ge.patch25
-rw-r--r--patches/server/0977-Rewrite-chunk-system.patch30
2 files changed, 37 insertions, 18 deletions
diff --git a/patches/server/0966-Fix-creation-of-invalid-block-entity-during-world-ge.patch b/patches/server/0966-Fix-creation-of-invalid-block-entity-during-world-ge.patch
index a745081446..2b1eed9161 100644
--- a/patches/server/0966-Fix-creation-of-invalid-block-entity-during-world-ge.patch
+++ b/patches/server/0966-Fix-creation-of-invalid-block-entity-during-world-ge.patch
@@ -5,14 +5,33 @@ Subject: [PATCH] Fix creation of invalid block entity during world generation
diff --git a/src/main/java/net/minecraft/server/level/WorldGenRegion.java b/src/main/java/net/minecraft/server/level/WorldGenRegion.java
-index a59eece9c7a8c33cb8ce963906e993c3462684fb..333a02e08cccf5cb0efa2076582cbd69e95ff0c0 100644
+index a59eece9c7a8c33cb8ce963906e993c3462684fb..386fbf79afe91af445f54aeab7d1296d1407a4d8 100644
--- a/src/main/java/net/minecraft/server/level/WorldGenRegion.java
+++ b/src/main/java/net/minecraft/server/level/WorldGenRegion.java
-@@ -339,6 +339,7 @@ public class WorldGenRegion implements WorldGenLevel {
+@@ -323,7 +323,7 @@ public class WorldGenRegion implements WorldGenLevel {
+ return false;
+ } else {
+ ChunkAccess ichunkaccess = this.getChunk(pos);
+- BlockState iblockdata1 = ichunkaccess.setBlockState(pos, state, false);
++ BlockState iblockdata1 = ichunkaccess.setBlockState(pos, state, false); final BlockState previousBlockState = iblockdata1; // Paper - Clear block entity before setting up a DUMMY block entity - obfhelper
+
+ if (iblockdata1 != null) {
+ this.level.onBlockStateChange(pos, iblockdata1, state);
+@@ -339,6 +339,17 @@ public class WorldGenRegion implements WorldGenLevel {
ichunkaccess.removeBlockEntity(pos);
}
} else {
-+ ichunkaccess.removeBlockEntity(pos); // Paper - Clear the block entity before setting up a DUMMY block entity
++ // Paper start - Clear block entity before setting up a DUMMY block entity
++ // The concept of removing a block entity when the block itself changes is generally lifted
++ // from LevelChunk#setBlockState.
++ // It is however to note that this may only run if the block actually changes.
++ // Otherwise a chest block entity generated by a structure template that is later "updated" to
++ // be waterlogged would remove its existing block entity (see PaperMC/Paper#10750)
++ // This logic is *also* found in LevelChunk#setBlockState.
++ if (previousBlockState != null && !java.util.Objects.equals(previousBlockState.getBlock(), state.getBlock())) {
++ ichunkaccess.removeBlockEntity(pos);
++ }
++ // Paper end - Clear block entity before setting up a DUMMY block entity
CompoundTag nbttagcompound = new CompoundTag();
nbttagcompound.putInt("x", pos.getX());
diff --git a/patches/server/0977-Rewrite-chunk-system.patch b/patches/server/0977-Rewrite-chunk-system.patch
index b3f3cf91fb..2bdeb9e4f4 100644
--- a/patches/server/0977-Rewrite-chunk-system.patch
+++ b/patches/server/0977-Rewrite-chunk-system.patch
@@ -18983,7 +18983,7 @@ index b33bf957b1541756e3b983b87b1c83629757739a..0ccdc8d135dd3edb410fbc1d248c20a4
return crashreportsystemdetails;
}
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
-index b032ce115b98af0e0384fb88ca88075eb4ffac11..e2b72b07888e84fb4472920932b3feedbd4829b9 100644
+index e247bafe1e7035b4e3f161b5a641af7ed116ebc1..2b5160468b9eb5bf869c24ea3b52a9d82df7bf16 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -293,6 +293,50 @@ public class ServerPlayer extends Player {
@@ -19274,10 +19274,10 @@ index 6051e5f272838ef23276a90e21c2fc821ca155d1..658e63ebde81dc14c8ab5850fb246dc0
public static <T> TicketType<T> create(String name, Comparator<T> argumentComparator) {
return new TicketType<>(name, argumentComparator, 0L);
diff --git a/src/main/java/net/minecraft/server/level/WorldGenRegion.java b/src/main/java/net/minecraft/server/level/WorldGenRegion.java
-index ca4c8e256047a4af45811c3e772b5a959e2ae941..1351423a12c19a01f602a202832372a399e6a867 100644
+index 8ebd4199fd68f9a16ec8014ff4de0634699748b6..442cebca1d51a8fbaee2a48e2826e35a91541106 100644
--- a/src/main/java/net/minecraft/server/level/WorldGenRegion.java
+++ b/src/main/java/net/minecraft/server/level/WorldGenRegion.java
-@@ -544,4 +544,21 @@ public class WorldGenRegion implements WorldGenLevel {
+@@ -554,4 +554,21 @@ public class WorldGenRegion implements WorldGenLevel {
public long nextSubTickCount() {
return this.subTickCount.getAndIncrement();
}
@@ -19500,10 +19500,10 @@ index 0382b6597a130d746f8954a93a756a9d1ac81d50..ffbb3bf9ff3fc968ef69d4f889b0baf7
}
}
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
-index 370d00afe8384556ee92e28d253c44ed6989efab..6324b875472fc2dbc581157306ff255ef1bf5db2 100644
+index d6c24ad4e32fba5416c7cdd898d72f6207ae278a..e4ae674d006821b254ffdd88c37c4a2dfec86bd9 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
-@@ -481,6 +481,58 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
+@@ -482,6 +482,58 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
}
// Paper end
@@ -19562,7 +19562,7 @@ index 370d00afe8384556ee92e28d253c44ed6989efab..6324b875472fc2dbc581157306ff255e
public Entity(EntityType<?> type, Level world) {
this.id = Entity.ENTITY_COUNTER.incrementAndGet();
this.passengers = ImmutableList.of();
-@@ -2607,11 +2659,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
+@@ -2608,11 +2660,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
return InteractionResult.PASS;
}
@@ -19576,7 +19576,7 @@ index 370d00afe8384556ee92e28d253c44ed6989efab..6324b875472fc2dbc581157306ff255e
return false;
}
-@@ -4042,6 +4094,13 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
+@@ -4043,6 +4095,13 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
}).count();
}
@@ -19590,7 +19590,7 @@ index 370d00afe8384556ee92e28d253c44ed6989efab..6324b875472fc2dbc581157306ff255e
public boolean hasExactlyOnePlayerPassenger() {
if (this.passengers.isEmpty()) { return false; } // Paper - Optimize indirect passenger iteration
return this.countPlayerPassengers() == 1;
-@@ -4392,6 +4451,12 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
+@@ -4393,6 +4452,12 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
return;
}
// Paper end - Block invalid positions and bounding box
@@ -19603,7 +19603,7 @@ index 370d00afe8384556ee92e28d253c44ed6989efab..6324b875472fc2dbc581157306ff255e
// Paper start - Fix MC-4
if (this instanceof ItemEntity) {
if (io.papermc.paper.configuration.GlobalConfiguration.get().misc.fixEntityPositionDesync) {
-@@ -4519,6 +4584,13 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
+@@ -4520,6 +4585,13 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@Override
public final void setRemoved(Entity.RemovalReason entity_removalreason, EntityRemoveEvent.Cause cause) {
@@ -19617,7 +19617,7 @@ index 370d00afe8384556ee92e28d253c44ed6989efab..6324b875472fc2dbc581157306ff255e
CraftEventFactory.callEntityRemoveEvent(this, cause);
// CraftBukkit end
final boolean alreadyRemoved = this.removalReason != null; // Paper - Folia schedulers
-@@ -4530,7 +4602,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
+@@ -4531,7 +4603,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
this.stopRiding();
}
@@ -19626,7 +19626,7 @@ index 370d00afe8384556ee92e28d253c44ed6989efab..6324b875472fc2dbc581157306ff255e
this.levelCallback.onRemove(entity_removalreason);
// Paper start - Folia schedulers
if (!(this instanceof ServerPlayer) && entity_removalreason != RemovalReason.CHANGED_DIMENSION && !alreadyRemoved) {
-@@ -4561,7 +4633,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
+@@ -4562,7 +4634,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@Override
public boolean shouldBeSaved() {
@@ -21607,10 +21607,10 @@ index 7dae8d91b74cc7df0745f0c121e3bea09b8d0b6d..1e2530c9e5212b6d2bdbc94817beddb4
@Override
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
-index 542ad1746c3a933688fa8c2384beda48718a22e6..678d7dc846dd48b0e7054f31b967ba3a9016dcd9 100644
+index 522231b47036c98b1334dbe7756b07ed3481001a..13eb670b85a7ac77238b0a0ba9be13336765894e 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
-@@ -1403,7 +1403,6 @@ public final class CraftServer implements Server {
+@@ -1402,7 +1402,6 @@ public final class CraftServer implements Server {
// Paper - Put world into worldlist before initing the world; move up
this.getServer().prepareLevels(internal.getChunkSource().chunkMap.progressListener, internal);
@@ -21618,7 +21618,7 @@ index 542ad1746c3a933688fa8c2384beda48718a22e6..678d7dc846dd48b0e7054f31b967ba3a
this.pluginManager.callEvent(new WorldLoadEvent(internal.getWorld()));
return internal.getWorld();
-@@ -1448,7 +1447,7 @@ public final class CraftServer implements Server {
+@@ -1447,7 +1446,7 @@ public final class CraftServer implements Server {
}
handle.getChunkSource().close(save);
@@ -21627,7 +21627,7 @@ index 542ad1746c3a933688fa8c2384beda48718a22e6..678d7dc846dd48b0e7054f31b967ba3a
handle.convertable.close();
} catch (Exception ex) {
this.getLogger().log(Level.SEVERE, null, ex);
-@@ -2484,7 +2483,7 @@ public final class CraftServer implements Server {
+@@ -2483,7 +2482,7 @@ public final class CraftServer implements Server {
@Override
public boolean isPrimaryThread() {