Начинающий
- Статус
- Оффлайн
- Регистрация
- 30 Сен 2022
- Сообщения
- 87
- Реакции
- 1
- Выберите загрузчик игры
- Прочие моды
прошу не кидать По мне кирпичами первая тема в жизни
доработал AhHelper на 3.1 expensive,по установке сам гайд - (1) AuctionHelper FunTime exp 3.1 ready | Сайт читов, скриптов и кодов для онлайн игр - YouGame.Biz
SS
сама функция
доработал AhHelper на 3.1 expensive,по установке сам гайд - (1) AuctionHelper FunTime exp 3.1 ready | Сайт читов, скриптов и кодов для онлайн игр - YouGame.Biz
SS
Пожалуйста, авторизуйтесь для просмотра ссылки.
сама функция
Код:
package im.natrix.functions.impl.misc;
import com.google.common.eventbus.Subscribe;
import com.viaversion.viaversion.libs.gson.JsonArray;
import com.viaversion.viaversion.libs.gson.JsonObject;
import com.viaversion.viaversion.libs.gson.JsonParser;
import im.natrix.events.EventUpdate;
import im.natrix.functions.api.Category;
import im.natrix.functions.api.Function;
import im.natrix.functions.api.FunctionRegister;
import im.natrix.functions.settings.impl.BooleanSetting;
import lombok.Getter;
import lombok.Setter;
import net.minecraft.client.gui.screen.inventory.ChestScreen;
import net.minecraft.inventory.container.Container;
import net.minecraft.inventory.container.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.ListNBT;
Getter
setter
@FunctionRegister(name = "AuctionHelper", type = Category.Misc)
public class AhHelper extends Function {
public BooleanSetting three = new BooleanSetting("Подсвечивать 3 слота", true);
public AhHelper() {
addSettings(three);
}
float x = 0;
float y = 0;
float x2 = 0;
float y2 = 0;
float x3 = 0;
float y3 = 0;
Subscribe
public void onUpdate(EventUpdate update) {
if (mc.currentScreen instanceof ChestScreen e) {
if (e.getTitle().getString().contains("Аукцион") || e.getTitle().getString().contains("Поиск:")) {
Container container = e.getContainer();
Slot slot1 = null;
Slot slot2 = null;
Slot slot3 = null;
double fsPrice = Double.MAX_VALUE;
double medPrice = Double.MAX_VALUE;
double thPrice = Double.MAX_VALUE;
for (Slot slot : container.inventorySlots) {
if (slot.slotNumber > 44) continue;
ItemStack stack = slot.getStack();
int totalPrice = extractPriceFromStack(stack);
int count = stack.getCount();
if (totalPrice == -1 || count == 0) continue;
double pricePerItem = (double) totalPrice / count;
if (pricePerItem < fsPrice) {
thPrice = medPrice;
slot3 = slot2;
medPrice = fsPrice;
slot2 = slot1;
fsPrice = pricePerItem;
slot1 = slot;
} else if (three.get() && pricePerItem < medPrice) {
thPrice = medPrice;
slot3 = slot2;
medPrice = pricePerItem;
slot2 = slot;
} else if (three.get() && pricePerItem < thPrice) {
thPrice = pricePerItem;
slot3 = slot;
}
}
if (slot1 != null) {
setX(slot1.xPos);
setY(slot1.yPos);
}
if (slot2 != null) {
setX2(slot2.xPos);
setY2(slot2.yPos);
}
if (slot3 != null) {
setX3(slot3.xPos);
setY3(slot3.yPos);
}
} else {
setX(0);
setX2(0);
setX3(0);
}
} else {
setX(0);
setX2(0);
setX3(0);
}
}
protected int extractPriceFromStack(ItemStack stack) {
CompoundNBT tag = stack.getTag();
if (tag != null && tag.contains("display", 10)) {
CompoundNBT display = tag.getCompound("display");
if (display.contains("Lore", 9)) {
ListNBT lore = display.getList("Lore", 8);
for (int j = 0; j < lore.size(); ++j) {
JsonObject object = JsonParser.parseString(lore.getString(j)).getAsJsonObject();
if (object.has("extra")) {
JsonArray array = object.getAsJsonArray("extra");
if (array.size() > 2) {
JsonObject title = array.get(1).getAsJsonObject();
if (title.get("text").getAsString().trim().toLowerCase().contains("ценa")) {
String line = array.get(2).getAsJsonObject().get("text").getAsString().trim()
.substring(1).replaceAll(" ", "").replaceAll(",", "");
try {
return Integer.parseInt(line);
} catch (NumberFormatException e) {
return -1;
}
}
}
}
}
}
}
return -1;
}
}
//holz lox