aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
author alemi <me@alemi.dev>2024-01-17 00:18:13 +0100
committer alemi <me@alemi.dev>2024-01-17 00:18:13 +0100
commit2893438f64fa9e5a4c38d896c93244daa51aacd6 (patch)
tree95609dcf72b0045e671e322606926f2d194c00bc /src/main
parent63cfbaa56ccf67da7b65cf058a68a4b843af5748 (diff)
feat: add distance option to autofish
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/ftbsc/bscv/modules/self/AutoFish.java15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/main/java/ftbsc/bscv/modules/self/AutoFish.java b/src/main/java/ftbsc/bscv/modules/self/AutoFish.java
index 9394233..bed4e9e 100644
--- a/src/main/java/ftbsc/bscv/modules/self/AutoFish.java
+++ b/src/main/java/ftbsc/bscv/modules/self/AutoFish.java
@@ -9,6 +9,7 @@ import net.minecraft.client.Minecraft;
import net.minecraft.network.play.server.SPlaySoundEffectPacket;
import net.minecraft.util.Hand;
import net.minecraft.util.SoundEvents;
+import net.minecraft.util.math.vector.Vector3d;
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.eventbus.api.SubscribeEvent;
@@ -17,6 +18,7 @@ public class AutoFish extends AbstractModule {
public final ForgeConfigSpec.ConfigValue<Boolean> recast;
public final ForgeConfigSpec.ConfigValue<Integer> delay;
+ public final ForgeConfigSpec.ConfigValue<Double> distance;
// public final ForgeConfigSpec.ConfigValue<Long> reaction;
public AutoFish() {
@@ -33,13 +35,23 @@ public class AutoFish extends AbstractModule {
.name("delay")
.comment("how long in ms to wait before recasting hook")
.build(this);
+
+ this.distance = Setting.Decimal.builder()
+ .fallback(0.)
+ .name("distance")
+ .comment("ignore splashes further than X blocks, set to 0 to disable")
+ .build(this);
}
@SubscribeEvent
public void onPacket(PacketEvent.Incoming event) {
if (event.packet instanceof SPlaySoundEffectPacket) {
SPlaySoundEffectPacket packet = (SPlaySoundEffectPacket) event.packet;
- if (packet.getSound().equals(SoundEvents.FISHING_BOBBER_SPLASH)) {
+ Vector3d location = new Vector3d(packet.getX(), packet.getY(), packet.getZ());
+ if (
+ packet.getSound().equals(SoundEvents.FISHING_BOBBER_SPLASH)
+ && (this.distance.get() == 0 || MC.player.position().distanceTo(location) < this.distance.get())
+ ) {
MC.gameMode.useItem(MC.player, MC.level, Hand.MAIN_HAND);
if (this.recast.get()) {
new RecastThread(MC, this.delay.get()).start();
@@ -48,6 +60,7 @@ public class AutoFish extends AbstractModule {
}
}
+ // TODO don't spawn a thread, minecraft has a way to schedule actions for later
private class RecastThread extends Thread {
private long delay;
private Minecraft mc;