forked from RepoMirrors/kami-blue
close #631
This commit is contained in:
parent
8164b66274
commit
fd60fd087d
|
@ -3,42 +3,63 @@ package me.zeroeightsix.kami.module.modules.misc;
|
|||
import me.zero.alpine.listener.EventHandler;
|
||||
import me.zero.alpine.listener.Listener;
|
||||
import me.zeroeightsix.kami.command.Command;
|
||||
import me.zeroeightsix.kami.event.events.GuiScreenEvent;
|
||||
import me.zeroeightsix.kami.event.events.PacketEvent;
|
||||
import me.zeroeightsix.kami.event.events.ServerConnectedEvent;
|
||||
import me.zeroeightsix.kami.event.events.ServerDisconnectedEvent;
|
||||
import me.zeroeightsix.kami.module.Module;
|
||||
import me.zeroeightsix.kami.setting.Setting;
|
||||
import me.zeroeightsix.kami.setting.Settings;
|
||||
import net.minecraft.client.gui.GuiDisconnected;
|
||||
import net.minecraft.client.multiplayer.GuiConnecting;
|
||||
import net.minecraft.client.multiplayer.ServerData;
|
||||
import net.minecraft.network.play.server.SPacketSoundEffect;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import static me.zeroeightsix.kami.KamiMod.EVENT_BUS;
|
||||
|
||||
/**
|
||||
* Created by 086 on 22/03/2018.
|
||||
* Updated by Qther on 05/03/20
|
||||
* Updated by S-B99 on 07/03/20
|
||||
* Updated by S-B99 on 30/03/20
|
||||
*/
|
||||
@Module.Info(name = "AutoFish", category = Module.Category.MISC, description = "Automatically catch fish")
|
||||
@Module.Info(name = "AutoFish", category = Module.Category.MISC, description = "Automatically catch fish", alwaysListening = true)
|
||||
public class AutoFish extends Module {
|
||||
private boolean recastHide = false;
|
||||
private static ServerData cServer;
|
||||
Random random;
|
||||
|
||||
private Setting<Boolean> defaultSetting = register(Settings.b("Defaults", false));
|
||||
private Setting<Integer> baseDelay = register(Settings.integerBuilder("Throw Delay").withValue(450).withMinimum(50).withMaximum(1000).build());
|
||||
private Setting<Integer> extraDelay = register(Settings.integerBuilder("Catch Delay").withValue(300).withMinimum(0).withMaximum(1000).build());
|
||||
private Setting<Integer> variation = register(Settings.integerBuilder("Variation").withValue(50).withMinimum(0).withMaximum(1000).build());
|
||||
|
||||
Random random;
|
||||
private Setting<Boolean> recast = register(Settings.booleanBuilder("Recast").withValue(false).withVisibility(v -> recastHide).build());
|
||||
|
||||
public void onUpdate() {
|
||||
if (defaultSetting.getValue()) {
|
||||
baseDelay.setValue(450);
|
||||
extraDelay.setValue(300);
|
||||
variation.setValue(50);
|
||||
defaultSetting.setValue(false);
|
||||
Command.sendChatMessage(getChatName() + " Set to defaults!");
|
||||
Command.sendChatMessage(getChatName() + " Close and reopen the " + getName() + " settings menu to see changes");
|
||||
if (defaultSetting.getValue()) defaults();
|
||||
if (recast.getValue()) {
|
||||
Command.sendChatMessage("owo");
|
||||
} else {
|
||||
Command.sendChatMessage("uwu");
|
||||
}
|
||||
if (mc.player != null && recast.getValue()) {
|
||||
mc.rightClickMouse();
|
||||
recast.setValue(false);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private Listener<PacketEvent.Receive> receiveListener = new Listener<>(e -> {
|
||||
if (e.getPacket() instanceof SPacketSoundEffect) {
|
||||
public Listener<ServerDisconnectedEvent> disconnectedEventListener = new Listener<>(event -> {
|
||||
if (isDisabled()) return;
|
||||
recast.setValue(true);
|
||||
});
|
||||
|
||||
@EventHandler
|
||||
private Listener<PacketEvent.Receive> receiveListener = new Listener<>(this::invoke);
|
||||
|
||||
private void invoke(PacketEvent.Receive e) {
|
||||
if (isEnabled() && e.getPacket() instanceof SPacketSoundEffect) {
|
||||
SPacketSoundEffect pck = (SPacketSoundEffect) e.getPacket();
|
||||
if (pck.getSound().getSoundName().toString().toLowerCase().contains("entity.bobber.splash")) {
|
||||
if (mc.player.fishEntity == null) return;
|
||||
|
@ -51,7 +72,8 @@ public class AutoFish extends Module {
|
|||
random = new Random();
|
||||
try {
|
||||
Thread.sleep(extraDelay.getValue() + random.ints(1, -variation.getValue(), variation.getValue()).findFirst().getAsInt());
|
||||
} catch (InterruptedException ignored) { }
|
||||
} catch (InterruptedException ignored) {
|
||||
}
|
||||
mc.rightClickMouse();
|
||||
random = new Random();
|
||||
try {
|
||||
|
@ -64,10 +86,33 @@ public class AutoFish extends Module {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public Listener<GuiScreenEvent.Closed> serverConnectedEvent = new Listener<>(event -> {
|
||||
if (isEnabled() && event.getScreen() instanceof GuiConnecting) {
|
||||
cServer = mc.currentServerData;
|
||||
EVENT_BUS.post(new ServerConnectedEvent());
|
||||
}
|
||||
});
|
||||
|
||||
public boolean kindaEquals(int kara, int ni) {
|
||||
@EventHandler
|
||||
public Listener<GuiScreenEvent.Displayed> serverDisconnectedEvent = new Listener<>(event -> {
|
||||
if (isEnabled() && event.getScreen() instanceof GuiDisconnected && (cServer != null || mc.currentServerData != null)) {
|
||||
EVENT_BUS.post(new ServerDisconnectedEvent());
|
||||
}
|
||||
});
|
||||
|
||||
private boolean kindaEquals(int kara, int ni) {
|
||||
return ni == kara || ni == kara - 1 || ni == kara + 1;
|
||||
}
|
||||
|
||||
private void defaults() {
|
||||
baseDelay.setValue(450);
|
||||
extraDelay.setValue(300);
|
||||
variation.setValue(50);
|
||||
defaultSetting.setValue(false);
|
||||
Command.sendChatMessage(getChatName() + " Set to defaults!");
|
||||
Command.sendChatMessage(getChatName() + " Close and reopen the " + getName() + " settings menu to see changes");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue