Search in sources :

Example 16 with FindItemResult

use of mathax.client.utils.player.FindItemResult 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 17 with FindItemResult

use of mathax.client.utils.player.FindItemResult in project Client by MatHax.

the class ElytraFlightMode method onTick.

public void onTick() {
    if (elytraFly.autoReplenish.get()) {
        FindItemResult fireworks = InvUtils.find(Items.FIREWORK_ROCKET);
        FindItemResult hotbarFireworks = InvUtils.findInHotbar(Items.FIREWORK_ROCKET);
        if (!hotbarFireworks.found() && fireworks.found()) {
            InvUtils.move().from(fireworks.slot()).toHotbar(elytraFly.replenishSlot.get() - 1);
        }
    }
    if (elytraFly.replace.get()) {
        ItemStack chestStack = MatHax.mc.player.getInventory().getArmorStack(2);
        if (chestStack.getItem() == Items.ELYTRA) {
            if (chestStack.getMaxDamage() - chestStack.getDamage() <= elytraFly.replaceDurability.get()) {
                FindItemResult elytra = InvUtils.find(stack -> stack.getMaxDamage() - stack.getDamage() > elytraFly.replaceDurability.get() && stack.getItem() == Items.ELYTRA);
                InvUtils.move().from(elytra.slot()).toArmor(2);
            }
        }
    }
}
Also used : FindItemResult(mathax.client.utils.player.FindItemResult) ItemStack(net.minecraft.item.ItemStack)

Example 18 with FindItemResult

use of mathax.client.utils.player.FindItemResult in project Client by MatHax.

the class HoleFiller method onTick.

@EventHandler
private void onTick(TickEvent.Pre event) {
    for (Hole hole : holes) holePool.free(hole);
    holes.clear();
    FindItemResult block = InvUtils.findInHotbar(itemStack -> itemStack.getItem() instanceof BlockItem && blocks.get().contains(Block.getBlockFromItem(itemStack.getItem())));
    if (!block.found())
        return;
    BlockIterator.register(horizontalRadius.get(), verticalRadius.get(), (blockPos, blockState) -> {
        if (!validHole(blockPos))
            return;
        int bedrock = 0, obsidian = 0;
        Direction air = null;
        for (Direction direction : Direction.values()) {
            if (direction == Direction.UP)
                continue;
            BlockState state = mc.world.getBlockState(blockPos.offset(direction));
            if (state.getBlock() == Blocks.BEDROCK)
                bedrock++;
            else if (state.getBlock() == Blocks.OBSIDIAN)
                obsidian++;
            else if (direction == Direction.DOWN)
                return;
            else if (validHole(blockPos.offset(direction)) && air == null) {
                for (Direction dir : Direction.values()) {
                    if (dir == direction.getOpposite() || dir == Direction.UP)
                        continue;
                    BlockState blockState1 = mc.world.getBlockState(blockPos.offset(direction).offset(dir));
                    if (blockState1.getBlock() == Blocks.BEDROCK)
                        bedrock++;
                    else if (blockState1.getBlock() == Blocks.OBSIDIAN)
                        obsidian++;
                    else
                        return;
                }
                air = direction;
            }
        }
        if (obsidian + bedrock == 5 && air == null)
            holes.add(holePool.get().set(blockPos, NULL));
        else if (obsidian + bedrock == 8 && doubles.get() && air != null) {
            holes.add(holePool.get().set(blockPos, Dir.get(air)));
        }
    });
}
Also used : BlockState(net.minecraft.block.BlockState) FindItemResult(mathax.client.utils.player.FindItemResult) BlockItem(net.minecraft.item.BlockItem) Direction(net.minecraft.util.math.Direction) EventHandler(mathax.client.eventbus.EventHandler)

Example 19 with FindItemResult

use of mathax.client.utils.player.FindItemResult in project Client by MatHax.

the class HoleFiller method onTickPost.

@EventHandler
private void onTickPost(TickEvent.Post event) {
    if (timer <= 0 && !holes.isEmpty()) {
        FindItemResult block = InvUtils.findInHotbar(itemStack -> itemStack.getItem() instanceof BlockItem && blocks.get().contains(Block.getBlockFromItem(itemStack.getItem())));
        BlockUtils.place(holes.get(0).blockPos, block, rotate.get(), 10, true);
        timer = placeDelay.get();
    }
    timer--;
}
Also used : FindItemResult(mathax.client.utils.player.FindItemResult) BlockItem(net.minecraft.item.BlockItem) EventHandler(mathax.client.eventbus.EventHandler)

Example 20 with FindItemResult

use of mathax.client.utils.player.FindItemResult in project Client by MatHax.

the class Offhand method onTick.

@EventHandler
private void onTick(TickEvent.Pre event) {
    if (autoTotem.mode.get() == AutoTotem.Mode.Strict && autoTotem.isActive()) {
        info("(highlight)%s(default) does not work with (highlight)%s(default) set to (highlight)%s(default) mode, disabling...", title, autoTotem.title, "Strict");
        toggle();
        return;
    }
    if (autoTotem.mode.get() != AutoTotem.Mode.Strict && autoTotem.isActive() && PlayerUtils.getTotalHealth() - PlayerUtils.possibleHealthReductions(autoTotem.explosion.get(), autoTotem.fall.get()) <= autoTotem.health.get())
        return;
    if ((mc.player.getMainHandStack().getItem() instanceof SwordItem || mc.player.getMainHandStack().getItem() instanceof AxeItem) && swordGap.get())
        currentItem = Item.EGap;
    else if ((Modules.get().isActive(CrystalAura.class) && crystalCrystalAura.get()) || mc.interactionManager.isBreakingBlock() && crystalMine.get())
        currentItem = Item.Crystal;
    else
        currentItem = item.get();
    if (mc.player.getOffHandStack().getItem() != currentItem.item) {
        FindItemResult item = InvUtils.find(itemStack -> itemStack.getItem() == currentItem.item, hotbar.get() ? 0 : 9, 35);
        if (!item.found()) {
            if (!sentMessage) {
                warning("Chosen item not found" + (toggleNotFound.get() ? ", disabling..." : "."));
                if (toggleNotFound.get()) {
                    toggle();
                    return;
                }
                sentMessage = true;
            }
        } else if ((isClicking || !rightClick.get()) && !autoTotem.isLocked() && !item.isOffhand()) {
            InvUtils.move().from(item.slot()).toOffhand();
            sentMessage = false;
        }
    } else if (!isClicking && rightClick.get()) {
        if (autoTotem.isActive()) {
            FindItemResult totem = InvUtils.find(itemStack -> itemStack.getItem() == Items.TOTEM_OF_UNDYING, hotbar.get() ? 0 : 9, 35);
            if (totem.found() && !totem.isOffhand())
                InvUtils.move().from(totem.slot()).toOffhand();
        } else {
            FindItemResult empty = InvUtils.find(ItemStack::isEmpty, hotbar.get() ? 0 : 9, 35);
            if (empty.found())
                InvUtils.move().fromOffhand().to(empty.slot());
        }
    }
}
Also used : SettingGroup(mathax.client.settings.SettingGroup) BoolSetting(mathax.client.settings.BoolSetting) PlayerUtils(mathax.client.utils.player.PlayerUtils) net.minecraft.item(net.minecraft.item) EventHandler(mathax.client.eventbus.EventHandler) MouseButtonEvent(mathax.client.events.mathax.MouseButtonEvent) InvUtils(mathax.client.utils.player.InvUtils) Setting(mathax.client.settings.Setting) TickEvent(mathax.client.events.world.TickEvent) EnumSetting(mathax.client.settings.EnumSetting) GLFW_MOUSE_BUTTON_RIGHT(org.lwjgl.glfw.GLFW.GLFW_MOUSE_BUTTON_RIGHT) KeyAction(mathax.client.utils.misc.input.KeyAction) FindItemResult(mathax.client.utils.player.FindItemResult) Categories(mathax.client.systems.modules.Categories) Modules(mathax.client.systems.modules.Modules) Module(mathax.client.systems.modules.Module) FindItemResult(mathax.client.utils.player.FindItemResult) EventHandler(mathax.client.eventbus.EventHandler)

Aggregations

FindItemResult (mathax.client.utils.player.FindItemResult)30 EventHandler (mathax.client.eventbus.EventHandler)21 BlockPos (net.minecraft.util.math.BlockPos)13 InvUtils (mathax.client.utils.player.InvUtils)5 ItemStack (net.minecraft.item.ItemStack)5 ArrayList (java.util.ArrayList)4 TickEvent (mathax.client.events.world.TickEvent)4 Categories (mathax.client.systems.modules.Categories)4 Module (mathax.client.systems.modules.Module)4 mathax.client.settings (mathax.client.settings)3 PlayerUtils (mathax.client.utils.player.PlayerUtils)3 BlockUtils (mathax.client.utils.world.BlockUtils)3 Block (net.minecraft.block.Block)3 Blocks (net.minecraft.block.Blocks)3 BlockItem (net.minecraft.item.BlockItem)3 Items (net.minecraft.item.Items)3 Direction (net.minecraft.util.math.Direction)3 Comparator (java.util.Comparator)2 List (java.util.List)2 MatHax (mathax.client.MatHax)2