G

Stwórz mi moda ktory wykorzystuje Mechanike knockback displacement poprzez szybkie flicki dodaj do niego ustawienia w ktorych mozna zmieniać jak bardzo sie ma obrócic. Zeby mozna bylo zmienic tam prędkosc i kierunek obrotu. Spraw jeszcze tak aby postac obracała sie tylko wtedy kiedy uderzam a nie kiedy biegnę przed siebie. Do poki nie hitam oponenta mod ma nic nie robić nie zapomnij o BooleanControllerBuilder

Kodari AI
KodariJun 25 at 12:56 pm 16
KnockbackFlick
A Fabric mod that rotates the player character during knockback hits using flick mechanics. When the player lands a hit, a quick rotational displacement is applied based on configurable settings. Includes a YACL config screen to adjust rotation speed, direction, and toggle the effect. The rotation only triggers on confirmed hit events — no movement-based activation.

Let me read the necessary docs before writing any code.

Plan:

  • FlickConfig — YACL config with BooleanControllerBuilder (enabled), float slider (speed), int slider (duration), enum dropdown (direction)

  • KnockbackFlickClient — registers AttackEntityCallback to set flick timer, ClientTickEvents to apply yaw rotation per tick

  • ModMenuIntegration — exposes config screen via ModMenu

  • No mixins needed — pure event-based, rotation only fires on confirmed entity hit

KnockbackFlick
A Fabric 1.21.11 client-side mod that adds a quick rotational flick to your camera whenever you land a hit on an entity. Includes a full YACL config screen accessible via ModMenu where you can toggle the effect on/off, adjust rotation speed (degrees per tick), flick duration (ticks), and choose left or right rotation direction. The rotation is completely passive while walking — it only triggers on confirmed entity hits.

How it works:

Setting
Default
Range
Enable Flick
ON
toggle (BooleanControllerBuilder)
Rotation Speed
3.0°/tick
0.5 – 15.0°/tick
Flick Duration
5 ticks
1 – 20 ticks
Rotation Direction
RIGHT
LEFT / RIGHT
  • AttackEntityCallback fires only when you physically click on an entity — walking/running never triggers it

  • On hit, a counter (flickTicksRemaining) is set to the configured duration

  • ClientTickEvents.END_CLIENT_TICK decrements the counter each tick and adds the rotation delta to player.setYaw() until the timer expires

  • Config is saved to config/knockbackflick.json and accessible via ModMenu → Configure

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
manifest.kod
Code
8 227
src/client/java/com/example/knockbackflick/KnockbackFlickClient.java
package com.example.knockbackflick;

import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.event.player.AttackEntityCallback;
import net.minecraft.util.ActionResult;

public class KnockbackFlickClient implements ClientModInitializer {

    private static int flickTicksRemaining = 0;

    @Override
    public void onInitializeClient() {
        FlickConfig.HANDLER.load();

        AttackEntityCallback.EVENT.register((player, world, hand, entity, hitResult) -> {
            if (!world.isClient()) return ActionResult.PASS;
            FlickConfig cfg = FlickConfig.get();
            if (!cfg.enabled) return ActionResult.PASS;
            flickTicksRemaining = cfg.flickDuration;
            return ActionResult.PASS;
        });

        ClientTickEvents.END_CLIENT_TICK.register(client -> {
            if (flickTicksRemaining <= 0 || client.player == null) return;
            FlickConfig cfg = FlickConfig.get();
            float delta = cfg.rotationSpeed * (cfg.direction == FlickConfig.RotationDirection.RIGHT ? 1f : -1f);
            client.player.setYaw(client.player.getYaw() + delta);
            flickTicksRemaining--;
        });
    }
}