Package org.bukkit.spawner
Interface Spawner
- All Superinterfaces:
BaseSpawner
- All Known Subinterfaces:
CreatureSpawner
,SpawnerMinecart
-
Method Summary
Modifier and TypeMethodDescriptionint
Set the new maximum amount of similar entities that are allowed to be within spawning range of this spawner.int
The maximum spawn delay amount (in ticks).int
The minimum spawn delay amount (in ticks).int
Get how many mobs attempt to spawn.boolean
Check if spawner is activated (a player is close enough)void
Resets the spawn delay timer within the min/max rangevoid
setDelay
(int delay) Set the spawner's delay.void
setMaxNearbyEntities
(int maxNearbyEntities) Set the maximum number of similar entities that are allowed to be within spawning range of this spawner.void
setMaxSpawnDelay
(int delay) Set the maximum spawn delay amount (in ticks).void
setMinSpawnDelay
(int delay) Set the minimum spawn delay amount (in ticks).void
setSpawnCount
(int spawnCount) Set how many mobs attempt to spawn.void
setSpawnedItem
(@NotNull ItemStack itemStack) Methods inherited from interface org.bukkit.spawner.BaseSpawner
addPotentialSpawn, addPotentialSpawn, getDelay, getPotentialSpawns, getRequiredPlayerRange, getSpawnedEntity, getSpawnedType, getSpawnRange, setPotentialSpawns, setRequiredPlayerRange, setSpawnedEntity, setSpawnedEntity, setSpawnedType, setSpawnRange
-
Method Details
-
setDelay
void setDelay(int delay) Set the spawner's delay.
If set to -1, the spawn delay will be reset to a random value betweengetMinSpawnDelay()
andgetMaxSpawnDelay()
.- Specified by:
setDelay
in interfaceBaseSpawner
- Parameters:
delay
- The delay.
-
getMinSpawnDelay
int getMinSpawnDelay()The minimum spawn delay amount (in ticks).
This value is used when the spawner resets its delay (for any reason). It will choose a random number betweengetMinSpawnDelay()
andgetMaxSpawnDelay()
for its nextBaseSpawner.getDelay()
.
Default value is 200 ticks.- Returns:
- the minimum spawn delay amount
-
setMinSpawnDelay
void setMinSpawnDelay(int delay) Set the minimum spawn delay amount (in ticks).- Parameters:
delay
- the minimum spawn delay amount- See Also:
-
getMaxSpawnDelay
int getMaxSpawnDelay()The maximum spawn delay amount (in ticks).
This value is used when the spawner resets its delay (for any reason). It will choose a random number betweengetMinSpawnDelay()
andgetMaxSpawnDelay()
for its nextBaseSpawner.getDelay()
.
This value must be greater than 0 and less than or equal togetMaxSpawnDelay()
.
Default value is 800 ticks.- Returns:
- the maximum spawn delay amount
-
setMaxSpawnDelay
void setMaxSpawnDelay(int delay) Set the maximum spawn delay amount (in ticks).
This value must be greater than 0, as well as greater than or equal togetMinSpawnDelay()
- Parameters:
delay
- the new maximum spawn delay amount- See Also:
-
getSpawnCount
int getSpawnCount()Get how many mobs attempt to spawn.
Default value is 4.- Returns:
- the current spawn count
-
setSpawnCount
void setSpawnCount(int spawnCount) Set how many mobs attempt to spawn.- Parameters:
spawnCount
- the new spawn count
-
getMaxNearbyEntities
int getMaxNearbyEntities()Set the new maximum amount of similar entities that are allowed to be within spawning range of this spawner.
If more than the maximum number of entities are within range, the spawner will not spawn and try again with a newBaseSpawner.getDelay()
.
Default value is 16.- Returns:
- the maximum number of nearby, similar, entities
-
setMaxNearbyEntities
void setMaxNearbyEntities(int maxNearbyEntities) Set the maximum number of similar entities that are allowed to be within spawning range of this spawner.
Similar entities are entities that are of the sameEntityType
- Parameters:
maxNearbyEntities
- the maximum number of nearby, similar, entities
-
isActivated
boolean isActivated()Check if spawner is activated (a player is close enough)- Returns:
- True if a player is close enough to activate it
-
resetTimer
void resetTimer()Resets the spawn delay timer within the min/max range -
setSpawnedItem
Sets theEntityType
toEntityType.ITEM
and sets the data to the givenItemStack
.setSpawnCount(int)
does not dictate the amount of items in the stack spawned, but rather how many stacks should be spawned.- Parameters:
itemStack
- The item to spawn. Must notbe air
.- See Also:
-