Начинающий
- Статус
- Оффлайн
- Регистрация
- 17 Июл 2024
- Сообщения
- 258
- Реакции
- 3
- Выберите загрузчик игры
- Vanilla
- Прочие моды
видел эту функцию в кряке дельты ну сделал вроде нормальная 1 минус не берет с инвентаря работает на всех блоках предметах надо просто найти название по типу diamond_pickaxe можно настроить скорость и включить логи ну это спасибо чату лгбт что добавил это ещё он сам выключаеться если нету места на ах
Пожалуйста, авторизуйтесь для просмотра ссылки.
Код:
package client.main.module.impl.misc;
import client.main.module.api.Category;
import client.main.module.api.Module;
import client.main.module.api.ModuleRegister;
import client.main.module.settings.impl.StringSetting;
import client.main.module.settings.impl.BooleanSetting;
import client.main.other.litkautil.StopWatch;
import client.events.EventPacket;
import com.google.common.eventbus.Subscribe;
import net.minecraft.network.play.server.SChatPacket;
import net.minecraft.item.ItemStack;
@ModuleRegister(name = "AutoSell", type = Category.Misc, desc = "Автоматически продает указанный предмет")
public class AutoSell extends Module {
private final StringSetting itemName = new StringSetting("Предмет", "", "Часть названия для поиска");
private final StringSetting price = new StringSetting("Цена", "", "Цена в монетах");
private final BooleanSetting logChat = new BooleanSetting("Логи в чат", false);
private final client.main.module.settings.impl.SliderSetting sellDelay =
new client.main.module.settings.impl.SliderSetting("Задержка продаж (ms)", 1000f, 200f, 5000f, 100f);
private String lastSoldKey = "";
private int scanIndex = 0;
private final StopWatch sellTimer = new StopWatch();
public AutoSell() {
addSettings(itemName, price, logChat, sellDelay);
}
@Override
public boolean onEnable() {
super.onEnable();
lastSoldKey = "";
scanIndex = 0;
if (mc.player == null) {
return false;
}
String itemQuery = itemName.get().trim().toLowerCase();
String pr = price.get().trim();
if (itemQuery.isEmpty()) {
print("Укажите название предмета");
}
if (pr.isEmpty()) {
print("Укажите цену");
}
sellTimer.reset();
return false;
}
@Subscribe
private void onUpdate(client.events.EventUpdate e) {
if (mc.player == null) return;
String itemQuery = itemName.get().trim().toLowerCase();
String pr = price.get().trim();
if (itemQuery.isEmpty() || pr.isEmpty()) {
return;
}
ItemStack held = mc.player.getHeldItemMainhand();
if (held == null || held.isEmpty()) {
lastSoldKey = "";
}
if (held != null && !held.isEmpty()) {
String heldKey = held.getItem().getTranslationKey().toLowerCase();
if ((heldKey.contains(itemQuery) || held.getItem().toString().toLowerCase().contains(itemQuery))
&& !heldKey.equals(lastSoldKey)) {
mc.player.sendChatMessage("/ah sell " + pr);
lastSoldKey = heldKey;
if (logChat.get()) {
print("Предмет " + heldKey + " выставлен за " + pr + " (в руке)");
}
sellTimer.reset();
return;
}
}
if (!sellTimer.isReached((long) sellDelay.get().intValue())) {
return;
}
sellTimer.reset();
int total = mc.player.inventory.mainInventory.size();
int found = -1;
String foundKey = null;
for (int i = 0; i < total; i++) {
int idx = (scanIndex + i) % total;
ItemStack s = mc.player.inventory.mainInventory.get(idx);
if (s == null || s.isEmpty()) continue;
String key = s.getItem().getTranslationKey().toLowerCase();
if (key.contains(itemQuery) || s.getItem().toString().toLowerCase().contains(itemQuery)) {
found = idx;
foundKey = key;
break;
}
}
if (found != -1 && foundKey != null) {
ItemStack heldNow = mc.player.getHeldItemMainhand();
if (heldNow != null && !heldNow.isEmpty()) {
String heldKey = heldNow.getItem().getTranslationKey().toLowerCase();
if (heldKey.equals(lastSoldKey) && heldKey.equals(foundKey)) {
scanIndex = (found + 1) % total;
return;
}
}
if (found < 9) {
mc.player.inventory.currentItem = found;
if (logChat.get()) print("Переключаюсь на слот " + found + " (хотбар)");
} else {
client.util.player.InventoryUtil.moveItem(found, 0, true);
mc.player.inventory.currentItem = 0;
if (logChat.get()) print("Перемещаю предмет из слота " + found + " в хотбар");
}
scanIndex = (found + 1) % total;
return;
}
scanIndex = (scanIndex + total) % total;
}
@Override
public boolean onDisable() {
lastSoldKey = "";
scanIndex = 0;
return super.onDisable();
}
@Subscribe
public void onPacket(EventPacket e) {
if (!e.isReceive() || !(e.getPacket() instanceof SChatPacket chat)) return;
String msg = net.minecraft.util.text.TextFormatting.getTextWithoutFormattingCodes(chat.getChatComponent().getString()).toLowerCase();
if (msg.contains("освободите хранилище") || msg.contains("уберите предметы с продажи")) {
if (mc.player != null) mc.player.sendMessage(new net.minecraft.util.text.StringTextComponent("§c[AutoSell] Отключаюсь: " + msg), mc.player.getUniqueID());
setenabled(false, false);
} else if (msg.contains("используете команду слишком часто") || msg.contains("слишком часто")) {
if (mc.player != null) mc.player.sendMessage(new net.minecraft.util.text.StringTextComponent("§e[AutoSell] Слишком часто, попробую ещё раз"), mc.player.getUniqueID());
lastSoldKey = "";
sellTimer.reset();
}
}
}
