Drop mappings declaration for unobfuscated 26.2
Some checks failed
continuous-integration/drone/push Build is failing

Starting with 26.1 Mojang ships Minecraft unobfuscated, and Yarn /
Intermediary are no longer published past 1.21.11. Loom does not need
a mappings dependency in that mode: the Mojang-named source compiles
directly. Remove the mappings line, drop the yarn_mappings property,
revert the client entrypoint to Mojang names (Minecraft, Component,
ChatFormatting, gui.getChat(), getUser().getName()), and rewrite the
README note so it stops claiming Mojang mappings via Loom.
This commit is contained in:
2026-06-21 15:57:22 +06:00
parent 71dc665ef1
commit 8a969bc843
4 changed files with 20 additions and 22 deletions

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