Interface Spawner

All Superinterfaces:
BaseSpawner
All Known Subinterfaces:
CreatureSpawner, SpawnerMinecart

public interface Spawner extends BaseSpawner
Represents an entity spawner.
May be a SpawnerMinecart or a CreatureSpawner.
  • 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 between getMinSpawnDelay() and getMaxSpawnDelay().
      Specified by:
      setDelay in interface BaseSpawner
      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 between getMinSpawnDelay() and getMaxSpawnDelay() for its next BaseSpawner.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 between getMinSpawnDelay() and getMaxSpawnDelay() for its next BaseSpawner.getDelay().
      This value must be greater than 0 and less than or equal to getMaxSpawnDelay().
      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 to getMinSpawnDelay()
      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 new BaseSpawner.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 same EntityType
      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

      void setSpawnedItem(@NotNull ItemStack itemStack)
      Sets the EntityType to EntityType.ITEM and sets the data to the given ItemStack.

      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 not be air.
      See Also: