M.A.R.S
๐Ÿ“Ž 1 file 3,658 chars
๐Ÿ“„
pasted-code-1794958181378.txt
txt 55 lines
โ–ถ
You are a personal Minecraft PvP sword trainer running as a Fabric mod for Minecraft 1.21.11 (Java Edition). Coach me in sword PvP: teach every mechanic, build my muscle memory, point out mistakes in real time, confirm correct execution with a sound, and visually demonstrate techniques.

ROLE
- Act as a strict but encouraging coach.
- Track my inputs, movement, attack timing, and spacing every tick.
- Teach progressively: basics first, then advanced mechanics.

MECHANICS TO TEACH (one at a time, locked until I reach a set success rate)
- Attack cooldown: hitting at full charge (100%) vs. spam clicking, and the damage difference
- Critical hits: falling hit, no sprint, not on ground, jump-crit timing
- Sprint hits and knockback: W-tap, S-tap, sprint reset, blockhit-free knockback control
- Movement: strafing, circle strafing, jump-strafing, spacing and reach (3 blocks), angle changes
- Combos: keeping the opponent in the air, hit chaining, trade efficiency, hurt-time (invulnerability frames) awareness
- Defense: shield blocking (including the short raise delay), shield timing against sword hits, axe shield-disable awareness, strafing out of hits
- Items in combat: golden apple timing, totem swap, ender pearl escapes, fishing rod pulls, wind charge use, lava/water bucket tricks
- Situations: low health, 1v2 pressure, corner escapes, fighting on edges and in cobwebs

MUSCLE MEMORY TRAINING
- Repetition drills on one technique at a time, with a visible success counter.
- Sparring bots that imitate real players (strafing, jump-crits, W-tapping, shield use).
- Rhythm cue showing the exact tick the attack cooldown reaches full charge.
- Adaptive difficulty: faster, more aggressive bots as I improve; easier if I struggle.

MISTAKE DETECTION
- Report errors immediately as a short on-screen message plus one quick fix tip.
- Detect: hitting before cooldown is full, missed crit window, sprint not reset, bad spacing, out of reach, predictable strafing, blocking too late, wasted pearl or golden apple.
- After each session show a report: accuracy per technique, recurring errors, recommended next drill.

AUDIO FEEDBACK
- Play a confirmation sound when I execute a technique correctly.
- Different tones for perfect timing, good timing, and completed combo.
- Soft error sound on mistakes (toggleable).
- Volume and custom sound files configurable.

VISUAL TRAINER AND VISUALIZATION
- Spawn a translucent ghost player that performs the technique so I can copy it.
- Overlay timing windows, hit zones, reach range, and movement paths in the world.
- Side-by-side comparison of my attempt versus the ideal, with differences highlighted.
- Slow motion and freeze frame to break techniques into steps.
- Draw path trails of my strafing and attack angles after each round.

ITEM VISUAL STYLE
- Every item in my hands (sword, shield, totem, golden apple, any held item) is rendered with a glowing purple outline.
- All items are rendered semi-transparent so I can see the demonstrated movement through them.
- Glow color, intensity, and opacity are adjustable and toggleable in the mod config.

PROGRESS TRACKING
- Skill rating per mechanic, session history, accuracy graphs, improvement trends.
- Recommend what to practice next based on my weakest areas.

BEHAVIOR RULES
- Keep feedback short during combat; give detailed explanations between rounds.
- Show only the single most important mistake at a time.
- Always explain why the mistake happened and how to fix it.
- Stay client-side only: no gameplay advantage on servers, training works in singleplayer or a private training world.
Kodari AI
KodariTue at 11:40 pm 8
PvPSwordCoach
A client-side Fabric mod for Minecraft 1.21.11 that acts as a personal sword PvP trainer. It tracks player inputs every tick to detect mistakes in real-time, teaches mechanics progressively from attack cooldowns to advanced combos, and provides audio confirmation for correct execution. Features include ghost player demonstrations, visual overlays for timing windows and reach ranges, adaptive sparring bots, muscle memory drills with success counters, and comprehensive progress tracking with skill ratings and session reports. All held items render with adjustable glowing purple outlines, and feedback remains concise during combat with detailed explanations between rounds.

Created a singleplayer cooldown drill with a charge display, hit counter, immediate feedback and a success sound.

This is only a starting point: the other drills, bots, visualizations, configuration and persistent progress tracking are not implemented.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
settings.gradle
Code
5 150
src/client/java/dev/kodari/swordtrainer/SwordTrainerClient.java
package dev.kodari.swordtrainer;

import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.rendering.v1.hud.HudElementRegistry;
import net.fabricmc.fabric.api.event.player.AttackEntityCallback;
import net.minecraft.client.MinecraftClient;
import net.minecraft.sound.SoundEvents;
import net.minecraft.text.Text;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Identifier;

public final class SwordTrainerClient implements ClientModInitializer {
    private int attempts;
    private int successes;
    private int messageTicks;
    private String message = "Hit at full charge. Wait until the meter reaches 100%.";
    private boolean wasInWorld;

    @Override
    public void onInitializeClient() {
        AttackEntityCallback.EVENT.register((player, world, hand, target, hitResult) -> {
            MinecraftClient client = MinecraftClient.getInstance();
            if (!client.isInSingleplayer() || player != client.player) {
                return ActionResult.PASS;
            }

            float charge = player.getAttackCooldownProgress(0.0f);
            attempts++;
            if (charge >= 1.0f) {
                successes++;
                message = "Full charge! Keep that rhythm.";
                player.playSound(SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, 0.35f, 1.4f);
            } else {
                message = "Too early: damage is reduced. Wait for 100%.";
            }
            messageTicks = 80;
            return ActionResult.PASS;
        });

        ClientTickEvents.END_CLIENT_TICK.register(client -> {
            boolean inWorld = client.player != null && client.isInSingleplayer();
            if (!inWorld && wasInWorld) {
                attempts = 0;
                successes = 0;
                messageTicks = 0;
                message = "Hit at full charge. Wait until the meter reaches 100%.";
            }
            wasInWorld = inWorld;
            if (messageTicks > 0) {
                messageTicks--;
            }
        });

        HudElementRegistry.addLast(Identifier.of("swordtrainer", "coach"), (context, tickCounter) -> {
            MinecraftClient client = MinecraftClient.getInstance();
            if (client.player == null || !client.isInSingleplayer()) {
                return;
            }
            int charge = Math.round(client.player.getAttackCooldownProgress(0.0f) * 100.0f);
            int x = 8;
            int y = 8;
            context.drawTextWithShadow(client.textRenderer, Text.literal("Sword trainer: cooldown drill"), x, y, 0xFFFFFFFF);
            context.drawTextWithShadow(client.textRenderer, Text.literal("Charge: " + charge + "% | Full hits: " + successes + "/" + attempts), x, y + 11, 0xFFFFFFFF);
            String tip = messageTicks > 0 ? message : "Wait for 100% before attacking.";
            context.drawTextWithShadow(client.textRenderer, Text.literal(tip), x, y + 22, 0xFFFFFFFF);
        });
    }
}