Create a Floating Damage Number Above a Mob
Setting Up the Hologram
Floating damage numbers are one of the most common uses for holograms. You'll need to trigger hologram creation when damage occurs—typically through an event listener in your mod code.
1. Listen for a damage event on the target entity
2. Get the entity's position and add a small offset upward (usually 1-2 blocks) so the text appears above the mob's head
3. Create a text component with your damage value, styled in red or another color
4. Spawn the hologram at those coordinates
Animating the Rise
To make the number rise and fade, attach an update function that runs every tick:
- Increment the Y position slightly each tick to move the text upward
- Optionally reduce opacity or scale over time for a fade effect
- Set the lifetime to 40-60 ticks (2-3 seconds) so the hologram disappears automatically
Adjust the render distance so the number is visible from a reasonable combat distance, and enable text shadow for better readability against varied backgrounds.