Подписывайтесь на наш Telegram и не пропускайте важные новости! Перейти

Вопрос Почему крит не дает?

Начинающий
Начинающий
Статус
Оффлайн
Регистрация
22 Май 2025
Сообщения
45
Реакции
0
Когда бегу на чела Hit Aura в начале 1 тыку не даёт, потом 10 тык где то и опять 1 не дает polar ротация
Код:
Expand Collapse Copy
package ru.night.module.impl.combat.auraProcess;

import java.security.SecureRandom;
import java.util.Arrays;
import java.util.concurrent.ThreadLocalRandom;
import lombok.Generated;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.util.Hand;
import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.AxeItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.world.World;
import net.minecraft.block.Blocks;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.hit.HitResult;
import net.minecraft.util.math.Vec3d;
import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket;
import net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket;
import net.minecraft.network.packet.c2s.play.UpdateSelectedSlotC2SPacket;
import net.minecraft.network.packet.c2s.play.PlayerInteractItemC2SPacket;
import net.minecraft.client.MinecraftClient;
import net.minecraft.registry.tag.FluidTags;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.RaycastContext;
import net.minecraft.entity.attribute.EntityAttributes;
import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket.Action;
import net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket.Mode;
import net.minecraft.world.RaycastContext.FluidHandling;
import net.minecraft.world.RaycastContext.ShapeType;
import ru.night.module.impl.combat.HitAura;
import ru.night.module.impl.combat.auraProcess.auraUtil.AuraUtil;
import ru.night.module.impl.combat.auraProcess.auraUtil.RayTraceUtil;
import ru.night.util.other.IMinecraft;
import ru.night.util.other.StopWatch;

@Environment(EnvType.CLIENT)
public final class Attack implements IMinecraft {
   private static final SecureRandom secureRandom = new SecureRandom();
   private static final MinecraftClient mc = MinecraftClient.getInstance();
   public static long hitCounterCPSBypass;
   public static int randomInt1PosibleOrNotOnHit = -1;
   private static final StopWatch cooldownTimer = new StopWatch();
   private static boolean missDetected;
   private static int counterTo0PostMissHits;

   public static void hitCounterCPSBypassNext() {
      hitCounterCPSBypass++;
   }

   public static void hitCounterCPSBypassReset() {
      hitCounterCPSBypass = 0L;
   }

   public static boolean cpsBypassTrigger() {
      return hitCounterCPSBypass % 7L == 3L;
   }

   public static PlayerEntity getSelf() {
      return mc.player;
   }

   public static World getWorld() {
      return mc.world;
   }

   public static float applyGaussianJitter(float rotation) {
      float strength = 0.2F;
      return (float)(rotation + (secureRandom.nextGaussian() * 0.2F * 2.0 - 0.2F));
   }

   public static boolean randomBoolean(int chance010) {
      return secureRandom.nextInt(chance010 + 1) >= 1.0F * (1.0F / Math.max((float)chance010, 1.0F));
   }

   public static boolean randomBoolean() {
      return secureRandom.nextInt(2) == 1;
   }

   public static float randomFloat(float min, float max) {
      return secureRandom.nextFloat(min, max);
   }

   public static float randomFloat() {
      return randomFloat(0.0F, 1.0F);
   }

   public static int randomInt1PosibleOrNot() {
      return randomBoolean() ? 1 : -1;
   }

   public static int getAxeSlot() {
      if (mc.player == null) {
         return -1;
      } else {
         for (int i = 0; i < 9; i++) {
            if (mc.player.getInventory().getStack(i).getItem() instanceof AxeItem) {
               return i;
            }
         }
         return -1;
      }
   }

   public static Runnable[] hitShieldBreakTaskForUse(LivingEntity livingIn, boolean enabled) {
      Runnable[] pre$post = new Runnable[]{() -> {}, () -> {}};
      if (enabled && mc.player != null) {
         if (livingIn instanceof PlayerEntity player) {
            if (!player.isBlocking()) {
               return pre$post;
            }

            ItemStack main = player.getMainHandStack();
            ItemStack off = player.getOffHandStack();
            Item mainItem = main.isEmpty() ? null : main.getItem();
            Item offItem = off.isEmpty() ? null : off.getItem();
            if (mainItem == Items.SHIELD || offItem == Items.SHIELD) {
               int handSlot = mc.player.getInventory().getSelectedSlot();
               int slot;
               if ((slot = getAxeSlot()) != -1 && slot != handSlot) {
                  pre$post[0] = () -> {
                     if (mc.getNetworkHandler() != null) {
                        mc.getNetworkHandler().sendPacket(new UpdateSelectedSlotC2SPacket(slot));
                     }
                  };
                  pre$post[1] = () -> {
                     if (mc.getNetworkHandler() != null) {
                        mc.getNetworkHandler().sendPacket(new UpdateSelectedSlotC2SPacket(handSlot));
                     }
                  };
               }
            }
         }
         return pre$post;
      } else {
         return pre$post;
      }
   }

   public static Runnable[] resetShieldSilentTaskForUse(boolean enabled) {
      Runnable[] pre$post = new Runnable[]{() -> {}, () -> {}};
      if (enabled && mc.player != null) {
         if (mc.player.isBlocking()) {
            Hand active = mc.player.getActiveHand();
            if (active == null) {
               return pre$post;
            }

            pre$post[0] = () -> mc.getNetworkHandler().sendPacket(new PlayerActionC2SPacket(Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, Direction.DOWN));
            pre$post[1] = () -> mc.getNetworkHandler().sendPacket(new PlayerInteractItemC2SPacket(active, 0, mc.player.getYaw(), mc.player.getPitch()));
         }
         return pre$post;
      } else {
         return pre$post;
      }
   }

   public static Runnable[] skipSilentSprintingTaskForUse(boolean enabled) {
      Runnable[] pre$post = new Runnable[]{() -> {}, () -> {}};
      if (enabled && mc.player != null) {
         if (mc.player.isSprinting() && !mc.player.isOnGround() && !mc.player.isSubmergedIn(FluidTags.WATER)) {
            pre$post[0] = () -> {
               mc.player.setSprinting(false);
               mc.getNetworkHandler().sendPacket(new ClientCommandC2SPacket(mc.player, Mode.STOP_SPRINTING));
            };
            pre$post[1] = () -> {
               mc.player.setSprinting(true);
               mc.getNetworkHandler().sendPacket(new ClientCommandC2SPacket(mc.player, Mode.START_SPRINTING));
            };
         }
         return pre$post;
      } else {
         return pre$post;
      }
   }

   public static double getYCapacityOnPlayerPos(int rangeY) {
      if (mc.world != null && mc.player != null) {
         Vec3d eyePos = mc.player.getEyePos();
         double minDst = rangeY * 2.0;
         double maxY = 320.0;
         double minY = -64.0;
         float selfWD2 = mc.player.getWidth() / 2.0F - 0.01F;

         for (Vec3d vec : Arrays.asList(
                 eyePos.add(-selfWD2, 0.0, -selfWD2),
                 eyePos.add(selfWD2, 0.0, selfWD2),
                 eyePos.add(selfWD2, 0.0, -selfWD2),
                 eyePos.add(-selfWD2, 0.0, selfWD2)
         )) {
            HitResult first = mc.world
                    .raycast(new RaycastContext(vec, vec.add(0.0, -rangeY, 0.0), ShapeType.VISUAL, FluidHandling.ANY, mc.player));
            HitResult second = mc.world
                    .raycast(new RaycastContext(vec, vec.add(0.0, rangeY, 0.0), ShapeType.VISUAL, FluidHandling.ANY, mc.player));
            if (maxY > second.getPos().y) {
               maxY = second.getPos().y;
            }

            if (minY < first.getPos().y) {
               minY = first.getPos().y;
            }

            double dst = maxY - minY;
            if (minDst > dst) {
               minDst = dst;
            }
         }
         return minDst - mc.player.getHeight();
      } else {
         return 1.0;
      }
   }

   public static double convenientFallOffset() {
      if (mc.player == null) {
         return 0.0;
      } else {
         double fallOffset = mc.player.fallDistance;
         if (mc.world != null && !mc.player.isOnGround() && mc.player.getVelocity().y < -0.0784000015258789) {
            boolean posLiquid = !mc.world.getFluidState(mc.player.getBlockPos()).isEmpty();
            boolean posUpLiquid = !mc.world.getFluidState(mc.player.getBlockPos().up()).isEmpty();
            if (!posLiquid && !posUpLiquid && mc.player.fallDistance < -mc.player.getVelocity().y && mc.player.age > 6) {
               fallOffset = -mc.player.getVelocity().y;
            }
         }
         return fallOffset;
      }
   }

   public static boolean isBestMomentToHit(boolean fallCheck) {
      if (fallCheck && mc.player != null) {
         boolean hasFall = convenientFallOffset() > 0.0F || getYCapacityOnPlayerPos(2) < 0.1F;
         if (hasFall) {
            return true;
         } else {
            boolean isInWeb = mc.world.getBlockState(mc.player.getBlockPos()).isOf(Blocks.COBWEB);
            boolean badLiquidMoment = !mc.player.isJumping() && (mc.player.isTouchingWater() || mc.player.isInLava())
                    || mc.player.isSubmergedIn(FluidTags.WATER)
                    || mc.player.isSubmergedIn(FluidTags.LAVA)
                    || isInWeb;
            return badLiquidMoment
                    || !mc.player.isJumping() && mc.player.age > 6 && HitAura.extraSettings.get("Умные криты")
                    || mc.player.isClimbing()
                    || mc.player.hasVehicle()
                    || mc.player.hasStatusEffect(StatusEffects.BLINDNESS)
                    || mc.player.hasStatusEffect(StatusEffects.LEVITATION)
                    || mc.player.hasStatusEffect(StatusEffects.SLOW_FALLING)
                    || mc.player.getAbilities().flying;
         }
      } else {
         return true;
      }
   }

   public static boolean useEntity(LivingEntity livingIn, Runnable preHit, Runnable postHit, Hand hand, boolean cpsBypass) {
      if (preHit != null) {
         preHit.run();
      }

      if (livingIn != null && mc.interactionManager != null && mc.player != null) {
         mc.interactionManager.attackEntity(mc.player, livingIn);
         if (hand != null) {
            mc.player.swingHand(hand);
         }

         if (cpsBypass) {
            hitCounterCPSBypassNext();
         } else {
            hitCounterCPSBypassReset();
         }

         cooldownTimer.reset();
      }

      if (postHit != null) {
         postHit.run();
      }

      return livingIn != null;
   }

   public static long getMsCooldown() {
      if (mc.player == null) {
         return 500L;
      } else {
         double attackSpeed = mc.player.getAttributeValue(EntityAttributes.ATTACK_SPEED);
         float maxDeviation = 0.2F;
         long msCooldown2 = (long)(1.0 / attackSpeed * 1000.0 * (1.0F - Math.min(maxDeviation, 1.0F)));
         long msCooldown;
         if (HitAura.attackDelay.is("Динамичный")) {
            msCooldown = msCooldown2 + ThreadLocalRandom.current().nextLong(10L, 50L);
         } else {
            msCooldown = msCooldown2 + 40L;
         }
         return msCooldown;
      }
   }

   public static boolean msCooldownReached(long msOffset) {
      return cooldownTimer.finished(getMsCooldown() + msOffset);
   }

   public static boolean msCooldownReached() {
      return msCooldownReached(0L);
   }

   public static boolean msCooldownHasMs(long ms) {
      return cooldownTimer.finished(ms);
   }

   public static float msCooldownPC01() {
      return Math.min((float)cooldownTimer.elapsedTime() / (float)getMsCooldown(), 1.0F);
   }

   public static float msCooldownReach() {
      return (float)cooldownTimer.elapsedTime();
   }

   public static boolean anyEntityOnRay(LivingEntity livingIn, double range) {
      return livingIn != null
              && RayTraceUtil.rayTraceEntity(MathHelper.wrapDegrees(mc.player.getYaw()), mc.player.getPitch(), (float)range, livingIn);
   }

   public static boolean shouldAttack(LivingEntity livingTarget, boolean rayCast, boolean distanceCheck, boolean fallCheck, long cooldownMSOffset, float[] ranges) {
      if (distanceCheck && livingTarget != null && !AuraUtil.validDistance(livingTarget, ranges[0], true)) {
         return false;
      } else if (!msCooldownReached(cooldownMSOffset)) {
         return false;
      } else {
         boolean validNext = isBestMomentToHit(fallCheck);
         if (validNext && rayCast && !anyEntityOnRay(livingTarget, ranges[0])) {
            validNext = false;
         }
         return validNext;
      }
   }

   public static boolean shouldAttack(LivingEntity livingTarget, boolean rayCast, boolean fallCheck, long cooldownMSOffset, float[] ranges) {
      return shouldAttack(livingTarget, rayCast, true, fallCheck, cooldownMSOffset, ranges);
   }

   public static boolean resetSprintTickP(LivingEntity targetIn, float[] ranges) {
      return targetIn != null
              && shouldAttack(targetIn, false, false, -80L, ranges)
              && !mc.player.isOnGround()
              && !mc.player.isSubmergedIn(FluidTags.WATER)
              && mc.player.getVelocity().y <= 0.0030162615090425808;
   }

   public static boolean resetSprintTick(LivingEntity targetIn, float[] ranges) {
      return targetIn != null
              && shouldAttack(targetIn, false, false, -60L, ranges)
              && !mc.player.isOnGround()
              && !mc.player.isSubmergedIn(FluidTags.WATER)
              && mc.player.getVelocity().y <= 0.16477328182606651;
   }

   private static int maxHitsCountOnMiss() {
      return 3;
   }

   public static void antiMissesHittingReset() {
      missDetected = false;
      counterTo0PostMissHits = 0;
   }

   public static void antiMissesHittingUpdate(LivingEntity targetIn, boolean cpsBypass, boolean rayCastCheck, boolean enabled) {
      if (targetIn == null || counterTo0PostMissHits == 0 || !enabled || targetIn.hurtTime != 0) {
         antiMissesHittingReset();
      }

      if (enabled && targetIn != null && msCooldownHasMs(cpsBypassTrigger() ? 250L : 150L) && mc.player.handSwinging) {
         if (!missDetected && counterTo0PostMissHits == 0 && targetIn.hurtTime == 0) {
            missDetected = true;
            counterTo0PostMissHits = maxHitsCountOnMiss();
         }

         if (missDetected
                 && counterTo0PostMissHits > 0
                 && targetIn != null
                 && (!rayCastCheck || anyEntityOnRay(targetIn, 6.0))
                 && useEntity(targetIn, () -> {}, () -> {}, Hand.MAIN_HAND, cpsBypass)) {
            counterTo0PostMissHits--;
         }
      }
   }

   @Generated
   private Attack() {
      throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
   }

   @Generated
   public static StopWatch getCooldownTimer() {
      return cooldownTimer;
   }
}
Код:
Expand Collapse Copy
package ru.night.module.impl.combat.auraProcess;

import java.security.SecureRandom;
import java.util.concurrent.ThreadLocalRandom;
import lombok.Generated;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.MathHelper;
import ru.night.module.impl.combat.HitAura;
import ru.night.module.impl.combat.auraProcess.auraUtil.AuraUtil;
import ru.night.module.impl.combat.auraProcess.auraUtil.UBoxPoints;
import ru.night.module.impl.combat.auraProcess.rotationProcess.impl.FreeLookUtil;
import ru.night.module.impl.combat.auraProcess.rotationProcess.impl.Rotation;
import ru.night.module.impl.combat.auraProcess.rotationProcess.impl.RotationProcess;
import ru.night.util.other.IMinecraft;
import ru.night.util.other.Mathf;
import ru.night.util.other.TimerUtil;
import ru.night.util.render.math.animation.anim2.Interpolator;

@Environment(EnvType.CLIENT)
public final class Rotate implements IMinecraft {
   static int tick;
   static float tickF;
   static TimerUtil time1 = new TimerUtil();
   static TimerUtil time2 = new TimerUtil();

   public static void onFunTimeRotation(LivingEntity target, boolean isAttack, float attackDistance, boolean check) {
      long currentTime = System.currentTimeMillis();
      if (!HitAura.isLookingUp && currentTime - HitAura.lastLookUpTime >= HitAura.nextLookUpDelay) {
         HitAura.isLookingUp = true;
         HitAura.lookUpStartTime = currentTime;
         HitAura.lookUpDuration = ThreadLocalRandom.current().nextInt(270, 390);
         HitAura.lastLookUpTime = currentTime;
         HitAura.nextLookUpDelay = ThreadLocalRandom.current().nextLong(6500L, 7200L);
      }

      boolean fastspeed = false;
      if (HitAura.isLookingUp && currentTime - HitAura.lookUpStartTime >= HitAura.lookUpDuration) {
         HitAura.isLookingUp = false;
      }

      if (currentTime - HitAura.lookUpStartTime >= HitAura.lookUpDuration + 40L) {
         fastspeed = true;
      }

      Vec3d playerEyePos = mc.player.getEyePos();
      float oscillY = (float)Math.cos(System.currentTimeMillis() / 450.0);
      float offsetY = 0.06F * oscillY;
      float oscillZ = (float)Math.cos(System.currentTimeMillis() / 500.0);
      float offsetZ = 0.06F * oscillZ;
      float oscillX = (float)Math.cos(System.currentTimeMillis() / 14000.0);
      float oscillX3 = (float)Math.cos(System.currentTimeMillis() / 2500L);
      float offsetX = 0.5F * oscillX;
      Vec3d directionVec = AuraUtil.getVector3(target);
      float baseYaw = FreeLookUtil.freeYaw;
      if (isAttack && AuraUtil.getStrictDistance(target) < attackDistance && !check) {
         tickF = Mathf.randomValue(6.0F, 7.0F);
      }

      float yawChangeSpeed = Mathf.randomValue(22.0F, 28.0F);
      float randomAttackShift = 0.0F;
      float pitchChangeSpeed = Mathf.randomValue(0.0F, 3.5F);
      float waveA = (float)Math.cos(System.currentTimeMillis() / 40.0);
      float waveB = (float)Math.sin(System.currentTimeMillis() / 70.0);
      if (tickF > 0.0F) {
         yawChangeSpeed = Mathf.randomValue(70.0F, 120.0F);
         baseYaw = (float)Math.toDegrees(Math.atan2(-directionVec.x, directionVec.z));
         randomAttackShift = (waveA + waveB) * randomLerp(1.0F, 2.0F);
         tickF--;
      }

      float basePitch = (float)MathHelper.clamp(
         -Math.toDegrees(Math.atan2(directionVec.y, Math.hypot(directionVec.x, directionVec.z))), -90.0, 90.0
      );
      float yawJitter = waveA * randomLerp(13.0F, 15.0F) + randomAttackShift;
      float pitchJitter = waveB * randomLerp(5.0F, 7.0F) + randomAttackShift;
      float finalPitch = HitAura.isLookingUp ? -Mathf.randomValue(80.0F, 90.0F) : basePitch;
      Rotation newRotation = new Rotation(baseYaw + yawJitter, finalPitch + pitchJitter);
      RotationProcess.update(
         newRotation,
         yawChangeSpeed,
         HitAura.isLookingUp ? randomLerp(120.0F, 170.0F) : (fastspeed ? randomLerp(120.0F, 170.0F) : randomLerp(6.0F, 8.0F)),
         25.0F,
         25.0F,
         0,
         15,
         false
      );
   }

   public static float randomLerp(float min, float max) {
      return Interpolator.lerp(max, min, new SecureRandom().nextFloat());
   }

   public static void onSpookyRotation(LivingEntity target, boolean attack) {
      float addyVacY = 0.02F * (float)Math.sin(System.currentTimeMillis() / 1200.0);
      float addyVacZ = 0.03F * (float)Math.sin(System.currentTimeMillis() / 900.0) + 0.02F * (float)Math.cos(System.currentTimeMillis() / 1200.0);
      float addyVacX = 0.4F * (float)Math.cos(System.currentTimeMillis() / 700L) + 0.04F * (float)Math.sin(System.currentTimeMillis() / 900.0);
      Vec3d vec = UBoxPoints.getBestVector3dOnEntityBox(target.getBoundingBox(), false).subtract(mc.player.getEyePos());
      boolean attackF = false;
      if (attack) {
         tick = 4;
      }

      if (tick > 0) {
         attackF = true;
         tick--;
      }

      float yaw = (float)Math.toDegrees(Math.atan2(-vec.x, vec.z));
      float pitch = (float)MathHelper.clamp(-Math.toDegrees(Math.atan2(vec.y, Math.hypot(vec.x, vec.z))), -90.0, 90.0);
      float randomToAttack = 0.0F;
      if (attackF) {
         randomToAttack = Mathf.random(-3.0F, 4.0F) + (float)(2.0 * Math.sin(System.currentTimeMillis() / 30.0));
      }

      float randomXY = Mathf.random(-3.0F, 3.0F) + (float)(3.0 * Math.cos(System.currentTimeMillis() / 40.0));
      float randomX = Mathf.random(-1.0F, 1.0F) + (float)(6.0 * Math.sin(System.currentTimeMillis() / 240.0));
      Rotation newRotation = new Rotation(yaw + randomXY + randomToAttack, pitch + randomX);
      RotationProcess.update(newRotation, Mathf.randomInt(90, 110), Mathf.randomValue(16.0F, 21.0F), 30.0F, 30.0F, 1, 15, false);
   }

   public static void onHolyRotation(LivingEntity target, boolean attack) {
      float addyVacY = 0.3F * (float)Math.cos(System.currentTimeMillis() / 2200.0);
      float addyVacZ = 0.03F * (float)Math.sin(System.currentTimeMillis() / 900.0) + 0.06F * (float)Math.cos(System.currentTimeMillis() / 1200.0);
      float addyVacX = 0.2F * (float)Math.cos(System.currentTimeMillis() / 700.0) + 0.04F * (float)Math.sin(System.currentTimeMillis() / 900.0);
      Vec3d playerEyePos = mc.player.getEyePos();
      Vec3d vec = target.getPos().add(addyVacX, target.getHeight() - 0.35F - addyVacY, addyVacZ).subtract(playerEyePos).normalize();
      boolean attackF = false;
      if (attack) {
         tick = 4;
      }

      if (tick > 0) {
         attackF = true;
         tick--;
      }

      float yaw = (float)Math.toDegrees(Math.atan2(-vec.x, vec.z));
      float pitch = (float)MathHelper.clamp(-Math.toDegrees(Math.atan2(vec.y, Math.hypot(vec.x, vec.z))), -90.0, 90.0);
      float randomToAttack = 0.0F;
      if (attackF) {
         randomToAttack = (float)(3.0 * Math.sin(System.currentTimeMillis() / 30.0))
            + (float)(Mathf.randomInt(3, 4) * Math.cos(System.currentTimeMillis() / 60.0));
      }

      Rotation newRotation = new Rotation(
         yaw + randomToAttack + ThreadLocalRandom.current().nextFloat(-2.0F, 2.0F), pitch + ThreadLocalRandom.current().nextFloat(-2.0F, 2.0F) + randomToAttack
      );
      RotationProcess.update(
         newRotation, (float)Mathf.randomWithUpdate(60.0, 80.0, 70L, time1), (float)Mathf.randomWithUpdate(10.0, 20.0, 240L, time2), 30.0F, 30.0F, 1, 15, false
      );
   }

   public static void onAresRotation(LivingEntity target, boolean attack) {
      Vec3d playerEyePos = mc.player.getEyePos();
      Vec3d vec = target.getPos().add(0.0, target.getHeight() / 2.0F, 0.0).subtract(playerEyePos).normalize();
      float yaw = (float)Math.toDegrees(Math.atan2(-vec.x, vec.z));
      float pitch = (float)MathHelper.clamp(-Math.toDegrees(Math.atan2(vec.y, Math.hypot(vec.x, vec.z))), -90.0, 90.0);
      float spy = 180.0F;
      float spx = 45.0F;
      Rotation newRotation = new Rotation(yaw + ThreadLocalRandom.current().nextFloat(-2.0F, 2.0F), pitch + ThreadLocalRandom.current().nextFloat(-1.0F, 1.0F));
      RotationProcess.update(newRotation, spx, spy, spx, spy, 0, 15, false);
   }

   public static void onMatrixRotation(LivingEntity target, boolean attack) {
      float addyVacY = target.getHeight() / 2.0F * (float)Math.cos(System.currentTimeMillis() / 2200.0);
      float addyVacZ = 0.16F * (float)Math.cos(System.currentTimeMillis() / 1250.0);
      float addyVacX = 0.22F * (float)Math.sin(System.currentTimeMillis() / 1700.0);
      Vec3d vec = UBoxPoints.getBestVector3dOnEntityBox(target.getBoundingBox(), false)
         .add(addyVacX, addyVacY, addyVacZ)
         .subtract(mc.player.getEyePos());
      float yaw = (float)Math.toDegrees(Math.atan2(-vec.x, vec.z));
      float pitch = (float)MathHelper.clamp(-Math.toDegrees(Math.atan2(vec.y, Math.hypot(vec.x, vec.z))), -90.0, 90.0);
      float spy = Mathf.random(7.0F, 9.0F);
      float spx = Mathf.randomInt(60, 80);
      Rotation newRotation = new Rotation(yaw + Mathf.randomInt(-1, 2), pitch);
      RotationProcess.update(newRotation, spx, spy, Mathf.randomInt(20, 30), Mathf.randomInt(20, 30), 1, 15, false);
   }

   public static void onPolarRotation(LivingEntity target, boolean attack) {
   }

   public static void onSnapRotation(LivingEntity target, boolean attack, String type) {
      float addyVacY = 0.25F * (float)Math.cos(System.currentTimeMillis() / 1500L);
      float addyVacZ = 0.2F * (float)Math.cos(System.currentTimeMillis() / 700L);
      float addyVacX = 0.2F * (float)Math.cos(System.currentTimeMillis() / 900L);
      Vec3d playerEyePos = mc.player.getEyePos();
      Vec3d vec = target.getPos()
         .add(addyVacX, MathHelper.clamp(playerEyePos.y - target.getPos().y, 0.0, 0.8) - addyVacY, addyVacZ)
         .subtract(playerEyePos)
         .normalize();
      if (type.contains("Fast")) {
         float yaw = FreeLookUtil.freeYaw;
         float pitch = FreeLookUtil.freePitch;
         float speed = Mathf.random(190.0F, 245.0F);
         if (attack) {
            yaw = (float)Math.toDegrees(Math.atan2(-vec.x, vec.z));
            pitch = (float)MathHelper.clamp(-Math.toDegrees(Math.atan2(vec.y, Math.hypot(vec.x, vec.z))), -90.0, 90.0);
         }

         float rx = 0.0F;
         float ry = 0.0F;
         RotationProcess.update(new Rotation(yaw + rx, pitch + ry), speed, speed, 40.0F, 40.0F, 1, 7, false);
      } else if (type.contains("Smooth")) {
         float yaw = FreeLookUtil.freeYaw;
         float pitch = FreeLookUtil.freePitch;
         float speed = 24.0F;
         if (attack) {
            tick = 3;
            speed = 88.0F;
         }

         if (tick > 0) {
            yaw = (float)Math.toDegrees(Math.atan2(-vec.x, vec.z));
            pitch = (float)MathHelper.clamp(-Math.toDegrees(Math.atan2(vec.y, Math.hypot(vec.x, vec.z))), -90.0, 90.0);
            tick--;
         }

         float rx = 0.0F;
         float ry = 0.0F;
         RotationProcess.update(new Rotation(yaw + rx, pitch + ry), speed, speed, 40.0F, 40.0F, 1, 7, false);
      } else if (type.contains("Random")) {
         float yawx = FreeLookUtil.freeYaw;
         float pitchx = FreeLookUtil.freePitch;
         float speedx = Mathf.random(30.0F, 35.0F);
         if (attack) {
            tick = Mathf.randomInt(2, 4);
         }

         if (tick > 0) {
            speedx = Mathf.random(140.0F, 220.0F);
            yawx = (float)Math.toDegrees(Math.atan2(-vec.x, vec.z));
            pitchx = (float)MathHelper.clamp(-Math.toDegrees(Math.atan2(vec.y, Math.hypot(vec.x, vec.z))), -90.0, 90.0);
            tick--;
         }

         float randomXY = ThreadLocalRandom.current().nextFloat(-3.0F, 3.0F)
            + (float)(Mathf.random(4.0F, 5.0F) * Math.cos(System.currentTimeMillis() / 150.0))
            + (float)(Mathf.random(4.0F, 5.0F) * Math.sin(System.currentTimeMillis() / 50.0))
            + (float)(Mathf.random(5.0F, 8.0F) * Math.sin(System.currentTimeMillis() / 130.0))
               * (float)(Mathf.random(4.0F, 7.0F) * Math.cos(System.currentTimeMillis() / 650.0))
            + (float)(Mathf.random(12.0F, 18.0F) * Math.sin(System.currentTimeMillis() / 80.0))
               * (float)(Mathf.random(2.0F, 3.0F) * Math.cos(System.currentTimeMillis() / 2650.0));
         float randomX = ThreadLocalRandom.current().nextFloat(-1.0F, 1.0F)
            + (float)(Mathf.random(2.0F, 3.0F) * Math.cos(System.currentTimeMillis() / 170.0))
            + (float)(Mathf.random(3.0F, 4.0F) * Math.sin(System.currentTimeMillis() / 70.0))
            + (float)(Mathf.random(1.0F, 2.0F) * Math.sin(System.currentTimeMillis() / 110.0))
               * (float)(Mathf.random(1.0F, 2.0F) * Math.cos(System.currentTimeMillis() / 350.0));
         RotationProcess.update(new Rotation(yawx + randomXY / 4.0F, pitchx + randomX), speedx, speedx, 40.0F, 40.0F, 1, 7, false);
      }
   }

   @Generated
   private Rotate() {
      throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
   }
}
 
Назад
Сверху Снизу