Search in sources :

Example 11 with HandSwingC2SPacket

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

the class InstaAutoCity method doMine.

private void doMine() {
    --delayLeft;
    if (!mining) {
        if (rotate.get())
            Rotations.rotate(Rotations.getYaw(mineTarget), Rotations.getPitch(mineTarget));
        if (swing.get())
            mc.getNetworkHandler().sendPacket(new HandSwingC2SPacket(Hand.MAIN_HAND));
        else
            mc.player.swingHand(Hand.MAIN_HAND);
        mc.getNetworkHandler().sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, mineTarget, direction));
        mining = true;
    }
    if (delayLeft <= 0) {
        if (rotate.get())
            Rotations.rotate(Rotations.getYaw(mineTarget), Rotations.getPitch(mineTarget));
        mc.getNetworkHandler().sendPacket(new HandSwingC2SPacket(Hand.MAIN_HAND));
        mc.getNetworkHandler().sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, mineTarget, direction));
        delayLeft = delay.get();
    }
}
Also used : HandSwingC2SPacket(net.minecraft.network.packet.c2s.play.HandSwingC2SPacket) PlayerActionC2SPacket(net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket)

Example 12 with HandSwingC2SPacket

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

the class SelfProtect method sendStopPackets.

private void sendStopPackets(BlockPos blockPos) {
    mc.getNetworkHandler().sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.ABORT_DESTROY_BLOCK, blockPos, Direction.UP));
    mc.getNetworkHandler().sendPacket(new HandSwingC2SPacket(Hand.MAIN_HAND));
}
Also used : PlayerActionC2SPacket(net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket) HandSwingC2SPacket(net.minecraft.network.packet.c2s.play.HandSwingC2SPacket)

Example 13 with HandSwingC2SPacket

use of net.minecraft.network.packet.c2s.play.HandSwingC2SPacket in project Hypnotic-Client by Hypnotic-Development.

the class Killaura method onMotionUpdate.

@EventTarget
public void onMotionUpdate(EventMotionUpdate event) {
    if (maxAps.getValue() <= minAps.getValue())
        maxAps.setValue(minAps.getValue() + 1);
    if (event.isPre()) {
        try {
            if (mc.world != null) {
                List<LivingEntity> targets = Lists.<LivingEntity>newArrayList();
                for (Entity e : mc.world.getEntities()) {
                    if (e instanceof LivingEntity && e != mc.player && !FriendManager.INSTANCE.isFriend((LivingEntity) e) && mc.player.distanceTo(e) <= range.getValue() && canAttack((LivingEntity) e))
                        targets.add((LivingEntity) e);
                    else {
                        if (targets.contains(e))
                            targets.remove(e);
                    }
                }
                if (target != null && mc.player.distanceTo(target) > range.getValue()) {
                    targets.remove(target);
                    target = null;
                    if (!ModuleManager.INSTANCE.getModule(Scaffold.class).isEnabled()) {
                        RotationUtils.resetPitch();
                        RotationUtils.resetYaw();
                    }
                }
                switch(mode.getSelected()) {
                    case "Sort":
                        switch(sortMode.getSelected()) {
                            case "Distance":
                                targets.sort(Comparator.comparingDouble(entity -> mc.player.distanceTo(entity)));
                                break;
                            case "Health":
                                targets.sort(Comparator.comparingDouble(entity -> ((LivingEntity) entity).getHealth()));
                                break;
                        }
                        if (!targets.isEmpty()) {
                            if (!FriendManager.INSTANCE.isFriend((LivingEntity) targets.get(0)))
                                target = (LivingEntity) targets.get(0);
                            if (mc.player.distanceTo(target) > range.getValue())
                                target = null;
                            if (target != null) {
                                this.setDisplayName("Killaura " + ColorUtils.gray + (target instanceof PlayerEntity ? target.getName().asString().replaceAll(ColorUtils.colorChar, "&") : target.getDisplayName().asString()));
                                if (canAttack(target)) {
                                    RotationUtils.setSilentPitch(RotationUtils.getRotations(target)[1]);
                                    RotationUtils.setSilentYaw(RotationUtils.getRotations(target)[0]);
                                    if (rotation.is("Lock View")) {
                                        mc.player.setYaw(RotationUtils.getRotations(target)[0]);
                                        mc.player.setPitch(RotationUtils.getRotations(target)[1]);
                                    }
                                    long aps = minAps.getValue() < 20 ? new Random().nextInt((int) (maxAps.getValue() - minAps.getValue())) + (int) minAps.getValue() : 20;
                                    if (delay.isEnabled() && random.isEnabled() && mc.player.getAttackCooldownProgress(0.5F) != 1)
                                        attackTimer.reset();
                                    if (delay.isEnabled() ? mc.player.getAttackCooldownProgress(0.5F) == 1 && (random.isEnabled() ? attackTimer.hasTimeElapsed(new Random().nextInt(300 - 100) + 100, true) : true) : attackTimer.hasTimeElapsed((long) (1000L / aps), true)) {
                                        if (autoBlock.isEnabled() && mc.player.getOffHandStack().getItem() instanceof ShieldItem && (mc.player.getMainHandStack().getItem() instanceof ToolItem || mc.player.getMainHandStack().getItem() == Items.AIR || mc.player.getMainHandStack().getItem() instanceof AxeItem || mc.player.getMainHandStack().getItem() instanceof SwordItem) && autoBlockMode.is("Normal")) {
                                            mc.player.networkHandler.sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, Direction.DOWN));
                                        }
                                        blocking = false;
                                        mc.interactionManager.attackEntity(mc.player, target);
                                        if (swing.isEnabled() && (autoBlock.isEnabled() ? !ModuleManager.INSTANCE.getModule(OldBlock.class).isEnabled() : true) || (ModuleManager.INSTANCE.getModule(OldBlock.class).isEnabled() ? mc.options.getPerspective() != Perspective.FIRST_PERSON : false) && !(mc.player.getMainHandStack().getItem() instanceof SwordItem))
                                            mc.player.swingHand(Hand.MAIN_HAND);
                                        else
                                            mc.player.networkHandler.sendPacket(new HandSwingC2SPacket(Hand.MAIN_HAND));
                                        if (swing.isEnabled() && !(mc.player.getMainHandStack().getItem() instanceof SwordItem) || ModuleManager.INSTANCE.getModule(OldBlock.class).animation.is("Swing"))
                                            mc.player.swingHand(Hand.MAIN_HAND);
                                    }
                                }
                                if (target.isDead()) {
                                    RotationUtils.resetYaw();
                                    RotationUtils.resetPitch();
                                }
                            } else {
                                if (blocking)
                                    mc.options.useKey.setPressed(false);
                                blocking = false;
                                if (!ModuleManager.INSTANCE.getModule(Scaffold.class).isEnabled()) {
                                    RotationUtils.resetPitch();
                                    RotationUtils.resetYaw();
                                }
                                this.setDisplayName("Killaura " + ColorUtils.gray + "None");
                            }
                        } else {
                            if (blocking)
                                mc.options.useKey.setPressed(false);
                            blocking = false;
                            if (!ModuleManager.INSTANCE.getModule(Scaffold.class).isEnabled()) {
                                RotationUtils.resetPitch();
                                RotationUtils.resetYaw();
                            }
                        }
                        break;
                    case "Multi":
                        if (!targets.isEmpty()) {
                            for (LivingEntity entity : targets) {
                                if (entity != null && !FriendManager.INSTANCE.isFriend(entity)) {
                                    this.setDisplayName("Killaura " + ColorUtils.gray + (entity instanceof PlayerEntity ? entity.getName().asString().replaceAll(ColorUtils.colorChar, "&") : entity.getDisplayName().asString()));
                                    if (canAttack(entity)) {
                                        if (target != null)
                                            RotationUtils.setSilentPitch(RotationUtils.getRotations(target)[1]);
                                        if (target != null)
                                            RotationUtils.setSilentYaw(RotationUtils.getRotations(target)[0]);
                                        if (rotation.is("Lock View")) {
                                            if (target != null)
                                                mc.player.setYaw(RotationUtils.getRotations(target)[0]);
                                            if (target != null)
                                                mc.player.setPitch(RotationUtils.getRotations(target)[1]);
                                        }
                                        long aps = minAps.getValue() < 20 ? new Random().nextInt((int) (maxAps.getValue() - minAps.getValue())) + (int) minAps.getValue() : 20;
                                        if (delay.isEnabled() && random.isEnabled() && mc.player.getAttackCooldownProgress(0.5F) != 1)
                                            attackTimer.reset();
                                        if ((delay.isEnabled() ? mc.player.getAttackCooldownProgress(0.5F) == 1 && (random.isEnabled() ? attackTimer.hasTimeElapsed(new Random().nextInt(300 - 100) + 100, true) : true) : attackTimer.hasTimeElapsed((long) (1000L / aps), true)) && targets.indexOf(entity) == new Random().nextInt(targets.size())) {
                                            if (autoBlock.isEnabled() && mc.player.getOffHandStack().getItem() instanceof ShieldItem && (mc.player.getMainHandStack().getItem() instanceof ToolItem || mc.player.getMainHandStack().getItem() == Items.AIR || mc.player.getMainHandStack().getItem() instanceof AxeItem || mc.player.getMainHandStack().getItem() instanceof SwordItem) && autoBlockMode.is("NCP")) {
                                                mc.player.networkHandler.sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, Direction.DOWN));
                                            }
                                            blocking = false;
                                            target = entity;
                                            mc.interactionManager.attackEntity(mc.player, entity);
                                            if (swing.isEnabled() && (autoBlock.isEnabled() ? !ModuleManager.INSTANCE.getModule(OldBlock.class).isEnabled() : true) || (ModuleManager.INSTANCE.getModule(OldBlock.class).isEnabled() ? mc.options.getPerspective() != Perspective.FIRST_PERSON : false) && !(mc.player.getMainHandStack().getItem() instanceof SwordItem))
                                                mc.player.swingHand(Hand.MAIN_HAND);
                                            else
                                                mc.player.networkHandler.sendPacket(new HandSwingC2SPacket(Hand.MAIN_HAND));
                                            if (swing.isEnabled() && !(mc.player.getMainHandStack().getItem() instanceof SwordItem) || ModuleManager.INSTANCE.getModule(OldBlock.class).animation.is("Swing"))
                                                mc.player.swingHand(Hand.MAIN_HAND);
                                        }
                                    }
                                    if (entity.isDead()) {
                                        RotationUtils.resetYaw();
                                        RotationUtils.resetPitch();
                                    }
                                } else {
                                }
                            }
                        } else {
                            if (!ModuleManager.INSTANCE.getModule(Scaffold.class).isEnabled()) {
                                RotationUtils.resetPitch();
                                RotationUtils.resetYaw();
                            }
                        }
                        break;
                }
                if (targets.isEmpty())
                    target = null;
                this.setDisplayName("Killaura " + ColorUtils.gray + mode.getSelected());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    } else {
        if (target == null)
            return;
        if (autoBlock.isEnabled() && (mc.player.getMainHandStack().getItem() instanceof ToolItem || mc.player.getMainHandStack().getItem() == Items.AIR || mc.player.getMainHandStack().getItem() instanceof AxeItem || mc.player.getMainHandStack().getItem() instanceof SwordItem) && !autoBlockMode.is("Visual")) {
            mc.interactionManager.interactItem(mc.player, mc.world, Hand.OFF_HAND);
            mc.interactionManager.interactItem(mc.player, mc.world, Hand.MAIN_HAND);
            if (!blocking && autoBlockMode.is("NCP")) {
                mc.player.networkHandler.sendPacket(new PlayerInteractBlockC2SPacket(Hand.MAIN_HAND, new BlockHitResult(new Vec3d(0.0f, 0.0f, 0.0f), Direction.DOWN, new BlockPos(-1, -1, -1), false)));
                blocking = true;
            }
        }
    }
}
Also used : ColorSetting(dev.hypnotic.settings.settingtypes.ColorSetting) Category(dev.hypnotic.module.Category) PlayerMoveC2SPacketAccessor(dev.hypnotic.mixin.PlayerMoveC2SPacketAccessor) RotationUtils(dev.hypnotic.utils.RotationUtils) PlayerActionC2SPacket(net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket) Random(java.util.Random) FriendManager(dev.hypnotic.config.friends.FriendManager) ModuleManager(dev.hypnotic.module.ModuleManager) Direction(net.minecraft.util.math.Direction) EventMotionUpdate(dev.hypnotic.event.events.EventMotionUpdate) Scaffold(dev.hypnotic.module.player.Scaffold) Lists(com.google.common.collect.Lists) EventTarget(dev.hypnotic.event.EventTarget) PlayerInteractBlockC2SPacket(net.minecraft.network.packet.c2s.play.PlayerInteractBlockC2SPacket) Vec3d(net.minecraft.util.math.Vec3d) SwordItem(net.minecraft.item.SwordItem) Hand(net.minecraft.util.Hand) AnimalEntity(net.minecraft.entity.passive.AnimalEntity) NumberSetting(dev.hypnotic.settings.settingtypes.NumberSetting) AxeItem(net.minecraft.item.AxeItem) EventRender3D(dev.hypnotic.event.events.EventRender3D) Entity(net.minecraft.entity.Entity) HandSwingC2SPacket(net.minecraft.network.packet.c2s.play.HandSwingC2SPacket) PassiveEntity(net.minecraft.entity.passive.PassiveEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) LivingEntity(net.minecraft.entity.LivingEntity) ArmorStandEntity(net.minecraft.entity.decoration.ArmorStandEntity) ColorUtils(dev.hypnotic.utils.ColorUtils) BlockHitResult(net.minecraft.util.hit.BlockHitResult) BlockPos(net.minecraft.util.math.BlockPos) RenderUtils(dev.hypnotic.utils.render.RenderUtils) Items(net.minecraft.item.Items) OldBlock(dev.hypnotic.module.render.OldBlock) ModeSetting(dev.hypnotic.settings.settingtypes.ModeSetting) HitResult(net.minecraft.util.hit.HitResult) EntityHitResult(net.minecraft.util.hit.EntityHitResult) List(java.util.List) Monster(net.minecraft.entity.mob.Monster) ToolItem(net.minecraft.item.ToolItem) Timer(dev.hypnotic.utils.Timer) Type(net.minecraft.util.hit.HitResult.Type) Mod(dev.hypnotic.module.Mod) PlayerMoveC2SPacket(net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket) Perspective(net.minecraft.client.option.Perspective) Comparator(java.util.Comparator) EventSendPacket(dev.hypnotic.event.events.EventSendPacket) ShieldItem(net.minecraft.item.ShieldItem) BooleanSetting(dev.hypnotic.settings.settingtypes.BooleanSetting) AnimalEntity(net.minecraft.entity.passive.AnimalEntity) Entity(net.minecraft.entity.Entity) PassiveEntity(net.minecraft.entity.passive.PassiveEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) LivingEntity(net.minecraft.entity.LivingEntity) ArmorStandEntity(net.minecraft.entity.decoration.ArmorStandEntity) ShieldItem(net.minecraft.item.ShieldItem) PlayerActionC2SPacket(net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket) HandSwingC2SPacket(net.minecraft.network.packet.c2s.play.HandSwingC2SPacket) SwordItem(net.minecraft.item.SwordItem) AxeItem(net.minecraft.item.AxeItem) Vec3d(net.minecraft.util.math.Vec3d) PlayerEntity(net.minecraft.entity.player.PlayerEntity) LivingEntity(net.minecraft.entity.LivingEntity) OldBlock(dev.hypnotic.module.render.OldBlock) Random(java.util.Random) BlockPos(net.minecraft.util.math.BlockPos) BlockHitResult(net.minecraft.util.hit.BlockHitResult) ToolItem(net.minecraft.item.ToolItem) PlayerInteractBlockC2SPacket(net.minecraft.network.packet.c2s.play.PlayerInteractBlockC2SPacket) EventTarget(dev.hypnotic.event.EventTarget)

Example 14 with HandSwingC2SPacket

use of net.minecraft.network.packet.c2s.play.HandSwingC2SPacket in project Hypnotic-Client by Hypnotic-Development.

the class WorldUtils method place.

private static void place(BlockHitResult blockHitResult, Hand hand, boolean swing) {
    boolean wasSneaking = mc.player.input.sneaking;
    mc.player.input.sneaking = false;
    ActionResult result = mc.interactionManager.interactBlock(mc.player, mc.world, hand, blockHitResult);
    if (result.shouldSwingHand()) {
        if (swing)
            mc.player.swingHand(hand);
        else
            mc.getNetworkHandler().sendPacket(new HandSwingC2SPacket(hand));
    }
    mc.player.input.sneaking = wasSneaking;
}
Also used : ActionResult(net.minecraft.util.ActionResult) HandSwingC2SPacket(net.minecraft.network.packet.c2s.play.HandSwingC2SPacket)

Example 15 with HandSwingC2SPacket

use of net.minecraft.network.packet.c2s.play.HandSwingC2SPacket in project Hypnotic-Client by Hypnotic-Development.

the class WorldUtils method placeBlock.

public static boolean placeBlock(Hand hand, BlockPos pos, Boolean rotate, Boolean airPlace, Boolean ignoreEntity, Direction overrideSide, boolean swing) {
    // make sure place is empty if ignoreEntity is not true
    if (ignoreEntity) {
        if (!mc.world.getBlockState(pos).getMaterial().isReplaceable())
            return false;
    } else if (!mc.world.getBlockState(pos).getMaterial().isReplaceable() || !mc.world.canPlace(Blocks.OBSIDIAN.getDefaultState(), pos, ShapeContext.absent()))
        return false;
    Vec3d eyesPos = new Vec3d(mc.player.getX(), mc.player.getY() + mc.player.getEyeHeight(mc.player.getPose()), mc.player.getZ());
    Vec3d hitVec = null;
    BlockPos neighbor = null;
    Direction side2 = null;
    if (overrideSide != null) {
        neighbor = pos.offset(overrideSide.getOpposite());
        side2 = overrideSide;
    }
    for (Direction side : Direction.values()) {
        if (overrideSide == null) {
            neighbor = pos.offset(side);
            side2 = side.getOpposite();
            // check if neighbor can be right clicked aka it isnt air
            if (mc.world.getBlockState(neighbor).isAir() || mc.world.getBlockState(neighbor).getBlock() instanceof FluidBlock) {
                neighbor = null;
                side2 = null;
                continue;
            }
        }
        hitVec = new Vec3d(neighbor.getX(), neighbor.getY(), neighbor.getZ()).add(0.5, 0.5, 0.5).add(new Vec3d(side2.getUnitVector()).multiply(0.5));
        break;
    }
    // Air place if no neighbour was found
    if (airPlace) {
        if (hitVec == null)
            hitVec = new Vec3d(pos.getX(), pos.getY(), pos.getZ());
        if (neighbor == null)
            neighbor = pos;
        if (side2 == null)
            side2 = Direction.UP;
    } else if (hitVec == null || neighbor == null || side2 == null) {
        return false;
    }
    // place block
    double diffX = hitVec.x - eyesPos.x;
    double diffY = hitVec.y - eyesPos.y;
    double diffZ = hitVec.z - eyesPos.z;
    double diffXZ = Math.sqrt(diffX * diffX + diffZ * diffZ);
    float yaw = (float) Math.toDegrees(Math.atan2(diffZ, diffX)) - 90F;
    float pitch = (float) -Math.toDegrees(Math.atan2(diffY, diffXZ));
    float[] rotations = { mc.player.getYaw() + MathHelper.wrapDegrees(yaw - mc.player.getYaw()), mc.player.getPitch() + MathHelper.wrapDegrees(pitch - mc.player.getPitch()) };
    if (rotate) {
        if (ModuleManager.INSTANCE.getModule(Scaffold.class).extend.getValue() > 1) {
            RotationUtils.setSilentYaw(rotations[0]);
            RotationUtils.setSilentPitch(rotations[1]);
        }
        mc.player.networkHandler.sendPacket(new PlayerMoveC2SPacket.LookAndOnGround(rotations[0], rotations[1], mc.player.isOnGround()));
    } else {
        RotationUtils.resetYaw();
        RotationUtils.resetPitch();
    }
    // mc.player.networkHandler.sendPacket(new ClientCommandC2SPacket(mc.player, ClientCommandC2SPacket.Mode.PRESS_SHIFT_KEY));
    mc.interactionManager.interactBlock(mc.player, mc.world, hand, new BlockHitResult(hitVec, side2, neighbor, false));
    if (swing)
        mc.player.swingHand(hand);
    else
        mc.player.networkHandler.sendPacket(new HandSwingC2SPacket(hand));
    return true;
}
Also used : HandSwingC2SPacket(net.minecraft.network.packet.c2s.play.HandSwingC2SPacket) PlayerMoveC2SPacket(net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket) BlockPos(net.minecraft.util.math.BlockPos) Scaffold(dev.hypnotic.module.player.Scaffold) BlockHitResult(net.minecraft.util.hit.BlockHitResult) Direction(net.minecraft.util.math.Direction) Vec3d(net.minecraft.util.math.Vec3d) IVec3d(dev.hypnotic.utils.mixin.IVec3d)

Aggregations

HandSwingC2SPacket (net.minecraft.network.packet.c2s.play.HandSwingC2SPacket)16 PlayerActionC2SPacket (net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket)6 ActionResult (net.minecraft.util.ActionResult)4 BlockHitResult (net.minecraft.util.hit.BlockHitResult)4 BlockPos (net.minecraft.util.math.BlockPos)4 Vec3d (net.minecraft.util.math.Vec3d)4 Hand (net.minecraft.util.Hand)3 Direction (net.minecraft.util.math.Direction)3 Scaffold (dev.hypnotic.module.player.Scaffold)2 List (java.util.List)2 Entity (net.minecraft.entity.Entity)2 PlayerMoveC2SPacket (net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket)2 Lists (com.google.common.collect.Lists)1 FriendManager (dev.hypnotic.config.friends.FriendManager)1 EventTarget (dev.hypnotic.event.EventTarget)1 EventMotionUpdate (dev.hypnotic.event.events.EventMotionUpdate)1 EventRender3D (dev.hypnotic.event.events.EventRender3D)1 EventSendPacket (dev.hypnotic.event.events.EventSendPacket)1 PlayerMoveC2SPacketAccessor (dev.hypnotic.mixin.PlayerMoveC2SPacketAccessor)1 Category (dev.hypnotic.module.Category)1