mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-09 06:50:32 +08:00
Immediately tell client a block is broken, then process the event.
In order to avoid clients seeing blocks break, reappear, then break again due to lag caused by plugins taking too long to process the BlockBreakEvent we immediately tell the client the block is air then process the event. If the event ends up being cancelled the client will get another packet telling them the block still exists.
This commit is contained in:
parent
cf521b5a5c
commit
74ead3abd1
@ -203,6 +203,16 @@ public class ItemInWorldManager {
|
|||||||
if (this.player instanceof EntityPlayer) {
|
if (this.player instanceof EntityPlayer) {
|
||||||
org.bukkit.block.Block block = this.world.getWorld().getBlockAt(i, j, k);
|
org.bukkit.block.Block block = this.world.getWorld().getBlockAt(i, j, k);
|
||||||
|
|
||||||
|
// Tell client the block is gone immediately then process events
|
||||||
|
if (world.getTileEntity(i, j, k) == null) {
|
||||||
|
int id = block.getTypeId();
|
||||||
|
byte data = block.getData();
|
||||||
|
|
||||||
|
block.setTypeId(0, false);
|
||||||
|
((EntityPlayer) this.player).netServerHandler.sendPacket(new Packet53BlockChange(i, j, k, this.world));
|
||||||
|
block.setTypeIdAndData(id, data, false);
|
||||||
|
}
|
||||||
|
|
||||||
BlockBreakEvent event = new BlockBreakEvent(block, (org.bukkit.entity.Player) this.player.getBukkitEntity());
|
BlockBreakEvent event = new BlockBreakEvent(block, (org.bukkit.entity.Player) this.player.getBukkitEntity());
|
||||||
this.world.getServer().getPluginManager().callEvent(event);
|
this.world.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user