Skip to content

Commit

Permalink
Updated NoAfk
Browse files Browse the repository at this point in the history
  • Loading branch information
uoil committed Dec 9, 2020
1 parent 1c24d1c commit 54cb544
Showing 1 changed file with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import me.rigamortis.seppuku.api.event.network.EventSendPacket;
import me.rigamortis.seppuku.api.event.player.EventUpdateWalkingPlayer;
import me.rigamortis.seppuku.api.module.Module;
import me.rigamortis.seppuku.api.value.Value;
import net.minecraft.client.Minecraft;
import net.minecraft.network.play.client.CPacketPlayer;
import team.stiff.pomelo.impl.annotated.handler.annotation.Listener;
Expand All @@ -15,6 +16,9 @@
*/
public final class NoAfkModule extends Module {

public final Value<Integer> yawOffset = new Value<Integer>("Yaw", new String[]{"yaw", "y"}, "The yaw to alternate each tick.", 1, 0, 180, 1);
public final Value<Integer> pitchOffset = new Value<Integer>("Pitch", new String[]{"pitch", "x"}, "The pitch to alternate each tick.", 0, 0, 90, 1);

public NoAfkModule() {
super("NoAFK", new String[]{"AntiAFK"}, "Prevents you from being kicked while idle", "NONE", -1, ModuleType.MISC);
}
Expand All @@ -24,8 +28,14 @@ public void onWalkingUpdate(EventUpdateWalkingPlayer event) {
if (event.getStage() == EventStageable.EventStage.PRE) {
final Minecraft mc = Minecraft.getMinecraft();
float yaw = mc.player.rotationYaw;
yaw += (1 * Math.sin(mc.player.ticksExisted / Math.PI));
Seppuku.INSTANCE.getRotationManager().setPlayerRotations(yaw, mc.player.rotationPitch);
float pitch = mc.player.rotationPitch;
if (this.yawOffset.getValue() > 0) {
yaw += (this.yawOffset.getValue() * Math.sin(mc.player.ticksExisted / Math.PI));
}
if (this.pitchOffset.getValue() > 0) {
pitch += (this.pitchOffset.getValue() * Math.sin(mc.player.ticksExisted / Math.PI));
}
Seppuku.INSTANCE.getRotationManager().setPlayerRotations(yaw, pitch);
}
}

Expand All @@ -35,7 +45,12 @@ public void sendPacket(EventSendPacket event) {
if (event.getPacket() instanceof CPacketPlayer.Rotation) {
if (Minecraft.getMinecraft().player.getRidingEntity() != null) {
final CPacketPlayer.Rotation packet = (CPacketPlayer.Rotation) event.getPacket();
packet.yaw += (1 * Math.sin(Minecraft.getMinecraft().player.ticksExisted / Math.PI));
if (this.yawOffset.getValue() > 0) {
packet.yaw += (this.yawOffset.getValue() * Math.sin(Minecraft.getMinecraft().player.ticksExisted / Math.PI));
}
if (this.pitchOffset.getValue() > 0) {
packet.pitch += (this.pitchOffset.getValue() * Math.sin(Minecraft.getMinecraft().player.ticksExisted / Math.PI));
}
}
}
}
Expand Down

0 comments on commit 54cb544

Please sign in to comment.