SPIGOT-6754: Temporarily restore previous behaviour for tile entities with removed blocks

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot 2021-10-09 16:29:58 +11:00
parent 188d3b23d0
commit e9ecd12983
2 changed files with 6 additions and 1 deletions

View file

@ -6,7 +6,7 @@ import org.bukkit.World;
import org.bukkit.block.TileState;
import org.bukkit.persistence.PersistentDataContainer;
public abstract class CraftBlockEntityState<T extends TileEntity> extends CraftBlockState implements TileState {
public class CraftBlockEntityState<T extends TileEntity> extends CraftBlockState implements TileState {
private final T tileEntity;
private final T snapshot;

View file

@ -106,6 +106,11 @@ 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()));
return new CraftBlockState(world, blockPosition, blockData);
}