mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-20 23:46:57 +01:00
Remove unnecessary CraftBlock creation in CraftRegionAccessor#setBlock
By: md_5 <git@md-5.net>
This commit is contained in:
parent
2a6e33ffed
commit
f3b1f97464
2 changed files with 10 additions and 3 deletions
|
@ -272,7 +272,11 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
|
|||
|
||||
@Override
|
||||
public void setBlockData(int x, int y, int z, BlockData blockData) {
|
||||
CraftBlock.at(getHandle(), new BlockPosition(x, y, z)).setTypeAndData(((CraftBlockData) blockData).getState(), true);
|
||||
GeneratorAccessSeed world = getHandle();
|
||||
BlockPosition pos = new BlockPosition(x, y, z);
|
||||
IBlockData old = getHandle().getBlockState(pos);
|
||||
|
||||
CraftBlock.setTypeAndData(world, pos, old, ((CraftBlockData) blockData).getState(), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -185,8 +185,11 @@ public class CraftBlock implements Block {
|
|||
setTypeAndData(((CraftBlockData) data).getState(), applyPhysics);
|
||||
}
|
||||
|
||||
public boolean setTypeAndData(final IBlockData blockData, final boolean applyPhysics) {
|
||||
IBlockData old = getNMS();
|
||||
boolean setTypeAndData(final IBlockData blockData, final boolean applyPhysics) {
|
||||
return setTypeAndData(world, position, getNMS(), blockData, applyPhysics);
|
||||
}
|
||||
|
||||
public static boolean setTypeAndData(GeneratorAccess world, BlockPosition position, IBlockData old, IBlockData blockData, boolean applyPhysics) {
|
||||
// SPIGOT-611: need to do this to prevent glitchiness. Easier to handle this here (like /setblock) than to fix weirdness in tile entity cleanup
|
||||
if (old.hasBlockEntity() && blockData.getBlock() != old.getBlock()) { // SPIGOT-3725 remove old tile entity if block changes
|
||||
// SPIGOT-4612: faster - just clear tile
|
||||
|
|
Loading…
Reference in a new issue