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

Часть функционала AutoPotion Авто Зелье варка

Начинающий
Начинающий
Статус
Оффлайн
Регистрация
17 Июл 2024
Сообщения
378
Реакции
5
Выберите загрузчик игры
  1. Vanilla
  2. Прочие моды
Увидел что наш любимый @ConeTin сделал авто зелье варку и я взял идею и сделал вам и сливаю вам ⚠️ВНИМАНИЕ ВАЙПКОДИНГ ПРИСУТСТВУЕТ НАПИСАНО Claude Opus 4.7
Работает на всех серверах
Пожалуйста, авторизуйтесь для просмотра ссылки.

Код:
Expand Collapse Copy
package client.main.module.impl.misc;

import client.events.EventUpdate;
import client.main.module.api.Category;
import client.main.module.api.Module;
import client.main.module.api.ModuleRegister;
import client.main.module.settings.impl.BooleanSetting;
import client.main.module.settings.impl.ModeSetting;
import client.main.module.settings.impl.StringSetting;
import client.util.math.StopWatch;
import com.google.common.eventbus.Subscribe;
import net.minecraft.client.gui.screen.inventory.BrewingStandScreen;
import net.minecraft.client.gui.screen.inventory.ChestScreen;
import net.minecraft.inventory.container.BrewingStandContainer;
import net.minecraft.inventory.container.ChestContainer;
import net.minecraft.inventory.container.ClickType;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.potion.PotionUtils;
import net.minecraft.potion.Potions;
import net.minecraft.tileentity.BrewingStandTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.vector.Vector3d;

@ModuleRegister(name = "AutoPotion", type = Category.Misc, desc = "Automatically brews potions in Brewing Stand")
public class AutoPotion extends Module {
   
    private final ModeSetting recipe = new ModeSetting("Рецепт", "Невидимость", "Невидимость", "Сила 2", "Скорость 2");
    private final BooleanSetting usePotionChest = new BooleanSetting("Сундук зелий", false);
    private final StringSetting potionChestX = new StringSetting("Зелья X", "0", "X координата сундука зелий");
    private final StringSetting potionChestY = new StringSetting("Зелья Y", "0", "Y координата сундука зелий");
    private final StringSetting potionChestZ = new StringSetting("Зелья Z", "0", "Z координата сундука зелий");

    private final BooleanSetting useIngredientChest = new BooleanSetting("Сундук ингредиентов", false);
    private final StringSetting ingredientChestX = new StringSetting("Ингредиенты X", "0", "X координата сундука ингредиентов");
    private final StringSetting ingredientChestY = new StringSetting("Ингредиенты Y", "0", "Y координата сундука ингредиентов");
    private final StringSetting ingredientChestZ = new StringSetting("Ингредиенты Z", "0", "Z координата сундука ингредиентов");

    private final BooleanSetting useBottleChest = new BooleanSetting("Сундук бутылок", false);
    private final StringSetting bottleChestX = new StringSetting("Бутылки X", "0", "X координата сундука бутылок");
    private final StringSetting bottleChestY = new StringSetting("Бутылки Y", "0", "Y координата сундука бутылок");
    private final StringSetting bottleChestZ = new StringSetting("Бутылки Z", "0", "Z координата сундука бутылок");
    private static final Item[] RECIPE_INVISIBILITY = {
        Items.NETHER_WART,
        Items.GOLDEN_CARROT,
        Items.FERMENTED_SPIDER_EYE,
        Items.REDSTONE
    };
    private static final Item[] RECIPE_STRENGTH_2 = {
        Items.NETHER_WART,
        Items.BLAZE_POWDER,
        Items.GLOWSTONE_DUST
    };
    private static final Item[] RECIPE_SPEED_2 = {
        Items.NETHER_WART,
        Items.SUGAR,
        Items.GLOWSTONE_DUST
    };
    private enum Stage {
        FIND_STAND, OPEN_STAND,
        TAKE_BOTTLES_OPEN, TAKE_BOTTLES,
        TAKE_INGREDIENTS_OPEN, TAKE_INGREDIENTS,
        PLACE_BOTTLES,
        BREWING, WAITING,
        COLLECT,
        STORE_POTIONS_OPEN, STORE_POTIONS
    }

    private Stage stage = Stage.FIND_STAND;
    private BlockPos standPos = null;
    private final StopWatch timer = new StopWatch();
    private final StopWatch openTimer = new StopWatch();
    private boolean ingredientPlaced = false;
    private int currentIngredientIndex = 0;

    public AutoPotion() {
        addSettings(
            recipe,
            usePotionChest, potionChestX, potionChestY, potionChestZ,
            useIngredientChest, ingredientChestX, ingredientChestY, ingredientChestZ,
            useBottleChest, bottleChestX, bottleChestY, bottleChestZ
        );
        potionChestX.setVisible(usePotionChest::get);
        potionChestY.setVisible(usePotionChest::get);
        potionChestZ.setVisible(usePotionChest::get);
        ingredientChestX.setVisible(useIngredientChest::get);
        ingredientChestY.setVisible(useIngredientChest::get);
        ingredientChestZ.setVisible(useIngredientChest::get);
        bottleChestX.setVisible(useBottleChest::get);
        bottleChestY.setVisible(useBottleChest::get);
        bottleChestZ.setVisible(useBottleChest::get);
    }

    private Item[] getRecipe() {
        if (recipe.is("Сила 2")) return RECIPE_STRENGTH_2;
        if (recipe.is("Скорость 2")) return RECIPE_SPEED_2;
        return RECIPE_INVISIBILITY;
    }

    @Override
    public boolean onEnable() {
        stage = Stage.FIND_STAND;
        standPos = null;
        ingredientPlaced = false;
        currentIngredientIndex = 0;
        return super.onEnable();
    }

    @Override
    public boolean onDisable() {
        if (mc.player != null && mc.currentScreen != null) mc.player.closeScreen();
        stage = Stage.FIND_STAND;
        ingredientPlaced = false;
        currentIngredientIndex = 0;
        return super.onDisable();
    }

    @Subscribe
    public void onUpdate(EventUpdate e) {
        if (mc.player == null || mc.world == null) return;
        if (!timer.isReached(300)) return;
        timer.reset();

        switch (stage) {
            case FIND_STAND -> {
                for (BlockPos pos : BlockPos.getAllInBoxMutable(
                        mc.player.getPosition().add(-4, -2, -4),
                        mc.player.getPosition().add(4, 2, 4))) {
                    TileEntity te = mc.world.getTileEntity(pos);
                    if (te instanceof BrewingStandTileEntity) {
                        standPos = pos.toImmutable();
                        if (useBottleChest.get() && needBottles()) {
                            stage = Stage.TAKE_BOTTLES_OPEN;
                        } else if (useIngredientChest.get() && needIngredients()) {
                            stage = Stage.TAKE_INGREDIENTS_OPEN;
                        } else {
                            stage = Stage.OPEN_STAND;
                        }
                        return;
                    }
                }
            }
            case TAKE_BOTTLES_OPEN -> {
                if (isChestOpen()) {
                    stage = Stage.TAKE_BOTTLES;
                    return;
                }
                if (openTimer.isReached(600)) {
                    openChest(getBottleChestPos());
                    openTimer.reset();
                }
            }
            case TAKE_BOTTLES -> {
                if (!isChestOpen()) { stage = Stage.TAKE_BOTTLES_OPEN; return; }
                ChestContainer c = (ChestContainer) mc.player.openContainer;
                int chestSlots = c.getNumRows() * 9;
                boolean took = false;
                for (int i = 0; i < chestSlots; i++) {
                    ItemStack stack = c.inventorySlots.get(i).getStack();
                    if (stack.isEmpty()) continue;
                    if (stack.getItem() == Items.POTION && PotionUtils.getPotionFromItem(stack) == Potions.WATER) {
                        mc.playerController.windowClick(c.windowId, i, 0, ClickType.QUICK_MOVE, mc.player);
                        took = true;
                        break;
                    }
                }
                if (!took || !needBottles()) {
                    mc.player.closeScreen();
                    if (useIngredientChest.get() && needIngredients()) {
                        stage = Stage.TAKE_INGREDIENTS_OPEN;
                    } else {
                        stage = Stage.OPEN_STAND;
                    }
                }
            }
            case TAKE_INGREDIENTS_OPEN -> {
                if (isChestOpen()) {
                    stage = Stage.TAKE_INGREDIENTS;
                    return;
                }
                if (openTimer.isReached(600)) {
                    openChest(getIngredientChestPos());
                    openTimer.reset();
                }
            }
            case TAKE_INGREDIENTS -> {
                if (!isChestOpen()) { stage = Stage.TAKE_INGREDIENTS_OPEN; return; }
                ChestContainer c = (ChestContainer) mc.player.openContainer;
                int chestSlots = c.getNumRows() * 9;
                boolean took = false;
                for (Item ingredient : getRecipe()) {
                    if (hasItemInInventory(ingredient)) continue;
                    for (int i = 0; i < chestSlots; i++) {
                        ItemStack stack = c.inventorySlots.get(i).getStack();
                        if (!stack.isEmpty() && stack.getItem() == ingredient) {
                            mc.playerController.windowClick(c.windowId, i, 0, ClickType.QUICK_MOVE, mc.player);
                            took = true;
                            break;
                        }
                    }
                    if (took) break;
                }
                if (!took || !needIngredients()) {
                    mc.player.closeScreen();
                    stage = Stage.OPEN_STAND;
                }
            }
            case OPEN_STAND -> {
                if (isBrewingOpen()) {
                    stage = Stage.PLACE_BOTTLES;
                    return;
                }
                if (openTimer.isReached(600)) {
                    openStand();
                    openTimer.reset();
                }
            }
            case PLACE_BOTTLES -> {
                if (!ensureBrewingOpen()) return;
                BrewingStandContainer c = (BrewingStandContainer) mc.player.openContainer;
                for (int i = 0; i <= 2; i++) {
                    ItemStack cur = c.inventorySlots.get(i).getStack();
                    boolean isNonWaterPotion = !cur.isEmpty() && cur.getItem() == Items.POTION
                            && PotionUtils.getPotionFromItem(cur) != Potions.WATER;
                    boolean isOther = !cur.isEmpty() && cur.getItem() != Items.GLASS_BOTTLE
                            && cur.getItem() != Items.POTION;
                    if (isNonWaterPotion || isOther) {
                        mc.playerController.windowClick(c.windowId, i, 0, ClickType.QUICK_MOVE, mc.player);
                        return;
                    }
                    if (cur.isEmpty()) {
                        int cs = findBrewingSlot(Items.POTION, true);
                        if (cs == -1) cs = findBrewingSlot(Items.GLASS_BOTTLE, false);
                        if (cs != -1) {
                            mc.playerController.windowClick(c.windowId, cs, 0, ClickType.PICKUP, mc.player);
                            mc.playerController.windowClick(c.windowId, i, 1, ClickType.PICKUP, mc.player);
                            mc.playerController.windowClick(c.windowId, cs, 0, ClickType.PICKUP, mc.player);
                            return;
                        }
                    }
                }
                currentIngredientIndex = 0;
                ingredientPlaced = false;
                stage = Stage.BREWING;
            }
            case BREWING -> {
                if (!ensureBrewingOpen()) return;
                Item[] currentRecipe = getRecipe();
                if (currentIngredientIndex >= currentRecipe.length) {
                    stage = Stage.COLLECT;
                    return;
                }
                if (placeSingleIngredient(currentRecipe[currentIngredientIndex])) {
                    ingredientPlaced = true;
                    stage = Stage.WAITING;
                }
            }
            case WAITING -> {
                if (!ensureBrewingOpen()) return;
                if (isIngredientGone()) {
                    ingredientPlaced = false;
                    currentIngredientIndex++;
                    stage = Stage.BREWING;
                }
            }

            case COLLECT -> {
                if (!ensureBrewingOpen()) return;
                BrewingStandContainer c = (BrewingStandContainer) mc.player.openContainer;
                for (int i = 0; i <= 2; i++) {
                    if (!c.inventorySlots.get(i).getStack().isEmpty()) {
                        mc.playerController.windowClick(c.windowId, i, 0, ClickType.QUICK_MOVE, mc.player);
                        return;
                    }
                }
                if (usePotionChest.get()) {
                    mc.player.closeScreen();
                    stage = Stage.STORE_POTIONS_OPEN;
                } else {
                    stage = Stage.PLACE_BOTTLES;
                }
            }
            case STORE_POTIONS_OPEN -> {
                if (isChestOpen()) {
                    stage = Stage.STORE_POTIONS;
                    return;
                }
                if (openTimer.isReached(600)) {
                    openChest(getPotionChestPos());
                    openTimer.reset();
                }
            }
            case STORE_POTIONS -> {
                if (!isChestOpen()) { stage = Stage.STORE_POTIONS_OPEN; return; }
                ChestContainer c = (ChestContainer) mc.player.openContainer;
                int chestSlots = c.getNumRows() * 9;
                boolean stored = false;
                int totalSlots = c.inventorySlots.size();
                for (int i = chestSlots; i < totalSlots; i++) {
                    ItemStack stack = c.inventorySlots.get(i).getStack();
                    if (stack.isEmpty()) continue;
                    if (stack.getItem() == Items.POTION && PotionUtils.getPotionFromItem(stack) != Potions.WATER) {
                        mc.playerController.windowClick(c.windowId, i, 0, ClickType.QUICK_MOVE, mc.player);
                        stored = true;
                        break;
                    }
                }
                if (!stored) {
                    mc.player.closeScreen();
                    if (useBottleChest.get() && needBottles()) {
                        stage = Stage.TAKE_BOTTLES_OPEN;
                    } else if (useIngredientChest.get() && needIngredients()) {
                        stage = Stage.TAKE_INGREDIENTS_OPEN;
                    } else {
                        stage = Stage.OPEN_STAND;
                    }
                }
            }
        }
    }
    private boolean isIngredientGone() {
        if (!ingredientPlaced) return false;
        if (!(mc.player.openContainer instanceof BrewingStandContainer c)) return false;
        return c.inventorySlots.get(3).getStack().isEmpty();
    }

    private boolean placeSingleIngredient(Item item) {
        if (!(mc.player.openContainer instanceof BrewingStandContainer c)) return false;
        ItemStack cur = c.inventorySlots.get(3).getStack();
        if (!cur.isEmpty() && cur.getItem() == item) return true;
        if (!cur.isEmpty()) {
            mc.playerController.windowClick(c.windowId, 3, 0, ClickType.QUICK_MOVE, mc.player);
            return false;
        }
        int cs = findBrewingSlot(item, false);
        if (cs == -1) return false;
        mc.playerController.windowClick(c.windowId, cs, 0, ClickType.PICKUP, mc.player);
        mc.playerController.windowClick(c.windowId, 3, 1, ClickType.PICKUP, mc.player);
        mc.playerController.windowClick(c.windowId, cs, 0, ClickType.PICKUP, mc.player);
        return false;
    }

    private boolean ensureBrewingOpen() {
        if (isBrewingOpen()) return true;
        if (openTimer.isReached(600)) {
            openStand();
            openTimer.reset();
        }
        return false;
    }

    private void openStand() {
        if (standPos == null) return;
        BlockRayTraceResult rtr = new BlockRayTraceResult(
            Vector3d.copyCentered(standPos), Direction.UP, standPos, false);
        mc.playerController.processRightClickBlock(mc.player, mc.world, Hand.MAIN_HAND, rtr);
    }

    private void openChest(BlockPos pos) {
        if (pos == null) return;
        BlockRayTraceResult rtr = new BlockRayTraceResult(
            Vector3d.copyCentered(pos), Direction.UP, pos, false);
        mc.playerController.processRightClickBlock(mc.player, mc.world, Hand.MAIN_HAND, rtr);
    }

    private boolean isBrewingOpen() {
        return mc.currentScreen instanceof BrewingStandScreen
                && mc.player.openContainer instanceof BrewingStandContainer;
    }

    private boolean isChestOpen() {
        return mc.currentScreen instanceof ChestScreen
                && mc.player.openContainer instanceof ChestContainer;
    }

    private boolean needBottles() {
        int count = 0;
        for (int i = 0; i < 36; i++) {
            ItemStack s = mc.player.inventory.getStackInSlot(i);
            if (s.getItem() == Items.POTION && PotionUtils.getPotionFromItem(s) == Potions.WATER) {
                count += s.getCount();
            }
        }
        return count < 3;
    }

    private boolean needIngredients() {
        for (Item ingredient : getRecipe()) {
            if (!hasItemInInventory(ingredient)) return true;
        }
        return false;
    }

    private boolean hasItemInInventory(Item item) {
        for (int i = 0; i < 36; i++) {
            ItemStack s = mc.player.inventory.getStackInSlot(i);
            if (!s.isEmpty() && s.getItem() == item) return true;
        }
        return false;
    }

    private BlockPos getPotionChestPos() {
        return parsePos(potionChestX, potionChestY, potionChestZ);
    }

    private BlockPos getIngredientChestPos() {
        return parsePos(ingredientChestX, ingredientChestY, ingredientChestZ);
    }

    private BlockPos getBottleChestPos() {
        return parsePos(bottleChestX, bottleChestY, bottleChestZ);
    }

    private BlockPos parsePos(StringSetting x, StringSetting y, StringSetting z) {
        try {
            return new BlockPos(
                Integer.parseInt(x.get().trim()),
                Integer.parseInt(y.get().trim()),
                Integer.parseInt(z.get().trim())
            );
        } catch (NumberFormatException e) {
            return null;
        }
    }
    private int findBrewingSlot(Item item, boolean waterBottleOnly) {
        for (int i = 9; i < 36; i++) {
            ItemStack s = mc.player.inventory.getStackInSlot(i);
            if (s.isEmpty() || s.getItem() != item) continue;
            if (waterBottleOnly && s.getItem() == Items.POTION
                    && PotionUtils.getPotionFromItem(s) != Potions.WATER) continue;
            return (i - 9) + 5;
        }
        for (int i = 0; i < 9; i++) {
            ItemStack s = mc.player.inventory.getStackInSlot(i);
            if (s.isEmpty() || s.getItem() != item) continue;
            if (waterBottleOnly && s.getItem() == Items.POTION
                    && PotionUtils.getPotionFromItem(s) != Potions.WATER) continue;
            return i + 32;
        }
        return -1;
    }
}
 
Увидел что наш любимый @ConeTin сделал авто зелье варку и я взял идею и сделал вам и сливаю вам ⚠️ВНИМАНИЕ ВАЙПКОДИНГ ПРИСУТСТВУЕТ НАПИСАНО Claude Opus 4.7
Работает на всех серверах
Пожалуйста, авторизуйтесь для просмотра ссылки.

Код:
Expand Collapse Copy
package client.main.module.impl.misc;

import client.events.EventUpdate;
import client.main.module.api.Category;
import client.main.module.api.Module;
import client.main.module.api.ModuleRegister;
import client.main.module.settings.impl.BooleanSetting;
import client.main.module.settings.impl.ModeSetting;
import client.main.module.settings.impl.StringSetting;
import client.util.math.StopWatch;
import com.google.common.eventbus.Subscribe;
import net.minecraft.client.gui.screen.inventory.BrewingStandScreen;
import net.minecraft.client.gui.screen.inventory.ChestScreen;
import net.minecraft.inventory.container.BrewingStandContainer;
import net.minecraft.inventory.container.ChestContainer;
import net.minecraft.inventory.container.ClickType;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.potion.PotionUtils;
import net.minecraft.potion.Potions;
import net.minecraft.tileentity.BrewingStandTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.vector.Vector3d;

@ModuleRegister(name = "AutoPotion", type = Category.Misc, desc = "Automatically brews potions in Brewing Stand")
public class AutoPotion extends Module {
  
    private final ModeSetting recipe = new ModeSetting("Рецепт", "Невидимость", "Невидимость", "Сила 2", "Скорость 2");
    private final BooleanSetting usePotionChest = new BooleanSetting("Сундук зелий", false);
    private final StringSetting potionChestX = new StringSetting("Зелья X", "0", "X координата сундука зелий");
    private final StringSetting potionChestY = new StringSetting("Зелья Y", "0", "Y координата сундука зелий");
    private final StringSetting potionChestZ = new StringSetting("Зелья Z", "0", "Z координата сундука зелий");

    private final BooleanSetting useIngredientChest = new BooleanSetting("Сундук ингредиентов", false);
    private final StringSetting ingredientChestX = new StringSetting("Ингредиенты X", "0", "X координата сундука ингредиентов");
    private final StringSetting ingredientChestY = new StringSetting("Ингредиенты Y", "0", "Y координата сундука ингредиентов");
    private final StringSetting ingredientChestZ = new StringSetting("Ингредиенты Z", "0", "Z координата сундука ингредиентов");

    private final BooleanSetting useBottleChest = new BooleanSetting("Сундук бутылок", false);
    private final StringSetting bottleChestX = new StringSetting("Бутылки X", "0", "X координата сундука бутылок");
    private final StringSetting bottleChestY = new StringSetting("Бутылки Y", "0", "Y координата сундука бутылок");
    private final StringSetting bottleChestZ = new StringSetting("Бутылки Z", "0", "Z координата сундука бутылок");
    private static final Item[] RECIPE_INVISIBILITY = {
        Items.NETHER_WART,
        Items.GOLDEN_CARROT,
        Items.FERMENTED_SPIDER_EYE,
        Items.REDSTONE
    };
    private static final Item[] RECIPE_STRENGTH_2 = {
        Items.NETHER_WART,
        Items.BLAZE_POWDER,
        Items.GLOWSTONE_DUST
    };
    private static final Item[] RECIPE_SPEED_2 = {
        Items.NETHER_WART,
        Items.SUGAR,
        Items.GLOWSTONE_DUST
    };
    private enum Stage {
        FIND_STAND, OPEN_STAND,
        TAKE_BOTTLES_OPEN, TAKE_BOTTLES,
        TAKE_INGREDIENTS_OPEN, TAKE_INGREDIENTS,
        PLACE_BOTTLES,
        BREWING, WAITING,
        COLLECT,
        STORE_POTIONS_OPEN, STORE_POTIONS
    }

    private Stage stage = Stage.FIND_STAND;
    private BlockPos standPos = null;
    private final StopWatch timer = new StopWatch();
    private final StopWatch openTimer = new StopWatch();
    private boolean ingredientPlaced = false;
    private int currentIngredientIndex = 0;

    public AutoPotion() {
        addSettings(
            recipe,
            usePotionChest, potionChestX, potionChestY, potionChestZ,
            useIngredientChest, ingredientChestX, ingredientChestY, ingredientChestZ,
            useBottleChest, bottleChestX, bottleChestY, bottleChestZ
        );
        potionChestX.setVisible(usePotionChest::get);
        potionChestY.setVisible(usePotionChest::get);
        potionChestZ.setVisible(usePotionChest::get);
        ingredientChestX.setVisible(useIngredientChest::get);
        ingredientChestY.setVisible(useIngredientChest::get);
        ingredientChestZ.setVisible(useIngredientChest::get);
        bottleChestX.setVisible(useBottleChest::get);
        bottleChestY.setVisible(useBottleChest::get);
        bottleChestZ.setVisible(useBottleChest::get);
    }

    private Item[] getRecipe() {
        if (recipe.is("Сила 2")) return RECIPE_STRENGTH_2;
        if (recipe.is("Скорость 2")) return RECIPE_SPEED_2;
        return RECIPE_INVISIBILITY;
    }

    @Override
    public boolean onEnable() {
        stage = Stage.FIND_STAND;
        standPos = null;
        ingredientPlaced = false;
        currentIngredientIndex = 0;
        return super.onEnable();
    }

    @Override
    public boolean onDisable() {
        if (mc.player != null && mc.currentScreen != null) mc.player.closeScreen();
        stage = Stage.FIND_STAND;
        ingredientPlaced = false;
        currentIngredientIndex = 0;
        return super.onDisable();
    }

    @Subscribe
    public void onUpdate(EventUpdate e) {
        if (mc.player == null || mc.world == null) return;
        if (!timer.isReached(300)) return;
        timer.reset();

        switch (stage) {
            case FIND_STAND -> {
                for (BlockPos pos : BlockPos.getAllInBoxMutable(
                        mc.player.getPosition().add(-4, -2, -4),
                        mc.player.getPosition().add(4, 2, 4))) {
                    TileEntity te = mc.world.getTileEntity(pos);
                    if (te instanceof BrewingStandTileEntity) {
                        standPos = pos.toImmutable();
                        if (useBottleChest.get() && needBottles()) {
                            stage = Stage.TAKE_BOTTLES_OPEN;
                        } else if (useIngredientChest.get() && needIngredients()) {
                            stage = Stage.TAKE_INGREDIENTS_OPEN;
                        } else {
                            stage = Stage.OPEN_STAND;
                        }
                        return;
                    }
                }
            }
            case TAKE_BOTTLES_OPEN -> {
                if (isChestOpen()) {
                    stage = Stage.TAKE_BOTTLES;
                    return;
                }
                if (openTimer.isReached(600)) {
                    openChest(getBottleChestPos());
                    openTimer.reset();
                }
            }
            case TAKE_BOTTLES -> {
                if (!isChestOpen()) { stage = Stage.TAKE_BOTTLES_OPEN; return; }
                ChestContainer c = (ChestContainer) mc.player.openContainer;
                int chestSlots = c.getNumRows() * 9;
                boolean took = false;
                for (int i = 0; i < chestSlots; i++) {
                    ItemStack stack = c.inventorySlots.get(i).getStack();
                    if (stack.isEmpty()) continue;
                    if (stack.getItem() == Items.POTION && PotionUtils.getPotionFromItem(stack) == Potions.WATER) {
                        mc.playerController.windowClick(c.windowId, i, 0, ClickType.QUICK_MOVE, mc.player);
                        took = true;
                        break;
                    }
                }
                if (!took || !needBottles()) {
                    mc.player.closeScreen();
                    if (useIngredientChest.get() && needIngredients()) {
                        stage = Stage.TAKE_INGREDIENTS_OPEN;
                    } else {
                        stage = Stage.OPEN_STAND;
                    }
                }
            }
            case TAKE_INGREDIENTS_OPEN -> {
                if (isChestOpen()) {
                    stage = Stage.TAKE_INGREDIENTS;
                    return;
                }
                if (openTimer.isReached(600)) {
                    openChest(getIngredientChestPos());
                    openTimer.reset();
                }
            }
            case TAKE_INGREDIENTS -> {
                if (!isChestOpen()) { stage = Stage.TAKE_INGREDIENTS_OPEN; return; }
                ChestContainer c = (ChestContainer) mc.player.openContainer;
                int chestSlots = c.getNumRows() * 9;
                boolean took = false;
                for (Item ingredient : getRecipe()) {
                    if (hasItemInInventory(ingredient)) continue;
                    for (int i = 0; i < chestSlots; i++) {
                        ItemStack stack = c.inventorySlots.get(i).getStack();
                        if (!stack.isEmpty() && stack.getItem() == ingredient) {
                            mc.playerController.windowClick(c.windowId, i, 0, ClickType.QUICK_MOVE, mc.player);
                            took = true;
                            break;
                        }
                    }
                    if (took) break;
                }
                if (!took || !needIngredients()) {
                    mc.player.closeScreen();
                    stage = Stage.OPEN_STAND;
                }
            }
            case OPEN_STAND -> {
                if (isBrewingOpen()) {
                    stage = Stage.PLACE_BOTTLES;
                    return;
                }
                if (openTimer.isReached(600)) {
                    openStand();
                    openTimer.reset();
                }
            }
            case PLACE_BOTTLES -> {
                if (!ensureBrewingOpen()) return;
                BrewingStandContainer c = (BrewingStandContainer) mc.player.openContainer;
                for (int i = 0; i <= 2; i++) {
                    ItemStack cur = c.inventorySlots.get(i).getStack();
                    boolean isNonWaterPotion = !cur.isEmpty() && cur.getItem() == Items.POTION
                            && PotionUtils.getPotionFromItem(cur) != Potions.WATER;
                    boolean isOther = !cur.isEmpty() && cur.getItem() != Items.GLASS_BOTTLE
                            && cur.getItem() != Items.POTION;
                    if (isNonWaterPotion || isOther) {
                        mc.playerController.windowClick(c.windowId, i, 0, ClickType.QUICK_MOVE, mc.player);
                        return;
                    }
                    if (cur.isEmpty()) {
                        int cs = findBrewingSlot(Items.POTION, true);
                        if (cs == -1) cs = findBrewingSlot(Items.GLASS_BOTTLE, false);
                        if (cs != -1) {
                            mc.playerController.windowClick(c.windowId, cs, 0, ClickType.PICKUP, mc.player);
                            mc.playerController.windowClick(c.windowId, i, 1, ClickType.PICKUP, mc.player);
                            mc.playerController.windowClick(c.windowId, cs, 0, ClickType.PICKUP, mc.player);
                            return;
                        }
                    }
                }
                currentIngredientIndex = 0;
                ingredientPlaced = false;
                stage = Stage.BREWING;
            }
            case BREWING -> {
                if (!ensureBrewingOpen()) return;
                Item[] currentRecipe = getRecipe();
                if (currentIngredientIndex >= currentRecipe.length) {
                    stage = Stage.COLLECT;
                    return;
                }
                if (placeSingleIngredient(currentRecipe[currentIngredientIndex])) {
                    ingredientPlaced = true;
                    stage = Stage.WAITING;
                }
            }
            case WAITING -> {
                if (!ensureBrewingOpen()) return;
                if (isIngredientGone()) {
                    ingredientPlaced = false;
                    currentIngredientIndex++;
                    stage = Stage.BREWING;
                }
            }

            case COLLECT -> {
                if (!ensureBrewingOpen()) return;
                BrewingStandContainer c = (BrewingStandContainer) mc.player.openContainer;
                for (int i = 0; i <= 2; i++) {
                    if (!c.inventorySlots.get(i).getStack().isEmpty()) {
                        mc.playerController.windowClick(c.windowId, i, 0, ClickType.QUICK_MOVE, mc.player);
                        return;
                    }
                }
                if (usePotionChest.get()) {
                    mc.player.closeScreen();
                    stage = Stage.STORE_POTIONS_OPEN;
                } else {
                    stage = Stage.PLACE_BOTTLES;
                }
            }
            case STORE_POTIONS_OPEN -> {
                if (isChestOpen()) {
                    stage = Stage.STORE_POTIONS;
                    return;
                }
                if (openTimer.isReached(600)) {
                    openChest(getPotionChestPos());
                    openTimer.reset();
                }
            }
            case STORE_POTIONS -> {
                if (!isChestOpen()) { stage = Stage.STORE_POTIONS_OPEN; return; }
                ChestContainer c = (ChestContainer) mc.player.openContainer;
                int chestSlots = c.getNumRows() * 9;
                boolean stored = false;
                int totalSlots = c.inventorySlots.size();
                for (int i = chestSlots; i < totalSlots; i++) {
                    ItemStack stack = c.inventorySlots.get(i).getStack();
                    if (stack.isEmpty()) continue;
                    if (stack.getItem() == Items.POTION && PotionUtils.getPotionFromItem(stack) != Potions.WATER) {
                        mc.playerController.windowClick(c.windowId, i, 0, ClickType.QUICK_MOVE, mc.player);
                        stored = true;
                        break;
                    }
                }
                if (!stored) {
                    mc.player.closeScreen();
                    if (useBottleChest.get() && needBottles()) {
                        stage = Stage.TAKE_BOTTLES_OPEN;
                    } else if (useIngredientChest.get() && needIngredients()) {
                        stage = Stage.TAKE_INGREDIENTS_OPEN;
                    } else {
                        stage = Stage.OPEN_STAND;
                    }
                }
            }
        }
    }
    private boolean isIngredientGone() {
        if (!ingredientPlaced) return false;
        if (!(mc.player.openContainer instanceof BrewingStandContainer c)) return false;
        return c.inventorySlots.get(3).getStack().isEmpty();
    }

    private boolean placeSingleIngredient(Item item) {
        if (!(mc.player.openContainer instanceof BrewingStandContainer c)) return false;
        ItemStack cur = c.inventorySlots.get(3).getStack();
        if (!cur.isEmpty() && cur.getItem() == item) return true;
        if (!cur.isEmpty()) {
            mc.playerController.windowClick(c.windowId, 3, 0, ClickType.QUICK_MOVE, mc.player);
            return false;
        }
        int cs = findBrewingSlot(item, false);
        if (cs == -1) return false;
        mc.playerController.windowClick(c.windowId, cs, 0, ClickType.PICKUP, mc.player);
        mc.playerController.windowClick(c.windowId, 3, 1, ClickType.PICKUP, mc.player);
        mc.playerController.windowClick(c.windowId, cs, 0, ClickType.PICKUP, mc.player);
        return false;
    }

    private boolean ensureBrewingOpen() {
        if (isBrewingOpen()) return true;
        if (openTimer.isReached(600)) {
            openStand();
            openTimer.reset();
        }
        return false;
    }

    private void openStand() {
        if (standPos == null) return;
        BlockRayTraceResult rtr = new BlockRayTraceResult(
            Vector3d.copyCentered(standPos), Direction.UP, standPos, false);
        mc.playerController.processRightClickBlock(mc.player, mc.world, Hand.MAIN_HAND, rtr);
    }

    private void openChest(BlockPos pos) {
        if (pos == null) return;
        BlockRayTraceResult rtr = new BlockRayTraceResult(
            Vector3d.copyCentered(pos), Direction.UP, pos, false);
        mc.playerController.processRightClickBlock(mc.player, mc.world, Hand.MAIN_HAND, rtr);
    }

    private boolean isBrewingOpen() {
        return mc.currentScreen instanceof BrewingStandScreen
                && mc.player.openContainer instanceof BrewingStandContainer;
    }

    private boolean isChestOpen() {
        return mc.currentScreen instanceof ChestScreen
                && mc.player.openContainer instanceof ChestContainer;
    }

    private boolean needBottles() {
        int count = 0;
        for (int i = 0; i < 36; i++) {
            ItemStack s = mc.player.inventory.getStackInSlot(i);
            if (s.getItem() == Items.POTION && PotionUtils.getPotionFromItem(s) == Potions.WATER) {
                count += s.getCount();
            }
        }
        return count < 3;
    }

    private boolean needIngredients() {
        for (Item ingredient : getRecipe()) {
            if (!hasItemInInventory(ingredient)) return true;
        }
        return false;
    }

    private boolean hasItemInInventory(Item item) {
        for (int i = 0; i < 36; i++) {
            ItemStack s = mc.player.inventory.getStackInSlot(i);
            if (!s.isEmpty() && s.getItem() == item) return true;
        }
        return false;
    }

    private BlockPos getPotionChestPos() {
        return parsePos(potionChestX, potionChestY, potionChestZ);
    }

    private BlockPos getIngredientChestPos() {
        return parsePos(ingredientChestX, ingredientChestY, ingredientChestZ);
    }

    private BlockPos getBottleChestPos() {
        return parsePos(bottleChestX, bottleChestY, bottleChestZ);
    }

    private BlockPos parsePos(StringSetting x, StringSetting y, StringSetting z) {
        try {
            return new BlockPos(
                Integer.parseInt(x.get().trim()),
                Integer.parseInt(y.get().trim()),
                Integer.parseInt(z.get().trim())
            );
        } catch (NumberFormatException e) {
            return null;
        }
    }
    private int findBrewingSlot(Item item, boolean waterBottleOnly) {
        for (int i = 9; i < 36; i++) {
            ItemStack s = mc.player.inventory.getStackInSlot(i);
            if (s.isEmpty() || s.getItem() != item) continue;
            if (waterBottleOnly && s.getItem() == Items.POTION
                    && PotionUtils.getPotionFromItem(s) != Potions.WATER) continue;
            return (i - 9) + 5;
        }
        for (int i = 0; i < 9; i++) {
            ItemStack s = mc.player.inventory.getStackInSlot(i);
            if (s.isEmpty() || s.getItem() != item) continue;
            if (waterBottleOnly && s.getItem() == Items.POTION
                    && PotionUtils.getPotionFromItem(s) != Potions.WATER) continue;
            return i + 32;
        }
        return -1;
    }
}
ускорить и кайф
 
Увидел что наш любимый @ConeTin сделал авто зелье варку и я взял идею и сделал вам и сливаю вам ⚠️ВНИМАНИЕ ВАЙПКОДИНГ ПРИСУТСТВУЕТ НАПИСАНО Claude Opus 4.7
Работает на всех серверах
Пожалуйста, авторизуйтесь для просмотра ссылки.

Код:
Expand Collapse Copy
package client.main.module.impl.misc;

import client.events.EventUpdate;
import client.main.module.api.Category;
import client.main.module.api.Module;
import client.main.module.api.ModuleRegister;
import client.main.module.settings.impl.BooleanSetting;
import client.main.module.settings.impl.ModeSetting;
import client.main.module.settings.impl.StringSetting;
import client.util.math.StopWatch;
import com.google.common.eventbus.Subscribe;
import net.minecraft.client.gui.screen.inventory.BrewingStandScreen;
import net.minecraft.client.gui.screen.inventory.ChestScreen;
import net.minecraft.inventory.container.BrewingStandContainer;
import net.minecraft.inventory.container.ChestContainer;
import net.minecraft.inventory.container.ClickType;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.potion.PotionUtils;
import net.minecraft.potion.Potions;
import net.minecraft.tileentity.BrewingStandTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.vector.Vector3d;

@ModuleRegister(name = "AutoPotion", type = Category.Misc, desc = "Automatically brews potions in Brewing Stand")
public class AutoPotion extends Module {
  
    private final ModeSetting recipe = new ModeSetting("Рецепт", "Невидимость", "Невидимость", "Сила 2", "Скорость 2");
    private final BooleanSetting usePotionChest = new BooleanSetting("Сундук зелий", false);
    private final StringSetting potionChestX = new StringSetting("Зелья X", "0", "X координата сундука зелий");
    private final StringSetting potionChestY = new StringSetting("Зелья Y", "0", "Y координата сундука зелий");
    private final StringSetting potionChestZ = new StringSetting("Зелья Z", "0", "Z координата сундука зелий");

    private final BooleanSetting useIngredientChest = new BooleanSetting("Сундук ингредиентов", false);
    private final StringSetting ingredientChestX = new StringSetting("Ингредиенты X", "0", "X координата сундука ингредиентов");
    private final StringSetting ingredientChestY = new StringSetting("Ингредиенты Y", "0", "Y координата сундука ингредиентов");
    private final StringSetting ingredientChestZ = new StringSetting("Ингредиенты Z", "0", "Z координата сундука ингредиентов");

    private final BooleanSetting useBottleChest = new BooleanSetting("Сундук бутылок", false);
    private final StringSetting bottleChestX = new StringSetting("Бутылки X", "0", "X координата сундука бутылок");
    private final StringSetting bottleChestY = new StringSetting("Бутылки Y", "0", "Y координата сундука бутылок");
    private final StringSetting bottleChestZ = new StringSetting("Бутылки Z", "0", "Z координата сундука бутылок");
    private static final Item[] RECIPE_INVISIBILITY = {
        Items.NETHER_WART,
        Items.GOLDEN_CARROT,
        Items.FERMENTED_SPIDER_EYE,
        Items.REDSTONE
    };
    private static final Item[] RECIPE_STRENGTH_2 = {
        Items.NETHER_WART,
        Items.BLAZE_POWDER,
        Items.GLOWSTONE_DUST
    };
    private static final Item[] RECIPE_SPEED_2 = {
        Items.NETHER_WART,
        Items.SUGAR,
        Items.GLOWSTONE_DUST
    };
    private enum Stage {
        FIND_STAND, OPEN_STAND,
        TAKE_BOTTLES_OPEN, TAKE_BOTTLES,
        TAKE_INGREDIENTS_OPEN, TAKE_INGREDIENTS,
        PLACE_BOTTLES,
        BREWING, WAITING,
        COLLECT,
        STORE_POTIONS_OPEN, STORE_POTIONS
    }

    private Stage stage = Stage.FIND_STAND;
    private BlockPos standPos = null;
    private final StopWatch timer = new StopWatch();
    private final StopWatch openTimer = new StopWatch();
    private boolean ingredientPlaced = false;
    private int currentIngredientIndex = 0;

    public AutoPotion() {
        addSettings(
            recipe,
            usePotionChest, potionChestX, potionChestY, potionChestZ,
            useIngredientChest, ingredientChestX, ingredientChestY, ingredientChestZ,
            useBottleChest, bottleChestX, bottleChestY, bottleChestZ
        );
        potionChestX.setVisible(usePotionChest::get);
        potionChestY.setVisible(usePotionChest::get);
        potionChestZ.setVisible(usePotionChest::get);
        ingredientChestX.setVisible(useIngredientChest::get);
        ingredientChestY.setVisible(useIngredientChest::get);
        ingredientChestZ.setVisible(useIngredientChest::get);
        bottleChestX.setVisible(useBottleChest::get);
        bottleChestY.setVisible(useBottleChest::get);
        bottleChestZ.setVisible(useBottleChest::get);
    }

    private Item[] getRecipe() {
        if (recipe.is("Сила 2")) return RECIPE_STRENGTH_2;
        if (recipe.is("Скорость 2")) return RECIPE_SPEED_2;
        return RECIPE_INVISIBILITY;
    }

    @Override
    public boolean onEnable() {
        stage = Stage.FIND_STAND;
        standPos = null;
        ingredientPlaced = false;
        currentIngredientIndex = 0;
        return super.onEnable();
    }

    @Override
    public boolean onDisable() {
        if (mc.player != null && mc.currentScreen != null) mc.player.closeScreen();
        stage = Stage.FIND_STAND;
        ingredientPlaced = false;
        currentIngredientIndex = 0;
        return super.onDisable();
    }

    @Subscribe
    public void onUpdate(EventUpdate e) {
        if (mc.player == null || mc.world == null) return;
        if (!timer.isReached(300)) return;
        timer.reset();

        switch (stage) {
            case FIND_STAND -> {
                for (BlockPos pos : BlockPos.getAllInBoxMutable(
                        mc.player.getPosition().add(-4, -2, -4),
                        mc.player.getPosition().add(4, 2, 4))) {
                    TileEntity te = mc.world.getTileEntity(pos);
                    if (te instanceof BrewingStandTileEntity) {
                        standPos = pos.toImmutable();
                        if (useBottleChest.get() && needBottles()) {
                            stage = Stage.TAKE_BOTTLES_OPEN;
                        } else if (useIngredientChest.get() && needIngredients()) {
                            stage = Stage.TAKE_INGREDIENTS_OPEN;
                        } else {
                            stage = Stage.OPEN_STAND;
                        }
                        return;
                    }
                }
            }
            case TAKE_BOTTLES_OPEN -> {
                if (isChestOpen()) {
                    stage = Stage.TAKE_BOTTLES;
                    return;
                }
                if (openTimer.isReached(600)) {
                    openChest(getBottleChestPos());
                    openTimer.reset();
                }
            }
            case TAKE_BOTTLES -> {
                if (!isChestOpen()) { stage = Stage.TAKE_BOTTLES_OPEN; return; }
                ChestContainer c = (ChestContainer) mc.player.openContainer;
                int chestSlots = c.getNumRows() * 9;
                boolean took = false;
                for (int i = 0; i < chestSlots; i++) {
                    ItemStack stack = c.inventorySlots.get(i).getStack();
                    if (stack.isEmpty()) continue;
                    if (stack.getItem() == Items.POTION && PotionUtils.getPotionFromItem(stack) == Potions.WATER) {
                        mc.playerController.windowClick(c.windowId, i, 0, ClickType.QUICK_MOVE, mc.player);
                        took = true;
                        break;
                    }
                }
                if (!took || !needBottles()) {
                    mc.player.closeScreen();
                    if (useIngredientChest.get() && needIngredients()) {
                        stage = Stage.TAKE_INGREDIENTS_OPEN;
                    } else {
                        stage = Stage.OPEN_STAND;
                    }
                }
            }
            case TAKE_INGREDIENTS_OPEN -> {
                if (isChestOpen()) {
                    stage = Stage.TAKE_INGREDIENTS;
                    return;
                }
                if (openTimer.isReached(600)) {
                    openChest(getIngredientChestPos());
                    openTimer.reset();
                }
            }
            case TAKE_INGREDIENTS -> {
                if (!isChestOpen()) { stage = Stage.TAKE_INGREDIENTS_OPEN; return; }
                ChestContainer c = (ChestContainer) mc.player.openContainer;
                int chestSlots = c.getNumRows() * 9;
                boolean took = false;
                for (Item ingredient : getRecipe()) {
                    if (hasItemInInventory(ingredient)) continue;
                    for (int i = 0; i < chestSlots; i++) {
                        ItemStack stack = c.inventorySlots.get(i).getStack();
                        if (!stack.isEmpty() && stack.getItem() == ingredient) {
                            mc.playerController.windowClick(c.windowId, i, 0, ClickType.QUICK_MOVE, mc.player);
                            took = true;
                            break;
                        }
                    }
                    if (took) break;
                }
                if (!took || !needIngredients()) {
                    mc.player.closeScreen();
                    stage = Stage.OPEN_STAND;
                }
            }
            case OPEN_STAND -> {
                if (isBrewingOpen()) {
                    stage = Stage.PLACE_BOTTLES;
                    return;
                }
                if (openTimer.isReached(600)) {
                    openStand();
                    openTimer.reset();
                }
            }
            case PLACE_BOTTLES -> {
                if (!ensureBrewingOpen()) return;
                BrewingStandContainer c = (BrewingStandContainer) mc.player.openContainer;
                for (int i = 0; i <= 2; i++) {
                    ItemStack cur = c.inventorySlots.get(i).getStack();
                    boolean isNonWaterPotion = !cur.isEmpty() && cur.getItem() == Items.POTION
                            && PotionUtils.getPotionFromItem(cur) != Potions.WATER;
                    boolean isOther = !cur.isEmpty() && cur.getItem() != Items.GLASS_BOTTLE
                            && cur.getItem() != Items.POTION;
                    if (isNonWaterPotion || isOther) {
                        mc.playerController.windowClick(c.windowId, i, 0, ClickType.QUICK_MOVE, mc.player);
                        return;
                    }
                    if (cur.isEmpty()) {
                        int cs = findBrewingSlot(Items.POTION, true);
                        if (cs == -1) cs = findBrewingSlot(Items.GLASS_BOTTLE, false);
                        if (cs != -1) {
                            mc.playerController.windowClick(c.windowId, cs, 0, ClickType.PICKUP, mc.player);
                            mc.playerController.windowClick(c.windowId, i, 1, ClickType.PICKUP, mc.player);
                            mc.playerController.windowClick(c.windowId, cs, 0, ClickType.PICKUP, mc.player);
                            return;
                        }
                    }
                }
                currentIngredientIndex = 0;
                ingredientPlaced = false;
                stage = Stage.BREWING;
            }
            case BREWING -> {
                if (!ensureBrewingOpen()) return;
                Item[] currentRecipe = getRecipe();
                if (currentIngredientIndex >= currentRecipe.length) {
                    stage = Stage.COLLECT;
                    return;
                }
                if (placeSingleIngredient(currentRecipe[currentIngredientIndex])) {
                    ingredientPlaced = true;
                    stage = Stage.WAITING;
                }
            }
            case WAITING -> {
                if (!ensureBrewingOpen()) return;
                if (isIngredientGone()) {
                    ingredientPlaced = false;
                    currentIngredientIndex++;
                    stage = Stage.BREWING;
                }
            }

            case COLLECT -> {
                if (!ensureBrewingOpen()) return;
                BrewingStandContainer c = (BrewingStandContainer) mc.player.openContainer;
                for (int i = 0; i <= 2; i++) {
                    if (!c.inventorySlots.get(i).getStack().isEmpty()) {
                        mc.playerController.windowClick(c.windowId, i, 0, ClickType.QUICK_MOVE, mc.player);
                        return;
                    }
                }
                if (usePotionChest.get()) {
                    mc.player.closeScreen();
                    stage = Stage.STORE_POTIONS_OPEN;
                } else {
                    stage = Stage.PLACE_BOTTLES;
                }
            }
            case STORE_POTIONS_OPEN -> {
                if (isChestOpen()) {
                    stage = Stage.STORE_POTIONS;
                    return;
                }
                if (openTimer.isReached(600)) {
                    openChest(getPotionChestPos());
                    openTimer.reset();
                }
            }
            case STORE_POTIONS -> {
                if (!isChestOpen()) { stage = Stage.STORE_POTIONS_OPEN; return; }
                ChestContainer c = (ChestContainer) mc.player.openContainer;
                int chestSlots = c.getNumRows() * 9;
                boolean stored = false;
                int totalSlots = c.inventorySlots.size();
                for (int i = chestSlots; i < totalSlots; i++) {
                    ItemStack stack = c.inventorySlots.get(i).getStack();
                    if (stack.isEmpty()) continue;
                    if (stack.getItem() == Items.POTION && PotionUtils.getPotionFromItem(stack) != Potions.WATER) {
                        mc.playerController.windowClick(c.windowId, i, 0, ClickType.QUICK_MOVE, mc.player);
                        stored = true;
                        break;
                    }
                }
                if (!stored) {
                    mc.player.closeScreen();
                    if (useBottleChest.get() && needBottles()) {
                        stage = Stage.TAKE_BOTTLES_OPEN;
                    } else if (useIngredientChest.get() && needIngredients()) {
                        stage = Stage.TAKE_INGREDIENTS_OPEN;
                    } else {
                        stage = Stage.OPEN_STAND;
                    }
                }
            }
        }
    }
    private boolean isIngredientGone() {
        if (!ingredientPlaced) return false;
        if (!(mc.player.openContainer instanceof BrewingStandContainer c)) return false;
        return c.inventorySlots.get(3).getStack().isEmpty();
    }

    private boolean placeSingleIngredient(Item item) {
        if (!(mc.player.openContainer instanceof BrewingStandContainer c)) return false;
        ItemStack cur = c.inventorySlots.get(3).getStack();
        if (!cur.isEmpty() && cur.getItem() == item) return true;
        if (!cur.isEmpty()) {
            mc.playerController.windowClick(c.windowId, 3, 0, ClickType.QUICK_MOVE, mc.player);
            return false;
        }
        int cs = findBrewingSlot(item, false);
        if (cs == -1) return false;
        mc.playerController.windowClick(c.windowId, cs, 0, ClickType.PICKUP, mc.player);
        mc.playerController.windowClick(c.windowId, 3, 1, ClickType.PICKUP, mc.player);
        mc.playerController.windowClick(c.windowId, cs, 0, ClickType.PICKUP, mc.player);
        return false;
    }

    private boolean ensureBrewingOpen() {
        if (isBrewingOpen()) return true;
        if (openTimer.isReached(600)) {
            openStand();
            openTimer.reset();
        }
        return false;
    }

    private void openStand() {
        if (standPos == null) return;
        BlockRayTraceResult rtr = new BlockRayTraceResult(
            Vector3d.copyCentered(standPos), Direction.UP, standPos, false);
        mc.playerController.processRightClickBlock(mc.player, mc.world, Hand.MAIN_HAND, rtr);
    }

    private void openChest(BlockPos pos) {
        if (pos == null) return;
        BlockRayTraceResult rtr = new BlockRayTraceResult(
            Vector3d.copyCentered(pos), Direction.UP, pos, false);
        mc.playerController.processRightClickBlock(mc.player, mc.world, Hand.MAIN_HAND, rtr);
    }

    private boolean isBrewingOpen() {
        return mc.currentScreen instanceof BrewingStandScreen
                && mc.player.openContainer instanceof BrewingStandContainer;
    }

    private boolean isChestOpen() {
        return mc.currentScreen instanceof ChestScreen
                && mc.player.openContainer instanceof ChestContainer;
    }

    private boolean needBottles() {
        int count = 0;
        for (int i = 0; i < 36; i++) {
            ItemStack s = mc.player.inventory.getStackInSlot(i);
            if (s.getItem() == Items.POTION && PotionUtils.getPotionFromItem(s) == Potions.WATER) {
                count += s.getCount();
            }
        }
        return count < 3;
    }

    private boolean needIngredients() {
        for (Item ingredient : getRecipe()) {
            if (!hasItemInInventory(ingredient)) return true;
        }
        return false;
    }

    private boolean hasItemInInventory(Item item) {
        for (int i = 0; i < 36; i++) {
            ItemStack s = mc.player.inventory.getStackInSlot(i);
            if (!s.isEmpty() && s.getItem() == item) return true;
        }
        return false;
    }

    private BlockPos getPotionChestPos() {
        return parsePos(potionChestX, potionChestY, potionChestZ);
    }

    private BlockPos getIngredientChestPos() {
        return parsePos(ingredientChestX, ingredientChestY, ingredientChestZ);
    }

    private BlockPos getBottleChestPos() {
        return parsePos(bottleChestX, bottleChestY, bottleChestZ);
    }

    private BlockPos parsePos(StringSetting x, StringSetting y, StringSetting z) {
        try {
            return new BlockPos(
                Integer.parseInt(x.get().trim()),
                Integer.parseInt(y.get().trim()),
                Integer.parseInt(z.get().trim())
            );
        } catch (NumberFormatException e) {
            return null;
        }
    }
    private int findBrewingSlot(Item item, boolean waterBottleOnly) {
        for (int i = 9; i < 36; i++) {
            ItemStack s = mc.player.inventory.getStackInSlot(i);
            if (s.isEmpty() || s.getItem() != item) continue;
            if (waterBottleOnly && s.getItem() == Items.POTION
                    && PotionUtils.getPotionFromItem(s) != Potions.WATER) continue;
            return (i - 9) + 5;
        }
        for (int i = 0; i < 9; i++) {
            ItemStack s = mc.player.inventory.getStackInSlot(i);
            if (s.isEmpty() || s.getItem() != item) continue;
            if (waterBottleOnly && s.getItem() == Items.POTION
                    && PotionUtils.getPotionFromItem(s) != Potions.WATER) continue;
            return i + 32;
        }
        return -1;
    }
}
по координатам ты че ебанулся?)
 
Увидел что наш любимый @ConeTin сделал авто зелье варку и я взял идею и сделал вам и сливаю вам ⚠️ВНИМАНИЕ ВАЙПКОДИНГ ПРИСУТСТВУЕТ НАПИСАНО Claude Opus 4.7
Работает на всех серверах
Пожалуйста, авторизуйтесь для просмотра ссылки.

Код:
Expand Collapse Copy
package client.main.module.impl.misc;

import client.events.EventUpdate;
import client.main.module.api.Category;
import client.main.module.api.Module;
import client.main.module.api.ModuleRegister;
import client.main.module.settings.impl.BooleanSetting;
import client.main.module.settings.impl.ModeSetting;
import client.main.module.settings.impl.StringSetting;
import client.util.math.StopWatch;
import com.google.common.eventbus.Subscribe;
import net.minecraft.client.gui.screen.inventory.BrewingStandScreen;
import net.minecraft.client.gui.screen.inventory.ChestScreen;
import net.minecraft.inventory.container.BrewingStandContainer;
import net.minecraft.inventory.container.ChestContainer;
import net.minecraft.inventory.container.ClickType;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.potion.PotionUtils;
import net.minecraft.potion.Potions;
import net.minecraft.tileentity.BrewingStandTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.vector.Vector3d;

@ModuleRegister(name = "AutoPotion", type = Category.Misc, desc = "Automatically brews potions in Brewing Stand")
public class AutoPotion extends Module {
  
    private final ModeSetting recipe = new ModeSetting("Рецепт", "Невидимость", "Невидимость", "Сила 2", "Скорость 2");
    private final BooleanSetting usePotionChest = new BooleanSetting("Сундук зелий", false);
    private final StringSetting potionChestX = new StringSetting("Зелья X", "0", "X координата сундука зелий");
    private final StringSetting potionChestY = new StringSetting("Зелья Y", "0", "Y координата сундука зелий");
    private final StringSetting potionChestZ = new StringSetting("Зелья Z", "0", "Z координата сундука зелий");

    private final BooleanSetting useIngredientChest = new BooleanSetting("Сундук ингредиентов", false);
    private final StringSetting ingredientChestX = new StringSetting("Ингредиенты X", "0", "X координата сундука ингредиентов");
    private final StringSetting ingredientChestY = new StringSetting("Ингредиенты Y", "0", "Y координата сундука ингредиентов");
    private final StringSetting ingredientChestZ = new StringSetting("Ингредиенты Z", "0", "Z координата сундука ингредиентов");

    private final BooleanSetting useBottleChest = new BooleanSetting("Сундук бутылок", false);
    private final StringSetting bottleChestX = new StringSetting("Бутылки X", "0", "X координата сундука бутылок");
    private final StringSetting bottleChestY = new StringSetting("Бутылки Y", "0", "Y координата сундука бутылок");
    private final StringSetting bottleChestZ = new StringSetting("Бутылки Z", "0", "Z координата сундука бутылок");
    private static final Item[] RECIPE_INVISIBILITY = {
        Items.NETHER_WART,
        Items.GOLDEN_CARROT,
        Items.FERMENTED_SPIDER_EYE,
        Items.REDSTONE
    };
    private static final Item[] RECIPE_STRENGTH_2 = {
        Items.NETHER_WART,
        Items.BLAZE_POWDER,
        Items.GLOWSTONE_DUST
    };
    private static final Item[] RECIPE_SPEED_2 = {
        Items.NETHER_WART,
        Items.SUGAR,
        Items.GLOWSTONE_DUST
    };
    private enum Stage {
        FIND_STAND, OPEN_STAND,
        TAKE_BOTTLES_OPEN, TAKE_BOTTLES,
        TAKE_INGREDIENTS_OPEN, TAKE_INGREDIENTS,
        PLACE_BOTTLES,
        BREWING, WAITING,
        COLLECT,
        STORE_POTIONS_OPEN, STORE_POTIONS
    }

    private Stage stage = Stage.FIND_STAND;
    private BlockPos standPos = null;
    private final StopWatch timer = new StopWatch();
    private final StopWatch openTimer = new StopWatch();
    private boolean ingredientPlaced = false;
    private int currentIngredientIndex = 0;

    public AutoPotion() {
        addSettings(
            recipe,
            usePotionChest, potionChestX, potionChestY, potionChestZ,
            useIngredientChest, ingredientChestX, ingredientChestY, ingredientChestZ,
            useBottleChest, bottleChestX, bottleChestY, bottleChestZ
        );
        potionChestX.setVisible(usePotionChest::get);
        potionChestY.setVisible(usePotionChest::get);
        potionChestZ.setVisible(usePotionChest::get);
        ingredientChestX.setVisible(useIngredientChest::get);
        ingredientChestY.setVisible(useIngredientChest::get);
        ingredientChestZ.setVisible(useIngredientChest::get);
        bottleChestX.setVisible(useBottleChest::get);
        bottleChestY.setVisible(useBottleChest::get);
        bottleChestZ.setVisible(useBottleChest::get);
    }

    private Item[] getRecipe() {
        if (recipe.is("Сила 2")) return RECIPE_STRENGTH_2;
        if (recipe.is("Скорость 2")) return RECIPE_SPEED_2;
        return RECIPE_INVISIBILITY;
    }

    @Override
    public boolean onEnable() {
        stage = Stage.FIND_STAND;
        standPos = null;
        ingredientPlaced = false;
        currentIngredientIndex = 0;
        return super.onEnable();
    }

    @Override
    public boolean onDisable() {
        if (mc.player != null && mc.currentScreen != null) mc.player.closeScreen();
        stage = Stage.FIND_STAND;
        ingredientPlaced = false;
        currentIngredientIndex = 0;
        return super.onDisable();
    }

    @Subscribe
    public void onUpdate(EventUpdate e) {
        if (mc.player == null || mc.world == null) return;
        if (!timer.isReached(300)) return;
        timer.reset();

        switch (stage) {
            case FIND_STAND -> {
                for (BlockPos pos : BlockPos.getAllInBoxMutable(
                        mc.player.getPosition().add(-4, -2, -4),
                        mc.player.getPosition().add(4, 2, 4))) {
                    TileEntity te = mc.world.getTileEntity(pos);
                    if (te instanceof BrewingStandTileEntity) {
                        standPos = pos.toImmutable();
                        if (useBottleChest.get() && needBottles()) {
                            stage = Stage.TAKE_BOTTLES_OPEN;
                        } else if (useIngredientChest.get() && needIngredients()) {
                            stage = Stage.TAKE_INGREDIENTS_OPEN;
                        } else {
                            stage = Stage.OPEN_STAND;
                        }
                        return;
                    }
                }
            }
            case TAKE_BOTTLES_OPEN -> {
                if (isChestOpen()) {
                    stage = Stage.TAKE_BOTTLES;
                    return;
                }
                if (openTimer.isReached(600)) {
                    openChest(getBottleChestPos());
                    openTimer.reset();
                }
            }
            case TAKE_BOTTLES -> {
                if (!isChestOpen()) { stage = Stage.TAKE_BOTTLES_OPEN; return; }
                ChestContainer c = (ChestContainer) mc.player.openContainer;
                int chestSlots = c.getNumRows() * 9;
                boolean took = false;
                for (int i = 0; i < chestSlots; i++) {
                    ItemStack stack = c.inventorySlots.get(i).getStack();
                    if (stack.isEmpty()) continue;
                    if (stack.getItem() == Items.POTION && PotionUtils.getPotionFromItem(stack) == Potions.WATER) {
                        mc.playerController.windowClick(c.windowId, i, 0, ClickType.QUICK_MOVE, mc.player);
                        took = true;
                        break;
                    }
                }
                if (!took || !needBottles()) {
                    mc.player.closeScreen();
                    if (useIngredientChest.get() && needIngredients()) {
                        stage = Stage.TAKE_INGREDIENTS_OPEN;
                    } else {
                        stage = Stage.OPEN_STAND;
                    }
                }
            }
            case TAKE_INGREDIENTS_OPEN -> {
                if (isChestOpen()) {
                    stage = Stage.TAKE_INGREDIENTS;
                    return;
                }
                if (openTimer.isReached(600)) {
                    openChest(getIngredientChestPos());
                    openTimer.reset();
                }
            }
            case TAKE_INGREDIENTS -> {
                if (!isChestOpen()) { stage = Stage.TAKE_INGREDIENTS_OPEN; return; }
                ChestContainer c = (ChestContainer) mc.player.openContainer;
                int chestSlots = c.getNumRows() * 9;
                boolean took = false;
                for (Item ingredient : getRecipe()) {
                    if (hasItemInInventory(ingredient)) continue;
                    for (int i = 0; i < chestSlots; i++) {
                        ItemStack stack = c.inventorySlots.get(i).getStack();
                        if (!stack.isEmpty() && stack.getItem() == ingredient) {
                            mc.playerController.windowClick(c.windowId, i, 0, ClickType.QUICK_MOVE, mc.player);
                            took = true;
                            break;
                        }
                    }
                    if (took) break;
                }
                if (!took || !needIngredients()) {
                    mc.player.closeScreen();
                    stage = Stage.OPEN_STAND;
                }
            }
            case OPEN_STAND -> {
                if (isBrewingOpen()) {
                    stage = Stage.PLACE_BOTTLES;
                    return;
                }
                if (openTimer.isReached(600)) {
                    openStand();
                    openTimer.reset();
                }
            }
            case PLACE_BOTTLES -> {
                if (!ensureBrewingOpen()) return;
                BrewingStandContainer c = (BrewingStandContainer) mc.player.openContainer;
                for (int i = 0; i <= 2; i++) {
                    ItemStack cur = c.inventorySlots.get(i).getStack();
                    boolean isNonWaterPotion = !cur.isEmpty() && cur.getItem() == Items.POTION
                            && PotionUtils.getPotionFromItem(cur) != Potions.WATER;
                    boolean isOther = !cur.isEmpty() && cur.getItem() != Items.GLASS_BOTTLE
                            && cur.getItem() != Items.POTION;
                    if (isNonWaterPotion || isOther) {
                        mc.playerController.windowClick(c.windowId, i, 0, ClickType.QUICK_MOVE, mc.player);
                        return;
                    }
                    if (cur.isEmpty()) {
                        int cs = findBrewingSlot(Items.POTION, true);
                        if (cs == -1) cs = findBrewingSlot(Items.GLASS_BOTTLE, false);
                        if (cs != -1) {
                            mc.playerController.windowClick(c.windowId, cs, 0, ClickType.PICKUP, mc.player);
                            mc.playerController.windowClick(c.windowId, i, 1, ClickType.PICKUP, mc.player);
                            mc.playerController.windowClick(c.windowId, cs, 0, ClickType.PICKUP, mc.player);
                            return;
                        }
                    }
                }
                currentIngredientIndex = 0;
                ingredientPlaced = false;
                stage = Stage.BREWING;
            }
            case BREWING -> {
                if (!ensureBrewingOpen()) return;
                Item[] currentRecipe = getRecipe();
                if (currentIngredientIndex >= currentRecipe.length) {
                    stage = Stage.COLLECT;
                    return;
                }
                if (placeSingleIngredient(currentRecipe[currentIngredientIndex])) {
                    ingredientPlaced = true;
                    stage = Stage.WAITING;
                }
            }
            case WAITING -> {
                if (!ensureBrewingOpen()) return;
                if (isIngredientGone()) {
                    ingredientPlaced = false;
                    currentIngredientIndex++;
                    stage = Stage.BREWING;
                }
            }

            case COLLECT -> {
                if (!ensureBrewingOpen()) return;
                BrewingStandContainer c = (BrewingStandContainer) mc.player.openContainer;
                for (int i = 0; i <= 2; i++) {
                    if (!c.inventorySlots.get(i).getStack().isEmpty()) {
                        mc.playerController.windowClick(c.windowId, i, 0, ClickType.QUICK_MOVE, mc.player);
                        return;
                    }
                }
                if (usePotionChest.get()) {
                    mc.player.closeScreen();
                    stage = Stage.STORE_POTIONS_OPEN;
                } else {
                    stage = Stage.PLACE_BOTTLES;
                }
            }
            case STORE_POTIONS_OPEN -> {
                if (isChestOpen()) {
                    stage = Stage.STORE_POTIONS;
                    return;
                }
                if (openTimer.isReached(600)) {
                    openChest(getPotionChestPos());
                    openTimer.reset();
                }
            }
            case STORE_POTIONS -> {
                if (!isChestOpen()) { stage = Stage.STORE_POTIONS_OPEN; return; }
                ChestContainer c = (ChestContainer) mc.player.openContainer;
                int chestSlots = c.getNumRows() * 9;
                boolean stored = false;
                int totalSlots = c.inventorySlots.size();
                for (int i = chestSlots; i < totalSlots; i++) {
                    ItemStack stack = c.inventorySlots.get(i).getStack();
                    if (stack.isEmpty()) continue;
                    if (stack.getItem() == Items.POTION && PotionUtils.getPotionFromItem(stack) != Potions.WATER) {
                        mc.playerController.windowClick(c.windowId, i, 0, ClickType.QUICK_MOVE, mc.player);
                        stored = true;
                        break;
                    }
                }
                if (!stored) {
                    mc.player.closeScreen();
                    if (useBottleChest.get() && needBottles()) {
                        stage = Stage.TAKE_BOTTLES_OPEN;
                    } else if (useIngredientChest.get() && needIngredients()) {
                        stage = Stage.TAKE_INGREDIENTS_OPEN;
                    } else {
                        stage = Stage.OPEN_STAND;
                    }
                }
            }
        }
    }
    private boolean isIngredientGone() {
        if (!ingredientPlaced) return false;
        if (!(mc.player.openContainer instanceof BrewingStandContainer c)) return false;
        return c.inventorySlots.get(3).getStack().isEmpty();
    }

    private boolean placeSingleIngredient(Item item) {
        if (!(mc.player.openContainer instanceof BrewingStandContainer c)) return false;
        ItemStack cur = c.inventorySlots.get(3).getStack();
        if (!cur.isEmpty() && cur.getItem() == item) return true;
        if (!cur.isEmpty()) {
            mc.playerController.windowClick(c.windowId, 3, 0, ClickType.QUICK_MOVE, mc.player);
            return false;
        }
        int cs = findBrewingSlot(item, false);
        if (cs == -1) return false;
        mc.playerController.windowClick(c.windowId, cs, 0, ClickType.PICKUP, mc.player);
        mc.playerController.windowClick(c.windowId, 3, 1, ClickType.PICKUP, mc.player);
        mc.playerController.windowClick(c.windowId, cs, 0, ClickType.PICKUP, mc.player);
        return false;
    }

    private boolean ensureBrewingOpen() {
        if (isBrewingOpen()) return true;
        if (openTimer.isReached(600)) {
            openStand();
            openTimer.reset();
        }
        return false;
    }

    private void openStand() {
        if (standPos == null) return;
        BlockRayTraceResult rtr = new BlockRayTraceResult(
            Vector3d.copyCentered(standPos), Direction.UP, standPos, false);
        mc.playerController.processRightClickBlock(mc.player, mc.world, Hand.MAIN_HAND, rtr);
    }

    private void openChest(BlockPos pos) {
        if (pos == null) return;
        BlockRayTraceResult rtr = new BlockRayTraceResult(
            Vector3d.copyCentered(pos), Direction.UP, pos, false);
        mc.playerController.processRightClickBlock(mc.player, mc.world, Hand.MAIN_HAND, rtr);
    }

    private boolean isBrewingOpen() {
        return mc.currentScreen instanceof BrewingStandScreen
                && mc.player.openContainer instanceof BrewingStandContainer;
    }

    private boolean isChestOpen() {
        return mc.currentScreen instanceof ChestScreen
                && mc.player.openContainer instanceof ChestContainer;
    }

    private boolean needBottles() {
        int count = 0;
        for (int i = 0; i < 36; i++) {
            ItemStack s = mc.player.inventory.getStackInSlot(i);
            if (s.getItem() == Items.POTION && PotionUtils.getPotionFromItem(s) == Potions.WATER) {
                count += s.getCount();
            }
        }
        return count < 3;
    }

    private boolean needIngredients() {
        for (Item ingredient : getRecipe()) {
            if (!hasItemInInventory(ingredient)) return true;
        }
        return false;
    }

    private boolean hasItemInInventory(Item item) {
        for (int i = 0; i < 36; i++) {
            ItemStack s = mc.player.inventory.getStackInSlot(i);
            if (!s.isEmpty() && s.getItem() == item) return true;
        }
        return false;
    }

    private BlockPos getPotionChestPos() {
        return parsePos(potionChestX, potionChestY, potionChestZ);
    }

    private BlockPos getIngredientChestPos() {
        return parsePos(ingredientChestX, ingredientChestY, ingredientChestZ);
    }

    private BlockPos getBottleChestPos() {
        return parsePos(bottleChestX, bottleChestY, bottleChestZ);
    }

    private BlockPos parsePos(StringSetting x, StringSetting y, StringSetting z) {
        try {
            return new BlockPos(
                Integer.parseInt(x.get().trim()),
                Integer.parseInt(y.get().trim()),
                Integer.parseInt(z.get().trim())
            );
        } catch (NumberFormatException e) {
            return null;
        }
    }
    private int findBrewingSlot(Item item, boolean waterBottleOnly) {
        for (int i = 9; i < 36; i++) {
            ItemStack s = mc.player.inventory.getStackInSlot(i);
            if (s.isEmpty() || s.getItem() != item) continue;
            if (waterBottleOnly && s.getItem() == Items.POTION
                    && PotionUtils.getPotionFromItem(s) != Potions.WATER) continue;
            return (i - 9) + 5;
        }
        for (int i = 0; i < 9; i++) {
            ItemStack s = mc.player.inventory.getStackInSlot(i);
            if (s.isEmpty() || s.getItem() != item) continue;
            if (waterBottleOnly && s.getItem() == Items.POTION
                    && PotionUtils.getPotionFromItem(s) != Potions.WATER) continue;
            return i + 32;
        }
        return -1;
    }
}
че за база
 
Увидел что наш любимый @ConeTin сделал авто зелье варку и я взял идею и сделал вам и сливаю вам ⚠️ВНИМАНИЕ ВАЙПКОДИНГ ПРИСУТСТВУЕТ НАПИСАНО Claude Opus 4.7
Работает на всех серверах
Пожалуйста, авторизуйтесь для просмотра ссылки.

Код:
Expand Collapse Copy
package client.main.module.impl.misc;

import client.events.EventUpdate;
import client.main.module.api.Category;
import client.main.module.api.Module;
import client.main.module.api.ModuleRegister;
import client.main.module.settings.impl.BooleanSetting;
import client.main.module.settings.impl.ModeSetting;
import client.main.module.settings.impl.StringSetting;
import client.util.math.StopWatch;
import com.google.common.eventbus.Subscribe;
import net.minecraft.client.gui.screen.inventory.BrewingStandScreen;
import net.minecraft.client.gui.screen.inventory.ChestScreen;
import net.minecraft.inventory.container.BrewingStandContainer;
import net.minecraft.inventory.container.ChestContainer;
import net.minecraft.inventory.container.ClickType;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.potion.PotionUtils;
import net.minecraft.potion.Potions;
import net.minecraft.tileentity.BrewingStandTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Direction;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.vector.Vector3d;

@ModuleRegister(name = "AutoPotion", type = Category.Misc, desc = "Automatically brews potions in Brewing Stand")
public class AutoPotion extends Module {
  
    private final ModeSetting recipe = new ModeSetting("Рецепт", "Невидимость", "Невидимость", "Сила 2", "Скорость 2");
    private final BooleanSetting usePotionChest = new BooleanSetting("Сундук зелий", false);
    private final StringSetting potionChestX = new StringSetting("Зелья X", "0", "X координата сундука зелий");
    private final StringSetting potionChestY = new StringSetting("Зелья Y", "0", "Y координата сундука зелий");
    private final StringSetting potionChestZ = new StringSetting("Зелья Z", "0", "Z координата сундука зелий");

    private final BooleanSetting useIngredientChest = new BooleanSetting("Сундук ингредиентов", false);
    private final StringSetting ingredientChestX = new StringSetting("Ингредиенты X", "0", "X координата сундука ингредиентов");
    private final StringSetting ingredientChestY = new StringSetting("Ингредиенты Y", "0", "Y координата сундука ингредиентов");
    private final StringSetting ingredientChestZ = new StringSetting("Ингредиенты Z", "0", "Z координата сундука ингредиентов");

    private final BooleanSetting useBottleChest = new BooleanSetting("Сундук бутылок", false);
    private final StringSetting bottleChestX = new StringSetting("Бутылки X", "0", "X координата сундука бутылок");
    private final StringSetting bottleChestY = new StringSetting("Бутылки Y", "0", "Y координата сундука бутылок");
    private final StringSetting bottleChestZ = new StringSetting("Бутылки Z", "0", "Z координата сундука бутылок");
    private static final Item[] RECIPE_INVISIBILITY = {
        Items.NETHER_WART,
        Items.GOLDEN_CARROT,
        Items.FERMENTED_SPIDER_EYE,
        Items.REDSTONE
    };
    private static final Item[] RECIPE_STRENGTH_2 = {
        Items.NETHER_WART,
        Items.BLAZE_POWDER,
        Items.GLOWSTONE_DUST
    };
    private static final Item[] RECIPE_SPEED_2 = {
        Items.NETHER_WART,
        Items.SUGAR,
        Items.GLOWSTONE_DUST
    };
    private enum Stage {
        FIND_STAND, OPEN_STAND,
        TAKE_BOTTLES_OPEN, TAKE_BOTTLES,
        TAKE_INGREDIENTS_OPEN, TAKE_INGREDIENTS,
        PLACE_BOTTLES,
        BREWING, WAITING,
        COLLECT,
        STORE_POTIONS_OPEN, STORE_POTIONS
    }

    private Stage stage = Stage.FIND_STAND;
    private BlockPos standPos = null;
    private final StopWatch timer = new StopWatch();
    private final StopWatch openTimer = new StopWatch();
    private boolean ingredientPlaced = false;
    private int currentIngredientIndex = 0;

    public AutoPotion() {
        addSettings(
            recipe,
            usePotionChest, potionChestX, potionChestY, potionChestZ,
            useIngredientChest, ingredientChestX, ingredientChestY, ingredientChestZ,
            useBottleChest, bottleChestX, bottleChestY, bottleChestZ
        );
        potionChestX.setVisible(usePotionChest::get);
        potionChestY.setVisible(usePotionChest::get);
        potionChestZ.setVisible(usePotionChest::get);
        ingredientChestX.setVisible(useIngredientChest::get);
        ingredientChestY.setVisible(useIngredientChest::get);
        ingredientChestZ.setVisible(useIngredientChest::get);
        bottleChestX.setVisible(useBottleChest::get);
        bottleChestY.setVisible(useBottleChest::get);
        bottleChestZ.setVisible(useBottleChest::get);
    }

    private Item[] getRecipe() {
        if (recipe.is("Сила 2")) return RECIPE_STRENGTH_2;
        if (recipe.is("Скорость 2")) return RECIPE_SPEED_2;
        return RECIPE_INVISIBILITY;
    }

    @Override
    public boolean onEnable() {
        stage = Stage.FIND_STAND;
        standPos = null;
        ingredientPlaced = false;
        currentIngredientIndex = 0;
        return super.onEnable();
    }

    @Override
    public boolean onDisable() {
        if (mc.player != null && mc.currentScreen != null) mc.player.closeScreen();
        stage = Stage.FIND_STAND;
        ingredientPlaced = false;
        currentIngredientIndex = 0;
        return super.onDisable();
    }

    @Subscribe
    public void onUpdate(EventUpdate e) {
        if (mc.player == null || mc.world == null) return;
        if (!timer.isReached(300)) return;
        timer.reset();

        switch (stage) {
            case FIND_STAND -> {
                for (BlockPos pos : BlockPos.getAllInBoxMutable(
                        mc.player.getPosition().add(-4, -2, -4),
                        mc.player.getPosition().add(4, 2, 4))) {
                    TileEntity te = mc.world.getTileEntity(pos);
                    if (te instanceof BrewingStandTileEntity) {
                        standPos = pos.toImmutable();
                        if (useBottleChest.get() && needBottles()) {
                            stage = Stage.TAKE_BOTTLES_OPEN;
                        } else if (useIngredientChest.get() && needIngredients()) {
                            stage = Stage.TAKE_INGREDIENTS_OPEN;
                        } else {
                            stage = Stage.OPEN_STAND;
                        }
                        return;
                    }
                }
            }
            case TAKE_BOTTLES_OPEN -> {
                if (isChestOpen()) {
                    stage = Stage.TAKE_BOTTLES;
                    return;
                }
                if (openTimer.isReached(600)) {
                    openChest(getBottleChestPos());
                    openTimer.reset();
                }
            }
            case TAKE_BOTTLES -> {
                if (!isChestOpen()) { stage = Stage.TAKE_BOTTLES_OPEN; return; }
                ChestContainer c = (ChestContainer) mc.player.openContainer;
                int chestSlots = c.getNumRows() * 9;
                boolean took = false;
                for (int i = 0; i < chestSlots; i++) {
                    ItemStack stack = c.inventorySlots.get(i).getStack();
                    if (stack.isEmpty()) continue;
                    if (stack.getItem() == Items.POTION && PotionUtils.getPotionFromItem(stack) == Potions.WATER) {
                        mc.playerController.windowClick(c.windowId, i, 0, ClickType.QUICK_MOVE, mc.player);
                        took = true;
                        break;
                    }
                }
                if (!took || !needBottles()) {
                    mc.player.closeScreen();
                    if (useIngredientChest.get() && needIngredients()) {
                        stage = Stage.TAKE_INGREDIENTS_OPEN;
                    } else {
                        stage = Stage.OPEN_STAND;
                    }
                }
            }
            case TAKE_INGREDIENTS_OPEN -> {
                if (isChestOpen()) {
                    stage = Stage.TAKE_INGREDIENTS;
                    return;
                }
                if (openTimer.isReached(600)) {
                    openChest(getIngredientChestPos());
                    openTimer.reset();
                }
            }
            case TAKE_INGREDIENTS -> {
                if (!isChestOpen()) { stage = Stage.TAKE_INGREDIENTS_OPEN; return; }
                ChestContainer c = (ChestContainer) mc.player.openContainer;
                int chestSlots = c.getNumRows() * 9;
                boolean took = false;
                for (Item ingredient : getRecipe()) {
                    if (hasItemInInventory(ingredient)) continue;
                    for (int i = 0; i < chestSlots; i++) {
                        ItemStack stack = c.inventorySlots.get(i).getStack();
                        if (!stack.isEmpty() && stack.getItem() == ingredient) {
                            mc.playerController.windowClick(c.windowId, i, 0, ClickType.QUICK_MOVE, mc.player);
                            took = true;
                            break;
                        }
                    }
                    if (took) break;
                }
                if (!took || !needIngredients()) {
                    mc.player.closeScreen();
                    stage = Stage.OPEN_STAND;
                }
            }
            case OPEN_STAND -> {
                if (isBrewingOpen()) {
                    stage = Stage.PLACE_BOTTLES;
                    return;
                }
                if (openTimer.isReached(600)) {
                    openStand();
                    openTimer.reset();
                }
            }
            case PLACE_BOTTLES -> {
                if (!ensureBrewingOpen()) return;
                BrewingStandContainer c = (BrewingStandContainer) mc.player.openContainer;
                for (int i = 0; i <= 2; i++) {
                    ItemStack cur = c.inventorySlots.get(i).getStack();
                    boolean isNonWaterPotion = !cur.isEmpty() && cur.getItem() == Items.POTION
                            && PotionUtils.getPotionFromItem(cur) != Potions.WATER;
                    boolean isOther = !cur.isEmpty() && cur.getItem() != Items.GLASS_BOTTLE
                            && cur.getItem() != Items.POTION;
                    if (isNonWaterPotion || isOther) {
                        mc.playerController.windowClick(c.windowId, i, 0, ClickType.QUICK_MOVE, mc.player);
                        return;
                    }
                    if (cur.isEmpty()) {
                        int cs = findBrewingSlot(Items.POTION, true);
                        if (cs == -1) cs = findBrewingSlot(Items.GLASS_BOTTLE, false);
                        if (cs != -1) {
                            mc.playerController.windowClick(c.windowId, cs, 0, ClickType.PICKUP, mc.player);
                            mc.playerController.windowClick(c.windowId, i, 1, ClickType.PICKUP, mc.player);
                            mc.playerController.windowClick(c.windowId, cs, 0, ClickType.PICKUP, mc.player);
                            return;
                        }
                    }
                }
                currentIngredientIndex = 0;
                ingredientPlaced = false;
                stage = Stage.BREWING;
            }
            case BREWING -> {
                if (!ensureBrewingOpen()) return;
                Item[] currentRecipe = getRecipe();
                if (currentIngredientIndex >= currentRecipe.length) {
                    stage = Stage.COLLECT;
                    return;
                }
                if (placeSingleIngredient(currentRecipe[currentIngredientIndex])) {
                    ingredientPlaced = true;
                    stage = Stage.WAITING;
                }
            }
            case WAITING -> {
                if (!ensureBrewingOpen()) return;
                if (isIngredientGone()) {
                    ingredientPlaced = false;
                    currentIngredientIndex++;
                    stage = Stage.BREWING;
                }
            }

            case COLLECT -> {
                if (!ensureBrewingOpen()) return;
                BrewingStandContainer c = (BrewingStandContainer) mc.player.openContainer;
                for (int i = 0; i <= 2; i++) {
                    if (!c.inventorySlots.get(i).getStack().isEmpty()) {
                        mc.playerController.windowClick(c.windowId, i, 0, ClickType.QUICK_MOVE, mc.player);
                        return;
                    }
                }
                if (usePotionChest.get()) {
                    mc.player.closeScreen();
                    stage = Stage.STORE_POTIONS_OPEN;
                } else {
                    stage = Stage.PLACE_BOTTLES;
                }
            }
            case STORE_POTIONS_OPEN -> {
                if (isChestOpen()) {
                    stage = Stage.STORE_POTIONS;
                    return;
                }
                if (openTimer.isReached(600)) {
                    openChest(getPotionChestPos());
                    openTimer.reset();
                }
            }
            case STORE_POTIONS -> {
                if (!isChestOpen()) { stage = Stage.STORE_POTIONS_OPEN; return; }
                ChestContainer c = (ChestContainer) mc.player.openContainer;
                int chestSlots = c.getNumRows() * 9;
                boolean stored = false;
                int totalSlots = c.inventorySlots.size();
                for (int i = chestSlots; i < totalSlots; i++) {
                    ItemStack stack = c.inventorySlots.get(i).getStack();
                    if (stack.isEmpty()) continue;
                    if (stack.getItem() == Items.POTION && PotionUtils.getPotionFromItem(stack) != Potions.WATER) {
                        mc.playerController.windowClick(c.windowId, i, 0, ClickType.QUICK_MOVE, mc.player);
                        stored = true;
                        break;
                    }
                }
                if (!stored) {
                    mc.player.closeScreen();
                    if (useBottleChest.get() && needBottles()) {
                        stage = Stage.TAKE_BOTTLES_OPEN;
                    } else if (useIngredientChest.get() && needIngredients()) {
                        stage = Stage.TAKE_INGREDIENTS_OPEN;
                    } else {
                        stage = Stage.OPEN_STAND;
                    }
                }
            }
        }
    }
    private boolean isIngredientGone() {
        if (!ingredientPlaced) return false;
        if (!(mc.player.openContainer instanceof BrewingStandContainer c)) return false;
        return c.inventorySlots.get(3).getStack().isEmpty();
    }

    private boolean placeSingleIngredient(Item item) {
        if (!(mc.player.openContainer instanceof BrewingStandContainer c)) return false;
        ItemStack cur = c.inventorySlots.get(3).getStack();
        if (!cur.isEmpty() && cur.getItem() == item) return true;
        if (!cur.isEmpty()) {
            mc.playerController.windowClick(c.windowId, 3, 0, ClickType.QUICK_MOVE, mc.player);
            return false;
        }
        int cs = findBrewingSlot(item, false);
        if (cs == -1) return false;
        mc.playerController.windowClick(c.windowId, cs, 0, ClickType.PICKUP, mc.player);
        mc.playerController.windowClick(c.windowId, 3, 1, ClickType.PICKUP, mc.player);
        mc.playerController.windowClick(c.windowId, cs, 0, ClickType.PICKUP, mc.player);
        return false;
    }

    private boolean ensureBrewingOpen() {
        if (isBrewingOpen()) return true;
        if (openTimer.isReached(600)) {
            openStand();
            openTimer.reset();
        }
        return false;
    }

    private void openStand() {
        if (standPos == null) return;
        BlockRayTraceResult rtr = new BlockRayTraceResult(
            Vector3d.copyCentered(standPos), Direction.UP, standPos, false);
        mc.playerController.processRightClickBlock(mc.player, mc.world, Hand.MAIN_HAND, rtr);
    }

    private void openChest(BlockPos pos) {
        if (pos == null) return;
        BlockRayTraceResult rtr = new BlockRayTraceResult(
            Vector3d.copyCentered(pos), Direction.UP, pos, false);
        mc.playerController.processRightClickBlock(mc.player, mc.world, Hand.MAIN_HAND, rtr);
    }

    private boolean isBrewingOpen() {
        return mc.currentScreen instanceof BrewingStandScreen
                && mc.player.openContainer instanceof BrewingStandContainer;
    }

    private boolean isChestOpen() {
        return mc.currentScreen instanceof ChestScreen
                && mc.player.openContainer instanceof ChestContainer;
    }

    private boolean needBottles() {
        int count = 0;
        for (int i = 0; i < 36; i++) {
            ItemStack s = mc.player.inventory.getStackInSlot(i);
            if (s.getItem() == Items.POTION && PotionUtils.getPotionFromItem(s) == Potions.WATER) {
                count += s.getCount();
            }
        }
        return count < 3;
    }

    private boolean needIngredients() {
        for (Item ingredient : getRecipe()) {
            if (!hasItemInInventory(ingredient)) return true;
        }
        return false;
    }

    private boolean hasItemInInventory(Item item) {
        for (int i = 0; i < 36; i++) {
            ItemStack s = mc.player.inventory.getStackInSlot(i);
            if (!s.isEmpty() && s.getItem() == item) return true;
        }
        return false;
    }

    private BlockPos getPotionChestPos() {
        return parsePos(potionChestX, potionChestY, potionChestZ);
    }

    private BlockPos getIngredientChestPos() {
        return parsePos(ingredientChestX, ingredientChestY, ingredientChestZ);
    }

    private BlockPos getBottleChestPos() {
        return parsePos(bottleChestX, bottleChestY, bottleChestZ);
    }

    private BlockPos parsePos(StringSetting x, StringSetting y, StringSetting z) {
        try {
            return new BlockPos(
                Integer.parseInt(x.get().trim()),
                Integer.parseInt(y.get().trim()),
                Integer.parseInt(z.get().trim())
            );
        } catch (NumberFormatException e) {
            return null;
        }
    }
    private int findBrewingSlot(Item item, boolean waterBottleOnly) {
        for (int i = 9; i < 36; i++) {
            ItemStack s = mc.player.inventory.getStackInSlot(i);
            if (s.isEmpty() || s.getItem() != item) continue;
            if (waterBottleOnly && s.getItem() == Items.POTION
                    && PotionUtils.getPotionFromItem(s) != Potions.WATER) continue;
            return (i - 9) + 5;
        }
        for (int i = 0; i < 9; i++) {
            ItemStack s = mc.player.inventory.getStackInSlot(i);
            if (s.isEmpty() || s.getItem() != item) continue;
            if (waterBottleOnly && s.getItem() == Items.POTION
                    && PotionUtils.getPotionFromItem(s) != Potions.WATER) continue;
            return i + 32;
        }
        return -1;
    }
}
ты шо с дуба рухнулся? Какие координаты??!
 
litka

я пробовал без кординат у него голова кипела он откривал все что можно
Так сделай норм настройку, у меня чит спрашивает в каком сундуке то-то то-то и юзер тыкает по сундуку
 
Можно без координат:
  1. Модуль шуршит все сундуки вокруг и запоминает, где какой ресурс лежит.
    (Просто складывает в свою память — ну там в файлик или в переменную.)
  2. Находит все зельеварки поблизости и запоминает, где они стоят.
  3. Потом хватает из сундуков нужные ингредиенты, выбирает самую дальнюю зельеварку и запоминает ее так-же как и сундуки
    И начинает туда кидать ингредиенты.
  4. Когда зелье сварилось — забирает его и скидывает в сундук, который пустой.
    (Сундук запомнит из 1 действия).

    Не знаю почему тебе опус не смог адекватно сделать. Да пример выше говно но это намного лучше чем кастыльно вписывать корды
 

Похожие темы

Назад
Сверху Снизу