Search in sources :

Example 1 with RecipeResultCollection

use of net.minecraft.client.gui.screen.recipebook.RecipeResultCollection in project orion by AntiCope.

the class AutoBedCraft method onTick.

@EventHandler
private void onTick(TickEvent.Post event) {
    if (PlayerUtils.getTotalHealth() <= minHealth.get())
        return;
    if (automatic.get() && isOutOfMaterial() && !alertedNoMats) {
        error("Cannot activate auto mode, no material left.");
        alertedNoMats = true;
    }
    if (automatic.get() && needsRefill() && canRefill(true) && !isOutOfMaterial() && !(mc.player.currentScreenHandler instanceof CraftingScreenHandler)) {
        FindItemResult craftTable = ItemHelper.findCraftTable();
        if (!craftTable.found()) {
            toggle();
            error("No crafting tables in hotbar!");
            return;
        }
        if (debug.get())
            info("Searching for nearby crafting tables");
        BlockPos tablePos;
        tablePos = findCraftingTable();
        if (tablePos == null) {
            if (debug.get())
                info("None nearby, placing table and returning.");
            placeCraftingTable(craftTable);
            return;
        }
        if (debug.get())
            info("Located usable crafting table, opening and refilling");
        openCraftingTable(tablePos);
        if (chatInfo.get() && !startedRefill) {
            info("Refilling...");
            startedRefill = true;
        }
        didRefill = true;
        return;
    }
    if (didRefill && !needsRefill()) {
        if (chatInfo.get())
            info("Refill complete.");
        didRefill = false;
        startedRefill = false;
        if (debug.get())
            info("Automatic finished.");
    }
    if (mc.player.currentScreenHandler instanceof CraftingScreenHandler) {
        if (!canRefill(false)) {
            if (debug.get())
                info("Cancelling current refill because canRefill is false");
            mc.player.closeHandledScreen();
            if (antiDesync.get())
                mc.player.getInventory().updateItems();
            return;
        }
        CraftingScreenHandler currentScreenHandler = (CraftingScreenHandler) mc.player.currentScreenHandler;
        if (isOutOfMaterial()) {
            if (chatInfo.get())
                error("You are out of material!");
            if (disableNoMats.get())
                toggle();
            mc.player.closeHandledScreen();
            if (antiDesync.get())
                mc.player.getInventory().updateItems();
            return;
        }
        if (InvHelper.isInventoryFull()) {
            if (disableAfter.get())
                toggle();
            if (closeAfter.get()) {
                mc.player.closeHandledScreen();
                if (antiDesync.get())
                    mc.player.getInventory().updateItems();
            }
            if (chatInfo.get() && !automatic.get())
                info("Your inventory is full.");
            return;
        }
        List<RecipeResultCollection> recipeResultCollectionList = mc.player.getRecipeBook().getResultsForGroup(RecipeBookGroup.CRAFTING_MISC);
        for (RecipeResultCollection recipeResultCollection : recipeResultCollectionList) {
            for (Recipe<?> recipe : recipeResultCollection.getRecipes(true)) {
                if (recipe.getOutput().getItem() instanceof BedItem) {
                    assert mc.interactionManager != null;
                    mc.interactionManager.clickRecipe(currentScreenHandler.syncId, recipe, false);
                    windowClick(currentScreenHandler, 0, SlotActionType.QUICK_MOVE, 1);
                }
            }
        }
    }
}
Also used : CraftingScreenHandler(net.minecraft.screen.CraftingScreenHandler) FindItemResult(meteordevelopment.meteorclient.utils.player.FindItemResult) BlockPos(net.minecraft.util.math.BlockPos) RecipeResultCollection(net.minecraft.client.gui.screen.recipebook.RecipeResultCollection) BedItem(net.minecraft.item.BedItem) EventHandler(meteordevelopment.orbit.EventHandler)

Example 2 with RecipeResultCollection

use of net.minecraft.client.gui.screen.recipebook.RecipeResultCollection in project meteor-rejects by AntiCope.

the class AutoCraft method onTick.

@EventHandler
private void onTick(TickEvent.Post event) {
    if (mc.interactionManager == null)
        return;
    if (items.get().isEmpty())
        return;
    if (!(mc.player.currentScreenHandler instanceof CraftingScreenHandler))
        return;
    if (antiDesync.get())
        mc.player.getInventory().updateItems();
    // Danke schön GhostTypes
    // https://github.com/GhostTypes/orion/blob/main/src/main/java/me/ghosttypes/orion/modules/main/AutoBedCraft.java
    CraftingScreenHandler currentScreenHandler = (CraftingScreenHandler) mc.player.currentScreenHandler;
    List<Item> itemList = items.get();
    List<RecipeResultCollection> recipeResultCollectionList = mc.player.getRecipeBook().getOrderedResults();
    for (RecipeResultCollection recipeResultCollection : recipeResultCollectionList) {
        for (Recipe<?> recipe : recipeResultCollection.getRecipes(true)) {
            if (!itemList.contains(recipe.getOutput().getItem()))
                continue;
            mc.interactionManager.clickRecipe(currentScreenHandler.syncId, recipe, craftAll.get());
            mc.interactionManager.clickSlot(currentScreenHandler.syncId, 0, 1, drop.get() ? SlotActionType.THROW : SlotActionType.QUICK_MOVE, mc.player);
        }
    }
}
Also used : CraftingScreenHandler(net.minecraft.screen.CraftingScreenHandler) Item(net.minecraft.item.Item) RecipeResultCollection(net.minecraft.client.gui.screen.recipebook.RecipeResultCollection) EventHandler(meteordevelopment.orbit.EventHandler)

Example 3 with RecipeResultCollection

use of net.minecraft.client.gui.screen.recipebook.RecipeResultCollection in project BleachHack by BleachDrinker420.

the class AutoCraft method onTick.

@BleachSubscribe
public void onTick(EventTick event) {
    SettingToggle maxItems = getSetting(3).asToggle();
    if (maxItems.getState() && crafted >= maxItems.getChild(0).asSlider().getValueInt()) {
        if (maxItems.getChild(1).asToggle().getState())
            BleachLogger.info("Disabled AutoCraft after crafting " + crafted + " items.");
        setEnabled(false);
        return;
    }
    if (!(mc.player.currentScreenHandler instanceof CraftingScreenHandler))
        return;
    // quick hack
    CraftingScreenHandler handler = (CraftingScreenHandler) mc.player.currentScreenHandler;
    mc.player.getRecipeBook().setGuiOpen(handler.getCategory(), true);
    CraftingScreenHandler currentScreenHandler = (CraftingScreenHandler) mc.player.currentScreenHandler;
    List<RecipeResultCollection> recipeResultCollectionList = mc.player.getRecipeBook().getOrderedResults();
    boolean craftAll = getSetting(1).asToggle().getState();
    boolean drop = getSetting(2).asToggle().getState();
    for (RecipeResultCollection recipeResultCollection : recipeResultCollectionList) {
        for (Recipe<?> recipe : recipeResultCollection.getRecipes(true)) {
            if (getSetting(0).asList(Item.class).contains(recipe.getOutput().getItem())) {
                mc.interactionManager.clickRecipe(currentScreenHandler.syncId, recipe, craftAll);
                mc.interactionManager.clickSlot(currentScreenHandler.syncId, 0, 0, drop ? SlotActionType.THROW : SlotActionType.QUICK_MOVE, mc.player);
                crafted++;
                return;
            }
        }
    }
}
Also used : CraftingScreenHandler(net.minecraft.screen.CraftingScreenHandler) Item(net.minecraft.item.Item) SettingToggle(org.bleachhack.setting.module.SettingToggle) RecipeResultCollection(net.minecraft.client.gui.screen.recipebook.RecipeResultCollection) BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe)

Example 4 with RecipeResultCollection

use of net.minecraft.client.gui.screen.recipebook.RecipeResultCollection in project Client by MatHax.

the class AutoBedCraft method onTick.

@EventHandler
private void onTick(TickEvent.Post event) {
    if (PlayerUtils.getTotalHealth() <= minHealth.get())
        return;
    if (automatic.get() && isOutOfMaterial() && !alertedNoMats) {
        error("Cannot activate auto mode, no material left.");
        alertedNoMats = true;
    }
    if (automatic.get() && needsRefill() && canRefill(true) && !isOutOfMaterial() && !(mc.player.currentScreenHandler instanceof CraftingScreenHandler)) {
        FindItemResult craftTable = InvUtils.findCraftTable();
        if (!craftTable.found()) {
            toggle();
            error("No crafting tables in hotbar!");
            return;
        }
        BlockPos tablePos;
        tablePos = findCraftingTable();
        if (tablePos == null) {
            placeCraftingTable(craftTable);
            return;
        }
        openCraftingTable(tablePos);
        if (chatInfo.get() && !startedRefill) {
            info("Refilling...");
            startedRefill = true;
        }
        didRefill = true;
        return;
    }
    if (didRefill && !needsRefill()) {
        if (chatInfo.get())
            info("Refill complete.");
        didRefill = false;
        startedRefill = false;
    }
    if (mc.player.currentScreenHandler instanceof CraftingScreenHandler) {
        if (!canRefill(false)) {
            mc.player.closeHandledScreen();
            if (antiDesync.get())
                mc.player.getInventory().updateItems();
            return;
        }
        CraftingScreenHandler currentScreenHandler = (CraftingScreenHandler) mc.player.currentScreenHandler;
        if (isOutOfMaterial()) {
            if (chatInfo.get())
                error("You are out of material!");
            if (disableNoMats.get())
                toggle();
            mc.player.closeHandledScreen();
            if (antiDesync.get())
                mc.player.getInventory().updateItems();
            return;
        }
        if (InvUtils.isInventoryFull()) {
            if (disableAfter.get())
                toggle();
            if (closeAfter.get()) {
                mc.player.closeHandledScreen();
                if (antiDesync.get())
                    mc.player.getInventory().updateItems();
            }
            if (chatInfo.get() && !automatic.get())
                info("Your inventory is full.");
            return;
        }
        List<RecipeResultCollection> recipeResultCollectionList = mc.player.getRecipeBook().getResultsForGroup(RecipeBookGroup.CRAFTING_MISC);
        for (RecipeResultCollection recipeResultCollection : recipeResultCollectionList) {
            for (Recipe<?> recipe : recipeResultCollection.getRecipes(true)) {
                if (recipe.getOutput().getItem() instanceof BedItem) {
                    assert mc.interactionManager != null;
                    mc.interactionManager.clickRecipe(currentScreenHandler.syncId, recipe, false);
                    windowClick(currentScreenHandler, 0, SlotActionType.QUICK_MOVE, 1);
                }
            }
        }
    }
}
Also used : CraftingScreenHandler(net.minecraft.screen.CraftingScreenHandler) FindItemResult(mathax.client.utils.player.FindItemResult) BlockPos(net.minecraft.util.math.BlockPos) RecipeResultCollection(net.minecraft.client.gui.screen.recipebook.RecipeResultCollection) BedItem(net.minecraft.item.BedItem) EventHandler(mathax.client.eventbus.EventHandler)

Example 5 with RecipeResultCollection

use of net.minecraft.client.gui.screen.recipebook.RecipeResultCollection in project Client by MatHax.

the class AutoCraft method onTick.

@EventHandler
private void onTick(TickEvent.Post event) {
    if (mc.interactionManager == null)
        return;
    if (items.get().isEmpty())
        return;
    if (!(mc.player.currentScreenHandler instanceof CraftingScreenHandler))
        return;
    if (antiDesync.get())
        mc.player.getInventory().updateItems();
    CraftingScreenHandler currentScreenHandler = (CraftingScreenHandler) mc.player.currentScreenHandler;
    List<Item> itemList = items.get();
    List<RecipeResultCollection> recipeResultCollectionList = mc.player.getRecipeBook().getOrderedResults();
    for (RecipeResultCollection recipeResultCollection : recipeResultCollectionList) {
        for (Recipe<?> recipe : recipeResultCollection.getRecipes(true)) {
            if (!itemList.contains(recipe.getOutput().getItem()))
                continue;
            mc.interactionManager.clickRecipe(currentScreenHandler.syncId, recipe, craftAll.get());
            mc.interactionManager.clickSlot(currentScreenHandler.syncId, 0, 1, drop.get() ? SlotActionType.THROW : SlotActionType.QUICK_MOVE, mc.player);
        }
    }
}
Also used : CraftingScreenHandler(net.minecraft.screen.CraftingScreenHandler) Item(net.minecraft.item.Item) RecipeResultCollection(net.minecraft.client.gui.screen.recipebook.RecipeResultCollection) EventHandler(mathax.client.eventbus.EventHandler)

Aggregations

RecipeResultCollection (net.minecraft.client.gui.screen.recipebook.RecipeResultCollection)5 CraftingScreenHandler (net.minecraft.screen.CraftingScreenHandler)5 Item (net.minecraft.item.Item)3 EventHandler (mathax.client.eventbus.EventHandler)2 EventHandler (meteordevelopment.orbit.EventHandler)2 BedItem (net.minecraft.item.BedItem)2 BlockPos (net.minecraft.util.math.BlockPos)2 FindItemResult (mathax.client.utils.player.FindItemResult)1 FindItemResult (meteordevelopment.meteorclient.utils.player.FindItemResult)1 BleachSubscribe (org.bleachhack.eventbus.BleachSubscribe)1 SettingToggle (org.bleachhack.setting.module.SettingToggle)1