Krystian Prusinowski

Create a client-side Fabric 1.21.11 mod. It must display the player's own equipped armor, main-hand item, off-hand item, inventory items, and all of their active enchantments directly on the HUD screen. Register a custom KeyBinding for this display toggle that appears perfectly in the vanilla game options menu (Options -> Controls -> Key Binds) under a custom category.

Kodari AI
KodariOct 23 at 5:33 am 2
GearHudOverlay
Client-side Fabric mod for Minecraft 1.21.11 that displays the player's equipped armor, main-hand/off-hand items, full inventory contents, and all active enchantments directly on the HUD. Features a custom keybinding registered under a dedicated category in the vanilla Controls menu, allowing seamless toggling of the overlay. Renders item icons, names, and enchantment details in a clean, configurable HUD panel that updates in real-time as equipment changes.

Plan:

  1. Register the client-only keybinding in a custom Controls category and toggle the HUD.

  2. Render armor, held items, inventory contents, and enchantments using the 1.21.11 HUD APIs.

  3. Add the minimal Fabric project metadata and assets.

Created the client-only Fabric 1.21.11 mod. The HUD shows equipped armor and hand items, plus every occupied inventory slot with its item icon, count, and enchantments. It starts enabled and toggles with H, under Options → Controls → Key Binds → Inventory HUD.

Krystian Prusinowski

Name of project is player stats And this is a player search engine where you enter a person and there you can see what their eq is, what armor they have, what enchants they have, too.

Kodari AI
KodariOct 23 at 5:34 am 1
  1. Rename the project/mod label to Player Stats.

  2. Check whether this client-only mod can search other players’ full inventory/equipment; implement the feasible scope or explain the server-side requirement.

Renamed the project and mod display name to Player Stats.

A client-only mod cannot look up an arbitrary player’s inventory: Minecraft doesn’t send other players’ inventory contents to your client. It can only read their synced equipment—armor and hand items—while they’re loaded nearby. To search by name and see full inventory and enchantments, the server must also run a companion mod that provides that data.

Should I build nearby-player equipment search for client-only use, or the full player search with a required server-side companion mod?

Krystian Prusinowski

I want full player search

Kodari AI
KodariOct 23 at 5:42 am 2
  1. Add server-authoritative player lookup that returns only the requested player’s inventory/equipment data.

  2. Build an owo search screen and wire it to a custom Fabric payload, with the HUD toggle retained.

  3. Update project metadata and bundled library manifest.

Implemented Player Stats player search, opened with J. Search an online player by name to view their armor, hands, inventory, and item enchantments; H still toggles the local HUD.

The mod must be installed on both the client and the server. Searches are limited to players currently online.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
manifest.kod
settings.gradle
Code
10 598
src/client/java/com/example/inventoryhud/InventoryHudClient.java
package com.example.inventoryhud;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

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.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
import net.fabricmc.fabric.api.client.rendering.v1.hud.HudElementRegistry;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier;
import org.lwjgl.glfw.GLFW;

import com.example.inventoryhud.PlayerStatsPayloads.SearchResponse;

public class InventoryHudClient implements ClientModInitializer {
    private static final String MOD_ID = "inventoryhud";
    private static final KeyBinding.Category CATEGORY = KeyBinding.Category.create(Identifier.of(MOD_ID, "inventory_hud"));
    private static final KeyBinding TOGGLE_KEY = KeyBindingHelper.registerKeyBinding(
            new KeyBinding("key.inventoryhud.toggle", GLFW.GLFW_KEY_H, CATEGORY));
    private static final KeyBinding SEARCH_KEY = KeyBindingHelper.registerKeyBinding(
            new KeyBinding("key.inventoryhud.search", GLFW.GLFW_KEY_J, CATEGORY));

    private static boolean enabled = true;

    @Override
    public void onInitializeClient() {
        ClientTickEvents.END_CLIENT_TICK.register(client -> {
            if (TOGGLE_KEY.wasPressed()) {
                enabled = !enabled;
            }
            if (SEARCH_KEY.wasPressed() && client.player != null) {
                client.setScreen(new PlayerStatsScreen());
            }
        });

        ClientPlayNetworking.registerGlobalReceiver(SearchResponse.ID,
                (payload, context) -> PlayerStatsScreen.receive(payload));

        HudElementRegistry.addLast(Identifier.of(MOD_ID, "inventory_hud"), (context, tickCounter) -> {
            if (!enabled) {
                return;
            }

            MinecraftClient client = MinecraftClient.getInstance();
            if (client.player == null) {
                return;
            }

            renderHud(context, client);
        });
    }

    private static void renderHud(DrawContext context, MinecraftClient client) {
        int left = 6;
        int top = 6;
        int width = Math.max(1, client.getWindow().getScaledWidth() - left * 2);
        int columns = Math.max(1, Math.min(4, width / 140));
        TextRenderer textRenderer = client.textRenderer;

        List<HudLine> equipment = List.of(
                createLine("Head", client.player.getEquippedStack(EquipmentSlot.HEAD)),
                createLine("Chest", client.player.getEquippedStack(EquipmentSlot.CHEST)),
                createLine("Legs", client.player.getEquippedStack(EquipmentSlot.LEGS)),
                createLine("Feet", client.player.getEquippedStack(EquipmentSlot.FEET)),
                createLine("Main hand", client.player.getMainHandStack()),
                createLine("Off hand", client.player.getOffHandStack()));

        Layout equipmentLayout = layout(equipment, left + 6, top + 20, width - 12,
                Math.min(3, columns), textRenderer);

        List<HudLine> inventory = new ArrayList<>();
        for (int slot = 0; slot < 36; slot++) {
            ItemStack stack = client.player.getInventory().getStack(slot);
            if (!stack.isEmpty()) {
                inventory.add(createLine("Slot " + (slot + 1), stack));
            }
        }
        if (inventory.isEmpty()) {
            inventory.add(new HudLine("No items", ItemStack.EMPTY));
        }

        int inventoryHeadingY = equipmentLayout.bottom() + 8;
        Layout inventoryLayout = layout(inventory, left + 6, inventoryHeadingY + 13,
                width - 12, columns, textRenderer);
        int bottom = Math.min(client.getWindow().getScaledHeight() - 4, inventoryLayout.bottom() + 6);

        context.fill(left, top, left + width, Math.max(top + 24, bottom), 0xC010141B);
        context.drawTextWithShadow(textRenderer, "EQUIPMENT", left + 6, top + 6, 0xFF8ED6FF);
        drawLayout(context, client, equipmentLayout);
        context.drawTextWithShadow(textRenderer, "INVENTORY · ITEMS AND ENCHANTMENTS",
                left + 6, inventoryHeadingY, 0xFF8ED6FF);
        drawLayout(context, client, inventoryLayout);
    }

    private static HudLine createLine(String label, ItemStack stack) {
        if (stack.isEmpty()) {
            return new HudLine(label + ": Empty", ItemStack.EMPTY);
        }

        StringBuilder text = new StringBuilder(label)
                .append(": ")
                .append(stack.getName().getString())
                .append(" ×")
                .append(stack.getCount());

        List<String> enchantments = new ArrayList<>();
        for (var enchantmentEntry : stack.getEnchantments().getEnchantmentEntries()) {
            enchantments.add(Enchantment.getName(enchantmentEntry.getKey(), enchantmentEntry.getIntValue()).getString());
        }
        if (!enchantments.isEmpty()) {
            text.append(" · ").append(String.join(" · ", enchantments));
        }

        return new HudLine(text.toString(), stack);
    }

    private static Layout layout(List<HudLine> lines, int x, int y, int width, int columns,
                                 TextRenderer textRenderer) {
        int columnWidth = Math.max(1, width / columns);
        int[] columnBottoms = new int[columns];
        Arrays.fill(columnBottoms, y);
        List<PositionedLine> positioned = new ArrayList<>();

        for (HudLine line : lines) {
            int column = 0;
            for (int index = 1; index < columns; index++) {
                if (columnBottoms[index] < columnBottoms[column]) {
                    column = index;
                }
            }

            int itemX = x + column * columnWidth;
            boolean hasItem = !line.stack().isEmpty();
            int textX = itemX + (hasItem ? 20 : 0);
            int textWidth = Math.max(1, columnWidth - (hasItem ? 22 : 2));
            List<String> wrapped = wrap(line.text(), textWidth, textRenderer);
            int lineHeight = Math.max(16, wrapped.size() * 9 + 2);
            positioned.add(new PositionedLine(line, itemX, columnBottoms[column], textX, wrapped, lineHeight));
            columnBottoms[column] += lineHeight;
        }

        int bottom = y;
        for (int columnBottom : columnBottoms) {
            bottom = Math.max(bottom, columnBottom);
        }
        return new Layout(positioned, bottom);
    }

    private static List<String> wrap(String text, int maxWidth, TextRenderer textRenderer) {
        List<String> lines = new ArrayList<>();
        StringBuilder line = new StringBuilder();

        for (String word : text.split("\\s+")) {
            String candidate = line.isEmpty() ? word : line + " " + word;
            if (!line.isEmpty() && textRenderer.getWidth(candidate) > maxWidth) {
                lines.add(line.toString());
                line.setLength(0);
            }
            if (!line.isEmpty()) {
                line.append(' ');
            }
            line.append(word);
        }

        if (!line.isEmpty()) {
            lines.add(line.toString());
        }
        return lines;
    }

    private static void drawLayout(DrawContext context, MinecraftClient client, Layout layout) {
        for (PositionedLine positioned : layout.lines()) {
            ItemStack stack = positioned.line().stack();
            if (!stack.isEmpty()) {
                context.drawItem(stack, positioned.x(), positioned.y());
                context.drawStackOverlay(client.textRenderer, stack, positioned.x(), positioned.y());
            }

            for (int index = 0; index < positioned.wrapped().size(); index++) {
                context.drawTextWithShadow(client.textRenderer, positioned.wrapped().get(index),
                        positioned.textX(), positioned.y() + index * 9, 0xFFE8E8E8);
            }
        }
    }

    private record HudLine(String text, ItemStack stack) {
    }

    private record PositionedLine(HudLine line, int x, int y, int textX, List<String> wrapped, int height) {
    }