From fe71cb6a048546254955044b4a0202001e7aa867 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Mon, 29 Nov 2021 13:15:54 +0100 Subject: [PATCH] Updated Upstream (Bukkit/CraftBukkit) Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: ab6e73a2 Correct copied javadoc from previous commit CraftBukkit Changes: 9fb3aa4c SPIGOT-6817: Revert back to old block state behaviour again --- ...-get-a-BlockState-without-a-snapshot.patch | 34 ++++++++++++++++--- .../Fix-upstreams-block-state-factories.patch | 3 +- work/Bukkit | 2 +- work/CraftBukkit | 2 +- 4 files changed, 34 insertions(+), 7 deletions(-) diff --git a/patches/server/API-to-get-a-BlockState-without-a-snapshot.patch b/patches/server/API-to-get-a-BlockState-without-a-snapshot.patch index 35814c9512..c84b4e96b9 100644 --- a/patches/server/API-to-get-a-BlockState-without-a-snapshot.patch +++ b/patches/server/API-to-get-a-BlockState-without-a-snapshot.patch @@ -43,9 +43,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public InventoryHolder getOwner(boolean useSnapshot) { + // Paper end if (this.level == null) return null; - org.bukkit.block.Block block = this.level.getWorld().getBlockAt(this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ()); - if (block.getType() == org.bukkit.Material.AIR) return null; -- org.bukkit.block.BlockState state = block.getState(); +- org.bukkit.block.BlockState state = this.level.getWorld().getBlockAt(this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ()).getState(); ++ org.bukkit.block.Block block = this.level.getWorld().getBlockAt(this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ()); ++ if (block.getType() == org.bukkit.Material.AIR) return null; + org.bukkit.block.BlockState state = block.getState(useSnapshot); // Paper if (state instanceof InventoryHolder) return (InventoryHolder) state; return null; @@ -79,7 +79,12 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.ja index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java -@@ -0,0 +0,0 @@ public abstract class CraftBlockEntityState extends Craft +@@ -0,0 +0,0 @@ import org.bukkit.World; + import org.bukkit.block.TileState; + import org.bukkit.persistence.PersistentDataContainer; + +-public class CraftBlockEntityState extends CraftBlockState implements TileState { ++public abstract class CraftBlockEntityState extends CraftBlockState implements TileState { // Paper - revert revert private final T tileEntity; private final T snapshot; @@ -108,6 +113,27 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } public void refreshSnapshot() { +diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java ++++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockStates.java +@@ -0,0 +0,0 @@ public final class CraftBlockStates { + private static final BlockStateFactory DEFAULT_FACTORY = new BlockStateFactory(CraftBlockState.class) { + @Override + public CraftBlockState createBlockState(World world, BlockPos blockPosition, net.minecraft.world.level.block.state.BlockState blockData, BlockEntity tileEntity) { +- // SPIGOT-6754, SPIGOT-6817: Restore previous behaviour for tile entities with removed blocks (loot generation post-destroy) +- if (tileEntity != null) { +- // block with unhandled TileEntity: +- return new CraftBlockEntityState<>(world, tileEntity); +- } +- Preconditions.checkState(tileEntity == null, "Unexpected BlockState for %s", CraftMagicNumbers.getMaterial(blockData.getBlock())); ++ // Paper start - revert revert ++ // When a block is being destroyed, the TileEntity may temporarily still exist while the block's type has already been set to AIR. We ignore the TileEntity in this case. ++ Preconditions.checkState(tileEntity == null || CraftMagicNumbers.getMaterial(blockData.getBlock()) == Material.AIR, "Unexpected BlockState for %s", CraftMagicNumbers.getMaterial(blockData.getBlock())); ++ // Paper end + return new CraftBlockState(world, blockPosition, blockData); + } + }; diff --git a/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java b/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/persistence/CraftPersistentDataContainer.java diff --git a/patches/server/Fix-upstreams-block-state-factories.patch b/patches/server/Fix-upstreams-block-state-factories.patch index f0d4771b25..8256475749 100644 --- a/patches/server/Fix-upstreams-block-state-factories.patch +++ b/patches/server/Fix-upstreams-block-state-factories.patch @@ -35,11 +35,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 import net.minecraft.world.level.block.entity.CampfireBlockEntity; import net.minecraft.world.level.block.entity.ChestBlockEntity; @@ -0,0 +0,0 @@ public final class CraftBlockStates { - @Override public CraftBlockState createBlockState(World world, BlockPos blockPosition, net.minecraft.world.level.block.state.BlockState blockData, BlockEntity tileEntity) { + // Paper start - revert revert // When a block is being destroyed, the TileEntity may temporarily still exist while the block's type has already been set to AIR. We ignore the TileEntity in this case. - Preconditions.checkState(tileEntity == null || CraftMagicNumbers.getMaterial(blockData.getBlock()) == Material.AIR, "Unexpected BlockState for %s", CraftMagicNumbers.getMaterial(blockData.getBlock())); + Preconditions.checkState(tileEntity == null/* || CraftMagicNumbers.getMaterial(blockData.getBlock()) == Material.AIR*/, "Unexpected BlockState for %s", CraftMagicNumbers.getMaterial(blockData.getBlock())); // Paper - don't ignore the TileEntity while its still valid + // Paper end return new CraftBlockState(world, blockPosition, blockData); } }; diff --git a/work/Bukkit b/work/Bukkit index 810cb078fd..ab6e73a20e 160000 --- a/work/Bukkit +++ b/work/Bukkit @@ -1 +1 @@ -Subproject commit 810cb078fd22fde8bf94b5a23ed3329f0b1f68db +Subproject commit ab6e73a20eca8ecd0fef8720edc81e746595dd98 diff --git a/work/CraftBukkit b/work/CraftBukkit index 04f8e7e21f..9fb3aa4c7a 160000 --- a/work/CraftBukkit +++ b/work/CraftBukkit @@ -1 +1 @@ -Subproject commit 04f8e7e21f574311f67a6b0dd3bff1597630fef1 +Subproject commit 9fb3aa4c7ae8086c3c91122d716acc0464b2f300