Package org.bukkit.spawner
Interface BaseSpawner
- All Known Subinterfaces:
CreatureSpawner
,Spawner
,SpawnerMinecart
,TrialSpawnerConfiguration
public interface BaseSpawner
Represents a basic entity spawner.
May be a
May be a
SpawnerMinecart
, CreatureSpawner
or TrialSpawnerConfiguration
.-
Method Summary
Modifier and TypeMethodDescriptionvoid
addPotentialSpawn
(@NotNull SpawnerEntry spawnerEntry) Adds a newSpawnerEntry
to the list of entities this spawner can spawn.void
addPotentialSpawn
(@NotNull EntitySnapshot snapshot, int weight, @Nullable SpawnRule spawnRule) Adds a newEntitySnapshot
to the list of entities this spawner can spawn.int
getDelay()
Get the spawner's delay.Gets a list of potential spawns from this spawner or an empty list if no entities have been assigned to this spawner.int
Get the maximum distance(squared) a player can be in order for this spawner to be active.Gets theEntitySnapshot
that will be spawned by this spawner or null if no entities have been assigned to this spawner.Get the spawner's creature type.int
Get the radius around which the spawner will attempt to spawn mobs in.void
setDelay
(int delay) Set the spawner's delay.void
setPotentialSpawns
(@NotNull Collection<SpawnerEntry> entries) Sets the list ofSpawnerEntry
this spawner can spawn.void
setRequiredPlayerRange
(int requiredPlayerRange) Set the maximum distance (squared) a player can be in order for this spawner to be active.void
setSpawnedEntity
(@NotNull SpawnerEntry spawnerEntry) Sets theSpawnerEntry
that will be spawned by this spawner.void
setSpawnedEntity
(@Nullable EntitySnapshot snapshot) Sets the entity that will be spawned by this spawner.void
setSpawnedType
(@Nullable EntityType creatureType) Set the spawner's creature type.void
setSpawnRange
(int spawnRange) Set the new spawn range.
-
Method Details
-
getSpawnedType
Get the spawner's creature type.- Returns:
- The creature type or null if it not set.
-
setSpawnedType
Set the spawner's creature type.
This will override any entities that have been added withaddPotentialSpawn(org.bukkit.entity.EntitySnapshot, int, org.bukkit.block.spawner.SpawnRule)
- Parameters:
creatureType
- The creature type or null to clear.
-
getDelay
int getDelay()Get the spawner's delay.
This is the delay, in ticks, until the spawner will spawn its next mob.- Returns:
- The delay.
-
setDelay
void setDelay(int delay) Set the spawner's delay.- Parameters:
delay
- The delay.
-
getRequiredPlayerRange
int getRequiredPlayerRange()Get the maximum distance(squared) a player can be in order for this spawner to be active.
If this value is less than or equal to 0, this spawner is always active (given that there are players online).
Default value is 16.- Returns:
- the maximum distance(squared) a player can be in order for this spawner to be active.
-
setRequiredPlayerRange
void setRequiredPlayerRange(int requiredPlayerRange) Set the maximum distance (squared) a player can be in order for this spawner to be active.
Setting this value to less than or equal to 0 will make this spawner always active (given that there are players online).- Parameters:
requiredPlayerRange
- the maximum distance (squared) a player can be in order for this spawner to be active.
-
getSpawnRange
int getSpawnRange()Get the radius around which the spawner will attempt to spawn mobs in.
This area is square, includes the block the spawner is in, and is centered on the spawner's x,z coordinates - not the spawner itself.
It is 2 blocks high, centered on the spawner's y-coordinate (its bottom); thus allowing mobs to spawn as high as its top surface and as low as 1 block below its bottom surface.
Default value is 4.- Returns:
- the spawn range
-
setSpawnRange
void setSpawnRange(int spawnRange) Set the new spawn range.- Parameters:
spawnRange
- the new spawn range- See Also:
-
getSpawnedEntity
Gets theEntitySnapshot
that will be spawned by this spawner or null if no entities have been assigned to this spawner.
All applicable data from the spawner will be copied, such as custom name, health, and velocity.
- Returns:
- the entity snapshot or null if no entities have been assigned to this spawner.
-
setSpawnedEntity
Sets the entity that will be spawned by this spawner.
This will override any previous entries that have been added withaddPotentialSpawn(org.bukkit.entity.EntitySnapshot, int, org.bukkit.block.spawner.SpawnRule)
All applicable data from the snapshot will be copied, such as custom name, health, and velocity.
- Parameters:
snapshot
- the entity snapshot or null to clear
-
setSpawnedEntity
Sets theSpawnerEntry
that will be spawned by this spawner.
This will override any previous entries that have been added withaddPotentialSpawn(org.bukkit.entity.EntitySnapshot, int, org.bukkit.block.spawner.SpawnRule)
- Parameters:
spawnerEntry
- the spawner entry to use
-
addPotentialSpawn
void addPotentialSpawn(@NotNull @NotNull EntitySnapshot snapshot, int weight, @Nullable @Nullable SpawnRule spawnRule) Adds a newEntitySnapshot
to the list of entities this spawner can spawn.The weight will determine how often this entry is chosen to spawn, higher weighted entries will spawn more often than lower weighted ones.
TheSpawnRule
will determine under what conditions this entry can spawn, passing null will use the default conditions for the given entity.- Parameters:
snapshot
- the snapshot that will be spawnedweight
- the weightspawnRule
- the spawn rule for this entity, or null
-
addPotentialSpawn
Adds a newSpawnerEntry
to the list of entities this spawner can spawn.- Parameters:
spawnerEntry
- the spawner entry to use- See Also:
-
setPotentialSpawns
Sets the list ofSpawnerEntry
this spawner can spawn.
This will override any previous entries added withaddPotentialSpawn(org.bukkit.entity.EntitySnapshot, int, org.bukkit.block.spawner.SpawnRule)
- Parameters:
entries
- the list of entries
-
getPotentialSpawns
Gets a list of potential spawns from this spawner or an empty list if no entities have been assigned to this spawner.
Changes made to the returned list will not be reflected in the spawner unless applied withsetPotentialSpawns(java.util.Collection<org.bukkit.block.spawner.SpawnerEntry>)
- Returns:
- a list of potential spawns from this spawner, or an empty list if no entities have been assigned to this spawner
- See Also:
-