public abstract class AbstractSpawner
extends java.lang.Object
TriggerSpawner
and TickingSpawner
.
Instantiated implementations of this base should be added to the coordinator in PixelmonSpawning
.
Created by Hiroku
Modifier and Type | Class and Description |
---|---|
static class |
AbstractSpawner.SpawnerBuilder<T extends AbstractSpawner> |
Modifier and Type | Field and Description |
---|---|
java.util.HashMap<net.minecraft.world.biome.Biome,java.util.List<SpawnInfo>> |
cacheSets |
ICheckSpawns |
checkSpawns
The
ICheckSpawns used when /checkspawns name is used. |
java.util.List<ISpawnerCondition> |
conditions
A list of
ISpawnerCondition s to apply to potential spawns to filter early. |
boolean |
isBusy
Whether or not the spawner is currently busy doing processing.
|
long |
lastSpawnTime
The last time an entity spawned because of this spawner.
|
java.lang.String |
name
The unique name of the spawner.
|
java.util.List<RarityMultiplier> |
rarityMultipliers
A list of rarity multipliers to apply to all the spawns this processes.
|
java.util.List<IRarityTweak> |
rarityTweaks
A list of rarity tweaks to apply to spawns.
|
ISelectionAlgorithm |
selectionAlgorithm
The
ISelectionAlgorithm used to choose a spawn from a list with a location. |
SpawnedTracker |
spawnedTracker
The maintained list of spawned entities.
|
java.util.List<SpawnSet> |
spawnSets
The
SpawnSet s contained in this spawner. |
java.util.List<ISpawningTweak> |
tweaks
A list of
ISpawningTweak s to apply to the entities spawned. |
Constructor and Description |
---|
AbstractSpawner(java.lang.String name) |
Modifier and Type | Method and Description |
---|---|
SpatialData |
calculateSpatialData(net.minecraft.world.World world,
net.minecraft.util.math.BlockPos centre,
int max,
boolean includeDownwards,
java.util.function.Predicate<net.minecraft.block.Block> condition)
Calculates a
SpatialData for the given parameters. |
boolean |
fits(SpawnInfo spawnInfo,
SpawnLocation spawnLocation)
Whether or not this spawner finds it acceptable for this
SpawnInfo to spawn at this SpawnLocation . |
<T extends ISpawnerCondition> |
getCondition(java.lang.Class<T> clazz)
Gets the
ISpawnerCondition of the given type, if it exists. |
java.util.ArrayList<SpawnInfo> |
getSuitableSpawns(SpawnLocation spawnLocation)
Gets all the spawns from the contained sets that suit the given
SpawnLocation . |
BlockCollection |
getTrackedBlockCollection(net.minecraft.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 |
<T extends ISpawningTweak> |
getTweak(java.lang.Class<T> clazz)
Gets the
ISpawningTweak of the given type, if it exists. |
SpawnInfo |
getWeightedSpawnInfo(SpawnLocation spawnLocation)
Gets the
SpawnInfo to spawn at the given SpawnLocation based off what is suitable and chosen by selectionAlgorithm . |
boolean |
hasCondition(java.lang.Class<? extends ISpawnerCondition> clazz)
Returns true if this spawner has a particular
ISpawnerCondition present. |
boolean |
hasTweak(java.lang.Class<? extends ISpawningTweak> clazz)
Returns true if this spawner has a particular
ISpawningTweak present. |
boolean |
shouldDoSpawning()
Whether or not this spawner should do spawning when it is triggered
|
public final java.lang.String name
public final SpawnedTracker spawnedTracker
public ISelectionAlgorithm selectionAlgorithm
ISelectionAlgorithm
used to choose a spawn from a list with a location.public ICheckSpawns checkSpawns
ICheckSpawns
used when /checkspawns name
is used. By default it simply states not implemented.public java.util.List<ISpawningTweak> tweaks
ISpawningTweak
s to apply to the entities spawned.public java.util.List<ISpawnerCondition> conditions
ISpawnerCondition
s to apply to potential spawns to filter early.public java.util.List<IRarityTweak> rarityTweaks
public java.util.List<RarityMultiplier> rarityMultipliers
public volatile boolean isBusy
public long lastSpawnTime
public transient java.util.HashMap<net.minecraft.world.biome.Biome,java.util.List<SpawnInfo>> cacheSets
public boolean shouldDoSpawning()
public java.util.ArrayList<SpawnInfo> getSuitableSpawns(SpawnLocation spawnLocation)
SpawnLocation
.public boolean fits(SpawnInfo spawnInfo, SpawnLocation spawnLocation)
SpawnInfo
to spawn at this SpawnLocation
. Occurs after SpawnCondition#fits@Nullable public SpawnInfo getWeightedSpawnInfo(SpawnLocation spawnLocation)
SpawnInfo
to spawn at the given SpawnLocation
based off what is suitable and chosen by selectionAlgorithm
.public SpatialData calculateSpatialData(net.minecraft.world.World world, net.minecraft.util.math.BlockPos centre, int max, boolean includeDownwards, java.util.function.Predicate<net.minecraft.block.Block> condition)
SpatialData
for the given 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.SpatialData
with all its information.public BlockCollection getTrackedBlockCollection(net.minecraft.entity.Entity entity, float horizontalTrackFactor, float verticalTrackFactor, int horizontalSliceRadius, int verticalSliceRadius, int minDistFromCentre, int maxDistFromCentre)
BlockCollection
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.BlockCollection
that tracked the entity's motion to give a random but predictive collection.public boolean hasTweak(java.lang.Class<? extends ISpawningTweak> clazz)
ISpawningTweak
present.@Nullable public <T extends ISpawningTweak> T getTweak(java.lang.Class<T> clazz)
ISpawningTweak
of the given type, if it exists. This could be null.public boolean hasCondition(java.lang.Class<? extends ISpawnerCondition> clazz)
ISpawnerCondition
present.@Nullable public <T extends ISpawnerCondition> T getCondition(java.lang.Class<T> clazz)
ISpawnerCondition
of the given type, if it exists. This could be null.