Don't update physics when block place is cancelled. Fixes BUKKIT-3939

When a block placement happens we currently update physics on the
attempted placement and update again if the placement is cancelled.
To correct the first one we simply set the block without applying
physics. To correct the second we have to add a new method to
BlockState that lets us update without applying physics and use
this method method when putting the block back.

By: Travis Watkins <amaranth@ubuntu.com>
This commit is contained in:
CraftBukkit/Spigot 2013-03-31 19:18:42 -05:00
parent b845332f14
commit 94c1d44d57
11 changed files with 27 additions and 23 deletions

View file

@ -24,8 +24,8 @@ public class CraftBeacon extends CraftBlockState implements Beacon {
}
@Override
public boolean update(boolean force) {
boolean result = super.update(force);
public boolean update(boolean force, boolean applyPhysics) {
boolean result = super.update(force, applyPhysics);
if (result) {
beacon.update();

View file

@ -113,17 +113,21 @@ public class CraftBlockState implements BlockState {
}
public boolean update(boolean force) {
return update(force, true);
}
public boolean update(boolean force, boolean applyPhysics) {
Block block = getBlock();
if (block.getType() != this.getType()) {
if (block.getType() != getType()) {
if (force) {
block.setTypeId(this.getTypeId());
block.setTypeId(getTypeId(), applyPhysics);
} else {
return false;
}
}
block.setData(getRawData());
block.setData(getRawData(), applyPhysics);
world.getHandle().notify(x, y, z);
return true;

View file

@ -21,8 +21,8 @@ public class CraftBrewingStand extends CraftBlockState implements BrewingStand {
}
@Override
public boolean update(boolean force) {
boolean result = super.update(force);
public boolean update(boolean force, boolean applyPhysics) {
boolean result = super.update(force, applyPhysics);
if (result) {
brewingStand.update();

View file

@ -61,8 +61,8 @@ public class CraftChest extends CraftBlockState implements Chest {
}
@Override
public boolean update(boolean force) {
boolean result = super.update(force);
public boolean update(boolean force, boolean applyPhysics) {
boolean result = super.update(force, applyPhysics);
if (result) {
chest.update();

View file

@ -35,8 +35,8 @@ public class CraftCommandBlock extends CraftBlockState implements CommandBlock {
this.name = name != null ? name : "@";
}
public boolean update(boolean forced) {
boolean result = super.update(forced);
public boolean update(boolean force, boolean applyPhysics) {
boolean result = super.update(force, applyPhysics);
if (result) {
commandBlock.b(command);

View file

@ -39,8 +39,8 @@ public class CraftDispenser extends CraftBlockState implements Dispenser {
}
@Override
public boolean update(boolean force) {
boolean result = super.update(force);
public boolean update(boolean force, boolean applyPhysics) {
boolean result = super.update(force, applyPhysics);
if (result) {
dispenser.update();

View file

@ -36,8 +36,8 @@ public class CraftDropper extends CraftBlockState implements Dropper {
}
@Override
public boolean update(boolean force) {
boolean result = super.update(force);
public boolean update(boolean force, boolean applyPhysics) {
boolean result = super.update(force, applyPhysics);
if (result) {
dropper.update();

View file

@ -21,8 +21,8 @@ public class CraftFurnace extends CraftBlockState implements Furnace {
}
@Override
public boolean update(boolean force) {
boolean result = super.update(force);
public boolean update(boolean force, boolean applyPhysics) {
boolean result = super.update(force, applyPhysics);
if (result) {
furnace.update();

View file

@ -21,8 +21,8 @@ public class CraftHopper extends CraftBlockState implements Hopper {
}
@Override
public boolean update(boolean force) {
boolean result = super.update(force);
public boolean update(boolean force, boolean applyPhysics) {
boolean result = super.update(force, applyPhysics);
if (result) {
hopper.update();

View file

@ -31,8 +31,8 @@ public class CraftSign extends CraftBlockState implements Sign {
}
@Override
public boolean update(boolean force) {
boolean result = super.update(force);
public boolean update(boolean force, boolean applyPhysics) {
boolean result = super.update(force, applyPhysics);
if (result) {
for(int i = 0; i < 4; i++) {

View file

@ -181,8 +181,8 @@ public class CraftSkull extends CraftBlockState implements Skull {
}
@Override
public boolean update(boolean force) {
boolean result = super.update(force);
public boolean update(boolean force, boolean applyPhysics) {
boolean result = super.update(force, applyPhysics);
if (result) {
skull.setSkullType(getSkullType(skullType), player);