PaperMC/patches/server/1053-Fix-creation-of-invalid-block-entity-during-world-ge.patch

40 lines
2.8 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Pierpaolo Coletta <p.coletta@glyart.com>
Date: Sat, 30 Mar 2024 21:06:10 +0100
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 5ece375eaf6bcc61864997a389bb5e24625e4505..9c3f8f79c2b3389a118dce9a1558edda52446833 100644
--- a/src/main/java/net/minecraft/server/level/WorldGenRegion.java
+++ b/src/main/java/net/minecraft/server/level/WorldGenRegion.java
@@ -352,6 +352,7 @@ public class WorldGenRegion implements WorldGenLevel {
ichunkaccess.removeBlockEntity(pos);
}
} else {
+ ichunkaccess.removeBlockEntity(pos); // Paper - Clear the block entity before setting up a DUMMY block entity
CompoundTag nbttagcompound = new CompoundTag();
nbttagcompound.putInt("x", pos.getX());
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 6ec3fc801453fd54c25b642e6fa71c19b463311d..465458e8a7dbaf9afb32709a71c7b2620d1e1fd2 100644
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
@@ -1169,9 +1169,14 @@ public class LevelChunk extends ChunkAccess {
if (this.blockEntity.getType().isValid(iblockdata)) {
this.ticker.tick(LevelChunk.this.level, this.blockEntity.getBlockPos(), iblockdata, this.blockEntity);
this.loggedInvalidBlockState = false;
- } else if (!this.loggedInvalidBlockState) {
- this.loggedInvalidBlockState = true;
- LevelChunk.LOGGER.warn("Block entity {} @ {} state {} invalid for ticking:", new Object[]{LogUtils.defer(this::getType), LogUtils.defer(this::getPos), iblockdata});
+ // Paper start - Remove the Block Entity if it's invalid
+ } else {
+ LevelChunk.this.removeBlockEntity(this.getPos());
+ if (!this.loggedInvalidBlockState) {
+ this.loggedInvalidBlockState = true;
+ LevelChunk.LOGGER.warn("Block entity {} @ {} state {} invalid for ticking:", new Object[]{LogUtils.defer(this::getType), LogUtils.defer(this::getPos), iblockdata});
+ }
+ // Paper end - Remove the Block Entity if it's invalid
}
gameprofilerfiller.pop();