From 467599633577b6076ce426942e12ddb12ff549cd Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Fri, 8 Oct 2021 12:06:28 -0700 Subject: [PATCH] Fix unplaced block states after new chunk gen API (#6747) --- ...block-states-after-new-chunk-gen-API.patch | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 patches/server/Fix-unplaced-block-states-after-new-chunk-gen-API.patch diff --git a/patches/server/Fix-unplaced-block-states-after-new-chunk-gen-API.patch b/patches/server/Fix-unplaced-block-states-after-new-chunk-gen-API.patch new file mode 100644 index 0000000000..23b616c6a3 --- /dev/null +++ b/patches/server/Fix-unplaced-block-states-after-new-chunk-gen-API.patch @@ -0,0 +1,60 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jake Potrebic +Date: Thu, 7 Oct 2021 20:49:13 -0700 +Subject: [PATCH] Fix unplaced block states after new chunk gen API + + +diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBeehive.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBeehive.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBeehive.java ++++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBeehive.java +@@ -0,0 +0,0 @@ public class CraftBeehive extends CraftBlockEntityState impl + + @Override + public List releaseEntities() { +- Preconditions.checkState(getWorldHandle() instanceof net.minecraft.world.level.Level, "Can't release entities during world generation"); + + List bees = new ArrayList<>(); + + if (isPlaced()) { ++ Preconditions.checkState(getWorldHandle() instanceof net.minecraft.world.level.Level, "Can't release entities during world generation"); // Paper - don't fail if block isnt placed, this method did not use to fail + BeehiveBlockEntity beehive = ((BeehiveBlockEntity) this.getTileEntityFromWorld()); + for (Entity bee : beehive.releaseBees(this.getHandle(), BeeReleaseStatus.BEE_RELEASED, true)) { + bees.add((Bee) bee.getBukkitEntity()); +diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java ++++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockState.java +@@ -0,0 +0,0 @@ public class CraftBlockState implements BlockState { + + public LevelAccessor getWorldHandle() { + if (this.weakWorld == null) { ++ requirePlaced(); // Paper + return this.world.getHandle(); + } + + LevelAccessor access = this.weakWorld.get(); + if (access == null) { + this.weakWorld = null; ++ requirePlaced(); // Paper + return this.world.getHandle(); + } + +diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java b/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java ++++ b/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java +@@ -0,0 +0,0 @@ public class CraftChest extends CraftLootable implements Chest + + @Override + public Inventory getInventory() { +- Preconditions.checkState(getWorldHandle() instanceof net.minecraft.world.level.Level, "Can't get inventory during world generation, use getBlockInventory() instead"); + + CraftInventory inventory = (CraftInventory) this.getBlockInventory(); + if (!isPlaced()) { + return inventory; + } ++ Preconditions.checkState(getWorldHandle() instanceof net.minecraft.world.level.Level, "Can't get inventory during world generation, use getBlockInventory() instead"); // Paper - move after placed check + + // The logic here is basically identical to the logic in BlockChest.interact + CraftWorld world = (CraftWorld) this.getWorld();