aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/rosegoldaddons/utils/ShadyRotation.java
diff options
context:
space:
mode:
authorRoseGoldIsntGay <yoavkau@gmail.com>2022-07-27 21:47:43 +0300
committerRoseGoldIsntGay <yoavkau@gmail.com>2022-07-27 21:47:43 +0300
commit170ccfa42e36f04306820fbc3ef8a8ce3cf75010 (patch)
tree6728741f9a9befcb71ce1f27262073c984affe9a /src/main/java/rosegoldaddons/utils/ShadyRotation.java
parent854c131bf7965cef66d37e80640999242c9e0d65 (diff)
downloadRGA-master.tar.gz
RGA-master.tar.bz2
RGA-master.zip
last update for a whileHEADmaster
imma be real with y'all this is really old changes i never pushed to git so forgive me if the changelog is partial added an autoclicker that probably gets u banned added auto leave limbo added three weirdos auto solver added block size modifiers for dungeons i changed a log of stuff probably bug fixes have fun
Diffstat (limited to 'src/main/java/rosegoldaddons/utils/ShadyRotation.java')
-rw-r--r--src/main/java/rosegoldaddons/utils/ShadyRotation.java55
1 files changed, 52 insertions, 3 deletions
diff --git a/src/main/java/rosegoldaddons/utils/ShadyRotation.java b/src/main/java/rosegoldaddons/utils/ShadyRotation.java
index 111ea6e..3125aa2 100644
--- a/src/main/java/rosegoldaddons/utils/ShadyRotation.java
+++ b/src/main/java/rosegoldaddons/utils/ShadyRotation.java
@@ -2,10 +2,13 @@ package rosegoldaddons.utils;
import net.minecraft.entity.Entity;
import net.minecraft.util.BlockPos;
+import net.minecraft.util.MovementInput;
import net.minecraft.util.Vec3;
+import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;
import rosegoldaddons.Main;
+import rosegoldaddons.events.PlayerMoveEvent;
public class ShadyRotation {
private static float pitchDifference;
@@ -13,16 +16,33 @@ public class ShadyRotation {
private static int ticks = -1;
private static int tickCounter = 0;
private static Runnable callback = null;
+ private static boolean async = false;
+
+ private static float serverPitch;
+ private static float serverYaw;
public static boolean running = false;
+ public static boolean runningAsync = false;
public static class Rotation {
public float pitch;
public float yaw;
+ public boolean async;
public Rotation(float pitch, float yaw) {
this.pitch = pitch;
this.yaw = yaw;
+ this.async = false;
+ }
+
+ public Rotation(float pitch, float yaw, boolean async) {
+ this.pitch = pitch;
+ this.yaw = yaw;
+ this.async = async;
+ }
+
+ public void setAsync(boolean async) {
+ this.async = async;
}
}
@@ -76,7 +96,7 @@ public class ShadyRotation {
return new Rotation(pitch, yaw);
}
- public static void smoothLook(Rotation rotation, int ticks, Runnable callback) {
+ public static void smoothLook(Rotation rotation, int ticks, Runnable callback, boolean async) {
if(ticks == 0) {
look(rotation);
callback.run();
@@ -85,6 +105,7 @@ public class ShadyRotation {
ShadyRotation.callback = callback;
+ ShadyRotation.async = rotation.async;
pitchDifference = wrapAngleTo180(rotation.pitch - Main.mc.thePlayer.rotationPitch);
yawDifference = wrapAngleTo180(rotation.yaw - Main.mc.thePlayer.rotationYaw);
@@ -92,6 +113,10 @@ public class ShadyRotation {
ShadyRotation.tickCounter = 0;
}
+ public static void smoothLook(Rotation rotation, int ticks, Runnable callback) {
+ smoothLook(rotation, ticks, callback, false);
+ }
+
public static void smartLook(Rotation rotation, int ticksPer180, Runnable callback) {
float rotationDifference = Math.max(
Math.abs(rotation.pitch - Main.mc.thePlayer.rotationPitch),
@@ -105,16 +130,40 @@ public class ShadyRotation {
Main.mc.thePlayer.rotationYaw = rotation.yaw;
}
+ @SubscribeEvent(priority = EventPriority.HIGHEST)
+ public void onUpdatePre(PlayerMoveEvent.Pre pre) {
+ //if(Main.oringo) return;
+ serverPitch = Main.mc.thePlayer.rotationPitch;
+ serverYaw = Main.mc.thePlayer.rotationYaw;
+ }
+
+ @SubscribeEvent(priority = EventPriority.LOWEST)
+ public void onUpdatePost(PlayerMoveEvent.Post post) {
+ //if(Main.oringo) return;
+ Main.mc.thePlayer.rotationPitch = serverPitch;
+ Main.mc.thePlayer.rotationYaw = serverYaw;
+ }
+
@SubscribeEvent
public void onTick(TickEvent event) {
if(Main.mc.thePlayer == null) return;
if(tickCounter < ticks) {
- running = true;
+ if(!async) {
+ running = true;
+ runningAsync = false;
+ } else {
+ runningAsync = true;
+ running = false;
+ }
Main.mc.thePlayer.rotationPitch += pitchDifference / ticks;
Main.mc.thePlayer.rotationYaw += yawDifference / ticks;
tickCounter++;
} else if(callback != null) {
- running = false;
+ if(!async) {
+ running = false;
+ } else {
+ runningAsync = false;
+ }
callback.run();
callback = null;
}