salion2X
📎 1 file 2,110 chars
📄
pasted-code-1789061206707.txt
txt 45 lines
▶
Task: Create a detailed blueprint, project structure, and code implementation for a custom Minecraft mod that links the player's Minecraft client directly to Discord.

Core Requirements & Features:

Discord Authentication & Account Linking:

Integrate OAuth2 or Discord RPC/IPC authentication to securely link a player's Discord account directly inside Minecraft.

Store the session token safely in the client config.

Customizable Discord Rich Presence (DRP):

Dynamically update Discord status based on in-game states (e.g., Playing Singleplayer, In Main Menu, On a Server).

Provide an in-game GUI or config file allowing players to fully customize their Rich Presence (custom status text, main/small image keys, details, and dynamic placeholders like {world_name}, {biome}, {health}).

Discord Friend P2P Multiplayer Joining (Singleplayer Invite):

Enable players in a Singleplayer World to host a local session and send an in-game/Discord invite to a Discord friend who also has the mod installed.

Cross-Mod Compatibility Architecture: Create a syncing or compatibility layer (using UPnP, hole-punching, or a light tunneling proxy like ngrok/playit.gg API, or localized packet translation) so that two players can join each other's singleplayer world even if their installed mod lists/modpacks are completely different (handle missing/extra block, item, and entity registries gracefully without client crash on join).

Technical Constraints & Stack:

Target Minecraft Version: Specify preferred version (e.g., 1.20.1 / 1.20.4).

Mod Loader: Fabric (recommended for modern RPC networking) or Forge/NeoForge.

Discord Library: discord-game-sdk4j or DiscordIPC.

Deliverables Required:

Full project architecture and file directory tree.

Gradle build.gradle configuration with all necessary dependencies.

Key Java/Kotlin classes:

Main Mod Initialization Class.

Discord RPC Handler & Manager (handling status updates & custom presence config).

P2P Connection Manager (handling room creation, hosting, and Discord invite/join request hooks).

Packet/Registry fallback handler for cross-mod compatibility.
Kodari AI
KodariSep 10 at 5:30 pm 2
DiscordLink
DiscordLink is a Fabric mod for Minecraft 1.21.1 that integrates the game client with Discord. It provides secure OAuth2 authentication to link Discord accounts, stores session tokens safely in client config, and features fully customizable Rich Presence with dynamic placeholders like {world_name}, {biome}, and {health}. The mod enables P2P multiplayer joining through Discord friend invites, allowing players to host singleplayer sessions and invite friends directly. A cross-mod compatibility layer handles registry differences between modpacks gracefully, preventing crashes when joining worlds with mismatched mod lists.
  1. Project foundation: Fabric 1.21.11 Gradle setup, metadata, resources, and a blueprint README.

  2. Discord integration: encrypted OAuth token storage, Discord IPC presence, placeholders, and keybind-driven linking.

  3. Multiplayer: signaling-backed singleplayer hosting/joining with Discord join secrets and Fabric payload handshake.

  4. Compatibility boundary: registry fingerprint exchange that fails safely instead of pretending arbitrary modpacks can share incompatible registries.

Created the Fabric 1.21.11 DiscordLink project from scratch.

Included:

  • Fabric Loom 1.14 project setup targeting Minecraft 1.21.11 and Yarn mappings.

  • Discord OAuth2 PKCE account linking with encrypted local token storage.

  • Discord IPC Rich Presence with configurable placeholders:

    • {world_name}

    • {state}

    • {health}

    • {version}

  • Configurable presence and signaling settings in config/discordlink.json.

  • Discord IPC join-secret handling.

  • Singleplayer invite hosting with clipboard discordlink:// URIs.

  • Signaling client for HTTPS room creation and resolution.

  • Fabric CustomPayload compatibility handshake.

  • Deterministic loaded-mod fingerprint validation.

  • Keybinds:

    • L: Link Discord account

    • H: Host invite

    • J: Join clipboard invite

  • Full architecture and signaling-service contract in README.md.

The project intentionally rejects incompatible mod fingerprints rather than pretending arbitrary modpacks can safely share Minecraft registries. A real cross-modpack solution requires a controlled server-side protocol translation layer and explicit registry mappings.

salion2X

The compilation failed with this error:

code
Compilation failed with 2 error(s):

ERROR in src/main/java/com/kodari/discordlink/p2p/P2PConnectionManager.java at line 43: cannot find symbol
            client.execute(() -> client.connect(ServerAddress.parse(descriptor.endpoint()), null));
                                       ^
  symbol: method connect(ServerAddress,<null>)
  location: variable client of type MinecraftClient

ERROR in   src/main/java/com/kodari/discordlink/p2p/P2PConnectionManager.java at line 43: cannot find symbol
              client.execute(() -> client.connect(ServerAddress.parse(descriptor.endpoint()), null));
                                         ^
  symbol: method connect(ServerAddress,<null>)
  location: variable client of type MinecraftClient


=== COMPILATION ERROR ANALYSIS ===

MISSING METHODS:
  - connect(ServerAddress,<null>)
ACTION: Check method names and signatures

FILES TO INVESTIGATE:
  - src/main/java/com/kodari/discordlink/p2p/P2PConnectionManager.java
  -   src/main/java/com/kodari/discordlink/p2p/P2PConnectionManager.java

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

Kodari AI
KodariSep 10 at 5:30 pm 1
  1. Replace the removed MinecraftClient.connect(...) call with the 1.21.11 screen-based server connection API, preserving the existing invite flow.

Fixed P2PConnectionManager.java.

The removed MinecraftClient.connect(...) call now uses the 1.21.11 connection flow:

  • Parses the endpoint with ServerAddress.parse(...)

  • Creates a ServerInfo

  • Opens the connection through ConnectScreen.connect(...)

Updated artifact:

src/main/java/com/kodari/discordlink/p2p/P2PConnectionManager.java

salion2X

The compilation failed with this error:

code
Compilation failed with 6 error(s):

ERROR in src/main/java/com/kodari/discordlink/p2p/P2PConnectionManager.java at line 6: cannot find symbol
import net.minecraft.client.gui.screen.ConnectScreen;
                                      ^
  symbol: class ConnectScreen
  location: package net.minecraft.client.gui.screen

ERROR in src/main/java/com/kodari/discordlink/p2p/P2PConnectionManager.java at line 47: incompatible types: boolean cannot be converted to ServerType
                ServerInfo serverInfo = new ServerInfo("DiscordLink invite", descriptor.endpoint(), false);
                                                                                                    ^

ERROR in src/main/java/com/kodari/discordlink/p2p/P2PConnectionManager.java at line 48: cannot find symbol
                ConnectScreen.connect(null, client, address, serverInfo, false, null);
                ^
  symbol: variable ConnectScreen
  location: class P2PConnectionManager

ERROR in   src/main/java/com/kodari/discordlink/p2p/P2PConnectionManager.java at line 47: incompatible types: boolean cannot be converted to ServerType
                  ServerInfo serverInfo = new ServerInfo("DiscordLink invite", descriptor.endpoint(), false);
                                                                                                      ^

ERROR in   src/main/java/com/kodari/discordlink/p2p/P2PConnectionManager.java at line 6: cannot find symbol
  import net.minecraft.client.gui.screen.ConnectScreen;
                                        ^
  symbol: class ConnectScreen
  location: package net.minecraft.client.gui.screen

ERROR in   src/main/java/com/kodari/discordlink/p2p/P2PConnectionManager.java at line 48: cannot find symbol
                  ConnectScreen.connect(null, client, address, serverInfo, false, null);
                  ^
  symbol: variable ConnectScreen
  location: class P2PConnectionManager


=== COMPILATION ERROR ANALYSIS ===

MISSING CLASSES:
  - ConnectScreen
ACTION: Create these classes or check imports

TYPE MISMATCHES:
  - incompatible types: boolean cannot be converted to ServerType
  - incompatible types: boolean cannot be converted to ServerType
ACTION: Fix variable types or casting

FILES TO INVESTIGATE:
  - src/main/java/com/kodari/discordlink/p2p/P2PConnectionManager.java
  -   src/main/java/com/kodari/discordlink/p2p/P2PConnectionManager.java

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

Kodari AI
KodariSep 10 at 5:33 pm 1

Fixed P2PConnectionManager.java:

  • Corrected ConnectScreen import to:

    Java
    net.minecraft.client.gui.screen.multiplayer.ConnectScreen
    
  • Replaced the obsolete boolean ServerInfo argument with:

    Java
    ServerInfo.ServerType.OTHER
    

Updated artifact:

src/main/java/com/kodari/discordlink/p2p/P2PConnectionManager.java

salion2X
📎 1 file 1,099 chars
📄
pasted-code-1789061993491.txt
txt 20 lines
▶
Task: Add complete, user-friendly In-Game GUI Screens (using Cloth Config / YACL
or native Minecraft Screen API) for the com.kodari.discordlink mod.
Required GUI Screens & Features:
1. Discord Account Sync & Auth GUI:
• Screen showing active connection status (Linked Account, Avatar, Tag, User
ID).
• "Connect / Relink Account" button triggering OAuth2 / IPC authentication.
• "Disconnect / Logout" button clearing session tokens from SecureTokenStore.
2. Rich Presence Customizer GUI:
• Live editable text fields for Details, State, and Image Keys.
• Dynamic placeholder selector buttons (e.g. insert {world_name}, {biome},
{health}, {dimension}).
• Enable/Disable toggle switches for Rich Presence.
3. P2P Friend Invite & Lobby GUI:
• Integrated button in Singleplayer Pause Menu ("Invite Discord Friends").
• Friend List Screen showing online Discord friends using the mod.
• "Host P2P Session" toggle and "Send Game Invite" button linked to
P2PConnectionManager.
Deliverables: Provide all Java/Kotlin GUI Screen classes, Client Mod menu
entrypoints, and config binding logic.
Kodari AI
KodariSep 10 at 5:45 pm 4
  1. Native client GUI: add dashboard, account, Rich Presence, P2P lobby, and friend-status screens with shared config binding.

  2. Account lifecycle: persist Discord profile metadata after OAuth and add a secure logout path.

  3. In-game access: expose shared client services, register a pause-menu button, and add ModMenu configuration entrypoint.

  4. Presence/P2P integration: make saved GUI settings reload presence and wire host/copy/join actions to P2PConnectionManager.

Implemented the native Minecraft GUI suite for DiscordLink.

Added screens

  • DiscordLinkScreen

    • Main DiscordLink dashboard

    • Account, Rich Presence, and P2P navigation

  • DiscordAccountScreen

    • Discord client ID input

    • OAuth2 connect/relink flow

    • Linked account name/tag

    • Discord user ID

    • Avatar URL

    • Disconnect/logout action

    • Secure token clearing through SecureTokenStore

  • RichPresenceScreen

    • Editable Details, State, large image key, and small image key

    • Rich Presence enable/disable toggle

    • Placeholder insertion buttons:

      • {world_name}

      • {biome}

      • {health}

      • {dimension}

    • Immediate config persistence and presence refresh

  • P2PInviteScreen

    • Hosting toggle

    • Host P2P session

    • Send/copy game invite

    • Join clipboard invite

    • Discord friend screen navigation

  • DiscordFriendsScreen

    • Linked-account display

    • Friend/invite status screen

Integration added

  • Pause-menu button: Invite Discord Friends

  • ModMenu configuration entrypoint

  • ModMenu Gradle dependency and Terraformers Maven repository

  • manifest.kod bundling ModMenu

  • Client service getters for shared config, presence, and P2P managers

  • New discordlink.mixins.json

Additional updates

  • OAuth now fetches and stores Discord profile metadata:

    • User ID

    • Username

    • Global name

    • Discriminator

    • Avatar hash

    • Avatar URL

  • Added secure account logout cleanup.

  • Added {biome} and {dimension} Rich Presence placeholders.

  • Added DiscordPresenceManager.refresh() so GUI changes apply without restarting Minecraft.

The friend list screen is included, but the current custom Discord IPC implementation cannot enumerate a user’s Discord friends. It therefore provides an accurate explanation and uses the supported invite URI/Rich Presence flow instead of displaying fabricated friend data.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
manifest.kod
README.md
settings.gradle
Code
33 1,582
src/main/java/com/kodari/discordlink/DiscordLink.java
package com.kodari.discordlink;

import com.kodari.discordlink.network.DiscordLinkPackets;
import net.fabricmc.api.ModInitializer;

public final class DiscordLink implements ModInitializer {
    public static final String MOD_ID = "discordlink";
    public static final String PROTOCOL_VERSION = "1";

    @Override
    public void onInitialize() {
        DiscordLinkPackets.initialize();
    }
}