Search in sources :

Example 1 with SPacketPlayerPosLook

use of net.minecraft.network.play.server.SPacketPlayerPosLook in project Spark-Client by Spark-Client-Development.

the class Speed method onPacketReceive.

@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onPacketReceive(PacketReceiveEvent event) {
    if (mc.player != null)
        if (event.getPacket() instanceof SPacketPlayerPosLook) {
            jumps = 0;
            prevOnGround = false;
            state = mode.is("OnGround") ? 2 : 4;
            speed = 0;
            boost = 0;
        } else if (event.getPacket() instanceof SPacketExplosion || (event.getPacket() instanceof SPacketEntityVelocity && ((SPacketEntityVelocity) event.getPacket()).entityID == mc.player.entityId)) {
            double motionX;
            double motionZ;
            if (event.getPacket() instanceof SPacketExplosion) {
                SPacketExplosion p = event.getPacket();
                motionX = p.motionX;
                motionZ = p.motionZ;
            } else {
                SPacketEntityVelocity p = event.getPacket();
                motionX = p.motionX / 8000f;
                motionZ = p.motionZ / 8000f;
            }
            boostTick = 0;
            boost = MathHelper.clamp(Math.sqrt(MathUtil.square(motionX) + MathUtil.square(motionZ)) * boostF.getValue(), boost, 1);
        }
}
Also used : SPacketExplosion(net.minecraft.network.play.server.SPacketExplosion) SPacketPlayerPosLook(net.minecraft.network.play.server.SPacketPlayerPosLook) SPacketEntityVelocity(net.minecraft.network.play.server.SPacketEntityVelocity) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 2 with SPacketPlayerPosLook

use of net.minecraft.network.play.server.SPacketPlayerPosLook in project cosmos by momentumdevelopment.

the class ElytraFlightModule method onPacketReceive.

@SubscribeEvent
public void onPacketReceive(PacketEvent.PacketReceiveEvent event) {
    if (event.getPacket() instanceof SPacketPlayerPosLook && !firework.getValue().equals(Switch.NONE)) {
        if (mc.player.isElytraFlying()) {
            getCosmos().getInventoryManager().switchToItem(Items.FIREWORKS, firework.getValue());
            mc.player.connection.sendPacket(new CPacketPlayerTryUseItem(EnumHand.MAIN_HAND));
        }
    }
}
Also used : CPacketPlayerTryUseItem(net.minecraft.network.play.client.CPacketPlayerTryUseItem) SPacketPlayerPosLook(net.minecraft.network.play.server.SPacketPlayerPosLook) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 3 with SPacketPlayerPosLook

use of net.minecraft.network.play.server.SPacketPlayerPosLook in project 3arthh4ck by 3arthqu4ke.

the class ListenerPosLook method invoke.

@Override
public void invoke(PacketEvent.Receive<SPacketPlayerPosLook> event) {
    module.teleported.set(false);
    Entity player = RotationUtil.getRotationPlayer();
    if (player == null) {
        return;
    }
    SPacketPlayerPosLook packet = event.getPacket();
    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 += player.posX;
    }
    if (packet.getFlags().contains(SPacketPlayerPosLook.EnumFlags.Y)) {
        y += player.posY;
    }
    if (packet.getFlags().contains(SPacketPlayerPosLook.EnumFlags.Z)) {
        z += player.posZ;
    }
    if (packet.getFlags().contains(SPacketPlayerPosLook.EnumFlags.X_ROT)) {
        pitch += player.rotationPitch;
    }
    if (packet.getFlags().contains(SPacketPlayerPosLook.EnumFlags.Y_ROT)) {
        yaw += player.rotationYaw;
    }
    module.x = x;
    module.y = y;
    module.z = z;
    module.yaw = yaw;
    module.pitch = pitch;
}
Also used : Entity(net.minecraft.entity.Entity) SPacketPlayerPosLook(net.minecraft.network.play.server.SPacketPlayerPosLook)

Example 4 with SPacketPlayerPosLook

use of net.minecraft.network.play.server.SPacketPlayerPosLook in project Spark-Client by Spark-Client-Development.

the class AntiRotate method onPacketReceive.

@SubscribeEvent
public void onPacketReceive(PacketReceiveEvent event) {
    if (nullCheck())
        return;
    if (event.getPacket() instanceof SPacketPlayerPosLook) {
        SPacketPlayerPosLook p = event.getPacket();
        p.yaw = mc.player.rotationYaw;
        p.pitch = mc.player.rotationPitch;
    }
}
Also used : SPacketPlayerPosLook(net.minecraft.network.play.server.SPacketPlayerPosLook) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 5 with SPacketPlayerPosLook

use of net.minecraft.network.play.server.SPacketPlayerPosLook 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

SPacketPlayerPosLook (net.minecraft.network.play.server.SPacketPlayerPosLook)6 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)4 CPacketConfirmTeleport (net.minecraft.network.play.client.CPacketConfirmTeleport)2 CPacketPlayer (net.minecraft.network.play.client.CPacketPlayer)2 ICPacketPlayer (cope.cosmos.asm.mixins.accessor.ICPacketPlayer)1 ISPacketPlayerPosLook (cope.cosmos.asm.mixins.accessor.ISPacketPlayerPosLook)1 Entity (net.minecraft.entity.Entity)1 CPacketPlayerTryUseItem (net.minecraft.network.play.client.CPacketPlayerTryUseItem)1 SPacketEntityVelocity (net.minecraft.network.play.server.SPacketEntityVelocity)1 SPacketExplosion (net.minecraft.network.play.server.SPacketExplosion)1 Vec3d (net.minecraft.util.math.Vec3d)1