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.
Dieser Commit ist enthalten in:
Travis Watkins 2013-03-31 19:18:42 -05:00
Ursprung d3dbb1bb50
Commit 71a475f076
12 geänderte Dateien mit 29 neuen und 25 gelöschten Zeilen

Datei anzeigen

@ -80,11 +80,11 @@ public class ItemBlock extends Item {
org.bukkit.block.BlockState blockstate = org.bukkit.craftbukkit.block.CraftBlockState.getBlockState(world, x, y, z);
world.callingPlaceEvent = true;
world.setTypeIdAndData(x, y, z, id, data, 3);
world.setTypeIdAndData(x, y, z, id, data, 2);
org.bukkit.event.block.BlockPlaceEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockstate, clickedX, clickedY, clickedZ);
if (event.isCancelled() || !event.canBuild()) {
blockstate.update(true);
blockstate.update(true, false);
world.callingPlaceEvent = false;
return false;
}

Datei anzeigen

@ -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();

Datei anzeigen

@ -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;

Datei anzeigen

@ -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();

Datei anzeigen

@ -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();

Datei anzeigen

@ -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);

Datei anzeigen

@ -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();

Datei anzeigen

@ -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();

Datei anzeigen

@ -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();

Datei anzeigen

@ -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();

Datei anzeigen

@ -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++) {

Datei anzeigen

@ -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);