• Ну и что вы думаете? Мы взяли и создали свой собственный чат, с блекджеком и шлюхами, теперь все легенды в одном месте: даже те 1000 человек, которых мы забанили в старом чате 🫡 Будем публиковать там очень интересные подробности нового дизайна форума, oh yeah

    Вступай и становись легендой, пока это не стало поздно: жмякай на меня, ток не сильно(

AuctionHelper + Drop All Forge 1.16.5 | Подарок на новый год

Начинающий
Статус
Оффлайн
Регистрация
20 Июн 2024
Сообщения
456
Реакции[?]
1
Поинты[?]
2K
В общем и мне надо что-то подарить этому форуму на новый год. :coolface:
Хочу сказать спасибо всем участникам этого форума за такой необычный и интересный год за такое количество конфликтов кряков сливов и другого.
С новым годом пастеры! (Я в том числе если что)


AuctionHelperFeature создайте сами там просто класс с функцией нужен. Думаю с добавлениям миксинов в ваш проэкт разберётесь сами.


AuctionHelperMixin.java:
@OnlyIn(Dist.CLIENT)
@Mixin(ContainerScreen.class)
public abstract class MixinContainerScreen {

   [USER=8455]@Shadow[/USER]
    public abstract int getGuiTop();
    [USER=8455]@Shadow[/USER]
    public abstract int getGuiLeft();

    @Inject(method = "render", at = @At("TAIL"))
    private void onRender(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo ci) {
        ContainerScreen<?> screen = (ContainerScreen<?>) (Object) this;
        int x = (screen.width - screen.getXSize()) / 2 + screen.getXSize() / 2 - 50;
        int y = (screen.height - screen.getYSize()) / 2 + screen.getYSize() / 2 - 10;
        for (Feature feature : FeatureProvider.features) {
            if (feature.name.contains("AuctionHelper") && feature.enable == true) {
                if (screen.getTitle().getString().contains("Аукцион") || screen.getTitle().getString().contains("Поиск")) {
                    int minSlot = AuctionUtil.cheapItem();
                    for (Slot slot : screen.getMenu().slots) {
                        if (slot.getSlotIndex() == minSlot) {
                            int sosalX = this.getGuiLeft() + slot.x;
                            int sosalY = this.getGuiTop() + slot.y;
                            mc.gui.fill(matrices, sosalX - 2, sosalY - 2, sosalX + 18, sosalY + 18, 0x8000FF00);
                            break;
                        }
                    }
                }
            }
        }
    }
}

AuctionUtil.java:
 public static int getPrice(String nbt) {
        String regex = "\\$(\\d{1,3}(?:,\\d{3})*(?:\\.\\d{2})?)";
        Pattern pattern = Pattern.compile(regex);
        Matcher matcher = pattern.matcher(nbt);

        if (matcher.find()) {
            String priceString = matcher.group(1).replace(",", "").replace("$", "");
            return Integer.parseInt(priceString);
        }

        return 0;
    }

    public static int cheapItem() {
        int cheapestSlot = -1;
        int cheapestPrice = Integer.MAX_VALUE;
        for (int i = 0; i < 44; i++) {
            ItemStack itemStack = mc.player.containerMenu.getSlot(i).getItem();
            if (!itemStack.isEmpty()) {
                String nbt = itemStack.getTag() != null ? itemStack.getTag().toString() : "";
                int price = getPrice(nbt);

                if (price < cheapestPrice) {
                    cheapestPrice = price;
                    cheapestSlot = i;
                }
            }
        }
        return cheapestSlot;
    }

}
Drop All:
DropAllMixin.java:
@Mixin(InventoryScreen.class)
public abstract class MixinInventoryScreen extends ContainerScreen<Container> {

    public MixinInventoryScreen(Container container, PlayerInventory playerInventory, ITextComponent title) {
        super(container, playerInventory, title);
    }

    @Inject(method = "init", at = @At("TAIL"))
    private void renderButton(CallbackInfo ci) {
        Button dropAll = new Button(
                width / 2 - 50, //
                140,
                100,
                20,
                new StringTextComponent("Выбросить всё"),
                button -> {
                    for(int index = 0; index <= 36; index++) {
                        if(!mc.player.inventory.getItem(index).isEmpty()) {
                            mc.gameMode.handleInventoryMouseClick(mc.player.containerMenu.containerId, index, 0, ClickType.THROW, mc.player);
                        }
                    }
                }
        );
        this.addButton(dropAll);
    }
}
 
Похожие темы
Сверху Снизу