Начинающий
Начинающий
- Статус
- Оффлайн
- Регистрация
- 24 Сен 2024
- Сообщения
- 81
- Реакции
- 0
я написал киллку, но не прям я, чуть дипсик помогал и я не могу сделать то что когда включена киллаура то блять тело смотрит в том же направлении как и голова, а мне надо чтобы оно было как обычное движение игрока и я не могу сделать то что при отключении киллки чтобы прицел плавно отводился от таргета а не резко
JavaScript:
package im.expensive.functions.impl.combat;
import com.google.common.eventbus.Subscribe;
import im.expensive.Expensive;
import im.expensive.command.friends.FriendStorage;
import im.expensive.events.EventInput;
import im.expensive.events.EventMotion;
import im.expensive.events.EventUpdate;
import im.expensive.functions.api.Category;
import im.expensive.functions.api.Function;
import im.expensive.functions.api.FunctionRegister;
import im.expensive.functions.settings.impl.BooleanSetting;
import im.expensive.functions.settings.impl.ModeListSetting;
import im.expensive.functions.settings.impl.SliderSetting;
import im.expensive.utils.math.SensUtils;
import im.expensive.utils.math.StopWatch;
import im.expensive.utils.player.InventoryUtil;
import im.expensive.utils.player.MouseUtil;
import im.expensive.utils.player.MoveUtils;
import lombok.Getter;
import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.item.ArmorStandEntity;
import net.minecraft.entity.monster.MonsterEntity;
import net.minecraft.entity.passive.AnimalEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.container.ClickType;
import net.minecraft.item.ArmorItem;
import net.minecraft.item.ItemStack;
import net.minecraft.network.play.client.CHeldItemChangePacket;
import net.minecraft.tags.FluidTags;
import net.minecraft.util.Hand;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RayTraceContext;
import net.minecraft.util.math.vector.Vector2f;
import net.minecraft.util.math.vector.Vector3d;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;
import static java.lang.Math.hypot;
import static net.minecraft.util.math.MathHelper.clamp;
import static net.minecraft.util.math.MathHelper.wrapDegrees;
@FunctionRegister(name = "KillAura", type = Category.Combat)
public class KillAura extends Function {
private final SliderSetting attackRange = new SliderSetting("Дистанция атаки", 3.5f, 3f, 6f, 0.1f);
private final SliderSetting rotationSpeed = new SliderSetting("Скорость поворота", 120f, 30f, 360f, 5f);
private final SliderSetting smoothness = new SliderSetting("Плавность", 0.3f, 0.1f, 1.0f, 0.05f);
private final SliderSetting humanization = new SliderSetting("Естественность", 0.8f, 0.0f, 1f, 0.1f);
private final SliderSetting critBoost = new SliderSetting("Ускорение при критах", 1.5f, 1.0f, 3.0f, 0.1f);
private final SliderSetting headShakeIntensity = new SliderSetting("Интенсивность тряски", 0.8f, 0.0f, 3.0f, 0.1f);
private final SliderSetting headShakeDuration = new SliderSetting("Длительность тряски", 1.5f, 0.5f, 3.0f, 0.1f);
private final SliderSetting bodyMovement = new SliderSetting("Движения тела", 0.5f, 0.0f, 2.0f, 0.1f);
private final SliderSetting lookReturnSpeed = new SliderSetting("Скорость возврата взгляда", 0.1f, 0.01f, 0.5f, 0.01f);
final ModeListSetting targets = new ModeListSetting("Цели",
new BooleanSetting("Игроки", true),
new BooleanSetting("Голые игроки", true),
new BooleanSetting("Мобы", false),
new BooleanSetting("Животные", false),
new BooleanSetting("Друзья", false),
new BooleanSetting("Невидимки", true));
final ModeListSetting options = new ModeListSetting("Опции",
new BooleanSetting("Ломать щит", true),
new BooleanSetting("Отжимать щит", true),
new BooleanSetting("Коррекция движения", true),
new BooleanSetting("Фокусировать одну цель", true),
new BooleanSetting("Умный выбор цели", true),
new BooleanSetting("Серверный поворот", false),
new BooleanSetting("Ускорение при критах", true),
new BooleanSetting("HollyWorld тряска", true),
new BooleanSetting("Независимая голова", true),
new BooleanSetting("Проверять стены", true),
new BooleanSetting("Естественные движения", true),
new BooleanSetting("Плавные повороты", true),
new BooleanSetting("Плавный возврат взгляда", true));
@Getter
private final StopWatch stopWatch = new StopWatch();
private Vector2f rotateVector = new Vector2f(0, 0);
@Getter
private LivingEntity target;
private Entity selected;
int ticks = 0;
boolean isRotated;
private int headShakeTicks = 0;
private boolean isShakingHead = false;
private float bodyYawOffset = 0;
private float bodyPitchOffset = 0;
private int movementTicks = 0;
private Vector2f targetBodyMovement = new Vector2f(0, 0);
private float lastServerYaw = 0;
private float lastServerPitch = 0;
private boolean isFirstRotation = true;
private float headYaw = 0;
private float headPitch = 0;
private boolean isReturningLook = false;
private float returnProgress = 0;
final AutoPotion autoPotion;
public KillAura(AutoPotion autoPotion) {
this.autoPotion = autoPotion;
addSettings(attackRange, rotationSpeed, smoothness, humanization, critBoost, headShakeIntensity, headShakeDuration, bodyMovement, lookReturnSpeed, targets, options);
}
@Subscribe
public void onInput(EventInput eventInput) {
if (options.getValueByName("Коррекция движения").get() && target != null && mc.player != null) {
MoveUtils.fixMovement(eventInput, rotateVector.x);
}
}
@Subscribe
public void onUpdate(EventUpdate e) {
updateHeadShake();
updateBodyMovement();
updateLookReturn();
if (options.getValueByName("Фокусировать одну цель").get() && (target == null || !isValid(target)) || !options.getValueByName("Фокусировать одну цель").get()) {
updateTarget();
}
if (target != null && !(autoPotion.isState() && autoPotion.isActive())) {
isRotated = false;
isReturningLook = false;
returnProgress = 0;
if (isCritCondition() && shouldAttack() && (stopWatch.hasTimeElapsed()) && canReachTarget()) {
if (options.getValueByName("HollyWorld тряска").get()) {
startHeadShake();
}
updateAttack();
ticks = 2;
}
if (!isRotated) {
updateDeepSeekRotation();
}
} else {
if (!isReturningLook && options.getValueByName("Плавный возврат взгляда").get()) {
isReturningLook = true;
returnProgress = 0;
}
stopWatch.setLastMS(0);
reset();
}
}
private void updateHeadShake() {
if (isShakingHead && headShakeTicks > 0) {
headShakeTicks--;
if (headShakeTicks <= 0) {
isShakingHead = false;
}
}
}
private void updateBodyMovement() {
if (!options.getValueByName("Естественные движения").get() || bodyMovement.get() <= 0) return;
movementTicks--;
if (movementTicks <= 0) {
float movementIntensity = bodyMovement.get();
targetBodyMovement = new Vector2f(
(ThreadLocalRandom.current().nextFloat() - 0.5f) * 5f * movementIntensity,
(ThreadLocalRandom.current().nextFloat() - 0.5f) * 3f * movementIntensity
);
movementTicks = ThreadLocalRandom.current().nextInt(30, 90);
}
float smoothFactor = 0.05f;
bodyYawOffset += (targetBodyMovement.x - bodyYawOffset) * smoothFactor;
bodyPitchOffset += (targetBodyMovement.y - bodyPitchOffset) * smoothFactor;
}
private void updateLookReturn() {
if (!isReturningLook || !options.getValueByName("Плавный возврат взгляда").get()) return;
returnProgress += lookReturnSpeed.get();
if (returnProgress >= 1.0f) {
headYaw = mc.player.rotationYaw;
headPitch = mc.player.rotationPitch;
isReturningLook = false;
returnProgress = 0;
} else {
float targetYaw = mc.player.rotationYaw;
float targetPitch = mc.player.rotationPitch;
headYaw = headYaw + (targetYaw - headYaw) * returnProgress;
headPitch = headPitch + (targetPitch - headPitch) * returnProgress;
}
}
private void startHeadShake() {
isShakingHead = true;
headShakeTicks = (int) (headShakeDuration.get() * 10f);
}
@Subscribe
private void onWalking(EventMotion e) {
if (target == null || autoPotion.isState() && autoPotion.isActive()) {
if (isReturningLook && options.getValueByName("Плавный возврат взгляда").get()) {
e.setYaw(mc.player.rotationYaw);
e.setPitch(mc.player.rotationPitch);
mc.player.rotationYawHead = headYaw;
mc.player.renderYawOffset = mc.player.rotationYaw;
} else {
e.setYaw(mc.player.rotationYaw);
e.setPitch(mc.player.rotationPitch);
mc.player.rotationYawHead = mc.player.rotationYaw;
mc.player.renderYawOffset = mc.player.rotationYaw;
}
return;
}
float yaw = rotateVector.x;
float pitch = rotateVector.y;
if (options.getValueByName("Естественные движения").get() && bodyMovement.get() > 0) {
yaw += bodyYawOffset;
pitch += bodyPitchOffset;
pitch = clamp(pitch, -90, 90);
}
e.setYaw(yaw);
e.setPitch(pitch);
if (options.getValueByName("Независимая голова").get()) {
float currentHeadYaw = yaw;
float currentHeadPitch = pitch;
if (isShakingHead && options.getValueByName("HollyWorld тряска").get()) {
float intensity = headShakeIntensity.get();
float progress = (float) headShakeTicks / (headShakeDuration.get() * 10f);
float currentIntensity = intensity * progress;
currentHeadYaw += (ThreadLocalRandom.current().nextFloat() - 0.5f) * 2f * currentIntensity;
currentHeadPitch += (ThreadLocalRandom.current().nextFloat() - 0.5f) * currentIntensity;
}
headYaw = currentHeadYaw;
headPitch = currentHeadPitch;
mc.player.rotationYawHead = currentHeadYaw;
mc.player.renderYawOffset = yaw;
} else {
mc.player.rotationYawHead = yaw;
mc.player.renderYawOffset = yaw;
}
}
private void updateTarget() {
List<LivingEntity> validTargets = new ArrayList<>();
for (Entity entity : mc.world.getAllEntities()) {
if (entity instanceof LivingEntity living && isValid(living)) {
validTargets.add(living);
}
}
if (validTargets.isEmpty()) {
target = null;
return;
}
if (options.getValueByName("Умный выбор цели").get()) {
target = selectSmartTarget(validTargets);
} else {
validTargets.sort(Comparator.comparingDouble(e -> mc.player.getDistanceSq(e)));
target = validTargets.get(0);
}
}
private LivingEntity selectSmartTarget(List<LivingEntity> targets) {
return targets.stream()
.min(Comparator.comparingDouble(this::getTargetPriority))
.orElse(null);
}
private double getTargetPriority(LivingEntity entity) {
double priority = mc.player.getDistanceSq(entity);
if (entity instanceof PlayerEntity) priority *= 0.3;
if (entity.getHealth() < 10) priority *= 0.5;
if (entity.getTotalArmorValue() < 10) priority *= 0.7;
if (isInFieldOfView(entity)) priority *= 0.8;
return priority;
}
private boolean isInFieldOfView(Entity entity) {
Vector3d targetPos = entity.getBoundingBox().getCenter();
Vector3d playerPos = mc.player.getEyePosition(1.0f);
Vector3d direction = targetPos.subtract(playerPos).normalize();
Vector3d lookVec = mc.player.getLook(1.0f);
double dot = lookVec.dotProduct(direction);
return dot > 0.5;
}
private boolean canReachTarget() {
if (!options.getValueByName("Проверять стены").get()) return true;
if (target == null) return false;
Vector3d from = mc.player.getEyePosition(1.0f);
Vector3d to = target.getBoundingBox().getCenter();
BlockRayTraceResult blockResult = mc.world.rayTraceBlocks(new RayTraceContext(
from, to, RayTraceContext.BlockMode.COLLIDER, RayTraceContext.FluidMode.NONE, mc.player
));
return blockResult.getType() == BlockRayTraceResult.Type.MISS;
}
private void updateDeepSeekRotation() {
Vector3d vec = target.getPositionVec().add(0, clamp(mc.player.getPosYEye() - target.getPosY(),
0, target.getHeight() * (mc.player.getDistanceEyePos(target) / attackRange.get())), 0)
.subtract(mc.player.getEyePosition(1.0F));
isRotated = true;
float yawToTarget = (float) MathHelper.wrapDegrees(Math.toDegrees(Math.atan2(vec.z, vec.x)) - 90);
float pitchToTarget = (float) (-Math.toDegrees(Math.atan2(vec.y, hypot(vec.x, vec.z))));
float yawDelta = wrapDegrees(yawToTarget - rotateVector.x);
float pitchDelta = wrapDegrees(pitchToTarget - rotateVector.y);
float baseRotationSpeed = rotationSpeed.get() / 25f;
float speedMultiplier = 1.0f;
float currentSmoothness = smoothness.get();
if (options.getValueByName("Ускорение при критах").get() && isCritCondition()) {
speedMultiplier = critBoost.get();
}
float maxYawSpeed = baseRotationSpeed * speedMultiplier * 1.5f;
float maxPitchSpeed = baseRotationSpeed * speedMultiplier * 1.2f;
float clampedYaw = Math.min(Math.abs(yawDelta), maxYawSpeed);
float clampedPitch = Math.min(Math.abs(pitchDelta), maxPitchSpeed);
float humanError = ThreadLocalRandom.current().nextFloat(-1.0f, 1.0f) * (1.0f - humanization.get());
if (options.getValueByName("Плавные повороты").get()) {
currentSmoothness *= 1.5f;
}
float newYaw = rotateVector.x + (yawDelta > 0 ? clampedYaw : -clampedYaw) * currentSmoothness + humanError;
float newPitch = clamp(rotateVector.y + (pitchDelta > 0 ? clampedPitch : -clampedPitch) * currentSmoothness, -89.0f, 89.0f);
float gcd = SensUtils.getGCDValue();
newYaw -= (newYaw - rotateVector.x) % gcd;
newPitch -= (newPitch - rotateVector.y) % gcd;
if (options.getValueByName("Серверный поворот").get()) {
if (isFirstRotation) {
lastServerYaw = newYaw;
lastServerPitch = newPitch;
isFirstRotation = false;
}
float serverSmoothness = 0.2f;
lastServerYaw += (newYaw - lastServerYaw) * serverSmoothness;
lastServerPitch += (newPitch - lastServerPitch) * serverSmoothness;
sendRotationPacket(lastServerYaw, lastServerPitch);
}
rotateVector = new Vector2f(newYaw, newPitch);
if (options.getValueByName("Коррекция движения").get()) {
mc.player.rotationYawOffset = newYaw;
}
}
private boolean isCritCondition() {
if (mc.player.isOnGround()) return false;
if (mc.player.fallDistance <= 0) return false;
if (mc.player.isInWater() || mc.player.isInLava()) return false;
if (mc.player.isOnLadder()) return false;
if (mc.player.isPassenger()) return false;
if (mc.player.abilities.isFlying) return false;
if (mc.player.isElytraFlying()) return false;
return true;
}
private boolean shouldAttack() {
float attackStrength = mc.player.getCooledAttackStrength(0.5f);
if (attackStrength < 1.0f) {
return false;
}
if (mc.player.isUsingItem()) {
return false;
}
return true;
}
private void sendRotationPacket(float yaw, float pitch) {
if (options.getValueByName("Серверный поворот").get()) {
mc.player.connection.sendPacket(new net.minecraft.network.play.client.CPlayerPacket.RotationPacket(
yaw, pitch, mc.player.isOnGround()
));
}
}
private void updateAttack() {
if (!canReachTarget()) {
return;
}
selected = MouseUtil.getMouseOver(target, rotateVector.x, rotateVector.y, attackRange.get());
if ((selected == null || selected != target) && !mc.player.isElytraFlying()) {
return;
}
if (mc.player.isBlocking() && options.getValueByName("Отжимать щит").get()) {
mc.playerController.onStoppedUsingItem(mc.player);
}
stopWatch.setLastMS(500);
mc.playerController.attackEntity(mc.player, target);
mc.player.swingArm(Hand.MAIN_HAND);
if (target instanceof PlayerEntity player && options.getValueByName("Ломать щит").get()) {
breakShieldPlayer(player);
}
}
private boolean isValid(LivingEntity entity) {
if (entity instanceof ClientPlayerEntity) return false;
if (entity.ticksExisted < 1) return false;
if (mc.player.getDistanceEyePos(entity) > attackRange.get()) return false;
if (options.getValueByName("Проверять стены").get() && !canReachTarget()) {
return false;
}
if (entity instanceof PlayerEntity p) {
if (AntiBot.isBot(entity)) {
return false;
}
if (!targets.getValueByName("Друзья").get() && FriendStorage.isFriend(p.getName().getString())) {
return false;
}
if (p.getName().getString().equalsIgnoreCase(mc.player.getName().getString())) return false;
if (!targets.getValueByName("Игроки").get()) return false;
if (!targets.getValueByName("Голые игроки").get() && entity.getTotalArmorValue() == 0) return false;
}
if (entity instanceof MonsterEntity && !targets.getValueByName("Мобы").get()) return false;
if (entity instanceof AnimalEntity && !targets.getValueByName("Животные").get()) return false;
if (entity.isInvisible() && !targets.getValueByName("Невидимки").get()) return false;
return !entity.isInvulnerable() && entity.isAlive() && !(entity instanceof ArmorStandEntity);
}
private void breakShieldPlayer(PlayerEntity entity) {
if (entity.isBlocking()) {
int invSlot = InventoryUtil.getInstance().getAxeInInventory(false);
int hotBarSlot = InventoryUtil.getInstance().getAxeInInventory(true);
if (hotBarSlot == -1 && invSlot != -1) {
int bestSlot = InventoryUtil.getInstance().findBestSlotInHotBar();
mc.playerController.windowClick(0, invSlot, 0, ClickType.PICKUP, mc.player);
mc.playerController.windowClick(0, bestSlot + 36, 0, ClickType.PICKUP, mc.player);
mc.player.connection.sendPacket(new CHeldItemChangePacket(bestSlot));
mc.playerController.attackEntity(mc.player, entity);
mc.player.swingArm(Hand.MAIN_HAND);
mc.player.connection.sendPacket(new CHeldItemChangePacket(mc.player.inventory.currentItem));
mc.playerController.windowClick(0, bestSlot + 36, 0, ClickType.PICKUP, mc.player);
mc.playerController.windowClick(0, invSlot, 0, ClickType.PICKUP, mc.player);
}
if (hotBarSlot != -1) {
mc.player.connection.sendPacket(new CHeldItemChangePacket(hotBarSlot));
mc.playerController.attackEntity(mc.player, entity);
mc.player.swingArm(Hand.MAIN_HAND);
mc.player.connection.sendPacket(new CHeldItemChangePacket(mc.player.inventory.currentItem));
}
}
}
private void reset() {
if (options.getValueByName("Коррекция движения").get()) {
mc.player.rotationYawOffset = Integer.MIN_VALUE;
}
rotateVector = new Vector2f(mc.player.rotationYaw, mc.player.rotationPitch);
isShakingHead = false;
headShakeTicks = 0;
bodyYawOffset = 0;
bodyPitchOffset = 0;
movementTicks = 0;
targetBodyMovement = new Vector2f(0, 0);
isFirstRotation = true;
}
@Override
public boolean onEnable() {
super.onEnable();
reset();
target = null;
headYaw = mc.player.rotationYaw;
headPitch = mc.player.rotationPitch;
return false;
}
@Override
public boolean onDisable() {
super.onDisable();
reset();
stopWatch.setLastMS(0);
target = null;
return false;
}
@Override
public void updateEntity() {
}
private double getEntityArmor(PlayerEntity entityPlayer2) {
double armor = 0.0;
for (int i = 0; i < 4; ++i) {
ItemStack is = entityPlayer2.inventory.armorInventory.get(i);
if (!(is.getItem() instanceof ArmorItem)) continue;
armor += getProtectionLvl(is);
}
return armor;
}
private double getProtectionLvl(ItemStack stack) {
if (stack.getItem() instanceof ArmorItem i) {
double damageReduceAmount = i.getDamageReduceAmount();
if (stack.isEnchanted()) {
damageReduceAmount += (double) EnchantmentHelper.getEnchantmentLevel(Enchantments.PROTECTION, stack) * 0.25;
}
return damageReduceAmount;
}
return 0;
}
}