mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-27 21:19:00 +01:00
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.
This commit is contained in:
parent
d3dbb1bb50
commit
71a475f076
@ -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;
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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++) {
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user