Class NMSWorldGenAccess
java.lang.Object
com.github.darksoulq.abyssallib.world.gen.NMSWorldGenAccess
- All Implemented Interfaces:
WorldGenAccess
Implementation of
WorldGenAccess backed by NMS (Native Minecraft Server).
This class provides high-performance world access during chunk generation by
interacting directly with WorldGenLevel, while maintaining thread safety
through the use of LimitedRegion.
It is designed specifically for use in terrain generation, structure placement, and other population phases where standard Bukkit API access is restricted.
-
Constructor Summary
ConstructorsConstructorDescriptionNMSWorldGenAccess(org.bukkit.generator.LimitedRegion region, org.bukkit.World world, Random random) Creates a new NMS-backed world generation access instance. -
Method Summary
Modifier and TypeMethodDescription@Nullable org.bukkit.entity.EntityaddEntity(double x, double y, double z, @NotNull SavedEntity entity) Spawns aSavedEntity.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 vanilla entity safely within the generation region.@NotNull org.bukkit.block.BiomegetBiome(int x, int y, int z) Gets the biome at a position.@NotNull org.bukkit.block.data.BlockDatagetBlockData(int x, int y, int z) Gets theBlockDataat a position.@NotNull org.bukkit.block.BlockStategetBlockState(int x, int y, int z) Retrieves the fullBlockStateusing the safeLimitedRegion.intgetHighestBlockY(int x, int z, org.bukkit.HeightMap heightMap) Gets the highest Y value at a position using aHeightMap.@NotNull RandomGets the random instance used for generation.@NotNull org.bukkit.MaterialgetType(int x, int y, int z) Gets the material at a position.@NotNull org.bukkit.WorldgetWorld()Gets the Bukkit world.booleanisInRegion(int x, int y, int z) Checks if the given coordinate is within this generation regionvoidsetBlock(int x, int y, int z, @NotNull CustomBlock block) Places aCustomBlockusing its default block data.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 using aMaterial.voidsetBlock(int x, int y, int z, @NotNull org.bukkit.block.data.BlockData data) Sets a block usingBlockData.
-
Constructor Details
-
NMSWorldGenAccess
public NMSWorldGenAccess(org.bukkit.generator.LimitedRegion region, org.bukkit.World world, Random random) Creates a new NMS-backed world generation access instance.- Parameters:
region- The limited region for safe block/entity accessworld- The Bukkit world being generatedrandom- The random instance for this generation pass
-
-
Method Details
-
isInRegion
public boolean isInRegion(int x, int y, int z) Checks if the given coordinate is within this generation region- Parameters:
x- X coordinatey- Y Coordinatez- Z Coordinate- Returns:
- Whether the coordinate is in region or not
-
setBlock
public void setBlock(int x, int y, int z, @NotNull @NotNull org.bukkit.Material material) Sets a block using aMaterial.- Specified by:
setBlockin interfaceWorldGenAccess- Parameters:
x- X coordinatey- Y coordinatez- Z coordinatematerial- Material to place
-
setBlock
public void setBlock(int x, int y, int z, @NotNull @NotNull org.bukkit.block.data.BlockData data) Sets a block usingBlockData.- Specified by:
setBlockin interfaceWorldGenAccess- Parameters:
x- X coordinatey- Y coordinatez- Z coordinatedata- Block data to apply
-
setBlock
Places aCustomBlockusing its default block data.- Specified by:
setBlockin interfaceWorldGenAccess- Parameters:
x- X coordinatey- Y coordinatez- Z coordinateblock- Custom block instance
-
setBlock
public void setBlock(int x, int y, int z, @NotNull @NotNull CustomBlock block, @NotNull @NotNull org.bukkit.block.data.BlockData data) Places aCustomBlockwith explicitBlockData.The base block is placed first, then custom logic is applied via a virtual wrapper.
- Specified by:
setBlockin interfaceWorldGenAccess- Parameters:
x- X coordinatey- Y coordinatez- Z coordinateblock- Custom block instancedata- Block data to apply
-
addEntity
@NotNull public @NotNull org.bukkit.entity.Entity addEntity(double x, double y, double z, @NotNull @NotNull org.bukkit.entity.EntityType type) Spawns a vanilla entity safely within the generation region.- Specified by:
addEntityin interfaceWorldGenAccess- Parameters:
x- X coordinatey- Y coordinatez- Z coordinatetype- Entity type- Returns:
- Spawned entity
-
addEntity
Spawns aCustomEntityat the given coordinates.- Specified by:
addEntityin interfaceWorldGenAccess- Parameters:
x- X coordinatey- Y coordinatez- Z coordinateentity- Custom entity instance
-
addEntity
@Nullable public @Nullable org.bukkit.entity.Entity addEntity(double x, double y, double z, @NotNull @NotNull SavedEntity entity) Spawns aSavedEntity.- Specified by:
addEntityin interfaceWorldGenAccess- Parameters:
x- X coordinatey- Y coordinatez- Z coordinateentity- Saved entity definition- Returns:
- Spawned entity or
nullif failed
-
getType
@NotNull public @NotNull org.bukkit.Material getType(int x, int y, int z) Gets the material at a position.- Specified by:
getTypein interfaceWorldGenAccess- Parameters:
x- X coordinatey- Y coordinatez- Z coordinate- Returns:
- Material at location
-
getBlockData
@NotNull public @NotNull org.bukkit.block.data.BlockData getBlockData(int x, int y, int z) Gets theBlockDataat a position.- Specified by:
getBlockDatain interfaceWorldGenAccess- Parameters:
x- X coordinatey- Y coordinatez- Z coordinate- Returns:
- Block data
-
getBlockState
@NotNull public @NotNull org.bukkit.block.BlockState getBlockState(int x, int y, int z) Retrieves the fullBlockStateusing the safeLimitedRegion.- Specified by:
getBlockStatein interfaceWorldGenAccess- Parameters:
x- X coordinatey- Y coordinatez- Z coordinate- Returns:
- Block state snapshot
-
getBiome
@NotNull public @NotNull org.bukkit.block.Biome getBiome(int x, int y, int z) Gets the biome at a position.- Specified by:
getBiomein interfaceWorldGenAccess- Parameters:
x- X coordinatey- Y coordinatez- Z coordinate- Returns:
- Biome
-
getHighestBlockY
public int getHighestBlockY(int x, int z, org.bukkit.HeightMap heightMap) Gets the highest Y value at a position using aHeightMap.- Specified by:
getHighestBlockYin interfaceWorldGenAccess- Parameters:
x- X coordinatez- Z coordinateheightMap- Heightmap type- Returns:
- Highest Y coordinate
-
getWorld
@NotNull public @NotNull org.bukkit.World getWorld()Gets the Bukkit world.- Specified by:
getWorldin interfaceWorldGenAccess- Returns:
- World instance
-
getRandom
Gets the random instance used for generation.- Specified by:
getRandomin interfaceWorldGenAccess- Returns:
- Random instance
-