Files
src
build.gradle
gradle.properties
manifest.kod
settings.gradle
Code
17 12,939
src/client/java/dev/gideon/GideonClient.java
package dev.gideon;
import com.mojang.brigadier.arguments.StringArgumentType;
import java.util.LinkedHashSet;
import java.util.Locale;
import java.util.Set;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.rendering.v1.EntityRendererRegistry;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.sound.SoundEvents;
import net.minecraft.text.Text;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.hit.HitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
public class GideonClient implements ClientModInitializer {
private final Set<BlockPos> shadows = new LinkedHashSet<>();
private ClientWorld lastWorld;
private double x;
private double y;
private double z;
private boolean positioned;
private int ticks;
private static GideonClient instance;
private GideonEntity companion;
private String mode = "follow";
@Override
public void onInitializeClient() {
instance = this;
EntityRendererRegistry.register(GideonEntity.TYPE, GideonRenderer::new);
ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> dispatcher.register(
ClientCommandManager.literal("gideon")
.executes(context -> {
reply("/gideon combo [static|jump|strafe|off], /s, /gideon remove, /gideon clear.");
return 1;
})
.then(ClientCommandManager.argument("question", StringArgumentType.greedyString())
.executes(context -> handle(StringArgumentType.getString(context, "question"))))
));
ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> dispatcher.register(
ClientCommandManager.literal("s").executes(context -> placeShadow())
));
CombatTelemetry.initialize();
ClientTickEvents.END_CLIENT_TICK.register(this::tick);
}
private int placeShadow() {
MinecraftClient client = MinecraftClient.getInstance();
if (client.player == null || client.world == null) return 0;
HitResult hit = client.player.raycast(5.0, 1.0f, false);
if (!(hit instanceof BlockHitResult blockHit) || hit.getType() != HitResult.Type.BLOCK) {
reply("Посмотрите на блок поблизости.");
return 0;
}
if (shadows.size() >= 32) {
reply("Достигнут предел: 32 теневых маркера. Используйте /gideon clear.");
return 0;
}
shadows.add(blockHit.getBlockPos().offset(blockHit.getSide()));
reply("Теневой маркер добавлен. Его видите только вы; коллизии нет.");
return 1;
}
private int handle(String input) {
MinecraftClient client = MinecraftClient.getInstance();
if (client.player == null || client.world == null) return 0;
String question = input.toLowerCase(Locale.ROOT).trim();
if (question.equals("combo") || question.startsWith("combo ")) {
String selected = question.equals("combo") ? "static" : question.substring(6).trim();
if (!selected.equals("static") && !selected.equals("jump") && !selected.equals("strafe") && !selected.equals("off")) {
reply("Режимы: /gideon combo static, jump, strafe или off.");
return 0;
}
mode = selected.equals("off") ? "follow" : selected;
if (companion != null) {
Vec3d pos = client.player.getEntityPos().add(client.player.getRotationVec(1.0f).multiply(3.0));
companion.setPosition(pos.x, client.player.getY(), pos.z);
companion.setVelocity(0, 0, 0);
companion.combo = 0;
}
reply("Режим Гидеона: " + mode + ".");
} else if (question.equals("remove")) {
HitResult hit = client.player.raycast(5.0, 1.0f, false);
if (hit instanceof BlockHitResult blockHit && hit.getType() == HitResult.Type.BLOCK
&& shadows.remove(blockHit.getBlockPos().offset(blockHit.getSide()))) {
reply("Теневой маркер удалён.");
} else {
reply("Посмотрите на ту же грань блока, рядом с которой поставили маркер.");
}
} else if (question.equals("clear")) {
shadows.clear();
reply("Теневые маркеры удалены.");
} else {
reply("Команды маркеров: /s, /gideon remove, /gideon clear.");
}
return 1;
}
private void reply(String message) {
MinecraftClient client = MinecraftClient.getInstance();
if (client.player != null) client.player.sendMessage(Text.literal("§bГидеон: §f" + message), false);
}
private void tick(MinecraftClient client) {
if (client.world != lastWorld) {
if (companion != null) companion.discard();
companion = null;
lastWorld = client.world;
shadows.clear();
positioned = false;
}
if (client.player == null || client.world == null) return;
if (companion == null || companion.isRemoved()) {
companion = new GideonEntity(GideonEntity.TYPE, client.world);
int id = -1;
while (client.world.getEntityById(id) != null) id--;
companion.setId(id);
companion.setPosition(client.player.getX(), client.player.getY() + 3, client.player.getZ());
client.world.addEntity(companion);
}
double orbit = ticks * 0.012;
double targetX = client.player.getX() + Math.cos(orbit) * 6.0;
double targetY = client.player.getY() + 3.0 + Math.sin(ticks * 0.035) * 0.65;
double targetZ = client.player.getZ() + Math.sin(orbit) * 6.0;
if (!positioned || Math.abs(x - targetX) + Math.abs(y - targetY) + Math.abs(z - targetZ) > 32) {
x = targetX;
y = targetY;
z = targetZ;
positioned = true;
} else {
x += (targetX - x) * 0.09;
y += (targetY - y) * 0.09;
z += (targetZ - z) * 0.09;
}
ticks++;
if (mode.equals("follow")) {
companion.resetPosition();
companion.setPosition(x, y, z);
companion.setVelocity(0, 0, 0);
} else {
if (companion.squaredDistanceTo(client.player.getEntityPos()) > 100) {
Vec3d pos = client.player.getEntityPos().add(client.player.getRotationVec(1.0f).multiply(3));
companion.setPosition(pos.x, client.player.getY(), pos.z);
companion.setVelocity(0, 0, 0);
}
if (mode.equals("strafe") && companion.hurtTicks == 0) {
Vec3d offset = companion.getEntityPos().subtract(client.player.getEntityPos());
Vec3d tangent = new Vec3d(-offset.z, 0, offset.x).normalize().multiply((ticks / 35 % 2 == 0) ? 0.08 : -0.08);
companion.setVelocity(companion.getVelocity().add(tangent));
}
if (!mode.equals("static") && companion.isOnGround() && ticks % 30 == 0) {
Vec3d velocity = companion.getVelocity();
companion.setVelocity(velocity.x, 0.42, velocity.z);
}
companion.physics();
}
if (ticks % 10 == 0) {
for (BlockPos pos : shadows) drawShadow(client.world, pos);
}
}
public static boolean attackDummy() {
GideonClient mod = instance;
MinecraftClient client = MinecraftClient.getInstance();
if (mod == null || mod.mode.equals("follow") || mod.companion == null || client.player == null || client.world == null) return false;
GideonEntity target = mod.companion;
Vec3d eye = client.player.getEyePos();
Vec3d end = eye.add(client.player.getRotationVec(1.0f).multiply(3.5));
var hit = target.getBoundingBox().raycast(eye, end);
if (hit.isEmpty()) return false;
if (client.crosshairTarget != null && client.crosshairTarget.getType() != HitResult.Type.MISS
&& eye.squaredDistanceTo(client.crosshairTarget.getPos()) + 0.001 < eye.squaredDistanceTo(hit.get())) return false;
float cooldown = client.player.getAttackCooldownProgress(0.5f);
client.player.swingHand(Hand.MAIN_HAND);
client.player.resetTicksSinceLastAttack();
if (target.hurtTicks > 0) return true;
boolean sprint = client.player.isSprinting() && cooldown > 0.9f;
boolean critical = !client.player.isOnGround() && client.player.fallDistance > 0 && cooldown > 0.9f;
Vec3d delta = target.getEntityPos().subtract(client.player.getEntityPos());
Vec3d direction = new Vec3d(delta.x, 0, delta.z).normalize();
double strength = (sprint ? 0.65 : 0.4) * (0.2 + cooldown * 0.8);
target.setVelocity(direction.x * strength, target.isOnGround() ? (sprint ? 0.42 : 0.35) : target.getVelocity().y, direction.z * strength);
target.hurtTicks = 10;
target.combo++;
target.comboTicks = 60;
target.playSound(critical ? SoundEvents.ENTITY_PLAYER_ATTACK_CRIT : sprint ? SoundEvents.ENTITY_PLAYER_ATTACK_KNOCKBACK : SoundEvents.ENTITY_PLAYER_ATTACK_STRONG, 1.0f, 1.0f);
if (critical) client.world.addParticleClient(ParticleTypes.CRIT, target.getX(), target.getY() + 1, target.getZ(), 0, 0.1, 0);
mod.reply("Комбо: " + target.combo + "x | заряд: " + Math.round(cooldown * 100) + "% | спринт: " + (sprint ? "да" : "нет") + (critical ? " | крит" : ""));
return true;
}
private void drawShadow(ClientWorld world, BlockPos pos) {