Interface WorldGenAccess
- All Known Implementing Classes:
BukkitWorldGenAccess, NMSWorldGenAccess
This interface is designed to safely expose block and entity manipulation in contexts where direct Bukkit API usage may be unsafe or restricted (such as async chunk generation or custom world pipelines).
Implementations may:
- Buffer writes instead of applying them immediately
- Bypass Bukkit thread restrictions
- Operate on custom world representations
All coordinates are expected to be in absolute world space unless otherwise stated.
-
Method Summary
Modifier and TypeMethodDescription@Nullable org.bukkit.entity.EntityaddEntity(double x, double y, double z, @NotNull SavedEntity entity) Spawns aSavedEntityat the given coordinates.voidaddEntity(double x, double y, double z, @NotNull CustomEntity<?> entity) Spawns aCustomEntityat the given coordinates.@NotNull org.bukkit.entity.EntityaddEntity(double x, double y, double z, @NotNull org.bukkit.entity.EntityType type) Spawns a vanillaEntityat the given coordinates.@NotNull org.bukkit.block.BiomegetBiome(int x, int y, int z) Retrieves theBiomeat the given coordinates.@NotNull org.bukkit.block.data.BlockDatagetBlockData(int x, int y, int z) Retrieves theBlockDataat the given coordinates.@NotNull org.bukkit.block.BlockStategetBlockState(int x, int y, int z) Retrieves a snapshotBlockStateat the given coordinates.intgetHighestBlockY(int x, int z, org.bukkit.HeightMap heightMap) Retrieves the highest Y coordinate at the given X/Z position based on aHeightMap.@NotNull RandomReturns theRandominstance used for this generation pass.@NotNull org.bukkit.MaterialgetType(int x, int y, int z) Retrieves theMaterialat the given coordinates.@NotNull org.bukkit.WorldgetWorld()Returns the backingWorldinstance.voidsetBlock(int x, int y, int z, @NotNull CustomBlock block) Places aCustomBlockat the given coordinates.voidsetBlock(int x, int y, int z, @NotNull CustomBlock block, @NotNull org.bukkit.block.data.BlockData data) Places aCustomBlockwith explicitBlockData.voidsetBlock(int x, int y, int z, @NotNull org.bukkit.Material material) Sets a block at the given coordinates using aMaterial.voidsetBlock(int x, int y, int z, @NotNull org.bukkit.block.data.BlockData data) Sets a block at the given coordinates using fullBlockData.
-
Method Details
-
setBlock
void setBlock(int x, int y, int z, @NotNull @NotNull org.bukkit.Material material) Sets a block at the given coordinates using aMaterial.This replaces any existing block at the target position.
- Parameters:
x- The absolute X coordinatey- The absolute Y coordinatez- The absolute Z coordinatematerial- The material to place (must represent a valid block)
-
setBlock
void setBlock(int x, int y, int z, @NotNull @NotNull org.bukkit.block.data.BlockData data) Sets a block at the given coordinates using fullBlockData.This allows specifying block states such as orientation, waterlogging, etc.
- Parameters:
x- The absolute X coordinatey- The absolute Y coordinatez- The absolute Z coordinatedata- The block data to apply
-
setBlock
Places aCustomBlockat the given coordinates.The implementation is responsible for correctly initializing any associated custom logic, metadata, or block entities.
- Parameters:
x- The absolute X coordinatey- The absolute Y coordinatez- The absolute Z coordinateblock- The custom block instance to place
-
setBlock
void setBlock(int x, int y, int z, @NotNull @NotNull CustomBlock block, @NotNull @NotNull org.bukkit.block.data.BlockData data) Places aCustomBlockwith explicitBlockData.This allows combining custom logic with a specific visual or state configuration.
- Parameters:
x- The absolute X coordinatey- The absolute Y coordinatez- The absolute Z coordinateblock- The custom block instancedata- The block data defining its visual/state configuration
-
addEntity
@NotNull @NotNull org.bukkit.entity.Entity addEntity(double x, double y, double z, @NotNull @NotNull org.bukkit.entity.EntityType type) Spawns a vanillaEntityat the given coordinates.Implementations must ensure this operation is safe within the generation context (e.g. deferred execution if required by threading constraints).
- Parameters:
x- The absolute X coordinate (double precision)y- The absolute Y coordinate (double precision)z- The absolute Z coordinate (double precision)type- TheEntityTypeto spawn- Returns:
- The created entity instance
-
addEntity
Spawns aCustomEntityat the given coordinates.The provided entity acts as a template and should be instantiated according to its internal logic.
- Parameters:
x- The absolute X coordinate (double precision)y- The absolute Y coordinate (double precision)z- The absolute Z coordinate (double precision)entity- The custom entity template
-
addEntity
@Nullable @Nullable org.bukkit.entity.Entity addEntity(double x, double y, double z, @NotNull @NotNull SavedEntity entity) Spawns aSavedEntityat the given coordinates.This typically restores an entity from serialized data (NBT or similar).
- Parameters:
x- The absolute X coordinate (double precision)y- The absolute Y coordinate (double precision)z- The absolute Z coordinate (double precision)entity- The saved entity definition- Returns:
- The spawned entity instance, or
nullif spawning failed
-
getType
@NotNull @NotNull org.bukkit.Material getType(int x, int y, int z) Retrieves theMaterialat the given coordinates.- Parameters:
x- The absolute X coordinatey- The absolute Y coordinatez- The absolute Z coordinate- Returns:
- The material at the specified position
-
getBlockData
@NotNull @NotNull org.bukkit.block.data.BlockData getBlockData(int x, int y, int z) Retrieves theBlockDataat the given coordinates.- Parameters:
x- The absolute X coordinatey- The absolute Y coordinatez- The absolute Z coordinate- Returns:
- The block data at the specified position
-
getBlockState
@NotNull @NotNull org.bukkit.block.BlockState getBlockState(int x, int y, int z) Retrieves a snapshotBlockStateat the given coordinates.This includes tile entity data where applicable.
- Parameters:
x- The absolute X coordinatey- The absolute Y coordinatez- The absolute Z coordinate- Returns:
- The block state snapshot
-
getBiome
@NotNull @NotNull org.bukkit.block.Biome getBiome(int x, int y, int z) Retrieves theBiomeat the given coordinates.- Parameters:
x- The absolute X coordinatey- The absolute Y coordinatez- The absolute Z coordinate- Returns:
- The biome at the specified position
-
getHighestBlockY
int getHighestBlockY(int x, int z, org.bukkit.HeightMap heightMap) Retrieves the highest Y coordinate at the given X/Z position based on aHeightMap.The result depends on the selected heightmap type (e.g. surface, ocean floor).
- Parameters:
x- The absolute X coordinatez- The absolute Z coordinateheightMap- The height map type to query- Returns:
- The highest Y coordinate matching the height map criteria
-
getWorld
@NotNull @NotNull org.bukkit.World getWorld()Returns the backingWorldinstance.Note that direct interaction with the returned world may not always be safe depending on the implementation context.
- Returns:
- The world associated with this generation access
-
getRandom
-