use of com.denizenscript.denizen.nms.v1_17.impl.BiomeNMSImpl in project Denizen-For-Bukkit by DenizenScript.
the class Handler method getBiomes.
@Override
public List<BiomeNMS> getBiomes(World world) {
ServerLevel level = ((CraftWorld) world).getHandle();
ArrayList<BiomeNMS> output = new ArrayList<>();
for (Map.Entry<ResourceKey<Biome>, Biome> pair : level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY).entrySet()) {
output.add(new BiomeNMSImpl(level, pair.getKey().location().toString()));
}
return output;
}
use of com.denizenscript.denizen.nms.v1_17.impl.BiomeNMSImpl in project Denizen-For-Bukkit by DenizenScript.
the class Handler method getBiomeAt.
@Override
public BiomeNMS getBiomeAt(Block block) {
// Based on CraftWorld source
ServerLevel level = ((CraftWorld) block.getWorld()).getHandle();
Biome biome = level.getNoiseBiome(block.getX() >> 2, block.getY() >> 2, block.getZ() >> 2);
ResourceLocation key = level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY).getKey(biome);
String keyText = key.getNamespace().equals("minecraft") ? key.getPath() : key.toString();
return new BiomeNMSImpl(level, keyText);
}
use of com.denizenscript.denizen.nms.v1_17.impl.BiomeNMSImpl in project Denizen-For-Bukkit by DenizenScript.
the class Handler method getBiomeAt.
@Override
public BiomeNMS getBiomeAt(Block block) {
// Based on CraftWorld source
ServerLevel level = ((CraftWorld) block.getWorld()).getHandle();
Biome biome = level.getNoiseBiome(block.getX() >> 2, block.getY() >> 2, block.getZ() >> 2);
ResourceLocation key = level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY).getKey(biome);
String keyText = key.getNamespace().equals("minecraft") ? key.getPath() : key.toString();
return new BiomeNMSImpl(level, keyText);
}
use of com.denizenscript.denizen.nms.v1_17.impl.BiomeNMSImpl in project Denizen-For-Bukkit by DenizenScript.
the class ChunkHelperImpl method setAllBiomes.
@Override
public void setAllBiomes(Chunk chunk, BiomeNMS biome) {
Biome nmsBiome = ((BiomeNMSImpl) biome).biomeBase;
LevelChunk nmsChunk = ((CraftChunk) chunk).getHandle();
ChunkBiomeContainer biomeContainer = nmsChunk.getBiomes();
for (int x = 0; x < 4; x++) {
for (int y = 0; y < 64; y++) {
for (int z = 0; z < 4; z++) {
biomeContainer.setBiome(x, y, z, nmsBiome);
}
}
}
nmsChunk.markUnsaved();
}
use of com.denizenscript.denizen.nms.v1_17.impl.BiomeNMSImpl in project Denizen-For-Bukkit by DenizenScript.
the class ChunkHelperImpl method setAllBiomes.
@Override
public void setAllBiomes(Chunk chunk, BiomeNMS biome) {
Biome nmsBiome = ((BiomeNMSImpl) biome).biomeBase;
LevelChunk nmsChunk = ((CraftChunk) chunk).getHandle();
ChunkPos chunkcoordintpair = nmsChunk.getPos();
int i = QuartPos.fromBlock(chunkcoordintpair.getMinBlockX());
int j = QuartPos.fromBlock(chunkcoordintpair.getMinBlockZ());
LevelHeightAccessor levelheightaccessor = nmsChunk.getHeightAccessorForGeneration();
for (int k = levelheightaccessor.getMinSection(); k < levelheightaccessor.getMaxSection(); ++k) {
LevelChunkSection chunksection = nmsChunk.getSection(nmsChunk.getSectionIndexFromSectionY(k));
PalettedContainer<Biome> datapaletteblock = chunksection.getBiomes();
datapaletteblock.acquire();
for (int l = 0; l < 4; ++l) {
for (int i1 = 0; i1 < 4; ++i1) {
for (int j1 = 0; j1 < 4; ++j1) {
datapaletteblock.getAndSetUnchecked(l, i1, j1, nmsBiome);
}
}
}
datapaletteblock.release();
}
}
Aggregations