mirror of
https://github.com/PaperMC/Paper.git
synced 2025-02-09 00:51:39 +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
@ -272,7 +272,11 @@ public abstract class CraftRegionAccessor implements RegionAccessor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setBlockData(int x, int y, int z, BlockData blockData) {
|
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
|
@Override
|
||||||
|
@ -185,8 +185,11 @@ public class CraftBlock implements Block {
|
|||||||
setTypeAndData(((CraftBlockData) data).getState(), applyPhysics);
|
setTypeAndData(((CraftBlockData) data).getState(), applyPhysics);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean setTypeAndData(final IBlockData blockData, final boolean applyPhysics) {
|
boolean setTypeAndData(final IBlockData blockData, final boolean applyPhysics) {
|
||||||
IBlockData old = getNMS();
|
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
|
// 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
|
if (old.hasBlockEntity() && blockData.getBlock() != old.getBlock()) { // SPIGOT-3725 remove old tile entity if block changes
|
||||||
// SPIGOT-4612: faster - just clear tile
|
// SPIGOT-4612: faster - just clear tile
|
||||||
|
Loading…
Reference in New Issue
Block a user