Class AbstractSpawner
java.lang.Object
com.pixelmonmod.pixelmon.api.spawning.AbstractSpawner
- Direct Known Subclasses:
TickingSpawner
,TriggerSpawner
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
.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
-
Field Summary
Modifier and TypeFieldDescriptionTheCheckSpawns
used when /checkspawnsname
is used.A list ofSpawnerCondition
s to apply to potential spawns to filter early.boolean
Whether or not the spawner is currently busy doing processing.long
The last time an entity spawned because of this spawner.final String
The unique name of the spawner.A list of rarity multipliers to apply to all the spawns this processes.A list of rarity tweaks to apply to spawns.TheSelectionAlgorithm
used to choose a spawn from a list with a location.final SpawnedTracker
The maintained list of spawned entities.TheSpawnSet
s contained in this spawner.A list ofSpawningTweak
s to apply to the entities spawned. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic 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 aSpatialData
for the given parameters.boolean
fits
(SpawnInfo spawnInfo, SpawnLocation spawnLocation) Whether or not this spawner finds it acceptable for thisSpawnInfo
to spawn at thisSpawnLocation
.<T extends SpawnerCondition>
TgetCondition
(Class<T> clazz) Gets theSpawnerCondition
of the given type, if it exists.getSuitableSpawns
(SpawnLocation spawnLocation) Gets all the spawns from the contained sets that suit the givenSpawnLocation
.getSuitableSpawnsForBiome
(net.minecraft.core.Holder<net.minecraft.world.level.biome.Biome> biomeHolder) Gets all the spawns from the contained sets that suit the givenBiome
.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 sizedBlockCollection
<T extends SpawningTweak>
TGets theSpawningTweak
of the given type, if it exists.getWeightedSpawnInfo
(SpawnLocation spawnLocation) Gets theSpawnInfo
to spawn at the givenSpawnLocation
based off what is suitable and chosen byselectionAlgorithm
.boolean
hasCondition
(Class<? extends SpawnerCondition> clazz) Returns true if this spawner has a particularSpawnerCondition
present.boolean
hasTweak
(Class<? extends SpawningTweak> clazz) Returns true if this spawner has a particularSpawningTweak
present.boolean
Whether or not this spawner should do spawning when it is triggered
-
Field Details
-
name
The unique name of the spawner. -
spawnedTracker
The maintained list of spawned entities. -
selectionAlgorithm
TheSelectionAlgorithm
used to choose a spawn from a list with a location. -
checkSpawns
TheCheckSpawns
used when /checkspawnsname
is used. By default it simply states not implemented. -
tweaks
A list ofSpawningTweak
s to apply to the entities spawned. -
conditions
A list ofSpawnerCondition
s to apply to potential spawns to filter early. -
rarityTweaks
A list of rarity tweaks to apply to spawns. -
rarityMultipliers
A list of rarity multipliers to apply to all the spawns this processes. -
isBusy
public volatile boolean isBusyWhether or not the spawner is currently busy doing processing. -
lastSpawnTime
public long lastSpawnTimeThe last time an entity spawned because of this spawner. -
spawnSets
TheSpawnSet
s contained in this spawner. -
cacheSets
-
-
Constructor Details
-
AbstractSpawner
-
-
Method Details
-
shouldDoSpawning
public boolean shouldDoSpawning()Whether or not this spawner should do spawning when it is triggered -
getSuitableSpawns
Gets all the spawns from the contained sets that suit the givenSpawnLocation
. -
fits
Whether or not this spawner finds it acceptable for thisSpawnInfo
to spawn at thisSpawnLocation
. Occurs after SpawnCondition#fits -
getWeightedSpawnInfo
Gets theSpawnInfo
to spawn at the givenSpawnLocation
based off what is suitable and chosen byselectionAlgorithm
. -
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 aSpatialData
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 sizedBlockCollection
- 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
Returns true if this spawner has a particularSpawningTweak
present. -
getTweak
Gets theSpawningTweak
of the given type, if it exists. This could be null. -
hasCondition
Returns true if this spawner has a particularSpawnerCondition
present. -
getCondition
Gets theSpawnerCondition
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 givenBiome
.
-