// пенис
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.EventDisplay;
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.Setting;
import im.expensive.functions.settings.impl.BooleanSetting;
import im.expensive.functions.settings.impl.ModeListSetting;
import im.expensive.functions.settings.impl.ModeSetting;
import im.expensive.functions.settings.impl.SliderSetting;
import im.expensive.utils.client.ClientUtil;
import im.expensive.utils.math.MathUtil;
import im.expensive.utils.math.SensUtils;
import im.expensive.utils.math.StopWatch;
import im.expensive.utils.player.InventoryUtil;
import im.expensive.utils.player.MoveUtils;
import im.expensive.utils.player.PlayerUtils;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import net.minecraft.block.material.Material;
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.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.network.play.client.CEntityActionPacket;
import net.minecraft.network.play.client.CHeldItemChangePacket;
import net.minecraft.network.play.client.CEntityActionPacket.Action;
import net.minecraft.tags.FluidTags;
import net.minecraft.util.Hand;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.vector.Vector2f;
import net.minecraft.util.math.vector.Vector3d;
@FunctionRegister(
name = "AttackAura",
type = Category.Combat
)
public class KillAura extends Function {
private final ModeSetting type = new ModeSetting("Тип", "Плавная", new String[]{"Плавная", "Резкая"});
private final SliderSetting attackRange = new SliderSetting("Дистанция аттаки", 3.0F, 3.0F, 6.0F, 0.1F);
private final SliderSetting attackRotate = (new SliderSetting("Доп ротация", 1.5F, 0.0F, 3.0F, 0.1F)).setVisible(() -> {
return this.type.is("Плавная");
});
private final SliderSetting eRotate = new SliderSetting("Элитра ротация", 15.0F, 0.0F, 30.0F, 0.1F);
final ModeSetting sortTargets = new ModeSetting("Сортировать по", "Всему сразу", new String[]{"Всему сразу", "Здоровью", "Дистанции"});
final ModeListSetting targets = new ModeListSetting("Таргеты", new BooleanSetting[]{new BooleanSetting("Игроки", true), new BooleanSetting("Голые", true), new BooleanSetting("Мобы", false), new BooleanSetting("Друзья", false), new BooleanSetting("Невидимки", true)});
final ModeListSetting options = new ModeListSetting("Опции", new BooleanSetting[]{new BooleanSetting("Ломать щит", true), new BooleanSetting("Отжимать щит", true), new BooleanSetting("Синхронизировать атаку с ТПС", false), new BooleanSetting("Коррекция движения", true)});
final BooleanSetting onlyCritical = new BooleanSetting("Только криты", true);
final BooleanSetting onlySpace = (new BooleanSetting("Только с пробелом", false)).setVisible(() -> {
return (Boolean)this.onlyCritical.get();
});
final ModeSetting correctionType = new ModeSetting("Тип коррекции", "Незаметный", new String[]{"Незаметный", "Сфокусированный"});
final BooleanSetting predikt = new BooleanSetting("Предикт позиций", true);
final SliderSetting prediktZ = (new SliderSetting("Значение предикта", 75.0F, 0.0F, 100.0F, 1.0F)).setVisible(() -> {
return (Boolean)this.predikt.get();
});
private final StopWatch stopWatch = new StopWatch();
public Vector2f rotateVector = new Vector2f(0.0F, 0.0F);
private LivingEntity target;
private Entity selected;
public static float hpbypass = 0.1F;
int ticks = 0;
boolean isRotated;
final AutoPotion autoPotion;
public KillAura(AutoPotion autoPotion) {
this.autoPotion = autoPotion;
this.addSettings(new Setting[]{this.targets, this.sortTargets, this.type, this.attackRange, this.attackRotate, this.eRotate, this.options, this.onlyCritical, this.onlySpace, this.correctionType, this.predikt, this.prediktZ});
}
@Subscribe
public void onInput(EventInput eventInput) {
if ((Boolean)this.options.getValueByName("Коррекция движения").get() && this.correctionType.is("Незаметный") && this.target != null && mc.player != null) {
MoveUtils.fixMovement(eventInput, this.rotateVector.x);
}
}
@Subscribe
public void onDisplay(EventDisplay eventDisplay) {
if (this.target != null && ClientUtil.isConnectedToServer("reallyworld")) {
if (ClientUtil.isPvP()) {
this.target.setHealth(hpbypass);
} else {
this.target.setHealth(this.target.getMaxHealth() + this.target.getAbsorptionAmount());
hpbypass = this.target.getMaxHealth();
}
}
}
@Subscribe
public void onUpdate(EventUpdate e) {
if (this.target == null || !this.isValid(this.target)) {
this.updateTarget();
}
boolean elytraFly = false;
if (mc.player.isElytraFlying()) {
elytraFly = true;
}
if (this.target != null && (!this.autoPotion.isState() || !this.autoPotion.isActive())) {
this.isRotated = false;
if (this.shouldPlayerFalling() && this.stopWatch.hasTimeElapsed()) {
this.updateAttack();
this.ticks = 2;
}
if (this.type.is("Резкая") || elytraFly) {
if (this.ticks > 0) {
this.updateRotation(this.target, true);
--this.ticks;
} else {
this.reset();
}
}
if (this.type.is("Плавная") || elytraFly && !this.isRotated) {
this.updateRotation(this.target, false);
}
} else {
this.stopWatch.setLastMS(0L);
this.reset();
}
}
@Subscribe
private void onWalking(EventMotion e) {
if (this.target != null && (!this.autoPotion.isState() || !this.autoPotion.isActive())) {
float yaw = this.rotateVector.x;
float pitch = this.rotateVector.y;
e.setYaw(yaw);
e.setPitch(pitch);
mc.player.rotationYawHead = yaw;
mc.player.renderYawOffset = PlayerUtils.calculateCorrectYawOffset(yaw);
mc.player.rotationPitchHead = pitch;
}
}
private void updateTarget() {
List<LivingEntity> targets = new ArrayList();
Iterator var2 = mc.world.getAllEntities().iterator();
while(var2.hasNext()) {
Entity entity = (Entity)var2.next();
if (entity instanceof LivingEntity living) {
if (this.isValid(living)) {
targets.add(living);
}
}
}
if (targets.isEmpty()) {
this.target = null;
} else if (targets.size() == 1) {
this.target = (LivingEntity)targets.get(0);
} else {
switch ((String)this.sortTargets.get()) {
case "Всему сразу":
targets.sort(Comparator.comparingDouble((object) -> {
if (object instanceof PlayerEntity player) {
return -this.getEntityArmor(player);
} else if (object instanceof LivingEntity base) {
return (double)(-base.getTotalArmorValue());
} else {
return 0.0;
}
}).thenComparing((object, object2) -> {
double d2 = this.getEntityHealth((LivingEntity)object);
double d3 = this.getEntityHealth((LivingEntity)object2);
return Double.compare(d2, d3);
}).thenComparing((object, object2) -> {
double d2 = (double)mc.player.getDistance((LivingEntity)object);
double d3 = (double)mc.player.getDistance((LivingEntity)object2);
return Double.compare(d2, d3);
}));
break;
case "Дистанции":
KillAura var7 = Expensive.getInstance().getFunctionRegistry().getKillAura();
Objects.requireNonNull(var7);
targets.sort(Comparator.comparingDouble(var7::getDistance).thenComparingDouble(this::getEntityHealth));
break;
case "Здоровью":
Comparator var10001 = Comparator.comparingDouble(this::getEntityHealth);
ClientPlayerEntity var10002 = mc.player;
Objects.requireNonNull(var10002);
targets.sort(var10001.thenComparingDouble(var10002::getDistance));
}
this.target = (LivingEntity)targets.get(0);
}
}
private void updateRotation(LivingEntity base, boolean attack) {
this.isRotated = true;
Vector3d vec3d;
double diffX;
double diffY;
double diffZ;
if ((Boolean)this.predikt.get() && mc.player.isElytraFlying()) {
vec3d = this.target.getPositionVec().add(0.0, MathHelper.clamp(this.target.getPosY() - (double)this.target.getHeight(), 0.0, (double)(this.target.getHeight() / 2.0F)), 0.0).subtract(mc.player.getEyePosition(1.0F)).add(this.target.getMotion().mul(mc.player.isElytraFlying() && this.target.isElytraFlying() ? (double)((Float)this.prediktZ.get() / 20.0F) : 0.0, mc.player.isElytraFlying() && this.target.isElytraFlying() ? (double)((Float)this.prediktZ.get() / 20.0F) : 0.0, mc.player.isElytraFlying() && this.target.isElytraFlying() ? (double)((Float)this.prediktZ.get() / 20.0F) : 0.0));
diffX = vec3d.x;
diffY = vec3d.y;
diffZ = vec3d.z;
} else {
vec3d = getVector(base);
diffX = vec3d.x;
diffY = vec3d.y;
diffZ = vec3d.z;
}
float[] rotations = new float[]{(float)MathHelper.wrapDegrees(Math.toDegrees(Math.atan2(diffZ, diffX)) - 90.0), (float)MathHelper.wrapDegrees(Math.toDegrees(-Math.atan2(diffY, Math.hypot(diffX, diffZ))))};
float deltaYaw = MathHelper.wrapDegrees(rotations[0] - this.rotateVector.x);
float deltaPitch = MathHelper.wrapDegrees(rotations[1] - this.rotateVector.y);
float rotationDifference = (float)Math.hypot((double)Math.abs(deltaYaw), (double)Math.abs(deltaPitch));
float limitedYaw = Math.abs(deltaYaw / rotationDifference) * 360.0F;
float limitedPitch = Math.abs(deltaPitch / rotationDifference) * 90.0F;
float finalYaw = this.rotateVector.x + Math.min(Math.max(deltaYaw, -limitedYaw), limitedYaw) + (float)MathUtil.getRandom(0.0, 1.0) * 0.7F;
float finalPitch = MathHelper.clamp(this.rotateVector.y + Math.min(Math.max(deltaPitch, -limitedPitch), limitedPitch) + (float)MathUtil.getRandom(0.0, 1.0) * 0.7F, -90.0F, 90.0F);
float gcd = SensUtils.getGCDValue();
finalYaw -= (finalYaw - this.rotateVector.x) % gcd;
finalPitch -= (finalPitch - this.rotateVector.y) % gcd;
this.rotateVector = new Vector2f(finalYaw, finalPitch);
if ((Boolean)this.options.getValueByName("Коррекция движения").get()) {
mc.player.rotationYawOffset = this.rotateVector.x;
}
}
private void updateAttack() {
if (mc.player.isBlocking() && (Boolean)this.options.getValueByName("Отжимать щит").get()) {
mc.playerController.onStoppedUsingItem(mc.player);
}
boolean sprint = false;
if (CEntityActionPacket.lastUpdatedSprint && !mc.player.isInWater()) {
mc.player.connection.sendPacket(new CEntityActionPacket(mc.player, Action.STOP_SPRINTING));
sprint = true;
}
this.stopWatch.setLastMS(500L);
mc.playerController.attackEntity(mc.player, this.target);
mc.player.swingArm(Hand.MAIN_HAND);
LivingEntity var3 = this.target;
if (var3 instanceof PlayerEntity player) {
if ((Boolean)this.options.getValueByName("Ломать щит").get()) {
this.breakShieldPlayer(player);
}
}
if (sprint) {
mc.player.connection.sendPacket(new CEntityActionPacket(mc.player, Action.START_SPRINTING));
}
}
private boolean shouldPlayerFalling() {
boolean onSpace = (Boolean)this.onlySpace.get() && mc.player.isOnGround() && !mc.gameSettings.keyBindJump.isKeyDown();
boolean cancelReason = mc.player.isInWater() && mc.player.areEyesInFluid(FluidTags.WATER) || mc.player.isInLava() && mc.player.areEyesInFluid(FluidTags.LAVA) || mc.player.isOnLadder() || mc.world.getBlockState(mc.player.getPosition()).getMaterial() == Material.WEB || mc.player.abilities.isFlying;
float attackStrength = mc.player.getCooledAttackStrength((Boolean)this.options.getValueByName("Синхронизировать атаку с ТПС").get() ? Expensive.getInstance().getTpsCalc().getAdjustTicks() : 1.5F);
if (!(this.getDistance(this.target) >= (double)(Float)this.attackRange.get()) && !(mc.player.getCooledAttackStrength(attackStrength) < 0.93F)) {
if (!cancelReason && (Boolean)this.onlyCritical.get()) {
return onSpace || !mc.player.isOnGround() && mc.player.fallDistance > 0.0F;
} else {
return true;
}
} else {
return false;
}
}
private boolean isValid(LivingEntity entity) {
if (entity instanceof ClientPlayerEntity) {
return false;
} else {
float elytrarotate = mc.player.isElytraFlying() ? (Float)this.eRotate.get() : 0.0F;
if (entity.ticksExisted < 3) {
return false;
} else if (this.getDistance(entity) > (double)((Float)this.attackRange.get() + (!this.type.is("Плавная") && (!this.type.is("Резкая") || !mc.player.isElytraFlying()) ? 0.0F : (Float)this.attackRotate.get() + elytrarotate))) {
return false;
} else {
if (entity instanceof PlayerEntity) {
PlayerEntity p = (PlayerEntity)entity;
if (AntiBot.isBot(entity)) {
return false;
}
if (!(Boolean)this.targets.getValueByName("Друзья").get() && FriendStorage.isFriend(p.getName().getString())) {
return false;
}
if (p.getName().getString().equalsIgnoreCase(mc.player.getName().getString())) {
return false;
}
}
if (entity instanceof PlayerEntity) {
boolean isBare = entity.getTotalArmorValue() == 0;
boolean isInvisible = entity.isInvisible();
if (isBare && !(Boolean)this.targets.getValueByName("Голые").get()) {
return false;
}
if (isInvisible && !isBare && !(Boolean)this.targets.getValueByName("Невидимки").get()) {
return false;
}
}
if ((entity instanceof MonsterEntity || entity instanceof AnimalEntity) && !(Boolean)this.targets.getValueByName("Мобы").get()) {
return false;
} else {
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 ((Boolean)this.options.getValueByName("Коррекция движения").get()) {
mc.player.rotationYawOffset = -2.1474836E9F;
}
this.rotateVector = new Vector2f(mc.player.rotationYaw, mc.player.rotationPitch);
}
public void onEnable() {
super.onEnable();
this.reset();
this.target = null;
}
public void onDisable() {
super.onDisable();
this.reset();
this.stopWatch.setLastMS(0L);
this.target = null;
}
private double getEntityArmor(PlayerEntity entityPlayer2) {
double d2 = 0.0;
for(int i2 = 0; i2 < 4; ++i2) {
ItemStack is = (ItemStack)entityPlayer2.inventory.armorInventory.get(i2);
if (is.getItem() instanceof ArmorItem) {
d2 += this.getProtectionLvl(is);
}
}
return d2;
}
private double getProtectionLvl(ItemStack stack) {
Item var3 = stack.getItem();
if (var3 instanceof ArmorItem i) {
double damageReduceAmount = (double)i.getDamageReduceAmount();
if (stack.isEnchanted()) {
damageReduceAmount += (double)EnchantmentHelper.getEnchantmentLevel(Enchantments.PROTECTION, stack) * 0.25;
}
return damageReduceAmount;
} else {
return 0.0;
}
}
private double getEntityHealth(LivingEntity ent) {
if (ent instanceof PlayerEntity player) {
return (double)(player.getHealth() + player.getAbsorptionAmount()) * (this.getEntityArmor(player) / 20.0);
} else {
return (double)(ent.getHealth() + ent.getAbsorptionAmount());
}
}
public static Vector3d getVector(LivingEntity target) {
double wHalf = (double)(target.getWidth() / 2.0F);
double yExpand = MathHelper.clamp(target.getPosYEye() - target.getPosY(), 0.0, (double)target.getHeight());
double xExpand = MathHelper.clamp(mc.player.getPosX() - target.getPosX(), -wHalf, wHalf);
double zExpand = MathHelper.clamp(mc.player.getPosZ() - target.getPosZ(), -wHalf, wHalf);
return new Vector3d(target.getPosX() - mc.player.getPosX() + xExpand, target.getPosY() - mc.player.getPosYEye() + yExpand, target.getPosZ() - mc.player.getPosZ() + zExpand);
}
private double getDistance(LivingEntity entity) {
return getVector(entity).length();
}
public ModeSetting getType() {
return this.type;
}
public ModeListSetting getOptions() {
return this.options;
}
public StopWatch getStopWatch() {
return this.stopWatch;
}
public LivingEntity getTarget() {
return this.target;
}
public void setTarget(LivingEntity target) {
this.target = target;
}
}