package b3.InsaneCheat.features.impl.combat;
import b3.InsaneCheat.events.impl.render.EventRender;
import b3.InsaneCheat.utils.SoundUtil;
import b3.InsaneCheat.utils.math.AuraUtil;
import b3.InsaneCheat.utils.math.GCDUtil;
import b3.InsaneCheat.utils.math.MathUtil;
import b3.InsaneCheat.events.Event;
import b3.InsaneCheat.events.impl.player.EventInput;
import b3.InsaneCheat.events.impl.player.EventInteractEntity;
import b3.InsaneCheat.events.impl.player.EventMotion;
import b3.InsaneCheat.events.impl.player.EventUpdate;
import b3.InsaneCheat.features.Category;
import b3.InsaneCheat.features.Feature;
import b3.InsaneCheat.features.FeatureInfo;
import b3.InsaneCheat.features.settings.impl.BooleanOption;
import b3.InsaneCheat.features.settings.impl.ModeSetting;
import b3.InsaneCheat.features.settings.impl.MultiBoxSetting;
import b3.InsaneCheat.features.settings.impl.SliderSetting;
import b3.InsaneCheat.manager.Manager;
import b3.InsaneCheat.utils.math.RayTraceUtil;
import b3.InsaneCheat.utils.movement.MoveUtil;
import b3.InsaneCheat.utils.world.InventoryUtil;
import net.minecraft.client.Minecraft;
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.MobEntity;
import net.minecraft.entity.passive.AnimalEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ArmorItem;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.network.play.client.CEntityActionPacket;
import net.minecraft.network.play.client.CHeldItemChangePacket;
import net.minecraft.potion.Effects;
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;
import com.mojang.blaze3d.systems.RenderSystem;
import org.lwjgl.opengl.GL11;
import java.util.*;
@SuppressWarnings("all")
@FeatureInfo(name = "Aura", type = Category.Combat)
public class Aura extends Feature {
public static LivingEntity target = null;
public Vector2f rotate = new Vector2f(0.0F, 0.0F);
private final ModeSetting rotationMode = new ModeSetting("Обход античита", "Funtime", new String[]{"Funtime", "Funtime Snap"});
private final ModeSetting sprintMode = new ModeSetting("Обход спринта", "Grim", new String[]{"Grim", "Intave"});
private final ModeSetting sortMode = new ModeSetting("Сортировать", "По всему", new String[]{"По всему", "По здоровью", "По дистанции"});
private final MultiBoxSetting targets = new MultiBoxSetting("Выбор целей", new BooleanOption[]{new BooleanOption("Игроки", true), new BooleanOption("Друзья", false), new BooleanOption("Голые Игроки", true), new BooleanOption("Монстры", true), new BooleanOption("Боты", true), new BooleanOption("Невидимые", true), new BooleanOption("Животные", true)});
private final SliderSetting distance = new SliderSetting("Дистанция аттаки", 3.0F, 1.0F, 6.0F, 0.1F);
private final SliderSetting rotateDistance = (new SliderSetting("Дистанция ротации", 0.0F, 0.0F, 32.0F, 1.0F)).setVisible(() -> {
return this.rotationMode.is("Matrix");
});
public final MultiBoxSetting settings = new MultiBoxSetting("Настройки", new BooleanOption[]{new BooleanOption("Только критами", true), new BooleanOption("Коррекция движения", true), new BooleanOption("Отжимать щит", true), new BooleanOption("Ломать щит", true), new BooleanOption("Синхронизация с TPS", false), new BooleanOption("Только с пробелом", false), new BooleanOption("Бить через шит", true), new BooleanOption("Бить через стены", true), new BooleanOption("Резольвер", true), new BooleanOption("Криты в воде", true)});
private final BooleanOption silent = (new BooleanOption("Дистанция под Grim", true)).setVisible(() -> {
return this.settings.get(1);
});
int ticksUntilNextAttack;
private boolean hasRotated;
private long cpsLimit = 0L;
private double prevCircleStep;
private double circleStep;
public Vector2f clientRot = null;
public Aura() {
addSettings(targets, rotationMode, sortMode, sprintMode, distance, rotateDistance, settings, silent);
}
public void onEvent(Event event) {
if (event instanceof EventInteractEntity) {
EventInteractEntity entity = (EventInteractEntity)event;
if (target != null) {
entity.setCancel(true);
}
}
if (event instanceof EventInput) {
EventInput eventInput = (EventInput)event;
if (this.settings.get(1) && this.silent.get()) {
float var10001;
if (Manager.FEATURE_MANAGER.autoPotion.isActivePotion) {
Minecraft.getInstance();
var10001 = mc.player.rotationYaw;
} else {
var10001 = this.rotate.x;
}
MoveUtil.fixMovement(eventInput, var10001);
}
}
if (event instanceof EventUpdate) {
EventUpdate updateEvent = (EventUpdate)event;
if (target == null || !this.isValidTarget(target)) {
target = this.findTarget();
}
if (target == null) {
this.cpsLimit = System.currentTimeMillis();
Minecraft var10003 = mc;
Minecraft var10004 = mc;
this.rotate = new Vector2f(mc.player.rotationYaw, mc.player.rotationPitch);
return;
}
this.attackAndRotateOnEntity(target);
}
if (event instanceof EventMotion) {
EventMotion motionEvent = (EventMotion)event;
this.handleMotionEvent(motionEvent);
}
/*if (event instanceof EventRender) {
EventRender e = (EventRender)event;
if (e.isRender3D() && target != null && this.settings.get(4)) {
this.drawCircle(target, e);
}
}*/
}
private void drawCircle(LivingEntity target, EventRender e) {
}
private void handleMotionEvent(EventMotion motionEvent) {
if (target != null && !Manager.FEATURE_MANAGER.autoPotion.isActivePotion) {
motionEvent.setYaw(this.rotate.x);
motionEvent.setPitch(this.rotate.y);
Minecraft var10000 = mc;
mc.player.rotationYawHead = this.rotate.x;
var10000 = mc;
mc.player.renderYawOffset = calculateCorrectYawOffset(this.rotate.x);
var10000 = mc;
mc.player.rotationPitchHead = this.rotate.y;
}
}
private void attackAndRotateOnEntity(LivingEntity target) {
this.hasRotated = false;
switch(this.rotationMode.getIndex()) {
case 0:
this.hasRotated = false;
if (this.shouldAttack(target) && RayTraceUtil.getMouseOver(target, this.rotate.x, this.rotate.y, (double)this.distance.getValue().floatValue()) == target && !Manager.FEATURE_MANAGER.autoPotion.isActivePotion) {
this.attackTarget(target);
}
if (!this.hasRotated) {
this.setRotation(target, false);
}
break;
case 1:
if (this.shouldAttack(target) && !Manager.FEATURE_MANAGER.autoPotion.isActivePotion) {
this.attackTarget(target);
this.ticksUntilNextAttack = 4;
}
if (this.ticksUntilNextAttack > 1) {
this.setRotation(target, false);
--this.ticksUntilNextAttack;
} else {
Minecraft var10001 = mc;
this.rotate.x = mc.player.rotationYaw;
var10001 = mc;
this.rotate.y = mc.player.rotationPitch;
}
}
}
public static float calculateCorrectYawOffset(float yaw) {
Minecraft var10000 = mc;
double var9 = mc.player.getPosX();
Minecraft var10001 = mc;
double xDiff = var9 - mc.player.prevPosX;
var10000 = mc;
var9 = mc.player.getPosZ();
var10001 = mc;
double zDiff = var9 - mc.player.prevPosZ;
float distSquared = (float)(xDiff * xDiff + zDiff * zDiff);
var10000 = mc;
float renderYawOffset = mc.player.prevRenderYawOffset;
float offset = renderYawOffset;
if (distSquared > 0.0025000002F) {
offset = (float)MathHelper.atan2(zDiff, xDiff) * 180.0F / 3.1415927F - 180.0F;
}
var10000 = mc;
if (mc.player != null) {
var10000 = mc;
if (mc.player.swingProgress > 0.0F) {
offset = yaw;
}
}
float yawOffsetDiff = MathHelper.wrapDegrees(yaw - (renderYawOffset + MathHelper.wrapDegrees(offset - renderYawOffset) * 0.3F));
yawOffsetDiff = MathHelper.clamp(yawOffsetDiff, -90.0F, 90.0F);
renderYawOffset = yaw - yawOffsetDiff;
if (yawOffsetDiff * yawOffsetDiff > 2500.0F) {
renderYawOffset += yawOffsetDiff * 0.2F;
}
return renderYawOffset;
}
private void attackTarget(LivingEntity targetEntity) {
Minecraft var10000;
Minecraft var10001;
if (this.settings.get(2)) {
var10000 = mc;
if (mc.player.isBlocking()) {
var10001 = mc;
mc.playerController.onStoppedUsingItem(mc.player);
}
}
boolean sprint = false;
Minecraft var10003;
if (CEntityActionPacket.lastUpdatedSprint) {
var10000 = mc;
if (!mc.player.isInWater()) {
var10000 = mc;
var10003 = mc;
mc.player.connection.sendPacket(new CEntityActionPacket(mc.player, CEntityActionPacket.Action.STOP_SPRINTING));
sprint = true;
}
}
this.cpsLimit = System.currentTimeMillis() + 550L;
var10001 = mc;
mc.playerController.attackEntity(mc.player, targetEntity);
var10000 = mc;
mc.player.swingArm(Hand.MAIN_HAND);
if (this.settings.get(3)) {
this.breakShieldAndSwapSlot();
}
if (sprint) {
var10000 = mc;
var10003 = mc;
mc.player.connection.sendPacket(new CEntityActionPacket(mc.player, CEntityActionPacket.Action.START_SPRINTING));
}
}
private void breakShieldAndSwapSlot() {
LivingEntity targetEntity = target;
if (targetEntity instanceof PlayerEntity) {
PlayerEntity player = (PlayerEntity)targetEntity;
if (target.isActiveItemStackBlocking(2) && !player.isSpectator() && !player.isCreative() && (target.getHeldItemOffhand().getItem() == Items.SHIELD || target.getHeldItemMainhand().getItem() == Items.SHIELD)) {
int slot = this.breakShield(player);
if (slot > 8) {
mc.playerController.pickItem(slot);
}
}
}
}
public int breakShield(LivingEntity target) {
int hotBarSlot = InventoryUtil.getAxe(true);
Minecraft var10000;
Minecraft var10001;
if (hotBarSlot != -1) {
var10000 = mc;
mc.player.connection.sendPacket(new CHeldItemChangePacket(hotBarSlot));
var10001 = mc;
mc.playerController.attackEntity(mc.player, target);
var10000 = mc;
mc.player.swingArm(Hand.MAIN_HAND);
var10000 = mc;
Minecraft var10003 = mc;
mc.player.connection.sendPacket(new CHeldItemChangePacket(mc.player.inventory.currentItem));
return hotBarSlot;
} else {
int inventorySLot = InventoryUtil.getAxe(false);
if (inventorySLot != -1) {
mc.playerController.pickItem(inventorySLot);
var10001 = mc;
mc.playerController.attackEntity(mc.player, target);
var10000 = mc;
mc.player.swingArm(Hand.MAIN_HAND);
return inventorySLot;
} else {
return -1;
}
}
}
private boolean shouldAttack(LivingEntity targetEntity) {
// Assume we increase the horizontal distance for the attack range
float maxHorizontalDistance = 3.0F; // Increase this for a larger horizontal attack radius
double distance = this.getDistance(targetEntity);
if (distance <= maxHorizontalDistance) {
// Attack if within range and the FOV logic also allows it
return this.canAttack() && targetEntity != null && this.cpsLimit <= System.currentTimeMillis();
}
return false;
}
private void setRotation(LivingEntity base, boolean attack) {
this.hasRotated = true;
// Get the vector from the player to the target
Vector3d targetVec = AuraUtil.getVector(base);
double diffX = targetVec.x;
double diffY = targetVec.y;
double diffZ = targetVec.z;
// Calculate yaw and pitch (yaw controls left/right, pitch controls up/down)
float targetYaw = (float) Math.toDegrees(Math.atan2(diffZ, diffX)) - 90.0F;
float targetPitch = (float) (-Math.toDegrees(Math.atan2(diffY, Math.hypot(diffX, diffZ))));
// Increase the FOV, for example 180 degrees for a full horizontal cone
if (isInFOV(targetYaw, 180)) { // Test with 180 degrees or 270
if (attack) {
// Start attacking if the target is within the larger FOV
startAttack(base);
}
} else {
return; // If outside FOV, do not attack
}
// Limit rotation speed to prevent snapping
float deltaYaw = MathHelper.wrapDegrees(targetYaw - this.rotate.x);
float deltaPitch = targetPitch - this.rotate.y;
float limitedYaw = Math.min(Math.max(Math.abs(deltaYaw), 1.0F), 180.0F);
float limitedPitch = Math.min(Math.max(Math.abs(deltaPitch), 1.0F), 180.0F);
// Final yaw and pitch values, applying smoothing based on speed limits
float finalYaw = this.rotate.x + (deltaYaw > 0.0F ? limitedYaw : -limitedYaw);
float finalPitch = MathHelper.clamp(this.rotate.y + (deltaPitch > 0.0F ? limitedPitch : -limitedPitch), -90.0F, 90.0F);
// Smooth the yaw and pitch transitions
float gcd = GCDUtil.getGCDValue();
finalYaw = (float) ((double) finalYaw - (double) (finalYaw - this.rotate.x) % (double) gcd);
finalPitch = (float) ((double) finalPitch - (double) (finalPitch - this.rotate.y) % (double) gcd);
this.rotate.x = finalYaw;
this.rotate.y = finalPitch;
}
private boolean isInFOV(float targetYaw, float fov) {
float playerYaw = this.rotate.x;
float angleDiff = MathHelper.wrapDegrees(targetYaw - playerYaw);
// Allow target to be within -90° to 90° (this is the 180° FOV for front-facing)
return Math.abs(angleDiff) <= 180.0F; // 180 degrees of field of view, allowing ±90 degrees.
}
// Метод для начала атаки
private void startAttack(LivingEntity target) {
// Логика для атаки
// Например, можно вызвать методы для атаки или другие механики игры
System.out.println("Атака на цель: " + target.getName().getString());
// Например, если у вас есть метод, который инициирует атаку, то его можно вызвать здесь
}
public boolean canAttack() {
Minecraft var10000;
boolean var3;
label65: {
if (this.settings.get(5)) {
var10000 = mc;
if (mc.player.isOnGround() && !mc.gameSettings.keyBindJump.isKeyDown()) {
var3 = true;
break label65;
}
}
var3 = false;
}
boolean onSpace;
label59: {
onSpace = var3;
var10000 = mc;
if (!mc.player.isPotionActive(Effects.BLINDNESS)) {
var10000 = mc;
if (!mc.player.isOnLadder()) {
label56: {
var10000 = mc;
if (mc.player.isInWater()) {
var10000 = mc;
if (mc.player.areEyesInFluid(FluidTags.WATER)) {
break label56;
}
}
var10000 = mc;
if (!mc.player.isRidingHorse()) {
var10000 = mc;
if (!mc.player.abilities.isFlying) {
var10000 = mc;
if (!mc.player.isElytraFlying()) {
var3 = false;
break label59;
}
}
}
}
}
}
var3 = true;
}
boolean reasonForAttack = var3;
if (!(this.getDistance(target) >= (double)this.distance.getValue().floatValue())) {
var10000 = mc;
if (!(mc.player.getCooledAttackStrength(1.5F) < 0.92F)) {
if (Manager.FEATURE_MANAGER.freeCam.player != null) {
return true;
}
if (!reasonForAttack && this.settings.get(0)) {
if (!onSpace) {
label76: {
var10000 = mc;
if (!mc.player.isOnGround()) {
var10000 = mc;
if (mc.player.fallDistance > MathUtil.randomizeFloat(0.0F, 0.3F)) {
break label76;
}
}
var3 = false;
return var3;
}
}
var3 = true;
return var3;
}
return true;
}
}
return false;
}
private LivingEntity findTarget() {
List<LivingEntity> targets = new ArrayList();
Iterator var2 = mc.world.getAllEntities().iterator();
while(var2.hasNext()) {
Entity entity = (Entity)var2.next();
if (entity instanceof LivingEntity && this.isValidTarget((LivingEntity)entity)) {
targets.add((LivingEntity)entity);
}
}
if (targets.isEmpty()) {
return null;
} else {
if (targets.size() > 1) {
String var4 = this.sortMode.get();
byte var5 = -1;
switch(var4.hashCode()) {
case -697210061:
if (var4.equals("По дистанции")) {
var5 = 1;
}
break;
case -178236820:
if (var4.equals("По всему")) {
var5 = 0;
}
break;
case 460219158:
if (var4.equals("По здоровью")) {
var5 = 2;
}
}
switch(var5) {
case 0:
targets.sort(Comparator.comparingDouble((target) -> {
if (target instanceof PlayerEntity) {
PlayerEntity player = (PlayerEntity)target;
return -this.getEntityArmor(player);
} else if (target instanceof LivingEntity) {
LivingEntity livingEntity = (LivingEntity)target;
return (double)(-livingEntity.getTotalArmorValue());
} else {
return 0.0D;
}
}).thenComparing((o, o1) -> {
double health = this.getEntityHealth((LivingEntity)o);
double health1 = this.getEntityHealth((LivingEntity)o1);
return Double.compare(health, health1);
}).thenComparing((object, object2) -> {
double d2 = this.getDistance((LivingEntity)object);
double d3 = this.getDistance((LivingEntity)object2);
return Double.compare(d2, d3);
}));
break;
case 1:
Aura var6 = Manager.FEATURE_MANAGER.aura;
Objects.requireNonNull(var6);
targets.sort(Comparator.comparingDouble(var6::getDistance).thenComparingDouble(this::getEntityHealth));
break;
case 2:
Comparator var10001 = Comparator.comparingDouble(this::getEntityHealth);
Minecraft var10002 = mc;
ClientPlayerEntity var7 = mc.player;
Objects.requireNonNull(var7);
//targets.sort(getDistance(target));
}
} else {
this.cpsLimit = System.currentTimeMillis();
}
return (LivingEntity)targets.get(0);
}
}
private boolean isValidTarget(LivingEntity base) {
if (!base.getShouldBeDead() && base.isAlive()) {
Minecraft var10001 = mc;
if (base != mc.player) {
if (base instanceof PlayerEntity) {
String playerName = base.getName().getString();
if (Manager.FRIEND_MANAGER.isFriend(playerName) && !this.targets.get(1)
|| Manager.FEATURE_MANAGER.freeCam.player != null
&& playerName.equals(Manager.FEATURE_MANAGER.freeCam.player.getName().getString())
|| base.getTotalArmorValue() == 0 && (!this.targets.get(0) || !this.targets.get(2))) {
return false;
}
}
if ((base instanceof MobEntity || base instanceof AnimalEntity) && !this.targets.get(3)) {
return false;
}
if (base instanceof PlayerEntity && !this.targets.get(0)
|| base instanceof PlayerEntity && ((PlayerEntity) base).isBot && !this.targets.get(4)) {
return false;
}
// Рассчитаем угол между вектором взгляда игрока и вектором, направленным на цель
Vector3d vec3d = AuraUtil.getVector(base); // Вектор цели
Vector3d playerVec = mc.player.getLookVec(); // Вектор взгляда игрока
// Вычисляем косинус угла между векторами
double dotProduct = playerVec.dotProduct(vec3d);
double playerLength = playerVec.length();
double targetLength = vec3d.length();
double angleCos = dotProduct / (playerLength * targetLength);
// Проверяем, если угол меньше 30 градусов (косинус угла должен быть больше 0.866)
if (angleCos < 0.866 || !mc.player.canEntityBeSeen(base)) {
return false;
}
// Проверка, что цель находится в пределах максимального расстояния
return this.getDistance(base) <= (double) (this.distance.getValue().floatValue()
+ (this.rotationMode.is("Matrix") ? this.rotateDistance.getValue().floatValue() : 0.0F));
}
}
return false;
}
private void renderFOVCircle() {
int screenWidth = mc.getMainWindow().getScaledWidth();
int screenHeight = mc.getMainWindow().getScaledHeight();
int centerX = screenWidth / 2;
int centerY = screenHeight / 2;
int radius = 50; // Радиус круга
RenderSystem.disableTexture();
RenderSystem.enableBlend();
RenderSystem.defaultBlendFunc();
GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.5F); // Прозрачность круга
GL11.glBegin(GL11.GL_LINE_LOOP);
for (int i = 0; i <= 360; i += 5) {
double angle = Math.toRadians(i);
double x = centerX + Math.cos(angle) * radius;
double y = centerY + Math.sin(angle) * radius;
GL11.glVertex2d(x, y);
}
GL11.glEnd();
RenderSystem.enableTexture();
RenderSystem.disableBlend();
}
private double getDistance(LivingEntity entity) {
return AuraUtil.getVector(entity).length();
}
public double getEntityArmor(PlayerEntity target) {
double totalArmor = 0.0D;
Iterator var4 = target.inventory.armorInventory.iterator();
while(var4.hasNext()) {
ItemStack armorStack = (ItemStack)var4.next();
if (armorStack != null && armorStack.getItem() instanceof ArmorItem) {
totalArmor += this.getProtectionLvl(armorStack);
}
}
return totalArmor;
}
public double getEntityHealth(Entity ent) {
if (ent instanceof PlayerEntity) {
PlayerEntity player = (PlayerEntity)ent;
double armorValue = this.getEntityArmor(player) / 20.0D;
return (double)(player.getHealth() + player.getAbsorptionAmount()) * armorValue;
} else if (ent instanceof LivingEntity) {
LivingEntity livingEntity = (LivingEntity)ent;
return (double)(livingEntity.getHealth() + livingEntity.getAbsorptionAmount());
} else {
return 0.0D;
}
}
private double getProtectionLvl(ItemStack stack) {
ArmorItem armor = (ArmorItem)stack.getItem();
double damageReduce = (double)armor.getDamageReduceAmount();
if (stack.isEnchanted()) {
damageReduce += (double)EnchantmentHelper.getEnchantmentLevel(Enchantments.PROTECTION, stack) * 0.25D;
}
return damageReduce;
}
public void onDisable() {
Minecraft var10003 = mc;
Minecraft var10004 = mc;
this.rotate = new Vector2f(mc.player.rotationYaw, mc.player.rotationPitch);
target = null;
this.cpsLimit = System.currentTimeMillis();
super.onDisable();
}
public static LivingEntity getTarget() {
return target;
}
}