Package com.ticxo.modelengine.api.model
Interface ActiveModel
public interface ActiveModel
The class that represent the model you see on an entity. It contains
all the information specific to this model instance, and all the bones
used to construct this model.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
destroy()
Despawn the model from the world.
This method would despawn the model from all players that is close enough to see it.void
forceGenerateBone
(String parent, BlueprintBone blueprintBone) Forcefully generate bones in their unintended location.void
Populate this model with bones.
The default implementation ofModeledEntity
calls this method onModeledEntity.addModel(ActiveModel, boolean)
, and the default implementation ofActiveModel
would setisGenerated()
to true.Get the existing instance ofAnimationHandler
specific to this model.
This is used to control everything animation related of this model.Get theAnimationMode
of this model.
If the mode was not set withsetAnimationMode(AnimationMode)
, it would return the default mode set in the plugin config.Get the blueprint used to generate this model.Get a bone of this model with the bone ID.Get all bones in this model.
This method returns a flat view of all bones, which means all bones are searchable within this map.Get the existing instance ofDefaultStateHandler
specific to this model.
This is used to configure the animation properties of eachModelState
for this model.
To play a default animation, useModeledEntity.setState(ModelState)
.Get the handler for all item holder bones.Get the handler for all leash bones.Get the owner of this model.Get the handler for all mountable bones.
This includes driver bone and passenger bones.Get the handler for all nametag bones.Get the handler for all rendering bones.
This includes normal bones, ghost item bones and segment bones.Get the handler for all sub-hitbox bones.
This includes AABB and OBB hitboxes.boolean
Check if this model is playing any animations.
If the model is playing the death animation and holding on last frame, that animation is considered finished and is ignored.void
hideFromPlayer
(org.bukkit.entity.Player player) Hide the model from the player.
This does not unregister the player as a viewer of this model, hence update packets would still be sent, and the model would be visible to them when they exit and enter its render radius.boolean
Can the model play the damage animation.boolean
Check if the model has finished generating all its bones.boolean
Is the pitch locked.boolean
Is the head yaw locked.boolean
Is the model ready to be swapped.void
playDefaultAnimation
(ModelState state) Play the default animation of this model.
To play the default animations of all models, useModeledEntity.setState(ModelState)
.void
removeBone
(String bone) Remove a bone from this model.
The bone is destroyed immediately after removing, so this process is not revertible.
To hide a renderer bone temporarily, useBoneRenderer.setModelVisible(boolean)
.
To transfer a bone to another parent, useModelBone.addChild(ModelBone)
.void
void
Configure theAnimationMode
of this model.
Use this beforeModeledEntity.addModel(ActiveModel, boolean)
or it would have no effect.void
setCanHurt
(boolean flag) Set if the model should play the damage tint.
This is mainly use to disable damage tint for inanimate models like rocks, barrels, etc.void
setGlowing
(boolean flag) Set the glow state of the model.void
setHurt
(boolean flag) Toggle the damage tint on the model.
The model would not disable the tint by itself.void
setLockPitch
(boolean flag) Lock the pitch of this model.
When locked, the pitch defaults to 0 degree.void
setLockYaw
(boolean flag) Lock the head yaw of this model.
When locked, the head yaw defaults to 0 degree relative to the body's yaw rotation.void
setModeledEntity
(ModeledEntity modeledEntity) Set the owner of this model.
The default implementation ofModeledEntity
calls this method onModeledEntity.addModel(ActiveModel, boolean)
void
setSwappable
(boolean flag) Mark this model ready to be swapped to another entity.
Only call this after usingModeledEntity.removeModel(String)
.void
showToPlayer
(org.bukkit.entity.Player player) Show the model to the player.
This does not register the player as a viewer of this model, hence no update packets would be sent to them.void
spawn()
Spawn the model into the world.
This method would spawn the model to all players that is close enough to see it.void
tick()
Update method that is called every tick.
This method is called on an async thread.
-
Method Details
-
isGenerated
boolean isGenerated()Check if the model has finished generating all its bones. -
safeRun
-
tick
void tick()Update method that is called every tick.
This method is called on an async thread. Beware when accessing the Bukkit API. -
spawn
void spawn()Spawn the model into the world.
This method would spawn the model to all players that is close enough to see it. SeeRangeManager.getRenderDistance()
. -
destroy
void destroy()Despawn the model from the world.
This method would despawn the model from all players that is close enough to see it. SeeRangeManager.getRenderDistance()
. -
setModeledEntity
Set the owner of this model.
The default implementation ofModeledEntity
calls this method onModeledEntity.addModel(ActiveModel, boolean)
- Parameters:
modeledEntity
- model owner
-
getModeledEntity
ModeledEntity getModeledEntity()Get the owner of this model. -
getBlueprint
ModelBlueprint getBlueprint()Get the blueprint used to generate this model. -
getAnimationHandler
AnimationHandler getAnimationHandler()Get the existing instance ofAnimationHandler
specific to this model.
This is used to control everything animation related of this model. -
getDefaultStateHandler
DefaultStateHandler getDefaultStateHandler()Get the existing instance ofDefaultStateHandler
specific to this model.
This is used to configure the animation properties of eachModelState
for this model.
To play a default animation, useModeledEntity.setState(ModelState)
. -
getRendererHandler
RendererHandler getRendererHandler()Get the handler for all rendering bones.
This includes normal bones, ghost item bones and segment bones. -
getMountHandler
MountHandler getMountHandler()Get the handler for all mountable bones.
This includes driver bone and passenger bones. -
getNametagHandler
NametagHandler getNametagHandler()Get the handler for all nametag bones. -
getLeashHandler
LeashHandler getLeashHandler()Get the handler for all leash bones. -
getSubHitboxHandler
SubHitboxHandler getSubHitboxHandler()Get the handler for all sub-hitbox bones.
This includes AABB and OBB hitboxes. -
getItemHolderHandler
ItemHolderHandler getItemHolderHandler()Get the handler for all item holder bones. -
getBoneIndex
Get all bones in this model.
This method returns a flat view of all bones, which means all bones are searchable within this map. -
getBone
Get a bone of this model with the bone ID.- Parameters:
boneId
- the ID without the tags (h_, ir_, tag_ etc)- Returns:
- the bone, or null if none is found.
-
setAnimationMode
Configure theAnimationMode
of this model.
Use this beforeModeledEntity.addModel(ActiveModel, boolean)
or it would have no effect. -
getAnimationMode
AnimationMode getAnimationMode()Get theAnimationMode
of this model.
If the mode was not set withsetAnimationMode(AnimationMode)
, it would return the default mode set in the plugin config. -
showToPlayer
void showToPlayer(org.bukkit.entity.Player player) Show the model to the player.
This does not register the player as a viewer of this model, hence no update packets would be sent to them. UseRangeManager.forceSpawn(Player)
orRangeManager.updatePlayer(Player)
to show the model properly.- Parameters:
player
- the viewer
-
hideFromPlayer
void hideFromPlayer(org.bukkit.entity.Player player) Hide the model from the player.
This does not unregister the player as a viewer of this model, hence update packets would still be sent, and the model would be visible to them when they exit and enter its render radius. UseRangeManager.removePlayer(Player)
to hide the model properly.- Parameters:
player
- the viewer
-
setGlowing
void setGlowing(boolean flag) Set the glow state of the model. -
setCanHurt
void setCanHurt(boolean flag) Set if the model should play the damage tint.
This is mainly use to disable damage tint for inanimate models like rocks, barrels, etc. -
isCanHurt
boolean isCanHurt()Can the model play the damage animation. -
setHurt
void setHurt(boolean flag) Toggle the damage tint on the model.
The model would not disable the tint by itself. UseModeledEntity.hurt()
for auto disable. -
setLockPitch
void setLockPitch(boolean flag) Lock the pitch of this model.
When locked, the pitch defaults to 0 degree. -
isLockPitch
boolean isLockPitch()Is the pitch locked. -
setLockYaw
void setLockYaw(boolean flag) Lock the head yaw of this model.
When locked, the head yaw defaults to 0 degree relative to the body's yaw rotation. -
isLockYaw
boolean isLockYaw()Is the head yaw locked. -
generateModel
void generateModel()Populate this model with bones.
The default implementation ofModeledEntity
calls this method onModeledEntity.addModel(ActiveModel, boolean)
, and the default implementation ofActiveModel
would setisGenerated()
to true. -
forceGenerateBone
Forcefully generate bones in their unintended location. The specified bone would also generate all its child bones, and would be animated relative to the specified parent.- Parameters:
parent
- bone ID of the parent boneblueprintBone
- the blueprint of the generated bone
-
removeBone
Remove a bone from this model.
The bone is destroyed immediately after removing, so this process is not revertible.
To hide a renderer bone temporarily, useBoneRenderer.setModelVisible(boolean)
.
To transfer a bone to another parent, useModelBone.addChild(ModelBone)
.- Parameters:
bone
- bone ID
-
playDefaultAnimation
Play the default animation of this model.
To play the default animations of all models, useModeledEntity.setState(ModelState)
.- Parameters:
state
- the default state.
-
hasAnimations
boolean hasAnimations()Check if this model is playing any animations.
If the model is playing the death animation and holding on last frame, that animation is considered finished and is ignored. -
setSwappable
void setSwappable(boolean flag) Mark this model ready to be swapped to another entity.
Only call this after usingModeledEntity.removeModel(String)
. -
isSwappable
boolean isSwappable()Is the model ready to be swapped.
-