nexbanee

Create a client-side Minecraft mod called "Breach Swap Notifier" for Minecraft Java Edition 1.21.4.

Purpose

The mod should detect when a player successfully performs a Breach Swap and provide an on-screen notification.

Features Monitor player actions related to Breach Swap execution.

Detect only successful and valid Breach Swaps.

Do not trigger on failed attempts, mistimed swaps, or normal item switching.

When a successful Breach Swap occurs, display a HUD notification at the bottom-center of the screen.

Notification Text: "✓ Successful Swap" Color: Bright Green Position: Bottom-center of the screen Duration: 2 seconds Animation: Smooth fade-in and fade-out Optional success sound when the notification appears Settings Menu

Add a simple configuration screen with:

Enable/Disable notifications Enable/Disable sound Change notification duration Change notification position Change notification color Performance Requirements Client-side only Lightweight and optimized No FPS drops No unnecessary background processing Compatibility Minecraft Java Edition 1.21.4 Fabric Loader Compatible with popular PvP clients and HUD mods User Experience Notification should be clean and minimalistic.

It should feel similar to competitive PvP utility mods.

The notification must never block the player's view.

Mod Name

Breach Swap Notifier

Example

When the player performs a perfect Breach Swap:

✓ Successful Swap

appears at the bottom-center of the screen for 2 seconds and then smoothly fades away.

Kodari AI
KodariJun 23 at 5:51 am 43
BreachSwapNotifier
A client-side Fabric mod for Minecraft 1.21.4 that detects successful Breach Swaps in PvP — timing a hotbar/offhand swap when attack cooldown is fully charged. Displays a clean "✓ Successful Swap" HUD notification at the bottom-center with smooth fade-in/fade-out animation. Includes a config screen to toggle notifications, sound, adjust duration, position, and color. Lightweight, client-only, and built for competitive PvP play.
BreachSwapNotifier
A client-side Fabric 1.21.4 mod that detects successful Breach Swaps — timing a hotbar slot switch when attack cooldown is fully charged — and displays a clean "✓ Successful Swap" HUD notification with smooth fade-in/out animation. Includes a settings screen accessible via keybind to toggle notifications, enable/disable sound, adjust duration, position, and color. Lightweight, client-only, no FPS impact.

Here’s my plan before writing anything:

  • Detection: Poll inventory.selectedSlot each client tick; if slot changes and getAttackCooldownProgress(0f) >= threshold → successful breach swap

  • HUD: HudRenderCallback + System.currentTimeMillis() for smooth frame-rate-independent fade animation

  • Config: Gson JSON config with durationSeconds, position enum, color int preset, toggles, cooldown threshold

  • Config screen: Minecraft Screen subclass with cycle buttons (click = next, Shift+click = previous)

  • Sound: Played via player.playSound() on detection

  • Structure: All Java in src/client/, resources in src/main/resources/



Here’s a summary of every file and what it does:

File
Role
BreachSwapNotifierClient
Entry point — registers keybind, wires up all systems
BreachSwapDetector
Polls
inventory.selectedSlot
each client tick; fires on slot change when
attackCooldownProgress ≥ threshold
SwapNotificationHud
HudRenderCallback
renderer with
System.currentTimeMillis()
-based smooth fade-in / fade-out
ModConfig
Plain POJO with all settings;
Position
enum for dropdown
ConfigManager
Gson JSON load/save to
.minecraft/config/breachswapnotifier.json
ConfigScreen
Minecraft
Screen
with cycle buttons —
click
to advance,
Shift+click
to reverse

Key detection logic: every tick, if selectedSlot changed AND getAttackCooldownProgress(0f) >= cooldownThreshold (default 90%), it counts as a successful Breach Swap. This prevents false positives from accidental swaps when the weapon hasn’t recharged.

Settings (bound to an unset key by default — assign it in Controls → Breach Swap Notifier):

  • Enable/disable notifications and sound independently

  • Duration: 0.5 s → 5.0 s in 0.5 s steps

  • Position: Bottom Center / Left / Right, Top Center, Center

  • Color: 8 presets (Green, Yellow, Red, Blue, White, Cyan, Orange, Pink) shown in their own color

  • Cooldown threshold: 50 %–100 % in 5 % steps

nexbanee

Improve the detection system. Do not count every hotbar slot change as a successful Breach Swap. Add additional validation checks to reduce false positives, such as verifying that the player recently attacked, checking timing windows, and ensuring the swap occurred within a valid Breach Swap sequence. Only show "✓ Successful Swap" when a genuine Breach Swap is detected.

nexbanee

The compilation failed with this error:

code
Compilation failed with 2 error(s):

ERROR in src/main/java/client/java/com/breachswapnotifier/detection/BreachSwapDetector.java at line 49: incompatible types: Reference<SoundEvent> cannot be converted to SoundEvent
            client.player.playSound(SoundEvents.BLOCK_NOTE_BLOCK_PLING, 0.6f, 2.0f);
                                               ^

ERROR in   src/main/java/client/java/com/breachswapnotifier/detection/BreachSwapDetector.java at line 49: incompatible types: Reference<SoundEvent> cannot be converted to SoundEvent
              client.player.playSound(SoundEvents.BLOCK_NOTE_BLOCK_PLING, 0.6f, 2.0f);
                                                 ^


=== COMPILATION ERROR ANALYSIS ===

TYPE MISMATCHES:
  - incompatible types: Reference<SoundEvent> cannot be converted to SoundEvent
  - incompatible types: Reference<SoundEvent> cannot be converted to SoundEvent
ACTION: Fix variable types or casting

FILES TO INVESTIGATE:
  - src/main/java/client/java/com/breachswapnotifier/detection/BreachSwapDetector.java
  -   src/main/java/client/java/com/breachswapnotifier/detection/BreachSwapDetector.java

Please fix this error by creating a new artifact with the corrected code.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
settings.gradle
Code
12 504
src/client/java/com/breachswapnotifier/BreachSwapNotifierClient.java
package com.breachswapnotifier;

import com.breachswapnotifier.config.ConfigManager;
import com.breachswapnotifier.config.ConfigScreen;
import com.breachswapnotifier.detection.BreachSwapDetector;
import com.breachswapnotifier.hud.SwapNotificationHud;
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.util.InputUtil;
import org.lwjgl.glfw.GLFW;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class BreachSwapNotifierClient implements ClientModInitializer {

    public static final String MOD_ID = "breachswapnotifier";
    public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);

    private static KeyBinding openConfigKey;

    @Override
    public void onInitializeClient() {
        ConfigManager.load();

        openConfigKey = KeyBindingHelper.registerKeyBinding(new KeyBinding(
            "key.breachswapnotifier.open_config",
            InputUtil.Type.KEYSYM,
            GLFW.GLFW_KEY_UNKNOWN,
            "key.categories.breachswapnotifier"
        ));

        SwapNotificationHud.register();
        BreachSwapDetector.register();

        ClientTickEvents.END_CLIENT_TICK.register(client -> {
            if (openConfigKey.wasPressed() && client.player != null) {
                client.setScreen(new ConfigScreen(null));
            }
        });

        LOGGER.info("Breach Swap Notifier initialized.");
    }
}