леон

Сделай мне мод на версию 1.21.11 фабрик который сам будет добавлять в конце сообщения чата 1 из эмоций: ":3", "OwO", "0_0", "MwM", ">w<", "UwU", "^_^", "XD", ">_<", "(◕‿◕)", "(≧▽≦)", "(¬‿¬)", "(。•̀ᴗ-)✧". Сделай так что бы его можно было выключить и если пишу команду через / то не работает. После написания мода дай мне сразу прости скачать мой мод

Kodari AI
KodariSep 7 at 1:59 pm 1
ChatEmoteAppender
Adds a random emoticon from a curated list to the end of every chat message sent by players on a Fabric 1.21.11 server. The mod is toggleable via a client-side command, allowing players to enable or disable the feature at will. Messages that begin with a slash (commands) are ignored and never modified. The emoticon is chosen randomly from a set including &quot;:3&quot;, &quot;OwO&quot;, &quot;0_0&quot;, &quot;MwM&quot;, &quot;&gt;w&lt;&quot;, &quot;UwU&quot;, &quot;^_^&quot;, &quot;XD&quot;, &quot;&gt;_&lt;&quot;, &quot;(◕‿◕)&quot;, &quot;(≧▽≦)&quot;, &quot;(¬‿¬)&quot;, and &quot;(。•̀ᴗ-)✧&quot;. The mod integrates seamlessly with the chat system, appending the emoticon only to normal player messages, preserving the original text, and providing a simple command interface for toggling the feature on and off.

[Generation stopped]

леон

Сделай мне мод на версию 1.21.11 фабрик который сам будет добавлять в конце сообщения чата 1 из эмоций: ":3", "OwO", "0_0", "MwM", ">w<", "UwU", "^_^", "XD", ">_<", "(◕‿◕)", "(≧▽≦)", "(¬‿¬)", "(。•̀ᴗ-)✧". Сделай так что бы его можно было выключить и если пишу команду через / то не работает. После написания мода дай мне сразу прости скачать мой мод

Kodari AI
KodariSep 7 at 2:03 pm 1

Создаю клиентский Fabric-мод: автодобавление случайной эмоции, сохранённый переключатель и локальную команду /chatemotes. Команды Minecraft не изменяются.

Готово: создан Fabric-мод Chat Emotes для Minecraft 1.21.11.

  • Добавляет случайную эмоцию в конец обычных сообщений.

  • Команды, начинающиеся с /, не изменяются.

  • Переключение сохраняется в конфигурации:

    • /chatemotes on

    • /chatemotes off

    • /chatemotes toggle

    • /chatemotes status

  • Конфигурация: config/chatemotes.json

  • Проект доступен для скачивания через созданные файлы в сообщении. Для сборки запустите ./gradlew build, готовый JAR появится в build/libs/.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
settings.gradle
Code
6 213
src/client/java/ru/kodari/chatemotes/ChatEmotesClient.java
package ru.kodari.chatemotes;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.mojang.brigadier.Command;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager;
import net.fabricmc.fabric.api.client.message.v1.ClientSendMessageEvents;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.text.Text;

import java.io.Reader;
import java.io.Writer;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;

public final class ChatEmotesClient implements ClientModInitializer {
    private static final List<String> EMOTES = List.of(
            ":3", "OwO", "0_0", "MwM", ">w<", "UwU", "^_^", "XD", ">_<",
            "(◕‿◕)", "(≧▽≦)", "(¬‿¬)", "(。•̀ᴗ-)✧"
    );

    private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
    private static final Path CONFIG_PATH = FabricLoader.getInstance()
            .getConfigDir()
            .resolve("chatemotes.json");
    private static Config config;

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

        ClientSendMessageEvents.MODIFY_CHAT.register(message -> {
            if (!config.enabled || message.isBlank() || message.startsWith("/")) {
                return message;
            }

            String emote = EMOTES.get(ThreadLocalRandom.current().nextInt(EMOTES.size()));
            return message + " " + emote;
        });

        ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> {
            dispatcher.register(ClientCommandManager.literal("chatemotes")
                    .executes(context -> {
                        sendStatus(context.getSource());
                        return Command.SINGLE_SUCCESS;
                    })
                    .then(ClientCommandManager.literal("on")
                            .executes(context -> setEnabled(context.getSource(), true)))
                    .then(ClientCommandManager.literal("off")
                            .executes(context -> setEnabled(context.getSource(), false)))
                    .then(ClientCommandManager.literal("toggle")
                            .executes(context -> setEnabled(context.getSource(), !config.enabled)))
                    .then(ClientCommandManager.literal("status")
                            .executes(context -> {
                                sendStatus(context.getSource());
                                return Command.SINGLE_SUCCESS;
                            })));
        });
    }

    private static int setEnabled(net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource source,
                                  boolean enabled) {
        config.enabled = enabled;
        saveConfig();
        source.sendFeedback(Text.translatable(
                enabled ? "chatemotes.command.enabled" : "chatemotes.command.disabled"));
        return Command.SINGLE_SUCCESS;
    }

    private static void sendStatus(net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource source) {
        source.sendFeedback(Text.translatable(
                config.enabled
                        ? "chatemotes.command.status.enabled"
                        : "chatemotes.command.status.disabled"));
    }

    private static Config loadConfig() {
        if (Files.exists(CONFIG_PATH)) {
            try (Reader reader = Files.newBufferedReader(CONFIG_PATH, StandardCharsets.UTF_8)) {
                Config loaded = GSON.fromJson(reader, Config.class);
                if (loaded != null) {
                    return loaded;
                }
            } catch (Exception ignored) {
            }
        }

        Config defaults = new Config();
        config = defaults;
        saveConfig();
        return defaults;
    }

    private static void saveConfig() {
        try {
            Files.createDirectories(CONFIG_PATH.getParent());
            try (Writer writer = Files.newBufferedWriter(CONFIG_PATH, StandardCharsets.UTF_8)) {
                GSON.toJson(config, writer);
            }
        } catch (Exception ignored) {
        }
    }

    private static final class Config {
        private boolean enabled = true;
    }
}