package org.bukkit; import java.util.Collection; import java.util.List; import java.util.Random; import java.util.function.Predicate; import org.bukkit.block.Biome; import org.bukkit.block.BlockState; import org.bukkit.block.data.BlockData; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.LivingEntity; import org.bukkit.util.Consumer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** * A RegionAccessor gives access to getting, modifying and spawning {@link Biome}, {@link BlockState} and {@link Entity}, * as well as generating some basic structures. */ public interface RegionAccessor { /** * Gets the {@link Biome} at the given {@link Location}. * * @param location the location of the biome * @return Biome at the given location */ @NotNull Biome getBiome(@NotNull Location location); /** * Gets the {@link Biome} at the given coordinates. * * @param x X-coordinate of the block * @param y Y-coordinate of the block * @param z Z-coordinate of the block * @return Biome at the given coordinates */ @NotNull Biome getBiome(int x, int y, int z); /** * Sets the {@link Biome} at the given {@link Location}. * * @param location the location of the biome * @param biome New Biome type for this block */ void setBiome(@NotNull Location location, @NotNull Biome biome); /** * Sets the {@link Biome} for the given block coordinates * * @param x X-coordinate of the block * @param y Y-coordinate of the block * @param z Z-coordinate of the block * @param biome New Biome type for this block */ void setBiome(int x, int y, int z, @NotNull Biome biome); /** * Gets the {@link BlockState} at the given {@link Location}. * * @param location The location of the block state * @return Block state at the given location */ @NotNull BlockState getBlockState(@NotNull Location location); /** * Gets the {@link BlockState} at the given coordinates. * * @param x X-coordinate of the block state * @param y Y-coordinate of the block state * @param z Z-coordinate of the block state * @return Block state at the given coordinates */ @NotNull BlockState getBlockState(int x, int y, int z); /** * Gets the {@link BlockData} at the given {@link Location}. * * @param location The location of the block data * @return Block data at the given location */ @NotNull BlockData getBlockData(@NotNull Location location); /** * Gets the {@link BlockData} at the given coordinates. * * @param x X-coordinate of the block data * @param y Y-coordinate of the block data * @param z Z-coordinate of the block data * @return Block data at the given coordinates */ @NotNull BlockData getBlockData(int x, int y, int z); /** * Gets the type of the block at the given {@link Location}. * * @param location The location of the block * @return Material at the given coordinates */ @NotNull Material getType(@NotNull Location location); /** * Gets the type of the block at the given coordinates. * * @param x X-coordinate of the block * @param y Y-coordinate of the block * @param z Z-coordinate of the block * @return Material at the given coordinates */ @NotNull Material getType(int x, int y, int z); /** * Sets the {@link BlockData} at the given {@link Location}. * * @param location The location of the block * @param blockData The block data to set the block to */ void setBlockData(@NotNull Location location, @NotNull BlockData blockData); /** * Sets the {@link BlockData} at the given coordinates. * * @param x X-coordinate of the block * @param y Y-coordinate of the block * @param z Z-coordinate of the block * @param blockData The block data to set the block to */ void setBlockData(int x, int y, int z, @NotNull BlockData blockData); /** * Sets the {@link Material} at the given {@link Location}. * * @param location The location of the block * @param material The type to set the block to */ void setType(@NotNull Location location, @NotNull Material material); /** * Sets the {@link Material} at the given coordinates. * * @param x X-coordinate of the block * @param y Y-coordinate of the block * @param z Z-coordinate of the block * @param material The type to set the block to */ void setType(int x, int y, int z, @NotNull Material material); /** * Creates a tree at the given {@link Location} * * @param location Location to spawn the tree * @param random Random to use to generated the tree * @param type Type of the tree to create * @return true if the tree was created successfully, otherwise false */ boolean generateTree(@NotNull Location location, @NotNull Random random, @NotNull TreeType type); /** * Creates a tree at the given {@link Location} *
* 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 world are done yet. Which means, that calling * {@link #getBlockState(Location)} in the consumer while return the state * of the block before the generation. *
* Modifications done to the {@link BlockState} in the consumer are respected,
* which means that it is not necessary to call {@link BlockState#update()}
*
* @param location Location to spawn the tree
* @param random Random to use to generated the tree
* @param type Type of the tree to create
* @param stateConsumer The consumer which should get called for every block which gets changed
* @return true if the tree was created successfully, otherwise false
*/
boolean generateTree(@NotNull Location location, @NotNull Random random, @NotNull TreeType type, @Nullable Consumer
* 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 world are done yet. Which means, that calling
* {@link #getBlockState(Location)} in the predicate will return the state
* of the block before the generation.
*
* If the predicate returns {@code true} the block gets set in the world.
* If it returns {@code false} the block won't get set in the world.
*
* @param location Location to spawn the tree
* @param random Random to use to generated the tree
* @param type Type of the tree to create
* @param statePredicate The predicate which should get used to test if a block should be set or not.
* @return true if the tree was created successfully, otherwise false
*/
boolean generateTree(@NotNull Location location, @NotNull Random random, @NotNull TreeType type, @Nullable Predicate
* Note that when the function is run, the entity will not be actually in
* the world. Any operation involving such as teleporting the entity is undefined
* until after this function returns.
*
* @param location the {@link Location} to spawn the entity at
* @param clazz the class of the {@link Entity} to spawn
* @param function the function to be run before the entity is spawned.
* @param
* Note that when the function is run, the entity will not be actually in
* the world. Any operation involving such as teleporting the entity is undefined
* until after this function returns.
* The passed function however is run after the potential entity'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 entity
* equipment.
*
* @param location the location at which the entity will be spawned.
* @param clazz the class of the {@link Entity} that is to be spawned.
* @param