Подведи собственные итоги года совместно с YOUGAME и забери ценные призы! Перейти

Вопрос Ротация спукич

Начинающий
Начинающий
Статус
Оффлайн
Регистрация
5 Янв 2023
Сообщения
33
Реакции
0
пытаюсь сделать ротацию под спукитайм, до этого играл меня не банило, сейчас зашёл и откинуло ( присутствует шитгпткод )


Javavelo:
Expand Collapse Copy
package dev.simpledlc.client.modules.impl.combat;

import lombok.Getter;
import lombok.Setter;
import meteordevelopment.orbit.EventHandler;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.decoration.ArmorStandEntity;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket;
import net.minecraft.util.Hand;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import org.joml.Vector2f;
import dev.simpledlc.api.events.impl.game.*;
import dev.simpledlc.api.interfaces.QuickImports;
import dev.simpledlc.api.settings.impl.BooleanSetting;
import dev.simpledlc.api.settings.impl.ModeSetting;
import dev.simpledlc.api.settings.impl.MultiModeSetting;
import dev.simpledlc.api.settings.impl.SliderSetting;
import dev.simpledlc.api.util.game.PlayerUtility;
import dev.simpledlc.api.util.game.TimerUtility;
import dev.simpledlc.Client;
import dev.simpledlc.client.modules.Module;
import dev.simpledlc.client.modules.api.ModuleCategory;
import dev.simpledlc.client.modules.api.ModuleInfo;
import dev.simpledlc.client.modules.impl.movement.AutoSprint;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import java.util.Comparator;

@ModuleInfo(name = "Aura", category = ModuleCategory.COMBAT)
public class Aura extends Module {
    @Getter
    private LivingEntity target;
    @Getter
    @Setter
    private Vector2f rotationVector = new Vector2f(0, 0);
    @Getter
    private Vector2f prevRotationVector = new Vector2f(0, 0);

    private float serverYaw = 0.0f;
    private long lastTargetAcquireTime = 0;

    public final ModeSetting rotation = new ModeSetting(
            "Поворот",
            this,
            "Обычный",
            "SpookyTime"
    );

    private final ModeSetting sortMode = new ModeSetting("Сортировать", this, "По всему", "По здоровью", "По броне", "По дистанции", "По обзору");

    private final MultiModeSetting targetType = new MultiModeSetting("Цели", this,
            "Игроки",
            "Мобы",
            "Животные",
            "Друзья");

    public final ModeSetting sprint = new ModeSetting("Сброс спринта", this, "Обычный", "Рейдж");

    private final ModeSetting moveCorrection = new ModeSetting("Коррекция движения", this,
            "Выключена",
            "Незаметная",
            "Сфокусированная");

    private final SliderSetting maxDistance = new SliderSetting("Дистанция", this,
            3.05F, 2.5F, 6.0F, 0.01F);
    @Getter
    private final SliderSetting maxPreDistance = new SliderSetting("Дистанция наводки", this,
            0.3F, 0.0F, 6, 0.1F);

    private final MultiModeSetting options = new MultiModeSetting("Опции", this,
            "Бить критами",
            "Умные криты",
            "Фокусировать одну цель",
            "Ломать щит");

    private boolean hasResetRotation = true;
    public boolean lookingAtTarget = false;
    public boolean isFalling = false;
    private int smoothToTargetTicks = 0;
    private boolean softDisabling = false;
    private boolean returningToPlayerRotation = false;

    public boolean isReturningToPlayerRotation() {
        return returningToPlayerRotation;
    }

    @Override
    public void onEnable() {
        super.onEnable();
        softDisabling = false;
        returningToPlayerRotation = false;
        hasResetRotation = true;
        lookingAtTarget = false;
        lastRotationTime = System.currentTimeMillis();
        if (mc.player != null) {
            Vector2f reset = new Vector2f(mc.player.getYaw(), mc.player.getPitch());
            prevRotationVector = reset;
            rotationVector = reset;
            serverYaw = mc.player.getYaw();
        }
    }

    @Override
    public void onDisable() {
        softDisabling = false;
        returningToPlayerRotation = false;
        super.onDisable();
    }

    @Override
    public void toggle() {
        if (isEnabled()) {
            if (mc.player != null) {
                target = null;
                lookingAtTarget = false;
                softDisabling = true;
                returningToPlayerRotation = true;
                hasResetRotation = false;
            } else {
                super.toggle();
            }
            return;
        }

        super.toggle();
        lastRotationTime = System.currentTimeMillis();
        smoothToTargetTicks = 7;
    }

    private final Random random = new Random();

    @EventHandler
    public void onTick(EventTick eventTick) {
        if (mc.player == null || mc.world == null) {
            isFalling = false;
            return;
        }
        isFalling = AuraHelper.INSTANCE.isValidFallState();
    }

    @EventHandler
    public void onUpdate(EventUpdate eventTick) {
        LivingEntity newTarget = softDisabling ? null : updateTarget();

        if (newTarget != null) {
            if (target == null || target != newTarget) {
                smoothToTargetTicks = 7;
                lastTargetAcquireTime = System.currentTimeMillis();
            }
            target = newTarget;
            returningToPlayerRotation = false;
            prevRotationVector = new Vector2f(rotationVector.x, rotationVector.y);
            updateAttack();
            updateRotations(false);
            hasResetRotation = false;
            return;
        }

        target = null;
        lookingAtTarget = false;

        if (mc.player == null) {
            hasResetRotation = true;
            returningToPlayerRotation = false;
            return;
        }

        if (!hasResetRotation) {
            returningToPlayerRotation = true;
        }

        if (returningToPlayerRotation) {
            prevRotationVector = new Vector2f(rotationVector.x, rotationVector.y);
            float targetYaw = mc.player.getYaw();
            float targetPitch = mc.player.getPitch();

            float yawDelta = MathHelper.wrapDegrees(targetYaw - serverYaw);
            float pitchDelta = MathHelper.wrapDegrees(targetPitch - rotationVector.y);

            float yawStep = MathHelper.clamp(yawDelta, -18.0f, 18.0f);
            float pitchStep = MathHelper.clamp(pitchDelta, -14.0f, 14.0f);

            float newYaw = serverYaw + yawStep;
            float newPitch = MathHelper.clamp(rotationVector.y + pitchStep, -89.0F, 89.0F);
            serverYaw = newYaw;
            rotationVector = new Vector2f(MathHelper.wrapDegrees(serverYaw), newPitch);

            if (Math.abs(yawDelta) <= 0.35f && Math.abs(pitchDelta) <= 0.35f) {
                Vector2f reset = new Vector2f(targetYaw, targetPitch);
                prevRotationVector = reset;
                rotationVector = reset;
                serverYaw = targetYaw;
                returningToPlayerRotation = false;
                hasResetRotation = true;

                if (softDisabling) {
                    softDisabling = false;
                    super.toggle();
                    return;
                }
            } else {
                hasResetRotation = false;
            }
        } else {
            Vector2f reset = new Vector2f(mc.player.getYaw(), mc.player.getPitch());
            prevRotationVector = reset;
            rotationVector = reset;
            serverYaw = mc.player.getYaw();
            hasResetRotation = true;

            if (softDisabling) {
                softDisabling = false;
                super.toggle();
            }
        }
    }

    @EventHandler
    public void onTrace(EventTrace e) {
        if (mc.player != null && mc.world != null && (target != null || returningToPlayerRotation)) {
            e.setYaw(rotationVector.x);
            e.setPitch(rotationVector.y);
            e.setCancelled(true);
        }
    }

    @EventHandler
    public void onInputMove(EventInputMove e) {
        if (mc.player == null || mc.world == null) {
            return;
        }
        if (moveCorrection.is(0)) {
            return;
        }

        if (target == null && !returningToPlayerRotation) {
            return;
        }
        
        if (mc.player.isGliding()) {
            handleElytraMovementCorrection(e);
        } else {
            if (moveCorrection.is(1)) {
                e.setYaw(rotationVector.x, rotationVector.x);
            } else {
                e.setYaw(rotationVector.x, rotationVector.x);
            }
        }
    }

    private void handleElytraMovementCorrection(EventInputMove e) {
        float yawDifference = MathHelper.wrapDegrees(rotationVector.x - mc.player.getYaw());
        float extremeCorrectionThreshold = 45.0f;
        
        if (Math.abs(yawDifference) <= extremeCorrectionThreshold) {
            return;
        }
        
        if (moveCorrection.is(1)) {
            float correctedYaw = mc.player.getYaw() + (yawDifference * 0.1f);
            e.setYaw(correctedYaw, correctedYaw);
        } else {
            float correctedYaw = mc.player.getYaw() + (yawDifference * 0.2f);
            e.setYaw(correctedYaw, correctedYaw);
        }
    }

    @EventHandler
    public void onMotion(EventMotion e) {
        if (mc.player != null && mc.world != null && (target != null || returningToPlayerRotation)) {
            if (mc.player.isGliding() || mc.player.isTouchingWater() || mc.player.isSubmergedInWater()) {
                float yawDifference = MathHelper.wrapDegrees(rotationVector.x - mc.player.getYaw());
                if (Math.abs(yawDifference) > 45.0f) {
                    float correctedYaw = mc.player.getYaw() + (yawDifference * 0.1f);
                    e.setYaw(correctedYaw);
                } else {
                    e.setYaw(mc.player.getYaw());
                }
                e.setPitch(mc.player.getPitch());
            } else {
                e.setYaw(serverYaw);
                e.setPitch(rotationVector.y);
            }
        }
    }

    @EventHandler
    public void onRotationVector(EventRotationVector e) {
        if (mc.player != null && mc.world != null && (target != null || returningToPlayerRotation)) {
            if (mc.player.isGliding() || mc.player.isTouchingWater() || mc.player.isSubmergedInWater()) {
                float yawDifference = MathHelper.wrapDegrees(rotationVector.x - mc.player.getYaw());
                if (Math.abs(yawDifference) > 45.0f) {
                    float correctedYaw = mc.player.getYaw() + (yawDifference * 0.1f);
                    e.setYaw(correctedYaw);
                } else {
                    e.setYaw(mc.player.getYaw());
                }
                e.setPitch(mc.player.getPitch());
            } else {
                e.setYaw(serverYaw);
                e.setPitch(rotationVector.y);
            }
        }
    }

    @EventHandler
    public void onJump(EventJump e) {
        if ((target != null || returningToPlayerRotation) && mc.player != null && mc.world != null) {
            e.setYaw(serverYaw);
        }
    }

    private void updateAttack() {
        final AuraHelper auraHelper = AuraHelper.INSTANCE;
        boolean onlyCrits = options.get(0) != null && options.get(0).isEnabled();
        boolean smartCrits = options.get(1) != null && options.get(1).isEnabled();
        boolean isFalling = auraHelper.canHit(onlyCrits, smartCrits, this.isFalling);

        if (isFalling) {
            attackTarget(auraHelper);
        }
    }

    private long lastRotationTime = 0;

    private void updateRotations(boolean eventTick) {
        if (mc.player == null || target == null) {
            return;
        }

        if (serverYaw == 0.0f) {
            serverYaw = mc.player.getYaw();
        }

        Vec3d eyePos = mc.player.getEyePos();
        Vec3d targetPos = target.getPos().add(0, target.getEyeHeight(target.getPose()) * 0.85f, 0);
        Vec3d diff = targetPos.subtract(eyePos);
        double distXZ = Math.hypot(diff.x, diff.z);
        float yawToTarget = (float) (Math.toDegrees(Math.atan2(diff.z, diff.x)) - 90.0F);
        float pitchToTarget = (float) (-Math.toDegrees(Math.atan2(diff.y, distXZ)));
        float humanOffsetYaw = (float) (Math.random() * 0.8f - 0.4f);
        float humanOffsetPitch = (float) (Math.random() * 0.6f - 0.3f);

        yawToTarget += humanOffsetYaw;
        pitchToTarget += humanOffsetPitch;
        pitchToTarget = MathHelper.clamp(pitchToTarget, -89.0F, 89.0F);

        float yawDelta = MathHelper.wrapDegrees(yawToTarget - serverYaw);
        float pitchDelta = MathHelper.wrapDegrees(pitchToTarget - rotationVector.y);

        if (smoothToTargetTicks > 0) {
            float progress = 1.0f - (smoothToTargetTicks / 7.0f);
            float ease = (float) (1 - Math.pow(1 - progress, 2));

            float maxYawStep = 10.0f + (float) Math.random() * 4.0f;
            float maxPitchStep = 8.0f + (float) Math.random() * 3.0f;

            float yawStep = MathHelper.clamp(yawDelta * ease, -maxYawStep, maxYawStep);
            float pitchStep = MathHelper.clamp(pitchDelta * ease, -maxPitchStep, maxPitchStep);
            
            yawStep += (float) (Math.random() * 0.4f - 0.2f);
            pitchStep += (float) (Math.random() * 0.3f - 0.15f);

            serverYaw += yawStep;
            rotationVector.y = MathHelper.clamp(rotationVector.y + pitchStep, -89.0F, 89.0F);
            rotationVector.x = MathHelper.wrapDegrees(serverYaw);

            smoothToTargetTicks--;
            return;
        }

        switch (rotation.getCurrentMode()) {
            case "Обычный" -> {
                float yaw = serverYaw;
                float pitch = rotationVector.y;

                boolean fastTrack = PlayerUtility.isMoving() && (Math.abs(yawDelta) > 3.0f || Math.abs(pitchDelta) > 3.0f);

                if (fastTrack) {
                    float gcd = (float) getGcd();
                    float ny = yaw + MathHelper.wrapDegrees(yawToTarget - yaw);
                    float np = MathHelper.clamp(pitchToTarget, -89.0F, 89.0F);
                    ny -= (ny - yaw) % gcd;
                    np -= (np - rotationVector.y) % gcd;
                    serverYaw = ny;
                    rotationVector = new Vector2f(MathHelper.wrapDegrees(serverYaw), np);
                    break;
                }

                long currentTime = System.currentTimeMillis();
                float deltaTime = lastRotationTime == 0 ? 1.0f : Math.min((currentTime - lastRotationTime) / 16.0f, 2.0f);
                lastRotationTime = currentTime;

                float targetYaw = yawToTarget;
                float targetPitch = MathHelper.clamp(pitchToTarget, -89.0F, 89.0F);

                float yd = MathHelper.wrapDegrees(targetYaw - yaw);
                float pd = MathHelper.wrapDegrees(targetPitch - pitch);

                float totalRotation = Math.abs(yd) + Math.abs(pd);
                float progress = 1.0f - (totalRotation / 180.0f);
                progress = MathHelper.clamp(progress, 0.1f, 0.95f);

                float baseSpeed = 15.0f + (float) (Math.random() * 10.0f);
                float yawStep = MathHelper.clamp(yd * deltaTime, -25.0f, 25.0f);
                float pitchStep = MathHelper.clamp(pd * deltaTime, -10.0f, 10.0f);

                yaw += yawStep;
                pitch += pitchStep;
                pitch = MathHelper.clamp(pitch, -89.0F, 89.0F);

                if (Math.abs(yd) < 5.0f) {
                    yaw += ((float) Math.random() * 2.0f - 1.0f) * 0.5f;
                }

                float gcd = (float) getGcd();
                yaw -= (yaw - serverYaw) % gcd;

                serverYaw = yaw;
                rotationVector = new Vector2f(MathHelper.wrapDegrees(serverYaw), pitch);
            }
            case "SpookyTime" -> {
                long currentTime = System.currentTimeMillis();
                float deltaTime = Math.min((currentTime - lastRotationTime) / 16.666f, 1.2f);
                lastRotationTime = currentTime;
                float baseYawSpeed = 25.0f + (float)Math.random() * 10.0f;
                float basePitchSpeed = 20.0f + (float)Math.random() * 8.0f;
                float urgency = Math.min((Math.abs(yawDelta) + Math.abs(pitchDelta)) / 30.0f, 1.5f);
                float yawSpeed = baseYawSpeed * urgency;
                float pitchSpeed = basePitchSpeed * urgency;
                float yawStep = yawDelta * deltaTime * 0.8f;
                float pitchStep = pitchDelta * deltaTime * 0.8f;
                yawStep = MathHelper.clamp(yawStep, -yawSpeed, yawSpeed);
                pitchStep = MathHelper.clamp(pitchStep, -pitchSpeed, pitchSpeed);
                if (Math.abs(yawDelta) < 10.0f) {
                    yawStep += (float)(Math.random() * 0.8f - 0.4f);
                }
                if (Math.abs(pitchDelta) < 8.0f) {
                    pitchStep += (float)(Math.random() * 0.6f - 0.3f);
                }
                yawStep += (float)(Math.random() * 0.06f - 0.03f);
                pitchStep += (float)(Math.random() * 0.05f - 0.025f);
                serverYaw += yawStep;
                rotationVector.y = MathHelper.clamp(rotationVector.y + pitchStep, -89.0F, 89.0F);
                rotationVector.x = MathHelper.wrapDegrees(serverYaw);
                if (Math.abs(yawDelta) < 1.5f && Math.abs(pitchDelta) < 1.5f) {
                    serverYaw += (float)(Math.random() * 0.3f - 0.15f);
                    rotationVector.x = MathHelper.wrapDegrees(serverYaw);
                }
            }
        }
        lookingAtTarget = true;
    }

    private double getGcd() {
        double sensitivity = mc.options.getMouseSensitivity().getValue();
        double value = sensitivity * 0.6 + 0.2;
        double result = Math.pow(value, 1.5F) * 0.8;
        return result * 0.15D;
    }

    private boolean canHit(AuraHelper auraHelper) {
        if (!lookingAtTarget) return false;
        if (!distanceCheck()) return false;
        if (!isCrosshairOnTarget()) return false;
        boolean breakShield = options.get(3) != null && options.get(3).isEnabled();
        return auraHelper.preHit(target, sprint.is(0) ? AuraHelper.SprintReset.LEGIT : AuraHelper.SprintReset.PACKET, breakShield);
    }

    private boolean isCrosshairOnTarget() {
        if (mc.player == null || target == null) return false;
        Vec3d eyePos = mc.player.getEyePos();
        Vec3d targetPos = target.getPos().add(0, target.getEyeHeight(target.getPose()), 0);
        Vec3d diff = targetPos.subtract(eyePos);

        double distXZ = Math.hypot(diff.x, diff.z);
        if (distXZ <= 0.0001D) return true;

        float yawToTarget = (float) (Math.toDegrees(Math.atan2(diff.z, diff.x)) - 90.0F);
        float auraYaw = rotationVector.x;

        float yawDiff = Math.abs(MathHelper.wrapDegrees(yawToTarget - auraYaw));

        float maxYawDiff = 35.0F;

        return yawDiff <= maxYawDiff;
    }

    public boolean distanceCheck() {
        if (target == null || mc.player == null) return false;

        if (target.distanceTo(mc.player) > getMaxDistance()) {
            return false;
        }
        return true;
    }

    private void attackTarget(AuraHelper auraHelper) {
        if (!canHit(auraHelper)) return;
        updateRotations(true);
        auraHelper.upHitCooldown();

        mc.interactionManager.attackEntity(mc.player, this.target);
        mc.player.swingHand(Hand.MAIN_HAND);
        auraHelper.postHit();
    }

    private float getPreDistance() {
        return maxPreDistance.getValue();
    }

    private LivingEntity updateTarget() {
        if (mc.player == null || mc.world == null) {
            return null;
        }

        boolean focusTarget = options.get(2) != null && options.get(2).isEnabled();
        float max = getMaxDistance() + getPreDistance();

        if (focusTarget && target != null && isValidTarget(target)
                && mc.player.getEyePos().distanceTo(target.getEyePos()) <= max) {
            return target;
        }

        List<LivingEntity> candidates = new ArrayList<>();
        for (Entity entity : mc.world.getEntities()) {
            if (!(entity instanceof LivingEntity living)) continue;
            if (!isValidTarget(living)) continue;
            if (mc.player.getEyePos().distanceTo(living.getEyePos()) > max) continue;
            candidates.add(living);
        }

        if (candidates.isEmpty()) {
            return null;
        }

        if (candidates.size() == 1) {
            return candidates.get(0);
        }

        switch (sortMode.getCurrentMode()) {
            case "По всему" -> Collections.shuffle(candidates, random);
            case "По здоровью" -> candidates.sort(Comparator.comparingDouble(this::getEntityHealth));
            case "По броне" -> candidates.sort(Comparator.comparingDouble(this::getEntityArmorScore));
            case "По дистанции" -> candidates.sort(Comparator.comparingDouble(e -> e.distanceTo(mc.player)));
            case "По обзору" -> candidates.sort(Comparator.comparingDouble(this::getFovToEntity));
            default -> {
            }
        }

        return candidates.get(0);
    }

    private boolean isValidTarget(LivingEntity entity) {
        if (entity == mc.player) return false;
        if (!entity.isAlive() || entity.getHealth() <= 0) return false;
        if (entity instanceof ArmorStandEntity) return false;

        if (entity instanceof PlayerEntity) {
            BooleanSetting players = targetType.get(0);
            return players != null && players.isEnabled();
        }

        if (entity instanceof MobEntity) {
            BooleanSetting mobs = targetType.get(1);
            return mobs != null && mobs.isEnabled();
        }

        BooleanSetting animals = targetType.get(2);
        return animals != null && animals.isEnabled();
    }

    private double getEntityArmorScore(LivingEntity entity) {
        if (entity instanceof PlayerEntity playerEntity) {
            return playerEntity.getArmor();
        }
        return entity.getArmor();
    }

    private double getEntityHealth(LivingEntity entity) {
        return entity.getHealth() + entity.getAbsorptionAmount();
    }

    private double getFovToEntity(LivingEntity entity) {
        if (mc.player == null) return 180.0;
        Vec3d look = mc.player.getRotationVec(1.0F);
        Vec3d toEntity = entity.getPos().subtract(mc.player.getPos()).normalize();
        double dot = look.dotProduct(toEntity);
        dot = MathHelper.clamp(dot, -1.0, 1.0);
        return Math.acos(dot) * (180.0 / Math.PI);
    }

    public float getMaxDistance() {
        return maxDistance.getValue();
    }



    @Getter
    @Setter
    public static class AuraHelper implements QuickImports {
        public static AuraHelper INSTANCE;

        Aura killAura = Client.getInstance().getModuleManager().get(Aura.class);
        AutoSprint autoSprint = Client.getInstance().getModuleManager().get(AutoSprint.class);

        private final TimerUtility hitCooldown = new TimerUtility();
        private final TimerUtility legitSprintTimer = new TimerUtility();

        @Getter
        private boolean wasSprinting = false;
        private SprintReset sprintReset;

        public AuraHelper() {
            INSTANCE = this;
        }

        @EventHandler
        public void onTick(EventTick eventTick) {
            if (!killAura.sprint.is(0)) {
                autoSprint.setAuraStop(true);
                return;
            }

            LivingEntity target = killAura.getTarget();
            boolean onlyCrits = killAura.options.get(0) != null && killAura.options.get(0).isEnabled();
            boolean smartCrits = killAura.options.get(1) != null && killAura.options.get(1).isEnabled();

            if (target == null || !killAura.isEnabled() || !onlyCrits || !killAura.lookingAtTarget || !killAura.distanceCheck() || target.hurtTime > 1) {
                autoSprint.setAuraStop(true);
                return;
            }

            double verticalDistance = -1;
            BlockPos playerPos = mc.player.getBlockPos();

            for (int i = 0; i <= mc.player.getBlockY(); i++) {
                BlockPos checkPos = playerPos.down(i);
                BlockState state = mc.world.getBlockState(checkPos);

                if (!state.isAir() && state.isSolid()) {
                    verticalDistance = mc.player.getY() - (checkPos.getY() + 1);
                    break;
                }
            }

            boolean cancel = shouldCancelCrit();
            boolean cond = cancel ? verticalDistance > 0 : verticalDistance >= 0;
            boolean shouldCancel = (cond || cancel ||
                    (smartCrits && !mc.options.jumpKey.isPressed() && mc.player.isOnGround()))
                    && mc.player.getAttackCooldownProgress(0.5f) >= 0.8f;

            if (shouldCancel) {
                autoSprint.setAuraStop(false);
                mc.player.setSprinting(false);
            } else {
                autoSprint.setAuraStop(true);
            }
        }

        public boolean shouldCancelCrit() {
            if (mc.player == null) return false;
            return mc.player.isSubmergedInWater()
                    || mc.player.isInLava()
                    || PlayerUtility.isCollide(Blocks.COBWEB) || PlayerUtility.isCollide(Blocks.SWEET_BERRY_BUSH)
                    || mc.player.isClimbing()
                    || mc.player.getAbilities().flying
                    || mc.player.hasStatusEffect(StatusEffects.BLINDNESS)
                    || mc.player.hasStatusEffect(StatusEffects.LEVITATION)
                    || mc.player.hasStatusEffect(StatusEffects.SLOW_FALLING);
        }

        public boolean isValidFallState() {
            return mc.player.fallDistance > getFallDistance();
        }

        private boolean isAttackReady() {
            float attackStrength = mc.player.getAttackCooldownProgress(0.5F);
            float attackDelay = 0.9F;
            return attackStrength > attackDelay;
        }

        private float getFallDistance() {
            return 0;
        }

        public boolean canHit(boolean onlyCrit, boolean onlySpace, boolean isCrit) {
            if (!isAttackReady()) return false;
            if (shouldCancelCrit()) return true;
            if (onlySpace && !mc.options.jumpKey.isPressed() && mc.player.isOnGround()) return true;

            return !onlyCrit || isCrit;
        }

        private boolean tryBreakShield(LivingEntity entity) {
            return false;
        }

        public void upHitCooldown() {
            hitCooldown.reset();
        }

        public boolean preHit(LivingEntity entity, SprintReset sprintReset, boolean breakShield) {
            if (breakShield && tryBreakShield(entity)) {
                upHitCooldown();
                return false;
            }

            this.sprintReset = sprintReset;

            if (mc.player.isSprinting()) {
                if (this.sprintReset.equals(SprintReset.LEGIT)) {
                    wasSprinting = mc.player.isSprinting();
                    mc.player.setSprinting(false);
                }

                if (this.sprintReset.equals(SprintReset.PACKET)) {
                    mc.player.networkHandler.sendPacket(new ClientCommandC2SPacket(mc.player, ClientCommandC2SPacket.Mode.STOP_SPRINTING));
                    mc.player.setSprinting(false);
                    wasSprinting = true;
                }
            }

            return true;
        }

        public boolean postHit() {
            if (wasSprinting) {
                if (sprintReset == SprintReset.PACKET) {
                    mc.player.networkHandler.sendPacket(new ClientCommandC2SPacket(mc.player, ClientCommandC2SPacket.Mode.START_SPRINTING));
                    mc.player.setSprinting(true);
                }
                wasSprinting = false;
            }

            return true;
        }

        public enum SprintReset {
            NONE,
            PACKET,
            LEGIT
        }
    }
}
 
Назад
Сверху Снизу