Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve fastbreak verbose message #1851

Open
wants to merge 7 commits into
base: 2.0
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/main/java/ac/grim/grimac/checks/impl/misc/FastBreak.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.github.retrooper.packetevents.protocol.player.ClientVersion;
import com.github.retrooper.packetevents.protocol.player.DiggingAction;
import com.github.retrooper.packetevents.protocol.world.states.WrappedBlockState;
import com.github.retrooper.packetevents.protocol.world.states.type.StateType;
import com.github.retrooper.packetevents.protocol.world.states.type.StateTypes;
import com.github.retrooper.packetevents.util.Vector3i;
import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerDigging;
Expand All @@ -37,6 +38,9 @@ public FastBreak(GrimPlayer playerData) {

// The block the player is currently breaking
Vector3i targetBlock = null;
// The material of block the player is currently breaking
StateType targetType = null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FastBreak gets handled before updating the block, you don't need to track the block type, you can use blockBreak.block.getType()


// The maximum amount of damage the player deals to the block
//
double maximumBlockDamage = 0;
Expand Down Expand Up @@ -71,6 +75,7 @@ public void onPacketReceive(PacketReceiveEvent event) {

startBreak = System.currentTimeMillis() - (targetBlock == null ? 50 : 0); // ???
targetBlock = blockPosition;
targetType = block.getType();

maximumBlockDamage = BlockBreakSpeed.getBlockDamage(player, targetBlock);

Expand All @@ -83,7 +88,7 @@ public void onPacketReceive(PacketReceiveEvent event) {
}

if (blockDelayBalance > 1000) { // If more than a second of advantage
flagAndAlert("Delay=" + breakDelay);
flagAndAlert("delay=" + breakDelay + " type=" + block.getType());
SergioK29 marked this conversation as resolved.
Show resolved Hide resolved
if (shouldModifyPackets()) {
event.setCancelled(true); // Cancelling start digging will cause server to reject block break
player.onPacketCancel();
Expand Down Expand Up @@ -136,7 +141,8 @@ public void onPacketReceive(PacketReceiveEvent event) {
}
}, null, 0);

if (flagAndAlert("Diff=" + diff + ",Balance=" + blockBreakBalance) && shouldModifyPackets()) {
if (flagAndAlert("diff=" + diff + " balance=" + blockBreakBalance
+ " maxBlockDamage=" + maximumBlockDamage + " type=" + targetType) && shouldModifyPackets()) {
SergioK29 marked this conversation as resolved.
Show resolved Hide resolved
event.setCancelled(true);
player.onPacketCancel();
}
Expand Down