Skip to content

Commit

Permalink
+ Full release (yay)
Browse files Browse the repository at this point in the history
= Teleporting to garden should produce way less false tp checks - lmk if it works properly for you
+ Pests Destroyer - If starts from spawn, it will directly fly to the closest plot with pest, instead of using fireworks all the time
= Visitors - Pathfinder crash fix
= Pests Destroyer - Obstructed spawn detection possible fix
+ Debug Hud - Added running features for easier debugging
- Removed unused code
  • Loading branch information
May2Beez committed Jan 8, 2024
1 parent d826af5 commit 6b336f4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
44 changes: 22 additions & 22 deletions src/main/java/com/jelly/farmhelperv2/handler/RotationHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ public void easeTo(RotationConfiguration configuration) {
easingModifier = (random.nextFloat() * 0.5f - 0.25f);
dontRotate.reset();
startTime = System.currentTimeMillis();
startRotation.setRotation(configuration.getFrom());
startRotation.setRotation(configuration.from());
Rotation neededChange;
randomAddition = (Math.random() * 0.3 - 0.15);
if (configuration.getTarget().isPresent() && configuration.getTarget().get().getTarget().isPresent()) {
neededChange = getNeededChange(startRotation, configuration.getTarget().get().getTarget().get());
} else if (configuration.getTo().isPresent()) {
neededChange = getNeededChange(startRotation, configuration.getTo().get());
if (configuration.target().isPresent() && configuration.target().get().getTarget().isPresent()) {
neededChange = getNeededChange(startRotation, configuration.target().get().getTarget().get());
} else if (configuration.to().isPresent()) {
neededChange = getNeededChange(startRotation, configuration.to().get());
} else {
throw new IllegalArgumentException("No target or rotation specified!");
}
Expand All @@ -76,7 +76,7 @@ public void easeTo(RotationConfiguration configuration) {
float absYaw = Math.max(Math.abs(neededChange.getYaw()), 1);
float absPitch = Math.max(Math.abs(neededChange.getPitch()), 1);
float pythagoras = pythagoras(absYaw, absPitch);
float time = getTime(pythagoras, configuration.getTime());
float time = getTime(pythagoras, configuration.time());
endTime = (long) (System.currentTimeMillis() + Math.max(time, 50 + Math.random() * 100));
rotating = true;
}
Expand Down Expand Up @@ -107,17 +107,17 @@ public void easeBackFromServerRotation() {
LogUtils.sendDebug("[Rotation] Easing back from server rotation");
configuration.goingBackToClientSide(true);
startTime = System.currentTimeMillis();
configuration.setTarget(Optional.empty());
configuration.target(Optional.empty());
startRotation.setRotation(new Rotation(serverSideYaw, serverSidePitch));
Rotation neededChange = getNeededChange(startRotation, new Rotation(clientSideYaw, clientSidePitch));
targetRotation.setYaw(startRotation.getYaw() + neededChange.getYaw());
targetRotation.setPitch(startRotation.getPitch() + neededChange.getPitch());

LogUtils.sendDebug("[Rotation] Needed change: " + neededChange.getYaw() + " " + neededChange.getPitch());

float time = configuration.getTime();
float time = configuration.time();
endTime = System.currentTimeMillis() + Math.max((long) time, 50);
configuration.setCallback(Optional.of(this::reset));
configuration.callback(Optional.of(this::reset));
rotating = true;
}

Expand All @@ -126,7 +126,7 @@ private float pythagoras(float a, float b) {
}

public Rotation getNeededChange(Rotation target) {
if (configuration != null && configuration.getRotationType() == RotationConfiguration.RotationType.SERVER) {
if (configuration != null && configuration.rotationType() == RotationConfiguration.RotationType.SERVER) {
return getNeededChange(new Rotation(serverSideYaw, serverSidePitch), target);
} else {
return getNeededChange(new Rotation(mc.thePlayer.rotationYaw, mc.thePlayer.rotationPitch), target);
Expand Down Expand Up @@ -239,18 +239,18 @@ private float easeOutBack(float x) {

@SubscribeEvent
public void onRender(RenderWorldLastEvent event) {
if (!rotating || configuration == null || configuration.getRotationType() != RotationConfiguration.RotationType.CLIENT)
if (!rotating || configuration == null || configuration.rotationType() != RotationConfiguration.RotationType.CLIENT)
return;

if (mc.currentScreen != null || dontRotate.isScheduled() && !dontRotate.passed()) {
endTime = System.currentTimeMillis() + configuration.getTime();
endTime = System.currentTimeMillis() + configuration.time();
return;
}

if (System.currentTimeMillis() >= endTime) {
// finish
if (configuration.getCallback().isPresent()) {
configuration.getCallback().get().run();
if (configuration.callback().isPresent()) {
configuration.callback().get().run();
} else { // No callback, just reset
if (Math.abs(mc.thePlayer.rotationYaw - targetRotation.getYaw()) < 0.1 && Math.abs(mc.thePlayer.rotationPitch - targetRotation.getPitch()) < 0.1) {
mc.thePlayer.rotationYaw = targetRotation.getYaw();
Expand All @@ -265,7 +265,7 @@ public void onRender(RenderWorldLastEvent event) {
return;
}

if (configuration.followTarget() && configuration.getTarget().isPresent() && delayBetweenTargetFollow.passed()) {
if (configuration.followTarget() && configuration.target().isPresent() && delayBetweenTargetFollow.passed()) {
adjustTargetRotation(false);
}
mc.thePlayer.rotationYaw = interpolate(startRotation.getYaw(), targetRotation.getYaw(), configuration.easeOutBack() ? this::easeOutBack : this::easeOutExpo);
Expand All @@ -274,16 +274,16 @@ public void onRender(RenderWorldLastEvent event) {

@SubscribeEvent(receiveCanceled = true)
public void onUpdatePre(MotionUpdateEvent.Pre event) {
if (!rotating || configuration == null || configuration.getRotationType() != RotationConfiguration.RotationType.SERVER) {
if (!rotating || configuration == null || configuration.rotationType() != RotationConfiguration.RotationType.SERVER) {
serverSidePitch = event.pitch;
serverSideYaw = event.yaw;
return;
}

if (System.currentTimeMillis() >= endTime) {
// finish
if (configuration.getCallback().isPresent()) {
configuration.getCallback().get().run();
if (configuration.callback().isPresent()) {
configuration.callback().get().run();
} else { // No callback, just reset
reset();
return;
Expand All @@ -295,7 +295,7 @@ public void onUpdatePre(MotionUpdateEvent.Pre event) {
clientSidePitch = mc.thePlayer.rotationPitch;
clientSideYaw = mc.thePlayer.rotationYaw;
// rotating
if (configuration.followTarget() && configuration.getTarget().isPresent() && !configuration.goingBackToClientSide() && delayBetweenTargetFollow.passed()) {
if (configuration.followTarget() && configuration.target().isPresent() && !configuration.goingBackToClientSide() && delayBetweenTargetFollow.passed()) {
adjustTargetRotation(true);
}
if (configuration.goingBackToClientSide()) {
Expand All @@ -306,7 +306,7 @@ public void onUpdatePre(MotionUpdateEvent.Pre event) {
if (mc.currentScreen != null || dontRotate.isScheduled() && !dontRotate.passed()) {
event.yaw = serverSideYaw;
event.pitch = serverSidePitch;
endTime = System.currentTimeMillis() + configuration.getTime();
endTime = System.currentTimeMillis() + configuration.time();
} else {
float interX = interpolate(startRotation.getYaw(), targetRotation.getYaw(), configuration.easeOutBack() ? this::easeOutBack : this::easeOutExpo);
float interY = interpolate(startRotation.getPitch(), targetRotation.getPitch(), configuration.easeOutBack() ? this::easeOutBack : this::easeOutExpo);
Expand All @@ -322,7 +322,7 @@ public void onUpdatePre(MotionUpdateEvent.Pre event) {
}

private void adjustTargetRotation(boolean serverSide) {
Target target = configuration.getTarget().get();
Target target = configuration.target().get();
Rotation rot;
if (target.getEntity() != null) {
rot = getRotation(target.getEntity());
Expand All @@ -345,7 +345,7 @@ private void adjustTargetRotation(boolean serverSide) {
@SubscribeEvent(receiveCanceled = true)
public void onUpdatePost(MotionUpdateEvent.Post event) {
if (!rotating) return;
if (configuration == null || configuration.getRotationType() != RotationConfiguration.RotationType.SERVER)
if (configuration == null || configuration.rotationType() != RotationConfiguration.RotationType.SERVER)
return;

mc.thePlayer.rotationYaw = clientSideYaw;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class MixinModelBiped {

@Inject(method = {"setRotationAngles"}, at = {@At(value = "FIELD", target = "Lnet/minecraft/client/model/ModelBiped;swingProgress:F")})
public void onSetRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn, CallbackInfo ci) {
if (!RotationHandler.getInstance().isRotating() || RotationHandler.getInstance().getConfiguration() != null && RotationHandler.getInstance().getConfiguration().getRotationType() != RotationConfiguration.RotationType.SERVER)
if (!RotationHandler.getInstance().isRotating() || RotationHandler.getInstance().getConfiguration() != null && RotationHandler.getInstance().getConfiguration().rotationType() != RotationConfiguration.RotationType.SERVER)
return;

if (entityIn != null && entityIn.equals(Minecraft.getMinecraft().thePlayer)) {
Expand Down

0 comments on commit 6b336f4

Please sign in to comment.