Подписывайтесь на наш Telegram и не пропускайте важные новости! Перейти

Вопрос AuctionHelper

Есть ли сейчас на югейме рабочий AucHelper для фт/хв?
если есть то пинганите эту тему плиз

Пожалуйста, зарегистрируйтесь или авторизуйтесь, чтобы увидеть содержимое.



база zenith norecode джп код но работает

Код:
Expand Collapse Copy
package fun.Just.features.impl.render;

import fun.Just.events.container.HandledScreenEvent;
import fun.Just.features.module.Module;
import fun.Just.features.module.ModuleCategory;
import fun.Just.features.module.setting.implement.ColorSetting;
import fun.Just.utils.client.managers.event.EventHandler;
import fun.Just.utils.display.shape.ShapeProperties;
import fun.Just.utils.display.color.ColorAssist;
import fun.Just.events.player.TickEvent;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.ingame.GenericContainerScreen;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.item.ItemStack;
import net.minecraft.screen.slot.Slot;
import net.minecraft.text.Text;

import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class AuctionHelper extends Module {

    private ColorSetting cheapestColor = new ColorSetting("Самый дешевый", "Подсветка самого дешевого предмета")
            .setColor(0xFF00FF00);

    private ColorSetting secondColor = new ColorSetting("Второй по цене", "Подсветка второго по дешевизне предмета")
            .setColor(0xFFFFFF00);

    private ColorSetting thirdColor = new ColorSetting("Третий по цене", "Подсветка третьего по дешевизне предмета")
            .setColor(0xFFFFA500);

    private Slot cheapestSlot, secondSlot, thirdSlot;

    private static final Pattern PRICE_PATTERN = Pattern.compile("Цена\\s*\\$?\\s*([\\d,]+)");

    public AuctionHelper() {
        super("AuctionHelper", "AuctionHelper", ModuleCategory.RENDER);
        setup(cheapestColor, secondColor, thirdColor);
    }

    @EventHandler
    public void onTick(TickEvent e) {
        if (!(mc.currentScreen instanceof GenericContainerScreen)) {
            resetSlots();
            return;
        }
        GenericContainerScreen screen = (GenericContainerScreen) mc.currentScreen;
        String title = screen.getTitle().getString();
        if (!title.contains("Аукционы") && !title.contains("Аукцион") && !title.contains("Поиск:")) {
            resetSlots();
            return;
        }

        List<Slot> slots = screen.getScreenHandler().slots;
        findCheapestSlots(slots);
    }

    private void findCheapestSlots(List<Slot> slots) {
        cheapestSlot = null;
        secondSlot = null;
        thirdSlot = null;

        double firstPrice = Double.MAX_VALUE;
        double secondPrice = Double.MAX_VALUE;
        double thirdPrice = Double.MAX_VALUE;

        for (Slot slot : slots) {
            if (slot.id > 44) continue;

            ItemStack stack = slot.getStack();
            if (stack.isEmpty()) continue;

            int totalPrice = extractPriceFromStack(stack);
            if (totalPrice == -1) continue;

            int count = stack.getCount();
            if (count == 0) continue;

            double pricePerItem = (double) totalPrice / count;

            if (pricePerItem < firstPrice) {
                thirdPrice = secondPrice;
                thirdSlot = secondSlot;

                secondPrice = firstPrice;
                secondSlot = cheapestSlot;

                firstPrice = pricePerItem;
                cheapestSlot = slot;
            } else if (pricePerItem < secondPrice) {
                thirdPrice = secondPrice;
                thirdSlot = secondSlot;

                secondPrice = pricePerItem;
                secondSlot = slot;
            } else if (pricePerItem < thirdPrice) {
                thirdPrice = pricePerItem;
                thirdSlot = slot;
            }
        }
    }

    protected int extractPriceFromStack(ItemStack stack) {
        try {
            String itemName = stack.getName().getString();

            List<Text> texts = new java.util.ArrayList<>();

            texts.add(stack.getName());

            net.minecraft.component.ComponentMap components = stack.getComponents();
            if (components != null) {
                net.minecraft.component.type.LoreComponent lore = components.get(net.minecraft.component.DataComponentTypes.LORE);
                if (lore != null) {
                    texts.addAll(lore.lines());
                }
            }

            for (Text text : texts) {
                String str = text.getString();
                if (str.contains("Цена") || str.contains("$")) {
                    java.util.regex.Matcher matcher = java.util.regex.Pattern.compile("([\\d,]+)").matcher(str);
                    if (matcher.find()) {
                        String priceStr = matcher.group(1).replace(",", "");
                        try {
                            return Integer.parseInt(priceStr);
                        } catch (NumberFormatException e) {
                            continue;
                        }
                    }
                }
            }

        } catch (Exception e) {
        }

        return -1;
    }

    private void resetSlots() {
        cheapestSlot = null;
        secondSlot = null;
        thirdSlot = null;
    }

    @EventHandler
    public void onRenderScreen(HandledScreenEvent e) {
        if (!(mc.currentScreen instanceof GenericContainerScreen)) return;

        GenericContainerScreen screen = (GenericContainerScreen) mc.currentScreen;
        String title = screen.getTitle().getString();

        if (!title.contains("Аукционы") && !title.contains("Аукцион") && !title.contains("Поиск:")) return;

        DrawContext context = e.getDrawContext();
        MatrixStack matrices = context.getMatrices();

        int x = (screen.width - e.getBackgroundWidth()) / 2;
        int y = (screen.height - e.getBackgroundHeight()) / 2;

        matrices.push();
        matrices.translate(x, y, 0);

        if (cheapestSlot != null) {
            highlightSlot(context, cheapestSlot, cheapestColor.getColor());
        }
        if (secondSlot != null) {
            highlightSlot(context, secondSlot, secondColor.getColor());
        }
        if (thirdSlot != null) {
            highlightSlot(context, thirdSlot, thirdColor.getColor());
        }
        matrices.pop();
    }

    private int getBlinkingColor(int color) {
        return color;
    }

    private void highlightSlot(DrawContext context, Slot slot, int color) {
        if (slot != null) {
            rectangle.render(ShapeProperties.create(
                    context.getMatrices(),
                    slot.x,
                    slot.y,
                    16,
                    16
            ).color(color).build());
        }
    }
}
 
Назад
Сверху Снизу