Search in sources :

Example 1 with GuiCrafting

use of net.minecraft.client.gui.inventory.GuiCrafting in project Spark-Client by Spark-Client-Development.

the class ShulkerAura method onUpdate.

@SubscribeEvent
void onUpdate(PlayerUpdateEvent event) {
    if (targetPos == null) {
        disable();
        return;
    }
    boolean disable = true;
    for (EntityPlayer e : mc.world.playerEntities) {
        if (!e.isDead)
            if (new BlockPos(e.posX, e.posY + 2, e.posZ).equals(targetPos)) {
                disable = false;
                break;
            }
    }
    if (disable) {
        Spark.sendInfo("No more target in the trap");
        this.disable();
    }
    // trap player on sides...
    for (EnumFacing facing : EnumFacing.HORIZONTALS) {
        BlockPos pos = targetPos.down().add(facing.getDirectionVec());
        Block block = mc.world.getBlockState(pos).getBlock();
        if (block != Blocks.AIR)
            continue;
        BlockInteractUtil.BlockPlaceResult r = BlockInteractUtil.tryPlaceBlock(pos, new SpecBlockSwitchItem(Blocks.OBSIDIAN), false, true, 2);
        if (r != BlockInteractUtil.BlockPlaceResult.FAILED)
            return;
    }
    // trap the upperblock...
    if (mc.world.getBlockState(targetPos).getBlock() == Blocks.AIR) {
        BlockInteractUtil.BlockPlaceResult r = BlockInteractUtil.tryPlaceBlock(targetPos, new SpecBlockSwitchItem(Blocks.OBSIDIAN), false, true, 2);
        if (r == BlockInteractUtil.BlockPlaceResult.FAILED) {
            // failed lets add support
            for (EnumFacing facing : EnumFacing.HORIZONTALS) {
                if (targetFacing == facing || targetFacing == facing.getOpposite())
                    continue;
                BlockPos pos = targetPos.add(facing.getDirectionVec());
                Block block = mc.world.getBlockState(pos).getBlock();
                if (block != Blocks.AIR)
                    continue;
                BlockInteractUtil.BlockPlaceResult r2 = BlockInteractUtil.tryPlaceBlock(pos, new SpecBlockSwitchItem(Blocks.OBSIDIAN), false, true, 2);
                if (r2 != BlockInteractUtil.BlockPlaceResult.FAILED)
                    return;
            }
        } else
            return;
    }
    // check if the shulk is there
    if (mc.world.getBlockState(targetPos.offset(targetFacing).offset(targetFacing)).getBlock() instanceof BlockShulkerBox) {
        doShulkerAura();
    } else {
        flag = false;
        int slot = ItemSwitcher.FindStackInInventory(new ShulkerSwitchItem(), false);
        if ((slot != -1 && slot < 9) || !craft.getValue()) {
            BlockPos support = targetPos.add(targetFacing.getDirectionVec()).add(targetFacing.getDirectionVec()).add(targetFacing.getDirectionVec());
            if (mc.world.getBlockState(support).getBlock().isReplaceable(mc.world, support)) {
                if (BlockInteractUtil.tryPlaceBlock(support, new SpecBlockSwitchItem(Blocks.OBSIDIAN), false, true, 2) == BlockInteractUtil.BlockPlaceResult.FAILED) {
                    if (BlockInteractUtil.tryPlaceBlock(support.down(), new SpecBlockSwitchItem(Blocks.OBSIDIAN), false, true, 2) == BlockInteractUtil.BlockPlaceResult.FAILED) {
                        if (BlockInteractUtil.tryPlaceBlock(support.down().offset(targetFacing.getOpposite()), new SpecBlockSwitchItem(Blocks.OBSIDIAN), false, true, 2) == BlockInteractUtil.BlockPlaceResult.FAILED) {
                        // wtf i hope we never get here but nothing left to do but return ig
                        } else
                            return;
                    } else
                        return;
                } else
                    return;
            } else {
                BlockInteractUtil.tryPlaceBlockOnBlock(support.offset(targetFacing.getOpposite()), targetFacing.getOpposite(), new ShulkerSwitchItem(), false, true, 2, false);
            }
        } else if (craft.getValue() && mc.currentScreen == null && !flag) {
            boolean flag = false;
            BlockPos craftPos = null;
            int best = 0;
            for (BlockPos pos : WorldUtils.getSphere(PlayerUtil.getPlayerPosFloored(mc.player), 6, 6, 1)) {
                if (mc.world.getBlockState(pos).getBlock() == Blocks.CRAFTING_TABLE) {
                    Pair<Vec3d, EnumFacing> pair = BlockInteractUtil.getInteractPoint(pos);
                    if (pair != null) {
                        craftPos = pos;
                        flag = true;
                        break;
                    }
                }
                if (!BlockInteractUtil.canPlaceBlockAtPos(pos, true))
                    continue;
                if (BlockInteractUtil.getDirForPlacingBlockAtPos(pos) == null)
                    continue;
                int save = 0;
                for (EnumFacing enumFacing : EnumFacing.VALUES) {
                    if (HoleUtil.getBlockResistance(pos.offset(enumFacing)) == HoleUtil.BlockResistance.Resistant || HoleUtil.getBlockResistance(pos.offset(enumFacing)) == HoleUtil.BlockResistance.Unbreakable)
                        save++;
                }
                if (craftPos == null || save > best || (save == best && mc.player.getDistanceSq(pos) < mc.player.getDistanceSq(craftPos))) {
                    best = save;
                    craftPos = pos;
                }
            }
            if (flag || BlockInteractUtil.tryPlaceBlock(craftPos, new SpecBlockSwitchItem(Blocks.CRAFTING_TABLE), false, true, 2) == BlockInteractUtil.BlockPlaceResult.PLACED) {
                Vec3d pos = new Vec3d(craftPos).add(0.5, 0.5, 0.5);
                List<Vec3d> vecs = RaytraceUtil.getVisiblePointsForBox(new AxisAlignedBB(craftPos));
                if (!vecs.isEmpty())
                    pos = PlayerUtil.getClosestPoint(vecs);
                final RayTraceResult result = mc.world.rayTraceBlocks(PlayerUtil.getEyePos(), pos, false, true, false);
                EnumFacing facing = (result == null || !craftPos.equals(result.getBlockPos()) || result.sideHit == null) ? EnumFacing.UP : result.sideHit;
                if (flag && !Spark.rotationManager.rotate(Spark.rotationManager.getLegitRotations(pos), AntiCheatConfig.INSTANCE.getBlockRotStep(), 2, true, false))
                    return;
                EnumHand hand = EnumHand.OFF_HAND;
                if (mc.player.getHeldItemOffhand().getItem() instanceof ItemEndCrystal && !(mc.player.getHeldItemMainhand().getItem() instanceof ItemEndCrystal))
                    hand = EnumHand.MAIN_HAND;
                mc.player.connection.sendPacket(new CPacketPlayerTryUseItemOnBlock(craftPos, facing, hand, (float) pos.x, (float) pos.y, (float) pos.z));
                state = 0;
            }
        } else if (craft.getValue() && mc.currentScreen instanceof GuiCrafting) {
            int id = mc.player.openContainer.windowId;
            if (mc.player.openContainer.getSlot(0).getStack().getItem() instanceof ItemShulkerBox) {
                if (state == 4) {
                    mc.playerController.windowClick(id, 0, 0, ClickType.PICKUP, mc.player);
                    mc.playerController.windowClick(id, 36 + shulkerSlot.getValue(), 0, ClickType.PICKUP, mc.player);
                    mc.player.closeScreen();
                    state++;
                } else
                    state++;
            } else {
                if (state == 0) {
                    shell = -1;
                    chest = -1;
                    for (int i = 10; i < 46; i++) {
                        ItemStack stack = mc.player.openContainer.getSlot(i).getStack();
                        if (stack.getItem() == Items.SHULKER_SHELL)
                            shell = i;
                        if (stack.getItem() == Item.getItemFromBlock(Blocks.CHEST))
                            chest = i;
                        if (chest > 0 && shell > 0)
                            break;
                    }
                    if (shell == -1 || chest == -1) {
                        disable();
                    } else
                        state++;
                } else if (state == 1) {
                    if (shell == -1 || chest == -1) {
                        disable();
                    }
                    mc.playerController.windowClick(id, shell, 0, ClickType.PICKUP, mc.player);
                    mc.playerController.windowClick(id, 1, 1, ClickType.PICKUP, mc.player);
                    mc.playerController.windowClick(id, 7, 1, ClickType.PICKUP, mc.player);
                    mc.playerController.windowClick(id, shell, 0, ClickType.PICKUP, mc.player);
                    state++;
                } else if (state == 2) {
                    if (shell == -1 || chest == -1) {
                        disable();
                    }
                    mc.playerController.windowClick(id, chest, 0, ClickType.PICKUP, mc.player);
                    mc.playerController.windowClick(id, 4, 1, ClickType.PICKUP, mc.player);
                    mc.playerController.windowClick(id, chest, 0, ClickType.PICKUP, mc.player);
                    state++;
                }
            }
        }
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) GuiCrafting(net.minecraft.client.gui.inventory.GuiCrafting) EnumFacing(net.minecraft.util.EnumFacing) ItemShulkerBox(net.minecraft.item.ItemShulkerBox) RayTraceResult(net.minecraft.util.math.RayTraceResult) SpecBlockSwitchItem(me.wallhacks.spark.util.player.itemswitcher.itemswitchers.SpecBlockSwitchItem) ShulkerSwitchItem(me.wallhacks.spark.util.player.itemswitcher.itemswitchers.ShulkerSwitchItem) ItemEndCrystal(net.minecraft.item.ItemEndCrystal) Vec3d(net.minecraft.util.math.Vec3d) CPacketPlayerTryUseItemOnBlock(net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock) BlockShulkerBox(net.minecraft.block.BlockShulkerBox) BlockInteractUtil(me.wallhacks.spark.util.player.BlockInteractUtil) EnumHand(net.minecraft.util.EnumHand) EntityPlayer(net.minecraft.entity.player.EntityPlayer) CPacketPlayerTryUseItemOnBlock(net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) List(java.util.List) ItemStack(net.minecraft.item.ItemStack) Pair(me.wallhacks.spark.util.objects.Pair) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 2 with GuiCrafting

use of net.minecraft.client.gui.inventory.GuiCrafting in project 3arthh4ck by 3arthqu4ke.

the class BedBomb method doBedCraft.

public void doBedCraft() {
    int woolSlot = findInventoryWool();
    int woodSlot = InventoryUtil.findInInventory(s -> s.getItem() instanceof ItemBlock && ((ItemBlock) s.getItem()).getBlock() instanceof BlockPlanks, true);
    if (woolSlot == -1 || woodSlot == -1) {
        if (mc.currentScreen instanceof GuiCrafting) {
            mc.displayGuiScreen(null);
            mc.currentScreen = null;
        }
        return;
    }
    if (placeCraftingTable.getValue() && getBlockSphere(tableRange.getValue() - 1, BlockWorkbench.class).size() == 0) {
        List<BlockPos> targets = getSphere(mc.player.getPosition(), tableRange.getValue(), tableRange.getValue().intValue(), false, true, 0).stream().filter(pos -> isPositionPlaceable(pos, false) == 3).sorted(Comparator.comparingInt(pos -> -safety(pos))).collect(Collectors.toList());
        if (!targets.isEmpty()) {
            BlockPos target = targets.get(0);
            int tableSlot = InventoryUtil.findInInventory(s -> s.getItem() instanceof ItemBlock && ((ItemBlock) s.getItem()).getBlock() instanceof BlockPlanks, true);
            if (tableSlot != -1) {
                mc.player.inventory.currentItem = tableSlot;
                /*float[] rotations = RotationUtil.getLegitRotations(new Vec3d(target));
                    yaw.set(rotations[0]);
                    if(rotate.getValue()) {
                        shouldRotate.set(true);
                        pitch.set(rotations[1]);
                    }*/
                placeBlock(target, EnumHand.MAIN_HAND, rotate.getValue(), true, false);
            } else {
                if (craftTable.getValue()) {
                    craftTable();
                }
                tableSlot = InventoryUtil.findInHotbar(s -> s.getItem() instanceof ItemBlock && ((ItemBlock) s.getItem()).getBlock() instanceof BlockPlanks);
                if (tableSlot != -1 && tableSlot != -2) {
                    mc.player.inventory.currentItem = tableSlot;
                    placeBlock(target, EnumHand.MAIN_HAND, rotate.getValue(), true, false);
                }
            /*float[] rotations = RotationUtil.getLegitRotations(new Vec3d(target));
                    yaw.set(rotations[0]);
                    if(rotate.getValue()) {
                        shouldRotate.set(true);
                        pitch.set(rotations[1]);
                    }*/
            }
        }
    }
    if (openCraftingTable.getValue()) {
        List<BlockPos> tables = getBlockSphere(tableRange.getValue(), BlockWorkbench.class);
        tables.sort(Comparator.comparingDouble(pos -> mc.player.getDistanceSq(pos)));
        if (!tables.isEmpty() && !(mc.currentScreen instanceof GuiCrafting)) {
            BlockPos target = tables.get(0);
            mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.STOP_SNEAKING));
            // BlockUtil.rightClickBlock(target, tableRange.getValue(), rotate.getValue() && !place.getValue(), EnumHand.MAIN_HAND, yaw, pitch, shouldRotate, true);
            if (mc.player.getDistanceSq(target) > MathUtil.square(breakRange.getValue()))
                return;
            // mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.STOP_SNEAKING));
            // .add(0.5, 0.5, 0.5);
            Vec3d hitVec = new Vec3d(target);
            // BlockUtil.rightClickBlockLegit(maxPos, range.getValue(), rotate.getValue() && !place.getValue(), EnumHand.MAIN_HAND, yaw, pitch, shouldRotate, true);
            float[] rotations = getLegitRotations(hitVec);
            yaw.set(rotations[0]);
            if (rotate.getValue()) {
                shouldRotate.set(true);
                pitch.set(rotations[1]);
            }
            RayTraceResult result = mc.world.rayTraceBlocks(new Vec3d(mc.player.posX, mc.player.posY + mc.player.getEyeHeight(), mc.player.posZ), new Vec3d(target.getX() + .5, target.getY() - .5d, target.getZ() + .5));
            // if(mc.player.isSneaking()) {
            EnumFacing facing = (result == null || result.sideHit == null) ? EnumFacing.UP : result.sideHit;
            rightClickBlock(target, hitVec, EnumHand.MAIN_HAND, facing, true);
            // mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.START_SNEAKING));
            // }
            breakTimer.reset();
            if (mc.player.isSneaking()) {
                mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.START_SNEAKING));
            }
        }
        if (mc.currentScreen instanceof GuiCrafting) {
            shouldCraft = true;
        } else {
            shouldCraft = false;
        }
        craftStage = 0;
        craftTimer.reset();
    /*if (mc.currentScreen instanceof GuiCrafting) {
                mc.player.connection.sendPacket(new CPacketPlaceRecipe(mc.player.openContainer.windowId, CraftingManager.getRecipe(new ResourceLocation("white_bed")), true));
                mc.playerController.windowClick(mc.player.openContainer.windowId, 0, 0, ClickType.QUICK_MOVE, mc.player);
                mc.playerController.updateController();
            }*/
    }
}
Also used : BlockWorkbench(net.minecraft.block.BlockWorkbench) EnumHand(net.minecraft.util.EnumHand) StopWatch(me.earth.earthhack.impl.util.math.StopWatch) BlockTallGrass(net.minecraft.block.BlockTallGrass) SpecialBlocks(me.earth.earthhack.impl.util.minecraft.blocks.SpecialBlocks) BlockLiquid(net.minecraft.block.BlockLiquid) MathUtil(me.earth.earthhack.impl.util.math.MathUtil) SimpleData(me.earth.earthhack.impl.util.client.SimpleData) Block(net.minecraft.block.Block) Vec3d(net.minecraft.util.math.Vec3d) Stage(me.earth.earthhack.api.event.events.Stage) Map(java.util.Map) InventoryUtil(me.earth.earthhack.impl.util.minecraft.InventoryUtil) GuiContainer(net.minecraft.client.gui.inventory.GuiContainer) NonNullList(net.minecraft.util.NonNullList) EntityItem(net.minecraft.entity.item.EntityItem) BlockSnow(net.minecraft.block.BlockSnow) NumberSetting(me.earth.earthhack.api.setting.settings.NumberSetting) Collectors(java.util.stream.Collectors) List(java.util.List) TileEntityBed(net.minecraft.tileentity.TileEntityBed) EntityPlayer(net.minecraft.entity.player.EntityPlayer) CPacketEntityAction(net.minecraft.network.play.client.CPacketEntityAction) ICPacketPlayer(me.earth.earthhack.impl.core.mixins.network.client.ICPacketPlayer) CPacketPlayer(net.minecraft.network.play.client.CPacketPlayer) Blocks(net.minecraft.init.Blocks) AtomicDouble(com.google.common.util.concurrent.AtomicDouble) BooleanSetting(me.earth.earthhack.api.setting.settings.BooleanSetting) AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) EventListener(me.earth.earthhack.api.event.bus.EventListener) Module(me.earth.earthhack.api.module.Module) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Setting(me.earth.earthhack.api.setting.Setting) HashMap(java.util.HashMap) MotionUpdateEvent(me.earth.earthhack.impl.event.events.network.MotionUpdateEvent) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack) RayTraceResult(net.minecraft.util.math.RayTraceResult) PositionUtil(me.earth.earthhack.impl.util.math.position.PositionUtil) EntityXPOrb(net.minecraft.entity.item.EntityXPOrb) CPacketPlayerTryUseItemOnBlock(net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock) BlockPlanks(net.minecraft.block.BlockPlanks) Category(me.earth.earthhack.api.module.util.Category) Entity(net.minecraft.entity.Entity) CPacketPlayerListener(me.earth.earthhack.impl.event.listeners.CPacketPlayerListener) GuiCrafting(net.minecraft.client.gui.inventory.GuiCrafting) BlockAir(net.minecraft.block.BlockAir) Items(net.minecraft.init.Items) BlockFire(net.minecraft.block.BlockFire) EnumFacing(net.minecraft.util.EnumFacing) BlockPos(net.minecraft.util.math.BlockPos) PacketEvent(me.earth.earthhack.impl.event.events.network.PacketEvent) DamageUtil(me.earth.earthhack.impl.util.minecraft.DamageUtil) IBlockState(net.minecraft.block.state.IBlockState) Material(net.minecraft.block.material.Material) MathHelper(net.minecraft.util.math.MathHelper) EnumSetting(me.earth.earthhack.api.setting.settings.EnumSetting) BlockDeadBush(net.minecraft.block.BlockDeadBush) TileEntity(net.minecraft.tileentity.TileEntity) ItemBlock(net.minecraft.item.ItemBlock) Comparator(java.util.Comparator) EntityUtil(me.earth.earthhack.impl.util.minecraft.entity.EntityUtil) ClickType(net.minecraft.inventory.ClickType) GuiCrafting(net.minecraft.client.gui.inventory.GuiCrafting) BlockWorkbench(net.minecraft.block.BlockWorkbench) EnumFacing(net.minecraft.util.EnumFacing) RayTraceResult(net.minecraft.util.math.RayTraceResult) ItemBlock(net.minecraft.item.ItemBlock) BlockPlanks(net.minecraft.block.BlockPlanks) Vec3d(net.minecraft.util.math.Vec3d) CPacketEntityAction(net.minecraft.network.play.client.CPacketEntityAction) BlockPos(net.minecraft.util.math.BlockPos)

Example 3 with GuiCrafting

use of net.minecraft.client.gui.inventory.GuiCrafting in project 3arthh4ck by 3arthqu4ke.

the class BedBomb method onUpdateWalkingPlayer.

public void onUpdateWalkingPlayer(MotionUpdateEvent event) {
    current = event;
    if ((mc.player.dimension != -1 && mc.player.dimension != 1)) {
        return;
    }
    if (event.getStage() == Stage.PRE) {
        doBedBomb();
        if (shouldCraft) {
            if (mc.currentScreen instanceof GuiCrafting) {
                int woolSlot = findInventoryWool();
                int woodSlot = InventoryUtil.findInInventory(s -> s.getItem() instanceof ItemBlock && ((ItemBlock) s.getItem()).getBlock() instanceof BlockPlanks, true);
                if (woolSlot == -1 || woodSlot == -1 || woolSlot == -2 || woodSlot == -2) {
                    mc.displayGuiScreen(null);
                    mc.currentScreen = null;
                    shouldCraft = false;
                    return;
                }
                if (craftStage > 1 && !one) {
                    mc.playerController.windowClick(((GuiContainer) mc.currentScreen).inventorySlots.windowId, woolSlot, 0, ClickType.PICKUP, mc.player);
                    mc.playerController.windowClick(((GuiContainer) mc.currentScreen).inventorySlots.windowId, 1, 1, ClickType.PICKUP, mc.player);
                    mc.playerController.windowClick(((GuiContainer) mc.currentScreen).inventorySlots.windowId, woolSlot, 0, ClickType.PICKUP, mc.player);
                    one = true;
                } else if (craftStage > (1 + craftDelay.getValue()) && !two) {
                    mc.playerController.windowClick(((GuiContainer) mc.currentScreen).inventorySlots.windowId, woolSlot, 0, ClickType.PICKUP, mc.player);
                    mc.playerController.windowClick(((GuiContainer) mc.currentScreen).inventorySlots.windowId, 2, 1, ClickType.PICKUP, mc.player);
                    mc.playerController.windowClick(((GuiContainer) mc.currentScreen).inventorySlots.windowId, woolSlot, 0, ClickType.PICKUP, mc.player);
                    two = true;
                } else if (craftStage > (1 + craftDelay.getValue() * 2) && !three) {
                    mc.playerController.windowClick(((GuiContainer) mc.currentScreen).inventorySlots.windowId, woolSlot, 0, ClickType.PICKUP, mc.player);
                    mc.playerController.windowClick(((GuiContainer) mc.currentScreen).inventorySlots.windowId, 3, 1, ClickType.PICKUP, mc.player);
                    mc.playerController.windowClick(((GuiContainer) mc.currentScreen).inventorySlots.windowId, woolSlot, 0, ClickType.PICKUP, mc.player);
                    three = true;
                } else if (craftStage > (1 + craftDelay.getValue() * 3) && !four) {
                    mc.playerController.windowClick(((GuiContainer) mc.currentScreen).inventorySlots.windowId, woodSlot, 0, ClickType.PICKUP, mc.player);
                    mc.playerController.windowClick(((GuiContainer) mc.currentScreen).inventorySlots.windowId, 4, 1, ClickType.PICKUP, mc.player);
                    mc.playerController.windowClick(((GuiContainer) mc.currentScreen).inventorySlots.windowId, woodSlot, 0, ClickType.PICKUP, mc.player);
                    four = true;
                } else if (craftStage > (1 + craftDelay.getValue() * 4) && !five) {
                    mc.playerController.windowClick(((GuiContainer) mc.currentScreen).inventorySlots.windowId, woodSlot, 0, ClickType.PICKUP, mc.player);
                    mc.playerController.windowClick(((GuiContainer) mc.currentScreen).inventorySlots.windowId, 5, 1, ClickType.PICKUP, mc.player);
                    mc.playerController.windowClick(((GuiContainer) mc.currentScreen).inventorySlots.windowId, woodSlot, 0, ClickType.PICKUP, mc.player);
                    five = true;
                } else if (craftStage > (1 + craftDelay.getValue() * 5) && !six) {
                    mc.playerController.windowClick(((GuiContainer) mc.currentScreen).inventorySlots.windowId, woodSlot, 0, ClickType.PICKUP, mc.player);
                    mc.playerController.windowClick(((GuiContainer) mc.currentScreen).inventorySlots.windowId, 6, 1, ClickType.PICKUP, mc.player);
                    mc.playerController.windowClick(((GuiContainer) mc.currentScreen).inventorySlots.windowId, woodSlot, 0, ClickType.PICKUP, mc.player);
                    recheckBedSlots(woolSlot, woodSlot);
                    mc.playerController.windowClick(((GuiContainer) mc.currentScreen).inventorySlots.windowId, 0, 0, ClickType.QUICK_MOVE, mc.player);
                    six = true;
                    one = false;
                    two = false;
                    three = false;
                    four = false;
                    five = false;
                    six = false;
                    craftStage = -2;
                    shouldCraft = false;
                }
                craftStage++;
            /*if (craftTimer.passedMs(craftDelay.getValue() * 10)) {
                        mc.playerController.windowClick(1, 0, 0, ClickType.QUICK_MOVE, mc.player);
                        shouldCraft = false;
                        craftTimer.reset();
                        return;
                    } else if (craftTimer.passedMs(craftDelay.getValue() * 9)) {
                        mc.playerController.windowClick(1, InventoryUtil.findEmptySlot(), 0, ClickType.PICKUP, mc.player);
                        return;
                    } else if (craftTimer.passedMs(craftDelay.getValue() * 8)) {
                        mc.playerController.windowClick(1, 6, 1, ClickType.PICKUP, mc.player);
                        return;
                    } else if (craftTimer.passedMs(craftDelay.getValue() * 7)) {
                        mc.playerController.windowClick(1, 5, 1, ClickType.PICKUP, mc.player);
                        return;
                    } else if (craftTimer.passedMs(craftDelay.getValue() * 6)) {
                        mc.playerController.windowClick(1, 4, 1, ClickType.PICKUP, mc.player);
                        return;
                    } else if (craftTimer.passedMs(craftDelay.getValue() * 5)) {
                        mc.playerController.windowClick(1, woodSlot, 0, ClickType.PICKUP, mc.player);
                        return;
                    } else if (craftTimer.passedMs(craftDelay.getValue() * 4)) {
                        mc.playerController.windowClick(1, 3, 1, ClickType.PICKUP, mc.player);
                        return;
                    } else if (craftTimer.passedMs(craftDelay.getValue() * 3)) {
                        mc.playerController.windowClick(1, 2, 1, ClickType.PICKUP, mc.player);
                        return;
                    } else if (craftTimer.passedMs(craftDelay.getValue() * 2)) {
                        mc.playerController.windowClick(1, 1, 1, ClickType.PICKUP, mc.player);
                        return;
                    } else if (craftTimer.passedMs(craftDelay.getValue())) {
                        mc.playerController.windowClick(1, woolSlot, 0, ClickType.PICKUP, mc.player);
                        return;
                    }*/
            // if (lastCraftStage == craftStage) return;
            /*switch(craftStage) {
                        case 0:
                            mc.playerController.windowClick(1, woolSlot, 0, ClickType.PICKUP, mc.player);
                            incrementCraftStage();
                            break;
                        case 1:
                            mc.playerController.windowClick(1, 1, 1, ClickType.PICKUP, mc.player);
                            incrementCraftStage();
                            break;
                        case 2:
                            mc.playerController.windowClick(1, 2, 1, ClickType.PICKUP, mc.player);
                            incrementCraftStage();
                            break;
                        case 3:
                            mc.playerController.windowClick(1, 3, 1, ClickType.PICKUP, mc.player);
                            incrementCraftStage();
                            break;
                        case 4:
                            mc.playerController.windowClick(1, woodSlot, 0, ClickType.PICKUP, mc.player);
                            incrementCraftStage();
                            break;
                        case 5:
                            mc.playerController.windowClick(1, 4, 1, ClickType.PICKUP, mc.player);
                            incrementCraftStage();
                            break;
                        case 6:
                            mc.playerController.windowClick(1, 5, 1, ClickType.PICKUP, mc.player);
                            incrementCraftStage();
                            break;
                        case 7:
                            mc.playerController.windowClick(1, 6, 1, ClickType.PICKUP, mc.player);
                            incrementCraftStage();
                            break;
                        case 8:
                            mc.playerController.windowClick(1, InventoryUtil.findEmptySlot(), 0, ClickType.PICKUP, mc.player);
                            incrementCraftStage();
                            break;
                        case 9:
                            mc.playerController.windowClick(1, 0, 0, ClickType.QUICK_MOVE, mc.player);
                            incrementCraftStage();
                            shouldCraft = false;
                            break;
                    }*/
            }
        }
    } else if (event.getStage() == Stage.POST && finalPos != null) {
        // ökjlsdhblknsö
        Vec3d hitVec = new Vec3d(finalPos.down()).add(0.5, 0.5, 0.5).add(new Vec3d(finalFacing.getOpposite().getDirectionVec()).scale(0.5));
        mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.START_SNEAKING));
        InventoryUtil.switchTo(bedSlot);
        rightClickBlock(finalPos.down(), hitVec, bedSlot == -2 ? EnumHand.OFF_HAND : EnumHand.MAIN_HAND, EnumFacing.UP, packet.getValue());
        mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.STOP_SNEAKING));
        placeTimer.reset();
        finalPos = null;
    }
}
Also used : CPacketEntityAction(net.minecraft.network.play.client.CPacketEntityAction) GuiCrafting(net.minecraft.client.gui.inventory.GuiCrafting) GuiContainer(net.minecraft.client.gui.inventory.GuiContainer) ItemBlock(net.minecraft.item.ItemBlock) BlockPlanks(net.minecraft.block.BlockPlanks) Vec3d(net.minecraft.util.math.Vec3d)

Aggregations

GuiCrafting (net.minecraft.client.gui.inventory.GuiCrafting)3 Vec3d (net.minecraft.util.math.Vec3d)3 List (java.util.List)2 Block (net.minecraft.block.Block)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 ItemStack (net.minecraft.item.ItemStack)2 CPacketPlayerTryUseItemOnBlock (net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock)2 EnumFacing (net.minecraft.util.EnumFacing)2 EnumHand (net.minecraft.util.EnumHand)2 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)2 BlockPos (net.minecraft.util.math.BlockPos)2 RayTraceResult (net.minecraft.util.math.RayTraceResult)2 AtomicDouble (com.google.common.util.concurrent.AtomicDouble)1 ArrayList (java.util.ArrayList)1 Comparator (java.util.Comparator)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 Collectors (java.util.stream.Collectors)1 EventListener (me.earth.earthhack.api.event.bus.EventListener)1