Fix Collisions and improve setback handling #2
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
6b6t/NoCheatPlus!2
Loading…
Reference in a new issue
No description provided.
Delete branch "master"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixed collisions for chains, bamboo, dripstone and copper golems. Fixed a theoretical setback teleport crash, also improved collisions accuracy in diagonal tunnels
Summary by CodeRabbit
Bug Fixes
Tests
📝 Walkthrough
Walkthrough
The changes update movement validation, setback handling, combat restrictions, vanilla-compatible seed calculations, block compatibility, trace logging, piglin head models, and repository ignore rules.
Changes
Movement validation and setback handling
NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/magic/Magic.java,NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/model/PlayerMoveData.java,NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/player/CreativeFly.javaNCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingData.java,NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingListener.java,NCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/util/MovingUtil.java,NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/Folia.javaNCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/fight/FightListener.java,NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/BridgeMaterial.javaVanilla location seed behavior
NCPCore/src/main/java/fr/neatmonster/nocheatplus/utilities/location/LocUtil.java,NCPCompatBukkit/src/main/java/fr/neatmonster/nocheatplus/compat/bukkit/model/BukkitBamboo.java,NCPPlugin/src/test/java/fr/neatmonster/nocheatplus/test/TestBlockOffsetSeed.javaRuntime compatibility and environment handling
NCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/blocks/init/vanilla/BlocksMC1_16.java,NCPCompatBukkit/src/main/java/fr/neatmonster/nocheatplus/compat/bukkit/MCAccessBukkitModern.javaNCPCore/src/main/java/fr/neatmonster/nocheatplus/logging/BukkitLogManager.javaRepository ignore configuration
.gitignoreCLAUDE.mdis added to the ignore list.Priority: ➖ Normal
Estimated code review effort: 4 (Complex) | ~45 minutes
Change: Bug fix
Sequence Diagram(s)
Merge Risk: 🟠 High · up to
1080cThis can prevent startup on supported legacy servers or leave corrective movement handling broken at runtime. These issues should be fixed before merge.
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share
Comment
@coderabbitai helpto get the list of available commands.Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Advanced
Run ID:
8eda5af0-dcd8-4706-a7d5-3b4a9a400621📥 Commits
Reviewing files that changed from the base of the PR and between
fb4c7ccf0dand6dd11858df.📒 Files selected for processing (13)
.gitignoreNCPCompatBukkit/src/main/java/fr/neatmonster/nocheatplus/compat/bukkit/model/BukkitBamboo.javaNCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingData.javaNCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingListener.javaNCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/magic/Magic.javaNCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/model/PlayerMoveData.javaNCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/player/CreativeFly.javaNCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/util/MovingUtil.javaNCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/Folia.javaNCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/blocks/init/vanilla/BlocksMC1_16.javaNCPCore/src/main/java/fr/neatmonster/nocheatplus/logging/BukkitLogManager.javaNCPCore/src/main/java/fr/neatmonster/nocheatplus/utilities/location/LocUtil.javaNCPPlugin/src/test/java/fr/neatmonster/nocheatplus/test/TestBlockOffsetSeed.javaIncluded review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Handle clock rollback for
MovingData.When a pending set-back stores a future timestamp,
MovingUtil.processStoredSetBack()rejects requests until wall time passes that timestamp by one second.DataManager.handleSystemTimeRanBackwards()invokes onlyICanHandleTimeRunningBackwardsinstances, butMovingDatadoes not implement that interface. Therefore, its existinghandleTimeRanBackwards()method does not run.Make
MovingDataimplementICanHandleTimeRunningBackwardsand clamp the field in the dispatched handler:A monotonic clock is an alternative for this throttle.
🤖 Prompt for AI Agents
✅ Addressed in commits
0983ee8tof6bfa44🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Require a confirmed wall collision before increasing the friction base.
isFlushWithBlockEdge(to)only tests bounding-box alignment. It is true in open space when a player is at coordinates such asx = n + 0.3. Line 172 then stores up tohDistance * sqrt(2), and line 482 uses it to increase the next move allowance. A player can therefore obtain extra horizontal friction without being cut short by a wall.Set
hClippedBaseonly when the move was blocked by a colliding block in the travelled direction. Reset it to0.0otherwise.🤖 Prompt for AI Agents
✅ Addressed in commits
0983ee8tof6bfa44🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Do not let an older completion clear a newer pending teleport.
After one second, this method can record a newer pending teleport. If the older future then completes, this unconditional write clears the newer request state. The next call can schedule another teleport while the newer request is still pending.
Track a request generation or use an
AtomicLongand clear the state only withcompareAndSet(requestTimestamp, 0L).🤖 Prompt for AI Agents
✅ Addressed in commits
0983ee8tof6bfa44@codex review
To use Codex here, create a Codex account and connect to github.
lol
@codex
To use Codex here, create a Codex account and connect to github.
@claude review
@coderabbit revoew
@AlexProgrammerDEI will review pull request#2.⚠️ Action not completed
Review rate limited.
@coderabbitai review
✅ Action performed
Review finished.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Advanced
Run ID:
90514782-caad-4146-885e-67182d94e328📥 Commits
Reviewing files that changed from the base of the PR and between
6dd11858dfand1080ce87ee.📒 Files selected for processing (7)
NCPCompatBukkit/src/main/java/fr/neatmonster/nocheatplus/compat/bukkit/MCAccessBukkitModern.javaNCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/fight/FightListener.javaNCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingData.javaNCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/MovingListener.javaNCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/player/CreativeFly.javaNCPCore/src/main/java/fr/neatmonster/nocheatplus/checks/moving/util/MovingUtil.javaNCPCore/src/main/java/fr/neatmonster/nocheatplus/compat/BridgeMaterial.javaIncluded review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.
@ -718,2 +734,4 @@}/** AbstractArrow exists since MC 1.14, Trident since 1.13. Looked up by name to load on legacy servers. */private static final Class<?> ABSTRACT_ARROW = ReflectionUtil.getClass("org.bukkit.entity.AbstractArrow");🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift
Remove direct references to version-specific projectile classes.
The project supports legacy Spigot versions as far back as 1.7.10, where
AbstractArrowandTridentare absent.FightListeneris instantiated and registered during plugin startup. ThehasAbstractArrowguard only protects execution ofonProjectileLaunch; it does not prevent JVM linking of the directinstanceofreferences. A missing class can therefore preventFightListenerfrom loading before registration.Use reflected class handles with
Class.isInstancefor both classes.🤖 Prompt for AI Agents
Reviewed commit
da65173fe3against the surrounding NCP code and the Minecraft 26.2, Paper and Folia sources available locally.Requesting changes for the inline findings: the elytra vertical cap rejects legitimate dives, the wall allowance can feed repeated acceleration into later limits, offhand spear attacks are missed, arrow launches are not covered while a setback is pending, and the untracked-movement poll can permanently miss a short burst.
The collision fixes are justified: vanilla performs the x seed multiplication as an int before promotion, so the shared seed correction fixes bamboo and Java dripstone offsets; piglin heads need their distinct collision shapes; and removing the obsolete CHAIN assertion allows later version setups, including iron chains and copper-golem statues, to execute. Scheduling setbacks independently of debug mode and consistently using the fallback teleport location also fix real issues.
The nonblocking Folia teleport helper is the right direction. The one-second pending timeout remains a heuristic because it does not cancel an older request. Routing trace output to the console is a separate behavior change, enabled by the default console setting. The new seed test passes, though deterministic overflow-boundary cases would be easier to maintain than randomized comparisons against a copied formula. The ignore-file change and compatibility constant are otherwise straightforward.
Validation: the default Maven reactor compiled and TestBlockOffsetSeed passed. The dive and wall-allowance recurrences were also checked numerically. These findings are based on source inspection and calculations, not live client/server reproductions.
@ -691,6 +697,16 @@ public class FightListener extends CheckListener implements JoinLeaveListener{else attackerData = null;[P2] Check the hand responsible for spear damage
This checks only the main-hand item, but Minecraft's
ItemStack.onUseTickpasseslivingEntity.getUsedItemHand().asEquipmentSlot()intoKineticWeapon.damageEntities, andPlayer.stabAttackuses that equipment slot to select the weapon. An offhand spear with an ordinary main-hand item therefore avoids the new post-setback restriction. Please identify the weapon responsible for the attack, including an actively used offhand spear.@ -717,6 +733,64 @@ public class FightListener extends CheckListener implements JoinLeaveListener{}}[P2] Cover pending setbacks when preventing arrow launches
isRecentlySetBack()only becomes true afterMovingData.onSetBack()records the confirmation tick. This launch handler does not check whether a setback has been prepared, scheduled or is still pending, so a launch between movement rejection and confirmation is not covered. That matters for asynchronous/deferred setback handling and is the interval in which invalid movement should not contribute to projectile velocity. The existing melee path already checks scheduled setbacks. Please cover the pending interval here as well as the post-confirmation interval.[P2] Preserve an unresolved position discrepancy across polling intervals
A normal movement event followed by an untracked burst before the next poll changes
moveCount, so that poll skips enforcement. The method nevertheless stores the displaced location inuntrackedX/Y/Z. If the player stops there, every subsequent poll fails this positive-distance condition, even though the player remains more than 0.1 blocks fromlastMove.to. A short untracked burst can therefore remain undetected indefinitely by this new check. Please track the unresolved discrepancy from the last validated position independently of whether the player changed position since the previous poll.[P1] Do not feed unused bunnyhop allowance into the next movement limit
The added 0.3 is granted whenever modifiers apply and the player is not flying, even when
hDist()grants no bunnyhop leniency. Moving parallel to a wall at exactlylimitHproduces no horizontal violation, yet storesmin(limitH + 0.3, limitH * sqrt(2))for the next friction calculation. This creates repeated acceleration. For example, the default slow-falling model enables modifiers: starting at its 0.39 allowance, the recurrence reaches about 2.83 blocks/move after ten moves and 5.00 after twenty, with each submitted horizontal distance at its current limit. The sqrt(2) cap does not stop the feedback. Please restrict this to justified collision-related motion and avoid adding allowance that the current move never used or qualified for.@ -223,6 +231,16 @@ public class CreativeFly extends Check {limitV = res[0];[P1] Allow legitimate elytra dives above 3 blocks per tick
Vanilla's
LivingEntity.updateFallFlyingMovementdoes not impose this cap. With pitch straight down and normal gravity, the vertical recurrence is approximatelyvy = (vy - 0.08) * 0.98, approaching -3.92 blocks/tick. Starting from rest, it exceeds 3 blocks/tick after 72 ticks and roughly 135 blocks of descent, without riptide or external velocity. This condition therefore adds violations and potential setbacks to ordinary elytra dives that match the existing physics calculation. Please validate against the movement envelope, including previous velocity, pitch, gravity and boosts, rather than applying this fixed absolute cap.Fresh review of all 16 changed files at
3708807against base3e95e59and the local Minecraft/Folia sources. The earlier wall-speed increase, offhand spear gap, pending-setback combat gap, and descending-elytra case have been addressed. The seed and collision compatibility changes look justified.Requesting changes for the three teleport-state issues below: legitimate eventless Folia teleports can be rolled back, delayed setbacks do not confirm completion, and failed untracked-movement corrections cannot perform their intended retry.
Validation: mvn -B -ntp test passed all 88 tests. These findings are based on source tracing, not a live-server reproduction.
[P1] Account for legitimate eventless Folia teleports before rolling back
This also matches a legitimate same-region /tp or plugin teleport followed by the player standing still. Folia's Entity.teleportAsync same-region path calls ServerPlayer.teleportSyncSameRegion, which uses internalTeleport and resets the connection position without firing PlayerTeleportEvent. MovingData therefore retains the old checked position, hasTeleported() is false, and this poll sends the player back once the displacement exceeds 0.1 blocks. The outgoing-position adapter only updates NetData and does not refresh this movement reference. Please track legitimate server teleports and update the trusted reference before treating an eventless displacement as an exploit.
[P2] Preserve a trusted correction target so failed teleports can retry
prepareSetBack(newTo) invalidates playerMoves before the teleport is attempted. If the future returns false or completes exceptionally, resetTeleported() does not restore that history. The next poll consequently takes the !lastMove.valid branch and continues skipping correction until a new movement event arrives. A client producing no PlayerMoveEvent is precisely the case this check is intended to handle, so the stated retry never happens. Please retain a trusted retry target independently of the invalidated move history, or restore the necessary trusted state on failure.
[P2] Confirm delayed setbacks on the player thread after successful completion
This callback only clears setBackTeleportPendingSince; it does not confirm or clear MovingData.teleported. On Folia's same-region path there is no PlayerTeleportEvent to perform that work, and PlayerData already cleared requestPlayerSetBack before calling this method. If no subsequent movement event arrives, hasTeleported() remains true: the new untracked-movement poll keeps skipping the player and isRecentlySetBack keeps blocking eligible combat beyond the five-tick window. Please perform guarded completion handling on the player's entity thread, including updating the movement reference and setback tick on success, as the untracked-movement path does.
Reviewed the changes in
298e147. The delayed-setback completion handling and preservation of the correction target across failed teleports address the previous findings. However, the new rule for recognizing eventless teleports still needs changes: a pause can legitimize untracked movement, and a legitimate teleport followed by a small movement can still be rolled back. Please use verified server-teleport information instead of inferring a teleport from whether the player pauses.Validation: all 88 Maven tests pass. An isolated Java harness running the extracted check reproduced both cases below, and confirmed that a stationary eventless teleport is accepted and a failed correction can retry while movement continues. These are source/harness results, not live-server reproductions.
[P1] Do not promote an untracked position to trusted solely because the player pauses
A client can move in a short PacketFly burst, hold the endpoint for the next poll, and repeat. The first poll records a discrepancy; the second enters this branch and adopts the unchecked endpoint. No PlayerMoveEvent or verified server teleport is needed. In a harness running the extracted check, ten 0.15-block bursts with a stationary poll after each advanced the trusted position by 1.5 blocks with zero corrections, while the checked movement reference remained at the starting position. Please require verified server-teleport information before adopting the endpoint; a pause does not distinguish legitimate teleports from this exploit.
[P2] Preserve legitimate eventless teleports followed by sub-threshold movement
The assumption that a legitimate teleport stays put still causes false corrections. For example, after an eventless same-region teleport from x=0 to x=10, let the first poll record x=10 and then move to x=10.02 before the next poll without changing rotation. Bukkit does not fire PlayerMoveEvent for this 0.02-block displacement because it is below 1/16 block, so the checked reference remains at x=0. However, it exceeds this check's 0.01-block stationary threshold, so this branch teleports the player back to x=0. The extracted-check harness reproduces that result. Please update the trusted reference from the legitimate server teleport itself, so subsequent small movements cannot be treated as evidence against that teleport.
Heads up on a platform gap I ran into while fixing the untracked-move findings — it's broader than this PR.
On Folia, player teleports fire no
PlayerTeleportEvent. Checked against the shippedfolia-26.2jar (26.2-7-14b7fee):CraftPlayer.teleport0(...)throwsUnsupportedOperationException("Must use teleportAsync while in region threading"), so the sync Bukkit teleport path doesn't exist for players.CraftEntity.teleportAsync(...)delegates vialambda$teleportAsync$0straight toEntity.teleportAsync(ServerLevel, Vec3, ...)with no event call.ServerPlayer.teleportSyncSameRegion(...)→connection.internalTeleport(...), which sets the position without firing the event.PluginManager.callEventsites inEntity/ServerPlayerareEntityPoseChangeEvent(insetPose) andPlayerRespawnEvent(in respawn) — nothing teleport related.Consequences for NCP on Folia:
MovingListener'sPlayerTeleportEventhandling is effectively dead, so a/tpor plugin teleport leaves the movement reference stale.processStoredSetBackand the untracked-move correction now confirm explicitly viaMovingUtil.confirmSetBack.TeleportQueueis only fed byOutgoingPosition(ProtocolLib) and by NCP's own set back path. So on a Folia server without ProtocolLib, an eventless teleport gets corrected once by the untracked-move check. I deliberately did not paper over that by inferring teleports from movement, since that was exploitable.Is it worth tracking separately? If Folia exposes a hook I missed, or you'd rather the untracked-move check skip correcting entirely when no verified teleport info is available, say which way you want it.