Skip to content

Commit

Permalink
Merge pull request JellyLabScripts#14 from mqtze/feature/autocomposter
Browse files Browse the repository at this point in the history
Feature/autocomposter
  • Loading branch information
mqtze authored Sep 2, 2024
2 parents c7c28ca + a7c17e7 commit 836568f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2337,6 +2337,15 @@ public FarmHelperConfig() {
this.addDependency("sprintWhileFlying", "enablePestsDestroyer");
this.addDependency("pausePestsDestroyerDuringJacobsContest", "enablePestsDestroyer");

this.addDependency("pauseAutoComposterDuringJacobsContest","autoComposter");
this.addDependency("autoComposterMinMoney","autoComposter");
this.addDependency("autoComposterMaxSpendLimit","autoComposter");
this.addDependency("autoComposterOrganicMatterLeft","autoComposter");
this.addDependency("autoComposterFuelLeft","autoComposter");
this.addDependency("autoComposterAutosellBeforeFilling","autoComposter");
this.addDependency("logAutoComposterEvents","enableWebHook");
this.addDependency("triggerManuallyAutoComposter","autoComposter");


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 @@ -139,6 +139,12 @@ public void stop() {

@Override
public void resetStatesAfterMacroDisabled() {
mainState = MainState.NONE;
travelState = TravelState.NONE;
composterState = ComposterState.NONE;
composterChecked = false;
buyState = BuyState.NONE;
itemsToBuy.clear();
if (!FarmHelperConfig.autoComposterAfkInfiniteMode) return;
FarmHelperConfig.autoComposterAfkInfiniteMode = false;
afkDelay.reset();
Expand Down Expand Up @@ -466,6 +472,7 @@ public void onComposterState() {
break;
}
if (invName.contains("Composter")) {
LogUtils.sendDebug("[Auto Composter] Checking Composter");
Slot organicMatterSlot = InventoryUtils.getSlotOfIdInContainer(37);
Slot fuelSlot = InventoryUtils.getSlotOfIdInContainer(43);
if (organicMatterSlot == null || fuelSlot == null) break;
Expand Down Expand Up @@ -508,7 +515,7 @@ public void onComposterState() {
if (currentFuel == -1) break;
int amountFuel = (maxFuel - currentFuel) / voltaFuel;
if (amountFuel > 0) {
itemsToBuy.add(Pair.of("Volta", amountFuel)); //TODO oil barrel or volta which is cheaper
itemsToBuy.add(Pair.of("Volta", amountFuel));
}
composterChecked = true;
PlayerUtils.closeScreen();
Expand All @@ -532,7 +539,7 @@ public void onComposterState() {
if (invName2.contains("Composter")) {
ContainerChest chest = (ContainerChest) mc.thePlayer.openContainer;
int boughtOrganicMatterSlot = InventoryUtils.getSlotIdOfItemInContainer("Box of Seeds");
int boughtFuelSlot = InventoryUtils.getSlotIdOfItemInContainer("Volta"); //TODO if change to buy cheaper of volta / oil barrel
int boughtFuelSlot = InventoryUtils.getSlotIdOfItemInContainer("Volta");
if (boughtOrganicMatterSlot != -1) {
InventoryUtils.clickSlotWithId(boughtOrganicMatterSlot, InventoryUtils.ClickType.LEFT, InventoryUtils.ClickMode.PICKUP, chest.windowId);
delayClock.schedule(FarmHelperConfig.getRandomGUIMacroDelay());
Expand All @@ -541,6 +548,10 @@ public void onComposterState() {
InventoryUtils.clickSlotWithId(boughtFuelSlot, InventoryUtils.ClickType.LEFT, InventoryUtils.ClickMode.PICKUP, chest.windowId);
delayClock.schedule(FarmHelperConfig.getRandomGUIMacroDelay());
}
LogUtils.sendWarning("Supplied composter with resources.");
if (FarmHelperConfig.logAutoComposterEvents){
LogUtils.webhookLog("Supplied composter with resources.");
}
setComposterState(ComposterState.END);
} else {
PlayerUtils.closeScreen();
Expand Down Expand Up @@ -616,7 +627,6 @@ private Entity getComposter() {
.min(Comparator.comparingDouble(entity -> entity.getDistanceSqToCenter(mc.thePlayer.getPosition()))).orElse(null);
}


@SubscribeEvent
public void onRenderWorldLast(RenderWorldLastEvent event) {
if (!isRunning()) return;
Expand Down

0 comments on commit 836568f

Please sign in to comment.