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, SpawnActionNPCTrainer, SpawnActionPokemon, SpawnActionWormhole

public abstract class SpawnAction<T extends net.minecraft.world.entity.Entity> extends Object
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 Details

    • spawnInfo

      public SpawnInfo spawnInfo
      The SpawnInfo this action is based on. This is only used for reference, and shouldn't be changed.
    • spawnLocation

      public SpawnLocation spawnLocation
      The location at which the spawn will occur. This can be changed.
    • entity

      protected T extends net.minecraft.world.entity.Entity 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 through getOrCreateEntity(), but this is down to developer choice.
  • Constructor Details

  • Method Details

    • createEntity

      protected abstract T createEntity()
      Creates the entity and returns the result. Returning null if the spawn should fail is safe in default implementations.
    • getOrCreateEntity

      public T getOrCreateEntity()
      Gets the entity that will spawn, creating it if necessary. This may sometimes be null based on the implementation.
    • setEntity

      public void setEntity(T t)
    • doSpawn

      @Nullable public T doSpawn(AbstractSpawner spawner)
      Does the spawn of this entity at the stored 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.

    • applyLocationMutations

      public void applyLocationMutations()