Search in sources :

Example 1 with BedItem

use of net.minecraft.item.BedItem 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 BedItem

use of net.minecraft.item.BedItem 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 3 with BedItem

use of net.minecraft.item.BedItem in project Client by MatHax.

the class BedHud method render.

@Override
public void render(HudRenderer renderer) {
    double x = box.getX();
    double y = box.getY();
    if (isInEditor())
        RenderUtils.drawItem(Items.RED_BED.getDefaultStack(), (int) x, (int) y, scale.get(), true);
    else if (InvUtils.find(itemStack -> itemStack.getItem() instanceof BedItem).count() > 0)
        RenderUtils.drawItem(new ItemStack(Items.RED_BED, InvUtils.find(itemStack -> itemStack.getItem() instanceof BedItem).count()), (int) x, (int) y, scale.get(), true);
}
Also used : SettingGroup(mathax.client.settings.SettingGroup) InvUtils(mathax.client.utils.player.InvUtils) ItemStack(net.minecraft.item.ItemStack) DoubleSetting(mathax.client.settings.DoubleSetting) Setting(mathax.client.settings.Setting) RenderUtils(mathax.client.utils.render.RenderUtils) BedItem(net.minecraft.item.BedItem) HudRenderer(mathax.client.systems.hud.HudRenderer) Items(net.minecraft.item.Items) HUD(mathax.client.systems.hud.HUD) HudElement(mathax.client.systems.hud.HudElement) BedItem(net.minecraft.item.BedItem) ItemStack(net.minecraft.item.ItemStack)

Aggregations

BedItem (net.minecraft.item.BedItem)3 RecipeResultCollection (net.minecraft.client.gui.screen.recipebook.RecipeResultCollection)2 CraftingScreenHandler (net.minecraft.screen.CraftingScreenHandler)2 BlockPos (net.minecraft.util.math.BlockPos)2 EventHandler (mathax.client.eventbus.EventHandler)1 DoubleSetting (mathax.client.settings.DoubleSetting)1 Setting (mathax.client.settings.Setting)1 SettingGroup (mathax.client.settings.SettingGroup)1 HUD (mathax.client.systems.hud.HUD)1 HudElement (mathax.client.systems.hud.HudElement)1 HudRenderer (mathax.client.systems.hud.HudRenderer)1 FindItemResult (mathax.client.utils.player.FindItemResult)1 InvUtils (mathax.client.utils.player.InvUtils)1 RenderUtils (mathax.client.utils.render.RenderUtils)1 FindItemResult (meteordevelopment.meteorclient.utils.player.FindItemResult)1 EventHandler (meteordevelopment.orbit.EventHandler)1 ItemStack (net.minecraft.item.ItemStack)1 Items (net.minecraft.item.Items)1