Skip to content

Commit

Permalink
Visitors Macro:
Browse files Browse the repository at this point in the history
 = Another fixes
 = Fixed camera rotating at the visitors
 + Added detection of server too laggy for bz
 + Added detection of compacted items

Pests Destroyer:
 = Adjusted a lot of things, such as movement, camera rotating, pests detection, stuck detection etc

Reward Claimer:
 + Works in main jacob's menu, not only in rewards one

Jacob Contests:
 + Count only current crop for disabling certain features, such as 'Pause the visitors macro during Jacob's contests' and others
  • Loading branch information
May2Beez committed Mar 2, 2024
2 parents 87c812b + 48dfa68 commit 01724d7
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import net.minecraft.client.gui.inventory.GuiInventory;
import net.minecraft.inventory.ContainerChest;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.network.play.server.S18PacketEntityTeleport;
import net.minecraft.util.StringUtils;
import net.minecraftforge.client.event.ClientChatReceivedEvent;
Expand Down Expand Up @@ -212,7 +213,7 @@ public void onTickShouldEnable(TickEvent.ClientTickEvent event) {
if (!MacroHandler.getInstance().isMacroToggled()) return;
if (GameStateHandler.getInstance().getServerClosingSeconds().isPresent()) return;
if (!GameStateHandler.getInstance().inGarden()) return;
if (sprayState != AUTO_SPRAYONATOR_STATE.NONE && sprayState != AUTO_SPRAYONATOR_STATE.WAITING_FOR_PLOT) return;
if (sprayState != AUTO_SPRAYONATOR_STATE.NONE) return;
sprayItem = SPRAYONATOR_ITEM.values()[FarmHelperConfig.sprayonatorType];

System.out.println("Has sprayonator: " + hasSprayonator());
Expand All @@ -222,9 +223,7 @@ public void onTickShouldEnable(TickEvent.ClientTickEvent event) {
}
if (!enableDelay.passed()) return;
PlotData data = sprayonatorPlotStates.get(GameStateHandler.getInstance().getCurrentPlot());
if (data == null)
return;
if (sprayonatorPlotStates.isEmpty() || !data.isSprayed()) {
if (sprayonatorPlotStates.isEmpty() || (data != null && !data.isSprayed())) {
LogUtils.sendWarning("[Auto Sprayonator] Activating!");
LogUtils.sendDebug("[Auto Sprayonator] Plot Data: " + data);
KeyBindUtils.stopMovement();
Expand Down Expand Up @@ -286,16 +285,14 @@ public void onClientTick(TickEvent.ClientTickEvent event) {
sprayState = AUTO_SPRAYONATOR_STATE.NONE;
}
PlotData data = sprayonatorPlotStates.get(GameStateHandler.getInstance().getCurrentPlot());
if (data == null)
return;
if (!data.isSprayed() || !data.sprayItem.equals(sprayItem.getItemName())) {
if (data != null && (!data.isSprayed() || !data.sprayItem.equals(sprayItem.getItemName()))) {
LogUtils.sendSuccess("[Auto Sprayonator] Spraying plot " + GameStateHandler.getInstance().getCurrentPlot());
sprayState = AUTO_SPRAYONATOR_STATE.CHECK_SPRAYONATOR;
running = true;
return;
} else {
if (running && MacroHandler.getInstance().isCurrentMacroPaused()) {
MacroHandler.getInstance().resumeMacro();
stop();
}
}
if (running && MacroHandler.getInstance().isCurrentMacroPaused()) {
stop();
}
break;
case CHECK_SPRAYONATOR:
Expand Down Expand Up @@ -345,7 +342,9 @@ public void onClientTick(TickEvent.ClientTickEvent event) {
if (mc.thePlayer.inventory.currentItem != getChosenSprayonatorSlot()) {
mc.thePlayer.inventory.currentItem = getChosenSprayonatorSlot();
}
List<String> itemLore = InventoryUtils.getItemLore(mc.thePlayer.inventory.getStackInSlot(getChosenSprayonatorSlot()));
ItemStack stack = mc.thePlayer.inventory.getStackInSlot(getChosenSprayonatorSlot());
if (stack == null) return;
List<String> itemLore = InventoryUtils.getItemLore(stack);
if (itemLore.isEmpty()) return;
if (itemLore.size() < 19) return;

Expand Down Expand Up @@ -587,19 +586,17 @@ public void onGuiOpen(DrawScreenAfterEvent event) {
@SubscribeEvent
public void onChatReceived(ClientChatReceivedEvent e) {
if (mc.thePlayer == null || mc.theWorld == null) return;
if (!running) return;
if (!isToggled()) return;
if (e.type != 0) return;

String message = StringUtils.stripControlCodes(e.message.getUnformattedText());
String message2 = StringUtils.stripControlCodes(e.message.getFormattedText());
if (message.contains("sprayed with that item recently") || message2.contains("sprayed with that item recently")) {
if (message.contains("sprayed with that item recently")) {
sprayState = AUTO_SPRAYONATOR_STATE.CHECK_PLOTS;
}
if (message.contains(":") || message2.contains(":")) return;
if (message.contains("You sprayed Plot") || message2.contains("You sprayed Plot")) {
if (!StringUtils.stripControlCodes(e.message.getUnformattedText()).startsWith("SPRAYONATOR!")) return;
if (message.contains("sprayed")) {
String plotNumber = e.message.getUnformattedText().split(" ")[5];
PlotData data = new PlotData(Integer.parseInt(plotNumber), sprayItem.getItemName(), TimeUnit.MINUTES.toMillis(30));
sprayonatorPlotStates.put(Integer.parseInt(plotNumber), data);
sprayState = AUTO_SPRAYONATOR_STATE.WAITING_FOR_PLOT;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -464,21 +464,22 @@ private void getPrices(JsonObject json1, List<BazaarItem> cropsToCount) {
getPricesPerList(json1, cropsToCount);
}

private void getPricesPerList(JsonObject json1, List<BazaarItem> list) {
for (BazaarItem item : list) {
JsonObject json2 = json1.getAsJsonObject(item.bazaarId);
JsonArray json3 = json2.getAsJsonArray("sell_summary");
JsonObject json4 = json3.size() > 1 ? json3.get(1).getAsJsonObject() : json3.get(0).getAsJsonObject();

double buyPrice = json4.get("pricePerUnit").getAsDouble();
APICrop apiCrop;
if (bazaarPrices.containsKey(item.localizedName)) {
apiCrop = bazaarPrices.get(item.localizedName);
apiCrop.currentPrice = buyPrice;
} else {
apiCrop = new APICrop(item.localizedName, buyPrice);
private void getPricesPerList(JsonObject bazaarData, List<BazaarItem> itemList) {
for (BazaarItem item : itemList) {
JsonObject itemData = bazaarData.getAsJsonObject(item.bazaarId);
JsonArray sellSummary = itemData.getAsJsonArray("sell_summary");

JsonObject summaryData = (sellSummary.size() > 1) ? sellSummary.get(1).getAsJsonObject() :
(sellSummary.size() > 0) ? sellSummary.get(0).getAsJsonObject() : null;

if (summaryData != null) {
double buyPrice = summaryData.get("pricePerUnit").getAsDouble();
bazaarPrices.computeIfPresent(item.localizedName, (name, apiCrop) -> {
apiCrop.currentPrice = buyPrice;
return apiCrop;
});
bazaarPrices.putIfAbsent(item.localizedName, new APICrop(item.localizedName, buyPrice));
}
bazaarPrices.put(item.localizedName, apiCrop);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/jelly/farmhelperv2/hud/DebugHUD.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ protected void getLines(List<String> lines, boolean example) {
lines.add(" Forward: " + FlyPathfinder.getInstance().isDeceleratingForward);
lines.add(" Backward: " + FlyPathfinder.getInstance().isDeceleratingBackward);
}
if (AutoSprayonator.getInstance().isRunning()) {
if (AutoSprayonator.getInstance().isToggled()) {
lines.add("Auto Sprayonator");
lines.add(" Running: " + AutoSprayonator.getInstance().isRunning());
lines.add(" Enable Delay: " + AutoSprayonator.getInstance().getEnableDelay().getRemainingTime());
Expand Down

0 comments on commit 01724d7

Please sign in to comment.