Packet Dig Issue
Longehh opened this issue ยท 2 comments
- This issue is not solved in a development build
Describe the bug
I am attempting to listen for the BlockDig Packet on ProtocolLib in order to obtain the Block Face they have clicked on to mine the block, however EnumWrappers.PlayerDigType.STOP_DESTROY_BLOCK is not fired when using efficiency levels such as Efficiency X.
To Reproduce
Steps to reproduce the behavior:
Listen for the Packet, and print out when they stop destroying the block, this will not happen when you use a pickaxe with efficiency 8 or greater.
Expected behavior
The packet to still fire regardless of how fast the block was broken.
Version Info
https://hastebin.com/share/cowuvoyiva.kotlin
This is not an issue anymore on 1.20.6.
Might also have been mitigated on 1.20 or lower.
You should close this issue.
Hi, this is no problem of ProtocolLib as the Minecraft Client does not send a STOP_DESTROY_BLOCK
packet if the digging is really fast. In this case, the block is already destroyed by the START_DESTROY_BLOCK
like in creative mode.
Here is the corresponding code from the 1.19.4 minecraft server from net.minecraft.server.level.ServerPlayerGameMode
:
if (action == ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK) {
....
if (!iblockdata.isAir() && f >= 1.0F) {
this.destroyAndAck(pos, sequence, "insta mine");
} else {
if (this.isDestroyingBlock) {
this.player.connection.send(new ClientboundBlockUpdatePacket(this.destroyPos, this.level.getBlockState(this.destroyPos)));
this.debugLogging(pos, false, sequence, "abort destroying since another started (client insta mine, server disagreed)");
}
this.isDestroyingBlock = true;
this.destroyPos = pos.immutable();
int k = (int) (f * 10.0F);
this.level.destroyBlockProgress(this.player.getId(), pos, k);
this.debugLogging(pos, true, sequence, "actual start of destroying");
this.lastSentState = k;
}
}
As you can see, the computation of the variable f
is the criterion for insta breaking the block. So I would not suggest using ProtocolLib for this specific use case. Have a look at the BlockDamageEvent
with the Method getInstaBreak()
and the BlockBreakEvent
.