Skip to content

Commit

Permalink
Fly pathfinder:
Browse files Browse the repository at this point in the history
 = Fixed false tp check while aotv'ing during fly
  • Loading branch information
May2Beez committed Apr 27, 2024
1 parent 5f188d9 commit cf24d44
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 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.5
version=2.6.6
shouldRelease=true
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void onReceivedPacketDetection(ReceivePacketEvent event) {
LogUtils.sendDebug("[Failsafe] Player is below Y = 0. Ignoring");
return;
}
if (FlyPathFinderExecutor.getInstance().isRunning() && FlyPathFinderExecutor.getInstance().isPositionInCache(packetPlayerBlockPos)) {
if (FlyPathFinderExecutor.getInstance().isRunning() && (FlyPathFinderExecutor.getInstance().isTping() || FlyPathFinderExecutor.getInstance().isPositionInCache(packetPlayerBlockPos))) {
LogUtils.sendDebug("[Failsafe] Teleport packet received while Fly pathfinder is running. Ignoring");
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -875,8 +875,11 @@ public void onTickExecute(TickEvent.ClientTickEvent event) {
null
));
}
KeyBindUtils.setKeyBindState(mc.gameSettings.keyBindUseItem, distance2 < currentVacuumRange);
FlyPathFinderExecutor.getInstance().setUseAOTV(distanceXZ > vacuumMinRange && InventoryUtils.hasItemInHotbar("Aspect of the Void", "Aspect of the End"));
if (distance2 < currentVacuumRange && getVacuum(mc.thePlayer.getHeldItem())) {
break;
}
KeyBindUtils.setKeyBindState(mc.gameSettings.keyBindUseItem, distance2 < currentVacuumRange);
}
break;
case CHECK_ANOTHER_PEST:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import cc.polyfrost.oneconfig.utils.Multithreading;
import com.google.common.collect.EvictingQueue;
import com.jelly.farmhelperv2.config.FarmHelperConfig;
import com.jelly.farmhelperv2.event.ReceivePacketEvent;
import com.jelly.farmhelperv2.handler.RotationHandler;
import com.jelly.farmhelperv2.mixin.client.EntityPlayerAccessor;
import com.jelly.farmhelperv2.mixin.pathfinder.PathfinderAccessor;
Expand All @@ -19,6 +20,7 @@
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityArmorStand;
import net.minecraft.network.play.server.S08PacketPlayerPosLook;
import net.minecraft.pathfinding.PathEntity;
import net.minecraft.pathfinding.PathFinder;
import net.minecraft.pathfinding.PathPoint;
Expand All @@ -29,6 +31,7 @@
import net.minecraft.util.Vec3;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import net.minecraftforge.event.world.WorldEvent;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.TickEvent;

Expand Down Expand Up @@ -259,6 +262,8 @@ public void stop() {
RotationHandler.getInstance().reset();
path.clear();
target = null;
tped = true;
aotvDely.reset();
targetEntity = null;
yModifier = 0;
state = State.NONE;
Expand Down Expand Up @@ -308,6 +313,7 @@ public void onTick(TickEvent.ClientTickEvent event) {

private final Clock loweringRaisingDelay = new Clock();
private final Clock aotvDely = new Clock();
private boolean tped = true;

@SubscribeEvent
public void onTickNeededYaw(TickEvent.ClientTickEvent event) {
Expand Down Expand Up @@ -403,13 +409,14 @@ public void onTickNeededYaw(TickEvent.ClientTickEvent event) {
}
Vec3 next = getNext(copyPath);

if (FarmHelperConfig.useAoteVInPestsDestroyer && useAOTV && aotvDely.passed() && mc.thePlayer.getDistance(next.xCoord, mc.thePlayer.getPositionVector().yCoord, next.zCoord) > 7.5 && !RotationHandler.getInstance().isRotating()) {
if (FarmHelperConfig.useAoteVInPestsDestroyer && tped && useAOTV && aotvDely.passed() && mc.thePlayer.getDistance(next.xCoord, mc.thePlayer.getPositionVector().yCoord, next.zCoord) > 7.5 && !RotationHandler.getInstance().isRotating()) {
int aotv = InventoryUtils.getSlotIdOfItemInHotbar("Aspect of the Void", "Aspect of the End");
if (aotv != mc.thePlayer.inventory.currentItem) {
mc.thePlayer.inventory.currentItem = aotv;
aotvDely.schedule(180);
} else {
KeyBindUtils.rightClick();
tped = false;
aotvDely.schedule(150 + Math.random() * 100);
}
}
Expand Down Expand Up @@ -491,6 +498,21 @@ else if (this.neededYaw != Integer.MIN_VALUE) {
KeyBindUtils.stopMovement(true);
}

@SubscribeEvent(priority = EventPriority.LOW)
public void onTeleportPacket(ReceivePacketEvent event) {
if (!isRunning()) return;
if (event.packet instanceof S08PacketPlayerPosLook) {
S08PacketPlayerPosLook packet = (S08PacketPlayerPosLook) event.packet;
if (packet.func_179834_f().contains(S08PacketPlayerPosLook.EnumFlags.X) || packet.func_179834_f().contains(S08PacketPlayerPosLook.EnumFlags.Y) || packet.func_179834_f().contains(S08PacketPlayerPosLook.EnumFlags.Z)) {
tped = true;
}
}
}

public boolean isTping() {
return !tped;
}

private boolean willArriveAtDestinationAfterStopping(Vec3 targetPos) {
return predictStoppingPosition().distanceTo(targetPos) < 0.75;
}
Expand Down

0 comments on commit cf24d44

Please sign in to comment.