Search in sources :

Example 1 with ShortArraySet

use of it.unimi.dsi.fastutil.shorts.ShortArraySet in project MechanicsMain by WeaponMechanics.

the class Block_1_17_R1 method getMultiBlockMaskPacket.

private ClientboundSectionBlocksUpdatePacket getMultiBlockMaskPacket(List<Block> blocks, @Nullable BlockState mask) {
    BlockPos position = ((CraftBlock) blocks.get(0)).getPosition();
    // Setup default information
    short[] locations = new short[blocks.size()];
    BlockState[] data = new BlockState[blocks.size()];
    for (int i = 0; i < locations.length; i++) {
        Block block = blocks.get(i);
        int x = block.getX() & 0xF;
        int y = block.getY() & 0xF;
        int z = block.getZ() & 0xF;
        short shortLocation = (short) (x << 8 | z << 4 | y);
        locations[i] = shortLocation;
        data[i] = mask;
    }
    ClientboundSectionBlocksUpdatePacket packet = new ClientboundSectionBlocksUpdatePacket(SectionPos.of(position), new ShortArraySet(0), null, false);
    ReflectionUtil.setField(multiBlockChangeB, packet, locations);
    ReflectionUtil.setField(multiBlockChangeC, packet, data);
    return packet;
}
Also used : BlockState(net.minecraft.world.level.block.state.BlockState) CraftBlockState(org.bukkit.craftbukkit.v1_17_R1.block.CraftBlockState) ShortArraySet(it.unimi.dsi.fastutil.shorts.ShortArraySet) CraftBlock(org.bukkit.craftbukkit.v1_17_R1.block.CraftBlock) Block(org.bukkit.block.Block) ClientboundSectionBlocksUpdatePacket(net.minecraft.network.protocol.game.ClientboundSectionBlocksUpdatePacket) BlockPos(net.minecraft.core.BlockPos) CraftBlock(org.bukkit.craftbukkit.v1_17_R1.block.CraftBlock)

Example 2 with ShortArraySet

use of it.unimi.dsi.fastutil.shorts.ShortArraySet in project MechanicsMain by WeaponMechanics.

the class Block_1_18_R1 method getMultiBlockMaskPacket.

private ClientboundSectionBlocksUpdatePacket getMultiBlockMaskPacket(List<Block> blocks, @Nullable BlockState mask) {
    BlockPos position = ((CraftBlock) blocks.get(0)).getPosition();
    // Setup default information
    short[] locations = new short[blocks.size()];
    BlockState[] data = new BlockState[blocks.size()];
    for (int i = 0; i < locations.length; i++) {
        Block block = blocks.get(i);
        int x = block.getX() & 0xF;
        int y = block.getY() & 0xF;
        int z = block.getZ() & 0xF;
        short shortLocation = (short) (x << 8 | z << 4 | y);
        locations[i] = shortLocation;
        data[i] = mask;
    }
    ClientboundSectionBlocksUpdatePacket packet = new ClientboundSectionBlocksUpdatePacket(SectionPos.of(position), new ShortArraySet(0), null, false);
    ReflectionUtil.setField(multiBlockChangeB, packet, locations);
    ReflectionUtil.setField(multiBlockChangeC, packet, data);
    return packet;
}
Also used : BlockState(net.minecraft.world.level.block.state.BlockState) CraftBlockState(org.bukkit.craftbukkit.v1_18_R1.block.CraftBlockState) ShortArraySet(it.unimi.dsi.fastutil.shorts.ShortArraySet) CraftBlock(org.bukkit.craftbukkit.v1_18_R1.block.CraftBlock) Block(org.bukkit.block.Block) ClientboundSectionBlocksUpdatePacket(net.minecraft.network.protocol.game.ClientboundSectionBlocksUpdatePacket) BlockPos(net.minecraft.core.BlockPos) CraftBlock(org.bukkit.craftbukkit.v1_18_R1.block.CraftBlock)

Example 3 with ShortArraySet

use of it.unimi.dsi.fastutil.shorts.ShortArraySet in project MechanicsMain by WeaponMechanics.

the class Block_1_18_R2 method getMultiBlockMaskPacket.

private ClientboundSectionBlocksUpdatePacket getMultiBlockMaskPacket(List<Block> blocks, @Nullable BlockState mask) {
    BlockPos position = ((CraftBlock) blocks.get(0)).getPosition();
    // Setup default information
    short[] locations = new short[blocks.size()];
    BlockState[] data = new BlockState[blocks.size()];
    for (int i = 0; i < locations.length; i++) {
        Block block = blocks.get(i);
        int x = block.getX() & 0xF;
        int y = block.getY() & 0xF;
        int z = block.getZ() & 0xF;
        short shortLocation = (short) (x << 8 | z << 4 | y);
        locations[i] = shortLocation;
        data[i] = mask;
    }
    ClientboundSectionBlocksUpdatePacket packet = new ClientboundSectionBlocksUpdatePacket(SectionPos.of(position), new ShortArraySet(0), null, false);
    ReflectionUtil.setField(multiBlockChangeB, packet, locations);
    ReflectionUtil.setField(multiBlockChangeC, packet, data);
    return packet;
}
Also used : CraftBlockState(org.bukkit.craftbukkit.v1_18_R2.block.CraftBlockState) BlockState(net.minecraft.world.level.block.state.BlockState) ShortArraySet(it.unimi.dsi.fastutil.shorts.ShortArraySet) Block(org.bukkit.block.Block) CraftBlock(org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock) ClientboundSectionBlocksUpdatePacket(net.minecraft.network.protocol.game.ClientboundSectionBlocksUpdatePacket) BlockPos(net.minecraft.core.BlockPos) CraftBlock(org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock)

Aggregations

ShortArraySet (it.unimi.dsi.fastutil.shorts.ShortArraySet)3 BlockPos (net.minecraft.core.BlockPos)3 ClientboundSectionBlocksUpdatePacket (net.minecraft.network.protocol.game.ClientboundSectionBlocksUpdatePacket)3 BlockState (net.minecraft.world.level.block.state.BlockState)3 Block (org.bukkit.block.Block)3 CraftBlock (org.bukkit.craftbukkit.v1_17_R1.block.CraftBlock)1 CraftBlockState (org.bukkit.craftbukkit.v1_17_R1.block.CraftBlockState)1 CraftBlock (org.bukkit.craftbukkit.v1_18_R1.block.CraftBlock)1 CraftBlockState (org.bukkit.craftbukkit.v1_18_R1.block.CraftBlockState)1 CraftBlock (org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock)1 CraftBlockState (org.bukkit.craftbukkit.v1_18_R2.block.CraftBlockState)1