Implement the user's requested Fabric client mod in this project. User's clarified meaning: “Attribute swapping is a combat mechanic in Minecraft (Java Edition) where a player quickly switches hotbar slots and attacks within the same game tick (a 50-millisecond window). This causes the game server to mix the attributes, cooldowns, and damage of one item with the enchantments, special abilities, or reach of a completely different item.” They want exactly one module, named “Attribute Swap,” that can be toggled on/off, with a clean GUI inspired by Krypton Client's polished/minimal visual style (do not copy its branding/assets), and a clear way to choose the two hotbar slots involved.

Make it a client-side Fabric mod for the project's configured Minecraft version. Expose only this one gameplay module; do not invent a suite of modules. Provide an intuitive GUI opened by a keybind, with an obvious enabled/disabled toggle and two clear hotbar slot selectors (1–9, labeled source/attribute slot and attack/effect slot or similarly understandable labels). Show selected values clearly and make controls usable. Persist configuration if practical. When enabled, respond to the user's normal attack input on a valid target by performing the selected-slot swap/attack sequence in the same game tick, using the appropriate client-side interaction/packet APIs for the configured Minecraft/Fabric version; do not spam attacks or generate extra attacks beyond the user's normal attack action. Leave a sensible and predictable slot selection after execution. Avoid crashes when GUI is open, player/world is absent, slots are invalid/equal, or target is not attackable; explain any unavoidable Minecraft/server limitations in UI/docs. Make sure the GUI toggle and module toggle work independently and there are no unrelated modules. Use the project's existing structure and APIs; implement the feature code only. Finish when the feature is implemented and code is coherent, do not add tests or ask the user for more details.

Kodari AI
KodariNov 6 at 12:10 am 2
AttributeSwapMod
Client-side Fabric mod implementing an automatic attribute swap combat mechanic. Features a single toggleable module with a polished Krypton-inspired GUI opened via keybind. Users select source and attack hotbar slots (1-9), with independent module and GUI toggles. When enabled, responds to normal attack input by performing the slot swap/attack sequence within the same game tick using client-side interaction APIs. Persists configuration, handles edge cases gracefully, and leaves predictable slot selection after execution.
  1. Build one client-side Attribute Swap module with independent keybinds, persistent slot settings, and an owo-ui screen; then wire a guarded single-attack sequence.

Implemented one client-side module, Attribute Swap, disabled by default. Press H to open/close its GUI and J to toggle the module; both keys can be rebound in Controls. The GUI has independent source/attribute and attack/effect slot selectors for hotbar slots 1–9, and settings persist in config/attributeswap.properties.

When enabled with two different slots, a normal attack sends the selected source slot, exactly one attack packet, then selects the effect slot. The GUI explains the vanilla/server limitation: a hit cannot combine attributes, enchantments, or reach from two separate items, and server behavior may vary.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
manifest.kod
settings.gradle
Code
8 421
src/client/java/com/kodari/attributeswap/AttributeSwapClient.java
package com.kodari.attributeswap;

import com.mojang.blaze3d.platform.InputConstants;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keymapping.v1.KeyMappingHelper;
import net.fabricmc.fabric.api.event.player.AttackEntityCallback;
import net.minecraft.client.KeyMapping;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientPacketListener;
import net.minecraft.network.protocol.game.ServerboundAttackPacket;
import net.minecraft.network.protocol.game.ServerboundSetCarriedItemPacket;
import net.minecraft.resources.Identifier;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Properties;

public final class AttributeSwapClient implements ClientModInitializer {
	public static final String MOD_ID = "attributeswap";

	private static final int DEFAULT_ATTRIBUTE_SLOT = 0;
	private static final int DEFAULT_EFFECT_SLOT = 1;

	private static boolean enabled;
	private static int attributeSlot = DEFAULT_ATTRIBUTE_SLOT;
	private static int effectSlot = DEFAULT_EFFECT_SLOT;
	private static KeyMapping openScreenKey;
	private static KeyMapping toggleModuleKey;

	@Override
	public void onInitializeClient() {
		loadConfig();

		KeyMapping.Category category = KeyMapping.Category.register(Identifier.fromNamespaceAndPath(MOD_ID, "controls"));
		openScreenKey = KeyMappingHelper.registerKeyMapping(new KeyMapping(
				"key.attributeswap.open", InputConstants.Type.KEYBOARD, InputConstants.KEY_H, category));
		toggleModuleKey = KeyMappingHelper.registerKeyMapping(new KeyMapping(
				"key.attributeswap.toggle", InputConstants.Type.KEYBOARD, InputConstants.KEY_J, category));

		ClientTickEvents.END_CLIENT_TICK.register(client -> {
			while (openScreenKey.consumeClick()) {
				if (client.gui.screen() instanceof AttributeSwapScreen) {
					client.gui.setScreen(null);
				} else if (client.gui.screen() == null) {
					client.gui.setScreen(new AttributeSwapScreen());
				}
			}

			while (toggleModuleKey.consumeClick()) {
				setEnabled(!enabled);
			}
		});

		AttackEntityCallback.EVENT.register((player, level, hand, entity, hitResult) -> handleAttack(player, entity));
	}

	public static boolean isEnabled() {
		return enabled;
	}

	public static int getAttributeSlot() {
		return attributeSlot;
	}

	public static int getEffectSlot() {
		return effectSlot;
	}

	public static void toggleEnabled() {
		setEnabled(!enabled);
	}

	public static void setAttributeSlot(int slot) {
		if (!isValidSlot(slot))
			return;

		attributeSlot = slot;
		saveConfig();
	}

	public static void setEffectSlot(int slot) {
		if (!isValidSlot(slot))
			return;

		effectSlot = slot;
		saveConfig();
	}

	private static InteractionResult handleAttack(Player player, Entity entity) {
		Minecraft client = Minecraft.getInstance();
		if (!enabled || client.player != player || client.gui.screen() != null || client.gameMode == null)
			return InteractionResult.PASS;

		if (entity == player || !entity.isAlive() || entity.isRemoved() || !entity.isAttackable())
			return InteractionResult.PASS;

		if (!isValidSlot(attributeSlot) || !isValidSlot(effectSlot) || attributeSlot == effectSlot)
			return InteractionResult.PASS;

		ClientPacketListener connection = client.getConnection();
		if (connection == null)
			return InteractionResult.PASS;

		Inventory inventory = player.getInventory();
		inventory.setSelectedSlot(attributeSlot);
		connection.send(new ServerboundSetCarriedItemPacket(attributeSlot));

		player.attack(entity);
		player.resetAttackStrengthTicker();
		connection.send(new ServerboundAttackPacket(entity.getId()));

		inventory.setSelectedSlot(effectSlot);
		connection.send(new ServerboundSetCarriedItemPacket(effectSlot));

		return InteractionResult.FAIL;
	}

	private static void setEnabled(boolean value) {
		enabled = value;
		saveConfig();
	}

	private static boolean isValidSlot(int slot) {
		return slot >= 0 && slot < 9;
	}

	private static Path configPath() {
		return Minecraft.getInstance().gameDirectory.toPath().resolve("config").resolve("attributeswap.properties");
	}

	private static void loadConfig() {
		Properties properties = new Properties();
		try (InputStream input = Files.newInputStream(configPath())) {
			properties.load(input);
			enabled = Boolean.parseBoolean(properties.getProperty("enabled", "false"));
			attributeSlot = readSlot(properties, "attributeSlot", DEFAULT_ATTRIBUTE_SLOT);
			effectSlot = readSlot(properties, "effectSlot", DEFAULT_EFFECT_SLOT);
		} catch (IOException | IllegalArgumentException ignored) {
			enabled = false;
			attributeSlot = DEFAULT_ATTRIBUTE_SLOT;
			effectSlot = DEFAULT_EFFECT_SLOT;
		}
	}

	private static int readSlot(Properties properties, String key, int fallback) {
		try {
			int slot = Integer.parseInt(properties.getProperty(key, Integer.toString(fallback)));
			return isValidSlot(slot) ? slot : fallback;
		} catch (NumberFormatException ignored) {
			return fallback;
		}
	}

	private static void saveConfig() {
		Properties properties = new Properties();
		properties.setProperty("enabled", Boolean.toString(enabled));
		properties.setProperty("attributeSlot", Integer.toString(attributeSlot));
		properties.setProperty("effectSlot", Integer.toString(effectSlot));

		Path path = configPath();
		try {
			Files.createDirectories(path.getParent());
			try (OutputStream output = Files.newOutputStream(path)) {
				properties.store(output, "Attribute Swap client settings");
			}
		} catch (IOException ignored) {
		}
	}
}