Search in sources :

Example 1 with BiomeNMSImpl

use of com.denizenscript.denizen.nms.v1_19.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();
    Holder<Biome> biome = level.getNoiseBiome(block.getX() >> 2, block.getY() >> 2, block.getZ() >> 2);
    ResourceLocation key = level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY).getKey(biome.value());
    String keyText = key.getNamespace().equals("minecraft") ? key.getPath() : key.toString();
    return new BiomeNMSImpl(level, keyText);
}
Also used : ServerLevel(net.minecraft.server.level.ServerLevel) Biome(net.minecraft.world.level.biome.Biome) ResourceLocation(net.minecraft.resources.ResourceLocation) CraftWorld(org.bukkit.craftbukkit.v1_18_R2.CraftWorld) BiomeNMSImpl(com.denizenscript.denizen.nms.v1_18.impl.BiomeNMSImpl)

Example 2 with BiomeNMSImpl

use of com.denizenscript.denizen.nms.v1_19.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;
}
Also used : ServerLevel(net.minecraft.server.level.ServerLevel) Biome(net.minecraft.world.level.biome.Biome) ArrayList(java.util.ArrayList) CraftWorld(org.bukkit.craftbukkit.v1_17_R1.CraftWorld) Map(java.util.Map) ResourceKey(net.minecraft.resources.ResourceKey) BiomeNMSImpl(com.denizenscript.denizen.nms.v1_17.impl.BiomeNMSImpl)

Example 3 with BiomeNMSImpl

use of com.denizenscript.denizen.nms.v1_19.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);
}
Also used : ServerLevel(net.minecraft.server.level.ServerLevel) Biome(net.minecraft.world.level.biome.Biome) ResourceLocation(net.minecraft.resources.ResourceLocation) CraftWorld(org.bukkit.craftbukkit.v1_17_R1.CraftWorld) BiomeNMSImpl(com.denizenscript.denizen.nms.v1_17.impl.BiomeNMSImpl)

Example 4 with BiomeNMSImpl

use of com.denizenscript.denizen.nms.v1_19.impl.BiomeNMSImpl in project Denizen by DenizenScript.

the class ChunkHelperImpl method setAllBiomes.

@Override
public void setAllBiomes(Chunk chunk, BiomeNMS biome) {
    Holder<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<Holder<Biome>> datapaletteblock = (PalettedContainer<Holder<Biome>>) 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();
    }
}
Also used : LevelHeightAccessor(net.minecraft.world.level.LevelHeightAccessor) Biome(net.minecraft.world.level.biome.Biome) LevelChunk(net.minecraft.world.level.chunk.LevelChunk) LevelChunkSection(net.minecraft.world.level.chunk.LevelChunkSection) Holder(net.minecraft.core.Holder) ChunkPos(net.minecraft.world.level.ChunkPos) CraftChunk(org.bukkit.craftbukkit.v1_19_R1.CraftChunk) BiomeNMSImpl(com.denizenscript.denizen.nms.v1_19.impl.BiomeNMSImpl) PalettedContainer(net.minecraft.world.level.chunk.PalettedContainer)

Example 5 with BiomeNMSImpl

use of com.denizenscript.denizen.nms.v1_19.impl.BiomeNMSImpl in project Denizen 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;
}
Also used : ServerLevel(net.minecraft.server.level.ServerLevel) Biome(net.minecraft.world.level.biome.Biome) ArrayList(java.util.ArrayList) CraftWorld(org.bukkit.craftbukkit.v1_19_R1.CraftWorld) Map(java.util.Map) ResourceKey(net.minecraft.resources.ResourceKey) BiomeNMSImpl(com.denizenscript.denizen.nms.v1_19.impl.BiomeNMSImpl)

Aggregations

Biome (net.minecraft.world.level.biome.Biome)15 ServerLevel (net.minecraft.server.level.ServerLevel)10 BiomeNMSImpl (com.denizenscript.denizen.nms.v1_17.impl.BiomeNMSImpl)6 BiomeNMSImpl (com.denizenscript.denizen.nms.v1_18.impl.BiomeNMSImpl)6 ArrayList (java.util.ArrayList)5 Map (java.util.Map)5 ResourceKey (net.minecraft.resources.ResourceKey)5 ResourceLocation (net.minecraft.resources.ResourceLocation)5 LevelChunk (net.minecraft.world.level.chunk.LevelChunk)5 CraftWorld (org.bukkit.craftbukkit.v1_17_R1.CraftWorld)4 CraftWorld (org.bukkit.craftbukkit.v1_18_R2.CraftWorld)4 BiomeNMSImpl (com.denizenscript.denizen.nms.v1_19.impl.BiomeNMSImpl)3 Holder (net.minecraft.core.Holder)3 ChunkPos (net.minecraft.world.level.ChunkPos)3 LevelHeightAccessor (net.minecraft.world.level.LevelHeightAccessor)3 LevelChunkSection (net.minecraft.world.level.chunk.LevelChunkSection)3 ChunkBiomeContainer (net.minecraft.world.level.chunk.ChunkBiomeContainer)2 CraftChunk (org.bukkit.craftbukkit.v1_17_R1.CraftChunk)2 CraftChunk (org.bukkit.craftbukkit.v1_18_R2.CraftChunk)2 CraftWorld (org.bukkit.craftbukkit.v1_19_R1.CraftWorld)2