Switch to Yarn mappings 26.2+build.3
Some checks failed
continuous-integration/drone/push Build is failing

Loom rejected officialMojangMappings() with a non-obfuscated
environment error, and Mojang client_mappings are not published for
26.2 yet. Pin Yarn at 26.2+build.3 via the new yarn_mappings property
and rewrite the client entrypoint with Yarn names: MinecraftClient,
Text, Formatting, inGameHud.getChatHud(), getSession().getUsername().
This commit is contained in:
2026-06-21 15:49:02 +06:00
parent fb233cee93
commit 71dc665ef1
3 changed files with 21 additions and 20 deletions

View File

@@ -30,7 +30,7 @@ repositories {
dependencies { dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}" minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings loom.officialMojangMappings() mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
} }

View File

@@ -4,6 +4,7 @@ org.gradle.configuration-cache=false
# Minecraft 26.2 released on 2026-06-16. # Minecraft 26.2 released on 2026-06-16.
minecraft_version=26.2 minecraft_version=26.2
yarn_mappings=26.2+build.3
loader_version=0.19.3 loader_version=0.19.3
fabric_version=0.152.2+26.2 fabric_version=0.152.2+26.2

View File

@@ -5,9 +5,9 @@ import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.message.v1.ClientSendMessageEvents; import net.fabricmc.fabric.api.client.message.v1.ClientSendMessageEvents;
import net.fabricmc.loader.api.FabricLoader; import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.ChatFormatting; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.Minecraft; import net.minecraft.text.Text;
import net.minecraft.network.chat.Component; import net.minecraft.util.Formatting;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -49,8 +49,8 @@ public final class ClientIrcMod implements ClientModInitializer {
ClientTickEvents.END_CLIENT_TICK.register(client -> { ClientTickEvents.END_CLIENT_TICK.register(client -> {
IrcService.DisplayLine line; IrcService.DisplayLine line;
while ((line = service.pollLine()) != null) { while ((line = service.pollLine()) != null) {
ChatFormatting color = line.system() ? ChatFormatting.GRAY : ChatFormatting.AQUA; Formatting color = line.system() ? Formatting.GRAY : Formatting.AQUA;
pushClientChat(client, Component.literal(line.text()).withStyle(color)); pushClientChat(client, Text.literal(line.text()).formatted(color));
} }
}); });
@@ -63,17 +63,17 @@ public final class ClientIrcMod implements ClientModInitializer {
return false; return false;
} }
Minecraft client = Minecraft.getInstance(); MinecraftClient client = MinecraftClient.getInstance();
String argument = trimmed.length() == COMMAND_PREFIX.length() ? "" : trimmed.substring(COMMAND_PREFIX.length()).trim(); String argument = trimmed.length() == COMMAND_PREFIX.length() ? "" : trimmed.substring(COMMAND_PREFIX.length()).trim();
if (argument.isBlank()) { if (argument.isBlank()) {
pushClientChat(client, Component.literal("[IRC] Usage: .irc <message> | .irc status | .irc reconnect | .irc reload").withStyle(ChatFormatting.YELLOW)); pushClientChat(client, Text.literal("[IRC] Usage: .irc <message> | .irc status | .irc reconnect | .irc reload").formatted(Formatting.YELLOW));
return true; return true;
} }
if ("status".equalsIgnoreCase(argument)) { if ("status".equalsIgnoreCase(argument)) {
String status = service.isConnected() ? "connected" : "disconnected"; String status = service.isConnected() ? "connected" : "disconnected";
pushClientChat(client, Component.literal("[IRC] " + status + " | " + config.host + ":" + config.port + " | clientName=" + config.clientName).withStyle(ChatFormatting.YELLOW)); pushClientChat(client, Text.literal("[IRC] " + status + " | " + config.host + ":" + config.port + " | clientName=" + config.clientName).formatted(Formatting.YELLOW));
return true; return true;
} }
@@ -81,8 +81,8 @@ public final class ClientIrcMod implements ClientModInitializer {
String playerName = resolvePlayerName(client); String playerName = resolvePlayerName(client);
IO_EXECUTOR.execute(() -> { IO_EXECUTOR.execute(() -> {
boolean connected = service.reconnect(playerName); boolean connected = service.reconnect(playerName);
ChatFormatting color = connected ? ChatFormatting.GREEN : ChatFormatting.RED; Formatting color = connected ? Formatting.GREEN : Formatting.RED;
pushClientChat(client, Component.literal("[IRC] reconnect " + (connected ? "ok" : "failed")).withStyle(color)); pushClientChat(client, Text.literal("[IRC] reconnect " + (connected ? "ok" : "failed")).formatted(color));
}); });
return true; return true;
} }
@@ -90,40 +90,40 @@ public final class ClientIrcMod implements ClientModInitializer {
if ("reload".equalsIgnoreCase(argument)) { if ("reload".equalsIgnoreCase(argument)) {
config = IrcConfig.load(FabricLoader.getInstance().getConfigDir().resolve("clientirc.json")); config = IrcConfig.load(FabricLoader.getInstance().getConfigDir().resolve("clientirc.json"));
service.updateConfig(config); service.updateConfig(config);
pushClientChat(client, Component.literal("[IRC] config reloaded").withStyle(ChatFormatting.YELLOW)); pushClientChat(client, Text.literal("[IRC] config reloaded").formatted(Formatting.YELLOW));
return true; return true;
} }
String playerName = resolvePlayerName(client); String playerName = resolvePlayerName(client);
IO_EXECUTOR.execute(() -> { IO_EXECUTOR.execute(() -> {
if (!service.ensureConnected(playerName)) { if (!service.ensureConnected(playerName)) {
pushClientChat(client, Component.literal("[IRC] server is offline or config is wrong").withStyle(ChatFormatting.RED)); pushClientChat(client, Text.literal("[IRC] server is offline or config is wrong").formatted(Formatting.RED));
return; return;
} }
if (!service.sendChat(playerName, argument)) { if (!service.sendChat(playerName, argument)) {
pushClientChat(client, Component.literal("[IRC] send failed").withStyle(ChatFormatting.RED)); pushClientChat(client, Text.literal("[IRC] send failed").formatted(Formatting.RED));
} }
}); });
return true; return true;
} }
private static void pushClientChat(Minecraft client, Component text) { private static void pushClientChat(MinecraftClient client, Text text) {
if (client == null) { if (client == null) {
return; return;
} }
client.execute(() -> { client.execute(() -> {
if (client.gui != null && client.gui.getChat() != null) { if (client.inGameHud != null && client.inGameHud.getChatHud() != null) {
client.gui.getChat().addMessage(text); client.inGameHud.getChatHud().addMessage(text);
} }
}); });
} }
private static String resolvePlayerName(Minecraft client) { private static String resolvePlayerName(MinecraftClient client) {
if (client != null && client.player != null) { if (client != null && client.player != null) {
return client.player.getGameProfile().getName(); return client.player.getGameProfile().getName();
} }
if (client != null && client.getUser() != null) { if (client != null && client.getSession() != null) {
return client.getUser().getName(); return client.getSession().getUsername();
} }
return "unknown"; return "unknown";
} }