Search in sources :

Example 26 with CraftChunk

use of org.bukkit.craftbukkit.v1_9_R1.CraftChunk in project MagicPlugin by elBukkit.

the class CompatibilityUtils method setBlockFast.

@Override
public boolean setBlockFast(Chunk chunk, int x, int y, int z, Material material, int data) {
    LevelChunk nmsChunk = ((CraftChunk) chunk).getHandle();
    net.minecraft.world.level.block.Block block = CraftMagicNumbers.getBlock(material);
    BlockPos blockLocation = new BlockPos(x, y, z);
    nmsChunk.setBlockState(blockLocation, block.defaultBlockState(), false);
    return true;
}
Also used : LevelChunk(net.minecraft.world.level.chunk.LevelChunk) BlockPos(net.minecraft.core.BlockPos) CraftChunk(org.bukkit.craftbukkit.v1_17_R1.CraftChunk)

Example 27 with CraftChunk

use of org.bukkit.craftbukkit.v1_9_R1.CraftChunk in project MagicPlugin by elBukkit.

the class CompatibilityUtils method setBlockFast.

@Override
public boolean setBlockFast(Chunk chunk, int x, int y, int z, Material material, int data) {
    LevelChunk nmsChunk = ((CraftChunk) chunk).getHandle();
    net.minecraft.world.level.block.Block block = CraftMagicNumbers.getBlock(material);
    BlockPos blockLocation = new BlockPos(x, y, z);
    nmsChunk.setBlockState(blockLocation, block.defaultBlockState(), false);
    return true;
}
Also used : LevelChunk(net.minecraft.world.level.chunk.LevelChunk) BlockPos(net.minecraft.core.BlockPos) CraftChunk(org.bukkit.craftbukkit.v1_18_R1.CraftChunk)

Example 28 with CraftChunk

use of org.bukkit.craftbukkit.v1_9_R1.CraftChunk in project FastAsyncWorldEdit by IntellectualSites.

the class PaperweightPlatformAdapter method ensureLoaded.

public static LevelChunk ensureLoaded(ServerLevel serverLevel, int chunkX, int chunkZ) {
    if (!PaperLib.isPaper()) {
        LevelChunk nmsChunk = serverLevel.getChunkSource().getChunk(chunkX, chunkZ, false);
        if (nmsChunk != null) {
            return nmsChunk;
        }
        if (Fawe.isMainThread()) {
            return serverLevel.getChunk(chunkX, chunkZ);
        }
    } else {
        LevelChunk nmsChunk = serverLevel.getChunkSource().getChunkAtIfCachedImmediately(chunkX, chunkZ);
        if (nmsChunk != null) {
            return nmsChunk;
        }
        nmsChunk = serverLevel.getChunkSource().getChunkAtIfLoadedImmediately(chunkX, chunkZ);
        if (nmsChunk != null) {
            return nmsChunk;
        }
        // Avoid "async" methods from the main thread.
        if (Fawe.isMainThread()) {
            return serverLevel.getChunk(chunkX, chunkZ);
        }
        CompletableFuture<org.bukkit.Chunk> future = serverLevel.getWorld().getChunkAtAsync(chunkX, chunkZ, true, true);
        try {
            CraftChunk chunk = (CraftChunk) future.get();
            return chunk.getHandle();
        } catch (Throwable e) {
            e.printStackTrace();
        }
    }
    return TaskManager.taskManager().sync(() -> serverLevel.getChunk(chunkX, chunkZ));
}
Also used : LevelChunk(net.minecraft.world.level.chunk.LevelChunk) LevelChunk(net.minecraft.world.level.chunk.LevelChunk) CraftChunk(org.bukkit.craftbukkit.v1_17_R1.CraftChunk) CraftChunk(org.bukkit.craftbukkit.v1_17_R1.CraftChunk)

Example 29 with CraftChunk

use of org.bukkit.craftbukkit.v1_9_R1.CraftChunk 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 30 with CraftChunk

use of org.bukkit.craftbukkit.v1_9_R1.CraftChunk in project Denizen by DenizenScript.

the class ChunkHelperImpl method getHeightMap.

@Override
public int[] getHeightMap(Chunk chunk) {
    Heightmap map = ((CraftChunk) chunk).getHandle().heightmaps.get(Heightmap.Types.MOTION_BLOCKING);
    int[] outputMap = new int[256];
    for (int x = 0; x < 16; x++) {
        for (int y = 0; y < 16; y++) {
            outputMap[x * 16 + y] = map.getFirstAvailable(x, y);
        }
    }
    return outputMap;
}
Also used : Heightmap(net.minecraft.world.level.levelgen.Heightmap) CraftChunk(org.bukkit.craftbukkit.v1_19_R1.CraftChunk)

Aggregations

LevelChunk (net.minecraft.world.level.chunk.LevelChunk)17 Material (org.bukkit.Material)14 World (org.bukkit.World)12 NMSTileEntitySet (com.loohp.interactionvisualizer.objectholders.NMSTileEntitySet)11 TileEntity (com.loohp.interactionvisualizer.objectholders.TileEntity)11 TileEntityType (com.loohp.interactionvisualizer.objectholders.TileEntity.TileEntityType)11 BlockPos (net.minecraft.core.BlockPos)11 Location (org.bukkit.Location)11 ArrayList (java.util.ArrayList)9 List (java.util.List)9 CraftChunk (org.bukkit.craftbukkit.v1_17_R1.CraftChunk)9 CraftChunk (org.bukkit.craftbukkit.v1_18_R2.CraftChunk)9 WildLoadersPlugin (com.bgsoftware.wildloaders.WildLoadersPlugin)8 Hologram (com.bgsoftware.wildloaders.api.holograms.Hologram)8 ChunkLoader (com.bgsoftware.wildloaders.api.loaders.ChunkLoader)8 ChunkLoaderNPC (com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC)8 ITileEntityChunkLoader (com.bgsoftware.wildloaders.loaders.ITileEntityChunkLoader)8 WChunkLoader (com.bgsoftware.wildloaders.loaders.WChunkLoader)8 Collection (java.util.Collection)8 Collections (java.util.Collections)8