Начинающий
- Статус
- Оффлайн
- Регистрация
- 14 Дек 2022
- Сообщения
- 118
- Реакции
- 2
- Выберите загрузчик игры
- Fabric
Не знаю зачем но по приколу дам, мб кому-то пригодиться
code:
package fun.Nexgen.function.impl.misc;
import fun.Nexgen.api.events.impl.EventPacket;
import fun.Nexgen.api.events.impl.EventTick;
import fun.Nexgen.function.api.Category;
import fun.Nexgen.function.api.Function;
import fun.Nexgen.function.settings.impl.EnumSetting;
import fun.Nexgen.utils.math.TimerUtils;
import meteordevelopment.orbit.EventHandler;
import net.minecraft.client.gui.screen.ingame.GenericContainerScreen;
import net.minecraft.client.network.PlayerListEntry;
import net.minecraft.network.packet.s2c.play.GameMessageS2CPacket;
import net.minecraft.screen.slot.SlotActionType;
import net.minecraft.util.math.Vec3d;
import java.util.*;
import java.util.regex.Pattern;
public class AutoDuel extends Function {
public enum Mode implements fun.Nexgen.function.settings.api.Nameable {
Shield("Щит", 0),
Spikes("Шипы", 1),
Bow("Лук", 2),
Totems("Тотемы", 3),
NoDebuff("Нодебафф", 4),
Orbs("Шары", 5),
Classic("Классик", 6),
Cheater("Читер", 7),
Nether("Незер", 8);
private final String name;
private final int slot;
Mode(String name, int slot) {
this.name = name;
this.slot = slot;
}
public String getName() { return name; }
public int getSlot() { return slot; }
@Override
public String toString() { return name; }
}
private final EnumSetting<Mode> mode = new EnumSetting<>("Режим", Mode.Orbs);
private static final Pattern NAME_PATTERN = Pattern.compile("^\\w{3,16}$");
private final List<String> sent = new ArrayList<>();
private final TimerUtils duelT = new TimerUtils();
private final TimerUtils clrT = new TimerUtils();
private final TimerUtils pickT = new TimerUtils();
private final TimerUtils setT = new TimerUtils();
private Vec3d lastPos;
private boolean inDuel;
public AutoDuel() {
super("AutoDuel", Category.Misc, "Авто-дуэль с выбором режима");
setTag("AD");
}
@Override
public void onEnable() {
sent.clear();
inDuel = false;
if (mc.player != null) lastPos = mc.player.getPos();
duelT.reset();
clrT.reset();
}
@EventHandler
public void onTick(EventTick e) {
if (fullNullCheck() || inDuel) return;
if (lastPos != null && mc.player.getPos().distanceTo(lastPos) > 500) {
setToggled(false);
return;
}
lastPos = mc.player.getPos();
if (clrT.passed(30000)) {
sent.clear();
clrT.reset();
}
if (duelT.passed(1000)) {
sendDuel();
duelT.reset();
}
handleGui();
}
@EventHandler
public void onPacket(EventPacket.Receive e) {
if (fullNullCheck()) return;
if (e.getPacket() instanceof GameMessageS2CPacket p) {
String msg = p.content().getString().toLowerCase();
if ((msg.contains("начало") && msg.contains("через") && msg.contains("секунд")) ||
msg.contains("поединок начался") ||
msg.contains("во время поединка")) {
inDuel = true;
setToggled(false);
}
}
}
private void sendDuel() {
for (String p : getPlayers()) {
if (!sent.contains(p) && !p.equals(mc.player.getName().getString())) {
mc.getNetworkHandler().sendChatCommand("duel " + p);
sent.add(p);
break;
}
}
}
private void handleGui() {
if (!(mc.currentScreen instanceof GenericContainerScreen s)) return;
int id = s.getScreenHandler().syncId;
String t = s.getTitle().getString();
if (t.contains("Выбор набора") && pickT.passed(150)) {
mc.interactionManager.clickSlot(id, mode.getValue().getSlot(), 0, SlotActionType.QUICK_MOVE, mc.player);
pickT.reset();
} else if (t.contains("Настройка поединка") && setT.passed(150)) {
mc.interactionManager.clickSlot(id, 0, 0, SlotActionType.QUICK_MOVE, mc.player);
setT.reset();
}
}
private List<String> getPlayers() {
List<String> list = new ArrayList<>();
if (mc.getNetworkHandler() == null) return list;
for (PlayerListEntry e : mc.getNetworkHandler().getPlayerList()) {
String n = e.getProfile().getName();
if (NAME_PATTERN.matcher(n).matches()) list.add(n);
}
return list;
}
@Override
public void onDisable() {
sent.clear();
inDuel = false;
}
}