Interface RegionAccessor
- All Known Subinterfaces:
LimitedRegion,World
Biome, BlockState and Entity,
as well as generating some basic structures.-
Method Summary
Modifier and TypeMethodDescriptionbooleangenerateTree(Location location, Random random, TreeType type) Creates a tree at the givenLocationbooleangenerateTree(Location location, Random random, TreeType type, Predicate<BlockState> statePredicate) Creates a tree at the givenLocationbooleangenerateTree(Location location, Random random, TreeType type, Consumer<BlockState> stateConsumer) Creates a tree at the givenLocationgetBiome(int x, int y, int z) Gets theBiomeat the given coordinates.getBlockData(int x, int y, int z) Gets theBlockDataat the given coordinates.getBlockData(Location location) getBlockState(int x, int y, int z) Gets theBlockStateat the given coordinates.getBlockState(Location location) Gets theBlockStateat the givenLocation.Get a list of all entities in this RegionAccessor<T extends Entity>
Collection<T>getEntitiesByClass(Class<T> cls) Get a collection of all entities in this RegionAccessor matching the given class/interfacegetEntitiesByClasses(Class<?>... classes) Get a collection of all entities in this RegionAccessor matching any of the given classes/interfacesGet a list of all living entities in this RegionAccessorgetType(int x, int y, int z) Gets the type of the block at the given coordinates.Gets the type of the block at the givenLocation.voidSets theBiomefor the given block coordinatesvoidvoidsetBlockData(int x, int y, int z, BlockData blockData) Sets theBlockDataat the given coordinates.voidsetBlockData(Location location, BlockData blockData) voidSets theMaterialat the given coordinates.void<T extends Entity>
TSpawn an entity of a specific class at the givenLocation<T extends Entity>
TCreates a new entity at the givenLocationwith the supplied function run before the entity is added to the world.<T extends Entity>
TSpawn an entity of a specific class at the givenLocation, with the supplied function run before the entity is added to the world.spawnEntity(Location location, EntityType type) Creates a entity at the givenLocationspawnEntity(Location loc, EntityType type, boolean randomizeData) Creates a new entity at the givenLocation.
-
Method Details
-
getBiome
- Parameters:
location- the location of the biome- Returns:
- Biome at the given location
-
getBiome
Gets theBiomeat the given coordinates.- Parameters:
x- X-coordinate of the blocky- Y-coordinate of the blockz- Z-coordinate of the block- Returns:
- Biome at the given coordinates
-
setBiome
- Parameters:
location- the location of the biomebiome- New Biome type for this block
-
setBiome
Sets theBiomefor the given block coordinates- Parameters:
x- X-coordinate of the blocky- Y-coordinate of the blockz- Z-coordinate of the blockbiome- New Biome type for this block
-
getBlockState
Gets theBlockStateat the givenLocation.- Parameters:
location- The location of the block state- Returns:
- Block state at the given location
-
getBlockState
Gets theBlockStateat the given coordinates.- Parameters:
x- X-coordinate of the block statey- Y-coordinate of the block statez- Z-coordinate of the block state- Returns:
- Block state at the given coordinates
-
getBlockData
- Parameters:
location- The location of the block data- Returns:
- Block data at the given location
-
getBlockData
Gets theBlockDataat the given coordinates.- Parameters:
x- X-coordinate of the block datay- Y-coordinate of the block dataz- Z-coordinate of the block data- Returns:
- Block data at the given coordinates
-
getType
Gets the type of the block at the givenLocation.- Parameters:
location- The location of the block- Returns:
- Material at the given coordinates
-
getType
Gets the type of the block at the given coordinates.- Parameters:
x- X-coordinate of the blocky- Y-coordinate of the blockz- Z-coordinate of the block- Returns:
- Material at the given coordinates
-
setBlockData
- Parameters:
location- The location of the blockblockData- The block data to set the block to
-
setBlockData
Sets theBlockDataat the given coordinates.- Parameters:
x- X-coordinate of the blocky- Y-coordinate of the blockz- Z-coordinate of the blockblockData- The block data to set the block to
-
setType
- Parameters:
location- The location of the blockmaterial- The type to set the block to
-
setType
Sets theMaterialat the given coordinates.- Parameters:
x- X-coordinate of the blocky- Y-coordinate of the blockz- Z-coordinate of the blockmaterial- The type to set the block to
-
generateTree
Creates a tree at the givenLocation- Parameters:
location- Location to spawn the treerandom- Random to use to generated the treetype- Type of the tree to create- Returns:
- true if the tree was created successfully, otherwise false
-
generateTree
boolean generateTree(@NotNull Location location, @NotNull Random random, @NotNull TreeType type, @Nullable Consumer<BlockState> stateConsumer) Creates a tree at the givenLocationThe 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
BlockStatein the consumer are respected, which means that it is not necessary to callBlockState.update()- Parameters:
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 changed- Returns:
- true if the tree was created successfully, otherwise false
-
generateTree
boolean generateTree(@NotNull Location location, @NotNull Random random, @NotNull TreeType type, @Nullable Predicate<BlockState> statePredicate) Creates a tree at the givenLocationThe 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
truethe block gets set in the world. If it returnsfalsethe block won't get set in the world.- Parameters:
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.- Returns:
- true if the tree was created successfully, otherwise false
-
spawnEntity
Creates a entity at the givenLocation- Parameters:
location- The location to spawn the entitytype- The entity to spawn- Returns:
- Resulting Entity of this method
-
spawnEntity
Creates a new entity at the givenLocation.- Parameters:
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 theMobinterface provide randomisation logic for their spawn. This parameter is hence useless for any other type of entity.- Returns:
- the spawned entity instance.
-
getEntities
Get a list of all entities in this RegionAccessor- Returns:
- A List of all Entities currently residing in this world accessor
-
getLivingEntities
Get a list of all living entities in this RegionAccessor- Returns:
- A List of all LivingEntities currently residing in this world accessor
-
getEntitiesByClass
Get a collection of all entities in this RegionAccessor matching the given class/interface- Type Parameters:
T- an entity subclass- Parameters:
cls- The class representing the type of entity to match- Returns:
- A List of all Entities currently residing in this world accessor that match the given class/interface
-
getEntitiesByClasses
Get a collection of all entities in this RegionAccessor matching any of the given classes/interfaces- Parameters:
classes- The classes representing the types of entity to match- Returns:
- A List of all Entities currently residing in this world accessor that match one or more of the given classes/interfaces
-
spawn
@NotNull <T extends Entity> T spawn(@NotNull Location location, @NotNull Class<T> clazz) throws IllegalArgumentException Spawn an entity of a specific class at the givenLocation- Type Parameters:
T- the class of theEntityto spawn- Parameters:
location- theLocationto spawn the entity atclazz- the class of theEntityto spawn- Returns:
- an instance of the spawned
Entity - Throws:
IllegalArgumentException- if either parameter is null or theEntityrequested cannot be spawned
-
spawn
@NotNull <T extends Entity> T spawn(@NotNull Location location, @NotNull Class<T> clazz, @Nullable Consumer<T> function) throws IllegalArgumentException Spawn an entity of a specific class at the givenLocation, with the supplied function run before the entity is added to the world.
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.- Type Parameters:
T- the class of theEntityto spawn- Parameters:
location- theLocationto spawn the entity atclazz- the class of theEntityto spawnfunction- the function to be run before the entity is spawned.- Returns:
- an instance of the spawned
Entity - Throws:
IllegalArgumentException- if either parameter is null or theEntityrequested cannot be spawned
-
spawn
@NotNull <T extends Entity> T spawn(@NotNull Location location, @NotNull Class<T> clazz, boolean randomizeData, @Nullable Consumer<T> function) throws IllegalArgumentException Creates a new entity at the givenLocationwith the supplied function run before the entity is added to the world.
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.- Type Parameters:
T- the generic type of the entity that is being created.- Parameters:
location- the location at which the entity will be spawned.clazz- the class of theEntitythat 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 theMobinterface 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.- Returns:
- the spawned entity instance.
- Throws:
IllegalArgumentException- if either the world or clazz parameter are null.
-