diff options
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/ftbsc/bscv/modules/self/AutoFish.java | 15 |
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; |