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:
Travis Watkins 2012-01-17 15:52:02 -06:00 committed by EvilSeph
parent cf521b5a5c
commit 74ead3abd1

View File

@ -203,6 +203,16 @@ public class ItemInWorldManager {
if (this.player instanceof EntityPlayer) {
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());
this.world.getServer().getPluginManager().callEvent(event);