mirror of
https://hub.spigotmc.org/stash/scm/spigot/craftbukkit.git
synced 2025-08-21 05:44:33 +00:00
Remove unnecessary CraftBlock creation in CraftRegionAccessor#setBlock
This commit is contained in:
parent
03f249f098
commit
a11ec5d7f5
2 changed files with 10 additions and 3 deletions
|
@ -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…
Add table
Reference in a new issue