Search in sources :

Example 31 with Chunk

use of net.minecraft.server.v1_14_R1.Chunk in project MechanicsMain by WeaponMechanics.

the class Block_1_15_R1 method getMultiBlockMaskPacket.

@Override
@NotNull
public List<Object> getMultiBlockMaskPacket(@NotNull List<Block> blocks, @Nullable BlockState mask) {
    if (blocks == null || blocks.isEmpty()) {
        throw new IllegalArgumentException("No blocks are being changed!");
    }
    Map<org.bukkit.Chunk, List<Block>> sortedBlocks = new HashMap<>();
    for (Block block : blocks) {
        List<Block> list = sortedBlocks.computeIfAbsent(block.getChunk(), chunk -> new ArrayList<>());
        list.add(block);
    }
    List<Object> packets = new ArrayList<>(sortedBlocks.size());
    IBlockData theMask = mask == null ? null : ((CraftBlockState) mask).getHandle();
    for (List<Block> entry : sortedBlocks.values()) {
        packets.add(getMultiBlockMaskPacket(entry, theMask));
    }
    return packets;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Chunk(net.minecraft.server.v1_15_R1.Chunk) CraftChunk(org.bukkit.craftbukkit.v1_15_R1.CraftChunk) IBlockData(net.minecraft.server.v1_15_R1.IBlockData) Block(org.bukkit.block.Block) ArrayList(java.util.ArrayList) List(java.util.List) NotNull(org.jetbrains.annotations.NotNull)

Example 32 with Chunk

use of net.minecraft.server.v1_14_R1.Chunk in project Movecraft by APDevTeam.

the class IWorldHandler method setBlockFast.

private void setBlockFast(@NotNull World world, @NotNull BlockPosition position, @NotNull IBlockData data) {
    Chunk chunk = world.getChunkAtWorldCoords(position);
    ChunkSection chunkSection = chunk.getSections()[position.getY() >> 4];
    if (chunkSection == null) {
        // Put a GLASS block to initialize the section. It will be replaced next with the real block.
        chunk.setType(position, Blocks.GLASS.getBlockData(), false);
        chunkSection = chunk.getSections()[position.getY() >> 4];
    }
    if (chunkSection.getType(position.getX() & 15, position.getY() & 15, position.getZ() & 15).equals(data)) {
        // Block is already of correct type and data, don't overwrite
        return;
    }
    chunkSection.setType(position.getX() & 15, position.getY() & 15, position.getZ() & 15, data);
    world.notify(position, data, data, 3);
    var engine = chunk.e();
    if (engine != null)
        engine.a(position);
    chunk.markDirty();
}
Also used : Chunk(net.minecraft.server.v1_14_R1.Chunk) ChunkSection(net.minecraft.server.v1_14_R1.ChunkSection)

Example 33 with Chunk

use of net.minecraft.server.v1_14_R1.Chunk in project Movecraft by APDevTeam.

the class IWorldHandler method setBlockFast.

private void setBlockFast(@NotNull World world, @NotNull BlockPosition position, @NotNull IBlockData data) {
    Chunk chunk = world.getChunkAtWorldCoords(position);
    ChunkSection chunkSection = chunk.getSections()[position.getY() >> 4];
    if (chunkSection == null) {
        // Put a GLASS block to initialize the section. It will be replaced next with the real block.
        chunk.setType(position, Blocks.GLASS.getBlockData(), false);
        chunkSection = chunk.getSections()[position.getY() >> 4];
    }
    if (chunkSection.getType(position.getX() & 15, position.getY() & 15, position.getZ() & 15).equals(data)) {
        // Block is already of correct type and data, don't overwrite
        return;
    }
    chunkSection.setType(position.getX() & 15, position.getY() & 15, position.getZ() & 15, data);
    world.notify(position, data, data, 3);
    var engine = chunk.e();
    if (engine != null)
        engine.a(position);
    chunk.markDirty();
}
Also used : Chunk(net.minecraft.server.v1_16_R3.Chunk) ChunkSection(net.minecraft.server.v1_16_R3.ChunkSection)

Aggregations

ArrayList (java.util.ArrayList)13 List (java.util.List)13 Location (org.bukkit.Location)13 HashMap (java.util.HashMap)12 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 Map (java.util.Map)8 UUID (java.util.UUID)8 Chunk (net.minecraft.server.v1_16_R3.Chunk)8 GenericChunk (org.dynmap.common.chunk.GenericChunk)6 Chunk (net.minecraft.server.v1_15_R1.Chunk)4 Block (org.bukkit.block.Block)4 DynmapChunk (org.dynmap.DynmapChunk)4 Chunk (net.minecraft.server.v1_16_R2.Chunk)3