Search in sources :

Example 26 with PlayerActionC2SPacket

use of net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket in project Client by MatHax.

the class AutoCity method mine.

private void mine(BlockPos blockPos) {
    mc.getNetworkHandler().sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, blockPos, Direction.UP));
    mc.player.swingHand(Hand.MAIN_HAND);
    mc.getNetworkHandler().sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, blockPos, Direction.UP));
}
Also used : PlayerActionC2SPacket(net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket)

Example 27 with PlayerActionC2SPacket

use of net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket in project Client by MatHax.

the class Sniper method onPacketSend.

@EventHandler
public void onPacketSend(PacketEvent.Send event) {
    if (event.packet == null)
        return;
    if (event.packet instanceof PlayerActionC2SPacket) {
        PlayerActionC2SPacket packet = (PlayerActionC2SPacket) event.packet;
        if (packet.getAction() == PlayerActionC2SPacket.Action.RELEASE_USE_ITEM) {
            if ((isBow() && bows.get()) || (isTrident() && tridents.get())) {
                spoofed = false;
                doSpoofs();
            }
        }
    }
}
Also used : PlayerActionC2SPacket(net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket) EventHandler(mathax.client.eventbus.EventHandler)

Example 28 with PlayerActionC2SPacket

use of net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket in project Client by MatHax.

the class CEVBreaker method onTick.

@EventHandler
public void onTick(TickEvent.Pre pre) {
    if (mc.world != null && mc.player != null) {
        if (pause > 0)
            --pause;
        else {
            pause = delay.get();
            SortPriority sortPriority = SortPriority.Lowest_Distance;
            PlayerEntity target = TargetUtils.getPlayerTarget(7.0, sortPriority);
            if (target != null) {
                BlockPos blockPos;
                BlockPos blockPos1 = new BlockPos(target.getBlockPos().getX(), target.getBlockPos().getY() + 2, target.getBlockPos().getZ());
                if (mc.player.distanceTo(target) <= targetRange.get() && mc.world.getBlockState(blockPos = new BlockPos(target.getBlockPos().getX(), target.getBlockPos().getY() + 1, target.getBlockPos().getZ())).getBlock() != Blocks.OBSIDIAN && mc.world.getBlockState(blockPos).getBlock() != Blocks.BEDROCK) {
                    BlockPos blockPos2 = new BlockPos(target.getBlockPos().getX(), target.getBlockPos().getY() + 3, target.getBlockPos().getZ());
                    if (mc.world.getBlockState(blockPos1).getBlock() == Blocks.BEDROCK && !mc.player.isCreative()) {
                        error("Can't break bedrock, disabling...");
                        toggle();
                        return;
                    }
                    if (mc.world.getBlockState(blockPos1).isAir() || mc.world.getBlockState(blockPos1).getBlock() == Blocks.OBSIDIAN) {
                        int slot = InvUtils.findItemInHotbar(Items.IRON_PICKAXE);
                        if (slot == -1)
                            slot = InvUtils.findItemInHotbar(Items.NETHERITE_PICKAXE);
                        if (slot == -1)
                            slot = InvUtils.findItemInHotbar(Items.DIAMOND_PICKAXE);
                        if (slot == -1 && !mc.player.isCreative()) {
                            error("Can't find any pickaxe in your hotbar, disabling...");
                            toggle();
                        } else {
                            EndCrystalEntity endCrystalEntity = null;
                            for (Object object : mc.world.getEntities()) {
                                if (!(object instanceof EndCrystalEntity) || !equalsBlockPos(((EndCrystalEntity) object).getBlockPos(), blockPos2))
                                    continue;
                                endCrystalEntity = (EndCrystalEntity) object;
                                break;
                            }
                            if (!equalsBlockPos(pos, blockPos1))
                                pos = blockPos1;
                            if (mc.world.getBlockState(blockPos1).getBlock() != Blocks.OBSIDIAN && endCrystalEntity == null)
                                placeBlock(pos, InvUtils.findItemInHotbar(Items.OBSIDIAN), rotate.get());
                            if (mc.world.getBlockState(blockPos1).getBlock() != Blocks.OBSIDIAN && mc.world.getBlockState(blockPos1).getBlock() != Blocks.BEDROCK && endCrystalEntity != null)
                                isDone = true;
                            if (mc.world.getBlockState(blockPos1).getBlock() == Blocks.OBSIDIAN && endCrystalEntity == null) {
                                place(target, blockPos1);
                                isDone = false;
                            }
                            if (endCrystalEntity != null) {
                                double selfDamage = DamageUtils.crystalDamage(mc.player, endCrystalEntity.getPos(), false, endCrystalEntity.getBlockPos(), true);
                                if (selfDamage > maxDamage.get() || (antiSuicide.get() && selfDamage >= EntityUtils.getTotalPlayerHealth(mc.player)))
                                    return;
                            }
                            if (canPlace(pos, endCrystalEntity)) {
                                InvUtils.swap2(slot);
                                mc.getNetworkHandler().sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, pos, Direction.UP));
                                if (swing.get())
                                    mc.player.swingHand(Hand.MAIN_HAND);
                                mc.getNetworkHandler().sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, pos, Direction.UP));
                                isDone = true;
                            } else if (canAttack(endCrystalEntity)) {
                                if (rotate.get())
                                    Rotations.rotate(Rotations.getYaw(endCrystalEntity), Rotations.getPitch(endCrystalEntity));
                                int oldSlot = mc.player.getInventory().selectedSlot;
                                InvUtils.swap2(slot);
                                mc.getNetworkHandler().sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, pos, Direction.UP));
                                InvUtils.swap2(oldSlot);
                                attack(endCrystalEntity);
                                isDone = false;
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : EndCrystalEntity(net.minecraft.entity.decoration.EndCrystalEntity) PlayerActionC2SPacket(net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket) SortPriority(mathax.client.utils.entity.SortPriority) BlockPos(net.minecraft.util.math.BlockPos) PlayerEntity(net.minecraft.entity.player.PlayerEntity) EventHandler(mathax.client.eventbus.EventHandler)

Example 29 with PlayerActionC2SPacket

use of net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket in project Client by MatHax.

the class GhostCommand method execute.

private void execute(int radius) {
    ClientPlayNetworkHandler conn = mc.getNetworkHandler();
    if (conn == null)
        return;
    BlockPos pos = mc.player.getBlockPos();
    for (int dx = -radius; dx <= radius; dx++) for (int dy = -radius; dy <= radius; dy++) for (int dz = -radius; dz <= radius; dz++) {
        PlayerActionC2SPacket packet = new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.ABORT_DESTROY_BLOCK, new BlockPos(pos.getX() + dx, pos.getY() + dy, pos.getZ() + dz), Direction.UP);
        conn.sendPacket(packet);
    }
}
Also used : PlayerActionC2SPacket(net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket) BlockPos(net.minecraft.util.math.BlockPos) ClientPlayNetworkHandler(net.minecraft.client.network.ClientPlayNetworkHandler)

Example 30 with PlayerActionC2SPacket

use of net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket in project Client by MatHax.

the class AntiGhostBlock method onActivate.

@Override
public void onActivate() {
    if (mc.getNetworkHandler() == null)
        return;
    BlockPos pos = mc.player.getBlockPos();
    for (int dz = -horizontalRange.get(); dz <= horizontalRange.get(); dz++) {
        for (int dx = -horizontalRange.get(); dx <= horizontalRange.get(); dx++) {
            for (int dy = -verticalRange.get(); dy <= verticalRange.get(); dy++) {
                blockPos.set(pos.getX() + dx, (pos.getY() + underFeet.get()) + dy, pos.getZ() + dz);
                BlockState blockState = mc.world.getBlockState(blockPos);
                if (!blockState.isAir() && !blockState.isOf(Blocks.BEDROCK) && ((blockState.getBlock().getBlastResistance() >= 600 && onlyBlastProof.get()) || !onlyBlastProof.get())) {
                    PlayerActionC2SPacket packet = new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, new BlockPos(pos.getX() + dx, (pos.getY() + underFeet.get()) + dy, pos.getZ() + dz), Direction.UP);
                    mc.getNetworkHandler().sendPacket(packet);
                }
            }
        }
    }
    toggle();
}
Also used : BlockState(net.minecraft.block.BlockState) PlayerActionC2SPacket(net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket) BlockPos(net.minecraft.util.math.BlockPos)

Aggregations

PlayerActionC2SPacket (net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket)32 BlockPos (net.minecraft.util.math.BlockPos)10 HandSwingC2SPacket (net.minecraft.network.packet.c2s.play.HandSwingC2SPacket)6 BleachSubscribe (org.bleachhack.eventbus.BleachSubscribe)4 EventTarget (dev.hypnotic.event.EventTarget)3 EventHandler (mathax.client.eventbus.EventHandler)3 ClientPlayNetworkHandler (net.minecraft.client.network.ClientPlayNetworkHandler)3 Items (net.minecraft.item.Items)3 Hand (net.minecraft.util.Hand)3 Direction (net.minecraft.util.math.Direction)3 Vec3d (net.minecraft.util.math.Vec3d)3 Comparator (java.util.Comparator)2 BlockState (net.minecraft.block.BlockState)2 LivingEntity (net.minecraft.entity.LivingEntity)2 PlayerEntity (net.minecraft.entity.player.PlayerEntity)2 ItemStack (net.minecraft.item.ItemStack)2 PlayerInteractBlockC2SPacket (net.minecraft.network.packet.c2s.play.PlayerInteractBlockC2SPacket)2 UpdateSelectedSlotC2SPacket (net.minecraft.network.packet.c2s.play.UpdateSelectedSlotC2SPacket)2 BlockHitResult (net.minecraft.util.hit.BlockHitResult)2 Lists (com.google.common.collect.Lists)1