Reach Distance Mixin Override
Minecraft Gameplay Impact
In Minecraft, ClientPlayerInteractionManager coordinates player actions in the world, including block placement, breaking, and entity interactions. The method getReachDistance() returns the client reach distance in blocks, while hasExtendedReach() checks whether creative or extended range mode is currently active.
Reach_Mixin_Override detects mods that hook into ClientPlayerInteractionManager via SpongePowered Mixin to override these methods. In the Phosphor cheat client (net.caffeinemc.phosphor.mixin.ClientPlayerInteractionManagerMixin), @Inject hooks into getReachDistance()F at HEAD with cancellable = true. If the client module is active and blockReachToggle is enabled, it cancels vanilla calculation and immediately returns a custom float (reachModule.blockReach.getFValue()). Simultaneously, hasExtendedReach()Z is hooked to return false to avoid triggering client-side creative-mode discrepancies.
While this allows the client to target blocks and entities from greater distances, server-side position validation will still discard interaction packets if the server calculates the distance between player and target as exceeding server limits.
Functions & APIs Analyzed
ClientPlayerInteractionManager.getReachDistance / method_2904
Returns the player's base interaction reach in blocks (typically 4.5f in vanilla).
ClientPlayerInteractionManager.hasExtendedReach / method_2924
Boolean predicate indicating whether the player possesses extended reach privileges.
@Inject / @ModifyReturnValue (Mixin)
SpongePowered Mixin annotations intercepting method execution and overriding return values.
Decompiled Representation (Vineflower View)
@Inject(at = @At("HEAD"), method = "getReachDistance()F", cancellable = true)
private void onGetReachDistance(CallbackInfoReturnable<Float> cir) {
ReachModule reachModule = (ReachModule)Phosphor.moduleManager().getModule(ReachModule.class);
if (AsteriaMenu.isClientEnabled() && reachModule != null && reachModule.isEnabled() && reachModule.blockReachToggle.isEnabled()) {
cir.setReturnValue(reachModule.blockReach.getFValue());
}
}
@Inject(at = @At("HEAD"), method = "hasExtendedReach()Z", cancellable = true)
private void hasExtendedReach(CallbackInfoReturnable<Boolean> cir) {
if (AsteriaMenu.isClientEnabled() && Phosphor.moduleManager().isModuleEnabled(ReachModule.class)) {
cir.setReturnValue(false);
}
}
Bytecode Signature & Static Detection
The detector inspects method and class annotations, matching Mixin injection annotations (@Inject, @ModifyReturnValue, @ModifyExpressionValue, @Redirect, or @Overwrite) whose target method attribute matches reach query signatures:
- Intermediary methods:
method_2904(getReachDistance),method_2924(hasExtendedReach),method_55693(getEntityInteractionRange), ormethod_55694(getBlockInteractionRange). - Named vanilla, Forge, or NeoForge methods:
getReachDistance,hasExtendedReach,getEntityReach,getBlockReach,func_78749_i,func_78757_d,m_320392_, orm_320393_.
The detector identifies modifications that intercept reach getter methods directly via bytecode mixins. If a mod modifies reach calculations entirely outside Mixin transformers (for example via custom runtime ASM class redefinition or custom networking protocols), this rule will not trigger.