Skip to content

Commit

Permalink
CRITICAL UPDATE - Dirt failsafe and JDA update
Browse files Browse the repository at this point in the history
WARNING! Requires Farm Helper JDA Dependency v1.0.3! Yes, it has been updated once again.

Failsafes:
= Dirt Check - improved by checking whether the admin removed the blocks immediately after touching them

Toggle Sprint mods:
= Fixed an issue with Toggle Sprint mods not working properly

GUI:
= Fixed a warning in the GUI about outdated JDA
  • Loading branch information
onixiya1337 committed May 14, 2024
1 parent 8dd82bc commit 47e8aa3
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 15 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.22-pre4
version=2.6.22-pre5
shouldRelease=true
2 changes: 1 addition & 1 deletion src/main/java/com/jelly/farmhelperv2/FarmHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public static boolean checkIfJDAVersionCorrect() {
Optional<ModContainer> modContainer = Loader.instance().getActiveModList().stream()
.filter(mod -> "farmhelperjdadependency".equals(mod.getModId()))
.findFirst();
isJDAVersionCorrect = modContainer.map(container -> container.getVersion().equals("1.0.2")).orElse(false);
isJDAVersionCorrect = modContainer.map(container -> container.getVersion().equals("1.0.3")).orElse(false);
return isJDAVersionCorrect;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2085,7 +2085,7 @@ public FarmHelperConfig() {


this.hideIf("infoRemoteControl", () -> Loader.isModLoaded("farmhelperjdadependency"));
this.hideIf("info2RemoteControl", () -> FarmHelper.isJDAVersionCorrect);
this.hideIf("info2RemoteControl", () -> Loader.isModLoaded("farmhelperjdadependency") && FarmHelper.isJDAVersionCorrect);
this.hideIf("failsafeSoundTimes", () -> true);

this.addDependency("debugMode", "Streamer Mode", () -> !streamerMode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,12 @@ public void duringFailsafeTrigger() {
}
switch (dirtCheckState) {
case NONE:
if (blocksRemoved()) break;
dirtCheckState = DirtCheckState.WAIT_BEFORE_START;
FailsafeManager.getInstance().scheduleRandomDelay(500, 1000);
break;
case WAIT_BEFORE_START:
if (blocksRemoved()) break;
MacroHandler.getInstance().pauseMacro();
maxReactions = (int) Math.round(3 + Math.random() * 3);
LogUtils.sendDebug("[Failsafe] Minimum reactions: " + maxReactions);
Expand All @@ -116,6 +118,7 @@ else if (BlockUtils.getRelativeBlock(1, 1, 0).equals(Blocks.dirt))
FailsafeManager.getInstance().scheduleRandomDelay(500, 500);
break;
case PLAY_RECORDING:
if (blocksRemoved()) break;
if (dirtOnLeft)
MovRecPlayer.getInstance().playRandomRecording("DIRT_CHECK_Left_Start_");
else
Expand Down Expand Up @@ -157,18 +160,7 @@ else if (BlockUtils.getRelativeBlock(1, 1, 0).equals(Blocks.dirt))
break;
if (FailsafeManager.getInstance().swapItemDuringRecording && Math.random() > 0.6)
FailsafeManager.getInstance().swapItemDuringRecording = false;
dirtBlocks.removeIf(tuple -> {
if (System.currentTimeMillis() - tuple.getSecond() > 120_000 || !mc.theWorld.getBlockState(tuple.getFirst()).getBlock().isCollidable() || BlockUtils.canWalkThrough(tuple.getFirst()) || mc.theWorld.getBlockState(tuple.getFirst()).getBlock().equals(Blocks.air) || CropUtils.isCrop(mc.theWorld.getBlockState(tuple.getFirst()).getBlock()) || mc.theWorld.getBlockState(tuple.getFirst()).getBlock().equals(Blocks.water) || mc.theWorld.getBlockState(tuple.getFirst()).getBlock().equals(Blocks.flowing_water)) {
LogUtils.sendDebug("[Failsafe] Dirt block removed: " + tuple.getFirst());
return true;
}
return false;
});
if (dirtBlocks.isEmpty()) {
LogUtils.sendDebug("No dirt blocks left!");
dirtCheckState = DirtCheckState.GO_BACK_START;
break;
}
if (blocksRemoved()) break;
String tempRecordingName = "DIRT_CHECK_";
if (dirtOnLeft)
tempRecordingName += "Left_";
Expand Down Expand Up @@ -263,6 +255,29 @@ public boolean isTouchingDirtBlock() {
return false;
}

private boolean blocksRemoved() {
dirtBlocks.removeIf(tuple -> {
if (System.currentTimeMillis() - tuple.getSecond() > 120_000 || !mc.theWorld.getBlockState(tuple.getFirst()).getBlock().isCollidable() || BlockUtils.canWalkThrough(tuple.getFirst()) || mc.theWorld.getBlockState(tuple.getFirst()).getBlock().equals(Blocks.air) || CropUtils.isCrop(mc.theWorld.getBlockState(tuple.getFirst()).getBlock()) || mc.theWorld.getBlockState(tuple.getFirst()).getBlock().equals(Blocks.water) || mc.theWorld.getBlockState(tuple.getFirst()).getBlock().equals(Blocks.flowing_water)) {
LogUtils.sendDebug("[Failsafe] Dirt block removed: " + tuple.getFirst());
return true;
}
return false;
});
if (dirtBlocks.isEmpty()) {
if (dirtCheckState == DirtCheckState.NONE || dirtCheckState == DirtCheckState.WAIT_BEFORE_START) {
FailsafeManager.getInstance().stopFailsafes();
LogUtils.sendWarning("[Failsafe] Dirt check failsafe was triggered but the admin removed the blocks immediately. §c§lDO NOT REACT§e TO THIS OR YOU WILL GET BANNED!");
if (FailsafeNotificationsPage.notifyOnDirtFailsafe)
LogUtils.webhookLog("[Failsafe]\nDirt check failsafe was triggered but the admin removed the blocks immediately. DO NOT REACT TO THIS OR YOU WILL GET BANNED!");
return true;
}
LogUtils.sendDebug("No dirt blocks left!");
dirtCheckState = DirtCheckState.GO_BACK_START;
return true;
}
return false;
}

public boolean hasDirtBlocks() {
return !dirtBlocks.isEmpty();
}
Expand Down

0 comments on commit 47e8aa3

Please sign in to comment.