Class SpawnAction<T extends net.minecraft.world.entity.Entity>
java.lang.Object
com.pixelmonmod.pixelmon.api.spawning.SpawnAction<T>
- Type Parameters:
T
- The kind of entity that this spawns. This is for the convenience of the developer only.
- Direct Known Subclasses:
SpawnActionItem
,SpawnActionNPC
,SpawnActionPokemon
,SpawnActionWormhole
A queued spawning action. This conceptually is the state in between a
SpawnInfo
and a spawned entity.
SpawnInfos construct these after it's confirmed that a spawn will be attempted. It is still possible for a spawn
to fail after a SpawnAction has been queued, if doSpawn(AbstractSpawner)
returns null.
Note: Spawn actions are usually constructed asynchronously.
Different implementations of SpawnAction usually contain extra information about the entity to spawn.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
protected abstract T
Creates the entity and returns the result.doSpawn
(AbstractSpawner spawner) Does the spawn of this entity at the storedSpawnLocation
on behalf of the givenAbstractSpawner
.Gets the entity that will spawn, creating it if necessary.void
-
Field Details
-
spawnInfo
TheSpawnInfo
this action is based on. This is only used for reference, and shouldn't be changed. -
spawnLocation
The location at which the spawn will occur. This can be changed. -
entity
The entity it will spawn. This is instantiated at some point depending on the implementation but due to limitations put in place by Sponge API, this may only be instantiated on the main thread. It's advisable to access this throughgetOrCreateEntity()
, but this is down to developer choice.
-
-
Constructor Details
-
SpawnAction
-
-
Method Details
-
createEntity
Creates the entity and returns the result. Returning null if the spawn should fail is safe in default implementations. -
getOrCreateEntity
Gets the entity that will spawn, creating it if necessary. This may sometimes be null based on the implementation. -
setEntity
-
doSpawn
Does the spawn of this entity at the storedSpawnLocation
on behalf of the givenAbstractSpawner
. This can return null if the spawn should fail at any point, and the Better Spawner will interpret this as a cancelled spawn without consequences.Overrides of this method are strongly advised to call the super due to important functions that occur here.
-
applyLocationMutations
public void applyLocationMutations()
-