Начинающий
- Статус
- Оффлайн
- Регистрация
- 13 Янв 2025
- Сообщения
- 31
- Реакции
- 0
- Выберите загрузчик игры
- Vanilla
- Fabric
- OptiFine
Апгрейднутая версия доджера
Не засирайте это моя 2-я тема
Не засирайте это моя 2-я тема
C++:
package wtf.loft.functions.impl.movement;
import com.google.common.eventbus.Subscribe;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.entity.projectile.*;
import wtf.loft.events.EventMotion;
import wtf.loft.events.EventUpdate;
import wtf.loft.functions.api.Category;
import wtf.loft.functions.api.Function;
import wtf.loft.functions.api.FunctionRegister;
import net.minecraft.item.PotionItem;
import net.minecraft.potion.EffectInstance;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionUtils;
import net.minecraft.util.math.vector.Vector2f;
import net.minecraft.util.math.vector.Vector3d;
import wtf.loft.functions.settings.impl.BooleanSetting;
import wtf.loft.functions.settings.impl.ModeListSetting;
import wtf.loft.functions.settings.impl.SliderSetting;
import wtf.loft.utils.math.MathUtil;
import java.util.Random;
@FunctionRegister(
name = "Dodger",
type = Category.Movement
)
public class AutoDodge extends Function {
private final Random random = new Random();
private Vector3d lastMovement = Vector3d.ZERO;
private int evasionTicks = 0;
private long lastDodgeTime;
public final SliderSetting detectionRadius = new SliderSetting("Радиус обнаружения", 6f, 3f, 10f, 0.5f);
public final SliderSetting evasionPower = new SliderSetting("Сила уклонения", 0.35f, 0.1f, 0.8f, 0.05f);
public final SliderSetting cooldown = new SliderSetting("Задержка", 1500, 500, 3000, 100);
public final SliderSetting jumpChance = new SliderSetting("Шанс прыжка", 30, 0, 100, 1);
public final ModeListSetting dodgeItems = new ModeListSetting("Уклоняться от",
new BooleanSetting("Стрел", true),
new BooleanSetting("Зелий", true),
new BooleanSetting("Снежков", true),
new BooleanSetting("Трезубцев", true),
new BooleanSetting("Огненных шаров", false));
public final BooleanSetting smartPrediction = new BooleanSetting("Умное предсказание", true);
public final BooleanSetting naturalMovement = new BooleanSetting("Естественные движения", true);
public final SliderSetting randomness = new SliderSetting("Случайность", 30, 0, 60, 1)
.setVisible(() -> naturalMovement.get());
@Subscribe
private void onUpdate(EventUpdate e) {
if (mc.world == null || mc.player == null) return;
if (evasionTicks > 0) {
evasionTicks--;
if (evasionTicks == 0 && naturalMovement.get()) {
mc.player.setMotion(lastMovement);
}
return;
}
if (System.currentTimeMillis() - lastDodgeTime < cooldown.get()) return;
for (Entity entity : mc.world.getAllEntities()) {
if (shouldProcessProjectile(entity)) {
ProjectileEntity projectile = (ProjectileEntity) entity;
if (shouldDodge(projectile)) {
Vector3d predictedPos = predictImpactPosition(projectile);
double distanceSq = mc.player.getDistanceSq(predictedPos);
if (distanceSq <= 9.0) {
performEvasion(projectile, distanceSq);
lastDodgeTime = System.currentTimeMillis();
break;
}
}
}
}
}
private boolean shouldProcessProjectile(Entity entity) {
if (!(entity instanceof ProjectileEntity)) return false;
if (entity instanceof AbstractArrowEntity) return dodgeItems.getValueByName("Стрел").get();
if (entity instanceof PotionEntity) return dodgeItems.getValueByName("Зелий").get();
if (entity instanceof SnowballEntity) return dodgeItems.getValueByName("Снежков").get();
if (entity instanceof TridentEntity) return dodgeItems.getValueByName("Трезубцев").get();
if (entity instanceof FireballEntity) return dodgeItems.getValueByName("Огненных шаров").get();
return false;
}
private boolean shouldDodge(ProjectileEntity projectile) {
if (projectile.getMotion().lengthSquared() < 0.01) return false;
if (projectile.getDistance(mc.player) > detectionRadius.get()) return false;
Vector3d toPlayer = mc.player.getPositionVec().subtract(projectile.getPositionVec()).normalize();
double dot = projectile.getMotion().normalize().dotProduct(toPlayer);
return dot > 0.7;
}
private Vector3d predictImpactPosition(ProjectileEntity projectile) {
Vector3d position = projectile.getPositionVec();
Vector3d motion = projectile.getMotion();
float gravity = getProjectileGravity(projectile);
int steps = smartPrediction.get() ? 20 : 10;
for (int i = 0; i < steps; i++) {
motion = applyPhysics(motion, gravity, projectile.isInWater());
position = position.add(motion);
if (position.y <= mc.player.getPosY()) {
break;
}
}
return position;
}
private Vector3d applyPhysics(Vector3d motion, float gravity, boolean inWater) {
double drag = inWater ? 0.8 : 0.99;
return new Vector3d(
motion.x * drag,
motion.y - gravity,
motion.z * drag
);
}
private float getProjectileGravity(ProjectileEntity projectile) {
if (projectile instanceof AbstractArrowEntity) return 0.05F;
if (projectile instanceof PotionEntity) return 0.03F;
if (projectile instanceof FireballEntity) return 0.0F;
if (projectile instanceof SnowballEntity) return 0.01F;
return 0.05F;
}
private void performEvasion(ProjectileEntity projectile, double distanceSq) {
lastMovement = mc.player.getMotion();
Vector3d toProjectile = projectile.getPositionVec().subtract(mc.player.getPositionVec()).normalize();
Vector3d evasionDirection = new Vector3d(-toProjectile.z, 0, toProjectile.x).normalize();
if (naturalMovement.get()) {
float randomAngle = (random.nextFloat() - 0.5F) * randomness.get();
evasionDirection = rotateVector(evasionDirection, randomAngle);
}
float power = MathUtil.lerp(
(float)evasionPower.getValue() * 0.5f,
(float)evasionPower.getValue(),
1.0f - (float)(distanceSq / 9.0F)
);
float verticalMotion = 0;
if (random.nextInt(100) < jumpChance.get() && mc.player.isOnGround()) {
verticalMotion = 0.2F + random.nextFloat() * 0.2F;
}
mc.player.setMotion(
evasionDirection.x * power,
verticalMotion,
evasionDirection.z * power
);
evasionTicks = naturalMovement.get() ? 5 + random.nextInt(5) : 3;
}
private Vector3d rotateVector(Vector3d vec, float angleDegrees) {
double angle = Math.toRadians(angleDegrees);
double cos = Math.cos(angle);
double sin = Math.sin(angle);
return new Vector3d(
vec.x * cos - vec.z * sin,
vec.y,
vec.x * sin + vec.z * cos
);
}
@Override
public void onDisable() {
super.onDisable();
lastDodgeTime = 0;
evasionTicks = 0;
}
public AutoDodge() {
addSettings(
detectionRadius,
evasionPower,
cooldown,
jumpChance,
dodgeItems,
smartPrediction,
naturalMovement,
randomness
);
}
}