mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-09 09:57:45 +01:00
Improve block breaking code, to fix issue when breaking a block should immediately place a new one
This commit is contained in:
parent
2843da6b26
commit
d60118d5f6
@ -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
|
||||
{
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user