mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-09 01:37:35 +01:00
SPIGOT-6754: We ignore any still present TileEntity now when we create a BlockState for a block of type AIR.
During block destruction, the type of the block may already have been set to AIR while the TileEntity has not yet been removed. Also, TileEntity#getOwner() skips the whole BlockState construction now if the block is of type AIR. This removes the previous workaround again of returning a dummy CraftBlockEntityState in this case. By: blablubbabc <lukas@wirsindwir.de>
This commit is contained in:
parent
e9ecd12983
commit
82e8261d70
@ -49,7 +49,7 @@
|
||||
return nbttagcompound;
|
||||
}
|
||||
}
|
||||
@@ -164,4 +188,13 @@
|
||||
@@ -164,4 +188,15 @@
|
||||
public void b(IBlockData iblockdata) {
|
||||
this.blockState = iblockdata;
|
||||
}
|
||||
@ -57,7 +57,9 @@
|
||||
+ // CraftBukkit start - add method
|
||||
+ public InventoryHolder getOwner() {
|
||||
+ if (level == null) return null;
|
||||
+ org.bukkit.block.BlockState state = level.getWorld().getBlockAt(worldPosition.getX(), worldPosition.getY(), worldPosition.getZ()).getState();
|
||||
+ org.bukkit.block.Block block = level.getWorld().getBlockAt(worldPosition.getX(), worldPosition.getY(), worldPosition.getZ());
|
||||
+ if (block.getType() == org.bukkit.Material.AIR) return null;
|
||||
+ org.bukkit.block.BlockState state = block.getState();
|
||||
+ if (state instanceof InventoryHolder) return (InventoryHolder) state;
|
||||
+ return null;
|
||||
+ }
|
||||
|
@ -6,7 +6,7 @@ import org.bukkit.World;
|
||||
import org.bukkit.block.TileState;
|
||||
import org.bukkit.persistence.PersistentDataContainer;
|
||||
|
||||
public class CraftBlockEntityState<T extends TileEntity> extends CraftBlockState implements TileState {
|
||||
public abstract class CraftBlockEntityState<T extends TileEntity> extends CraftBlockState implements TileState {
|
||||
|
||||
private final T tileEntity;
|
||||
private final T snapshot;
|
||||
|
@ -106,12 +106,8 @@ public final class CraftBlockStates {
|
||||
private static final BlockStateFactory<?> DEFAULT_FACTORY = new BlockStateFactory<CraftBlockState>(CraftBlockState.class) {
|
||||
@Override
|
||||
public CraftBlockState createBlockState(World world, BlockPosition blockPosition, IBlockData blockData, TileEntity tileEntity) {
|
||||
// SPIGOT-6754: Temporarily restore previous behaviour for tile entities with removed blocks
|
||||
if (tileEntity != null) {
|
||||
// block with unhandled TileEntity:
|
||||
return new CraftBlockEntityState<>(world, tileEntity);
|
||||
}
|
||||
Preconditions.checkState(tileEntity == null, "Unexpected BlockState for %s", CraftMagicNumbers.getMaterial(blockData.getBlock()));
|
||||
// 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()));
|
||||
return new CraftBlockState(world, blockPosition, blockData);
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user