Class AbstractSpawner

java.lang.Object
com.pixelmonmod.pixelmon.api.spawning.AbstractSpawner
Direct Known Subclasses:
TickingSpawner, TriggerSpawner

public abstract class AbstractSpawner extends Object
The base of all spawning. The primary implementations are TriggerSpawner and TickingSpawner. Instantiated implementations of this base should be added to the coordinator in PixelmonSpawning.
  • Field Details

    • name

      public final String name
      The unique name of the spawner.
    • spawnedTracker

      public final SpawnedTracker spawnedTracker
      The maintained list of spawned entities.
    • selectionAlgorithm

      public SelectionAlgorithm selectionAlgorithm
      The SelectionAlgorithm used to choose a spawn from a list with a location.
    • checkSpawns

      public CheckSpawns checkSpawns
      The CheckSpawns used when /checkspawns name is used. By default it simply states not implemented.
    • tweaks

      public List<SpawningTweak> tweaks
      A list of SpawningTweaks to apply to the entities spawned.
    • conditions

      public List<SpawnerCondition> conditions
      A list of SpawnerConditions to apply to potential spawns to filter early.
    • rarityTweaks

      public List<RarityTweak> rarityTweaks
      A list of rarity tweaks to apply to spawns.
    • rarityMultipliers

      public List<RarityMultiplier> rarityMultipliers
      A list of rarity multipliers to apply to all the spawns this processes.
    • isBusy

      public volatile boolean isBusy
      Whether or not the spawner is currently busy doing processing.
    • lastSpawnTime

      public long lastSpawnTime
      The last time an entity spawned because of this spawner.
    • spawnSets

      public List<SpawnSet> spawnSets
      The SpawnSets contained in this spawner.
    • cacheSets

      public transient Map<String,List<SpawnInfo>> cacheSets
  • Constructor Details

    • AbstractSpawner

      public AbstractSpawner(String name)
  • Method Details

    • shouldDoSpawning

      public boolean shouldDoSpawning()
      Whether or not this spawner should do spawning when it is triggered
    • getSuitableSpawns

      public ArrayList<SpawnInfo> getSuitableSpawns(SpawnLocation spawnLocation)
      Gets all the spawns from the contained sets that suit the given SpawnLocation.
    • fits

      public boolean fits(SpawnInfo spawnInfo, SpawnLocation spawnLocation)
      Whether or not this spawner finds it acceptable for this SpawnInfo to spawn at this SpawnLocation. Occurs after SpawnCondition#fits
    • getWeightedSpawnInfo

      @Nullable public SpawnInfo getWeightedSpawnInfo(SpawnLocation spawnLocation)
      Gets the SpawnInfo to spawn at the given SpawnLocation based off what is suitable and chosen by selectionAlgorithm.
    • calculateSpatialData

      public static SpatialData calculateSpatialData(net.minecraft.world.level.Level world, net.minecraft.core.BlockPos centre, int max, boolean includeDownwards, Predicate<net.minecraft.world.level.block.state.BlockState> condition)
      Calculates a SpatialData for the given parameters.
      Parameters:
      world - - The world this is in.
      centre - - The blockpos for the centre of the area. This is the base block for spawning.
      max - - The largest diameter to search. If it encounters obstacles, this will be cut short, being the returned diameter.
      includeDownwards - - Whether or not the radial checks should move toward -ve y as well or just focus upwards.
      condition - - The condition on the surrounding blocks that must be met for it to count towards the available space.
      Returns:
      - A new SpatialData with all its information.
    • getTrackedBlockCollection

      public CompletableFuture<BlockCollection> getTrackedBlockCollection(net.minecraft.world.entity.Entity entity, float horizontalTrackFactor, float verticalTrackFactor, int horizontalSliceRadius, int verticalSliceRadius, int minDistFromCentre, int maxDistFromCentre)
      Tracks the given entity's motion using the given parameters, and returns an appropriately sized BlockCollection
      Parameters:
      entity - - The entity to track.
      horizontalTrackFactor - - The coefficient for tracking horizontal entity motion.
      verticalTrackFactor - - The coefficient for tracking vertical entity motion.
      horizontalSliceRadius - - The horizontal diameter of the BlockCollection.
      verticalSliceRadius - - The vertical diameter of the BlockCollection.
      minDistFromCentre - - The minimum distance from the tracked position that the BlockCollection may be centred on.
      maxDistFromCentre - - The maximum distance from the tracked position that the BlockCollection may be centred on.
      Returns:
      - A BlockCollection that tracked the entity's motion to give a random but predictive collection.
    • hasTweak

      public boolean hasTweak(Class<? extends SpawningTweak> clazz)
      Returns true if this spawner has a particular SpawningTweak present.
    • getTweak

      @Nullable public <T extends SpawningTweak> T getTweak(Class<T> clazz)
      Gets the SpawningTweak of the given type, if it exists. This could be null.
    • hasCondition

      public boolean hasCondition(Class<? extends SpawnerCondition> clazz)
      Returns true if this spawner has a particular SpawnerCondition present.
    • getCondition

      @Nullable public <T extends SpawnerCondition> T getCondition(Class<T> clazz)
      Gets the SpawnerCondition of the given type, if it exists. This could be null.
    • getSuitableSpawnsForBiome

      public ArrayList<SpawnInfo> getSuitableSpawnsForBiome(net.minecraft.core.Holder<net.minecraft.world.level.biome.Biome> biomeHolder)
      Gets all the spawns from the contained sets that suit the given Biome.