Interface BiomeRegistry


public interface BiomeRegistry
Server-wide registry of biomes, holding both the vanilla ones and those added by plugins.
Since:
0.1.0
  • Method Details

    • register

      @Contract("_ -> param1") BiomeDefinition register(BiomeDefinition definition)
      Registers a new biome.
      Parameters:
      definition - the biome to add
      Returns:
      the registered definition
      Throws:
      IllegalStateException - if a biome is already registered under the same key; use overwrite(BiomeDefinition) to replace it on purpose
      Since:
      0.1.0
    • register

      default BiomeDefinition register(BiomeBuilder builder)
      Builds and registers a new biome.
      Parameters:
      builder - the builder describing the biome
      Returns:
      the registered definition
      Throws:
      IllegalStateException - if a biome is already registered under the same key
      Since:
      0.1.0
    • registerFromJson

      BiomeDefinition registerFromJson(Key key, String json)
      Reads a biome from its data pack JSON representation and registers it.
      Parameters:
      key - the key to register the biome under
      json - the JSON object describing the biome
      Returns:
      the registered definition
      Throws:
      IllegalArgumentException - if the JSON is malformed or misses a mandatory field
      IllegalStateException - if a biome is already registered under the same key
      Since:
      0.1.0
    • overwrite

      Optional<BiomeDefinition> overwrite(BiomeDefinition definition)
      Registers a biome, replacing any existing one sharing its key.
      Parameters:
      definition - the biome to add or replace
      Returns:
      the definition previously registered under that key, if any
      Since:
      0.1.0
    • unregister

      boolean unregister(Key key)
      Removes a biome from the registry.
      Parameters:
      key - the key of the biome to remove
      Returns:
      true if a biome was removed, false if none was registered
      Throws:
      IllegalArgumentException - if key is the server's fallback biome, which must always stay registered
      Since:
      0.1.0
    • unregister

      default boolean unregister(TypedKey<Biome> key)
      Removes a biome from the registry.
      Parameters:
      key - the typed key of the biome to remove
      Returns:
      true if a biome was removed, false if none was registered
      Throws:
      IllegalArgumentException - if key is the server's fallback biome
      Since:
      0.1.0
    • definition

      Optional<BiomeDefinition> definition(Key key)
      Returns the definition registered under key, if that biome carries one.
      Parameters:
      key - the biome key
      Returns:
      the definition registered under key, if that biome carries one
      Since:
      0.1.0
    • contains

      boolean contains(Key key)
      Returns whether a biome is registered under key.
      Parameters:
      key - the biome key
      Returns:
      whether a biome is registered under key
      Since:
      0.1.0
    • isCustom

      boolean isCustom(Key key)
      Returns whether key maps to a biome defined by this server rather than a stock vanilla one.
      Parameters:
      key - the biome key
      Returns:
      whether key maps to a biome defined by this server rather than a stock vanilla one
      Since:
      0.1.0
    • keys

      @Contract(pure=true) Collection<Key> keys()
      Returns every registered biome key, in network order.
      Returns:
      every registered biome key, in network order
      Since:
      0.1.0
    • definitions

      @Contract(pure=true) Collection<BiomeDefinition> definitions()
      Returns every biome defined by this server, vanilla overrides included.
      Returns:
      every biome defined by this server, vanilla overrides included
      Since:
      0.1.0
    • networkId

      int networkId(Key key)
      Returns the network identifier of key, or -1 if it is not registered.
      Parameters:
      key - the biome key
      Returns:
      the network identifier of key, or -1 if it is not registered
      Since:
      0.1.0
    • fallback

      @Contract(pure=true) Key fallback()
      Returns the key of the biome used whenever a chunk references an unknown biome.
      Returns:
      the key of the biome used whenever a chunk references an unknown biome
      Since:
      0.1.0
    • totalRegistered

      int totalRegistered()
      Returns the number of registered biomes.
      Returns:
      the number of registered biomes
      Since:
      0.1.0