Skip to content

Interacting with an entity

Checking if an entity is an injected entity

Section titled “Checking if an entity is an injected entity”

To check if an entity is an injected Bestium entity, use:

Bestium.getEntityManager().isInjected(entity)

To get the EntityInjection of an injected entity, use:

val injection = Bestium.getEntityManager().getInjection(entity)

This returns null if the entity is not an injected Bestium entity.

Alternatively, you can use the requireInjection method, which throws an exception if the entity is not an injected Bestium entity:

val injection = Bestium.getEntityManager().requireInjection(entity)

To get the entity’s real type, obtain the Minecraft NMS entity and call getType().

val nmsEntity = (entity as CraftEntity).handle
val realType = nmsEntity.type

To get the entity’s backing type, use:

val backingType = Bestium.getEntityManager().getBackingType(entity)

This method is more efficient than first obtaining an EntityInjection and then calling .getRealType() on it.