Search in sources :

Example 26 with EnumHand

use of net.minecraft.util.EnumHand in project Spark-Client by Spark-Client-Development.

the class CevBreaker method placeCrystalOnBlock.

public boolean placeCrystalOnBlock(BlockPos bestPos) {
    Vec3d pos = CrystalUtil.getRotationPos(false, bestPos, null);
    final RayTraceResult result = mc.world.rayTraceBlocks(PlayerUtil.getEyePos(), pos, false, true, false);
    EnumFacing facing = (result == null || !bestPos.equals(result.getBlockPos()) || result.sideHit == null) ? EnumFacing.UP : result.sideHit;
    Vec3d v = new Vec3d(bestPos).add(0.5, 0.5, 0.5).add(new Vec3d(facing.getDirectionVec()).scale(0.5));
    if (result != null && bestPos.equals(result.getBlockPos()) && result.hitVec != null)
        v = result.hitVec;
    if (bestPos.getY() >= 254)
        facing = EnumFacing.EAST;
    // offhand
    EnumHand hand = Spark.switchManager.Switch(new SpecItemSwitchItem(Items.END_CRYSTAL), ItemSwitcher.usedHand.Both, switchingMode.getValue());
    if (hand == null)
        return false;
    // rotate if needed
    if (!Spark.rotationManager.rotate(Spark.rotationManager.getLegitRotations(pos), AntiCheatConfig.getInstance().getCrystalRotStep(), 4, false, true))
        return false;
    // send packet
    mc.player.connection.sendPacket(new CPacketPlayerTryUseItemOnBlock(bestPos, facing, hand, (float) v.x, (float) v.y, (float) v.z));
    // swing
    switch(AntiCheatConfig.getInstance().crystalPlaceSwing.getValue()) {
        case "Normal":
            mc.player.swingArm(hand);
            break;
        case "Packet":
            mc.player.connection.sendPacket(new CPacketAnimation(hand));
            break;
    }
    if (render.getValue())
        new FadePos(bestPos, fill, true);
    return true;
}
Also used : FadePos(me.wallhacks.spark.util.objects.FadePos) SpecItemSwitchItem(me.wallhacks.spark.util.player.itemswitcher.itemswitchers.SpecItemSwitchItem) EnumFacing(net.minecraft.util.EnumFacing) EnumHand(net.minecraft.util.EnumHand) CPacketAnimation(net.minecraft.network.play.client.CPacketAnimation) CPacketPlayerTryUseItemOnBlock(net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock)

Example 27 with EnumHand

use of net.minecraft.util.EnumHand 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 28 with EnumHand

use of net.minecraft.util.EnumHand in project Spark-Client by Spark-Client-Development.

the class AutoWither method onUpdate.

@SubscribeEvent
void onUpdate(PlayerUpdateEvent event) {
    if (autoName.isOn()) {
        for (Entity entity : mc.world.loadedEntityList) {
            if (entity instanceof EntityWither && mc.player.getDistance(entity) < 4) {
                EntityWither w = (EntityWither) entity;
                if (w.getDisplayName().getUnformattedComponentText().equalsIgnoreCase("Wither")) {
                    EnumHand hand = Spark.switchManager.Switch(new SpecItemSwitchItem(Items.NAME_TAG), ItemSwitcher.usedHand.Both, AntiCheatConfig.getInstance().getBlockPlaceSwitchType());
                    if (hand != null) {
                        Vec3d lookAt = RaytraceUtil.getPointToLookAtEntity(w);
                        if (lookAt == null)
                            lookAt = w.boundingBox.getCenter();
                        if (rotateForName.isOn())
                            if (!Spark.rotationManager.rotate(Spark.rotationManager.getLegitRotations(lookAt), 80, 2, false))
                                return;
                        mc.playerController.interactWithEntity(mc.player, w, hand);
                        return;
                    }
                }
            }
        }
    }
    if (placeWither != null) {
        int placed = 0;
        for (int i = 0; i < placeWither.size(); i++) {
            BlockPos p = placeWither.get(i);
            if (PlayerUtil.getDistance(p) > 5) {
                placeWither = null;
                return;
            }
            if (mc.world.getBlockState(p).getBlock().material.isReplaceable()) {
                isDone = 20;
                if (placed >= blocksPerTick.getValue())
                    return;
                BlockInteractUtil.BlockPlaceResult res = BlockInteractUtil.tryPlaceBlock(p, new SpecBlockSwitchItem(i < 4 ? Blocks.SOUL_SAND : Blocks.SKULL), true, true, 4, true);
                if (res == BlockInteractUtil.BlockPlaceResult.PLACED) {
                    if (render.getValue())
                        new FadePos(p, fill, true);
                    placed++;
                } else if (res == BlockInteractUtil.BlockPlaceResult.WAIT)
                    return;
            }
        }
        if (isDone <= 0) {
            placeWither = null;
            if (witherPlaceMode.isValueName("ClickSkull"))
                Spark.switchManager.Switch(new SpecItemSwitchItem(Items.SKULL), ItemSwitcher.usedHand.Both);
        } else
            isDone--;
    } else if (placeWither == null) {
        if (witherPlaceMode.isValueName("Toggle"))
            setEnabled(false);
        else if (witherPlaceMode.isValueName("Walk") && mc.player.onGround) {
            int x = (int) Math.round(Math.max(-1, Math.min(1, (mc.player.posX - mc.player.lastTickPosX) * 22)));
            int y = (int) Math.round(Math.max(-1, Math.min(1, (mc.player.posZ - mc.player.lastTickPosZ) * 22)));
            if (x != 0 || y != 0) {
                BlockPos pos = PlayerUtil.getPlayerPosFloored(mc.player).add(-x * 2, -1, -y * 2);
                PlaceWitherAtPos(pos);
            }
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) FadePos(me.wallhacks.spark.util.objects.FadePos) SpecItemSwitchItem(me.wallhacks.spark.util.player.itemswitcher.itemswitchers.SpecItemSwitchItem) BlockInteractUtil(me.wallhacks.spark.util.player.BlockInteractUtil) EnumHand(net.minecraft.util.EnumHand) BlockPos(net.minecraft.util.math.BlockPos) MBlockPos(com.github.lunatrius.core.util.math.MBlockPos) SpecBlockSwitchItem(me.wallhacks.spark.util.player.itemswitcher.itemswitchers.SpecBlockSwitchItem) EntityWither(net.minecraft.entity.boss.EntityWither) Vec3d(net.minecraft.util.math.Vec3d) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 29 with EnumHand

use of net.minecraft.util.EnumHand in project Spark-Client by Spark-Client-Development.

the class BlockInteractUtil method tryPlaceBlockOnBlock.

public static BlockPlaceResult tryPlaceBlockOnBlock(BlockPos pos, EnumFacing face, BlockSwitchItem switcher, ItemSwitcher.switchType switchType, boolean clientSided, boolean checkEntities, int rotationStayTicks, boolean allowSendMultipleRotPacket) {
    if (!mc.world.getBlockState(pos).getMaterial().isReplaceable())
        return BlockPlaceResult.FAILED;
    Item willuse = Spark.switchManager.predictItem(switcher, ItemSwitcher.usedHand.Both, switchType);
    if (!(willuse instanceof ItemBlock) && !(willuse instanceof ItemSkull) && willuse != Items.SKULL && willuse != Items.WATER_BUCKET && willuse != Items.LAVA_BUCKET)
        return BlockPlaceResult.FAILED;
    if (checkEntities && !blockCollisionCheck(pos, ((ItemBlock) willuse).getBlock()))
        return BlockPlaceResult.FAILED;
    if (face == null)
        return BlockPlaceResult.FAILED;
    BlockPos placeOn = pos.offset(face, -1);
    if (mc.world.getBlockState(placeOn).getBlock().isReplaceable(mc.world, placeOn))
        return BlockPlaceResult.FAILED;
    Vec3d hitVec = getPointOnBlockFace(placeOn, face);
    if (hitVec == null)
        return BlockPlaceResult.FAILED;
    EnumHand hand = Spark.switchManager.Switch(switcher, ItemSwitcher.usedHand.Both, switchType);
    if (hand == null)
        return BlockPlaceResult.FAILED;
    if (AntiCheatConfig.getInstance().getBlockRotate())
        if (!Spark.rotationManager.rotate(Spark.rotationManager.getLegitRotations(hitVec), AntiCheatConfig.getInstance().getBlockRotStep(), rotationStayTicks, allowSendMultipleRotPacket))
            return BlockPlaceResult.WAIT;
    mc.playerController.syncCurrentPlayItem();
    return processRightClickBlockForPlace(placeOn, face, clientSided, hand, hitVec) ? BlockPlaceResult.PLACED : BlockPlaceResult.FAILED;
}
Also used : SpecBlockSwitchItem(me.wallhacks.spark.util.player.itemswitcher.itemswitchers.SpecBlockSwitchItem) Item(net.minecraft.item.Item) EntityItem(net.minecraft.entity.item.EntityItem) BlockSwitchItem(me.wallhacks.spark.util.player.itemswitcher.itemswitchers.BlockSwitchItem) EnumHand(net.minecraft.util.EnumHand) BlockPos(net.minecraft.util.math.BlockPos) ItemBlock(net.minecraft.item.ItemBlock) Vec3d(net.minecraft.util.math.Vec3d) ItemSkull(net.minecraft.item.ItemSkull)

Example 30 with EnumHand

use of net.minecraft.util.EnumHand in project Spark-Client by Spark-Client-Development.

the class BlockInteractUtil method tryPlaceBlock.

public static BlockPlaceResult tryPlaceBlock(BlockPos pos, BlockSwitchItem switcher, ItemSwitcher.switchType switchType, boolean clientSided, boolean checkEntities, int rotationStayTicks, boolean allowSendMultipleRotPacket) {
    if (!mc.world.getBlockState(pos).getMaterial().isReplaceable())
        return BlockPlaceResult.FAILED;
    Item willuse = null;
    if (switcher != null) {
        willuse = Spark.switchManager.predictItem(switcher, ItemSwitcher.usedHand.Both, switchType);
        if (!(willuse instanceof ItemBlock) && !(willuse instanceof ItemSkull) && willuse != Items.SKULL && willuse != Items.WATER_BUCKET && willuse != Items.LAVA_BUCKET)
            return BlockPlaceResult.FAILED;
    }
    if (checkEntities && !blockCollisionCheck(pos, willuse == null || !(willuse instanceof ItemBlock) ? null : ((ItemBlock) willuse).getBlock()))
        return BlockPlaceResult.FAILED;
    EnumFacing face = getDirForPlacingBlockAtPos(pos);
    if (face == null)
        return BlockPlaceResult.FAILED;
    BlockPos placeOn = pos.offset(face, -1);
    Vec3d hitVec = getPointOnBlockFace(placeOn, face);
    if (hitVec == null)
        return BlockPlaceResult.FAILED;
    EnumHand hand = Spark.switchManager.Switch(switcher, ItemSwitcher.usedHand.Both, switchType);
    if (hand == null)
        return BlockPlaceResult.FAILED;
    if (AntiCheatConfig.getInstance().getBlockRotate())
        if (!Spark.rotationManager.rotate(Spark.rotationManager.getLegitRotations(hitVec), AntiCheatConfig.getInstance().getBlockRotStep(), rotationStayTicks, allowSendMultipleRotPacket))
            return BlockPlaceResult.WAIT;
    mc.playerController.syncCurrentPlayItem();
    return processRightClickBlockForPlace(placeOn, face, clientSided, hand, hitVec) ? BlockPlaceResult.PLACED : BlockPlaceResult.FAILED;
}
Also used : SpecBlockSwitchItem(me.wallhacks.spark.util.player.itemswitcher.itemswitchers.SpecBlockSwitchItem) Item(net.minecraft.item.Item) EntityItem(net.minecraft.entity.item.EntityItem) BlockSwitchItem(me.wallhacks.spark.util.player.itemswitcher.itemswitchers.BlockSwitchItem) EnumFacing(net.minecraft.util.EnumFacing) EnumHand(net.minecraft.util.EnumHand) BlockPos(net.minecraft.util.math.BlockPos) ItemBlock(net.minecraft.item.ItemBlock) Vec3d(net.minecraft.util.math.Vec3d) ItemSkull(net.minecraft.item.ItemSkull)

Aggregations

EnumHand (net.minecraft.util.EnumHand)99 ItemStack (net.minecraft.item.ItemStack)56 EntityPlayer (net.minecraft.entity.player.EntityPlayer)48 BlockPos (net.minecraft.util.math.BlockPos)36 EnumFacing (net.minecraft.util.EnumFacing)25 World (net.minecraft.world.World)24 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)20 EntityLivingBase (net.minecraft.entity.EntityLivingBase)18 Entity (net.minecraft.entity.Entity)17 Item (net.minecraft.item.Item)17 Vec3d (net.minecraft.util.math.Vec3d)16 TileEntity (net.minecraft.tileentity.TileEntity)15 IBlockState (net.minecraft.block.state.IBlockState)14 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)14 RayTraceResult (net.minecraft.util.math.RayTraceResult)13 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)13 Block (net.minecraft.block.Block)12 List (java.util.List)11 EnumActionResult (net.minecraft.util.EnumActionResult)11 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)9