Class CustomEntity<T extends org.bukkit.entity.LivingEntity>

java.lang.Object
com.github.darksoulq.abyssallib.world.entity.CustomEntity<T>
Type Parameters:
T - the concrete LivingEntity type backing this custom entity
All Implemented Interfaces:
Cloneable

public class CustomEntity<T extends org.bukkit.entity.LivingEntity> extends Object implements Cloneable
Represents a fully configurable wrapper around a Bukkit LivingEntity, providing extended behavior, attributes, data components, and lifecycle control.

This abstraction enables:

  • Custom AI goals via Goal
  • Attribute and modifier control
  • Persistent data via ComponentMap, PDCTag, and CTag
  • Custom spawning pipelines and lifecycle hooks
  • Integration with internal registries and event systems
  • Field Details

    • uuid

      public UUID uuid
      Unique identifier linking this wrapper to a live entity instance.
  • Constructor Details

    • CustomEntity

      public CustomEntity(net.kyori.adventure.key.Key id, org.bukkit.entity.EntityType baseType, SpawnCategory category)
      Creates a new custom entity definition.
      Parameters:
      id - the unique registry identifier
      baseType - the base EntityType
      category - the spawn category
  • Method Details

    • addGoal

      public void addGoal(int priority, Function<T, net.minecraft.world.entity.ai.goal.Goal> goal)
      Registers a pathfinding goal.
      Parameters:
      priority - execution priority (lower = higher priority)
      goal - goal factory
    • addTargetGoal

      public void addTargetGoal(int priority, Function<T, net.minecraft.world.entity.ai.goal.Goal> goal)
      Registers a targeting goal.
      Parameters:
      priority - execution priority
      goal - goal factory
    • setAttribute

      public void setAttribute(org.bukkit.attribute.Attribute attribute, double value)
      Sets a base attribute value.
      Parameters:
      attribute - the attribute
      value - the value
    • addAttributeModifier

      public void addAttributeModifier(org.bukkit.attribute.Attribute attribute, org.bukkit.attribute.AttributeModifier modifier)
      Adds an attribute modifier.
      Parameters:
      attribute - the attribute
      modifier - the modifier
    • setSpawnSettings

      public void setSpawnSettings(CustomEntity.SpawnSettings settings)
      Sets spawn configuration.
      Parameters:
      settings - the spawn settings
    • getSpawnSettings

      @Nullable public @Nullable CustomEntity.SpawnSettings getSpawnSettings()
      Gets spawn configuration.
      Returns:
      the spawn settings or null
    • spawn

      public void spawn(org.bukkit.Location loc)
      Spawns this entity at a location using plugin reason.
      Parameters:
      loc - the spawn location
    • spawn

      public void spawn(org.bukkit.Location loc, CustomEntitySpawnEvent.SpawnReason reason)
      Spawns this entity at a location.
      Parameters:
      loc - the spawn location
      reason - the spawn reason
    • spawn

      public void spawn(T entity)
      Attaches this wrapper to an existing entity.
      Parameters:
      entity - the entity
    • spawn

      public void spawn(T entity, CustomEntitySpawnEvent.SpawnReason reason)
      Attaches this wrapper to an existing entity.
      Parameters:
      entity - the entity
      reason - the spawn reason
    • spawnFromInstance

      public void spawnFromInstance(org.bukkit.entity.Entity nativeEntity)
      Initializes this wrapper from a raw entity instance.
      Parameters:
      nativeEntity - the entity
    • setData

      public void setData(DataComponent<?> component)
      Sets a data component.
      Parameters:
      component - the component
    • getData

      public <C extends DataComponent<?>> C getData(DataComponentType<C> type)
      Gets a data component.
      Type Parameters:
      C - component type
      Parameters:
      type - the component type
      Returns:
      the component
    • hasData

      public boolean hasData(DataComponentType<?> type)
      Checks if a component exists.
      Parameters:
      type - the component type
      Returns:
      true if present
    • unsetData

      public void unsetData(DataComponentType<?> type)
      Removes a component.
      Parameters:
      type - the component type
    • applyGoals

      public void applyGoals()
      Applies all registered goals.
    • applyAttributes

      public void applyAttributes()
      Applies attributes and modifiers.
    • applyComponents

      public void applyComponents()
      Initializes the component map.
    • getId

      public net.kyori.adventure.key.Key getId()
      Returns:
      the entity identifier
    • getBaseType

      public org.bukkit.entity.EntityType getBaseType()
      Returns:
      the base entity type
    • getComponentMap

      public ComponentMap getComponentMap()
      Returns:
      the component map
    • getAttributes

      public Map<org.bukkit.attribute.Attribute, Double> getAttributes()
      Returns:
      attribute map
    • getModifiers

      public Map<org.bukkit.attribute.Attribute, List<org.bukkit.attribute.AttributeModifier>> getModifiers()
      Returns:
      modifiers map
    • getTargetGoals

      public Map<Integer, Function<T, net.minecraft.world.entity.ai.goal.Goal>> getTargetGoals()
      Returns:
      target goals
    • getPathfinderGoals

      public Map<Integer, Function<T, net.minecraft.world.entity.ai.goal.Goal>> getPathfinderGoals()
      Returns:
      pathfinder goals
    • getData

      public Optional<PDCTag> getData()
      Gets wrapped persistent data container.
      Returns:
      optional PDC wrapper
    • getCTag

      public CTag getCTag()
      Gets underlying NBT custom data.
      Returns:
      custom tag or null
    • setCTag

      public void setCTag(CTag container)
      Sets underlying NBT custom data.
      Parameters:
      container - the tag
    • getBaseEntity

      public Optional<T> getBaseEntity()
      Resolves the live entity.
      Returns:
      optional base entity
    • getCategory

      public SpawnCategory getCategory()
      Returns:
      spawn category
    • onSpawn

      public void onSpawn()
      Called after spawn.
    • onDeath

      public ActionResult onDeath(org.bukkit.event.entity.EntityDeathEvent event)
      Called on entity death.
      Parameters:
      event - the death event
      Returns:
      action result
    • onUnload

      public void onUnload()
      Called when entity unloads.
    • onLoad

      public void onLoad()
      Called when entity loads.
    • resolve

      public static CustomEntity<? extends org.bukkit.entity.LivingEntity> resolve(org.bukkit.entity.Entity entity)
      Resolves a custom entity wrapper.
      Parameters:
      entity - the entity
      Returns:
      custom entity or null
    • clone

      public CustomEntity<T> clone()
      Creates a deep clone of this entity definition.
      Returns:
      cloned entity