T
- The kind of entity that this spawns. This is for the convenience of the developer only.public abstract class SpawnAction<T extends net.minecraft.entity.Entity>
extends java.lang.Object
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.
Modifier and Type | Field and Description |
---|---|
protected T |
entity
The entity it will spawn.
|
SpawnInfo |
spawnInfo
The
SpawnInfo this action is based on. |
SpawnLocation |
spawnLocation
The location at which the spawn will occur.
|
Constructor and Description |
---|
SpawnAction(SpawnInfo spawnInfo,
SpawnLocation spawnLocation) |
Modifier and Type | Method and Description |
---|---|
void |
applyLocationMutations() |
protected abstract T |
createEntity()
Creates the entity and returns the result.
|
T |
doSpawn(AbstractSpawner spawner)
Does the spawn of this entity at the stored
SpawnLocation on behalf of the given AbstractSpawner . |
T |
getOrCreateEntity()
Gets the entity that will spawn, creating it if necessary.
|
void |
setEntity(T t) |
public SpawnInfo spawnInfo
SpawnInfo
this action is based on. This is only used for reference, and shouldn't be changed.public SpawnLocation spawnLocation
protected T extends net.minecraft.entity.Entity entity
getOrCreateEntity()
, but this is down to developer choice.public SpawnAction(SpawnInfo spawnInfo, SpawnLocation spawnLocation)
protected abstract T createEntity()
public T getOrCreateEntity()
public void setEntity(T t)
@Nullable public T doSpawn(AbstractSpawner spawner)
SpawnLocation
on behalf of the given AbstractSpawner
.
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.
public void applyLocationMutations()