feat: added basic autofish
This commit is contained in:
parent
1a11a3e163
commit
04aec8c2a3
2 changed files with 78 additions and 0 deletions
|
@ -64,6 +64,7 @@ public class BoSCoVicino implements ICommons {
|
||||||
BoSCoVicino.mods.add(new EntityList(cfg, dp).done(cfg));
|
BoSCoVicino.mods.add(new EntityList(cfg, dp).done(cfg));
|
||||||
BoSCoVicino.mods.add(new Fullbright(cfg, dp).done(cfg));
|
BoSCoVicino.mods.add(new Fullbright(cfg, dp).done(cfg));
|
||||||
BoSCoVicino.mods.add(new AntiHunger(cfg, dp).done(cfg));
|
BoSCoVicino.mods.add(new AntiHunger(cfg, dp).done(cfg));
|
||||||
|
BoSCoVicino.mods.add(new AutoFish(cfg, dp).done(cfg));
|
||||||
BoSCoVicino.mods.add(new Freecam(cfg, dp).done(cfg));
|
BoSCoVicino.mods.add(new Freecam(cfg, dp).done(cfg));
|
||||||
|
|
||||||
BoSCoVicino.spec = cfg.build();
|
BoSCoVicino.spec = cfg.build();
|
||||||
|
|
77
src/main/java/ftbsc/bscv/modules/self/AutoFish.java
Normal file
77
src/main/java/ftbsc/bscv/modules/self/AutoFish.java
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
package ftbsc.bscv.modules.self;
|
||||||
|
|
||||||
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
|
import com.mojang.brigadier.arguments.BoolArgumentType;
|
||||||
|
import com.mojang.brigadier.arguments.LongArgumentType;
|
||||||
|
|
||||||
|
import ftbsc.bscv.ICommons;
|
||||||
|
import ftbsc.bscv.events.PacketEvent;
|
||||||
|
import ftbsc.bscv.modules.Module;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.command.CommandSource;
|
||||||
|
import net.minecraft.network.play.server.SPlaySoundEffectPacket;
|
||||||
|
import net.minecraft.util.Hand;
|
||||||
|
import net.minecraft.util.SoundEvents;
|
||||||
|
import net.minecraftforge.common.ForgeConfigSpec;
|
||||||
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
|
|
||||||
|
public class AutoFish extends Module implements ICommons {
|
||||||
|
|
||||||
|
public final ForgeConfigSpec.ConfigValue<Boolean> recast;
|
||||||
|
public final ForgeConfigSpec.ConfigValue<Long> delay;
|
||||||
|
// public final ForgeConfigSpec.ConfigValue<Long> reaction;
|
||||||
|
|
||||||
|
public AutoFish(ForgeConfigSpec.Builder builder, CommandDispatcher<CommandSource> dispatcher) {
|
||||||
|
super("AutoFish", Group.SELF, builder, dispatcher);
|
||||||
|
|
||||||
|
this.recast = this.option(
|
||||||
|
"recast", "automatically recast hook after fishing", false,
|
||||||
|
BoolArgumentType.bool(), Boolean.class,
|
||||||
|
builder, dispatcher
|
||||||
|
);
|
||||||
|
|
||||||
|
this.delay = this.option(
|
||||||
|
"delay", "how long in ms to wait before recasting hook", 2500L,
|
||||||
|
LongArgumentType.longArg(0), Long.class,
|
||||||
|
builder, dispatcher
|
||||||
|
);
|
||||||
|
|
||||||
|
// this.reaction = this.option(
|
||||||
|
// "reaction", "time in ms to react to fish biting", 0L,
|
||||||
|
// LongArgumentType.longArg(0), Long.class,
|
||||||
|
// builder, dispatcher
|
||||||
|
// );
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubscribeEvent
|
||||||
|
public void onPacket(PacketEvent event) {
|
||||||
|
if (event.outgoing) return;
|
||||||
|
|
||||||
|
if (event.packet instanceof SPlaySoundEffectPacket) {
|
||||||
|
SPlaySoundEffectPacket packet = (SPlaySoundEffectPacket) event.packet;
|
||||||
|
if (packet.getSound().equals(SoundEvents.FISHING_BOBBER_SPLASH)) {
|
||||||
|
MC.gameMode.useItem(MC.player, MC.level, Hand.MAIN_HAND);
|
||||||
|
if (this.recast.get()) {
|
||||||
|
new RecastThread(MC, this.delay.get()).start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class RecastThread extends Thread {
|
||||||
|
private long delay;
|
||||||
|
private Minecraft mc;
|
||||||
|
public RecastThread(Minecraft mc, long delay) {
|
||||||
|
this.mc = mc;
|
||||||
|
this.delay = delay;
|
||||||
|
this.setDaemon(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
Thread.sleep(this.delay);
|
||||||
|
} catch (InterruptedException e) {} // ignore
|
||||||
|
this.mc.gameMode.useItem(this.mc.player, this.mc.level, Hand.MAIN_HAND);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue