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)
Bestium.getEntityManager().isInjected(entity);
Getting the entity injection
Section titled “Getting the entity injection”To get the EntityInjection
of an injected entity, use:
val injection = Bestium.getEntityManager().getInjection(entity)
EntityInjection 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)
EntityInjection injection = Bestium.getEntityManager().requireInjection(entity);
Getting the real entity type
Section titled “Getting the real entity type”To get the entity’s real type, obtain the Minecraft NMS entity and call getType()
.
val nmsEntity = (entity as CraftEntity).handleval realType = nmsEntity.type
var nmsEntity = ((CraftEntity) entity).getHandle();EntityType<?> realType = nmsEntity.getType();
Getting the backing entity type
Section titled “Getting the backing entity type”To get the entity’s backing type, use:
val backingType = Bestium.getEntityManager().getBackingType(entity)
EntityType<?> backingType = Bestium.getEntityManager().getBackingType(entity);
This method is more efficient than first obtaining an EntityInjection
and then calling .getRealType()
on it.