mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-10 02:17:41 +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();
|
final boolean allowed = !blockBreakEvent.isCancelled();
|
||||||
if (allowed) {
|
if (allowed) {
|
||||||
// Break or change the broken block based on event result
|
// 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
|
// Send the block break effect packet
|
||||||
{
|
{
|
||||||
|
@ -154,14 +154,11 @@ public class PlayerDiggingListener {
|
|||||||
// Unverified block break, client is fully responsible
|
// Unverified block break, client is fully responsible
|
||||||
final boolean result = instance.breakBlock(player, blockPosition);
|
final boolean result = instance.breakBlock(player, blockPosition);
|
||||||
|
|
||||||
final int updatedBlockId = result ? 0 : blockStateId;
|
final int updatedBlockId = instance.getBlockStateId(blockPosition);
|
||||||
final ClientPlayerDiggingPacket.Status status = result ?
|
|
||||||
ClientPlayerDiggingPacket.Status.FINISHED_DIGGING :
|
|
||||||
ClientPlayerDiggingPacket.Status.CANCELLED_DIGGING;
|
|
||||||
|
|
||||||
// Send acknowledge packet to allow or cancel the digging process
|
// Send acknowledge packet to allow or cancel the digging process
|
||||||
sendAcknowledgePacket(player, blockPosition, updatedBlockId,
|
sendAcknowledgePacket(player, blockPosition, updatedBlockId,
|
||||||
status, result);
|
ClientPlayerDiggingPacket.Status.FINISHED_DIGGING, result);
|
||||||
|
|
||||||
if (!result) {
|
if (!result) {
|
||||||
final boolean solid = Block.fromStateId((short) blockStateId).isSolid();
|
final boolean solid = Block.fromStateId((short) blockStateId).isSolid();
|
||||||
|
Loading…
Reference in New Issue
Block a user