Search in sources :

Example 16 with CraftBlock

use of org.bukkit.craftbukkit.v1_13_R1.block.CraftBlock 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 17 with CraftBlock

use of org.bukkit.craftbukkit.v1_13_R1.block.CraftBlock 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 18 with CraftBlock

use of org.bukkit.craftbukkit.v1_13_R1.block.CraftBlock 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)

Example 19 with CraftBlock

use of org.bukkit.craftbukkit.v1_13_R1.block.CraftBlock in project MechanicsMain by WeaponMechanics.

the class v1_13_R2 method getHitBox.

@Override
public HitBox getHitBox(Block block) {
    if (block.isEmpty() || block.isLiquid() || block.isPassable())
        return null;
    BoundingBox boundingBox = block.getBoundingBox();
    HitBox hitBox = new HitBox(boundingBox.getMinX(), boundingBox.getMinY(), boundingBox.getMinZ(), boundingBox.getMaxX(), boundingBox.getMaxY(), boundingBox.getMaxZ());
    hitBox.setBlockHitBox(block);
    if (WeaponMechanics.getBasicConfigurations().getBool("Check_Accurate_Hitboxes", true)) {
        CraftBlock craftBlock = (CraftBlock) block;
        List<AxisAlignedBB> voxelShape = craftBlock.getNMS().getCollisionShape(craftBlock.getCraftWorld().getHandle(), craftBlock.getPosition()).d();
        if (voxelShape.size() > 1) {
            int x = block.getX();
            int y = block.getY();
            int z = block.getZ();
            for (AxisAlignedBB boxPart : voxelShape) {
                hitBox.addVoxelShapePart(new HitBox(x + boxPart.minX, y + boxPart.minY, z + boxPart.minZ, x + boxPart.maxX, y + boxPart.maxY, z + boxPart.maxZ));
            }
        }
    }
    return hitBox;
}
Also used : AxisAlignedBB(net.minecraft.server.v1_13_R2.AxisAlignedBB) HitBox(me.deecaad.weaponmechanics.weapon.projectile.HitBox) BoundingBox(org.bukkit.util.BoundingBox) CraftBlock(org.bukkit.craftbukkit.v1_13_R2.block.CraftBlock)

Example 20 with CraftBlock

use of org.bukkit.craftbukkit.v1_13_R1.block.CraftBlock in project MechanicsMain by WeaponMechanics.

the class v1_14_R1 method getHitBox.

@Override
public HitBox getHitBox(Block block) {
    if (block.isEmpty() || block.isLiquid() || block.isPassable())
        return null;
    BoundingBox boundingBox = block.getBoundingBox();
    HitBox hitBox = new HitBox(boundingBox.getMinX(), boundingBox.getMinY(), boundingBox.getMinZ(), boundingBox.getMaxX(), boundingBox.getMaxY(), boundingBox.getMaxZ());
    hitBox.setBlockHitBox(block);
    if (WeaponMechanics.getBasicConfigurations().getBool("Check_Accurate_Hitboxes", true)) {
        CraftBlock craftBlock = (CraftBlock) block;
        List<AxisAlignedBB> voxelShape = craftBlock.getNMS().getCollisionShape(craftBlock.getCraftWorld().getHandle(), craftBlock.getPosition()).d();
        if (voxelShape.size() > 1) {
            int x = block.getX();
            int y = block.getY();
            int z = block.getZ();
            for (AxisAlignedBB boxPart : voxelShape) {
                hitBox.addVoxelShapePart(new HitBox(x + boxPart.minX, y + boxPart.minY, z + boxPart.minZ, x + boxPart.maxX, y + boxPart.maxY, z + boxPart.maxZ));
            }
        }
    }
    return hitBox;
}
Also used : AxisAlignedBB(net.minecraft.server.v1_14_R1.AxisAlignedBB) HitBox(me.deecaad.weaponmechanics.weapon.projectile.HitBox) BoundingBox(org.bukkit.util.BoundingBox) CraftBlock(org.bukkit.craftbukkit.v1_14_R1.block.CraftBlock)

Aggregations

BlockPos (net.minecraft.core.BlockPos)13 ServerLevel (net.minecraft.server.level.ServerLevel)10 ComplexCollisionBox (cc.funkemunky.api.utils.world.types.ComplexCollisionBox)9 SimpleCollisionBox (cc.funkemunky.api.utils.world.types.SimpleCollisionBox)9 CraftBlock (org.bukkit.craftbukkit.v1_17_R1.block.CraftBlock)6 CraftBlock (org.bukkit.craftbukkit.v1_18_R1.block.CraftBlock)6 Direction (net.minecraft.core.Direction)5 ServerPlayer (net.minecraft.server.level.ServerPlayer)5 BlockPlaceContext (net.minecraft.world.item.context.BlockPlaceContext)5 BlockHitResult (net.minecraft.world.phys.BlockHitResult)5 Vec3 (net.minecraft.world.phys.Vec3)5 CraftWorld (org.bukkit.craftbukkit.v1_17_R1.CraftWorld)5 CraftWorld (org.bukkit.craftbukkit.v1_18_R1.CraftWorld)5 ItemStack (org.bukkit.inventory.ItemStack)5 HitBox (me.deecaad.weaponmechanics.weapon.projectile.HitBox)4 BlockState (net.minecraft.world.level.block.state.BlockState)4 Block (org.bukkit.block.Block)4 CraftBlock (org.bukkit.craftbukkit.v1_16_R3.block.CraftBlock)4 ShortArraySet (it.unimi.dsi.fastutil.shorts.ShortArraySet)3 ClientboundSectionBlocksUpdatePacket (net.minecraft.network.protocol.game.ClientboundSectionBlocksUpdatePacket)3