Дэнзи
📎 1 file 3,802 chars
📄
pasted-code-1793655142242.txt
txt 35 lines
▶

Mod Development Specification: Team Indicator (Version 1.21.11, Fabric)

Create a cosmetic, client-side mod for Minecraft 1.21.11 using the Fabric loader. This mod is designed to improve team coordination and prevent accidental attacks on allies. The mod must run completely on the client side, send no data to the server, and remain hidden from server administrators. All visual elements must be rendered exclusively for the mod user.

🖥️ Menu Interface and GUI Functionality

• Open and Close Actions: By default, the menu opens when pressing the U key. This keybinding must be rebindable via the standard Minecraft Controls menu. To close the menu, the user can press the ESC key or click a neat "X" button located in the top-right corner of the screen.
• Sleek Black Design: When the menu is active, the background game world should blur slightly. The menu itself is a large, stylish solid black window centered on the screen, occupying about 85% of the display area. A thin, elegant border should wrap around the edges of the window.
• Search Bar and Autocomplete: A centered text input field must be placed at the top of the menu for typing a friend's nickname. Most importantly, as the user types the first letters, the mod should display dynamic autocomplete suggestions listing players currently online on the server. Pressing the TAB key should automatically autocomplete the nickname from the suggestion list.
• Friend List Layout: All added friends must be displayed in a clean, vertical scrollable list. Each friend entry should be styled as a horizontal card:
	• Left side: Displays a 2D square head icon of the friend's skin.
	• Center: Displays the friend's nickname in a large, clear white font. An online indicator (green dot for online, gray dot for offline) should appear next to the name.
	• Right side: Features a rectangular red "Delete" button. Hovering over this button increases its brightness. Clicking it removes the player from the friend list.

🔴 Local Ally Marker (Custom Outline)

• All players added to the friend list must have a permanent local graphical outline marker.
• Use Minecraft's native outline rendering system (Glow/Outline Render) and force its color to be solid red.
• This outline must serve as a visual tracking guide for the ally's position so the user never confuses them with opponents during fast-paced encounters.
• The outline must be rendered purely within the client's internal graphics engine, must not request status effects from the server, and must be completely invisible to anyone else.

⚔️ Complete Friendly Fire Prevention (Team Damage Control)

• While a player is on the friend list, the mod must activate a total local block on sending attack packets or interaction events toward them.
• This friend cannot be hit at all! No weapons, no items, and no conditions can damage or strike them.
• If the user's crosshair is on a friend from the list, mouse clicks and any attempts to attack must be completely blocked by the game client. This rule must always apply in both Survival and Creative modes.

💬 Custom Chat Notifications

• The moment a friend from the list connects to the server, the mod must instantly print a noticeable text message in the user's local chat: "Ваш друг [Nick] зашел на сервер!". This message must be formatted using standard Minecraft color codes (e.g., nickname in green, the rest of the text in gold) to immediately stand out.

💾 Configuration Saving

• The friend list must be saved permanently. Implement the local storage system on the computer in whichever way is best or most convenient. The critical requirement is that after rejoining a world, switching servers, or completely restarting Minecraft, all friends must automatically load back into the menu and remain there until deleted manually.
Kodari AI
KodariNov 2 at 9:39 pm 6
TeamIndicator
A client-side Fabric mod for Minecraft 1.21.11 that enhances team coordination through a sleek black GUI (opened with U key) featuring friend management, search with autocomplete, and scrollable friend list with skin icons and online indicators. Renders permanent red outlines around friends using native rendering, completely blocks attacks against allies in all game modes, displays colored chat notifications when friends join, and persists friend data locally across restarts.
  1. Build the client-only friend list, persistence, and menu.

  2. Add local ally outlines and attack protection.

  3. Add local join notifications and the rebindable key.

Created the client-side Team Indicator with a U-key menu, saved friend list, red outlines, direct attack blocking, and local join notifications.

Limits: Client-side protection cannot prevent indirect damage from projectiles, explosions, or other effects. Server administrators may also be able to detect client mods; invisibility cannot be guaranteed. Offline friends display a default skin, and join notifications are suppressed briefly after connecting.

The project has not been compiled or tested in-game.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
manifest.kod
settings.gradle
Code
13 432
src/client/java/com/kodari/teamindicator/TeamIndicatorClient.java
package com.kodari.teamindicator;

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.MinecraftClient;
import net.minecraft.client.network.PlayerListEntry;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.util.Identifier;
import org.lwjgl.glfw.GLFW;

import java.util.HashSet;
import java.util.Set;
import java.util.UUID;

public final class TeamIndicatorClient implements ClientModInitializer {
    private final Set<UUID> online = new HashSet<>();
    private Object connection;
    private int initialTicks;

    @Override
    public void onInitializeClient() {
        Friends.load();
        KeyBinding key = KeyBindingHelper.registerKeyBinding(new KeyBinding(
                "key.team_indicator.open", GLFW.GLFW_KEY_U,
                KeyBinding.Category.create(Identifier.of("team_indicator", "main"))));
        ClientTickEvents.END_CLIENT_TICK.register(client -> {
            while (key.wasPressed()) {
                if (client.currentScreen == null) client.setScreen(new FriendsScreen());
            }
            updateOnline(client);
        });
    }

    private void updateOnline(MinecraftClient client) {
        if (client.player == null || client.world == null) {
            connection = null;
            online.clear();
            return;
        }
        var handler = client.player.networkHandler;
        if (connection != handler) {
            connection = handler;
            online.clear();
            initialTicks = 20;
        }
        Set<UUID> current = new HashSet<>();
        for (PlayerListEntry entry : handler.getPlayerList()) {
            var profile = entry.getProfile();
            current.add(profile.id());
            if (initialTicks == 0 && !online.contains(profile.id()) && Friends.contains(profile.name())) {
                client.inGameHud.getChatHud().addMessage(Text.literal("Ваш друг ").formatted(Formatting.GOLD)
                        .append(Text.literal(profile.name()).formatted(Formatting.GREEN))
                        .append(Text.literal(" зашел на сервер!").formatted(Formatting.GOLD)));
            }
        }
        online.clear();
        online.addAll(current);
        if (initialTicks > 0) initialTicks--;
    }
}