Search in sources :

Example 21 with ChunkPos

use of net.minecraft.world.level.ChunkPos 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();
    }
}
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) ChunkPos(net.minecraft.world.level.ChunkPos) CraftChunk(org.bukkit.craftbukkit.v1_18_R1.CraftChunk) BiomeNMSImpl(com.denizenscript.denizen.nms.v1_18.impl.BiomeNMSImpl)

Example 22 with ChunkPos

use of net.minecraft.world.level.ChunkPos in project Denizen-For-Bukkit by DenizenScript.

the class BlockLightImpl method sendSingleChunkUpdate.

public static void sendSingleChunkUpdate(LevelChunk chunk) {
    doNotCheck = true;
    LevelLightEngine lightEngine = chunk.getLevel().getChunkSource().getLightEngine();
    ChunkPos pos = chunk.getPos();
    // TODO: 1.16: should 'trust edges' be true here?
    ClientboundLightUpdatePacket packet = new ClientboundLightUpdatePacket(pos, lightEngine, null, null, true);
    ((ServerChunkCache) chunk.getLevel().getChunkSource()).chunkMap.getPlayers(pos, false).forEach((player) -> {
        player.connection.send(packet);
    });
    doNotCheck = false;
}
Also used : ThreadedLevelLightEngine(net.minecraft.server.level.ThreadedLevelLightEngine) LevelLightEngine(net.minecraft.world.level.lighting.LevelLightEngine) ClientboundLightUpdatePacket(net.minecraft.network.protocol.game.ClientboundLightUpdatePacket) ChunkPos(net.minecraft.world.level.ChunkPos) ServerChunkCache(net.minecraft.server.level.ServerChunkCache)

Example 23 with ChunkPos

use of net.minecraft.world.level.ChunkPos in project Tropicraft by Tropicraft.

the class TropicraftChunkGenerator method fillFromNoise.

@Override
public CompletableFuture<ChunkAccess> fillFromNoise(Executor executor, StructureFeatureManager structures, ChunkAccess chunk) {
    CompletableFuture<ChunkAccess> future = super.fillFromNoise(executor, structures, chunk);
    return future.thenApply(chunkAccess -> {
        ChunkPos chunkPos = chunk.getPos();
        WorldgenRandom random = new WorldgenRandom(this.seed);
        volcano.generate(chunkPos.x, chunkPos.z, chunk, random);
        return chunkAccess;
    });
}
Also used : ChunkAccess(net.minecraft.world.level.chunk.ChunkAccess) ChunkPos(net.minecraft.world.level.ChunkPos) WorldgenRandom(net.minecraft.world.level.levelgen.WorldgenRandom)

Aggregations

ChunkPos (net.minecraft.world.level.ChunkPos)23 BlockPos (net.minecraft.core.BlockPos)12 Level (net.minecraft.world.level.Level)8 Vector3d (org.spongepowered.math.vector.Vector3d)6 ServerLevel (net.minecraft.server.level.ServerLevel)5 Map (java.util.Map)4 ServerChunkCache (net.minecraft.server.level.ServerChunkCache)4 LevelChunk (net.minecraft.world.level.chunk.LevelChunk)4 Collection (java.util.Collection)3 Objects (java.util.Objects)3 UUID (java.util.UUID)3 Stream (java.util.stream.Stream)3 BlockState (net.minecraft.world.level.block.state.BlockState)3 LongIterator (it.unimi.dsi.fastutil.longs.LongIterator)2 IOException (java.io.IOException)2 WeakReference (java.lang.ref.WeakReference)2 Set (java.util.Set)2 ClientboundLightUpdatePacket (net.minecraft.network.protocol.game.ClientboundLightUpdatePacket)2 ThreadedLevelLightEngine (net.minecraft.server.level.ThreadedLevelLightEngine)2 ChunkProgressListener (net.minecraft.server.level.progress.ChunkProgressListener)2