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);
}
}
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));
}
}
}
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;
}
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;
}
}
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();
}
}
Aggregations