Search in sources :

Example 6 with ChunkCoordIntPair

use of net.minecraft.server.v1_15_R1.ChunkCoordIntPair in project dynmap by webbukkit.

the class MapChunkCache116_2 method loadChunk.

// Load generic chunk from unloaded chunk
protected GenericChunk loadChunk(DynmapChunk chunk) {
    CraftWorld cw = (CraftWorld) w;
    NBTTagCompound nbt = null;
    ChunkCoordIntPair cc = new ChunkCoordIntPair(chunk.x, chunk.z);
    GenericChunk gc = null;
    try {
        nbt = cw.getHandle().getChunkProvider().playerChunkMap.read(cc);
    } catch (IOException iox) {
    }
    if (nbt != null) {
        gc = parseChunkFromNBT(new NBT.NBTCompound(nbt));
    }
    return gc;
}
Also used : ChunkCoordIntPair(net.minecraft.server.v1_16_R2.ChunkCoordIntPair) GenericChunk(org.dynmap.common.chunk.GenericChunk) NBTTagCompound(net.minecraft.server.v1_16_R2.NBTTagCompound) IOException(java.io.IOException) CraftWorld(org.bukkit.craftbukkit.v1_16_R2.CraftWorld)

Example 7 with ChunkCoordIntPair

use of net.minecraft.server.v1_15_R1.ChunkCoordIntPair in project THP-Engine by TheHollowPlanetMC.

the class PacketManager method createMultiBlockChangePacket.

public static Set<Object> createMultiBlockChangePacket(ParallelWorld parallelWorld, Set<BlockPosition3i> blocks) {
    Map<ChunkPosition, Set<BlockPosition3i>> chunkMap = new HashMap<>();
    for (BlockPosition3i bp : blocks) {
        chunkMap.computeIfAbsent(new ChunkPosition(bp.getX(), bp.getZ()), cp -> new HashSet<>()).add(bp);
    }
    Set<Object> packets = new HashSet<>();
    for (Map.Entry<ChunkPosition, Set<BlockPosition3i>> entry : chunkMap.entrySet()) {
        ChunkPosition chunkPosition = entry.getKey();
        Set<BlockPosition3i> bps = entry.getValue();
        ParallelChunk parallelChunk = parallelWorld.getChunk(chunkPosition.x, chunkPosition.z);
        if (parallelChunk == null)
            continue;
        PacketPlayOutMultiBlockChange packet = new PacketPlayOutMultiBlockChange();
        List<PacketPlayOutMultiBlockChange.MultiBlockChangeInfo> infoList = new ArrayList<>();
        for (BlockPosition3i bp : bps) {
            BlockData blockData = parallelChunk.getBlockData(bp.getX(), bp.getY(), bp.getZ());
            if (blockData == null)
                continue;
            short loc = (short) ((bp.getX() & 0xF) << 12 | (bp.getZ() & 0xF) << 8 | bp.getY());
            infoList.add(packet.new MultiBlockChangeInfo(loc, ((CraftBlockData) blockData).getState()));
        }
        PacketPlayOutMultiBlockChange.MultiBlockChangeInfo[] array = infoList.toArray(new PacketPlayOutMultiBlockChange.MultiBlockChangeInfo[infoList.size()]);
        try {
            MultiBlockChangePacketHandler.a.set(packet, new ChunkCoordIntPair(chunkPosition.x, chunkPosition.z));
            MultiBlockChangePacketHandler.b.set(packet, array);
            packets.add(packet);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    return packets;
}
Also used : java.util(java.util) CraftWorld(org.bukkit.craftbukkit.v1_15_R1.CraftWorld) BlockData(org.bukkit.block.data.BlockData) Player(org.bukkit.entity.Player) SectionTypeArray(thpmc.engine.util.SectionTypeArray) ParallelWorld(thpmc.engine.api.world.parallel.ParallelWorld) BlockChangePacketHandler(thpmc.engine.nms.v1_15_R1.BlockChangePacketHandler) MultiBlockChangePacketHandler(thpmc.engine.nms.v1_15_R1.MultiBlockChangePacketHandler) Nullable(org.jetbrains.annotations.Nullable) net.minecraft.server.v1_15_R1(net.minecraft.server.v1_15_R1) ParallelChunk(thpmc.engine.api.world.parallel.ParallelChunk) ChunkPosition(thpmc.engine.util.ChunkPosition) CraftChunk(org.bukkit.craftbukkit.v1_15_R1.CraftChunk) NMSHandler(thpmc.engine.nms.v1_15_R1.NMSHandler) CraftBlockData(org.bukkit.craftbukkit.v1_15_R1.block.data.CraftBlockData) BlockPosition3i(thpmc.engine.util.BlockPosition3i) SectionLevelArray(thpmc.engine.util.SectionLevelArray) Bukkit(org.bukkit.Bukkit) ChunkPosition(thpmc.engine.util.ChunkPosition) ParallelChunk(thpmc.engine.api.world.parallel.ParallelChunk) CraftBlockData(org.bukkit.craftbukkit.v1_15_R1.block.data.CraftBlockData) BlockPosition3i(thpmc.engine.util.BlockPosition3i) BlockData(org.bukkit.block.data.BlockData) CraftBlockData(org.bukkit.craftbukkit.v1_15_R1.block.data.CraftBlockData)

Aggregations

IOException (java.io.IOException)5 GenericChunk (org.dynmap.common.chunk.GenericChunk)5 ChunkCoordIntPair (net.minecraft.server.v1_15_R1.ChunkCoordIntPair)2 ChunkCoordIntPair (net.minecraft.server.v1_16_R2.ChunkCoordIntPair)2 NBTTagCompound (net.minecraft.server.v1_16_R2.NBTTagCompound)2 BlockData (org.bukkit.block.data.BlockData)2 CraftWorld (org.bukkit.craftbukkit.v1_15_R1.CraftWorld)2 CraftBlockData (org.bukkit.craftbukkit.v1_15_R1.block.data.CraftBlockData)2 CraftWorld (org.bukkit.craftbukkit.v1_16_R2.CraftWorld)2 ParallelChunk (thpmc.engine.api.world.parallel.ParallelChunk)2 ParallelWorld (thpmc.engine.api.world.parallel.ParallelWorld)2 java.util (java.util)1 ChunkCoordIntPair (net.minecraft.server.v1_14_R1.ChunkCoordIntPair)1 NBTTagCompound (net.minecraft.server.v1_14_R1.NBTTagCompound)1 net.minecraft.server.v1_15_R1 (net.minecraft.server.v1_15_R1)1 BlockPosition (net.minecraft.server.v1_15_R1.BlockPosition)1 NBTTagCompound (net.minecraft.server.v1_15_R1.NBTTagCompound)1 PacketPlayOutMultiBlockChange (net.minecraft.server.v1_15_R1.PacketPlayOutMultiBlockChange)1 ChunkCoordIntPair (net.minecraft.server.v1_16_R1.ChunkCoordIntPair)1 NBTTagCompound (net.minecraft.server.v1_16_R1.NBTTagCompound)1