summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/aizistral/nochatreports/NoChatReportsClient.java18
-rw-r--r--src/main/java/com/aizistral/nochatreports/config/NCRConfigClient.java24
-rw-r--r--src/main/java/com/aizistral/nochatreports/mixins/client/MixinChatOptionsScreen.java9
-rw-r--r--src/main/java/com/aizistral/nochatreports/mixins/client/MixinChatScreen.java2
-rw-r--r--src/main/java/com/aizistral/nochatreports/mixins/client/MixinClientboundHelloPacket.java4
-rw-r--r--src/main/java/com/aizistral/nochatreports/mixins/client/MixinConnectScreen.java3
-rw-r--r--src/main/java/com/aizistral/nochatreports/mixins/client/MixinJoinMultiplayerScreen.java52
-rw-r--r--src/main/java/com/aizistral/nochatreports/mixins/client/MixinLocalPlayer.java7
-rw-r--r--src/main/java/com/aizistral/nochatreports/mixins/client/MixinOptions.java4
-rw-r--r--src/main/java/com/aizistral/nochatreports/mixins/client/MixinProfileKeyPairManager.java13
-rw-r--r--src/main/java/com/aizistral/nochatreports/mixins/client/MixinRealmsConnect.java4
-rw-r--r--src/main/java/com/aizistral/nochatreports/network/ClientChannelHandler.java23
-rw-r--r--src/main/resources/assets/nochatreports/lang/en_us.json3
-rw-r--r--src/main/resources/assets/nochatreports/textures/gui/ncr_toggle_button.pngbin0 -> 1268 bytes
-rw-r--r--src/main/resources/nochatreports.accesswidener6
15 files changed, 157 insertions, 15 deletions
diff --git a/src/main/java/com/aizistral/nochatreports/NoChatReportsClient.java b/src/main/java/com/aizistral/nochatreports/NoChatReportsClient.java
index b534f10..bc43f21 100644
--- a/src/main/java/com/aizistral/nochatreports/NoChatReportsClient.java
+++ b/src/main/java/com/aizistral/nochatreports/NoChatReportsClient.java
@@ -3,6 +3,7 @@ package com.aizistral.nochatreports;
import java.util.List;
import com.aizistral.nochatreports.config.NCRConfig;
+import com.aizistral.nochatreports.config.NCRConfigClient;
import com.aizistral.nochatreports.core.ServerDataExtension;
import com.aizistral.nochatreports.core.ServerSafetyLevel;
import com.aizistral.nochatreports.core.ServerSafetyState;
@@ -52,13 +53,20 @@ public final class NoChatReportsClient implements ClientModInitializer {
@Override
public void onInitializeClient() {
NoChatReports.LOGGER.info("Client initialization...");
- ClientPlayNetworking.registerGlobalReceiver(NoChatReports.CHANNEL, ClientChannelHandler.INSTANCE);
+
+ if (NCRConfig.getClient().enableMod()) {
+ ClientChannelHandler.INSTANCE.register();
+ }
+
ClientPlayConnectionEvents.JOIN.register(this::onPlayReady);
ClientPlayConnectionEvents.DISCONNECT.register(this::onDisconnect);
ScreenEvents.AFTER_INIT.register(this::onScreenInit);
}
private void onScreenInit(Minecraft client, Screen screen, int scaledWidth, int scaledHeight) {
+ if (!NCRConfig.getClient().enableMod())
+ return;
+
if (screen instanceof AccessorDisconnectedScreen dsc) {
if (screenOverride)
return;
@@ -84,8 +92,8 @@ public final class NoChatReportsClient implements ClientModInitializer {
} else {
if (ServerSafetyState.getReconnectCount() <= 0) {
ServerSafetyState.setAllowsUnsafeServer(true);
- screenOverride = false;
reconnectLastServer();
+ screenOverride = false;
return;
} else {
ServerSafetyState.setReconnectCount(0);
@@ -101,10 +109,16 @@ public final class NoChatReportsClient implements ClientModInitializer {
}
private void onDisconnect(ClientPacketListener handler, Minecraft client) {
+ if (!NCRConfig.getClient().enableMod())
+ return;
+
client.execute(ServerSafetyState::reset);
}
private void onPlayReady(ClientPacketListener handler, PacketSender sender, Minecraft client) {
+ if (!NCRConfig.getClient().enableMod())
+ return;
+
client.execute(() -> {
ServerSafetyState.setReconnectCount(0);
diff --git a/src/main/java/com/aizistral/nochatreports/config/NCRConfigClient.java b/src/main/java/com/aizistral/nochatreports/config/NCRConfigClient.java
index 1d78df2..371a16c 100644
--- a/src/main/java/com/aizistral/nochatreports/config/NCRConfigClient.java
+++ b/src/main/java/com/aizistral/nochatreports/config/NCRConfigClient.java
@@ -16,7 +16,8 @@ public final class NCRConfigClient extends JSONConfig {
protected boolean demandOnServer = false, showServerSafety = true, hideRedChatIndicators = true,
hideYellowChatIndicators = true, hideGrayChatIndicators = true, hideWarningToast = true,
alwaysHideReportButton = false, disableTelemetry = true, showReloadButton = true,
- whitelistAllServers = false, verifiedIconEnabled = true;
+ whitelistAllServers = false, verifiedIconEnabled = true, showNCRButton = true,
+ enableMod = true;
protected int verifiedIconOffsetX = 0, verifiedIconOffsetY = 0;
protected NCRConfigClient() {
@@ -28,6 +29,10 @@ public final class NCRConfigClient extends JSONConfig {
return new NCRConfigClient();
}
+ public void toggleMod() {
+ this.enableMod = !this.enableMod;
+ }
+
/**
* @return True if client with No Chat Reports installed should demand that mod is present on
* every server that it tries to join. In that case client will not be able to join servers that
@@ -173,4 +178,21 @@ public final class NCRConfigClient extends JSONConfig {
return 12 + this.verifiedIconOffsetY;
}
+ /**
+ * @return True if button to disable/enable entire mod should be displayed in
+ * multiplayer menu.
+ */
+
+ public boolean showNCRButton() {
+ return this.showNCRButton;
+ }
+
+ /**
+ * @return Whether or not No Chat Reports should provide networking-related functionality.
+ */
+
+ public boolean enableMod() {
+ return this.enableMod;
+ }
+
}
diff --git a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinChatOptionsScreen.java b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinChatOptionsScreen.java
index dab16ad..2d0c9ba 100644
--- a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinChatOptionsScreen.java
+++ b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinChatOptionsScreen.java
@@ -5,6 +5,7 @@ import java.util.List;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.asm.mixin.Mixin;
+import com.aizistral.nochatreports.config.NCRConfig;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.Minecraft;
@@ -43,6 +44,10 @@ public class MixinChatOptionsScreen extends SimpleOptionsSubScreen {
@Override
protected void init() {
super.init();
+
+ if (!NCRConfig.getClient().enableMod())
+ return;
+
this.secureChatTooltip = Minecraft.getInstance().font.split(Component.translatable("gui.nochatreport.secureChat"), 200);
this.onlyShowSecureChat = this.list.findOption(Minecraft.getInstance().options.onlyShowSecureChat());
@@ -60,6 +65,10 @@ public class MixinChatOptionsScreen extends SimpleOptionsSubScreen {
@Override
public void render(@NotNull PoseStack poseStack, int x, int y, float f) {
super.render(poseStack, x, y, f);
+
+ if (!NCRConfig.getClient().enableMod())
+ return;
+
if (this.onlyShowSecureChat != null && this.onlyShowSecureChat.visible && x >= (double) this.onlyShowSecureChat.x && y >= (double) this.onlyShowSecureChat.y && x < (double) (this.onlyShowSecureChat.x + this.onlyShowSecureChat.getWidth()) && y < (double) (this.onlyShowSecureChat.y + this.onlyShowSecureChat.getHeight())) {
this.renderTooltip(poseStack, this.secureChatTooltip, x, y);
}
diff --git a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinChatScreen.java b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinChatScreen.java
index 123fb0a..e5437b6 100644
--- a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinChatScreen.java
+++ b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinChatScreen.java
@@ -46,7 +46,7 @@ public abstract class MixinChatScreen extends Screen {
@Inject(method = "init", at = @At("HEAD"))
private void onInit(CallbackInfo info) {
- if (!NCRConfig.getClient().showServerSafety())
+ if (!NCRConfig.getClient().showServerSafety() || !NCRConfig.getClient().enableMod())
return;
ServerSafetyLevel trust = this.minecraft.isLocalServer() ? ServerSafetyLevel.SECURE : ServerSafetyState.getCurrent();
diff --git a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinClientboundHelloPacket.java b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinClientboundHelloPacket.java
index 36989e8..82df5af 100644
--- a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinClientboundHelloPacket.java
+++ b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinClientboundHelloPacket.java
@@ -5,6 +5,7 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+import com.aizistral.nochatreports.config.NCRConfig;
import com.aizistral.nochatreports.core.ServerSafetyLevel;
import com.aizistral.nochatreports.core.ServerSafetyState;
@@ -23,6 +24,9 @@ public class MixinClientboundHelloPacket {
@Inject(method = "handle", at = @At("HEAD"))
private void onHandle(ClientLoginPacketListener listener, CallbackInfo info) {
+ if (!NCRConfig.getClient().enableMod())
+ return;
+
ServerSafetyState.setSessionRequestedKey(true);
}
diff --git a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinConnectScreen.java b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinConnectScreen.java
index 8d0a97c..804f06b 100644
--- a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinConnectScreen.java
+++ b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinConnectScreen.java
@@ -29,6 +29,9 @@ public class MixinConnectScreen {
@Inject(method = "startConnecting", at = @At("HEAD"))
private static void onStartConnecting(Screen screen, Minecraft minecraft, ServerAddress serverAddress,
@Nullable ServerData serverData, CallbackInfo info) {
+ if (!NCRConfig.getClient().enableMod())
+ return;
+
ServerSafetyState.updateCurrent(ServerSafetyLevel.UNKNOWN); // just to be 100% sure
ServerSafetyState.setLastConnectedServer(serverAddress, serverData);
diff --git a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinJoinMultiplayerScreen.java b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinJoinMultiplayerScreen.java
index cb1122b..872aee4 100644
--- a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinJoinMultiplayerScreen.java
+++ b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinJoinMultiplayerScreen.java
@@ -9,6 +9,8 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import com.aizistral.nochatreports.config.NCRConfig;
+import com.aizistral.nochatreports.core.ServerSafetyState;
+import com.aizistral.nochatreports.network.ClientChannelHandler;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.BufferBuilder;
import com.mojang.blaze3d.vertex.BufferUploader;
@@ -24,6 +26,7 @@ import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent
import net.minecraft.client.gui.screens.multiplayer.JoinMultiplayerScreen;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.client.renderer.MultiBufferSource;
+import net.minecraft.locale.Language;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.FormattedCharSequence;
@@ -35,7 +38,8 @@ import net.minecraft.util.FormattedCharSequence;
@Mixin(JoinMultiplayerScreen.class)
public abstract class MixinJoinMultiplayerScreen extends Screen {
- private static final ResourceLocation RELOAD_TEXTURE = new ResourceLocation("nochatreports", "textures/gui/config_reload_button.png");
+ private static final ResourceLocation RELOAD_TEXTURE = new ResourceLocation("nochatreports", "textures/gui/config_reload_button.png"),
+ TOGGLE_TEXTURE = new ResourceLocation("nochatreports", "textures/gui/ncr_toggle_button.png");
private static final Component RELOAD_TOOLTIP = Component.translatable("gui.nochatrepords.reload_config_tooltip");
protected MixinJoinMultiplayerScreen() {
@@ -45,16 +49,44 @@ public abstract class MixinJoinMultiplayerScreen extends Screen {
@Inject(method = "init", at = @At("HEAD"))
private void onInit(CallbackInfo info) {
- if (!NCRConfig.getClient().showReloadButton())
- return;
+ if (NCRConfig.getClient().showReloadButton()) {
+ var button = new ImageButton(this.width/2 + 158, this.height - 52, 20, 20, 0, 0, 20,
+ RELOAD_TEXTURE, 64, 64, btn -> NCRConfig.load(), (btn, poseStack, i, j) ->
+ this.renderTooltipNoGap(poseStack, this.minecraft.font.split(RELOAD_TOOLTIP, 250), i, j),
+ Component.translatable("gui.nochatrepords.reload_config"));
+ button.active = true;
+ button.visible = true;
+ this.addRenderableWidget(button);
+ }
+
+ if (NCRConfig.getClient().showNCRButton()) {
+ var button = new ImageButton(this.width/2 + 158, this.height - 28, 20, 20,
+ NCRConfig.getClient().enableMod() ? 0 : 20, 0, 20, TOGGLE_TEXTURE, 64, 64,
+ btn -> {
+ NCRConfig.getClient().toggleMod();
+ boolean enabled = NCRConfig.getClient().enableMod();
- var button = new ImageButton(this.width/2 + 158, this.height - 52, 20, 20, 0, 0, 20, RELOAD_TEXTURE,
- 64, 64, btn -> NCRConfig.load(), (btn, poseStack, i, j) ->
- this.renderTooltipNoGap(poseStack, this.minecraft.font.split(RELOAD_TOOLTIP, 250), i, j),
- Component.translatable("gui.nochatrepords.reload_config"));
- button.active = true;
- button.visible = true;
- this.addRenderableWidget(button);
+ if (enabled) {
+ ((ImageButton)btn).xTexStart = 0;
+ ClientChannelHandler.INSTANCE.register();
+ } else {
+ ((ImageButton)btn).xTexStart = 20;
+ ClientChannelHandler.INSTANCE.unregister();
+ }
+
+ ServerSafetyState.reset();
+ }, (btn, poseStack, i, j) -> this.renderTooltip(poseStack,
+ this.minecraft.font.split(
+ Component.translatable("gui.nochatreports.ncr_toggle_tooltip",
+ Language.getInstance()
+ .getOrDefault("gui.nochatreports.ncr_state_"
+ + (NCRConfig.getClient().enableMod()
+ ? "on" : "off"))), 250), i, j),
+ Component.translatable("gui.nochatreports.ncr_toggle"));
+ button.active = true;
+ button.visible = true;
+ this.addRenderableWidget(button);
+ }
}
protected void renderTooltipNoGap(PoseStack poseStack, List<? extends FormattedCharSequence> list, int i, int j) {
diff --git a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinLocalPlayer.java b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinLocalPlayer.java
index 1f7d3be..9e43d68 100644
--- a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinLocalPlayer.java
+++ b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinLocalPlayer.java
@@ -7,6 +7,7 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
+import com.aizistral.nochatreports.config.NCRConfig;
import com.aizistral.nochatreports.core.ServerSafetyState;
import com.mojang.brigadier.ParseResults;
@@ -30,6 +31,9 @@ public class MixinLocalPlayer {
@Inject(method = "signMessage", at = @At("HEAD"), cancellable = true)
private void onSignMessage(MessageSigner signer, ChatMessageContent message, LastSeenMessages messages, CallbackInfoReturnable<MessageSignature> info) {
+ if (!NCRConfig.getClient().enableMod())
+ return;
+
if (!ServerSafetyState.forceSignedMessages()) {
info.setReturnValue(MessageSignature.EMPTY);
}
@@ -42,6 +46,9 @@ public class MixinLocalPlayer {
@Inject(method = "signCommandArguments", at = @At("HEAD"), cancellable = true)
private void onSignCommand(MessageSigner signer, ParseResults<SharedSuggestionProvider> results, @Nullable Component component, LastSeenMessages messages, CallbackInfoReturnable<ArgumentSignatures> info) {
+ if (!NCRConfig.getClient().enableMod())
+ return;
+
if (!ServerSafetyState.forceSignedMessages()) {
info.setReturnValue(ArgumentSignatures.EMPTY);
}
diff --git a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinOptions.java b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinOptions.java
index b6cde14..8bbdbfb 100644
--- a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinOptions.java
+++ b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinOptions.java
@@ -6,6 +6,7 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
+import com.aizistral.nochatreports.config.NCRConfig;
import com.google.common.collect.ImmutableList;
import com.mojang.serialization.Codec;
@@ -25,6 +26,9 @@ public class MixinOptions {
@Inject(method = "onlyShowSecureChat", at = @At("RETURN"), cancellable = true)
private void onlyShowSecureChat(CallbackInfoReturnable<OptionInstance<Boolean>> cir) {
+ if (!NCRConfig.getClient().enableMod())
+ return;
+
if (this.alternativeOption == null) {
this.alternativeOption = new OptionInstance<>("options.onlyShowSecureChat",
OptionInstance.cachedConstantTooltip(Component.translatable("gui.nochatreport.secureChat")),
diff --git a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinProfileKeyPairManager.java b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinProfileKeyPairManager.java
index b9b4731..407a7ed 100644
--- a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinProfileKeyPairManager.java
+++ b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinProfileKeyPairManager.java
@@ -8,6 +8,7 @@ import org.spongepowered.asm.mixin.injection.Group;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
+import com.aizistral.nochatreports.config.NCRConfig;
import com.aizistral.nochatreports.core.ServerSafetyState;
import com.mojang.authlib.yggdrasil.response.KeyPairResponse;
@@ -27,6 +28,9 @@ public class MixinProfileKeyPairManager {
@Inject(method = "profilePublicKey", at = @At("HEAD"), cancellable = true)
private void onProfilePublicKey(CallbackInfoReturnable<Optional<ProfilePublicKey>> info) {
+ if (!NCRConfig.getClient().enableMod())
+ return;
+
if (!ServerSafetyState.allowsUnsafeServer()) {
info.setReturnValue(Optional.empty());
}
@@ -41,6 +45,9 @@ public class MixinProfileKeyPairManager {
@Group(min = 1, max = 2)
@Inject(method = "parsePublicKey", at = @At("HEAD"), cancellable = true)
private static void onParsePublicKey(KeyPairResponse response, CallbackInfoReturnable<ProfilePublicKey.Data> info) {
+ if (!NCRConfig.getClient().enableMod())
+ return;
+
if (!ServerSafetyState.allowsUnsafeServer()) {
info.setReturnValue(null);
}
@@ -55,6 +62,9 @@ public class MixinProfileKeyPairManager {
@Group(min = 1, max = 2)
@Inject(method = { "profilePublicKeyData", "method_43784" }, at = @At("HEAD"), cancellable = true, remap = false)
private void onProfilePublicKeyData(CallbackInfoReturnable<Optional<ProfilePublicKey.Data>> info) {
+ if (!NCRConfig.getClient().enableMod())
+ return;
+
if (!ServerSafetyState.allowsUnsafeServer()) {
info.setReturnValue(Optional.empty());
}
@@ -68,6 +78,9 @@ public class MixinProfileKeyPairManager {
@Inject(method = "signer", at = @At("HEAD"), cancellable = true)
private void onSigner(CallbackInfoReturnable<Optional<Signer>> info) {
+ if (!NCRConfig.getClient().enableMod())
+ return;
+
if (!ServerSafetyState.allowsUnsafeServer()) {
info.setReturnValue(null);
}
diff --git a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinRealmsConnect.java b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinRealmsConnect.java
index 01a5b1f..351c43f 100644
--- a/src/main/java/com/aizistral/nochatreports/mixins/client/MixinRealmsConnect.java
+++ b/src/main/java/com/aizistral/nochatreports/mixins/client/MixinRealmsConnect.java
@@ -5,6 +5,7 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+import com.aizistral.nochatreports.config.NCRConfig;
import com.aizistral.nochatreports.core.ServerSafetyLevel;
import com.aizistral.nochatreports.core.ServerSafetyState;
import com.mojang.realmsclient.dto.RealmsServer;
@@ -22,6 +23,9 @@ public class MixinRealmsConnect {
@Inject(method = "connect", at = @At("HEAD"))
private void onConnect(RealmsServer realmsServer, ServerAddress serverAddress, CallbackInfo info) {
+ if (!NCRConfig.getClient().enableMod())
+ return;
+
ServerSafetyState.setLastConnectedServer(serverAddress, null);
ServerSafetyState.updateCurrent(ServerSafetyLevel.INSECURE);
ServerSafetyState.setAllowsUnsafeServer(true);
diff --git a/src/main/java/com/aizistral/nochatreports/network/ClientChannelHandler.java b/src/main/java/com/aizistral/nochatreports/network/ClientChannelHandler.java
index 58c4734..fd44f1a 100644
--- a/src/main/java/com/aizistral/nochatreports/network/ClientChannelHandler.java
+++ b/src/main/java/com/aizistral/nochatreports/network/ClientChannelHandler.java
@@ -1,7 +1,10 @@
package com.aizistral.nochatreports.network;
+import com.aizistral.nochatreports.NoChatReports;
+
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
+import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking.PlayChannelHandler;
import net.fabricmc.fabric.api.networking.v1.PacketSender;
import net.minecraft.client.Minecraft;
@@ -16,6 +19,7 @@ import net.minecraft.network.FriendlyByteBuf;
@Environment(EnvType.CLIENT)
public final class ClientChannelHandler implements PlayChannelHandler {
public static final ClientChannelHandler INSTANCE = new ClientChannelHandler();
+ private boolean registered = false;
private ClientChannelHandler() {
// Can't touch this
@@ -25,4 +29,23 @@ public final class ClientChannelHandler implements PlayChannelHandler {
public void receive(Minecraft client, ClientPacketListener handler, FriendlyByteBuf buf, PacketSender responseSender) {
// NO-OP
}
+
+ public void register() {
+ if (!this.registered) {
+ ClientPlayNetworking.registerGlobalReceiver(NoChatReports.CHANNEL, ClientChannelHandler.INSTANCE);
+ this.registered = true;
+ }
+ }
+
+ public void unregister() {
+ if (this.registered) {
+ ClientPlayNetworking.unregisterGlobalReceiver(NoChatReports.CHANNEL);
+ this.registered = false;
+ }
+ }
+
+ public boolean isRegistered() {
+ return this.registered;
+ }
+
}
diff --git a/src/main/resources/assets/nochatreports/lang/en_us.json b/src/main/resources/assets/nochatreports/lang/en_us.json
index 9a6c84d..2acdeb4 100644
--- a/src/main/resources/assets/nochatreports/lang/en_us.json
+++ b/src/main/resources/assets/nochatreports/lang/en_us.json
@@ -13,6 +13,9 @@
"gui.nochatreports.unsafe_server.check": "Do not show again for this server",
"gui.nochatrepords.reload_config_tooltip": "Reload No Chat Reports config. Use carefully.",
"gui.nochatreports.verified_server": "§a§lSafe Server§r\nWe could verify that this server has No Chat Reports installed, or prevents chat reports in some other known way. You can chat there safely.",
+ "gui.nochatreports.ncr_toggle_tooltip": "§lNo Chat Reports:§r %1$s\nDisable or enable most of the mod's client-sided functionality. You may have to do this to join some Paper/Velocity servers, as they are known for causing issues with NCR.\nCertain networking-unrelated things, such as chat trust status tweaks and removal of vanilla's \"Chat messages can't be verified\" toast will still work; they can be disabled in config individually.",
+ "gui.nochatreports.ncr_state_on": "§a§lEnabled§r",
+ "gui.nochatreports.ncr_state_off": "§c§lDisabled§r",
"configuration.NoChatReports.config": "No Chat Reports",
diff --git a/src/main/resources/assets/nochatreports/textures/gui/ncr_toggle_button.png b/src/main/resources/assets/nochatreports/textures/gui/ncr_toggle_button.png
new file mode 100644
index 0000000..5d213f8
--- /dev/null
+++ b/src/main/resources/assets/nochatreports/textures/gui/ncr_toggle_button.png
Binary files differ
diff --git a/src/main/resources/nochatreports.accesswidener b/src/main/resources/nochatreports.accesswidener
index b1e1b2d..de7f190 100644
--- a/src/main/resources/nochatreports.accesswidener
+++ b/src/main/resources/nochatreports.accesswidener
@@ -1,4 +1,8 @@
accessWidener v1 named
mutable field net/minecraft/client/multiplayer/ClientPacketListener callbackScreen Lnet/minecraft/client/gui/screens/Screen;
accessible field net/minecraft/client/multiplayer/ClientPacketListener callbackScreen Lnet/minecraft/client/gui/screens/Screen;
-accessible field net/minecraft/client/gui/screens/SimpleOptionsSubScreen list Lnet/minecraft/client/gui/components/OptionsList; \ No newline at end of file
+accessible field net/minecraft/client/gui/screens/SimpleOptionsSubScreen list Lnet/minecraft/client/gui/components/OptionsList;
+accessible field net/minecraft/client/gui/components/ImageButton xTexStart I
+accessible field net/minecraft/client/gui/components/ImageButton yTexStart I
+mutable field net/minecraft/client/gui/components/ImageButton xTexStart I
+mutable field net/minecraft/client/gui/components/ImageButton yTexStart I \ No newline at end of file