Начинающий
- Статус
- Оффлайн
- Регистрация
- 28 Ноя 2023
- Сообщения
- 8
- Реакции
- 0
package dev.simplevisuals.client.events.impl;
import dev.simplevisuals.client.managers.FriendsManager;
import dev.simplevisuals.modules.api.Category;
import dev.simplevisuals.modules.api.Module;
import dev.simplevisuals.modules.settings.impl.BooleanSetting;
import dev.simplevisuals.modules.settings.impl.NumberSetting;
import meteordevelopment.orbit.EventHandler;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.network.packet.c2s.play.PlayerInteractEntityC2SPacket;
import net.minecraft.util.math.MathHelper;
public class AimAssist extends Module {
private final NumberSetting distance = new NumberSetting("Дистанция", 5.0f, 2.0f, 7.0f, 0.1f);
private final NumberSetting yawSpeed = new NumberSetting("Яв скорость", 110.0f, 0.0f, 200.0f, 1.0f);
private final NumberSetting pitchSpeed = new NumberSetting("Пич скорость", 35.0f, 0.0f, 100.0f, 1.0f);
private final BooleanSetting targetFriends = new BooleanSetting("Таргет Друзей", false);
private final BooleanSetting targetInvisible = new BooleanSetting("Таргет Инвизок", false);
private PlayerEntity currentTarget;
public AimAssist() {
super("AimAssist", Category.Utility, "Аим");
getSettings().add(distance);
getSettings().add(yawSpeed);
getSettings().add(pitchSpeed);
getSettings().add(targetFriends);
getSettings().add(targetInvisible);
}
@override
public void onEnable() {
super.onEnable();
currentTarget = null;
}
@override
public void onDisable() {
super.onDisable();
currentTarget = null;
}
@EventHandler
public void onPacket(EventPacket.Send event) {
if (fullNullCheck()) return;
if (event.getPacket() instanceof PlayerInteractEntityC2SPacket) {
PlayerInteractEntityC2SPacket packet = (PlayerInteractEntityC2SPacket) event.getPacket();
try {
int entityId = getEntityIdFromPacket(packet);
Entity targetEntity = mc.world.getEntityById(entityId);
if (targetEntity instanceof PlayerEntity) {
currentTarget = (PlayerEntity) targetEntity;
}
} catch (Exception e) {
}
}
}
@EventHandler
public void onPlayerTick(EventPlayerTick event) {
if (fullNullCheck()) return;
if (currentTarget != null) {
if (mc.player.distanceTo(currentTarget) <= distance.getValue()) {
float[] targetRotations = calculateRotations(currentTarget);
float newYaw = smoothRotation(mc.player.getYaw(), targetRotations[0], yawSpeed.getValue() / 100.0f);
float newPitch = smoothRotation(mc.player.getPitch(), targetRotations[1], pitchSpeed.getValue() / 100.0f);
mc.player.setYaw(newYaw);
mc.player.setPitch(newPitch);
} else {
currentTarget = null;
}
} else {
currentTarget = findClosestPlayer();
}
}
private PlayerEntity findClosestPlayer() {
PlayerEntity closestPlayer = null;
double closestDistanceSq = Double.MAX_VALUE;
float maxDistance = distance.getValue();
for (Entity entity : mc.world.getEntities()) {
if (!(entity instanceof PlayerEntity)) continue;
if (entity == mc.player) continue;
PlayerEntity player = (PlayerEntity) entity;
if (!targetFriends.getValue() && FriendsManager.checkFriend(player.getName().getString())) {
continue;
}
if (!targetInvisible.getValue() && player.isInvisible()) {
continue;
}
if (player.isSpectator() || player.isCreative()) {
continue;
}
double distanceSq = mc.player.squaredDistanceTo(player);
if (distanceSq < closestDistanceSq && distanceSq <= maxDistance * maxDistance) {
closestPlayer = player;
closestDistanceSq = distanceSq;
}
}
return closestPlayer;
}
private float[] calculateRotations(Entity entity) {
double x = entity.getX() - mc.player.getX();
double y = entity.getEyeY() - mc.player.getEyeY();
double z = entity.getZ() - mc.player.getZ();
double dist = Math.sqrt(x * x + z * z);
float yaw = (float) ((Math.atan2(z, x) * 180 / Math.PI) - 90);
float pitch = (float) (-(Math.atan2(y, dist) * 180 / Math.PI));
return new float[]{yaw, pitch};
}
private float smoothRotation(float current, float target, float factor) {
float delta = MathHelper.wrapDegrees(target - current);
return current + delta * factor;
}
private int getEntityIdFromPacket(PlayerInteractEntityC2SPacket packet) {
try {
var field = packet.getClass().getDeclaredField("entityId");
field.setAccessible(true);
return (int) field.get(packet);
} catch (Exception e) {
return -1;
}
}
}
import dev.simplevisuals.client.managers.FriendsManager;
import dev.simplevisuals.modules.api.Category;
import dev.simplevisuals.modules.api.Module;
import dev.simplevisuals.modules.settings.impl.BooleanSetting;
import dev.simplevisuals.modules.settings.impl.NumberSetting;
import meteordevelopment.orbit.EventHandler;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.network.packet.c2s.play.PlayerInteractEntityC2SPacket;
import net.minecraft.util.math.MathHelper;
public class AimAssist extends Module {
private final NumberSetting distance = new NumberSetting("Дистанция", 5.0f, 2.0f, 7.0f, 0.1f);
private final NumberSetting yawSpeed = new NumberSetting("Яв скорость", 110.0f, 0.0f, 200.0f, 1.0f);
private final NumberSetting pitchSpeed = new NumberSetting("Пич скорость", 35.0f, 0.0f, 100.0f, 1.0f);
private final BooleanSetting targetFriends = new BooleanSetting("Таргет Друзей", false);
private final BooleanSetting targetInvisible = new BooleanSetting("Таргет Инвизок", false);
private PlayerEntity currentTarget;
public AimAssist() {
super("AimAssist", Category.Utility, "Аим");
getSettings().add(distance);
getSettings().add(yawSpeed);
getSettings().add(pitchSpeed);
getSettings().add(targetFriends);
getSettings().add(targetInvisible);
}
@override
public void onEnable() {
super.onEnable();
currentTarget = null;
}
@override
public void onDisable() {
super.onDisable();
currentTarget = null;
}
@EventHandler
public void onPacket(EventPacket.Send event) {
if (fullNullCheck()) return;
if (event.getPacket() instanceof PlayerInteractEntityC2SPacket) {
PlayerInteractEntityC2SPacket packet = (PlayerInteractEntityC2SPacket) event.getPacket();
try {
int entityId = getEntityIdFromPacket(packet);
Entity targetEntity = mc.world.getEntityById(entityId);
if (targetEntity instanceof PlayerEntity) {
currentTarget = (PlayerEntity) targetEntity;
}
} catch (Exception e) {
}
}
}
@EventHandler
public void onPlayerTick(EventPlayerTick event) {
if (fullNullCheck()) return;
if (currentTarget != null) {
if (mc.player.distanceTo(currentTarget) <= distance.getValue()) {
float[] targetRotations = calculateRotations(currentTarget);
float newYaw = smoothRotation(mc.player.getYaw(), targetRotations[0], yawSpeed.getValue() / 100.0f);
float newPitch = smoothRotation(mc.player.getPitch(), targetRotations[1], pitchSpeed.getValue() / 100.0f);
mc.player.setYaw(newYaw);
mc.player.setPitch(newPitch);
} else {
currentTarget = null;
}
} else {
currentTarget = findClosestPlayer();
}
}
private PlayerEntity findClosestPlayer() {
PlayerEntity closestPlayer = null;
double closestDistanceSq = Double.MAX_VALUE;
float maxDistance = distance.getValue();
for (Entity entity : mc.world.getEntities()) {
if (!(entity instanceof PlayerEntity)) continue;
if (entity == mc.player) continue;
PlayerEntity player = (PlayerEntity) entity;
if (!targetFriends.getValue() && FriendsManager.checkFriend(player.getName().getString())) {
continue;
}
if (!targetInvisible.getValue() && player.isInvisible()) {
continue;
}
if (player.isSpectator() || player.isCreative()) {
continue;
}
double distanceSq = mc.player.squaredDistanceTo(player);
if (distanceSq < closestDistanceSq && distanceSq <= maxDistance * maxDistance) {
closestPlayer = player;
closestDistanceSq = distanceSq;
}
}
return closestPlayer;
}
private float[] calculateRotations(Entity entity) {
double x = entity.getX() - mc.player.getX();
double y = entity.getEyeY() - mc.player.getEyeY();
double z = entity.getZ() - mc.player.getZ();
double dist = Math.sqrt(x * x + z * z);
float yaw = (float) ((Math.atan2(z, x) * 180 / Math.PI) - 90);
float pitch = (float) (-(Math.atan2(y, dist) * 180 / Math.PI));
return new float[]{yaw, pitch};
}
private float smoothRotation(float current, float target, float factor) {
float delta = MathHelper.wrapDegrees(target - current);
return current + delta * factor;
}
private int getEntityIdFromPacket(PlayerInteractEntityC2SPacket packet) {
try {
var field = packet.getClass().getDeclaredField("entityId");
field.setAccessible(true);
return (int) field.get(packet);
} catch (Exception e) {
return -1;
}
}
}