Skip to content

Commit

Permalink
Fly Pathfinder:
Browse files Browse the repository at this point in the history
 = Decreased amount of false tp or rotation checks during using aote/v (AGAIN)

Log Utils:
 - Removed one temporary console log

Auto Sell:
 = Tweaks

Macros:
 = Saving state changes
  • Loading branch information
May2Beez committed Apr 28, 2024
1 parent 3c703c2 commit 5504a15
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 27 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.6.12
version=2.6.13
shouldRelease=true
Original file line number Diff line number Diff line change
Expand Up @@ -2076,11 +2076,11 @@ public FarmHelperConfig() {
registerKeyBind(openGuiKeybind, this::openGui);
registerKeyBind(toggleMacro, () -> MacroHandler.getInstance().toggleMacro());
registerKeyBind(debugKeybind, () -> {
// if (MacroHandler.getInstance().isCurrentMacroPaused()) {
// MacroHandler.getInstance().resumeMacro();
// } else {
// MacroHandler.getInstance().pauseMacro();
// }
if (MacroHandler.getInstance().isCurrentMacroPaused()) {
MacroHandler.getInstance().resumeMacro();
} else {
MacroHandler.getInstance().pauseMacro();
}
});
registerKeyBind(freelookKeybind, () -> Freelook.getInstance().toggle());
registerKeyBind(plotCleaningHelperKeybind, () -> PlotCleaningHelper.getInstance().toggle());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ public void onReceivedPacketDetection(ReceivePacketEvent event) {
double playerPitch = mc.thePlayer.rotationPitch;
double yawDiff = Math.abs(packetYaw - playerYaw);
double pitchDiff = Math.abs(packetPitch - playerPitch);
LogUtils.sendDebug("tp: " + FlyPathFinderExecutor.getInstance().isTping() + " lastTpTime: " + (FlyPathFinderExecutor.getInstance().getLastTpTime() + 100 > System.currentTimeMillis()) + " isInCache: " + FlyPathFinderExecutor.getInstance().isRotationInCache((float) packetYaw, (float) packetPitch));
if (FlyPathFinderExecutor.getInstance().isRunning() && (FlyPathFinderExecutor.getInstance().isTping() || FlyPathFinderExecutor.getInstance().getLastTpTime() + 100 > System.currentTimeMillis() || FlyPathFinderExecutor.getInstance().isRotationInCache((float) packetYaw, (float) packetPitch))) {
LogUtils.sendDebug("tp: " + FlyPathFinderExecutor.getInstance().isTping() + " lastTpTime: " + (FlyPathFinderExecutor.getInstance().getLastTpTime() + 100 > System.currentTimeMillis()) + " isInCache: " + FlyPathFinderExecutor.getInstance().isRotationInCache((float) packetYaw, (float) packetPitch));
if (FlyPathFinderExecutor.getInstance().isTping()) {
LogUtils.sendDebug("[Failsafe] Rotation packet received while Fly pathfinder is teleporting. Ignoring");
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ public void onReceivedPacketDetection(ReceivePacketEvent event) {
LogUtils.sendDebug("[Failsafe] Player is below Y = 0. Ignoring");
return;
}
LogUtils.sendDebug("tp: " + FlyPathFinderExecutor.getInstance().isTping() + " lastTpTime: " + (FlyPathFinderExecutor.getInstance().getLastTpTime() + 100 > System.currentTimeMillis()) + " isInCache: " + FlyPathFinderExecutor.getInstance().isPositionInCache(packetPlayerBlockPos));
if (FlyPathFinderExecutor.getInstance().isRunning() && (FlyPathFinderExecutor.getInstance().isTping() || FlyPathFinderExecutor.getInstance().getLastTpTime() + 100 > System.currentTimeMillis() || FlyPathFinderExecutor.getInstance().isPositionInCache(packetPlayerBlockPos))) {
LogUtils.sendDebug("tp: " + FlyPathFinderExecutor.getInstance().isTping() + " lastTpTime: " + (FlyPathFinderExecutor.getInstance().getLastTpTime() + 100 > System.currentTimeMillis()) + " isInCache: " + FlyPathFinderExecutor.getInstance().isPositionInCache(packetPlayerBlockPos));
if (FlyPathFinderExecutor.getInstance().isTping()) {
LogUtils.sendDebug("[Failsafe] Teleport packet received while Fly pathfinder is teleporting. Ignoring");
return;
Expand Down
23 changes: 11 additions & 12 deletions src/main/java/com/jelly/farmhelperv2/feature/impl/AutoSell.java
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ public void onTickEnabled(TickEvent.ClientTickEvent event) {
delayClock.schedule(FarmHelperConfig.getRandomGUIMacroDelay());
return;
}
if (!InventoryUtils.isInventoryLoaded()) break;
int sacksSlot;
if (FarmHelperConfig.autoSellSacksPlacement) {
if (InventoryUtils.getInventoryName() != null && !InventoryUtils.getInventoryName().contains("Sacks")) {
Expand Down Expand Up @@ -296,6 +297,7 @@ public void onTickEnabled(TickEvent.ClientTickEvent event) {
delayClock.schedule(FarmHelperConfig.getRandomGUIMacroDelay());
return;
}
if (!InventoryUtils.isInventoryLoaded()) break;
if (InventoryUtils.getInventoryName() != null && !InventoryUtils.getInventoryName().contains("Enchanted Agronomy Sack")) {
LogUtils.sendDebug("[Auto Sell] Wrong menu detected!");
PlayerUtils.closeScreen();
Expand Down Expand Up @@ -366,6 +368,7 @@ public void onTickEnabled(TickEvent.ClientTickEvent event) {
if (mc.currentScreen == null) {
break;
}
if (!InventoryUtils.isInventoryLoaded()) break;
if (InventoryUtils.getInventoryName() == null || !InventoryUtils.getInventoryName().contains("Bazaar")) {
break;
}
Expand Down Expand Up @@ -397,6 +400,7 @@ public void onTickEnabled(TickEvent.ClientTickEvent event) {
break;
case SELL_INV_CONFIRM:
if (mc.currentScreen == null) return;
if (!InventoryUtils.isInventoryLoaded()) break;
if (InventoryUtils.getInventoryName() == null || !InventoryUtils.getInventoryName().contains("Are you sure?")) {
break;
}
Expand Down Expand Up @@ -448,15 +452,15 @@ public void onTickEnabled(TickEvent.ClientTickEvent event) {
break;
}
setNpcState(NPCState.OPEN_MENU);
LogUtils.sendDebug("[Auto Sell] Opening Trades menu");
mc.thePlayer.sendChatMessage("/trades");
delayClock.schedule(FarmHelperConfig.getRandomGUIMacroDelay());
break;
case OPEN_MENU:
if (mc.currentScreen == null) {
LogUtils.sendDebug("[Auto Sell] Opening Trades menu");
mc.thePlayer.sendChatMessage("/trades");
delayClock.schedule(FarmHelperConfig.getRandomGUIMacroDelay());
setNpcState(NPCState.SELL);
break;
}
if (!InventoryUtils.isInventoryLoaded()) break;
if (InventoryUtils.getInventoryName() == null) {
break;
}
Expand All @@ -469,20 +473,15 @@ public void onTickEnabled(TickEvent.ClientTickEvent event) {
LogUtils.sendDebug("[Auto Sell] Detected wrong menu, closing it");
PlayerUtils.closeScreen();
delayClock.schedule(FarmHelperConfig.getRandomGUIMacroDelay());
setNpcState(NPCState.OPEN_MENU);
setNpcState(NPCState.NONE);
break;
case SELL:
if (mc.currentScreen == null) {
delayClock.schedule(FarmHelperConfig.getRandomGUIMacroDelay());
break;
}
if (InventoryUtils.getInventoryName() != null && !InventoryUtils.getInventoryName().contains("Trades")) {
LogUtils.sendDebug("[Auto Sell] Wrong menu detected!");
PlayerUtils.closeScreen();
delayClock.schedule(FarmHelperConfig.getRandomGUIMacroDelay());
setNpcState(NPCState.OPEN_MENU);
break;
} else if (InventoryUtils.getInventoryName() == null) {
if (!InventoryUtils.isInventoryLoaded()) break;
if (InventoryUtils.getInventoryName() == null || !InventoryUtils.getInventoryName().contains("Trades")) {
break;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ public void onEnable() {
restoredState = true;
savedState = Optional.empty();
GameStateHandler.getInstance().setUpdatedState(true);
GameStateHandler.getInstance().scheduleNotMoving((int) (FarmHelperConfig.rotationTime + FarmHelperConfig.rotationTimeRandomness + 50));
}
if (!closest90Deg.isPresent())
setClosest90Deg(Optional.of(AngleUtils.getClosest(getYaw())));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ else if (this.neededYaw != Integer.MIN_VALUE) {
if (!this.dontRotate) {
Vec3 lastElement = path.get(Math.max(0, path.size() - 1));
Rotation rot = RotationHandler.getInstance().getRotation(target.getTarget().get());
if (mc.thePlayer.getPositionVector().distanceTo(lastElement) > 2 && target.getTarget().isPresent() && RotationHandler.getInstance().shouldRotate(rot, 5)) {
if (mc.thePlayer.getPositionVector().distanceTo(lastElement) > 2 && target.getTarget().isPresent() && RotationHandler.getInstance().shouldRotate(rot, 3)) {
RotationHandler.getInstance().easeTo(new RotationConfiguration(
rot,
(long) (500 + Math.random() * 300),
Expand All @@ -442,15 +442,14 @@ else if (this.neededYaw != Integer.MIN_VALUE) {
aotvDely.reset();
}

if (FarmHelperConfig.useAoteVInPestsDestroyer && tped && useAOTV && aotvDely.passed() && mc.thePlayer.getDistance(next.xCoord, mc.thePlayer.getPositionVector().yCoord, next.zCoord) > 7.5 && !RotationHandler.getInstance().isRotating() && isFrontClean()) {
if (FarmHelperConfig.useAoteVInPestsDestroyer && tped && useAOTV && aotvDely.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);
} else {
KeyBindUtils.rightClick();
tped = false;
aotvDely.schedule(150 + Math.random() * 100);
}
}
}
Expand Down Expand Up @@ -508,12 +507,18 @@ else if (this.neededYaw != Integer.MIN_VALUE) {
KeyBindUtils.stopMovement(true);
}

@SubscribeEvent(priority = EventPriority.LOW)
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onTeleportPacket(ReceivePacketEvent event) {
if (!isRunning()) return;
if (event.packet instanceof S08PacketPlayerPosLook) {
tped = true;
lastTpTime = System.currentTimeMillis();
System.out.println("Tped");
Multithreading.schedule(() -> {
if (isRunning()) {
aotvDely.schedule(150 + Math.random() * 100);
tped = true;
lastTpTime = System.currentTimeMillis();
}
}, 50, TimeUnit.MILLISECONDS);
}
}

Expand Down
1 change: 0 additions & 1 deletion src/main/java/com/jelly/farmhelperv2/util/LogUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public static void sendError(String message) {

public static void sendDebug(String message) {
if (lastDebugMessage != null && lastDebugMessage.equals(message)) {
System.out.println("[Farm Helper] " + message + " (Duplicate message, not sending)");
return;
}
if (FarmHelperConfig.debugMode && mc.thePlayer != null)
Expand Down

0 comments on commit 5504a15

Please sign in to comment.