TargetEventBackport for Minecraft 1.16.5 (Forge)
Mod Overview
The TargetEventBackport mod addresses a significant limitation in Minecraft 1.16.5 Forge where the LivingSetAttackTargetEvent cannot be canceled. This prevents mod developers from controlling mob targeting behavior—functionality that's freely available in modern game versions (1.18.2+). This modification bridges this gap by introducing a fully cancelable event, restoring functional parity with newer Minecraft editions.
Key Features
-
Addition of
MobChangeTargetEvent: A cancelable event that triggers whenever a mob changes its attack target (via theMob#setTargetmethod). -
Seamless Integration: Uses Mixin injections to trigger the event without altering vanilla game behavior when unused.
-
High-Version Compatibility: Mimics the behavior of Forge's
LivingSetAttackTargetEventfrom versions 1.18.2+, enabling:- Canceling unwanted targeting (e.g., preventing creepers from targeting players)
- Dynamically overriding targets (e.g., redirecting mobs to custom entities)