
<Task> You are a senior Minecraft Mod Developer. Write a com...
Prompt
<Task> You are a senior Minecraft Mod Developer. Write a complete, production-ready implementation of a custom Zombie AI overhaul mod for Minecraft. The focus is strictly on highly optimized pathfinding, custom hearing/vision vectors, and zero server-tick lag. </Task> <Environment> - Minecraft Target Version: 1.16.x (Using official Mojang mappings) - Development Environment: Fabric Mixins - Language: Java 17+ </Environment> <SystemArchitecture> You must intercept and modify the vanilla `Zombie` / `ZombieEntity` goal selector selector system. Remove default target selectors (`NearestAttackableTargetGoal` for players) and replace them with the custom sensory mechanics defined below. </SystemArchitecture> <Constraints> 1. All mathematical conditions (angles, distance vectors) must be calculated using exact dot products (`Vec3.dot()`). 2. Write full, functional Java classes/mixins. Do not use placeholders, comments like "// TODO", or truncated code. 3. Optimize for performance: avoid running heavy sight/hearing checks every single tick. Use an interval-based gate (e.g., check every 4 or 5 ticks using `entity.tickCount % 5 == 0`). </Constraints> <Features> <HearingMechanics> - Active Sound Detection: Intercept sound events within a 24-block radius of the zombie. If a player triggers a sound (Sprinting, Jumping, Placing/Breaking blocks, Opening containers), the zombie must immediately pathfind to the exact `BlockPos` of the sound source. - Blindspot Proximity: If a player is walking (not sneaking, not sprinting) within a strict 5-block radius directly behind the zombie, the zombie must immediately detect the player and rotate to engage. </HearingMechanics> <VisionMechanics> - Field of View (FOV): Restrict the zombie's vision to a strict 70-degree cone relative to its current look vector. - Distance Cap: Inside this 70-degree cone, the absolute maximum detection distance is 12 blocks. - Stealth Traversal: If a player is outside the 70-degree front cone, they are completely invisible to the zombie, provided they remain outside the 5-block hearing radius. </VisionMechanics> <AdvancedBehaviors> - Investigation State: When a sound is heard but the player is not seen, the zombie must move to the sound location at 0.5x speed, perform a "looking around" animation/head rotation for 5 seconds, and then resume normal wandering if no target is found. - Pack Alert: When one zombie successfully locks onto a player in combat, it must trigger a dynamic alert to all other zombies within a 15-block radius, updating their pathfinding target to the player's current location. </AdvancedBehaviors> </Features> <ExecutionInstruction> Before outputting any code, use your internal reasoning space to plan the math for the 70-degree FOV check using dot product formulas between the zombie's look vector and the vector pointing to the player. Ensure the cosine of the angle is correctly mapped. </ExecutionInstruction> <OutputFormat> 1. Core Mixin or Event Handler class managing the sensory loops. 2. Custom AI Goals (`Goal` extensions) for the "Investigation" and "Hearing Target" states. 3. A breakdown of the FOV dot-product math used in the code. </OutputFormat>