Начинающий
- Статус
- Оффлайн
- Регистрация
- 29 Дек 2024
- Сообщения
- 25
- Реакции
- 1
- Выберите загрузчик игры
- Fabric
крутой умный фейк плеер клауд код писал да ну мне нравится он крутой
module:
private static final String[] ARMOR_PIECES = {"Helmet", "Chestplate", "Leggings", "Boots"};
private static final String[] ARMOR_TYPES = {"Leather", "Chainmail", "Iron", "Golden", "Diamond", "Netherite"};
private final MultiSelectSetting armorSetting;
private final ModeSetting armorTypeSetting;
private OtherClientPlayerEntity fakePlayer;
private float moveForward;
private float moveStrafe;
public FakePlayerModule() {
super("FakePlayer", "спавнит друга которого у тебя нет", Category.PLAYER, GLFW.GLFW_KEY_UNKNOWN);
INSTANCE = this;
armorSetting = addSetting(new MultiSelectSetting("Armor", "Armor pieces", ARMOR_PIECES, "Helmet", "Chestplate", "Leggings", "Boots"));
armorTypeSetting = addSetting(new ModeSetting("Armor Type", "Armor material", "Netherite", ARMOR_TYPES));
}
public static boolean handleLocalAttack(Entity target) {
FakePlayerModule module = INSTANCE;
if (module == null || !module.isEnabled()) return false;
return module.handleLocalAttackInternal(target);
}
@Override
public void onEnable() {
moveForward = 0.0f;
moveStrafe = 0.0f;
ensureFakePlayer();
}
@Override
public void onDisable() {
moveForward = 0.0f;
moveStrafe = 0.0f;
removeFakePlayer(true);
}
@Override
public void onTick() {
MinecraftClient client = MinecraftClient.getInstance();
if (client.player == null || client.world == null) {
removeFakePlayer(false);
return;
}
ensureFakePlayer();
if (fakePlayer == null) return;
fakePlayer.setStackInHand(Hand.MAIN_HAND, client.player.getMainHandStack().copy());
fakePlayer.setStackInHand(Hand.OFF_HAND, client.player.getOffHandStack().copy());
if (moveForward == 0.0f && moveStrafe == 0.0f) {
fakePlayer.setSprinting(false);
fakePlayer.setVelocity(0.0, fakePlayer.getVelocity().y, 0.0);
return;
}
float yaw = client.player.getYaw();
double speed = 0.2;
double motionX = moveStrafe * Math.cos(Math.toRadians(yaw)) - moveForward * Math.sin(Math.toRadians(yaw));
double motionZ = moveForward * Math.cos(Math.toRadians(yaw)) + moveStrafe * Math.sin(Math.toRadians(yaw));
Vec3d velocity = new Vec3d(motionX * speed, fakePlayer.getVelocity().y, motionZ * speed);
fakePlayer.setYaw(yaw);
fakePlayer.setHeadYaw(yaw);
fakePlayer.setBodyYaw(yaw);
fakePlayer.setVelocity(velocity);
fakePlayer.move(MovementType.SELF, velocity);
fakePlayer.setSprinting(true);
}
@Override
public void onKeyInput(int key, boolean pressed) {
MinecraftClient client = MinecraftClient.getInstance();
if (fakePlayer == null || client.currentScreen != null) return;
if (key == GLFW.GLFW_KEY_UP) {
moveForward = pressed ? 1.0f : 0.0f;
} else if (key == GLFW.GLFW_KEY_DOWN) {
moveForward = pressed ? -1.0f : 0.0f;
} else if (key == GLFW.GLFW_KEY_LEFT) {
moveStrafe = pressed ? 1.0f : 0.0f;
} else if (key == GLFW.GLFW_KEY_RIGHT) {
moveStrafe = pressed ? -1.0f : 0.0f;
}
}
private boolean handleLocalAttackInternal(Entity target) {
MinecraftClient client = MinecraftClient.getInstance();
if (!(target instanceof OtherClientPlayerEntity attackedFakePlayer)) return false;
if (client.player == null || client.world == null || attackedFakePlayer != fakePlayer) return false;
if (fakePlayer.hurtTime > 0) return true;
float baseDamage = getWeaponDamage(client.player.getMainHandStack());
float cooldown = client.player.getAttackCooldownProgress(0.5f);
baseDamage *= 0.2f + cooldown * cooldown * 0.8f;
boolean isCrit = client.player.fallDistance > 0.0f
&& !client.player.isOnGround()
&& !client.player.isClimbing()
&& !client.player.isTouchingWater()
&& !client.player.hasStatusEffect(StatusEffects.BLINDNESS)
&& !client.player.hasVehicle()
&& cooldown > 0.9f;
if (isCrit) {
baseDamage *= 1.5f;
}
DamageSource source = client.world.getDamageSources().playerAttack(client.player);
float armor = computeArmorValue();
float toughness = computeArmorToughness();
float afterArmor = DamageUtil.getDamageLeft(fakePlayer, baseDamage, source, armor, toughness);
client.world.playSound(
client.player,
fakePlayer.getX(),
fakePlayer.getY(),
fakePlayer.getZ(),
SoundEvents.ENTITY_PLAYER_HURT,
SoundCategory.PLAYERS,
1.0f,
1.0f
);
if (isCrit) {
client.world.playSound(
client.player,
fakePlayer.getX(),
fakePlayer.getY(),
fakePlayer.getZ(),
SoundEvents.ENTITY_PLAYER_ATTACK_CRIT,
SoundCategory.PLAYERS,
1.0f,
1.0f
);
new EntityStatusS2CPacket(fakePlayer, (byte) 36).apply(client.player.networkHandler);
} else if (cooldown > 0.9f) {
client.world.playSound(
client.player,
fakePlayer.getX(),
fakePlayer.getY(),
fakePlayer.getZ(),
SoundEvents.ENTITY_PLAYER_ATTACK_STRONG,
SoundCategory.PLAYERS,
1.0f,
1.0f
);
} else {
client.world.playSound(
client.player,
fakePlayer.getX(),
fakePlayer.getY(),
fakePlayer.getZ(),
SoundEvents.ENTITY_PLAYER_ATTACK_SWEEP,
SoundCategory.PLAYERS,
1.0f,
1.0f
);
}
fakePlayer.onDamaged(source);
float nextHealth = fakePlayer.getHealth() - afterArmor;
if (nextHealth <= 0.0f) {
fakePlayer.setHealth(20.0f);
new EntityStatusS2CPacket(fakePlayer, (byte) 35).apply(client.player.networkHandler);
} else {
fakePlayer.setHealth(nextHealth);
}
PocoyoModeModule.handleLocalAttack(target);
HitParticlesModule.handleLocalAttack(target);
HitColorModule.handleLocalAttack(target);
KillMessageModule.handleLocalAttack(target);
KillSoundModule.handleLocalAttack(target);
HitSoundModule.handleLocalAttack(target);
return true;
}
private void ensureFakePlayer() {
MinecraftClient client = MinecraftClient.getInstance();
if (client.player == null || client.world == null) return;
if (fakePlayer != null && fakePlayer.getWorld() == client.world && !fakePlayer.isRemoved()) return;
removeFakePlayer(false);
fakePlayer = new OtherClientPlayerEntity(client.world, new GameProfile(FAKE_PLAYER_UUID, "FakePlayer"));
fakePlayer.copyPositionAndRotation(client.player);
fakePlayer.setYaw(client.player.getYaw());
fakePlayer.setHeadYaw(client.player.getHeadYaw());
fakePlayer.setBodyYaw(client.player.getBodyYaw());
fakePlayer.setHealth(20.0f);
fakePlayer.setAbsorptionAmount(0.0f);
fakePlayer.setStackInHand(Hand.MAIN_HAND, client.player.getMainHandStack().copy());
fakePlayer.setStackInHand(Hand.OFF_HAND, client.player.getOffHandStack().copy());
equipArmor();
fakePlayer.addStatusEffect(new StatusEffectInstance(StatusEffects.REGENERATION, 9999, 0));
client.world.addEntity(fakePlayer);
sendMessage("FakePlayer spawned");
}
private void equipArmor() {
if (fakePlayer == null) return;
String type = armorTypeSetting.getValue().toLowerCase(java.util.Locale.ROOT);
if (armorSetting.isSelected("Helmet")) {
fakePlayer.equipStack(EquipmentSlot.HEAD, new ItemStack(getArmorItem(type, "helmet")));
} else {
fakePlayer.equipStack(EquipmentSlot.HEAD, ItemStack.EMPTY);
}
if (armorSetting.isSelected("Chestplate")) {
fakePlayer.equipStack(EquipmentSlot.CHEST, new ItemStack(getArmorItem(type, "chestplate")));
} else {
fakePlayer.equipStack(EquipmentSlot.CHEST, ItemStack.EMPTY);
}
if (armorSetting.isSelected("Leggings")) {
fakePlayer.equipStack(EquipmentSlot.LEGS, new ItemStack(getArmorItem(type, "leggings")));
} else {
fakePlayer.equipStack(EquipmentSlot.LEGS, ItemStack.EMPTY);
}
if (armorSetting.isSelected("Boots")) {
fakePlayer.equipStack(EquipmentSlot.FEET, new ItemStack(getArmorItem(type, "boots")));
} else {
fakePlayer.equipStack(EquipmentSlot.FEET, ItemStack.EMPTY);
}
}
private static net.minecraft.item.Item getArmorItem(String type, String piece) {
return switch (type) {
case "leather" -> switch (piece) {
case "helmet" -> Items.LEATHER_HELMET;
case "chestplate" -> Items.LEATHER_CHESTPLATE;
case "leggings" -> Items.LEATHER_LEGGINGS;
default -> Items.LEATHER_BOOTS;
};
case "chainmail" -> switch (piece) {
case "helmet" -> Items.CHAINMAIL_HELMET;
case "chestplate" -> Items.CHAINMAIL_CHESTPLATE;
case "leggings" -> Items.CHAINMAIL_LEGGINGS;
default -> Items.CHAINMAIL_BOOTS;
};
case "iron" -> switch (piece) {
case "helmet" -> Items.IRON_HELMET;
case "chestplate" -> Items.IRON_CHESTPLATE;
case "leggings" -> Items.IRON_LEGGINGS;
default -> Items.IRON_BOOTS;
};
case "golden" -> switch (piece) {
case "helmet" -> Items.GOLDEN_HELMET;
case "chestplate" -> Items.GOLDEN_CHESTPLATE;
case "leggings" -> Items.GOLDEN_LEGGINGS;
default -> Items.GOLDEN_BOOTS;
};
case "diamond" -> switch (piece) {
case "helmet" -> Items.DIAMOND_HELMET;
case "chestplate" -> Items.DIAMOND_CHESTPLATE;
case "leggings" -> Items.DIAMOND_LEGGINGS;
default -> Items.DIAMOND_BOOTS;
};
default -> switch (piece) {
case "helmet" -> Items.NETHERITE_HELMET;
case "chestplate" -> Items.NETHERITE_CHESTPLATE;
case "leggings" -> Items.NETHERITE_LEGGINGS;
default -> Items.NETHERITE_BOOTS;
};
};
}
private float computeArmorValue() {
if (fakePlayer == null) return 0f;
float total = 0f;
total += getAttributeFromItem(fakePlayer.getEquippedStack(EquipmentSlot.HEAD), EntityAttributes.ARMOR);
total += getAttributeFromItem(fakePlayer.getEquippedStack(EquipmentSlot.CHEST), EntityAttributes.ARMOR);
total += getAttributeFromItem(fakePlayer.getEquippedStack(EquipmentSlot.LEGS), EntityAttributes.ARMOR);
total += getAttributeFromItem(fakePlayer.getEquippedStack(EquipmentSlot.FEET), EntityAttributes.ARMOR);
return total;
}
private float computeArmorToughness() {
if (fakePlayer == null) return 0f;
float total = 0f;
total += getAttributeFromItem(fakePlayer.getEquippedStack(EquipmentSlot.HEAD), EntityAttributes.ARMOR_TOUGHNESS);
total += getAttributeFromItem(fakePlayer.getEquippedStack(EquipmentSlot.CHEST), EntityAttributes.ARMOR_TOUGHNESS);
total += getAttributeFromItem(fakePlayer.getEquippedStack(EquipmentSlot.LEGS), EntityAttributes.ARMOR_TOUGHNESS);
total += getAttributeFromItem(fakePlayer.getEquippedStack(EquipmentSlot.FEET), EntityAttributes.ARMOR_TOUGHNESS);
return total;
}
private static float getAttributeFromItem(ItemStack stack, RegistryEntry<EntityAttribute> targetAttr) {
if (stack == null || stack.isEmpty()) return 0f;
AttributeModifiersComponent modifiers = stack.get(DataComponentTypes.ATTRIBUTE_MODIFIERS);
if (modifiers == null) return 0f;
float total = 0f;
for (AttributeModifiersComponent.Entry entry : modifiers.modifiers()) {
if (entry.attribute().matches(targetAttr)) {
EntityAttributeModifier mod = entry.modifier();
if (mod.operation() == EntityAttributeModifier.Operation.ADD_VALUE) {
total += (float) mod.value();
}
}
}
return total;
}
private static float getWeaponDamage(ItemStack stack) {
return 1.0f + getAttributeFromItem(stack, EntityAttributes.ATTACK_DAMAGE);
}
private void removeFakePlayer(boolean notify) {
if (fakePlayer == null) return;
fakePlayer.discard();
fakePlayer = null;
if (notify) {
sendMessage("FakePlayer removed");
}
}
private static void sendMessage(String message) {
XClient client = XClient.get();
if (client == null) return;
client.getCommandManager().send(message);
}
}
mixin:
Mixin(ClientPlayerInteractionManager.class)
public final class ClientPlayerInteractionManagerMixin {
@Unique
private boolean xclient$restoreRotation;
@Unique
private float xclient$prevYaw;
@Unique
private float xclient$prevPitch;
@Inject(method = "attackEntity", at = @At("HEAD"), cancellable = true)
private void xclient$silentHitboxAim(PlayerEntity player, Entity target, CallbackInfo ci) {
if (FakePlayerModule.handleLocalAttack(target)) {
ci.cancel();
return;
}
if (target instanceof PlayerEntity targetPlayer && NoFriendDamageModule.shouldBlock(targetPlayer)) {
ci.cancel();
return;
}
FakeLagModule.handleLocalAttack(target);
if (!(target instanceof PlayerEntity)) return;
if (player == target) return;
HitboxesModule hitboxes = getHitboxes();
if (hitboxes == null || !hitboxes.isSilentEnabled()) return;
if (hitboxes.getExtraWidth() <= 0.0f) return;
Vec3d from = player.getCameraPosVec(1.0f);
Vec3d to = target.getEyePos();
float[] rot = getRotations(from, to, player.getYaw(), player.getPitch());
xclient$prevYaw = player.getYaw();
xclient$prevPitch = player.getPitch();
xclient$restoreRotation = true;
player.setYaw(rot[0]);
player.setPitch(rot[1]);
SilentRotationController.push(rot[0], rot[1], 180L, false);
}
@Inject(method = "attackEntity", at = @At("RETURN"))
private void xclient$restoreSilentHitboxAim(PlayerEntity player, Entity target, CallbackInfo ci) {
PocoyoModeModule.handleLocalAttack(target);
HitParticlesModule.handleLocalAttack(target);
HitColorModule.handleLocalAttack(target);
KillMessageModule.handleLocalAttack(target);
KillSoundModule.handleLocalAttack(target);
HitSoundModule.handleLocalAttack(target);
notifyKillAuraAttackExecuted(target);
if (!xclient$restoreRotation) return;
xclient$restoreRotation = false;
player.setYaw(xclient$prevYaw);
player.setPitch(xclient$prevPitch);
}
@Unique
private static float[] getRotations(Vec3d from, Vec3d to, float baseYaw, float basePitch) {
double dx = to.x - from.x;
double dy = to.y - from.y;
double dz = to.z - from.z;
double dist = Math.sqrt(dx * dx + dz * dz);
float rawYaw = (float) (Math.toDegrees(Math.atan2(dz, dx)) - 90.0);
float yaw = baseYaw + MathHelper.wrapDegrees(rawYaw - baseYaw);
float pitch = (float) (-Math.toDegrees(Math.atan2(dy, dist)));
pitch = MathHelper.clamp(pitch, basePitch - 89.0f, basePitch + 89.0f);
pitch = MathHelper.clamp(pitch, -90.0f, 90.0f);
return new float[] { yaw, pitch };
}
@Unique
private static HitboxesModule getHitboxes() {
XClient client = XClient.get();
if (client == null) return null;
Module module = client.getModuleManager().getModuleByName("Hitboxes");
if (!(module instanceof HitboxesModule hitboxes) || !hitboxes.isEnabled()) return null;
return hitboxes;
}
@Unique
private static void notifyKillAuraAttackExecuted(Entity target) {
XClient client = XClient.get();
if (client == null || target == null) return;
Module module = client.getModuleManager().getModuleByName("KillAura");
if (module instanceof KillAuraModule killAura && killAura.isEnabled()) {
killAura.confirmQueuedAttack(target);
}
}
}