Search in sources :

Example 6 with SpecBlockSwitchItem

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

the class Burrow method OnUpdate.

@SubscribeEvent
void OnUpdate(PlayerUpdateEvent event) {
    BlockPos floored = PlayerUtil.getPlayerPosFloored(mc.player, 0.2);
    BlockPos pos = floored.add(0, -1, 0);
    if (mc.world.getBlockState(floored).getBlock().material.isSolid() && !mc.world.getBlockState(floored.add(0, 1, 0)).getBlock().material.isSolid()) {
        if (bypass.isOn()) {
            mc.player.motionY = 0;
        } else if (KeepPlayer.isOn()) {
            Vec3d Center = new Vec3d(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5);
            double l_XDiff = Math.abs(Center.x - mc.player.posX);
            double l_ZDiff = Math.abs(Center.z - mc.player.posZ);
            if (l_XDiff <= 0.1 && l_ZDiff <= 0.1) {
                Center = Vec3d.ZERO;
            } else {
                double l_MotionX = Center.x - mc.player.posX;
                double l_MotionZ = Center.z - mc.player.posZ;
                mc.player.motionX = l_MotionX * 0.6f;
                mc.player.motionZ = l_MotionZ * 0.6f;
            }
        }
    } else if (status > 20)
        this.setEnabled(false);
    if (status == 0) {
        if (!mc.player.onGround) {
            this.setEnabled(false);
            return;
        } else {
            List<Entity> l = mc.world.getEntitiesWithinAABBExcludingEntity(mc.player, new AxisAlignedBB(floored));
            for (Entity e : l) {
                if (!(e instanceof EntityItem) && !e.isDead) {
                    this.setEnabled(false);
                    return;
                }
            }
        }
        if (Surround.instance.isPlacing())
            return;
        if (center.isOn()) {
            Vec3d Center = new Vec3d(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5);
            double l_XDiff = Math.abs(Center.x - mc.player.posX);
            double l_ZDiff = Math.abs(Center.z - mc.player.posZ);
            if (l_XDiff <= 0.1 && l_ZDiff <= 0.1) {
            } else {
                double l_MotionX = Center.x - mc.player.posX;
                double l_MotionZ = Center.z - mc.player.posZ;
                mc.player.motionX = l_MotionX / 2;
                mc.player.motionZ = l_MotionZ / 2;
                return;
            }
        }
        EnumHand hand = Spark.switchManager.Switch(new SpecBlockSwitchItem(getUse()), ItemSwitcher.usedHand.Both);
        if (UseOtherBlocks.isOn() && hand == null)
            hand = Spark.switchManager.Switch(new HardSolidBlockSwitchItem(), ItemSwitcher.usedHand.Both);
        if (hand == null) {
            this.setEnabled(false);
            return;
        }
        if (Rotate.isOn()) {
            sendPlayerRot(90, 90, true);
        }
        if (OneTick.isOn())
            status = 1;
    }
    if (status == 1) {
        Spark.rotationManager.setCancelNextWalkingUpdate();
        sendPlayerPos(mc.player.posX, mc.player.posY + 0.41999998688698, mc.player.posZ, false);
        sendPlayerPos(mc.player.posX, mc.player.posY + 0.7531999805212, mc.player.posZ, false);
        sendPlayerPos(mc.player.posX, mc.player.posY + 1.001335979, mc.player.posZ, false);
        sendPlayerPos(mc.player.posX, mc.player.posY + 1.16610926, mc.player.posZ, false);
        EnumHand hand = Spark.switchManager.Switch(new SpecBlockSwitchItem(getUse()), ItemSwitcher.usedHand.Both);
        if (UseOtherBlocks.isOn() && hand == null)
            hand = Spark.switchManager.Switch(new HardSolidBlockSwitchItem(), ItemSwitcher.usedHand.Both);
        if (hand == null) {
            this.setEnabled(false);
            return;
        }
        if (!BlockInteractUtil.processRightClickBlock(pos, EnumFacing.UP, false, hand, new Vec3d(mc.player.posX, pos.getY() + 0.5, mc.player.posZ)))
            return;
        Spark.sendInfo("placing burrow block");
        if (OneTick.isOn())
            status = 2;
    }
    if (status == 2) {
        Vec3i clip = getClip();
        sendPlayerPos(mc.player.posX + clip.getX(), mc.player.posY + clip.getY(), mc.player.posZ + clip.getZ(), true);
    }
    status++;
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Entity(net.minecraft.entity.Entity) Vec3i(net.minecraft.util.math.Vec3i) EnumHand(net.minecraft.util.EnumHand) BlockPos(net.minecraft.util.math.BlockPos) SpecBlockSwitchItem(me.wallhacks.spark.util.player.itemswitcher.itemswitchers.SpecBlockSwitchItem) HardSolidBlockSwitchItem(me.wallhacks.spark.util.player.itemswitcher.itemswitchers.HardSolidBlockSwitchItem) Vec3d(net.minecraft.util.math.Vec3d) EntityItem(net.minecraft.entity.item.EntityItem) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

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