nqhgng

Create a Minecraft Fabric client-side mod called "DirectionalHitIndicator" for Minecraft 1.21.11 that displays a shooter-game-style directional hit indicator whenever the local player takes damage.

Functionality:

Hook into the client tick / damage event to detect when the local player's health decreases (compare current health to previous tick's health, since this needs to work for both entity attacks and explosion damage like end crystals).

Determine the source position of the damage:

If the damage came from a living entity (player/mob), use that entity's position.

If the damage came from an explosion (end crystal), use the explosion's detonation coordinates. If the exact source isn't available from the event, estimate it from the nearest recent explosion packet/particle position.

Calculate the relative angle between the player's current yaw (facing direction) and the vector from the player's position to the damage source position, using atan2, normalized to a 0–360 degree range relative to screen orientation.

Render a HUD overlay (hook into the HUD render event, after game render, before other INVENTORY GUI elements):

A circular ring/reticle centered on the crosshair.

A bright arc/chevron segment lights up at the calculated angle on the ring (e.g., damage from directly behind = bottom of ring, damage from the left = left side of ring, etc.).

If the damage source is nearly vertical (directly above/below, e.g., crystal placed through a floor), show a distinct "center pulse" effect instead of a directional arc.

Fade the indicator out over 0.5 seconds after it appears. If a new hit lands before the previous indicator fully fades, replace/refresh it rather than stacking multiple indicators.

Color-code by damage type:

Red for melee/entity damage Orange for explosion/crystal damage Yellow for fall/other damage Add a config screen (Mod Menu / Cloth Config integration) with options to:

Toggle the indicator on/off Adjust indicator size and opacity Adjust fade duration Toggle color-coding on/off Choose indicator style: arc ring vs. single chevron

Technical requirements:

Target Minecraft 1.21, Fabric loader, Fabric API Use Fabric's HudRenderCallback for rendering Use ClientTickEvents for health-change detection Keep all logic client-side only, no server dependency Should be performant enough to run every tick without frame drops

Kodari AI
KodariJul 21 at 5:10 am 10
DirectionalHitIndicator
A client-side Fabric mod that displays a shooter-style directional hit indicator around the crosshair whenever the local player takes damage. It detects melee, explosion, fall, and other damage through health changes, resolves recent attacker or explosion positions, calculates screen-relative direction, and renders a fading arc or chevron with vertical center-pulse feedback. A configurable in-game settings screen controls visibility, size, opacity, fade duration, and color coding.
  1. Set up a Fabric 1.21.11 client-only mod with split source sets and metadata.

  2. Implement client tick damage detection, recent explosion tracking, direction resolution, and indicator state.

  3. Render the configurable ring, arc/chevron, and vertical center pulse through the HUD.

  4. Add YACL and Mod Menu configuration integration plus required assets and manifest.

A client-side Fabric 1.21.11 mod that displays a shooter-style HUD indicator whenever the local player takes damage. It resolves nearby entity and recent End Crystal explosion sources, points an arc or chevron toward the hit direction, shows a center pulse for vertical or unknown damage, fades indicators smoothly, color-codes damage types, and provides a YACL configuration screen through Mod Menu.

жы

Created DirectionalHitIndicator, a client-side Fabric 1.21.11 mod with:

  • Health-drop damage detection via ClientTickEvents

  • Entity and recent End Crystal source resolution

  • Directional arc ring, chevron, and vertical center-pulse HUD indicators

  • Red/orange/yellow damage color coding

  • Configurable enable toggle, size, opacity, fade duration, colors, and style

  • YACL configuration screen exposed through Mod Menu

  • Fabric 1.21.11 split client source sets and modern HudElementRegistry rendering

  • manifest.kod bundling YACL and Mod Menu dependencies

nqhgng

The compilation failed with this error:

code
Compilation failed with 10 error(s):

ERROR in src/main/java/client/java/com/kodari/directionalhitindicator/IndicatorHud.java at line 19: cannot find symbol
        float tickDelta = tickCounter.getTickDelta(false);
                                     ^
  symbol: method getTickDelta(boolean)
  location: variable tickCounter of type RenderTickCounter

ERROR in src/main/java/client/java/com/kodari/directionalhitindicator/DamageTracker.java at line 74: cannot find symbol
            crystalPositions.put(entity.getUuid(), new ExplosionCandidate(entity.getPos(), tick));
                                                                                ^
  symbol: method getPos()
  location: variable entity of type Entity

ERROR in src/main/java/client/java/com/kodari/directionalhitindicator/DamageTracker.java at line 93: cannot find symbol
        Vec3d playerPosition = player.getPos().add(0.0, player.getHeight() * 0.5, 0.0);
                                     ^
  symbol: method getPos()
  location: variable player of type ClientPlayerEntity

ERROR in src/main/java/client/java/com/kodari/directionalhitindicator/DamageTracker.java at line 136: cannot find symbol
            double distance = candidate.position.squaredDistanceTo(player.getPos());
                                                                         ^
  symbol: method getPos()
  location: variable player of type ClientPlayerEntity

ERROR in src/main/java/client/java/com/kodari/directionalhitindicator/DamageTracker.java at line 151: cannot find symbol
                nearestLivingEntity.getPos().add(0.0, nearestLivingEntity.getHeight() * 0.5, 0.0),
                                   ^
  symbol: method getPos()
  location: variable nearestLivingEntity of type LivingEntity

ERROR in   src/main/java/client/java/com/kodari/directionalhitindicator/IndicatorHud.java at line 19: cannot find symbol
          float tickDelta = tickCounter.getTickDelta(false);
                                       ^
  symbol: method getTickDelta(boolean)
  location: variable tickCounter of type RenderTickCounter

ERROR in   src/main/java/client/java/com/kodari/directionalhitindicator/DamageTracker.java at line 74: cannot find symbol
              crystalPositions.put(entity.getUuid(), new ExplosionCandidate(entity.getPos(), tick));
                                                                                  ^
  symbol: method getPos()
  location: variable entity of type Entity

ERROR in   src/main/java/client/java/com/kodari/directionalhitindicator/DamageTracker.java at line 93: cannot find symbol
          Vec3d playerPosition = player.getPos().add(0.0, player.getHeight() * 0.5, 0.0);
                                       ^
  symbol: method getPos()
  location: variable player of type ClientPlayerEntity

ERROR in   src/main/java/client/java/com/kodari/directionalhitindicator/DamageTracker.java at line 136: cannot find symbol
              double distance = candidate.position.squaredDistanceTo(player.getPos());
                                                                           ^
  symbol: method getPos()
  location: variable player of type ClientPlayerEntity

ERROR in   src/main/java/client/java/com/kodari/directionalhitindicator/DamageTracker.java at line 151: cannot find symbol
                  nearestLivingEntity.getPos().add(0.0, nearestLivingEntity.getHeight() * 0.5, 0.0),
                                     ^
  symbol: method getPos()
  location: variable nearestLivingEntity of type LivingEntity


=== COMPILATION ERROR ANALYSIS ===

MISSING METHODS:
  - getTickDelta(boolean)
  - getPos()
ACTION: Check method names and signatures

FILES TO INVESTIGATE:
  - src/main/java/client/java/com/kodari/directionalhitindicator/IndicatorHud.java
  - src/main/java/client/java/com/kodari/directionalhitindicator/DamageTracker.java
  -   src/main/java/client/java/com/kodari/directionalhitindicator/IndicatorHud.java
  -   src/main/java/client/java/com/kodari/directionalhitindicator/DamageTracker.java

Please fix this error by creating a new artifact with the corrected code.

Kodari AI
KodariJul 21 at 5:20 am 11
  1. Updated the HUD tick-delta call to the 1.21.11 RenderTickCounter API.

  2. Updated entity position calls to the 1.21.11 Yarn position accessor.

Fixed the 10 compilation errors and created the corrected artifact.

Changes:

  • Replaced RenderTickCounter.getTickDelta(false) with the verified 1.21.11 method getTickProgress(false).

  • Replaced all invalid entity position calls with getEntityPos():

    • End crystal positions

    • Client player positions

    • Living entity positions

  • Preserved the existing RenderTickCounter type and HUD registration compatibility.

Updated files:

  • src/client/java/com/kodari/directionalhitindicator/IndicatorHud.java

  • src/client/java/com/kodari/directionalhitindicator/DamageTracker.java

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
manifest.kod
settings.gradle
Code
13 719
src/client/java/com/kodari/directionalhitindicator/DirectionalHitIndicatorClient.java
package com.kodari.directionalhitindicator;

import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.rendering.v1.hud.HudElementRegistry;
import net.fabricmc.fabric.api.client.rendering.v1.hud.VanillaHudElements;
import net.minecraft.util.Identifier;

public class DirectionalHitIndicatorClient implements ClientModInitializer {
    public static final String MOD_ID = "directionalhitindicator";
    public static final Identifier HUD_ID = Identifier.of(MOD_ID, "damage_indicator");

    @Override
    public void onInitializeClient() {
        IndicatorConfig.load();
        ClientTickEvents.END_CLIENT_TICK.register(DamageTracker::tick);
        HudElementRegistry.attachElementAfter(VanillaHudElements.CROSSHAIR, HUD_ID, IndicatorHud::render);
    }
}