Skip to content

Commit

Permalink
Experimental update
Browse files Browse the repository at this point in the history
AutoBazaar:
= Fixed buying items in a loop

Evacuate failsafe:
= Fixed continuing farming during breaks

Pests Destroyer:
= Possibly fixed triggering false teleport failsafes during AOTV/E usage

Remote Control:
= Fixed Screenshot command rotating the player

Auto Repellent:
= Possibly fixed getting wrong items
  • Loading branch information
onixiya1337 committed Aug 30, 2024
1 parent b3be590 commit 5f35df4
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 29 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.8.9-pre6
version=2.8.9-pre7
shouldRelease=true
5 changes: 0 additions & 5 deletions src/main/java/com/jelly/farmhelperv2/FarmHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,6 @@ public void onTickSendInfoAboutShittyClient(TickEvent.PlayerTickEvent event) {
LogUtils.sendNotification("Farm Helper", "You've got Oringo installed in your mods folder! FarmHelper will use Oringo compatibility mode for FlyPathfinder.", 15000);
LogUtils.sendWarning("You've got §6§lOringo §cinstalled in your mods folder! FarmHelper will use Oringo compatibility mode for FlyPathfinder.");
}
if (FarmHelperConfig.failsafeCutoffAfterUsingAoteV == 100 && FarmHelperConfig.configVersion < 5) {
FarmHelperConfig.failsafeCutoffAfterUsingAoteV = 500;
LogUtils.sendNotification("Farm Helper", "Failsafe 'Cutoff After Using AOTE/V' has been set to 500 automatically to prevent false positives.", 15000);
LogUtils.sendWarning("Failsafe 'Cutoff After Using AOTE/V' has been set to 500 automatically to prevent false positives.");
}
if (FarmHelperConfig.configVersion == 3 && FarmHelperConfig.macroType > 7) {
FarmHelperConfig.macroType += 1; // Added cocoa bean macro with trapdoors
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1193,14 +1193,7 @@ public class FarmHelperConfig extends Config {
name = "Use AOTE/V in Pests Destroyer", category = PESTS_DESTROYER, subcategory = "Pests Destroyer",
description = "Uses AOTE/V in Pests Destroyer"
)
public static boolean useAoteVInPestsDestroyer = true;

@Slider(
name = "Failsafe cutoff after using AOTE/V", category = PESTS_DESTROYER, subcategory = "Pests Destroyer",
description = "The time in ms after which macro will count failsafes after using AOTE/V",
min = 0, max = 1500
)
public static int failsafeCutoffAfterUsingAoteV = 500;
public static boolean useAoteVInPestsDestroyer = false;

@Switch(
name = "Don't teleport to plots when the spawn is not obstructed", category = PESTS_DESTROYER, subcategory = "Pests Destroyer",
Expand Down Expand Up @@ -2175,7 +2168,6 @@ public FarmHelperConfig() {
this.addDependency("pestAdditionalGUIDelay", "enablePestsDestroyer");
this.addDependency("sprintWhileFlying", "enablePestsDestroyer");
this.addDependency("pausePestsDestroyerDuringJacobsContest", "enablePestsDestroyer");
this.addDependency("failsafeCutoffAfterUsingAoteV", "useAoteVInPestsDestroyer");


this.hideIf("infoCookieBuffRequired", () -> GameStateHandler.getInstance().inGarden() || GameStateHandler.getInstance().getCookieBuffState() == BuffState.NOT_ACTIVE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.jelly.farmhelperv2.config.page.FailsafeNotificationsPage;
import com.jelly.farmhelperv2.failsafe.Failsafe;
import com.jelly.farmhelperv2.failsafe.FailsafeManager;
import com.jelly.farmhelperv2.feature.impl.Scheduler;
import com.jelly.farmhelperv2.handler.GameStateHandler;
import com.jelly.farmhelperv2.handler.MacroHandler;
import com.jelly.farmhelperv2.util.LogUtils;
Expand Down Expand Up @@ -114,7 +115,8 @@ public void duringFailsafeTrigger() {
public void endOfFailsafeTrigger() {
FailsafeManager.getInstance().stopFailsafes();
FailsafeManager.getInstance().setHadEmergency(false);
MacroHandler.getInstance().resumeMacro();
if (Scheduler.getInstance().isFarming())
MacroHandler.getInstance().resumeMacro();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public void onChatReceive(ClientChatReceivedEvent event) {
String message = StringUtils.stripControlCodes(event.message.getUnformattedText());
String boughtMessage = String.format("[Bazaar] Bought %dx %s for", this.buyAmount, this.itemToBuy);

if (message.startsWith(boughtMessage) && this.buyState == BuyState.BUY_VERIFY) {
if (message.startsWith(boughtMessage) && (this.buyState == BuyState.BUY_VERIFY || this.buyState == BuyState.WARNING_PAGE)) {
this.buyState = BuyState.DISABLE;
this.timer.schedule(500);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public void start() {
state = State.NONE;
LogUtils.sendWarning("[Auto Repellent] Enabled!");
delay.reset();
hotbarSlot = -1;
MacroHandler.getInstance().pauseMacro();
IFeature.super.start();
}
Expand Down Expand Up @@ -243,7 +244,7 @@ public void onTickExecution(TickEvent.ClientTickEvent event) {
delay.schedule(300 + (long) (Math.random() * 300));
break;
}
int repellentSlot = InventoryUtils.getSlotIdOfItemInInventory("Pest Repellent");
int repellentSlot = InventoryUtils.getSlotOfItemByHypixelIdInInventory("PEST_REPELLENT", true);
if (repellentSlot == -1) {
LogUtils.sendError("Something went wrong while trying to get the slot of the Pest Repellent! Disabling Auto Repellent until manual check");
FarmHelperConfig.autoPestRepellent = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.google.common.collect.EvictingQueue;
import com.jelly.farmhelperv2.config.FarmHelperConfig;
import com.jelly.farmhelperv2.event.ReceivePacketEvent;
import com.jelly.farmhelperv2.feature.impl.LagDetector;
import com.jelly.farmhelperv2.handler.RotationHandler;
import com.jelly.farmhelperv2.mixin.client.EntityPlayerAccessor;
import com.jelly.farmhelperv2.mixin.pathfinder.PathfinderAccessor;
Expand Down Expand Up @@ -265,7 +266,7 @@ public void stop() {
path.clear();
target = null;
tped = true;
aotvDely.reset();
aotvDelay.reset();
targetEntity = null;
yModifier = 0;
lastTpTime = 0;
Expand Down Expand Up @@ -315,7 +316,7 @@ public void onTick(TickEvent.ClientTickEvent event) {
}

private final Clock loweringRaisingDelay = new Clock();
private final Clock aotvDely = new Clock();
private final Clock aotvDelay = new Clock();
private boolean tped = true;

@SubscribeEvent
Expand Down Expand Up @@ -437,11 +438,11 @@ else if (this.neededYaw != Integer.MIN_VALUE) {
}
}

if (FarmHelperConfig.useAoteVInPestsDestroyer && tped && useAOTV && aotvDely.passed() && mc.thePlayer.getDistance(next.xCoord, mc.thePlayer.getPositionVector().yCoord, next.zCoord) > 12 && !RotationHandler.getInstance().isRotating() && isFrontClean()) {
if (FarmHelperConfig.useAoteVInPestsDestroyer && tped && useAOTV && aotvDelay.passed() && mc.thePlayer.getDistance(next.xCoord, mc.thePlayer.getPositionVector().yCoord, next.zCoord) > 12 && !RotationHandler.getInstance().isRotating() && isFrontClean()) {
int aotv = InventoryUtils.getSlotIdOfItemInHotbar("Aspect of the Void", "Aspect of the End");
if (aotv != mc.thePlayer.inventory.currentItem) {
mc.thePlayer.inventory.currentItem = aotv;
aotvDely.schedule(150);
aotvDelay.schedule(150);
} else {
KeyBindUtils.rightClick();
tped = false;
Expand Down Expand Up @@ -511,15 +512,15 @@ public void onTeleportPacket(ReceivePacketEvent event) {
lastTpTime = System.currentTimeMillis() - 50;
Multithreading.schedule(() -> {
if (isRunning()) {
aotvDely.schedule(100 + Math.random() * 60);
aotvDelay.schedule(100 + Math.random() * 60);
tped = true;
}
}, 50, TimeUnit.MILLISECONDS);
}
}

public boolean hasJustTped() {
return lastTpTime + FarmHelperConfig.failsafeCutoffAfterUsingAoteV > System.currentTimeMillis();
return lastTpTime + LagDetector.getInstance().getLaggingTime() + 500 > System.currentTimeMillis();
}

private boolean isFrontClean() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.jelly.farmhelperv2.remote.struct.RemoteMessage;
import com.jelly.farmhelperv2.util.InventoryUtils;
import com.jelly.farmhelperv2.util.PlayerUtils;
import net.minecraft.client.gui.inventory.GuiInventory;

import java.util.concurrent.TimeUnit;

Expand Down Expand Up @@ -54,11 +55,13 @@ public void inventory() {

Multithreading.schedule(() -> {
try {
InventoryUtils.openInventory();
if (mc.currentScreen == null)
InventoryUtils.openInventory();
Thread.sleep(1000);
String screenshot = getScreenshot();
Thread.sleep(1000);
PlayerUtils.closeScreen();
if (mc.currentScreen instanceof GuiInventory)
PlayerUtils.closeScreen();
if (wasMacroing) {
MacroHandler.getInstance().resumeMacro();
}
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/com/jelly/farmhelperv2/util/InventoryUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,18 @@ public static Slot getSlotOfItemInInventory(String item) {
return null;
}

public static int getSlotOfItemByHypixelIdInInventory(String hypixelId) {
public static int getSlotOfItemByHypixelIdInInventory(String hypixelId, boolean contains) {
for (Slot slot : mc.thePlayer.inventoryContainer.inventorySlots) {
if (slot.getHasStack()) {
NBTTagCompound tag = slot.getStack().getTagCompound();
if (tag != null && tag.hasKey("ExtraAttributes")) {
NBTTagCompound extraAttributes = tag.getCompoundTag("ExtraAttributes");
if (extraAttributes.hasKey("id")) {
String id = extraAttributes.getString("id");
if (id.equals(hypixelId)) {
return slot.getSlotIndex();
if (contains && id.contains(hypixelId)) {
return slot.slotNumber;
} else if (id.equals(hypixelId)) {
return slot.slotNumber;
}
}
}
Expand Down

0 comments on commit 5f35df4

Please sign in to comment.