Skip to content

Commit

Permalink
= Pests Destroyer - some fixes
Browse files Browse the repository at this point in the history
= Manual reset profits now resets time
  • Loading branch information
May2Beez committed Feb 11, 2024
1 parent 705caa1 commit 275dc45
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 6 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-pre1
version=2.4.5-pre2
shouldRelease=true
31 changes: 28 additions & 3 deletions src/main/java/com/jelly/farmhelperv2/FarmHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@
import com.jelly.farmhelperv2.pathfinder.WorldCache;
import com.jelly.farmhelperv2.remote.DiscordBotHandler;
import com.jelly.farmhelperv2.remote.WebsocketHandler;
import com.jelly.farmhelperv2.util.FailsafeUtils;
import com.jelly.farmhelperv2.util.LogUtils;
import com.jelly.farmhelperv2.util.ReflectionUtils;
import com.jelly.farmhelperv2.util.*;
import com.jelly.farmhelperv2.util.helper.AudioManager;
import com.jelly.farmhelperv2.util.helper.BaritoneEventListener;
import com.jelly.farmhelperv2.util.helper.FlyPathfinder;
import com.jelly.farmhelperv2.util.helper.TickTask;
import net.minecraft.client.Minecraft;
import net.minecraft.util.BlockPos;
import net.minecraft.util.Vec3;
import net.minecraftforge.client.ClientCommandHandler;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.Mod;
Expand All @@ -36,6 +37,7 @@
import net.minecraftforge.fml.common.gameevent.TickEvent;
import org.lwjgl.opengl.Display;

import java.awt.*;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -120,4 +122,27 @@ private void initializeCommands() {
ClientCommandHandler.instance.registerCommand(new RewarpCommand());
CommandManager.register(new FarmHelperMainCommand());
}

@SubscribeEvent
public void onLastRender(RenderWorldLastEvent event) {
if (mc.thePlayer == null || mc.theWorld == null) return;
if (!FarmHelperConfig.showDebugPathfindingRoute) return;

Vec3 position = mc.thePlayer.getPositionVector();

for (int x = (int) (position.xCoord - 5); x < position.xCoord + 5; x++) {
for (int y = (int) (position.yCoord - 5); y < position.yCoord + 5; y++) {
for (int z = (int) (position.zCoord - 5); z < position.zCoord + 5; z++) {
WorldCache.CacheEntry pathNodeType = WorldCache.getInstance().getWorldCache().get(new BlockPos(x, y, z));
if (pathNodeType == null)
continue;
if (pathNodeType.getPathNodeType().equals(BlockUtils.PathNodeType.OPEN)) {
RenderUtils.drawBlockBox(new BlockPos(x, y, z), new Color(0, 200, 0, 35));
} else if (pathNodeType.getPathNodeType().equals(BlockUtils.PathNodeType.BLOCKED)) {
RenderUtils.drawBlockBox(new BlockPos(x, y, z), new Color(200, 0, 0, 35));
}
}
}
}
}
}
17 changes: 17 additions & 0 deletions src/main/java/com/jelly/farmhelperv2/config/FarmHelperConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -1219,6 +1219,16 @@ public static void triggerManuallyPestsDestroyer() {
//</editor-fold>

//<editor-fold desc="AUTO PEST HUNTER">

@Info(
text = "Once you collect enough pests, the macro will go to the Phillip NPC and exchange pests in your vacuum for Farming Fortune for 30 minutes.",
type = InfoType.INFO,
category = AUTO_PEST_HUNTER,
subcategory = "Auto Pest Hunter",
size = 2
)
public static boolean autoPestHunterInfo1;

@Switch(
name = "Enable Auto Pest Hunter", category = AUTO_PEST_HUNTER, subcategory = "Auto Pest Hunter",
description = "Automatically hunts pests"
Expand Down Expand Up @@ -1688,6 +1698,13 @@ public enum SPRAYONATOR_ITEM {
description = "Shows rotation debug messages"
)
public static boolean showRotationDebugMessages = false;

@Switch(
name = "Show debug pathfinding route", category = DEBUG, subcategory = "Debug",
description = "Shows debug pathfinding route"
)
public static boolean showDebugPathfindingRoute = false;

//</editor-fold>

//<editor-fold desc="Debug Hud">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import cc.polyfrost.oneconfig.renderer.TextRenderer;
import com.jelly.farmhelperv2.feature.impl.ProfitCalculator;
import com.jelly.farmhelperv2.handler.GameStateHandler;
import com.jelly.farmhelperv2.handler.MacroHandler;
import com.jelly.farmhelperv2.util.LogUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.util.Tuple;
Expand All @@ -37,7 +38,11 @@ public class ProfitCalculatorHUD extends BasicHud {
text = "Reset Now",
size = 2
)
Runnable _resetProfitCalculator = ProfitCalculator.getInstance()::resetProfits;
Runnable _resetProfitCalculator = () -> {
MacroHandler.getInstance().getMacroingTimer().reset();
ProfitCalculator.getInstance().resetProfits();
};

private final float iconWidth = 12 * scale;
private final float iconHeight = 12 * scale;
protected transient ArrayList<Tuple<String, String>> lines = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.jelly.farmhelperv2.config.FarmHelperConfig;
import com.jelly.farmhelperv2.event.MotionUpdateEvent;
import com.jelly.farmhelperv2.event.ReceivePacketEvent;
import com.jelly.farmhelperv2.handler.GameStateHandler;
import com.jelly.farmhelperv2.util.BlockUtils;
import lombok.Getter;
import net.minecraft.block.Block;
Expand Down Expand Up @@ -67,6 +68,9 @@ public void onWorldUnload(WorldEvent.Unload event) {
public void onPacketReceive(ReceivePacketEvent event) {
if (mc.theWorld == null) return;
if (!FarmHelperConfig.useCachingInFlyPathfinder) return;
if (!GameStateHandler.getInstance().getLocation().equals(GameStateHandler.Location.TELEPORTING) && !GameStateHandler.getInstance().inGarden())
return;


if (event.packet instanceof S21PacketChunkData) {
S21PacketChunkData packet = (S21PacketChunkData) event.packet;
Expand All @@ -89,7 +93,7 @@ public void onPacketReceive(ReceivePacketEvent event) {
private void cacheChunk(Chunk c, Coordinate coordinate) {
if (chunkCache.containsKey(coordinate)) return;
for (int x = 0; x < 16; x++)
for (int y = 65; y < 100; y++)
for (int y = 66; y < 100; y++)
for (int z = 0; z < 16; z++) {
BlockPos pos = new BlockPos(x + coordinate.x * 16, y, z + coordinate.z * 16);
BlockPos chunkPos = new BlockPos(x, y, z);
Expand Down

0 comments on commit 275dc45

Please sign in to comment.