Class SavedEntity
java.lang.Object
com.github.darksoulq.abyssallib.common.serialization.SavedEntity
Represents a serialized snapshot of an entity, including its type and associated data.
This abstraction supports both vanilla EntityType instances and
CustomEntity definitions, allowing entities to be captured, stored,
and later reconstructed in different contexts.
All data is stored in a format-agnostic representation using DynamicOps.
-
Constructor Summary
ConstructorsModifierConstructorDescription<D>SavedEntity(Either<org.bukkit.entity.EntityType, CustomEntity<? extends org.bukkit.entity.LivingEntity>> type, D rawData, DynamicOps<D> ops) Constructs a new saved entity instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidapplyData(org.bukkit.entity.Entity entity) Applies serialized data onto a target entity.static <D> SavedEntitycreate(org.bukkit.entity.Entity entity, DynamicOps<D> ops) Creates aSavedEntityfrom a live BukkitEntity.Retrieves the raw serialized data.Either<org.bukkit.entity.EntityType, CustomEntity<? extends org.bukkit.entity.LivingEntity>> getType()Retrieves the entity type representation.org.bukkit.entity.Entityspawn(WorldGenAccess level, org.bukkit.Location loc) Spawns this entity in aWorldGenAccesscontext.voidspawn(org.bukkit.entity.Entity entity) Applies this saved entity onto an existing entity instance.voidspawn(org.bukkit.entity.Entity entity, CustomEntitySpawnEvent.SpawnReason reason) Applies this saved entity onto an existing entity instance.org.bukkit.entity.Entityspawn(org.bukkit.Location loc) Spawns this entity at a location using plugin spawn reason.org.bukkit.entity.Entityspawn(org.bukkit.Location loc, CustomEntitySpawnEvent.SpawnReason reason) Spawns this entity at a location.voidspawnFromInstance(org.bukkit.entity.Entity nativeEntity) Applies this saved entity onto a pre-existing native instance.
-
Constructor Details
-
SavedEntity
public <D> SavedEntity(Either<org.bukkit.entity.EntityType, CustomEntity<? extends org.bukkit.entity.LivingEntity>> type, D rawData, DynamicOps<D> ops) Constructs a new saved entity instance.- Type Parameters:
D- the encoded data type- Parameters:
type- the entity type representationrawData- the serialized data payloadops- the dynamic operations instance
-
-
Method Details
-
create
Creates aSavedEntityfrom a live BukkitEntity.If the entity is associated with a
CustomEntity, its identifier is stored. Otherwise, the vanilla entity type is recorded.- Type Parameters:
D- the encoded data type- Parameters:
entity- the source entityops- the dynamic operations instance- Returns:
- a new saved entity instance
-
getType
public Either<org.bukkit.entity.EntityType, CustomEntity<? extends org.bukkit.entity.LivingEntity>> getType()Retrieves the entity type representation.- Returns:
- the
Eithercontaining either a vanilla type or custom entity
-
getRawData
-
spawn
public org.bukkit.entity.Entity spawn(org.bukkit.Location loc) Spawns this entity at a location using plugin spawn reason.- Parameters:
loc- the spawn location- Returns:
- the spawned entity
-
spawn
public org.bukkit.entity.Entity spawn(org.bukkit.Location loc, CustomEntitySpawnEvent.SpawnReason reason) Spawns this entity at a location.- Parameters:
loc- the spawn locationreason- the spawn reason- Returns:
- the spawned entity
-
spawn
Spawns this entity in aWorldGenAccesscontext.- Parameters:
level- the world generation accessloc- the spawn location- Returns:
- the spawned entity
-
spawn
public void spawn(org.bukkit.entity.Entity entity) Applies this saved entity onto an existing entity instance.- Parameters:
entity- the target entity
-
spawn
Applies this saved entity onto an existing entity instance.- Parameters:
entity- the target entityreason- the spawn reason
-
spawnFromInstance
public void spawnFromInstance(org.bukkit.entity.Entity nativeEntity) Applies this saved entity onto a pre-existing native instance.- Parameters:
nativeEntity- the entity instance
-
applyData
public void applyData(org.bukkit.entity.Entity entity) Applies serialized data onto a target entity.- Parameters:
entity- the target entity
-