public abstract class AbstractSpawner
extends java.lang.Object
TriggerSpawner
and TickingSpawner
.
Instantiated implementations of this base should be added to the coordinator in PixelmonSpawning
.Modifier and Type | Class and Description |
---|---|
static class |
AbstractSpawner.SpawnerBuilder<T extends AbstractSpawner> |
Modifier and Type | Field and Description |
---|---|
java.util.HashMap<net.minecraft.util.ResourceLocation,java.util.List<SpawnInfo>> |
cacheSets |
CheckSpawns |
checkSpawns
The
CheckSpawns used when /checkspawns name is used. |
java.util.List<SpawnerCondition> |
conditions
A list of
SpawnerCondition 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<RarityTweak> |
rarityTweaks
A list of rarity tweaks to apply to spawns.
|
SelectionAlgorithm |
selectionAlgorithm
The
SelectionAlgorithm 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<SpawningTweak> |
tweaks
A list of
SpawningTweak 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 SpawnerCondition> |
getCondition(java.lang.Class<T> clazz)
Gets the
SpawnerCondition of the given type, if it exists. |
java.util.List<SpawnInfo> |
getSuitableSpawns(SpawnLocation spawnLocation)
Gets all the spawns from the contained sets that suit the given
SpawnLocation . |
java.util.concurrent.CompletableFuture<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 SpawningTweak> |
getTweak(java.lang.Class<T> clazz)
Gets the
SpawningTweak 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 SpawnerCondition> clazz)
Returns true if this spawner has a particular
SpawnerCondition present. |
boolean |
hasTweak(java.lang.Class<? extends SpawningTweak> clazz)
Returns true if this spawner has a particular
SpawningTweak 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 SelectionAlgorithm selectionAlgorithm
SelectionAlgorithm
used to choose a spawn from a list with a location.public CheckSpawns checkSpawns
CheckSpawns
used when /checkspawns name
is used. By default it simply states not implemented.public java.util.List<SpawningTweak> tweaks
SpawningTweak
s to apply to the entities spawned.public java.util.List<SpawnerCondition> conditions
SpawnerCondition
s to apply to potential spawns to filter early.public java.util.List<RarityTweak> rarityTweaks
public java.util.List<RarityMultiplier> rarityMultipliers
public volatile boolean isBusy
public long lastSpawnTime
public transient java.util.HashMap<net.minecraft.util.ResourceLocation,java.util.List<SpawnInfo>> cacheSets
public boolean shouldDoSpawning()
public java.util.List<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 java.util.concurrent.CompletableFuture<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 SpawningTweak> clazz)
SpawningTweak
present.@Nullable public <T extends SpawningTweak> T getTweak(java.lang.Class<T> clazz)
SpawningTweak
of the given type, if it exists. This could be null.public boolean hasCondition(java.lang.Class<? extends SpawnerCondition> clazz)
SpawnerCondition
present.@Nullable public <T extends SpawnerCondition> T getCondition(java.lang.Class<T> clazz)
SpawnerCondition
of the given type, if it exists. This could be null.