Entity Handlers
Entity handlers can be used to display info about the entity the player is looking at.
Adding an Entity Handler
Make a class which will hold our Handler.
Make a function which will be our handler.
private static boolean handleMyEntity(Entity entity, Player player) { if (/* your condition */) { // Your logic here WITAPI.updateBar(yourInfo, player); return true; // Successfully handled the entity } return false; // Not your entity, skip it }Now that you have made the Handler, you must register it.
WITAPI.addEntityHandler(YourClass::handleMyEntity);That's it, you have made you entity handler!
A complete example of an entity handler (this uses the internal [WAILAManager]):
public static boolean handleEntity(Entity entity, Player player) { if (MTAPI.isBiter(entity)) { Info info = new Info(); info.setName(Component.text("Biter")); float health = 0; if (WITMinetorio.CONFIG.getBoolean("biter-health-progress")) { if (entity instanceof LivingEntity) { health = (float) Math.max(0f, Math.min(1f, ((LivingEntity) entity).getHealth() / ((LivingEntity) entity).getAttribute(Attribute.MAX_HEALTH).getValue())); } } for (Function<Entity, Component> func : suffixEntity) { info.addSuffix(func.apply(entity)); } API.updateBar(info, 1 - health, player); } return false; }
16 May 2025