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 6 commits
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
14 changes: 10 additions & 4 deletions src/main/java/ac/grim/grimac/checks/impl/misc/FastBreak.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,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.WrapperPlayClientPlayerFlying;
Expand All @@ -27,8 +28,11 @@ 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;
// The last time a finish digging packet was sent, to enforce 0.3-second delay after non-instabreak
long lastFinishBreak = 0;
Expand All @@ -51,6 +55,7 @@ public void onBlockBreak(BlockBreak blockBreak) {

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

maximumBlockDamage = BlockBreakSpeed.getBlockDamage(player, targetBlock);

Expand All @@ -63,7 +68,7 @@ public void onBlockBreak(BlockBreak blockBreak) {
}

if (blockDelayBalance > 1000) { // If more than a second of advantage
flagAndAlert("Delay=" + breakDelay);
flagAndAlert("delay=" + breakDelay + ", type=" + targetType);
if (shouldModifyPackets()) {
blockBreak.cancel();
}
Expand All @@ -86,7 +91,8 @@ public void onBlockBreak(BlockBreak blockBreak) {
}

if (blockBreakBalance > 1000) { // If more than a second of advantage
if (flagAndAlert("Diff=" + diff + ",Balance=" + blockBreakBalance) && shouldModifyPackets()) {
if (flagAndAlert("diff=" + diff + ", balance=" + blockBreakBalance
+ ", maxBlockDamage=" + maximumBlockDamage + ", type=" + targetType) && shouldModifyPackets()) {
blockBreak.cancel();
}
}
Expand All @@ -109,4 +115,4 @@ private void clampBalance() {
blockBreakBalance = GrimMath.clamp(blockBreakBalance, -balance, balance); // Clamp not Math.max in case other logic changes
blockDelayBalance = GrimMath.clamp(blockDelayBalance, -balance, balance);
}
}
}
SergioK29 marked this conversation as resolved.
Show resolved Hide resolved