-
Notifications
You must be signed in to change notification settings - Fork 338
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
Fix AirLiquidPlace falses (and BadPacketsX false) #1822
Open
Axionize
wants to merge
10
commits into
GrimAnticheat:2.0
Choose a base branch
from
Axionize:fix-airliquidplace
base: 2.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+171
−1
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
358dbef
Add new Data classes to see recently modified blocks
Axionize d2008f1
Fix AirLiquidPlace false
Axionize 3cb385b
Only check first value in iterator() in AirLiquidPlace()
Axionize c5ceb6d
Cleanup AirLiquidPlace
Axionize 8c3bc24
Move clearing updated blocks logic into an async loop; new ClearRecen…
Axionize 63be2d8
Remove debug messages
Axionize cad05f0
Finish documenting all edge cases that can false AirLiquidPlace and f…
Axionize 3b1ceaa
Cleanup
Axionize bf51676
More comment cleanup
Axionize 6f8776b
Adjust whitespace in AirLiquidPlace check fixes
Axionize File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
src/main/java/ac/grim/grimac/checks/impl/scaffolding/AirLiquidPlace.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/main/java/ac/grim/grimac/manager/tick/impl/ClearRecentlyUpdatedBlocks.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package ac.grim.grimac.manager.tick.impl; | ||
|
||
import ac.grim.grimac.GrimAPI; | ||
import ac.grim.grimac.manager.tick.Tickable; | ||
import ac.grim.grimac.player.GrimPlayer; | ||
|
||
public class ClearRecentlyUpdatedBlocks implements Tickable { | ||
|
||
private static final int maxTickAge = 2; | ||
|
||
@Override | ||
public void tick() { | ||
for (GrimPlayer player : GrimAPI.INSTANCE.getPlayerDataManager().getEntries()) { | ||
player.blockHistory.cleanup(GrimAPI.INSTANCE.getTickManager().currentTick - maxTickAge); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/main/java/ac/grim/grimac/utils/change/BlockModification.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -0,0 +1,39 @@ | ||||
package ac.grim.grimac.utils.change; | ||||
|
||||
import com.github.retrooper.packetevents.protocol.world.states.WrappedBlockState; | ||||
import com.github.retrooper.packetevents.util.Vector3i; | ||||
import lombok.Getter; | ||||
|
||||
@Getter | ||||
public class BlockModification { | ||||
private final WrappedBlockState oldBlockContents; | ||||
private final WrappedBlockState newBlockContents; | ||||
private final Vector3i location; | ||||
private final int tick; | ||||
private final Cause cause; // Optional enum for cause | ||||
// private final long time; // System time in milliseconds or nanoseconds for ordering | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||
|
||||
public BlockModification(WrappedBlockState oldBlockContents, WrappedBlockState newBlockContents, | ||||
Vector3i location, int tick, Cause cause) { | ||||
this.oldBlockContents = oldBlockContents; | ||||
this.newBlockContents = newBlockContents; | ||||
this.location = location; | ||||
this.tick = tick; | ||||
this.cause = cause; | ||||
} | ||||
|
||||
@Override | ||||
public String toString() { | ||||
return String.format( | ||||
"BlockModification{location=%s, old=%s, new=%s, tick=%d, cause=%s}", | ||||
location, oldBlockContents, newBlockContents, tick, cause | ||||
); | ||||
} | ||||
|
||||
public enum Cause { | ||||
START_DIGGING, | ||||
APPLY_BLOCK_CHANGES, | ||||
HANDLE_NETTY_SYNC_TRANSACTION, | ||||
OTHER | ||||
} | ||||
} |
35 changes: 35 additions & 0 deletions
35
src/main/java/ac/grim/grimac/utils/change/PlayerBlockHistory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package ac.grim.grimac.utils.change; | ||
|
||
import java.util.concurrent.ConcurrentLinkedDeque; | ||
import java.util.function.Predicate; | ||
|
||
public class PlayerBlockHistory { | ||
private final ConcurrentLinkedDeque<BlockModification> blockHistory = new ConcurrentLinkedDeque<>(); | ||
|
||
// Add a new block modification to the history. | ||
public void add(BlockModification modification) { | ||
blockHistory.add(modification); | ||
} | ||
|
||
// Get all recent modifications (optionally filtered by a condition). | ||
public Iterable<BlockModification> getRecentModifications(Predicate<BlockModification> filter) { | ||
return blockHistory.stream().filter(filter).toList(); // Java 8+ compatible | ||
} | ||
|
||
// Remove old modifications older than maxTick | ||
public void cleanup(int maxTick) { | ||
while (!blockHistory.isEmpty() && maxTick - blockHistory.peekFirst().getTick() > 0) { | ||
blockHistory.removeFirst(); | ||
} | ||
} | ||
|
||
// Get the size of the block history | ||
public int size() { | ||
return blockHistory.size(); | ||
} | ||
|
||
// Clear all block modifications | ||
public void clear() { | ||
blockHistory.clear(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.