blob: e275c4c27cad74c791046228253432e2af097f1e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
package ftbsc.bscv.modules.self;
import com.mojang.brigadier.CommandDispatcher;
import ftbsc.bscv.ICommons;
import ftbsc.bscv.events.PacketEvent;
import ftbsc.bscv.modules.AbstractModule;
import ftbsc.bscv.tools.Setting;
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 AbstractModule implements ICommons {
@Override
public String getName() {
return "AutoFish";
}
@Override
public Group getGroup() {
return Group.SELF;
}
public final ForgeConfigSpec.ConfigValue<Boolean> recast;
public final ForgeConfigSpec.ConfigValue<Integer> delay;
// public final ForgeConfigSpec.ConfigValue<Long> reaction;
public AutoFish() {
super();
this.recast = Setting.Bool.builder()
.name("recast")
.comment("automatically recast hook after fishing")
.fallback(false)
.build(this);
this.delay = Setting.Number.builder()
.fallback(2500)
.name("delay")
.comment("how long in ms to wait before recasting hook")
.build(this);
}
@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);
}
}
}
|