public interface RegionAccessor
Biome
, BlockState
and Entity
,
as well as generating some basic structures.Modifier and Type | Method and Description |
---|---|
boolean |
generateTree(Location location,
Random random,
TreeType type)
Creates a tree at the given
Location |
boolean |
generateTree(Location location,
Random random,
TreeType type,
Consumer<BlockState> stateConsumer)
Creates a tree at the given
Location |
boolean |
generateTree(Location location,
Random random,
TreeType type,
Predicate<BlockState> statePredicate)
Creates a tree at the given
Location |
Biome |
getBiome(int x,
int y,
int z)
Gets the
Biome at the given coordinates. |
Biome |
getBiome(Location location)
|
BlockData |
getBlockData(int x,
int y,
int z)
Gets the
BlockData at the given coordinates. |
BlockData |
getBlockData(Location location)
|
BlockState |
getBlockState(int x,
int y,
int z)
Gets the
BlockState at the given coordinates. |
BlockState |
getBlockState(Location location)
Gets the
BlockState at the given Location . |
List<Entity> |
getEntities()
Get a list of all entities in this RegionAccessor
|
<T extends Entity> |
getEntitiesByClass(Class<T> cls)
Get a collection of all entities in this RegionAccessor matching the given
class/interface
|
Collection<Entity> |
getEntitiesByClasses(Class<?>... classes)
Get a collection of all entities in this RegionAccessor matching any of the
given classes/interfaces
|
List<LivingEntity> |
getLivingEntities()
Get a list of all living entities in this RegionAccessor
|
Material |
getType(int x,
int y,
int z)
Gets the type of the block at the given coordinates.
|
Material |
getType(Location location)
Gets the type of the block at the given
Location . |
void |
setBiome(int x,
int y,
int z,
Biome biome)
Sets the
Biome for the given block coordinates |
void |
setBiome(Location location,
Biome biome)
|
void |
setBlockData(int x,
int y,
int z,
BlockData blockData)
Sets the
BlockData at the given coordinates. |
void |
setBlockData(Location location,
BlockData blockData)
|
void |
setType(int x,
int y,
int z,
Material material)
Sets the
Material at the given coordinates. |
void |
setType(Location location,
Material material)
|
<T extends Entity> |
spawn(Location location,
Class<T> clazz)
Spawn an entity of a specific class at the given
Location |
<T extends Entity> |
spawn(Location location,
Class<T> clazz,
boolean randomizeData,
Consumer<T> function)
Creates a new entity at the given
Location with the supplied
function run before the entity is added to the world. |
<T extends Entity> |
spawn(Location location,
Class<T> clazz,
Consumer<T> function)
Spawn an entity of a specific class at the given
Location , with
the supplied function run before the entity is added to the world. |
Entity |
spawnEntity(Location location,
EntityType type)
Creates a entity at the given
Location |
Entity |
spawnEntity(Location loc,
EntityType type,
boolean randomizeData)
Creates a new entity at the given
Location . |
@NotNull Biome getBiome(@NotNull Location location)
location
- the location of the biome@NotNull Biome getBiome(int x, int y, int z)
Biome
at the given coordinates.x
- X-coordinate of the blocky
- Y-coordinate of the blockz
- Z-coordinate of the blockvoid setBiome(@NotNull Location location, @NotNull Biome biome)
location
- the location of the biomebiome
- New Biome type for this blockvoid setBiome(int x, int y, int z, @NotNull Biome biome)
Biome
for the given block coordinatesx
- X-coordinate of the blocky
- Y-coordinate of the blockz
- Z-coordinate of the blockbiome
- New Biome type for this block@NotNull BlockState getBlockState(@NotNull Location location)
BlockState
at the given Location
.location
- The location of the block state@NotNull BlockState getBlockState(int x, int y, int z)
BlockState
at the given coordinates.x
- X-coordinate of the block statey
- Y-coordinate of the block statez
- Z-coordinate of the block state@NotNull BlockData getBlockData(@NotNull Location location)
location
- The location of the block data@NotNull BlockData getBlockData(int x, int y, int z)
BlockData
at the given coordinates.x
- X-coordinate of the block datay
- Y-coordinate of the block dataz
- Z-coordinate of the block data@NotNull Material getType(@NotNull Location location)
Location
.location
- The location of the block@NotNull Material getType(int x, int y, int z)
x
- X-coordinate of the blocky
- Y-coordinate of the blockz
- Z-coordinate of the blockvoid setBlockData(@NotNull Location location, @NotNull BlockData blockData)
location
- The location of the blockblockData
- The block data to set the block tovoid setBlockData(int x, int y, int z, @NotNull BlockData blockData)
BlockData
at the given coordinates.x
- X-coordinate of the blocky
- Y-coordinate of the blockz
- Z-coordinate of the blockblockData
- The block data to set the block tovoid setType(@NotNull Location location, @NotNull Material material)
location
- The location of the blockmaterial
- The type to set the block tovoid setType(int x, int y, int z, @NotNull Material material)
Material
at the given coordinates.x
- X-coordinate of the blocky
- Y-coordinate of the blockz
- Z-coordinate of the blockmaterial
- The type to set the block toboolean generateTree(@NotNull Location location, @NotNull Random random, @NotNull TreeType type)
Location
location
- Location to spawn the treerandom
- Random to use to generated the treetype
- Type of the tree to createboolean generateTree(@NotNull Location location, @NotNull Random random, @NotNull TreeType type, @Nullable Consumer<BlockState> stateConsumer)
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
getBlockState(Location)
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()
location
- Location to spawn the treerandom
- Random to use to generated the treetype
- Type of the tree to createstateConsumer
- The consumer which should get called for every block which gets changedboolean generateTree(@NotNull Location location, @NotNull Random random, @NotNull TreeType type, @Nullable Predicate<BlockState> statePredicate)
Location
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
getBlockState(Location)
in the predicate will return the state
of the block before the generation.
If the predicate returns true
the block gets set in the world.
If it returns false
the block won't get set in the world.
location
- Location to spawn the treerandom
- Random to use to generated the treetype
- Type of the tree to createstatePredicate
- The predicate which should get used to test if a block should be set or not.@NotNull Entity spawnEntity(@NotNull Location location, @NotNull EntityType type)
Location
location
- The location to spawn the entitytype
- The entity to spawn@NotNull Entity spawnEntity(@NotNull Location loc, @NotNull EntityType type, boolean randomizeData)
Location
.loc
- the location at which the entity will be spawned.type
- the entity type that determines the entity to spawn.randomizeData
- whether or not the entity'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 enchantments on the equipment of mobs
or even a zombie becoming a chicken jockey.
If set to false, the entity will not be randomised
before spawning, meaning all their data will remain
in their default state and not further modifications
to the entity 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 entity.@NotNull List<Entity> getEntities()
@NotNull List<LivingEntity> getLivingEntities()
@NotNull <T extends Entity> Collection<T> getEntitiesByClass(@NotNull Class<T> cls)
T
- an entity subclasscls
- The class representing the type of entity to match@NotNull Collection<Entity> getEntitiesByClasses(@NotNull Class<?>... classes)
classes
- The classes representing the types of entity to match@NotNull <T extends Entity> T spawn(@NotNull Location location, @NotNull Class<T> clazz) throws IllegalArgumentException
Location
T
- the class of the Entity
to spawnlocation
- the Location
to spawn the entity atclazz
- the class of the Entity
to spawnEntity
IllegalArgumentException
- if either parameter is null or the
Entity
requested cannot be spawned@NotNull <T extends Entity> T spawn(@NotNull Location location, @NotNull Class<T> clazz, @Nullable Consumer<T> function) throws IllegalArgumentException
Location
, with
the supplied function run before the entity is added to the world.
T
- the class of the Entity
to spawnlocation
- the Location
to spawn the entity atclazz
- the class of the Entity
to spawnfunction
- the function to be run before the entity is spawned.Entity
IllegalArgumentException
- if either parameter is null or the
Entity
requested cannot be spawned@NotNull <T extends Entity> T spawn(@NotNull Location location, @NotNull Class<T> clazz, boolean randomizeData, @Nullable Consumer<T> function) throws IllegalArgumentException
Location
with the supplied
function run before the entity is added to the world.
T
- the generic type of the entity that is being created.location
- the location at which the entity will be spawned.clazz
- the class of the Entity
that is to be spawned.randomizeData
- whether or not the entity'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 enchantments on the equipment of mobs
or even a zombie becoming a chicken jockey.
If set to false, the entity will not be randomised
before spawning, meaning all their data will remain
in their default state and not further modifications
to the entity 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 entity.function
- the function to be run before the entity is spawned.IllegalArgumentException
- if either the world or clazz parameter are null.Copyright © 2022. All rights reserved.