Class CustomEntity
java.lang.Object
dev.lone.itemsadder.api.CustomEntity
- Direct Known Subclasses:
CustomPlayer
Wrapper for a custom entity spawned or converted by ItemsAdder.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classWrapper for a rendered bone of a custom entity.static classWrapper for a mount bone of a custom entity. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddPassenger(LivingEntity passenger) Will add new passenger to the next unoccupied mount bonevoidAdds a viewer to this custom entity.static @Nullable CustomEntitybyAlreadySpawned(Entity entity) Gets a custom entity wrapper from an already spawned entity.static @Nullable CustomEntityconvert(String namespacedId, LivingEntity bukkitEntity) Converts an existing living entity into a custom entity.static @Nullable CustomEntityconvert(String namespacedId, LivingEntity bukkitEntity, boolean frustumCulling) Converts an existing living entity into a custom entity.static @Nullable CustomEntityconvert(String namespacedId, LivingEntity bukkitEntity, boolean frustumCulling, boolean noHitbox, boolean canBaseEntityBeDestroyed, boolean hideBaseEntity) Converts an existing living entity into a custom entity with advanced options.static @Nullable CustomEntityconvert(String namespacedId, LivingEntity bukkitEntity, List<Player> viewers, boolean frustumCulling) Converts an existing living entity into a custom entity visible to specific viewers.voiddestroy()Destroys this custom entity.Gets all animation names for this custom entity.getAnimationsNames(String entityNamespacedId) Gets all animation names for a registered custom entity.@Nullable CustomEntity.BonegetBones()Gets the base Bukkit entity used by this custom entity.booleanGets whether this custom entity uses frustum culling.getId()Gets the id of this custom entity without namespace.Gets the current custom entity location.getLoot()Gets the loot generated by this custom entity.getLoot(LivingEntity bukkitEntity, @Nullable ItemStack tool) Gets the loot generated by a custom entity.Gets the loot generated by this custom entity.@Nullable CustomEntity.MountBonegetMountBoneByPassenger(LivingEntity passenger) Gets theCustomEntity.MountBonecurrently ridden by the specified passenger if soGets the namespace of this custom entity.Gets the custom entity namespaced id.Gets all custom entity namespaced ids currently registered.Gets all passengers currently mounted on this custom entity.getType()Gets the Bukkit entity type of the base entity.booleanhasAnimation(String name) Checks if this custom entity has an animation.static booleanhasAnimation(String entityNamespacedId, String animationName) Checks if a registered custom entity has an animation.booleanChecks if this custom entity has mount bones.booleanbooleanhasPassenger(LivingEntity passenger) static booleanisCustomEntity(UUID uuid) Checks if an entity UUID is registered as a custom entity.static booleanisCustomEntity(Entity entity) Checks if a Bukkit entity is registered as a custom entity.static booleanisInRegistry(String namespacedId) Checks if a custom entity is registered.booleanisPlayingAnimation(String name) Checks if an animation is currently playing.booleanplayAnimation(String name) Plays an animation on this custom entity.booleanplayAnimation(String name, @Nullable Runnable callback) Plays an animation on this custom entity.voidplayDamageEffect(boolean fire) Plays the damage effect on this custom entity.static voidremovePassenger(LivingEntity passenger) Removes a passenger from any custom entity mount.voidremoveViewer(Player player) Removes a viewer from this custom entity.voidForces this custom entity bones to respawn for a player.voidsetColorAllBones(int color) Sets the color of all rendered bones.voidsetEnchantedAllBones(boolean enchanted) Sets the enchanted glint state of all rendered bones.voidsetFrustumCulling(boolean cull) Sets whether this custom entity uses frustum culling.static @Nullable CustomEntitySpawns a custom entity at a location.static @Nullable CustomEntitySpawns a custom entity at a location.static @Nullable CustomEntityspawn(String namespacedId, Location location, boolean frustumCulling, boolean noBase, boolean noHitbox) Spawns a custom entity with advanced base entity options.static @Nullable CustomEntityspawn(String namespacedId, Location location, List<Player> viewers, boolean frustumCulling, boolean noBase, boolean noHitbox, @Nullable Consumer<LivingEntity> function) Spawns a custom entity visible to specific viewers with advanced base entity options.static @Nullable CustomEntityspawn(String namespacedId, Location location, List<Player> viewers, boolean frustumCulling, @Nullable Consumer<LivingEntity> function) Spawns a custom entity visible to specific viewers.voidStops the current animation.voidTeleports this custom entity.
-
Constructor Details
-
CustomEntity
public CustomEntity()
-
-
Method Details
-
getNamespacedIdsInRegistry
-
isInRegistry
Checks if a custom entity is registered.- Parameters:
namespacedId- the custom entity namespaced id.- Returns:
- true if the custom entity exists in the registry.
-
spawn
Spawns a custom entity at a location.- Parameters:
namespacedId- the custom entity namespaced id.location- the spawn location.- Returns:
- the spawned custom entity wrapper, or null if it cannot be spawned.
-
spawn
@Nullable public static @Nullable CustomEntity spawn(String namespacedId, Location location, boolean frustumCulling) Spawns a custom entity at a location.- Parameters:
namespacedId- the custom entity namespaced id.location- the spawn location.frustumCulling- true to enable client-side frustum culling.- Returns:
- the spawned custom entity wrapper, or null if it cannot be spawned.
-
spawn
@Nullable public static @Nullable CustomEntity spawn(String namespacedId, Location location, List<Player> viewers, boolean frustumCulling, @Nullable @Nullable Consumer<LivingEntity> function) Spawns a custom entity visible to specific viewers.- Parameters:
namespacedId- the custom entity namespaced id.location- the spawn location.viewers- the players that should see the entity.frustumCulling- true to enable client-side frustum culling.function- optional callback executed with the base entity.- Returns:
- the spawned custom entity wrapper, or null if it cannot be spawned.
-
spawn
@Nullable public static @Nullable CustomEntity spawn(String namespacedId, Location location, boolean frustumCulling, boolean noBase, boolean noHitbox) Spawns a custom entity with advanced base entity options.- Parameters:
namespacedId- the custom entity namespaced id.location- the spawn location.frustumCulling- true to enable client-side frustum culling.noBase- true to avoid spawning the base entity.noHitbox- true to spawn without hitbox.- Returns:
- the spawned custom entity wrapper, or null if it cannot be spawned.
-
spawn
@Nullable public static @Nullable CustomEntity spawn(String namespacedId, Location location, List<Player> viewers, boolean frustumCulling, boolean noBase, boolean noHitbox, @Nullable @Nullable Consumer<LivingEntity> function) Spawns a custom entity visible to specific viewers with advanced base entity options.- Parameters:
namespacedId- the custom entity namespaced id.location- the spawn location.viewers- the players that should see the entity.frustumCulling- true to enable client-side frustum culling.noBase- true to avoid spawning the base entity.noHitbox- true to spawn without hitbox.function- optional callback executed with the base entity.- Returns:
- the spawned custom entity wrapper, or null if it cannot be spawned.
-
convert
@Nullable public static @Nullable CustomEntity convert(String namespacedId, LivingEntity bukkitEntity) Converts an existing living entity into a custom entity.- Parameters:
namespacedId- the custom entity namespaced id.bukkitEntity- the existing Bukkit entity.- Returns:
- the converted custom entity wrapper, or null if it cannot be converted.
-
convert
@Nullable public static @Nullable CustomEntity convert(String namespacedId, LivingEntity bukkitEntity, boolean frustumCulling) Converts an existing living entity into a custom entity.- Parameters:
namespacedId- the custom entity namespaced id.bukkitEntity- the existing Bukkit entity.frustumCulling- true to enable client-side frustum culling.- Returns:
- the converted custom entity wrapper, or null if it cannot be converted.
-
convert
@Nullable public static @Nullable CustomEntity convert(String namespacedId, LivingEntity bukkitEntity, boolean frustumCulling, boolean noHitbox, boolean canBaseEntityBeDestroyed, boolean hideBaseEntity) Converts an existing living entity into a custom entity with advanced options.- Parameters:
namespacedId- the custom entity namespaced id.bukkitEntity- the existing Bukkit entity.frustumCulling- true to enable client-side frustum culling.noHitbox- true to remove the custom entity hitbox.canBaseEntityBeDestroyed- true if the base entity can be destroyed with the custom entity.hideBaseEntity- true to hide the original Bukkit entity.- Returns:
- the converted custom entity wrapper, or null if it cannot be converted.
-
convert
@Nullable public static @Nullable CustomEntity convert(String namespacedId, LivingEntity bukkitEntity, List<Player> viewers, boolean frustumCulling) Converts an existing living entity into a custom entity visible to specific viewers.- Parameters:
namespacedId- the custom entity namespaced id.bukkitEntity- the existing Bukkit entity.viewers- the players that should see the entity.frustumCulling- true to enable client-side frustum culling.- Returns:
- the converted custom entity wrapper, or null if it cannot be converted.
-
byAlreadySpawned
Gets a custom entity wrapper from an already spawned entity.- Parameters:
entity- the Bukkit entity to check.- Returns:
- the custom entity wrapper, or null if the entity is not custom.
-
isCustomEntity
Checks if a Bukkit entity is registered as a custom entity.- Parameters:
entity- the Bukkit entity to check.- Returns:
- true if the entity is a custom entity.
-
isCustomEntity
Checks if an entity UUID is registered as a custom entity.- Parameters:
uuid- the entity UUID to check.- Returns:
- true if the UUID belongs to a custom entity.
-
getEntity
Gets the base Bukkit entity used by this custom entity.- Returns:
- the base Bukkit entity.
-
getType
Gets the Bukkit entity type of the base entity.- Returns:
- the entity type.
-
getLocation
Gets the current custom entity location.- Returns:
- the current location.
-
teleport
Teleports this custom entity.- Parameters:
location- the destination location.
-
getNamespacedID
-
getNamespace
-
getId
-
respawn
Forces this custom entity bones to respawn for a player.- Parameters:
player- the player.
-
addViewer
Adds a viewer to this custom entity.- Parameters:
player- the player to add as viewer.
-
removeViewer
Removes a viewer from this custom entity.- Parameters:
player- the player to remove.
-
setFrustumCulling
public void setFrustumCulling(boolean cull) Sets whether this custom entity uses frustum culling.- Parameters:
cull- true to enable frustum culling.
-
getFrustumCulling
public boolean getFrustumCulling()Gets whether this custom entity uses frustum culling.- Returns:
- true if frustum culling is enabled.
-
playAnimation
-
playAnimation
Plays an animation on this custom entity.- Parameters:
name- the animation name.- Returns:
- true if the animation exists and was started.
-
stopAnimation
public void stopAnimation()Stops the current animation. -
isPlayingAnimation
Checks if an animation is currently playing.- Parameters:
name- the animation name.- Returns:
- true if the animation is playing.
-
hasAnimation
-
hasAnimation
Checks if this custom entity has an animation.- Parameters:
name- the animation name.- Returns:
- true if the animation exists.
-
getAnimationsNames
-
getAnimationsNames
-
destroy
public void destroy()Destroys this custom entity. -
playDamageEffect
public void playDamageEffect(boolean fire) Plays the damage effect on this custom entity.- Parameters:
fire- true to include the fire damage effect.
-
setColorAllBones
public void setColorAllBones(int color) Sets the color of all rendered bones.- Parameters:
color- the RGB color.
-
setEnchantedAllBones
public void setEnchantedAllBones(boolean enchanted) Sets the enchanted glint state of all rendered bones.- Parameters:
enchanted- true to show the enchanted glint.
-
hasMountBones
public boolean hasMountBones()Checks if this custom entity has mount bones.- Returns:
- true if at least one mount bone exists.
-
addPassenger
Will add new passenger to the next unoccupied mount bone- Parameters:
passenger- the Entity to add as a passenger- Returns:
trueif the passenger was successfully added, otherwisefalse(e.g. if there is no free space)
-
removePassenger
Removes a passenger from any custom entity mount.- Parameters:
passenger- the passenger to remove.
-
getPassengers
Gets all passengers currently mounted on this custom entity.- Returns:
- the mounted passengers.
-
hasPassenger
- Parameters:
passenger- passengerEntityto check- Returns:
trueif this passenger rides the customEntity, otherwisefalse
-
hasPassenger
public boolean hasPassenger()- Returns:
trueif there is at least one passenger, otherwisefalse
-
getBones
- Returns:
- all bones of the current
CustomEntity
-
getMountBones
- Returns:
- all mount bones of the current
CustomEntity
-
getBone
- Parameters:
name- bone name- Returns:
CustomEntity.Boneat the specified name. Returns null if not found.
-
getMountBoneByPassenger
Gets theCustomEntity.MountBonecurrently ridden by the specified passenger if so- Parameters:
passenger- passenger to check- Returns:
- Optional of the
CustomEntity.MountBone. Not empty if there is such passenger
-
getLoot
-
getLoot
-
getLoot
public static List<ItemStack> getLoot(LivingEntity bukkitEntity, @Nullable @Nullable ItemStack tool) Gets the loot generated by a custom entity.- Parameters:
bukkitEntity- the base Bukkit entity.tool- the tool used to kill the entity, or null.- Returns:
- the generated loot, or an empty list if the entity is not custom.
-