Avoid block vector creation for combine stages = false

This commit is contained in:
Jesse Boyd 2019-04-15 19:56:38 +10:00
parent f6014089cc
commit 69e2ce6165
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
3 changed files with 6 additions and 4 deletions

View File

@ -61,7 +61,7 @@ public class HistoryExtent extends AbstractDelegateExtent {
@Override
public <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, B block) throws WorldEditException {
BaseBlock previous = queue.getFullBlock(BlockVector3.at(x, y, z)).toBaseBlock();
BaseBlock previous = queue.getFullBlock(mutable.setComponents(x, y, z)).toBaseBlock();
if (previous.getInternalId() == block.getInternalId()) {
if (!previous.hasNbtData() && (block instanceof BaseBlock && !((BaseBlock)block).hasNbtData())) {
return false;

View File

@ -25,6 +25,7 @@ import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.internal.cui.CUIEvent;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.MutableBlockVector3;
import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.util.Direction;
import com.sk89q.worldedit.util.HandSide;
@ -106,15 +107,16 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
byte free = 0;
BlockVector3 mutablePos = MutableBlockVector3.at(0, 0, 0);
while (y <= world.getMaximumPoint().getBlockY() + 2) {
if (!world.getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) {
if (!world.getBlock(mutablePos.setComponents(x, y, z)).getBlockType().getMaterial().isMovementBlocker()) {
++free;
} else {
free = 0;
}
if (free == 2) {
final BlockVector3 pos = BlockVector3.at(x, y - 2, z);
final BlockVector3 pos = mutablePos.setComponents(x, y - 2, z);
final BlockStateHolder state = world.getBlock(pos);
setPosition(new Location(world, Vector3.at(x + 0.5, y - 2 + BlockTypeUtil.centralTopLimit(state), z + 0.5)));
return;

View File

@ -47,7 +47,7 @@ import javax.annotation.Nullable;
public class AbstractDelegateExtent implements LightingExtent {
private transient final Extent extent;
private MutableBlockVector3 mutable = new MutableBlockVector3(0, 0, 0);
protected MutableBlockVector3 mutable = new MutableBlockVector3(0, 0, 0);
/**
* Create a new instance.