Skip to content

Commit

Permalink
# Critical Failsafe Update
Browse files Browse the repository at this point in the history
Pests Destroyer:
 = Fixes and improvements for new update

Auto Pest Hunter:
 = Fixed

Count only main crop in jacob contests:
 = Fixed

AntiStuck:
 = Tweaks

Important bug fixes after the latest Hypixel update

Optimizations and Improvements for some parts of the utils
  • Loading branch information
May2Beez committed Mar 14, 2024
2 parents b942806 + f15f39b commit ad94108
Show file tree
Hide file tree
Showing 5 changed files with 130 additions and 41 deletions.
21 changes: 21 additions & 0 deletions src/main/java/com/jelly/farmhelperv2/config/FarmHelperConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,12 @@ public class FarmHelperConfig extends Config {
min = 0, max = 2
)
public static float teleportCheckLagSensitivity = 0.5f;
@Slider(
name = "Teleport Check Time Window (in milliseconds)", category = FAILSAFE, subcategory = "Miscellaneous",
description = "The time window to check for teleports (in seconds)",
min = 50, max = 4000, step = 50
)
public static int teleportCheckTimeWindow = 500;
@Slider(
name = "Rotation Check Pitch Sensitivity", category = FAILSAFE, subcategory = "Miscellaneous",
description = "The sensitivity of the rotation check; the lower the sensitivity, the more accurate the check is, but it will also increase the chance of getting false positives.",
Expand Down Expand Up @@ -1771,6 +1777,19 @@ public enum SPRAYONATOR_ITEM {
)
public static boolean fastBreak = false;

@Switch(
name = "Enable Fast Break Randomization", category = EXPERIMENTAL, subcategory = "Fast Break",
description = "Randomizes the Fast Break chance"
)
public static boolean fastBreakRandomization = false;

@Slider(
name = "Fast Break Randomization Chance", category = EXPERIMENTAL, subcategory = "Fast Break",
description = "The chance to break the block",
min = 1, max = 100, step = 1
)
public static int fastBreakRandomizationChance = 5;

@Info(
text = "Fast Break will most likely ban you. Use at your own risk.",
type = InfoType.ERROR,
Expand Down Expand Up @@ -1956,6 +1975,8 @@ public FarmHelperConfig() {
this.addDependency("streamerModeInfo2", "debugMode");

this.addDependency("fastBreakSpeed", "fastBreak");
this.addDependency("fastBreakRandomization", "fastBreak");
this.addDependency("fastBreakRandomizationChance", "fastBreak");
this.addDependency("disableFastBreakDuringBanWave", "fastBreak");
this.addDependency("disableFastBreakDuringJacobsContest", "fastBreak");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,14 @@ public void duringFailsafeTrigger() {

switch (rotationCheckState) {
case NONE:
if (checkIfRotatedBack())
return;
rotationCheckState = RotationCheckState.WAIT_BEFORE_START;
FailsafeManager.getInstance().scheduleRandomDelay(500, 500);
break;
case WAIT_BEFORE_START:
if (checkIfRotatedBack())
return;
MacroHandler.getInstance().pauseMacro();
if (rotationBeforeReacting == null)
rotationBeforeReacting = new Rotation(mc.thePlayer.rotationYaw, mc.thePlayer.rotationPitch);
Expand Down Expand Up @@ -228,6 +232,18 @@ public void resetStates() {
rotation.reset();
}

private boolean checkIfRotatedBack() {
if ((Math.abs(AngleUtils.get360RotationYaw(rotationBeforeReacting.getYaw()) - AngleUtils.get360RotationYaw()) < 0.1)
&& (Math.abs(AngleUtils.get360RotationYaw(rotationBeforeReacting.getPitch()) - mc.thePlayer.rotationPitch) < 0.1)) {
FailsafeManager.getInstance().stopFailsafes();
LogUtils.sendWarning("[Failsafe] Rotation check failsafe was triggered but the admin rotated you back. DO NOT REACT TO THIS OR YOU WILL GET BANNED!");
if (FailsafeNotificationsPage.notifyOnRotationFailsafe)
LogUtils.webhookLog("[Failsafe]\nRotation check failsafe was triggered but the admin rotated you back. DO NOT REACT TO THIS OR YOU WILL GET BANNED!");
return true;
}
return false;
}

private RotationCheckState rotationCheckState = RotationCheckState.NONE;
private final RotationHandler rotation = RotationHandler.getInstance();
private BlockPos positionBeforeReacting = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.jelly.farmhelperv2.macro.AbstractMacro;
import com.jelly.farmhelperv2.pathfinder.FlyPathFinderExecutor;
import com.jelly.farmhelperv2.util.*;
import com.jelly.farmhelperv2.util.helper.Clock;
import com.jelly.farmhelperv2.util.helper.Rotation;
import com.jelly.farmhelperv2.util.helper.RotationConfiguration;
import net.minecraft.network.play.server.S08PacketPlayerPosLook;
Expand All @@ -27,6 +28,8 @@

import java.awt.*;
import java.util.Optional;
import java.util.LinkedList;
import java.util.Queue;

public class TeleportFailsafe extends Failsafe {
private static TeleportFailsafe instance;
Expand All @@ -38,7 +41,21 @@ public static TeleportFailsafe getInstance() {
return instance;
}

class TeleportData {
public Vec3 position;
public long timestamp;

public TeleportData(Vec3 position, long timestamp) {
this.position = position;
this.timestamp = timestamp;
}
}

private final EvictingQueue<Tuple<BlockPos, AbstractMacro.State>> lastWalkedPositions = EvictingQueue.create(400);
private Queue<TeleportData> teleportationEvents = new LinkedList<>();
private Vec3 originalPosition = null;
private static final Clock triggerTeleport = new Clock();


@Override
public int getPriority() {
Expand Down Expand Up @@ -77,6 +94,11 @@ public void onTickDetection(TickEvent.ClientTickEvent event) {
lastWalkedPositions.clear();
return;
}

if (triggerTeleport.passed() && triggerTeleport.isScheduled()) {
evaluateDisplacement();
triggerTeleport.reset();
}
BlockPos playerPos = mc.thePlayer.getPosition();
if (lastWalkedPositions.isEmpty()) {
lastWalkedPositions.add(new Tuple<>(playerPos, MacroHandler.getInstance().getCurrentMacro().map(AbstractMacro::getCurrentState).orElse(null)));
Expand Down Expand Up @@ -143,7 +165,8 @@ public void onReceivedPacketDetection(ReceivePacketEvent event) {

rotationBeforeReacting = new Rotation(mc.thePlayer.rotationYaw, mc.thePlayer.rotationPitch);
double distance = currentPlayerPos.distanceTo(packetPlayerPos);
LogUtils.sendDebug("[Failsafe] Teleport 2 detected! Distance: " + distance);

LogUtils.sendDebug("[Failsafe] Teleport packet received! Distance: " + distance);
if (distance >= FarmHelperConfig.teleportCheckSensitivity || (MacroHandler.getInstance().getCurrentMacro().isPresent() && Math.abs(packet.getY()) - Math.abs(MacroHandler.getInstance().getCurrentMacro().get().getLayerY()) > 0.8)) {
LogUtils.sendDebug("[Failsafe] Teleport detected! Distance: " + distance);
final double lastReceivedPacketDistance = currentPlayerPos.distanceTo(LagDetector.getInstance().getLastPacketPosition());
Expand All @@ -153,7 +176,11 @@ public void onReceivedPacketDetection(ReceivePacketEvent event) {
final double estimatedMovement = playerMovementSpeed * ticksSinceLastPacket;
if (lastReceivedPacketDistance > 7.5D && Math.abs(lastReceivedPacketDistance - estimatedMovement) < FarmHelperConfig.teleportCheckLagSensitivity)
return;
FailsafeManager.getInstance().possibleDetection(this);
if (originalPosition == null) {
originalPosition = mc.thePlayer.getPositionVector();
}
teleportationEvents.add(new TeleportData(packetPlayerPos, System.currentTimeMillis()));
triggerTeleport.schedule(FarmHelperConfig.teleportCheckTimeWindow);
}
}

Expand Down Expand Up @@ -327,6 +354,24 @@ public void resetStates() {
randomContinueMessage = null;
rotation.reset();
lastWalkedPositions.clear();
teleportationEvents.clear();
originalPosition = null;
}

private void evaluateDisplacement() {
Vec3 currentPosition = mc.thePlayer.getPositionVector();
double totalDisplacement = currentPosition.distanceTo(originalPosition);
if (totalDisplacement > FarmHelperConfig.teleportCheckSensitivity) {
FailsafeManager.getInstance().possibleDetection(this);
} else {
FailsafeManager.getInstance().stopFailsafes();
LogUtils.sendWarning("[Failsafe] Teleport check failsafe was triggered but the admin teleported you back. §c§lDO NOT REACT§e TO THIS OR YOU WILL GET BANNED!");
if (FailsafeNotificationsPage.notifyOnRotationFailsafe)
LogUtils.webhookLog("[Failsafe]\nTeleport check failsafe was triggered but the admin teleported you back. DO NOT REACT TO THIS OR YOU WILL GET BANNED!");
return;
}
teleportationEvents.clear();
originalPosition = null;
}

private TeleportCheckState teleportCheckState = TeleportCheckState.NONE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ public void updateState() {
case RIGHT: {
if ((GameStateHandler.getInstance().isLeftWalkable()) && getCurrentState() == State.LEFT) {
// Probably stuck in dirt, continue going left
setCurrentState(State.LEFT);
AntiStuck.getInstance().setDirectionBlockPos(BlockUtils.getRelativeBlockPos(0, 0, -1, getYaw()));
AntiStuck.getInstance().start();
return;
}
if ((GameStateHandler.getInstance().isRightWalkable()) && getCurrentState() == State.RIGHT) {
// Probably stuck in dirt, continue going right
setCurrentState(State.RIGHT);
AntiStuck.getInstance().setDirectionBlockPos(BlockUtils.getRelativeBlockPos(0, 0, -1, getYaw()));
AntiStuck.getInstance().start();
return;
Expand All @@ -41,27 +43,15 @@ public void updateState() {
AntiStuck.getInstance().start();
return;
}
// if (changeLaneDirection == ChangeLaneDirection.BACKWARD) {
// // Probably stuck in dirt
// changeState(State.NONE);
// return;
// }
changeState(State.SWITCHING_LANE);
// changeLaneDirection = ChangeLaneDirection.FORWARD;
setWalkingDirection();
} else if (GameStateHandler.getInstance().isBackWalkable() && !FarmHelperConfig.alwaysHoldW) {
// if (changeLaneDirection == ChangeLaneDirection.FORWARD) {
// // Probably stuck in dirt
// changeState(State.NONE);
// return;
// }
if (stuckInMelonsOrPumpkins()) {
AntiStuck.getInstance().setDirectionBlockPos(BlockUtils.getRelativeBlockPos(0, 0, -1, getYaw()));
AntiStuck.getInstance().start();
return;
}
changeState(State.SWITCHING_LANE);
// changeLaneDirection = ChangeLaneDirection.BACKWARD;
setWalkingDirection();
} else {
if (GameStateHandler.getInstance().isLeftWalkable()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
import com.jelly.farmhelperv2.handler.GameStateHandler;
import com.jelly.farmhelperv2.handler.MacroHandler;
import net.minecraft.block.Block;
import net.minecraft.block.BlockCrops;
import net.minecraft.block.BlockNetherWart;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.gui.GuiScreen;
Expand Down Expand Up @@ -63,34 +62,52 @@ private void sendClickBlockToController(CallbackInfo ci) {
}

boolean shouldClick = this.currentScreen == null && this.gameSettings.keyBindAttack.isKeyDown() && this.inGameHasFocus;
if (this.objectMouseOver != null && shouldClick)
for (int i = 0; i < FarmHelperConfig.fastBreakSpeed + 1; i++) {
BlockPos clickedBlock = this.objectMouseOver.getBlockPos();
this.objectMouseOver = this.renderViewEntity.rayTrace(this.playerController.getBlockReachDistance(), 1.0F);

if (this.objectMouseOver == null || this.objectMouseOver.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK) {
break;
}
if (this.objectMouseOver != null && shouldClick) {
boolean isCactus = false;

// checking first block
BlockPos newBlock = this.objectMouseOver.getBlockPos();
Block blockTryBreak = this.theWorld.getBlockState(newBlock).getBlock();

if (!newBlock.equals(clickedBlock)
&& (blockTryBreak instanceof BlockCrops ||
blockTryBreak instanceof BlockNetherWart ||
blockTryBreak == Blocks.reeds ||
blockTryBreak == Blocks.cactus ||
blockTryBreak == Blocks.brown_mushroom ||
blockTryBreak == Blocks.red_mushroom ||
blockTryBreak == Blocks.pumpkin ||
blockTryBreak == Blocks.melon_block ||
blockTryBreak == Blocks.cocoa)
) {
for (int i = 0; i < FarmHelperConfig.fastBreakSpeed + 1; i++) {
// try catch when player break block and the block is not exist(ghost block?) or some player in front of the block
try {
if (FarmHelperConfig.fastBreakRandomization && (Math.random() * 100 < (100 - FarmHelperConfig.fastBreakRandomizationChance))) {
break;
}

BlockPos clickedBlock = this.objectMouseOver.getBlockPos();
Block block = this.theWorld.getBlockState(clickedBlock).getBlock();
this.objectMouseOver = this.renderViewEntity.rayTrace(this.playerController.getBlockReachDistance(), 1.0F);

if (block == Blocks.cactus) {
isCactus = true;
} else {
isCactus = false;
}

if (this.objectMouseOver == null || this.objectMouseOver.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK) {
break;
}

BlockPos newBlock = this.objectMouseOver.getBlockPos();
Block blockTryBreak = this.theWorld.getBlockState(newBlock).getBlock();

if (this.theWorld.getBlockState(newBlock).getBlock().getPlayerRelativeBlockHardness(this.thePlayer, this.theWorld, clickedBlock) < 1.0F) {
return;
}

if (isCactus) {
this.playerController.resetBlockRemoving();
}

if (newBlock == null || this.objectMouseOver.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK || newBlock.equals(clickedBlock) || blockTryBreak.getMaterial() == Material.air) {
break;
}

this.thePlayer.swingItem();
this.playerController.clickBlock(newBlock, this.objectMouseOver.sideHit);
}
} catch (Exception ignored) {

if (i % 3 == 0) this.thePlayer.swingItem();
}
}

}
}
}

0 comments on commit ad94108

Please sign in to comment.