Search in sources :

Example 36 with CraftChunk

use of org.bukkit.craftbukkit.v1_17_R1.CraftChunk in project Denizen 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();
}
Also used : Biome(net.minecraft.world.level.biome.Biome) LevelChunk(net.minecraft.world.level.chunk.LevelChunk) CraftChunk(org.bukkit.craftbukkit.v1_17_R1.CraftChunk) ChunkBiomeContainer(net.minecraft.world.level.chunk.ChunkBiomeContainer) BiomeNMSImpl(com.denizenscript.denizen.nms.v1_17.impl.BiomeNMSImpl)

Example 37 with CraftChunk

use of org.bukkit.craftbukkit.v1_17_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_R2.CraftChunk)

Example 38 with CraftChunk

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

the class ChunkHelperImpl method refreshChunkSections.

@Override
public void refreshChunkSections(Chunk chunk) {
    ClientboundLevelChunkPacket packet = new ClientboundLevelChunkPacket(((CraftChunk) chunk).getHandle());
    ChunkPos pos = new ChunkPos(chunk.getX(), chunk.getZ());
    ChunkHolder playerChunk = ((CraftWorld) chunk.getWorld()).getHandle().getChunkProvider().chunkMap.l.get(pos.toLong());
    if (playerChunk == null) {
        return;
    }
    playerChunk.playerProvider.getPlayers(pos, false).forEach(player -> {
        player.connection.send(packet);
    });
}
Also used : ChunkHolder(net.minecraft.server.level.ChunkHolder) ChunkPos(net.minecraft.world.level.ChunkPos) ClientboundLevelChunkPacket(net.minecraft.network.protocol.game.ClientboundLevelChunkPacket) CraftWorld(org.bukkit.craftbukkit.v1_17_R1.CraftWorld)

Example 39 with CraftChunk

use of org.bukkit.craftbukkit.v1_17_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_17_R1.CraftChunk)

Example 40 with CraftChunk

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

the class BlockHelperImpl method doRandomTick.

@Override
public void doRandomTick(Location location) {
    BlockPosition pos = new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ());
    Chunk nmsChunk = ((CraftChunk) location.getChunk()).getHandle();
    IBlockData nmsBlock = nmsChunk.getType(pos);
    WorldServer nmsWorld = ((CraftWorld) location.getWorld()).getHandle();
    if (nmsBlock.isTicking()) {
        nmsBlock.b(nmsWorld, pos, nmsWorld.random);
    }
    Fluid fluid = nmsBlock.getFluid();
    if (fluid.f()) {
        fluid.b(nmsWorld, pos, nmsWorld.random);
    }
}
Also used : CraftChunk(org.bukkit.craftbukkit.v1_16_R3.CraftChunk) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld) CraftChunk(org.bukkit.craftbukkit.v1_16_R3.CraftChunk)

Aggregations

LevelChunk (net.minecraft.world.level.chunk.LevelChunk)17 Material (org.bukkit.Material)15 World (org.bukkit.World)13 NMSTileEntitySet (com.loohp.interactionvisualizer.objectholders.NMSTileEntitySet)12 TileEntity (com.loohp.interactionvisualizer.objectholders.TileEntity)12 TileEntityType (com.loohp.interactionvisualizer.objectholders.TileEntity.TileEntityType)12 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