13
0
geforkt von Mirrors/Paper

SPIGOT-6817: Revert back to old block state behaviour again

By: md_5 <git@md-5.net>
Dieser Commit ist enthalten in:
CraftBukkit/Spigot 2021-11-29 11:03:16 +11:00
Ursprung 6b0484122e
Commit 4dbb83e45d
3 geänderte Dateien mit 9 neuen und 7 gelöschten Zeilen

Datei anzeigen

@ -49,7 +49,7 @@
return nbttagcompound;
}
@@ -202,4 +226,15 @@
@@ -202,4 +226,13 @@
public void setBlockState(IBlockData iblockdata) {
this.blockState = iblockdata;
}
@ -57,9 +57,7 @@
+ // CraftBukkit start - add method
+ public InventoryHolder getOwner() {
+ if (level == null) return null;
+ 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();
+ org.bukkit.block.BlockState state = level.getWorld().getBlockAt(worldPosition.getX(), worldPosition.getY(), worldPosition.getZ()).getState();
+ if (state instanceof InventoryHolder) return (InventoryHolder) state;
+ return null;
+ }

Datei anzeigen

@ -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;

Datei anzeigen

@ -106,8 +106,12 @@ 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) {
// 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()));
// 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()));
return new CraftBlockState(world, blockPosition, blockData);
}
};