Skip to content

Commit

Permalink
Improve reliability of NoRotate
Browse files Browse the repository at this point in the history
  • Loading branch information
Artamedes committed May 12, 2020
1 parent f0716ef commit 5cfc673
Showing 1 changed file with 52 additions and 4 deletions.
56 changes: 52 additions & 4 deletions src/main/java/me/ionar/salhack/module/movement/NoRotateModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import me.ionar.salhack.module.Module;
import me.zero.alpine.fork.listener.EventHandler;
import me.zero.alpine.fork.listener.Listener;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.network.play.client.CPacketConfirmTeleport;
import net.minecraft.network.play.client.CPacketPlayer;
import net.minecraft.network.play.server.SPacketPlayerPosLook;

public final class NoRotateModule extends Module
Expand All @@ -25,11 +28,56 @@ public String getMetaData()
{
if (p_Event.getPacket() instanceof SPacketPlayerPosLook)
{
if (mc.player != null)
if (mc.player != null && mc.currentScreen == null)
{
final SPacketPlayerPosLook packet = (SPacketPlayerPosLook) p_Event.getPacket();
packet.yaw = mc.player.rotationYaw;
packet.pitch = mc.player.rotationPitch;
p_Event.cancel();
EntityPlayer entityplayer = mc.player;
final SPacketPlayerPosLook packetIn = (SPacketPlayerPosLook) p_Event.getPacket();
double d0 = packetIn.getX();
double d1 = packetIn.getY();
double d2 = packetIn.getZ();
float f = packetIn.getYaw();
float f1 = packetIn.getPitch();

if (packetIn.getFlags().contains(SPacketPlayerPosLook.EnumFlags.X))
{
d0 += entityplayer.posX;
}
else
{
entityplayer.motionX = 0.0D;
}

if (packetIn.getFlags().contains(SPacketPlayerPosLook.EnumFlags.Y))
{
d1 += entityplayer.posY;
}
else
{
entityplayer.motionY = 0.0D;
}

if (packetIn.getFlags().contains(SPacketPlayerPosLook.EnumFlags.Z))
{
d2 += entityplayer.posZ;
}
else
{
entityplayer.motionZ = 0.0D;
}

if (packetIn.getFlags().contains(SPacketPlayerPosLook.EnumFlags.X_ROT))
{
f1 += entityplayer.rotationPitch;
}

if (packetIn.getFlags().contains(SPacketPlayerPosLook.EnumFlags.Y_ROT))
{
f += entityplayer.rotationYaw;
}
entityplayer.setPosition(d0, d1, d2);
mc.getConnection().sendPacket(new CPacketConfirmTeleport(packetIn.getTeleportId()));
mc.getConnection().sendPacket(new CPacketPlayer.PositionRotation(entityplayer.posX, entityplayer.getEntityBoundingBox().minY, entityplayer.posZ, packetIn.yaw, packetIn.pitch, false));
}
}
});
Expand Down

0 comments on commit 5cfc673

Please sign in to comment.