Package de.eimmer

Interface RegionAkzessor

All Known Subinterfaces:
BegrenzteGegend, Welt

public interface RegionAkzessor
A RegionAkzessor gives access to getting, modifying and spawning Biome, BlockState and Wesen, as well as generating some basic structures.
  • Method Details

    • getBiome

      @NotNull Biome getBiome(@NotNull Ort ort)
      Gets the Biome at the given Ort.
      Parameters:
      ort - the ort of the biome
      Returns:
      Biome at the given ort
    • getBiome

      @NotNull Biome getBiome(int x, int y, int z)
      Gets the Biome at the given coordinates.
      Parameters:
      x - X-coordinate of the block
      y - Y-coordinate of the block
      z - Z-coordinate of the block
      Returns:
      Biome at the given coordinates
    • setBiome

      void setBiome(@NotNull Ort ort, @NotNull Biome biome)
      Sets the Biome at the given Ort.
      Parameters:
      ort - the ort of the biome
      biome - New Biome type for this block
    • setBiome

      void setBiome(int x, int y, int z, @NotNull Biome biome)
      Sets the Biome for the given block coordinates
      Parameters:
      x - X-coordinate of the block
      y - Y-coordinate of the block
      z - Z-coordinate of the block
      biome - New Biome type for this block
    • getBlockState

      @NotNull BlockState getBlockState(@NotNull Ort ort)
      Gets the BlockState at the given Ort.
      Parameters:
      ort - The ort of the block state
      Returns:
      Block state at the given ort
    • getBlockState

      @NotNull BlockState getBlockState(int x, int y, int z)
      Gets the BlockState at the given coordinates.
      Parameters:
      x - X-coordinate of the block state
      y - Y-coordinate of the block state
      z - Z-coordinate of the block state
      Returns:
      Block state at the given coordinates
    • getBlockData

      @NotNull BlockData getBlockData(@NotNull Ort ort)
      Gets the BlockData at the given Ort.
      Parameters:
      ort - The ort of the block data
      Returns:
      Block data at the given ort
    • getBlockData

      @NotNull BlockData getBlockData(int x, int y, int z)
      Gets the BlockData at the given coordinates.
      Parameters:
      x - X-coordinate of the block data
      y - Y-coordinate of the block data
      z - Z-coordinate of the block data
      Returns:
      Block data at the given coordinates
    • getType

      @NotNull Material getType(@NotNull Ort ort)
      Gets the type of the block at the given Ort.
      Parameters:
      ort - The ort of the block
      Returns:
      Material at the given coordinates
    • getType

      @NotNull Material getType(int x, int y, int z)
      Gets the type of the block at the given coordinates.
      Parameters:
      x - X-coordinate of the block
      y - Y-coordinate of the block
      z - Z-coordinate of the block
      Returns:
      Material at the given coordinates
    • setBlockData

      void setBlockData(@NotNull Ort ort, @NotNull BlockData blockData)
      Sets the BlockData at the given Ort.
      Parameters:
      ort - The ort of the block
      blockData - The block data to set the block to
    • setBlockData

      void setBlockData(int x, int y, int z, @NotNull BlockData blockData)
      Sets the BlockData at the given coordinates.
      Parameters:
      x - X-coordinate of the block
      y - Y-coordinate of the block
      z - Z-coordinate of the block
      blockData - The block data to set the block to
    • setType

      void setType(@NotNull Ort ort, @NotNull Material material)
      Sets the Material at the given Ort.
      Parameters:
      ort - The ort of the block
      material - The type to set the block to
    • setType

      void setType(int x, int y, int z, @NotNull Material material)
      Sets the Material at the given coordinates.
      Parameters:
      x - X-coordinate of the block
      y - Y-coordinate of the block
      z - Z-coordinate of the block
      material - The type to set the block to
    • generateTree

      boolean generateTree(@NotNull Ort ort, @NotNull Random random, @NotNull TreeType type)
      Creates a tree at the given Ort
      Parameters:
      ort - Ort to spawn the tree
      random - Random to use to generated the tree
      type - Type of the tree to create
      Returns:
      true if the tree was created successfully, otherwise false
    • generateTree

      boolean generateTree(@NotNull Ort ort, @NotNull Random random, @NotNull TreeType type, @Nullable Consumer<? super BlockState> stateConsumer)
      Creates a tree at the given Ort

      The provided consumer gets called for every block which gets changed as a result of the tree generation. When the consumer gets called no modifications to the welt are done yet. Which means, that calling getBlockState(Ort) in the consumer while return the state of the block before the generation.

      Modifications done to the BlockState in the consumer are respected, which means that it is not necessary to call BlockState.update()

      Parameters:
      ort - Ort to spawn the tree
      random - Random to use to generated the tree
      type - Type of the tree to create
      stateConsumer - The consumer which should get called for every block which gets changed
      Returns:
      true if the tree was created successfully, otherwise false
    • generateTree

      boolean generateTree(@NotNull Ort ort, @NotNull Random random, @NotNull TreeType type, @Nullable Predicate<? super BlockState> statePredicate)
      Creates a tree at the given Ort

      The provided predicate gets called for every block which gets changed as a result of the tree generation. When the predicate gets called no modifications to the welt are done yet. Which means, that calling getBlockState(Ort) in the predicate will return the state of the block before the generation.

      If the predicate returns true the block gets set in the welt. If it returns false the block won't get set in the welt.

      Parameters:
      ort - Ort to spawn the tree
      random - Random to use to generated the tree
      type - Type of the tree to create
      statePredicate - The predicate which should get used to test if a block should be set or not.
      Returns:
      true if the tree was created successfully, otherwise false
    • spawnEntity

      @NotNull Wesen spawnEntity(@NotNull Ort ort, @NotNull WesensTyp type)
      Creates a wesen at the given Ort
      Parameters:
      ort - The ort to spawn the wesen
      type - The wesen to spawn
      Returns:
      Resulting Wesen of this method
    • spawnEntity

      @NotNull Wesen spawnEntity(@NotNull Ort loc, @NotNull WesensTyp type, boolean randomizeData)
      Creates a new wesen at the given Ort.
      Parameters:
      loc - the location at which the wesen will be spawned.
      type - the wesen type that determines the wesen to spawn.
      randomizeData - whether or not the wesen's data should be randomised before spawning. By default entities are randomised before spawning in regards to their equipment, age, attributes, etc. An example of this randomization would be the color of a sheep, random verzauberungen on the equipment of mobs or even a zombie becoming a chicken jockey. If set to false, the wesen will not be randomised before spawning, meaning all their data will remain in their default state and not further modifications to the wesen will be made. Notably only entities that extend the Mob interface provide randomisation logic for their spawn. This parameter is hence useless for any other type of wesen.
      Returns:
      the spawned wesen instance.
    • getEntities

      @NotNull List<Wesen> getEntities()
      Get a list of all entities in this RegionAkzessor
      Returns:
      A List of all Entities currently residing in this welt accessor
    • getLivingEntities

      @NotNull List<Lebewesen> getLivingEntities()
      Get a list of all living entities in this RegionAkzessor
      Returns:
      A List of all LivingEntities currently residing in this welt accessor
    • getEntitiesByClass

      @NotNull <T extends Wesen> Collection<T> getEntitiesByClass(@NotNull Class<T> cls)
      Get a collection of all entities in this RegionAkzessor matching the given class/interface
      Type Parameters:
      T - an wesen subclass
      Parameters:
      cls - The class representing the type of wesen to match
      Returns:
      A List of all Entities currently residing in this welt accessor that match the given class/interface
    • getEntitiesByClasses

      @NotNull Collection<Wesen> getEntitiesByClasses(@NotNull Class<?>... classes)
      Get a collection of all entities in this RegionAkzessor matching any of the given classes/interfaces
      Parameters:
      classes - The classes representing the types of wesen to match
      Returns:
      A List of all Entities currently residing in this welt accessor that match one or more of the given classes/interfaces
    • createEntity

      @NotNull <T extends Wesen> T createEntity(@NotNull Ort ort, @NotNull Class<T> clazz)
      Creates an wesen of a specific class at the given Ort but does not spawn it in the welt.

      Note: The created wesen keeps a reference to the welt it was created in, care should be taken that the wesen does not outlive the welt instance as this will lead to memory leaks.

      Type Parameters:
      T - the class of the Wesen to create
      Parameters:
      ort - the Ort to create the wesen at
      clazz - the class of the Wesen to spawn
      Returns:
      an instance of the created Wesen
      See Also:
    • spawn

      @NotNull <T extends Wesen> T spawn(@NotNull Ort ort, @NotNull Class<T> clazz) throws IllegalArgumentException
      Spawn an wesen of a specific class at the given Ort
      Type Parameters:
      T - the class of the Wesen to spawn
      Parameters:
      ort - the Ort to spawn the wesen at
      clazz - the class of the Wesen to spawn
      Returns:
      an instance of the spawned Wesen
      Throws:
      IllegalArgumentException - if either parameter is null or the Wesen requested cannot be spawned
    • spawn

      @NotNull <T extends Wesen> T spawn(@NotNull Ort ort, @NotNull Class<T> clazz, @Nullable Consumer<? super T> function) throws IllegalArgumentException
      Spawn an wesen of a specific class at the given Ort, with the supplied function run before the wesen is added to the welt.
      Note that when the function is run, the wesen will not be actually in the welt. Any operation involving such as teleporting the wesen is undefined until after this function returns.
      Type Parameters:
      T - the class of the Wesen to spawn
      Parameters:
      ort - the Ort to spawn the wesen at
      clazz - the class of the Wesen to spawn
      function - the function to be run before the wesen is spawned.
      Returns:
      an instance of the spawned Wesen
      Throws:
      IllegalArgumentException - if either parameter is null or the Wesen requested cannot be spawned
    • spawn

      @NotNull <T extends Wesen> T spawn(@NotNull Ort ort, @NotNull Class<T> clazz, boolean randomizeData, @Nullable Consumer<? super T> function) throws IllegalArgumentException
      Creates a new wesen at the given Ort with the supplied function run before the wesen is added to the welt.
      Note that when the function is run, the wesen will not be actually in the welt. Any operation involving such as teleporting the wesen is undefined until after this function returns. The passed function however is run after the potential wesen's spawn randomization and hence already allows access to the values of the mob, whether or not those were randomized, such as attributes or the wesen equipment.
      Type Parameters:
      T - the generic type of the wesen that is being created.
      Parameters:
      ort - the ort at which the wesen will be spawned.
      clazz - the class of the Wesen that is to be spawned.
      randomizeData - whether or not the wesen's data should be randomised before spawning. By default entities are randomised before spawning in regards to their equipment, age, attributes, etc. An example of this randomization would be the color of a sheep, random verzauberungen on the equipment of mobs or even a zombie becoming a chicken jockey. If set to false, the wesen will not be randomised before spawning, meaning all their data will remain in their default state and not further modifications to the wesen will be made. Notably only entities that extend the Mob interface provide randomisation logic for their spawn. This parameter is hence useless for any other type of wesen.
      function - the function to be run before the wesen is spawned.
      Returns:
      the spawned wesen instance.
      Throws:
      IllegalArgumentException - if either the welt or clazz parameter are null.
    • getHighestBlockYAt

      int getHighestBlockYAt(int x, int z)
      Gets the highest non-empty (impassable) coordinate at the given coordinates.
      Parameters:
      x - X-coordinate of the blocks
      z - Z-coordinate of the blocks
      Returns:
      Y-coordinate of the highest non-empty block
    • getHighestBlockYAt

      int getHighestBlockYAt(@NotNull Ort ort)
      Gets the highest non-empty (impassable) coordinate at the given Ort.
      Parameters:
      ort - Ort of the blocks
      Returns:
      Y-coordinate of the highest non-empty block
    • getHighestBlockYAt

      int getHighestBlockYAt(int x, int z, @NotNull HoehenKarte hoehenKarte)
      Gets the highest coordinate corresponding to the HoehenKarte at the given coordinates.
      Parameters:
      x - X-coordinate of the blocks
      z - Z-coordinate of the blocks
      hoehenKarte - the hoehenKarte that is used to determine the highest point
      Returns:
      Y-coordinate of the highest block corresponding to the HoehenKarte
    • getHighestBlockYAt

      int getHighestBlockYAt(@NotNull Ort ort, @NotNull HoehenKarte hoehenKarte)
      Gets the highest coordinate corresponding to the HoehenKarte at the given Ort.
      Parameters:
      ort - Ort of the blocks
      hoehenKarte - the hoehenKarte that is used to determine the highest point
      Returns:
      Y-coordinate of the highest block corresponding to the HoehenKarte
    • addEntity

      @NotNull <T extends Wesen> T addEntity(@NotNull T entity)
      Spawns a previously created wesen in the welt.
      The provided wesen must not have already been spawned in a welt.
      Type Parameters:
      T - the generic type of the wesen that is being added.
      Parameters:
      entity - the wesen to add
      Returns:
      the wesen now in the welt