Skip to content

Commit

Permalink
PestsDestroyer:
Browse files Browse the repository at this point in the history
 = Flying adjustments

Auto God Pot:
 = Fixed stuck after hypixel's item lore changes
  • Loading branch information
May2Beez committed Mar 7, 2024
1 parent 9b0792b commit da7a1c7
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 46 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ baseGroup=com.jelly.farmhelperv2
mcVersion=1.8.9
modid=farmhelperv2
modName=FarmHelper
version=2.4.5-pre24
version=2.4.5-pre25
shouldRelease=true
64 changes: 31 additions & 33 deletions src/main/java/com/jelly/farmhelperv2/feature/impl/AutoGodPot.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

import cc.polyfrost.oneconfig.utils.Multithreading;
import com.jelly.farmhelperv2.config.FarmHelperConfig;
import com.jelly.farmhelperv2.failsafe.Failsafe;
import com.jelly.farmhelperv2.failsafe.FailsafeManager;
import com.jelly.farmhelperv2.feature.FeatureManager;
import com.jelly.farmhelperv2.feature.IFeature;
import com.jelly.farmhelperv2.handler.GameStateHandler;
import com.jelly.farmhelperv2.handler.MacroHandler;
import com.jelly.farmhelperv2.handler.RotationHandler;
import com.jelly.farmhelperv2.util.*;
import com.jelly.farmhelperv2.util.InventoryUtils;
import com.jelly.farmhelperv2.util.KeyBindUtils;
import com.jelly.farmhelperv2.util.LogUtils;
import com.jelly.farmhelperv2.util.PlayerUtils;
import com.jelly.farmhelperv2.util.helper.Clock;
import com.jelly.farmhelperv2.util.helper.Rotation;
import com.jelly.farmhelperv2.util.helper.RotationConfiguration;
Expand All @@ -27,7 +28,6 @@
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;

import java.awt.*;
import java.util.ArrayList;
import java.util.Objects;
import java.util.Optional;
Expand Down Expand Up @@ -133,7 +133,14 @@ public void start() {

@Override
public void stop() {
if (!enabled) return;
resetStates();
LogUtils.sendWarning("[Auto God Pot] Disabled!");
if (shouldTpToGarden) {
MacroHandler.getInstance().triggerWarpGarden(true, true);
}
}

private void resetStates() {
enabled = false;
stuckClock.reset();
delayClock.reset();
Expand All @@ -145,28 +152,7 @@ public void stop() {
resetBitsShopState();
godPotMode = GodPotMode.NONE;
KeyBindUtils.stopMovement();
LogUtils.sendWarning("[Auto God Pot] Disabled!");
shouldTpToGarden = true;
teleportToGarden();
}

private void teleportToGarden() {
if (teleportTries >= 3) {
LogUtils.sendError("[Auto God Pot] Could not teleport to garden after 3 tries! Disabling Auto God Pot!");
LogUtils.webhookLog("[Auto God Pot]\\nCould not teleport to garden after 3 tries! Disabling Auto God Pot!");
teleportTries = 0;
return;
}
Multithreading.schedule(() -> {
if (!GameStateHandler.getInstance().inGarden() && shouldTpToGarden) {
MacroHandler.getInstance().triggerWarpGarden(true, true);
teleportToGarden();
teleportTries++;
} else if (GameStateHandler.getInstance().inGarden() && MacroHandler.getInstance().isMacroToggled()) {
MacroHandler.getInstance().resumeMacro();
teleportTries = 0;
}
}, 4_000, TimeUnit.MILLISECONDS);
}

@Override
Expand Down Expand Up @@ -223,6 +209,13 @@ public void onTickUpdate(TickEvent.ClientTickEvent event) {
return;
}

if (stuckClock.isScheduled() && stuckClock.passed()) {
LogUtils.sendWarning("[Auto God Pot] Stuck for too long! Restarting!");
resetStates();
start();
return;
}

if (delayClock.isScheduled() && !delayClock.passed()) return;

switch (godPotMode) {
Expand Down Expand Up @@ -907,7 +900,14 @@ private void onBitsShop() {
delayClock.schedule(FarmHelperConfig.getRandomGUIMacroDelay());
break;
}
if (!Objects.requireNonNull(InventoryUtils.getInventoryName()).contains("Community Shop")) break;
String invNam = InventoryUtils.getInventoryName();
if (invNam == null) break;
if (!invNam.contains("Community Shop")) {
PlayerUtils.closeScreen();
delayClock.schedule(FarmHelperConfig.getRandomGUIMacroDelay());
stuckClock.schedule(STUCK_DELAY);
break;
}
Slot bitsShopTab = InventoryUtils.getSlotOfItemInContainer("Bits Shop");
if (bitsShopTab == null) break;
ArrayList<String> lore = InventoryUtils.getItemLore(bitsShopTab.getStack());
Expand All @@ -933,7 +933,7 @@ private void onBitsShop() {
if (confirm == null) break;
ArrayList<String> lore2 = InventoryUtils.getItemLore(confirm.getStack());
for (String line : lore2) {
if (line.contains("Confirmation: Enabled!")) {
if (line.contains("Confirmations: Enabled!")) {
InventoryUtils.clickContainerSlot(confirm.slotNumber, InventoryUtils.ClickType.LEFT, InventoryUtils.ClickMode.PICKUP);
setBitsShopState(BitsShopState.CLICK_GOD_POT);
delayClock.schedule(FarmHelperConfig.getRandomGUIMacroDelay());
Expand Down Expand Up @@ -999,11 +999,9 @@ public void onChatReceived(ClientChatReceivedEvent event) {
delayClock.schedule(FarmHelperConfig.getRandomGUIMacroDelay());
}
}
if (bitsShopState == BitsShopState.WAITING_FOR_BUY) {
if (message.startsWith("You bought God Potion!")) {
setBitsShopState(BitsShopState.END);
delayClock.schedule(FarmHelperConfig.getRandomGUIMacroDelay());
}
if (message.startsWith("You bought God Potion!")) {
setBitsShopState(BitsShopState.END);
delayClock.schedule(FarmHelperConfig.getRandomGUIMacroDelay());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ public void stop() {
FlyPathfinder.getInstance().stuckCounterWithMotion = 0;
FlyPathfinder.getInstance().stuckCounterWithoutMotion = 0;
state = States.IDLE;
KeyBindUtils.stopMovement();
FlyPathFinderExecutor.getInstance().stop();
KeyBindUtils.stopMovement();
}

@Override
Expand Down Expand Up @@ -424,7 +424,7 @@ public void onTickExecute(TickEvent.ClientTickEvent event) {
delayClock.schedule((long) (500 + Math.random() * 500));
return;
}
if (GameStateHandler.getInstance().getCurrentPlot() == plotNumberOpt.get().plotNumber) {
if (GameStateHandler.getInstance().getCurrentPlot() == plotNumberOpt.get().plotNumber && BlockUtils.canFlyHigher(8)) {
state = States.GET_LOCATION;
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ public void onTick(TickEvent.ClientTickEvent event) {
return;
}

if (!GameStateHandler.getInstance().inGarden()) {
if (!GameStateHandler.getInstance().inGarden() && !this.isTeleporting()) {
if (!FeatureManager.getInstance().shouldIgnoreFalseCheck() && !FailsafeManager.getInstance().triggeredFailsafe.isPresent()) {
FailsafeManager.getInstance().possibleDetection(WorldChangeFailsafe.getInstance());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public void findPath(Entity target, boolean follow, boolean smooth, float yModif
Vec3 targetPos = new Vec3(target.posX, target.posY, target.posZ);
Rotation rotation = RotationHandler.getInstance().getRotation(targetPos, mc.thePlayer.getPositionVector());
Vec3 direction = AngleUtils.getVectorForRotation(0, rotation.getYaw());
targetPos = targetPos.addVector(direction.xCoord * 1, 0, direction.zCoord * 1);
targetPos = targetPos.addVector(direction.xCoord * 1.2, 0.5, direction.zCoord * 1.2);
findPath(targetPos.addVector(0, this.yModifier, 0), follow, smooth);
}
}
Expand Down Expand Up @@ -371,15 +371,15 @@ public void onTickNeededYaw(TickEvent.ClientTickEvent event) {
float velocity = (float) Math.sqrt(mc.thePlayer.motionX * mc.thePlayer.motionX + mc.thePlayer.motionZ * mc.thePlayer.motionZ);
float entityVelocity = (float) Math.sqrt(targetEntity.motionX * targetEntity.motionX + targetEntity.motionZ * targetEntity.motionZ);
Vec3 targetPos = targetEntity.getPositionVector().addVector(0, this.yModifier, 0);
if (entityVelocity > 0.12) {
targetPos = targetPos.addVector(targetEntity.motionX * 1, targetEntity.motionY, targetEntity.motionZ * 1);
}
float distance = (float) mc.thePlayer.getPositionVector().distanceTo(targetPos);
System.out.println("Velo: " + velocity);
System.out.println("TargetPos: " + targetPos);
System.out.println("Distance: " + distance);
System.out.println("EntityVelo: " + entityVelocity);
if (entityVelocity > 0.12) {
targetPos = targetPos.addVector(targetEntity.motionX * 1.5, targetEntity.motionY, targetEntity.motionZ * 1.5);
}
if (willArriveAtDestinationAfterStopping(targetPos)) {
if (willArriveAtDestinationAfterStopping(copyPath.get(copyPath.size() - 1))) {
System.out.println("Will arrive");
stop();
return;
Expand Down Expand Up @@ -493,7 +493,7 @@ private Vec3 predictStoppingPosition() {
PlayerSimulation playerSimulation = new PlayerSimulation(mc.theWorld);
playerSimulation.copy(mc.thePlayer);
playerSimulation.isFlying = true;
playerSimulation.rotationYaw = neededYaw != Integer.MIN_VALUE ? neededYaw : mc.thePlayer.rotationYaw;
playerSimulation.rotationYaw = neededYaw != Integer.MIN_VALUE && !FarmHelperConfig.flyPathfinderOringoCompatible ? neededYaw : mc.thePlayer.rotationYaw;
for (int i = 0; i < 30; i++) {
playerSimulation.onLivingUpdate();
if (Math.abs(playerSimulation.motionX) < 0.01D && Math.abs(playerSimulation.motionZ) < 0.01D) {
Expand Down
17 changes: 14 additions & 3 deletions src/main/java/com/jelly/farmhelperv2/util/BlockUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -349,11 +349,22 @@ public static boolean canWalkThroughDoor(BlockPos blockPos, Direction direction)
return canWalkThroughDoorWithDirection(direction, playerFacing, doorFacing, standingOnDoor);
}

private static final Vec3[] BLOCK_SIDE_MULTIPLIERS = new Vec3[]{
new Vec3(-0.45, 0, -0.45),
new Vec3(-0.45, 0, 0.45),
new Vec3(0.45, 0, -0.45),
new Vec3(0.45, 0, 0.45)
};

public static boolean canFlyHigher(int distance) {
Vec3 vec = mc.thePlayer.getPositionEyes(1);
Vec3 vec1 = vec.addVector(0, distance, 0);
MovingObjectPosition mop = mc.theWorld.rayTraceBlocks(vec, vec1, false, true, false);
return mop == null || mop.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK;
for (Vec3 vec3 : BLOCK_SIDE_MULTIPLIERS) {
MovingObjectPosition mop = mc.theWorld.rayTraceBlocks(vec.add(vec3), vec.addVector(0, distance, 0).add(vec3), false, true, false);
if (mop != null && mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
return false;
}
}
return true;
}

public static BlockPos getBlockPosLookingAt() {
Expand Down

0 comments on commit da7a1c7

Please sign in to comment.