Скрытое содержимое
Типа так:
package me.deqes.mixin;
import me.deqes.Client;
import me.deqes.event.impl.EventMotion;
import me.deqes.module.impl.combat.Aura;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayNetworkHandler;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket;
import net.minecraft.util.math.MathHelper;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import static me.deqes.util.Wrapper.mc;
@Mixin(ClientPlayerEntity.class)
public abstract class ClientPlayerEntityMixin {
@Shadow
protected abstract void sendSprintingPacket();
@Shadow
protected abstract boolean isCamera();
@Shadow
private double lastX;
@Shadow
private double lastBaseY;
@Shadow
private double lastZ;
@Shadow
private int ticksSinceLastPositionPacketSent;
@Shadow
@FINAL
public ClientPlayNetworkHandler networkHandler;
@Shadow
private boolean lastOnGround;
@Shadow
private boolean lastHorizontalCollision;
@Shadow
private boolean autoJumpEnabled;
@Shadow
@FINAL
protected MinecraftClient client;
@Shadow
private float lastYaw;
@Shadow
private float lastPitch;
/**
*
@Author deqes
*
@Reason vi vse gavno! mi vse gavno! gavno dolzhno govorit gromche!!! MI VSE GOVNO!!!
*/
@Overwrite
private void sendMovementPackets() {
this.sendSprintingPacket();
if (Client.getInstance().getModuleManager().getModule(Aura.class).isToggled()) {
if (this.isCamera()) {
double d = mc.player.getX() - this.lastX;
double e = mc.player.getY() - this.lastBaseY;
double f = mc.player.getZ() - this.lastZ;
double g = Aura.yawToSend - this.lastYaw;
double h = Aura.pitchToSend - this.lastPitch;
++this.ticksSinceLastPositionPacketSent;
boolean bl = MathHelper.squaredMagnitude(d, e, f) > MathHelper.square(2.0E-4) || this.ticksSinceLastPositionPacketSent >= 20;
boolean bl2 = g != (double)0.0F || h != (double)0.0F;
if (bl && bl2) {
this.networkHandler.sendPacket(new PlayerMoveC2SPacket.Full(mc.player.getX(), mc.player.getY(), mc.player.getZ(), Aura.yawToSend, Aura.pitchToSend, mc.player.isOnGround(), mc.player.horizontalCollision));
} else if (bl) {
this.networkHandler.sendPacket(new PlayerMoveC2SPacket.PositionAndOnGround(mc.player.getX(), mc.player.getY(), mc.player.getZ(), mc.player.isOnGround(), mc.player.horizontalCollision));
} else if (bl2) {
this.networkHandler.sendPacket(new PlayerMoveC2SPacket.LookAndOnGround(Aura.yawToSend, Aura.pitchToSend, mc.player.isOnGround(), mc.player.horizontalCollision));
} else if (this.lastOnGround != mc.player.isOnGround() || this.lastHorizontalCollision != mc.player.horizontalCollision) {
this.networkHandler.sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(mc.player.isOnGround(), mc.player.horizontalCollision));
}
if (bl) {
this.lastX = mc.player.getX();
this.lastBaseY = mc.player.getY();
this.lastZ = mc.player.getZ();
this.ticksSinceLastPositionPacketSent = 0;
}
if (bl2) {
this.lastYaw = Aura.yawToSend;
this.lastPitch = Aura.pitchToSend;
}
this.lastOnGround = mc.player.isOnGround();
this.lastHorizontalCollision = mc.player.horizontalCollision;
this.autoJumpEnabled = this.client.options.getAutoJump().getValue();
}
} else {
if (this.isCamera()) {
double d = mc.player.getX() - this.lastX;
double e = mc.player.getY() - this.lastBaseY;
double f = mc.player.getZ() - this.lastZ;
double g = mc.player.getYaw() - this.lastYaw;
double h = mc.player.getPitch() - this.lastPitch;
++this.ticksSinceLastPositionPacketSent;
boolean bl = MathHelper.squaredMagnitude(d, e, f) > MathHelper.square(2.0E-4) || this.ticksSinceLastPositionPacketSent >= 20;
boolean bl2 = g != (double)0.0F || h != (double)0.0F;
if (bl && bl2) {
this.networkHandler.sendPacket(new PlayerMoveC2SPacket.Full(mc.player.getX(), mc.player.getY(), mc.player.getZ(), mc.player.getYaw(), mc.player.getPitch(), mc.player.isOnGround(), mc.player.horizontalCollision));
} else if (bl) {
this.networkHandler.sendPacket(new PlayerMoveC2SPacket.PositionAndOnGround(mc.player.getX(), mc.player.getY(), mc.player.getZ(), mc.player.isOnGround(), mc.player.horizontalCollision));
} else if (bl2) {
this.networkHandler.sendPacket(new PlayerMoveC2SPacket.LookAndOnGround(mc.player.getYaw(), mc.player.getPitch(), mc.player.isOnGround(), mc.player.horizontalCollision));
} else if (this.lastOnGround != mc.player.isOnGround() || this.lastHorizontalCollision != mc.player.horizontalCollision) {
this.networkHandler.sendPacket(new PlayerMoveC2SPacket.OnGroundOnly(mc.player.isOnGround(), mc.player.horizontalCollision));
}
if (bl) {
this.lastX = mc.player.getX();
this.lastBaseY = mc.player.getY();
this.lastZ = mc.player.getZ();
this.ticksSinceLastPositionPacketSent = 0;
}
if (bl2) {
this.lastYaw = mc.player.getYaw();
this.lastPitch = mc.player.getPitch();
}
this.lastOnGround = mc.player.isOnGround();
this.lastHorizontalCollision = mc.player.horizontalCollision;
this.autoJumpEnabled = this.client.options.getAutoJump().getValue();
}
}
}
}
package me.deqes.module.impl.combat;
import com.google.common.eventbus.Subscribe;
import me.deqes.event.impl.EventMotion;
import me.deqes.event.impl.EventTick;
import me.deqes.module.Category;
import me.deqes.module.Module;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.Hand;
import net.minecraft.util.math.Vec3d;
import java.util.ArrayList;
import java.util.Random;
import static me.deqes.util.Wrapper.mc;
public class Aura extends Module {
public Aura() {
super("Aura", Category.COMBAT);
}
public static float yawToSend, pitchToSend;
LivingEntity target;
private static final Random random = new Random();
boolean shouldAttack;
@Subscribe
public void onTick(EventTick e) {
if (nullCheck()) return;
target = getMinDistTarget();
if (shouldAttack && canAttack()) {
mc.interactionManager.attackEntity(mc.player, target);
yawToSend = mc.player.getYaw();
pitchToSend = mc.player.getPitch();
shouldAttack = false;
}
if (target == null) return;
float[] angle = getRotationsToEntity(mc.player, target);
if (canAttack()) {
yawToSend = angle[0];
pitchToSend = angle[1];
shouldAttack = true;
}
}
private LivingEntity getMinDistTarget() {
ArrayList<LivingEntity> entities = new ArrayList<>();
for (Entity entity : mc.world.getEntities()) {
if (!(entity instanceof LivingEntity)) continue;
if (entity == mc.player) continue;
if (mc.player.distanceTo(entity) > 3) continue;
entities.add((LivingEntity) entity);
// if (targetsType.isEnable(0) && entity instanceof PlayerEntity) {
// entities.add((LivingEntity) entity);
// } else if (entity instanceof Monster && targetsType.isEnable(1)) {
// entities.add((LivingEntity) entity);
// } else if (entity instanceof AnimalEntity && targetsType.isEnable(2)) {
// entities.add((LivingEntity) entity);
// }
}
LivingEntity minDistEntity = null;
float minDistance = Float.MAX_VALUE;
for (LivingEntity entity : entities) {
float distance = mc.player.distanceTo(entity);
if (distance < minDistance) {
minDistance = distance;
minDistEntity = entity;
}
}
return minDistEntity;
}
private boolean canAttack() {
boolean usingItem = mc.player.isUsingItem();
boolean cooldownReady = !(mc.player.getAttackCooldownProgress(1) < 0.9);
if (usingItem) return false;
if (!cooldownReady) return false;
return true;
}
public static float[] getRotationsToEntity(ClientPlayerEntity player, LivingEntity target) {
// Позиция глаз игрока
Vec3d eyes = new Vec3d(
player.getX(),
player.getY() + player.getEyeHeight(player.getPose()),
player.getZ()
);
// Позиция цели (немного ниже глаз — в тело)
Vec3d targetPos = new Vec3d(
target.getX(),
target.getY() + target.getEyeHeight(target.getPose()) - 0.1,
target.getZ()
);
double difX = targetPos.x - eyes.x;
double difY = targetPos.y - eyes.y;
double difZ = targetPos.z - eyes.z;
double dist = Math.sqrt(difX * difX + difZ * difZ);
float yaw = (float) Math.toDegrees(Math.atan2(difZ, difX)) - 90f;
float pitch = (float) -Math.toDegrees(Math.atan2(difY, dist));
// Нормализация yaw в [-180, 180]
while (yaw > 180f) yaw -= 360f;
while (yaw < -180f) yaw += 360f;
return new float[]{yaw, pitch};
}
}