Timur Aysin

Knockback Displacement Mod You already have this mod, but it doesn't have a bandage button. Make it so I have to press a key and this mod turns on and off.

Kodari AI
KodariOct 25 at 1:30 pm 1
KnockbackToggle
A Minecraft Fabric mod that adds a toggleable keybind for the Knockback Displacement feature. Press the assigned key to enable or disable the knockback displacement effect on demand. When enabled, the mod applies the configured knockback displacement to entities; when disabled, it temporarily suspends the effect without altering the original mod's settings. The mod integrates seamlessly with the existing Knockback Displacement mod, providing a simple on/off switch for players who want to control when the displacement occurs during gameplay.
  1. Create the Fabric 1.21.11 client mod scaffold and a toggle keybind.

  2. Make the enabled state suppress knockback for the local player, with an on/off status message.

Added the Toggle Knockback Displacement keybind, defaulting to K (rebindable in Controls). It starts disabled; press K to toggle local-player knockback suppression on or off, with an on-screen status message.

Timur Aysin

The mod doesn't throw the player to me. I attached a mod that works. Change the mod so that it has a bandage button.

Kodari AI
KodariOct 25 at 1:42 pm 1
  1. Compare the attached working mod’s behavior with this project.

  2. Replace the current knockback-cancel behavior with a toggle keybind for the matching displacement action.

The K toggle is already in the mod, but it currently cancels your own incoming knockback—it doesn’t pull an opponent toward you. The attached reference jar isn’t readable in this workspace, so I can’t safely reproduce its behavior. Also, a client-only mod can’t reliably force another player’s movement on a server that doesn’t support it.

Please provide the reference mod’s source or the relevant mixin code, and I can wire its working displacement behavior to the K toggle.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
Knockback-Displacement-Mod (1).jar
settings.gradle
Code
9 171
src/client/java/com/kodari/knockbackdisplacement/KnockbackDisplacementClient.java
package com.kodari.knockbackdisplacement;

import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import org.lwjgl.glfw.GLFW;

public final class KnockbackDisplacementClient implements ClientModInitializer {
    private static boolean enabled;

    private static final KeyBinding TOGGLE_KEY = KeyBindingHelper.registerKeyBinding(
            new KeyBinding(
                    "key.knockback_displacement.toggle",
                    GLFW.GLFW_KEY_K,
                    KeyBinding.Category.create(Identifier.of("knockback_displacement", "controls"))
            )
    );

    @Override
    public void onInitializeClient() {
        ClientTickEvents.END_CLIENT_TICK.register(client -> {
            while (TOGGLE_KEY.wasPressed()) {
                enabled = !enabled;
                ClientPlayerEntity player = client.player;
                if (player != null) {
                    player.sendMessage(Text.literal("Knockback displacement " + (enabled ? "enabled" : "disabled")), true);
                }
            }
        });
    }

    public static boolean isEnabled() {
        return enabled;
    }
}