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 Details

    • isGenerated

      boolean isGenerated()
      Check if the model has finished generating all its bones.
    • safeRun

      void safeRun(Runnable runnable)
    • 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. See RangeManager.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. See RangeManager.getRenderDistance().
    • setModeledEntity

      void setModeledEntity(ModeledEntity modeledEntity)
      Set the owner of this model.
      The default implementation of ModeledEntity calls this method on ModeledEntity.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 of AnimationHandler specific to this model.
      This is used to control everything animation related of this model.
    • getDefaultStateHandler

      DefaultStateHandler getDefaultStateHandler()
      Get the existing instance of DefaultStateHandler specific to this model.
      This is used to configure the animation properties of each ModelState for this model.
      To play a default animation, use ModeledEntity.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

      Map<String,ModelBone> 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

      ModelBone getBone(String boneId)
      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

      void setAnimationMode(AnimationMode mode)
      Configure the AnimationMode of this model.
      Use this before ModeledEntity.addModel(ActiveModel, boolean) or it would have no effect.
    • getAnimationMode

      AnimationMode getAnimationMode()
      Get the AnimationMode of this model.
      If the mode was not set with setAnimationMode(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. Use RangeManager.forceSpawn(Player) or RangeManager.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. Use RangeManager.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. Use ModeledEntity.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 of ModeledEntity calls this method on ModeledEntity.addModel(ActiveModel, boolean), and the default implementation of ActiveModel would set isGenerated() to true.
    • forceGenerateBone

      void forceGenerateBone(String parent, BlueprintBone blueprintBone)
      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 bone
      blueprintBone - the blueprint of the generated bone
    • removeBone

      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, use BoneRenderer.setModelVisible(boolean).
      To transfer a bone to another parent, use ModelBone.addChild(ModelBone).
      Parameters:
      bone - bone ID
    • playDefaultAnimation

      void playDefaultAnimation(ModelState state)
      Play the default animation of this model.
      To play the default animations of all models, use ModeledEntity.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 using ModeledEntity.removeModel(String).
    • isSwappable

      boolean isSwappable()
      Is the model ready to be swapped.