Maks Dymarek

Create a Minecraft Java 1.21.4 Fabric client-side mod that displays floating damage numbers whenever I hit an entity or player. Show the actual health damage dealt above the target. Add a simple configuration screen where I can enable or disable damage numbers and change their color using preset colors or a custom HEX color. Numbers should float upward, fade out, and disappear smoothly. Keep the mod lightweight and compatible with multiplayer. Generate a working Fabric mod JAR for Minecraft 1.21.4.

Kodari AI
KodariOct 28 at 8:36 pm 3
DamageFloater
Client-side Fabric mod for Minecraft 1.21.4 that displays floating damage numbers above hit entities. Numbers float upward, fade out smoothly, and show actual health damage dealt. Includes a configuration screen to toggle the mod on/off and customize number color via presets or custom HEX input. Lightweight, multiplayer-compatible, and generates a working mod JAR.
  1. Create the Fabric 1.21.4 client mod structure and metadata.

  2. Implement local-hit damage tracking, floating number rendering, and persisted color/enable settings.

  3. Add a keybind-opened configuration screen with preset and custom HEX colors.

Implemented the client-side Fabric mod. It tracks server-synchronized health loss after your attacks, then displays floating damage numbers that rise and fade. Press O to open settings; choose a preset or enter a custom HEX color. Settings are saved in config/floatdamage.properties.

To create and download the JAR: click Compile in the desktop top bar, or on phone tap ⋮ → Compile Project. Click Compile in the window, then click Download when the build succeeds.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
settings.gradle
Code
9 426
src/main/java/com/kodari/floatdamage/DamageNumbersClient.java
package com.kodari.floatdamage;

import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.fabricmc.fabric.api.client.rendering.v1.WorldRenderEvents;
import net.fabricmc.fabric.api.event.player.AttackEntityCallback;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.util.ActionResult;

public final class DamageNumbersClient implements ClientModInitializer {
    private static final KeyBinding OPEN_CONFIG = KeyBindingHelper.registerKeyBinding(
            new KeyBinding("key.floatdamage.config", 79, "key.categories.floatdamage")
    );

    @Override
    public void onInitializeClient() {
        MinecraftClient client = MinecraftClient.getInstance();
        DamageNumbersConfig.load(client);

        AttackEntityCallback.EVENT.register((player, world, hand, entity, hitResult) -> {
            if (player == client.player && world == client.world) {
                DamageNumberManager.trackAttack(entity);
            }
            return ActionResult.PASS;
        });

        ClientTickEvents.END_CLIENT_TICK.register(currentClient -> {
            DamageNumberManager.tick(currentClient);
            while (OPEN_CONFIG.wasPressed()) {
                currentClient.setScreen(new DamageNumbersConfigScreen());
            }
        });

        WorldRenderEvents.AFTER_ENTITIES.register(DamageNumberManager::render);
    }
}