Search in sources :

Example 11 with PacketPlayOutMultiBlockChange

use of net.minecraft.server.v1_15_R1.PacketPlayOutMultiBlockChange in project MechanicsMain by WeaponMechanics.

the class Block_1_13_R2 method getMultiBlockMaskPacket.

private PacketPlayOutMultiBlockChange getMultiBlockMaskPacket(List<Block> blocks, @Nullable IBlockData mask) {
    net.minecraft.server.v1_13_R2.Chunk chunk = ((CraftChunk) blocks.get(0).getChunk()).getHandle();
    // Setup default information
    PacketPlayOutMultiBlockChange packet = new PacketPlayOutMultiBlockChange(0, new short[0], chunk);
    PacketPlayOutMultiBlockChange.MultiBlockChangeInfo[] changes = new PacketPlayOutMultiBlockChange.MultiBlockChangeInfo[blocks.size()];
    for (int i = 0; i < blocks.size(); i++) {
        Block block = blocks.get(i);
        // Where the block is relative to the chunk it is in
        int x = block.getX() & 0xF;
        int y = block.getY();
        int z = block.getZ() & 0xF;
        // Setting the (x, y, z) location into VarInt format
        short location = (short) (x << 12 | y | z << 8);
        // If mask is null, then undo the mask. Otherwise set the mask
        if (mask == null) {
            changes[i] = packet.new MultiBlockChangeInfo(location, chunk);
        } else {
            changes[i] = packet.new MultiBlockChangeInfo(location, mask);
        }
    }
    ReflectionUtil.setField(multiBlockChangeB, packet, changes);
    return packet;
}
Also used : PacketPlayOutMultiBlockChange(net.minecraft.server.v1_13_R2.PacketPlayOutMultiBlockChange) Block(org.bukkit.block.Block) CraftChunk(org.bukkit.craftbukkit.v1_13_R2.CraftChunk)

Example 12 with PacketPlayOutMultiBlockChange

use of net.minecraft.server.v1_15_R1.PacketPlayOutMultiBlockChange in project MechanicsMain by WeaponMechanics.

the class Block_1_9_R2 method getMultiBlockMaskPacket.

private PacketPlayOutMultiBlockChange getMultiBlockMaskPacket(List<Block> blocks, @Nullable IBlockData mask) {
    net.minecraft.server.v1_9_R2.Chunk chunk = ((CraftChunk) blocks.get(0).getChunk()).getHandle();
    // Setup default information
    PacketPlayOutMultiBlockChange packet = new PacketPlayOutMultiBlockChange(0, new short[0], chunk);
    PacketPlayOutMultiBlockChange.MultiBlockChangeInfo[] changes = new PacketPlayOutMultiBlockChange.MultiBlockChangeInfo[blocks.size()];
    for (int i = 0; i < blocks.size(); i++) {
        Block block = blocks.get(i);
        // Where the block is relative to the chunk it is in
        int x = block.getX() & 0xF;
        int y = block.getY();
        int z = block.getZ() & 0xF;
        // Setting the (x, y, z) location into VarInt format
        short location = (short) (x << 12 | y | z << 8);
        // If mask is null, then undo the mask. Otherwise set the mask
        if (mask == null) {
            changes[i] = packet.new MultiBlockChangeInfo(location, chunk);
        } else {
            changes[i] = packet.new MultiBlockChangeInfo(location, mask);
        }
    }
    ReflectionUtil.setField(multiBlockChangeB, packet, changes);
    return packet;
}
Also used : PacketPlayOutMultiBlockChange(net.minecraft.server.v1_9_R2.PacketPlayOutMultiBlockChange) Block(org.bukkit.block.Block) CraftChunk(org.bukkit.craftbukkit.v1_9_R2.CraftChunk)

Aggregations

Block (org.bukkit.block.Block)8 CraftChunk (org.bukkit.craftbukkit.v1_15_R1.CraftChunk)3 ParallelChunk (thpmc.engine.api.world.parallel.ParallelChunk)3 ParallelWorld (thpmc.engine.api.world.parallel.ParallelWorld)3 SectionTypeArray (thpmc.engine.util.SectionTypeArray)3 net.minecraft.server.v1_15_R1 (net.minecraft.server.v1_15_R1)2 PacketPlayOutMultiBlockChange (net.minecraft.server.v1_15_R1.PacketPlayOutMultiBlockChange)2 IBlockData (net.minecraft.server.v1_16_R3.IBlockData)2 PacketPlayOutMultiBlockChange (net.minecraft.server.v1_16_R3.PacketPlayOutMultiBlockChange)2 BlockData (org.bukkit.block.data.BlockData)2 CraftBlockData (org.bukkit.craftbukkit.v1_15_R1.block.data.CraftBlockData)2 ParallelUniverse (thpmc.engine.api.world.parallel.ParallelUniverse)2 java.util (java.util)1 PacketPlayOutMultiBlockChange (net.minecraft.server.v1_10_R1.PacketPlayOutMultiBlockChange)1 PacketPlayOutMultiBlockChange (net.minecraft.server.v1_11_R1.PacketPlayOutMultiBlockChange)1 PacketPlayOutMultiBlockChange (net.minecraft.server.v1_12_R1.PacketPlayOutMultiBlockChange)1 PacketPlayOutMultiBlockChange (net.minecraft.server.v1_13_R2.PacketPlayOutMultiBlockChange)1 PacketPlayOutMultiBlockChange (net.minecraft.server.v1_14_R1.PacketPlayOutMultiBlockChange)1 BlockPosition (net.minecraft.server.v1_15_R1.BlockPosition)1 Chunk (net.minecraft.server.v1_15_R1.Chunk)1