Search in sources :

Example 1 with SpecBlockSwitchItem

use of me.wallhacks.spark.util.player.itemswitcher.itemswitchers.SpecBlockSwitchItem 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 SpecBlockSwitchItem

use of me.wallhacks.spark.util.player.itemswitcher.itemswitchers.SpecBlockSwitchItem 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 3 with SpecBlockSwitchItem

use of me.wallhacks.spark.util.player.itemswitcher.itemswitchers.SpecBlockSwitchItem in project Spark-Client by Spark-Client-Development.

the class GriefHelper method OnUpdate.

@SubscribeEvent
void OnUpdate(PlayerUpdateEvent event) {
    if (cooldown > 0) {
        cooldown--;
        return;
    }
    BlockPos floored = PlayerUtil.getPlayerPosFloored(mc.player);
    for (int x = floored.getX() - 5; x <= floored.getX() + 5; x++) {
        if (x % spacing.getValue() == 0) {
            for (int z = floored.getZ() - 5; z <= floored.getZ() + 5; z++) {
                if (z % spacing.getValue() == 0) {
                    boolean lastCanPlaceOn = false;
                    for (int h = floored.getY() - 5; h <= floored.getY() + 5; h++) {
                        Block b = mc.world.getBlockState(new BlockPos(x, h, z)).getBlock();
                        if (b == Blocks.AIR || b == Blocks.TNT) {
                            if (lastCanPlaceOn) {
                                boolean shouldPlaceNext = false;
                                for (int y = 0; y + h <= floored.getY() + 5; y++) {
                                    if (y % spacing.getValue() == 0 || shouldPlaceNext) {
                                        shouldPlaceNext = false;
                                        BlockPos place = new BlockPos(x, y + h, z);
                                        if (mc.world.getBlockState(place).getBlock().material.isReplaceable()) {
                                            if (RedStoneCheck(place))
                                                continue;
                                            BlockInteractUtil.BlockPlaceResult res = BlockInteractUtil.tryPlaceBlock(place, new SpecBlockSwitchItem(Blocks.TNT), true, true, 4, false);
                                            if (res != BlockInteractUtil.BlockPlaceResult.FAILED) {
                                                if (res == BlockInteractUtil.BlockPlaceResult.PLACED) {
                                                    if (render.getValue())
                                                        new FadePos(place, fill, true);
                                                    cooldown = delay.getValue();
                                                }
                                                return;
                                            } else
                                                shouldPlaceNext = mc.world.getBlockState(place.add(0, 1, 0)).getBlock() != Blocks.TNT;
                                        }
                                    }
                                }
                                break;
                            }
                        } else {
                            lastCanPlaceOn = true;
                        }
                    }
                }
            }
        }
    }
}
Also used : FadePos(me.wallhacks.spark.util.objects.FadePos) BlockInteractUtil(me.wallhacks.spark.util.player.BlockInteractUtil) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) MBlockPos(com.github.lunatrius.core.util.math.MBlockPos) SpecBlockSwitchItem(me.wallhacks.spark.util.player.itemswitcher.itemswitchers.SpecBlockSwitchItem) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 4 with SpecBlockSwitchItem

use of me.wallhacks.spark.util.player.itemswitcher.itemswitchers.SpecBlockSwitchItem in project Spark-Client by Spark-Client-Development.

the class Printer method OnUpdate.

@SubscribeEvent
void OnUpdate(PlayerUpdateEvent event) {
    if (ClientProxy.schematic == null)
        return;
    if (cooldown > 0) {
        cooldown--;
        return;
    }
    final double dX = ClientProxy.playerPosition.x - ClientProxy.schematic.position.x;
    final double dY = ClientProxy.playerPosition.y - ClientProxy.schematic.position.y;
    final double dZ = ClientProxy.playerPosition.z - ClientProxy.schematic.position.z;
    final int x = (int) Math.floor(dX);
    final int y = (int) Math.floor(dY);
    final int z = (int) Math.floor(dZ);
    final int range = 5;
    final int minX = Math.max(0, x - range);
    final int maxX = Math.min(ClientProxy.schematic.getWidth() - 1, x + range);
    int minY = Math.max(0, y - range);
    int maxY = Math.min(ClientProxy.schematic.getHeight() - 1, y + range);
    final int minZ = Math.max(0, z - range);
    final int maxZ = Math.min(ClientProxy.schematic.getLength() - 1, z + range);
    if (minX > maxX || minY > maxY || minZ > maxZ) {
        return;
    }
    for (final MBlockPos p : BlockPosHelper.getAllInBoxXZY(minX, minY, minZ, maxX, maxY, maxZ)) {
        BlockPos worldpos = p.add(ClientProxy.schematic.position);
        if (mc.world.getBlockState(worldpos).getBlock().material.isReplaceable()) {
            Block b = ClientProxy.schematic.getBlockState(p).getBlock();
            if (b != Blocks.AIR) {
                BlockInteractUtil.BlockPlaceResult res = BlockInteractUtil.tryPlaceBlock(p, new SpecBlockSwitchItem(Blocks.TNT), true, true, 4, false);
                if (res != BlockInteractUtil.BlockPlaceResult.FAILED) {
                    if (res == BlockInteractUtil.BlockPlaceResult.PLACED) {
                        if (render.getValue())
                            new FadePos(p, fill, true);
                        cooldown = delay.getValue();
                    }
                    return;
                }
            }
        }
    }
}
Also used : FadePos(me.wallhacks.spark.util.objects.FadePos) BlockInteractUtil(me.wallhacks.spark.util.player.BlockInteractUtil) MBlockPos(com.github.lunatrius.core.util.math.MBlockPos) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) MBlockPos(com.github.lunatrius.core.util.math.MBlockPos) SpecBlockSwitchItem(me.wallhacks.spark.util.player.itemswitcher.itemswitchers.SpecBlockSwitchItem) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 5 with SpecBlockSwitchItem

use of me.wallhacks.spark.util.player.itemswitcher.itemswitchers.SpecBlockSwitchItem in project Spark-Client by Spark-Client-Development.

the class Surround method Place.

BlockInteractUtil.BlockPlaceResult Place(BlockPos x) {
    ArrayList<EntityEnderCrystal> crystals = new ArrayList<EntityEnderCrystal>();
    boolean isblocked = false;
    List<Entity> l = mc.world.getEntitiesWithinAABBExcludingEntity(null, new AxisAlignedBB(x));
    for (Entity e : l) {
        if (!(e instanceof EntityItem) && !(e instanceof EntityXPOrb) && !e.isDead) {
            isblocked = true;
            if (e instanceof EntityEnderCrystal && (IgnoreCrystals.isOn() || BreakCrystals.isOn())) {
                crystals.add((EntityEnderCrystal) e);
            } else
                return BlockInteractUtil.BlockPlaceResult.FAILED;
        }
    }
    if (BreakCrystals.isOn())
        for (EntityEnderCrystal entity : crystals) {
            mc.player.connection.sendPacket(new CPacketUseEntity(entity));
            mc.player.swingArm(EnumHand.MAIN_HAND);
        }
    BlockInteractUtil.BlockPlaceResult res = (BlockInteractUtil.tryPlaceBlock(x, allowNonObi.isOn() ? new HardSolidBlockSwitchItem() : new SpecBlockSwitchItem(Blocks.OBSIDIAN), Spark.switchManager.getModeFromString(switchingMode.getValue()), false, false, 4, blocksPerTick.getValue() > 1));
    return res;
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) CPacketUseEntity(net.minecraft.network.play.client.CPacketUseEntity) Entity(net.minecraft.entity.Entity) EntityEnderCrystal(net.minecraft.entity.item.EntityEnderCrystal) ArrayList(java.util.ArrayList) SpecBlockSwitchItem(me.wallhacks.spark.util.player.itemswitcher.itemswitchers.SpecBlockSwitchItem) CPacketUseEntity(net.minecraft.network.play.client.CPacketUseEntity) BlockInteractUtil(me.wallhacks.spark.util.player.BlockInteractUtil) HardSolidBlockSwitchItem(me.wallhacks.spark.util.player.itemswitcher.itemswitchers.HardSolidBlockSwitchItem) EntityItem(net.minecraft.entity.item.EntityItem) EntityXPOrb(net.minecraft.entity.item.EntityXPOrb)

Aggregations

SpecBlockSwitchItem (me.wallhacks.spark.util.player.itemswitcher.itemswitchers.SpecBlockSwitchItem)6 BlockInteractUtil (me.wallhacks.spark.util.player.BlockInteractUtil)5 BlockPos (net.minecraft.util.math.BlockPos)5 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)5 MBlockPos (com.github.lunatrius.core.util.math.MBlockPos)3 FadePos (me.wallhacks.spark.util.objects.FadePos)3 Block (net.minecraft.block.Block)3 Entity (net.minecraft.entity.Entity)3 EnumHand (net.minecraft.util.EnumHand)3 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)3 Vec3d (net.minecraft.util.math.Vec3d)3 HardSolidBlockSwitchItem (me.wallhacks.spark.util.player.itemswitcher.itemswitchers.HardSolidBlockSwitchItem)2 EntityItem (net.minecraft.entity.item.EntityItem)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Pair (me.wallhacks.spark.util.objects.Pair)1 ShulkerSwitchItem (me.wallhacks.spark.util.player.itemswitcher.itemswitchers.ShulkerSwitchItem)1 SpecItemSwitchItem (me.wallhacks.spark.util.player.itemswitcher.itemswitchers.SpecItemSwitchItem)1 BlockShulkerBox (net.minecraft.block.BlockShulkerBox)1 GuiCrafting (net.minecraft.client.gui.inventory.GuiCrafting)1