Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-19 04:50:06 +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.
Dieser Commit ist enthalten in:
Ursprung
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);
|
org.bukkit.block.BlockState blockstate = org.bukkit.craftbukkit.block.CraftBlockState.getBlockState(world, x, y, z);
|
||||||
|
|
||||||
world.callingPlaceEvent = true;
|
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);
|
org.bukkit.event.block.BlockPlaceEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPlaceEvent(world, entityhuman, blockstate, clickedX, clickedY, clickedZ);
|
||||||
if (event.isCancelled() || !event.canBuild()) {
|
if (event.isCancelled() || !event.canBuild()) {
|
||||||
blockstate.update(true);
|
blockstate.update(true, false);
|
||||||
world.callingPlaceEvent = false;
|
world.callingPlaceEvent = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -24,8 +24,8 @@ public class CraftBeacon extends CraftBlockState implements Beacon {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean update(boolean force) {
|
public boolean update(boolean force, boolean applyPhysics) {
|
||||||
boolean result = super.update(force);
|
boolean result = super.update(force, applyPhysics);
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
beacon.update();
|
beacon.update();
|
||||||
|
@ -113,17 +113,21 @@ public class CraftBlockState implements BlockState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean update(boolean force) {
|
public boolean update(boolean force) {
|
||||||
|
return update(force, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean update(boolean force, boolean applyPhysics) {
|
||||||
Block block = getBlock();
|
Block block = getBlock();
|
||||||
|
|
||||||
if (block.getType() != this.getType()) {
|
if (block.getType() != getType()) {
|
||||||
if (force) {
|
if (force) {
|
||||||
block.setTypeId(this.getTypeId());
|
block.setTypeId(getTypeId(), applyPhysics);
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
block.setData(getRawData());
|
block.setData(getRawData(), applyPhysics);
|
||||||
world.getHandle().notify(x, y, z);
|
world.getHandle().notify(x, y, z);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -21,8 +21,8 @@ public class CraftBrewingStand extends CraftBlockState implements BrewingStand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean update(boolean force) {
|
public boolean update(boolean force, boolean applyPhysics) {
|
||||||
boolean result = super.update(force);
|
boolean result = super.update(force, applyPhysics);
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
brewingStand.update();
|
brewingStand.update();
|
||||||
|
@ -61,8 +61,8 @@ public class CraftChest extends CraftBlockState implements Chest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean update(boolean force) {
|
public boolean update(boolean force, boolean applyPhysics) {
|
||||||
boolean result = super.update(force);
|
boolean result = super.update(force, applyPhysics);
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
chest.update();
|
chest.update();
|
||||||
|
@ -35,8 +35,8 @@ public class CraftCommandBlock extends CraftBlockState implements CommandBlock {
|
|||||||
this.name = name != null ? name : "@";
|
this.name = name != null ? name : "@";
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean update(boolean forced) {
|
public boolean update(boolean force, boolean applyPhysics) {
|
||||||
boolean result = super.update(forced);
|
boolean result = super.update(force, applyPhysics);
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
commandBlock.b(command);
|
commandBlock.b(command);
|
||||||
|
@ -39,8 +39,8 @@ public class CraftDispenser extends CraftBlockState implements Dispenser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean update(boolean force) {
|
public boolean update(boolean force, boolean applyPhysics) {
|
||||||
boolean result = super.update(force);
|
boolean result = super.update(force, applyPhysics);
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
dispenser.update();
|
dispenser.update();
|
||||||
|
@ -36,8 +36,8 @@ public class CraftDropper extends CraftBlockState implements Dropper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean update(boolean force) {
|
public boolean update(boolean force, boolean applyPhysics) {
|
||||||
boolean result = super.update(force);
|
boolean result = super.update(force, applyPhysics);
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
dropper.update();
|
dropper.update();
|
||||||
|
@ -21,8 +21,8 @@ public class CraftFurnace extends CraftBlockState implements Furnace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean update(boolean force) {
|
public boolean update(boolean force, boolean applyPhysics) {
|
||||||
boolean result = super.update(force);
|
boolean result = super.update(force, applyPhysics);
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
furnace.update();
|
furnace.update();
|
||||||
|
@ -21,8 +21,8 @@ public class CraftHopper extends CraftBlockState implements Hopper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean update(boolean force) {
|
public boolean update(boolean force, boolean applyPhysics) {
|
||||||
boolean result = super.update(force);
|
boolean result = super.update(force, applyPhysics);
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
hopper.update();
|
hopper.update();
|
||||||
|
@ -31,8 +31,8 @@ public class CraftSign extends CraftBlockState implements Sign {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean update(boolean force) {
|
public boolean update(boolean force, boolean applyPhysics) {
|
||||||
boolean result = super.update(force);
|
boolean result = super.update(force, applyPhysics);
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
for(int i = 0; i < 4; i++) {
|
for(int i = 0; i < 4; i++) {
|
||||||
|
@ -181,8 +181,8 @@ public class CraftSkull extends CraftBlockState implements Skull {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean update(boolean force) {
|
public boolean update(boolean force, boolean applyPhysics) {
|
||||||
boolean result = super.update(force);
|
boolean result = super.update(force, applyPhysics);
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
skull.setSkullType(getSkullType(skullType), player);
|
skull.setSkullType(getSkullType(skullType), player);
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren