Class CustomEntity<T extends org.bukkit.entity.LivingEntity>
java.lang.Object
com.github.darksoulq.abyssallib.world.entity.CustomEntity<T>
- Type Parameters:
T- the concreteLivingEntitytype 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, andCTag - Custom spawning pipelines and lifecycle hooks
- Integration with internal registries and event systems
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumDefines spawn placement type.static classDefines spawn configuration. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCustomEntity(net.kyori.adventure.key.Key id, org.bukkit.entity.EntityType baseType, SpawnCategory category) Creates a new custom entity definition. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAttributeModifier(org.bukkit.attribute.Attribute attribute, org.bukkit.attribute.AttributeModifier modifier) Adds an attribute modifier.voidRegisters a pathfinding goal.voidaddTargetGoal(int priority, Function<T, net.minecraft.world.entity.ai.goal.Goal> goal) Registers a targeting goal.voidApplies attributes and modifiers.voidInitializes the component map.voidApplies all registered goals.clone()Creates a deep clone of this entity definition.Resolves the live entity.org.bukkit.entity.EntityTypegetCTag()Gets underlying NBT custom data.getData()Gets wrapped persistent data container.<C extends DataComponent<?>>
CgetData(DataComponentType<C> type) Gets a data component.net.kyori.adventure.key.KeygetId()@Nullable CustomEntity.SpawnSettingsGets spawn configuration.booleanhasData(DataComponentType<?> type) Checks if a component exists.onDeath(org.bukkit.event.entity.EntityDeathEvent event) Called on entity death.voidonLoad()Called when entity loads.voidonSpawn()Called after spawn.voidonUnload()Called when entity unloads.static CustomEntity<? extends org.bukkit.entity.LivingEntity> resolve(org.bukkit.entity.Entity entity) Resolves a custom entity wrapper.voidsetAttribute(org.bukkit.attribute.Attribute attribute, double value) Sets a base attribute value.voidSets underlying NBT custom data.voidsetData(DataComponent<?> component) Sets a data component.voidsetSpawnSettings(CustomEntity.SpawnSettings settings) Sets spawn configuration.voidspawn(org.bukkit.Location loc) Spawns this entity at a location using plugin reason.voidspawn(org.bukkit.Location loc, CustomEntitySpawnEvent.SpawnReason reason) Spawns this entity at a location.voidAttaches this wrapper to an existing entity.voidspawn(T entity, CustomEntitySpawnEvent.SpawnReason reason) Attaches this wrapper to an existing entity.voidspawnFromInstance(org.bukkit.entity.Entity nativeEntity) Initializes this wrapper from a raw entity instance.voidunsetData(DataComponentType<?> type) Removes a component.
-
Field Details
-
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 identifierbaseType- the baseEntityTypecategory- the spawn category
-
-
Method Details
-
addGoal
-
addTargetGoal
-
setAttribute
public void setAttribute(org.bukkit.attribute.Attribute attribute, double value) Sets a base attribute value.- Parameters:
attribute- the attributevalue- the value
-
addAttributeModifier
public void addAttributeModifier(org.bukkit.attribute.Attribute attribute, org.bukkit.attribute.AttributeModifier modifier) Adds an attribute modifier.- Parameters:
attribute- the attributemodifier- the modifier
-
setSpawnSettings
Sets spawn configuration.- Parameters:
settings- the spawn settings
-
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
Spawns this entity at a location.- Parameters:
loc- the spawn locationreason- the spawn reason
-
spawn
Attaches this wrapper to an existing entity.- Parameters:
entity- the entity
-
spawn
Attaches this wrapper to an existing entity.- Parameters:
entity- the entityreason- 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
Sets a data component.- Parameters:
component- the component
-
getData
Gets a data component.- Type Parameters:
C- component type- Parameters:
type- the component type- Returns:
- the component
-
hasData
Checks if a component exists.- Parameters:
type- the component type- Returns:
- true if present
-
unsetData
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
- Returns:
- the component map
-
getAttributes
-
getModifiers
-
getTargetGoals
-
getPathfinderGoals
-
getData
-
getCTag
-
setCTag
Sets underlying NBT custom data.- Parameters:
container- the tag
-
getBaseEntity
-
getCategory
- Returns:
- spawn category
-
onSpawn
public void onSpawn()Called after spawn. -
onDeath
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
Creates a deep clone of this entity definition.- Returns:
- cloned entity
-