Search in sources :

Example 1 with CPacketConfirmTeleport

use of net.minecraft.network.play.client.CPacketConfirmTeleport in project 3arthh4ck by 3arthqu4ke.

the class ListenerStopUsingItem method invoke.

@Override
public void invoke(PacketEvent.Send<CPacketPlayerDigging> event) {
    if (!mc.player.collidedVertically)
        return;
    if (event.getPacket().getAction() == CPacketPlayerDigging.Action.RELEASE_USE_ITEM && mc.player.getActiveItemStack().getItem() == Items.BOW && module.blockUnder) {
        module.cancelling = false;
        if (module.packetsSent >= module.runs.getValue() * 2 || module.always.getValue()) {
            PacketUtil.sendAction(CPacketEntityAction.Action.START_SPRINTING);
            if (module.cancelRotate.getValue() && (mc.player.rotationYaw != Managers.ROTATION.getServerYaw() || mc.player.rotationPitch != Managers.ROTATION.getServerPitch())) {
                PacketUtil.doRotation(mc.player.rotationYaw, mc.player.rotationPitch, true);
            }
            for (int i = 0; i < module.runs.getValue() + module.buffer.getValue(); i++) {
                if (i != 0 && i % module.interval.getValue() == 0) {
                    int id = Managers.POSITION.getTeleportID();
                    for (int j = 0; j < module.teleports.getValue(); j++) {
                        mc.player.connection.sendPacket(new CPacketConfirmTeleport(++id));
                    }
                }
                double[] dir = MovementUtil.strafe(0.001);
                if (module.rotate.getValue()) {
                    module.target = module.findTarget();
                    if (module.target != null) {
                        float[] rotations = module.rotationSmoother.getRotations(RotationUtil.getRotationPlayer(), module.target, module.height.getValue(), module.soft.getValue());
                        if (rotations != null) {
                            // onground true
                            PacketUtil.doPosRotNoEvent(mc.player.posX + (module.move.getValue() ? dir[0] : 0), mc.player.posY + 0.00000000000013, mc.player.posZ + (module.move.getValue() ? dir[1] : 0), rotations[0], rotations[1], true);
                            // onground false, jump
                            PacketUtil.doPosRotNoEvent(mc.player.posX + (module.move.getValue() ? dir[0] * 2 : 0), mc.player.posY + 0.00000000000027, mc.player.posZ + (module.move.getValue() ? dir[1] * 2 : 0), rotations[0], rotations[1], false);
                        }
                    } else {
                        // onground true
                        PacketUtil.doPosRotNoEvent(mc.player.posX + (module.move.getValue() ? dir[0] : 0), mc.player.posY + 0.00000000000013, mc.player.posZ + (module.move.getValue() ? dir[1] : 0), mc.player.rotationYaw, mc.player.rotationPitch, true);
                        // onground false, jump
                        PacketUtil.doPosRotNoEvent(mc.player.posX + (module.move.getValue() ? dir[0] * 2 : 0), mc.player.posY + 0.00000000000027, mc.player.posZ + (module.move.getValue() ? dir[1] * 2 : 0), mc.player.rotationYaw, mc.player.rotationPitch, false);
                    }
                } else {
                    // onground true
                    PacketUtil.doPosRotNoEvent(mc.player.posX + (module.move.getValue() ? dir[0] : 0), mc.player.posY + 0.00000000000013, mc.player.posZ + (module.move.getValue() ? dir[1] : 0), mc.player.rotationYaw, mc.player.rotationPitch, true);
                    // onground false, jump
                    PacketUtil.doPosRotNoEvent(mc.player.posX + (module.move.getValue() ? dir[0] * 2 : 0), mc.player.posY + 0.00000000000027, mc.player.posZ + (module.move.getValue() ? dir[1] * 2 : 0), mc.player.rotationYaw, mc.player.rotationPitch, false);
                }
            }
        }
        module.packetsSent = 0;
    }
}
Also used : CPacketConfirmTeleport(net.minecraft.network.play.client.CPacketConfirmTeleport)

Example 2 with CPacketConfirmTeleport

use of net.minecraft.network.play.client.CPacketConfirmTeleport in project 3arthh4ck by 3arthqu4ke.

the class PacketUtil method handlePosLook.

public static void handlePosLook(SPacketPlayerPosLook packet, Entity entity, boolean noRotate, boolean event) {
    double x = packet.getX();
    double y = packet.getY();
    double z = packet.getZ();
    float yaw = packet.getYaw();
    float pitch = packet.getPitch();
    if (packet.getFlags().contains(SPacketPlayerPosLook.EnumFlags.X)) {
        x += entity.posX;
    } else {
        entity.motionX = 0.0D;
    }
    if (packet.getFlags().contains(SPacketPlayerPosLook.EnumFlags.Y)) {
        y += entity.posY;
    } else {
        entity.motionY = 0.0D;
    }
    if (packet.getFlags().contains(SPacketPlayerPosLook.EnumFlags.Z)) {
        z += entity.posZ;
    } else {
        entity.motionZ = 0.0D;
    }
    if (packet.getFlags().contains(SPacketPlayerPosLook.EnumFlags.X_ROT)) {
        pitch += entity.rotationPitch;
    }
    if (packet.getFlags().contains(SPacketPlayerPosLook.EnumFlags.Y_ROT)) {
        yaw += entity.rotationYaw;
    }
    entity.setPositionAndRotation(x, y, z, noRotate ? entity.rotationYaw : yaw, noRotate ? entity.rotationPitch : pitch);
    Packet<?> confirm = new CPacketConfirmTeleport(packet.getTeleportId());
    CPacketPlayer posRot = positionRotation(entity.posX, entity.getEntityBoundingBox().minY, entity.posZ, yaw, pitch, false);
    if (event) {
        NetworkUtil.send(confirm);
        Managers.ROTATION.setBlocking(true);
        NetworkUtil.send(posRot);
        Managers.ROTATION.setBlocking(false);
    } else {
        NetworkUtil.sendPacketNoEvent(confirm);
        NetworkUtil.sendPacketNoEvent(posRot);
    }
    // might be called async
    mc.addScheduledTask(PacketUtil::loadTerrain);
}
Also used : CPacketConfirmTeleport(net.minecraft.network.play.client.CPacketConfirmTeleport) CPacketPlayer(net.minecraft.network.play.client.CPacketPlayer)

Example 3 with CPacketConfirmTeleport

use of net.minecraft.network.play.client.CPacketConfirmTeleport in project Spark-Client by Spark-Client-Development.

the class PacketFly method doMoveUpdate.

private void doMoveUpdate() {
    if (mc.player.isSprinting() != serverSprinting)
        safeSendPacket(new CPacketEntityAction(mc.player, mc.player.isSprinting() ? CPacketEntityAction.Action.START_SPRINTING : CPacketEntityAction.Action.STOP_SPRINTING));
    if (mc.player.isSneaking() != serverSneaking)
        safeSendPacket(new CPacketEntityAction(mc.player, mc.player.isSneaking() ? CPacketEntityAction.Action.START_SNEAKING : CPacketEntityAction.Action.STOP_SNEAKING));
    Vec3d positionBefore = new Vec3d(mc.player.prevPosX, mc.player.prevPosY, mc.player.prevPosZ);
    Vec3d positionAfter = new Vec3d(mc.player.posX, mc.player.posY, mc.player.posZ);
    // If we are about to be timed out by AEF force the antikick so we can stay floating without getting kicked
    // FIXME: Are we about to be kicked? This just tells us if we have been limited
    // fixed already by wallhacks_
    // (fixed not skidded)
    boolean forceAntiKick = !AntiCheatConfig.getInstance().wasPacketFlyLimited() && AntiCheatConfig.INSTANCE.isPacketFlyLimited();
    if ((antiKickTick > antiKickTicks.getValue() || forceAntiKick) && !expectedConfirm) {
        antiKickTick = 0.0f;
        if (!mc.player.capabilities.allowFlying && (!mc.player.isPotionActive(MobEffects.LEVITATION)) && !isInBlocks(mc.player.boundingBox.grow(0.0625).expand(0.0, -0.55, 0.0))) {
            if (antiKick.getValue()) {
                if (positionAfter.subtract(positionBefore).y >= -0.03125)
                    mc.player.setPosition(mc.player.posX, mc.player.prevPosY - 0.0313, mc.player.posZ);
            }
        }
    }
    positionAfter = mc.player.getPositionVector();
    Vec3d spoof = new Vec3d(0, 0, 0);
    switch(type.getValue()) {
        case "Up":
            spoof = new Vec3d(mc.player.posX, mc.player.posY + 20000, mc.player.posZ);
            break;
        case "Down":
            spoof = new Vec3d(mc.player.posX, mc.player.posY - 20000, mc.player.posZ);
            break;
        case "Random":
            spoof = new Vec3d(mc.player.posX + rand(), mc.player.posY, mc.player.posZ + rand());
            break;
    }
    if (positionBefore.equals(positionAfter)) {
        // have moved down we won't be kicked (until we start sending packets again)
        if (expectKick)
            antiKickTick += tickAdjust(skippedTicks);
        // server dropped our packet
        if (expectedConfirm)
            safeSendPacket(new CPacketPlayer.Position(spoof.x, spoof.y, spoof.z, false));
        // If we haven't moved just return since everything after this is spoofing
        return;
    }
    antiKickTick += tickAdjust(skippedTicks);
    expectKick = positionAfter.subtract(positionBefore).y >= -0.03125;
    // TODO: Rotation + on ground spoofing
    safeSendPacket(new CPacketPlayer.Position(positionAfter.x, positionAfter.y, positionAfter.z, false));
    safeSendPacket(new CPacketPlayer.Position(spoof.x, spoof.y, spoof.z, false));
    switch(mode.getValue()) {
        case "SetBack":
            {
                synchronized (this) {
                    if (!expectedConfirm || overSend.getValue()) {
                        // safeSendPacket(new WCPacketConfirmTeleport(spleefNet.positionHandler.getLastGoodTeleportID()));
                        waitingSince = System.currentTimeMillis();
                        expectedConfirm = true;
                    }
                }
                break;
            }
        case "Fast":
        case "Jitter":
            {
                int teleportID = Spark.positionManager.teleportId + 1;
                safeSendPacket(new CPacketConfirmTeleport(teleportID));
                synchronized (this) {
                    expectedPositions.put(teleportID, new Pair<>(System.currentTimeMillis(), positionAfter));
                }
                break;
            }
    }
}
Also used : CPacketConfirmTeleport(net.minecraft.network.play.client.CPacketConfirmTeleport) CPacketEntityAction(net.minecraft.network.play.client.CPacketEntityAction) CPacketPlayer(net.minecraft.network.play.client.CPacketPlayer) Vec3d(net.minecraft.util.math.Vec3d) Pair(me.wallhacks.spark.util.objects.Pair)

Example 4 with CPacketConfirmTeleport

use of net.minecraft.network.play.client.CPacketConfirmTeleport in project nebula by Sxmurai.

the class PacketFly method sendPacket.

private void sendPacket(double x, double y, double z, boolean bounds) {
    mc.player.connection.sendPacket(new CPacketConfirmTeleport(tpId++));
    mc.player.connection.sendPacket(new PositionRotation(x, y, z, mc.player.rotationYaw, mc.player.rotationPitch, false));
    if (bounds) {
        mc.player.connection.sendPacket(new PositionRotation(x, y - 1337.0, z, mc.player.rotationYaw, mc.player.rotationPitch, false));
    }
}
Also used : PositionRotation(net.minecraft.network.play.client.CPacketPlayer.PositionRotation) CPacketConfirmTeleport(net.minecraft.network.play.client.CPacketConfirmTeleport)

Example 5 with CPacketConfirmTeleport

use of net.minecraft.network.play.client.CPacketConfirmTeleport in project cosmos by momentumdevelopment.

the class PacketFlightModule method onPacketReceive.

@SubscribeEvent
public void onPacketReceive(PacketEvent.PacketReceiveEvent event) {
    if (event.getPacket() instanceof SPacketPlayerPosLook) {
        // packet vector associated with this rubberband
        Vec3d packetVector = packetMap.remove(((SPacketPlayerPosLook) event.getPacket()).getTeleportId());
        // server data
        double serverX = ((SPacketPlayerPosLook) event.getPacket()).getX();
        double serverY = ((SPacketPlayerPosLook) event.getPacket()).getY();
        double serverZ = ((SPacketPlayerPosLook) event.getPacket()).getZ();
        float serverYaw = ((SPacketPlayerPosLook) event.getPacket()).getYaw();
        float serverPitch = ((SPacketPlayerPosLook) event.getPacket()).getPitch();
        if (((SPacketPlayerPosLook) event.getPacket()).getFlags().contains(SPacketPlayerPosLook.EnumFlags.X)) {
            serverX += mc.player.posX;
        }
        if (((SPacketPlayerPosLook) event.getPacket()).getFlags().contains(SPacketPlayerPosLook.EnumFlags.Y)) {
            serverY += mc.player.getEntityBoundingBox().minY;
        }
        if (((SPacketPlayerPosLook) event.getPacket()).getFlags().contains(SPacketPlayerPosLook.EnumFlags.Z)) {
            serverZ += mc.player.posZ;
        }
        if (((SPacketPlayerPosLook) event.getPacket()).getFlags().contains(SPacketPlayerPosLook.EnumFlags.X_ROT)) {
            serverPitch += mc.player.rotationPitch;
        }
        if (((SPacketPlayerPosLook) event.getPacket()).getFlags().contains(SPacketPlayerPosLook.EnumFlags.Y_ROT)) {
            serverYaw += mc.player.rotationYaw;
        }
        // quickly confirm the teleport
        if (type.getValue().equals(Type.LIMIT) || type.getValue().equals(Type.LIMIT_JITTER)) {
            mc.player.connection.sendPacket(new CPacketConfirmTeleport(((SPacketPlayerPosLook) event.getPacket()).getTeleportId()));
        }
        // accept server position
        if (strict.getValue()) {
            mc.player.setPosition(serverX, serverY, serverZ);
            if (mc.getConnection() != null) {
                mc.getConnection().sendPacket(new CPacketPlayer.PositionRotation(serverX, serverY, serverZ, serverYaw, serverPitch, false));
            }
        }
        switch(mode.getValue()) {
            // we already predicted this rubberband and have sent a packet to resolve it, so we can ignore the server request
            case FAST:
                if (packetVector.x == serverX && packetVector.y == serverY && packetVector.z == serverZ) {
                    event.setCanceled(true);
                } else {
                    ((ISPacketPlayerPosLook) event.getPacket()).setYaw(mc.player.rotationYaw);
                    ((ISPacketPlayerPosLook) event.getPacket()).setPitch(mc.player.rotationPitch);
                    // remove packet flags
                    ((SPacketPlayerPosLook) event.getPacket()).getFlags().remove(SPacketPlayerPosLook.EnumFlags.X_ROT);
                    ((SPacketPlayerPosLook) event.getPacket()).getFlags().remove(SPacketPlayerPosLook.EnumFlags.Y_ROT);
                }
                break;
            case CONCEAL:
                event.setCanceled(true);
                break;
            case FACTOR:
                ((ISPacketPlayerPosLook) event.getPacket()).setYaw(mc.player.rotationYaw);
                ((ISPacketPlayerPosLook) event.getPacket()).setPitch(mc.player.rotationPitch);
                // remove packet flags
                ((SPacketPlayerPosLook) event.getPacket()).getFlags().remove(SPacketPlayerPosLook.EnumFlags.X_ROT);
                ((SPacketPlayerPosLook) event.getPacket()).getFlags().remove(SPacketPlayerPosLook.EnumFlags.Y_ROT);
                break;
        }
        // update our current teleport id
        teleportID = ((SPacketPlayerPosLook) event.getPacket()).getTeleportId();
    }
}
Also used : CPacketConfirmTeleport(net.minecraft.network.play.client.CPacketConfirmTeleport) ISPacketPlayerPosLook(cope.cosmos.asm.mixins.accessor.ISPacketPlayerPosLook) ISPacketPlayerPosLook(cope.cosmos.asm.mixins.accessor.ISPacketPlayerPosLook) SPacketPlayerPosLook(net.minecraft.network.play.server.SPacketPlayerPosLook) ICPacketPlayer(cope.cosmos.asm.mixins.accessor.ICPacketPlayer) CPacketPlayer(net.minecraft.network.play.client.CPacketPlayer) Vec3d(net.minecraft.util.math.Vec3d) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

CPacketConfirmTeleport (net.minecraft.network.play.client.CPacketConfirmTeleport)7 CPacketPlayer (net.minecraft.network.play.client.CPacketPlayer)5 Vec3d (net.minecraft.util.math.Vec3d)3 ICPacketPlayer (cope.cosmos.asm.mixins.accessor.ICPacketPlayer)2 SPacketPlayerPosLook (net.minecraft.network.play.server.SPacketPlayerPosLook)2 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)2 ISPacketPlayerPosLook (cope.cosmos.asm.mixins.accessor.ISPacketPlayerPosLook)1 Pair (me.wallhacks.spark.util.objects.Pair)1 CPacketEntityAction (net.minecraft.network.play.client.CPacketEntityAction)1 PositionRotation (net.minecraft.network.play.client.CPacketPlayer.PositionRotation)1