Search in sources :

Example 6 with CraftingScreenHandler

use of net.minecraft.screen.CraftingScreenHandler 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

CraftingScreenHandler (net.minecraft.screen.CraftingScreenHandler)6 RecipeResultCollection (net.minecraft.client.gui.screen.recipebook.RecipeResultCollection)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 CraftingResultInventory (net.minecraft.inventory.CraftingResultInventory)1 CraftingRecipe (net.minecraft.recipe.CraftingRecipe)1 PlayerScreenHandler (net.minecraft.screen.PlayerScreenHandler)1 BleachSubscribe (org.bleachhack.eventbus.BleachSubscribe)1 SettingToggle (org.bleachhack.setting.module.SettingToggle)1 AccessorCraftingScreenHandler (top.theillusivec4.polymorph.mixin.core.AccessorCraftingScreenHandler)1 AccessorPlayerScreenHandler (top.theillusivec4.polymorph.mixin.core.AccessorPlayerScreenHandler)1