Improve block breaking code, to fix issue when breaking a block should immediately place a new one

This commit is contained in:
themode 2021-02-24 12:18:27 +01:00
parent 2843da6b26
commit d60118d5f6
2 changed files with 5 additions and 6 deletions

View File

@ -391,7 +391,9 @@ public class InstanceContainer extends Instance {
final boolean allowed = !blockBreakEvent.isCancelled();
if (allowed) {
// Break or change the broken block based on event result
setSeparateBlocks(x, y, z, blockBreakEvent.getResultBlockStateId(), blockBreakEvent.getResultCustomBlockId());
final short resultState = blockBreakEvent.getResultBlockStateId();
final short resultCustom = blockBreakEvent.getResultCustomBlockId();
setSeparateBlocks(x, y, z, resultState, resultCustom);
// Send the block break effect packet
{

View File

@ -154,14 +154,11 @@ public class PlayerDiggingListener {
// Unverified block break, client is fully responsible
final boolean result = instance.breakBlock(player, blockPosition);
final int updatedBlockId = result ? 0 : blockStateId;
final ClientPlayerDiggingPacket.Status status = result ?
ClientPlayerDiggingPacket.Status.FINISHED_DIGGING :
ClientPlayerDiggingPacket.Status.CANCELLED_DIGGING;
final int updatedBlockId = instance.getBlockStateId(blockPosition);
// Send acknowledge packet to allow or cancel the digging process
sendAcknowledgePacket(player, blockPosition, updatedBlockId,
status, result);
ClientPlayerDiggingPacket.Status.FINISHED_DIGGING, result);
if (!result) {
final boolean solid = Block.fromStateId((short) blockStateId).isSolid();