Search in sources :

Example 1 with ClientCommandC2SPacket

use of net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket in project BleachHack by BleachDrinker420.

the class Speed method onTick.

@BleachSubscribe
public void onTick(EventTick event) {
    // System.out.println(mc.player.forwardSpeed + " | " + mc.player.sidewaysSpeed);
    if (mc.options.keySneak.isPressed())
        return;
    /* Strafe */
    if (getSetting(0).asMode().getMode() <= 1) {
        if ((mc.player.forwardSpeed != 0 || mc.player.sidewaysSpeed != 0)) /*&& mc.player.isOnGround()*/
        {
            if (!mc.player.isSprinting()) {
                mc.player.networkHandler.sendPacket(new ClientCommandC2SPacket(mc.player, ClientCommandC2SPacket.Mode.START_SPRINTING));
            }
            mc.player.setVelocity(new Vec3d(0, mc.player.getVelocity().y, 0));
            mc.player.updateVelocity(getSetting(1).asSlider().getValueFloat(), new Vec3d(mc.player.sidewaysSpeed, 0, mc.player.forwardSpeed));
            double vel = Math.abs(mc.player.getVelocity().getX()) + Math.abs(mc.player.getVelocity().getZ());
            if (getSetting(0).asMode().getMode() == 0 && vel >= 0.12 && mc.player.isOnGround()) {
                mc.player.updateVelocity(vel >= 0.3 ? 0.0f : 0.15f, new Vec3d(mc.player.sidewaysSpeed, 0, mc.player.forwardSpeed));
                mc.player.jump();
            }
        }
    /* OnGround */
    } else if (getSetting(0).asMode().getMode() == 2) {
        if (mc.options.keyJump.isPressed() || mc.player.fallDistance > 0.25)
            return;
        double speeds = 0.85 + getSetting(2).asSlider().getValue() / 30;
        if (jumping && mc.player.getY() >= mc.player.prevY + 0.399994D) {
            mc.player.setVelocity(mc.player.getVelocity().x, -0.9, mc.player.getVelocity().z);
            mc.player.setPos(mc.player.getX(), mc.player.prevY, mc.player.getZ());
            jumping = false;
        }
        if (mc.player.forwardSpeed != 0.0F && !mc.player.horizontalCollision) {
            if (mc.player.verticalCollision) {
                mc.player.setVelocity(mc.player.getVelocity().x * speeds, mc.player.getVelocity().y, mc.player.getVelocity().z * speeds);
                jumping = true;
                mc.player.jump();
            // 1.0379
            }
            if (jumping && mc.player.getY() >= mc.player.prevY + 0.399994D) {
                mc.player.setVelocity(mc.player.getVelocity().x, -100, mc.player.getVelocity().z);
                jumping = false;
            }
        }
    /* MiniHop */
    } else if (getSetting(0).asMode().getMode() == 3) {
        if (mc.player.horizontalCollision || mc.options.keyJump.isPressed() || mc.player.forwardSpeed == 0)
            return;
        double speeds = 0.9 + getSetting(3).asSlider().getValue() / 30;
        if (mc.player.isOnGround()) {
            mc.player.jump();
        } else if (mc.player.getVelocity().y > 0) {
            mc.player.setVelocity(mc.player.getVelocity().x * speeds, -1, mc.player.getVelocity().z * speeds);
            mc.player.input.movementSideways += 1.5F;
        }
    /* Bhop */
    } else if (getSetting(0).asMode().getMode() == 4) {
        if (mc.player.forwardSpeed > 0 && mc.player.isOnGround()) {
            double speeds = 0.65 + getSetting(4).asSlider().getValue() / 30;
            mc.player.jump();
            mc.player.setVelocity(mc.player.getVelocity().x * speeds, 0.255556, mc.player.getVelocity().z * speeds);
            mc.player.sidewaysSpeed += 3.0F;
            mc.player.jump();
            mc.player.setSprinting(true);
        }
    }
}
Also used : ClientCommandC2SPacket(net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket) Vec3d(net.minecraft.util.math.Vec3d) BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe)

Example 2 with ClientCommandC2SPacket

use of net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket in project BleachHack by BleachDrinker420.

the class WorldUtils method placeBlock.

public static boolean placeBlock(BlockPos pos, int slot, int rotateMode, boolean forceLegit, boolean airPlace, boolean swingHand) {
    if (!mc.world.isInBuildLimit(pos) || !isBlockEmpty(pos))
        return false;
    for (Direction d : Direction.values()) {
        if (!mc.world.isInBuildLimit(pos.offset(d)))
            continue;
        Block neighborBlock = mc.world.getBlockState(pos.offset(d)).getBlock();
        if (!airPlace && neighborBlock.getDefaultState().getMaterial().isReplaceable())
            continue;
        Vec3d vec = getLegitLookPos(pos.offset(d), d.getOpposite(), true, 5);
        if (vec == null) {
            if (forceLegit) {
                continue;
            }
            vec = getLegitLookPos(pos.offset(d), d.getOpposite(), false, 5);
            if (vec == null) {
                continue;
            }
        }
        int prevSlot = mc.player.getInventory().selectedSlot;
        Hand hand = InventoryUtils.selectSlot(slot);
        if (hand == null) {
            return false;
        }
        if (rotateMode == 1) {
            facePosPacket(vec.x, vec.y, vec.z);
        } else if (rotateMode == 2) {
            facePos(vec.x, vec.y, vec.z);
        }
        if (RIGHTCLICKABLE_BLOCKS.contains(neighborBlock)) {
            mc.player.networkHandler.sendPacket(new ClientCommandC2SPacket(mc.player, Mode.PRESS_SHIFT_KEY));
        }
        if (swingHand) {
            mc.player.swingHand(hand);
        } else {
            mc.player.networkHandler.sendPacket(new HandSwingC2SPacket(hand));
        }
        mc.interactionManager.interactBlock(mc.player, mc.world, hand, new BlockHitResult(Vec3d.of(pos), airPlace ? d : d.getOpposite(), airPlace ? pos : pos.offset(d), false));
        if (RIGHTCLICKABLE_BLOCKS.contains(neighborBlock))
            mc.player.networkHandler.sendPacket(new ClientCommandC2SPacket(mc.player, Mode.RELEASE_SHIFT_KEY));
        mc.player.getInventory().selectedSlot = prevSlot;
        return true;
    }
    return false;
}
Also used : ClientCommandC2SPacket(net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket) HandSwingC2SPacket(net.minecraft.network.packet.c2s.play.HandSwingC2SPacket) LeavesBlock(net.minecraft.block.LeavesBlock) Block(net.minecraft.block.Block) PlantBlock(net.minecraft.block.PlantBlock) BlockHitResult(net.minecraft.util.hit.BlockHitResult) Direction(net.minecraft.util.math.Direction) Hand(net.minecraft.util.Hand) Vec3d(net.minecraft.util.math.Vec3d)

Example 3 with ClientCommandC2SPacket

use of net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket in project BleachHack by BleachDrinker420.

the class AutoParkour method onTick.

@BleachSubscribe
public void onTick(EventTick event) {
    if (smartPos != null) {
        if (mc.player.getY() - 0.5 < smartPos.getY() && mc.player.getVelocity().y < 0) {
            smartPos = null;
        }
    }
    if (!mc.player.isSneaking() && mc.player.isOnGround()) {
        smartPos = null;
        Box box = mc.player.getBoundingBox().offset(0, -0.51, 0);
        Stream<VoxelShape> blockCollisions = mc.world.getBlockCollisions(mc.player, box);
        if (blockCollisions.findAny().isEmpty()) {
            if (getSetting(0).asToggle().getState() && !mc.player.isSprinting()) {
                mc.player.setSprinting(true);
                mc.player.networkHandler.sendPacket(new ClientCommandC2SPacket(mc.player, Mode.START_SPRINTING));
            }
            if (getSetting(1).asToggle().getState()) {
                Vec3d lookVec = mc.player.getPos().add(new Vec3d(0, 0, 3.5).rotateY(-(float) Math.toRadians(mc.player.getYaw())));
                BlockPos nearestPos = BlockPos.streamOutwards(mc.player.getBlockPos().down(), 4, 1, 4).map(BlockPos::toImmutable).filter(pos -> (mc.world.isTopSolid(pos, mc.player) && mc.world.getBlockCollisions(mc.player, new Box(pos.up(), pos.add(1, 3, 1))).findAny().isEmpty()) || mc.world.getBlockState(pos).getBlock() instanceof LadderBlock || mc.world.getBlockState(pos.up()).getBlock() instanceof LadderBlock).filter(pos -> mc.player.getPos().distanceTo(Vec3d.of(pos).add(0.5, 1, 0.5)) >= 1).filter(pos -> mc.player.getPos().distanceTo(Vec3d.of(pos).add(0.5, 1, 0.5)) <= 4.5).sorted(Comparator.comparing(pos -> pos.getSquaredDistance(lookVec, false))).findFirst().orElse(null);
                if (nearestPos != null) {
                    smartPos = nearestPos;
                }
            }
            mc.player.jump();
        }
    }
}
Also used : BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe) ModuleCategory(org.bleachhack.module.ModuleCategory) EventClientMove(org.bleachhack.event.events.EventClientMove) Box(net.minecraft.util.math.Box) EventWorldRender(org.bleachhack.event.events.EventWorldRender) BlockPos(net.minecraft.util.math.BlockPos) Renderer(org.bleachhack.util.render.Renderer) VoxelShape(net.minecraft.util.shape.VoxelShape) Mode(net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket.Mode) Module(org.bleachhack.module.Module) QuadColor(org.bleachhack.util.render.color.QuadColor) LadderBlock(net.minecraft.block.LadderBlock) Stream(java.util.stream.Stream) Vec3d(net.minecraft.util.math.Vec3d) SettingColor(org.bleachhack.setting.module.SettingColor) SettingToggle(org.bleachhack.setting.module.SettingToggle) Comparator(java.util.Comparator) ClientCommandC2SPacket(net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket) EventTick(org.bleachhack.event.events.EventTick) VoxelShape(net.minecraft.util.shape.VoxelShape) ClientCommandC2SPacket(net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket) LadderBlock(net.minecraft.block.LadderBlock) Box(net.minecraft.util.math.Box) BlockPos(net.minecraft.util.math.BlockPos) Vec3d(net.minecraft.util.math.Vec3d) BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe)

Example 4 with ClientCommandC2SPacket

use of net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket in project BleachHack by BleachDrinker420.

the class Killaura method onTick.

@BleachSubscribe
public void onTick(EventTick event) {
    if (!mc.player.isAlive()) {
        return;
    }
    delay++;
    int reqDelay = (int) Math.rint(20 / getSetting(12).asSlider().getValue());
    boolean cooldownDone = getSetting(10).asToggle().getState() ? mc.player.getAttackCooldownProgress(mc.getTickDelta()) == 1.0f : (delay > reqDelay || reqDelay == 0);
    if (cooldownDone) {
        for (Entity e : getEntities()) {
            boolean shouldRotate = getSetting(8).asRotate().getState() && DebugRenderer.getTargetedEntity(mc.player, 7).orElse(null) != e;
            if (shouldRotate) {
                WorldUtils.facePosAuto(e.getX(), e.getY() + e.getHeight() / 2, e.getZ(), getSetting(8).asRotate());
            }
            boolean wasSprinting = mc.player.isSprinting();
            if (wasSprinting)
                mc.player.networkHandler.sendPacket(new ClientCommandC2SPacket(mc.player, Mode.STOP_SPRINTING));
            mc.interactionManager.attackEntity(mc.player, e);
            mc.player.swingHand(Hand.MAIN_HAND);
            if (wasSprinting)
                mc.player.networkHandler.sendPacket(new ClientCommandC2SPacket(mc.player, Mode.START_SPRINTING));
            delay = 0;
        }
    }
}
Also used : ShulkerBulletEntity(net.minecraft.entity.projectile.ShulkerBulletEntity) AbstractFireballEntity(net.minecraft.entity.projectile.AbstractFireballEntity) Entity(net.minecraft.entity.Entity) ArmorStandEntity(net.minecraft.entity.decoration.ArmorStandEntity) ClientCommandC2SPacket(net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket) BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe)

Example 5 with ClientCommandC2SPacket

use of net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket in project BleachHack by BleachDrinker420.

the class Criticals method sendCritPackets.

private void sendCritPackets() {
    if (mc.player.isClimbing() || mc.player.isTouchingWater() || mc.player.hasStatusEffect(StatusEffects.BLINDNESS) || mc.player.hasVehicle()) {
        return;
    }
    boolean sprinting = mc.player.isSprinting();
    if (sprinting) {
        mc.player.setSprinting(false);
        mc.player.networkHandler.sendPacket(new ClientCommandC2SPacket(mc.player, Mode.STOP_SPRINTING));
    }
    if (mc.player.isOnGround()) {
        double x = mc.player.getX();
        double y = mc.player.getY();
        double z = mc.player.getZ();
        if (getSetting(0).asMode().getMode() == 0) {
            mc.player.networkHandler.sendPacket(new PlayerMoveC2SPacket.PositionAndOnGround(x, y + 0.0633, z, false));
            mc.player.networkHandler.sendPacket(new PlayerMoveC2SPacket.PositionAndOnGround(x, y, z, false));
        } else {
            mc.player.networkHandler.sendPacket(new PlayerMoveC2SPacket.PositionAndOnGround(x, y + 0.42, z, false));
            mc.player.networkHandler.sendPacket(new PlayerMoveC2SPacket.PositionAndOnGround(x, y + 0.65, z, false));
            mc.player.networkHandler.sendPacket(new PlayerMoveC2SPacket.PositionAndOnGround(x, y + 0.72, z, false));
            mc.player.networkHandler.sendPacket(new PlayerMoveC2SPacket.PositionAndOnGround(x, y + 0.53, z, false));
            mc.player.networkHandler.sendPacket(new PlayerMoveC2SPacket.PositionAndOnGround(x, y + 0.32, z, false));
        }
    }
    if (sprinting) {
        mc.player.setSprinting(true);
        mc.player.networkHandler.sendPacket(new ClientCommandC2SPacket(mc.player, Mode.START_SPRINTING));
    }
}
Also used : ClientCommandC2SPacket(net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket) PlayerMoveC2SPacket(net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket)

Aggregations

ClientCommandC2SPacket (net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket)18 Vec3d (net.minecraft.util.math.Vec3d)7 PlayerMoveC2SPacket (net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket)6 BleachSubscribe (org.bleachhack.eventbus.BleachSubscribe)5 EventTarget (dev.hypnotic.event.EventTarget)2 Entity (net.minecraft.entity.Entity)2 Subscribe (com.google.common.eventbus.Subscribe)1 EventMotionUpdate (dev.hypnotic.event.events.EventMotionUpdate)1 Comparator (java.util.Comparator)1 Stream (java.util.stream.Stream)1 EventHandler (mathax.client.eventbus.EventHandler)1 Block (net.minecraft.block.Block)1 LadderBlock (net.minecraft.block.LadderBlock)1 LeavesBlock (net.minecraft.block.LeavesBlock)1 PlantBlock (net.minecraft.block.PlantBlock)1 ShulkerBoxBlock (net.minecraft.block.ShulkerBoxBlock)1 HorseScreen (net.minecraft.client.gui.screen.ingame.HorseScreen)1 InventoryScreen (net.minecraft.client.gui.screen.ingame.InventoryScreen)1 ArmorStandEntity (net.minecraft.entity.decoration.ArmorStandEntity)1 AbstractDonkeyEntity (net.minecraft.entity.passive.AbstractDonkeyEntity)1