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
Nested ClassesModifier and TypeClassDescriptionstatic class -
Field Summary
FieldsModifier and TypeFieldDescriptionTheCheckSpawnsused when /checkspawnsnameis used.A list ofSpawnerConditions to apply to potential spawns to filter early.booleanWhether or not the spawner is currently busy doing processing.longThe last time an entity spawned because of this spawner.final StringThe 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.TheSelectionAlgorithmused to choose a spawn from a list with a location.final SpawnedTrackerThe maintained list of spawned entities.TheSpawnSets contained in this spawner.A list ofSpawningTweaks to apply to the entities spawned. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic SpatialDatacalculateSpatialData(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 aSpatialDatafor the given parameters.booleanfits(SpawnInfo spawnInfo, SpawnLocation spawnLocation) Whether or not this spawner finds it acceptable for thisSpawnInfoto spawn at thisSpawnLocation.<T extends SpawnerCondition>
TgetCondition(Class<T> clazz) Gets theSpawnerConditionof 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 theSpawningTweakof the given type, if it exists.getWeightedSpawnInfo(SpawnLocation spawnLocation) Gets theSpawnInfoto spawn at the givenSpawnLocationbased off what is suitable and chosen byselectionAlgorithm.booleanhasCondition(Class<? extends SpawnerCondition> clazz) Returns true if this spawner has a particularSpawnerConditionpresent.booleanhasTweak(Class<? extends SpawningTweak> clazz) Returns true if this spawner has a particularSpawningTweakpresent.booleanWhether 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
TheSelectionAlgorithmused to choose a spawn from a list with a location. -
checkSpawns
TheCheckSpawnsused when /checkspawnsnameis used. By default it simply states not implemented. -
tweaks
A list ofSpawningTweaks to apply to the entities spawned. -
conditions
A list ofSpawnerConditions 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
TheSpawnSets 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 thisSpawnInfoto spawn at thisSpawnLocation. Occurs after SpawnCondition#fits -
getWeightedSpawnInfo
Gets theSpawnInfoto spawn at the givenSpawnLocationbased 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 aSpatialDatafor 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
SpatialDatawith 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
BlockCollectionthat tracked the entity's motion to give a random but predictive collection.
-
hasTweak
Returns true if this spawner has a particularSpawningTweakpresent. -
getTweak
Gets theSpawningTweakof the given type, if it exists. This could be null. -
hasCondition
Returns true if this spawner has a particularSpawnerConditionpresent. -
getCondition
Gets theSpawnerConditionof 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.
-