Описание
## About
Entity Health Display is a fabric server-side library for displaying entities' health.
## Installing
To use Entity Health Display in your project add the Modrinth repository to your build file and a mod dependency. Replace the `VERSION_TAG` with the latest version, for example `0.3.1+1.20.2`
```gradle
repositories {
maven {
url "https://api.modrinth.com/maven"
content { includeGroup "maven.modrinth" }
}
maven { url "https://maven.nucleoid.xyz" }
}
dependencies {
modImplementation include("maven.modrinth:entity-health-display:VERSION_TAG")
modImplementation include("eu.pb4:placeholder-api:${project.placeholder_api}")
modImplementation include("eu.pb4:polymer-virtual-entity:${project.polymer_version}")
}
```
## Example
```java
HealthDisplayEvents.FORMAT_HEALTH_DISPLAY.register((entity, world) -> {
String color = (entity.getMaxHealth() / 2) >= entity.getHealth() ? "" : "";
var text = TextParserUtils.formatText("" + entity.getName().getString() + " " + color + String.format("%.1f", entity.getHealth()) + "/" + (int)entity.getMaxHealth() + "❤");
return text;
});
HealthDisplayEvents.SHOULD_DISPLAY_HEALTH.register((entity, world) -> {
return true;
});
```