aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSw3ys2026-08-22 16:25:20 +0100
committerSw3ys2026-08-22 16:25:20 +0100
commit5af607f117dea7a0525951762f650f30d86f57d7 (patch)
tree150eef086625d4b9ceac5883096972226698e83b
parentc853c395323585eb4129b9268e2961fffc4491d7 (diff)
Wrap user properties on read instead of transforming authlib
Account switchers fetch UserProperties themselves and assign the result straight to Minecraft#userPropertiesFuture, so wrapping the service at createUserApiService does not reliably survive a switch. Hooking Minecraft#userProperties instead covers every read, no matter which service or properties instance is currently in place. This also works on all three loaders, unlike the YggdrasilUserApiService mixin, which can only be applied on Fabric since Forge and NeoForge load authlib outside of the transformable class path. That mixin is now redundant and has been removed. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
-rw-r--r--Fabric/src/main/java/com/aizistral/nochatrestrictions/mixins/MixinMinecraft.java9
-rw-r--r--Fabric/src/main/java/com/aizistral/nochatrestrictions/mixins/MixinYggdrasilUserApiService.java45
-rw-r--r--Fabric/src/main/resources/nochatrestrictions.mixins.json3
-rw-r--r--Forge/src/main/java/com/aizistral/nochatrestrictions/mixins/MixinMinecraft.java9
-rw-r--r--Forge/src/main/java/com/aizistral/nochatrestrictions/mixins/MixinYggdrasilUserApiService.java45
-rw-r--r--Forge/src/main/resources/nochatrestrictions.mixins.json3
-rw-r--r--NeoForge/src/main/java/com/aizistral/nochatrestrictions/mixins/MixinMinecraft.java9
-rw-r--r--NeoForge/src/main/java/com/aizistral/nochatrestrictions/mixins/MixinYggdrasilUserApiService.java45
-rw-r--r--NeoForge/src/main/resources/nochatrestrictions.mixins.json3
9 files changed, 30 insertions, 141 deletions
diff --git a/Fabric/src/main/java/com/aizistral/nochatrestrictions/mixins/MixinMinecraft.java b/Fabric/src/main/java/com/aizistral/nochatrestrictions/mixins/MixinMinecraft.java
index aad4046..bffc6a9 100644
--- a/Fabric/src/main/java/com/aizistral/nochatrestrictions/mixins/MixinMinecraft.java
+++ b/Fabric/src/main/java/com/aizistral/nochatrestrictions/mixins/MixinMinecraft.java
@@ -8,6 +8,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import com.aizistral.nochatrestrictions.core.NCRCore;
import com.aizistral.nochatrestrictions.core.WrappedUserApiService;
import com.mojang.authlib.minecraft.UserApiService;
+import com.mojang.authlib.minecraft.UserApiService.UserProperties;
import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
import net.minecraft.client.Minecraft;
@@ -26,6 +27,14 @@ public class MixinMinecraft {
NCRCore.LOGGER.info("Successfully supplanted UserApiService with a wrapped version.");
}
+ // Account switchers fetch the properties themselves and put the result straight into
+ // userPropertiesFuture, so wrapping the service on its own doesn't always stick.
+ // Everything that gates chat/multiplayer/realms reads them back through here.
+ @Inject(method = "userProperties", at = @At("RETURN"), cancellable = true)
+ public void onGetUserProperties(CallbackInfoReturnable<UserProperties> info) {
+ info.setReturnValue(NCRCore.FORCED_USER_PROPERTIES);
+ }
+
@Inject(method = "isNameBanned", at = @At("HEAD"), cancellable = true)
public void onCheckNameBan(CallbackInfoReturnable<Boolean> info) {
info.setReturnValue(Boolean.FALSE);
diff --git a/Fabric/src/main/java/com/aizistral/nochatrestrictions/mixins/MixinYggdrasilUserApiService.java b/Fabric/src/main/java/com/aizistral/nochatrestrictions/mixins/MixinYggdrasilUserApiService.java
deleted file mode 100644
index 0e99493..0000000
--- a/Fabric/src/main/java/com/aizistral/nochatrestrictions/mixins/MixinYggdrasilUserApiService.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package com.aizistral.nochatrestrictions.mixins;
-
-import java.util.Map;
-import java.util.concurrent.Executor;
-
-import org.spongepowered.asm.mixin.Mixin;
-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.nochatrestrictions.core.NCRCore;
-import com.google.common.collect.ImmutableSet;
-import com.mojang.authlib.minecraft.TelemetrySession;
-import com.mojang.authlib.minecraft.UserApiService.UserFlag;
-import com.mojang.authlib.minecraft.UserApiService.UserProperties;
-import com.mojang.authlib.yggdrasil.YggdrasilUserApiService;
-
-/**
- * Applies the chat/multiplayer restriction removal directly on the concrete
- * service class instead of just wrapping it once at {@code Minecraft#createUserApiService}.
- *
- * In-game account switchers (e.g. IAS) build a brand new {@link YggdrasilUserApiService}
- * and swap it onto the Minecraft instance without going through the original wrapping
- * path, which is why restrictions used to come back after switching accounts. By hooking
- * the service class itself, every instance the game ever uses returns permissive
- * properties, regardless of who created it or when.
- */
-@Mixin(value = YggdrasilUserApiService.class, remap = false)
-public class MixinYggdrasilUserApiService {
-
- static {
- NCRCore.LOGGER.info("MixinYggdrasilUserApiService initialized succesfully.");
- }
-
- @Inject(method = "fetchProperties", at = @At("RETURN"), cancellable = true)
- private void onFetchProperties(CallbackInfoReturnable<UserProperties> info) {
- info.setReturnValue(NCRCore.FORCED_USER_PROPERTIES);
- }
-
- @Inject(method = "newTelemetrySession", at = @At("HEAD"), cancellable = true)
- private void onNewTelemetrySession(Executor executor, CallbackInfoReturnable<TelemetrySession> info) {
- info.setReturnValue(TelemetrySession.DISABLED);
- }
-
-}
diff --git a/Fabric/src/main/resources/nochatrestrictions.mixins.json b/Fabric/src/main/resources/nochatrestrictions.mixins.json
index 3f5e294..4b9d3fd 100644
--- a/Fabric/src/main/resources/nochatrestrictions.mixins.json
+++ b/Fabric/src/main/resources/nochatrestrictions.mixins.json
@@ -4,8 +4,7 @@
"minVersion": "0.8",
"mixins": [],
"client": [
- "MixinMinecraft",
- "MixinYggdrasilUserApiService"
+ "MixinMinecraft"
],
"injectors": {
"defaultRequire": 1
diff --git a/Forge/src/main/java/com/aizistral/nochatrestrictions/mixins/MixinMinecraft.java b/Forge/src/main/java/com/aizistral/nochatrestrictions/mixins/MixinMinecraft.java
index bf9b67e..a436702 100644
--- a/Forge/src/main/java/com/aizistral/nochatrestrictions/mixins/MixinMinecraft.java
+++ b/Forge/src/main/java/com/aizistral/nochatrestrictions/mixins/MixinMinecraft.java
@@ -8,6 +8,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import com.aizistral.nochatrestrictions.core.NCRCore;
import com.aizistral.nochatrestrictions.core.WrappedUserApiService;
import com.mojang.authlib.minecraft.UserApiService;
+import com.mojang.authlib.minecraft.UserApiService.UserProperties;
import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
import net.minecraft.client.Minecraft;
@@ -26,6 +27,14 @@ public class MixinMinecraft {
NCRCore.LOGGER.info("Successfully supplanted UserApiService with a wrapped version.");
}
+ // Account switchers fetch the properties themselves and put the result straight into
+ // userPropertiesFuture, so wrapping the service on its own doesn't always stick.
+ // Everything that gates chat/multiplayer/realms reads them back through here.
+ @Inject(method = "userProperties", at = @At("RETURN"), cancellable = true)
+ public void onGetUserProperties(CallbackInfoReturnable<UserProperties> info) {
+ info.setReturnValue(NCRCore.FORCED_USER_PROPERTIES);
+ }
+
@Inject(method = "isNameBanned", at = @At("HEAD"), cancellable = true)
public void onCheckNameBan(CallbackInfoReturnable<Boolean> info) {
info.setReturnValue(Boolean.FALSE);
diff --git a/Forge/src/main/java/com/aizistral/nochatrestrictions/mixins/MixinYggdrasilUserApiService.java b/Forge/src/main/java/com/aizistral/nochatrestrictions/mixins/MixinYggdrasilUserApiService.java
deleted file mode 100644
index 0e99493..0000000
--- a/Forge/src/main/java/com/aizistral/nochatrestrictions/mixins/MixinYggdrasilUserApiService.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package com.aizistral.nochatrestrictions.mixins;
-
-import java.util.Map;
-import java.util.concurrent.Executor;
-
-import org.spongepowered.asm.mixin.Mixin;
-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.nochatrestrictions.core.NCRCore;
-import com.google.common.collect.ImmutableSet;
-import com.mojang.authlib.minecraft.TelemetrySession;
-import com.mojang.authlib.minecraft.UserApiService.UserFlag;
-import com.mojang.authlib.minecraft.UserApiService.UserProperties;
-import com.mojang.authlib.yggdrasil.YggdrasilUserApiService;
-
-/**
- * Applies the chat/multiplayer restriction removal directly on the concrete
- * service class instead of just wrapping it once at {@code Minecraft#createUserApiService}.
- *
- * In-game account switchers (e.g. IAS) build a brand new {@link YggdrasilUserApiService}
- * and swap it onto the Minecraft instance without going through the original wrapping
- * path, which is why restrictions used to come back after switching accounts. By hooking
- * the service class itself, every instance the game ever uses returns permissive
- * properties, regardless of who created it or when.
- */
-@Mixin(value = YggdrasilUserApiService.class, remap = false)
-public class MixinYggdrasilUserApiService {
-
- static {
- NCRCore.LOGGER.info("MixinYggdrasilUserApiService initialized succesfully.");
- }
-
- @Inject(method = "fetchProperties", at = @At("RETURN"), cancellable = true)
- private void onFetchProperties(CallbackInfoReturnable<UserProperties> info) {
- info.setReturnValue(NCRCore.FORCED_USER_PROPERTIES);
- }
-
- @Inject(method = "newTelemetrySession", at = @At("HEAD"), cancellable = true)
- private void onNewTelemetrySession(Executor executor, CallbackInfoReturnable<TelemetrySession> info) {
- info.setReturnValue(TelemetrySession.DISABLED);
- }
-
-}
diff --git a/Forge/src/main/resources/nochatrestrictions.mixins.json b/Forge/src/main/resources/nochatrestrictions.mixins.json
index c74587e..c9e96c5 100644
--- a/Forge/src/main/resources/nochatrestrictions.mixins.json
+++ b/Forge/src/main/resources/nochatrestrictions.mixins.json
@@ -5,8 +5,7 @@
"refmap": "nochatrestrictions.refmap.json",
"mixins": [],
"client": [
- "MixinMinecraft",
- "MixinYggdrasilUserApiService"
+ "MixinMinecraft"
],
"injectors": {
"defaultRequire": 1
diff --git a/NeoForge/src/main/java/com/aizistral/nochatrestrictions/mixins/MixinMinecraft.java b/NeoForge/src/main/java/com/aizistral/nochatrestrictions/mixins/MixinMinecraft.java
index aad4046..bffc6a9 100644
--- a/NeoForge/src/main/java/com/aizistral/nochatrestrictions/mixins/MixinMinecraft.java
+++ b/NeoForge/src/main/java/com/aizistral/nochatrestrictions/mixins/MixinMinecraft.java
@@ -8,6 +8,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import com.aizistral.nochatrestrictions.core.NCRCore;
import com.aizistral.nochatrestrictions.core.WrappedUserApiService;
import com.mojang.authlib.minecraft.UserApiService;
+import com.mojang.authlib.minecraft.UserApiService.UserProperties;
import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
import net.minecraft.client.Minecraft;
@@ -26,6 +27,14 @@ public class MixinMinecraft {
NCRCore.LOGGER.info("Successfully supplanted UserApiService with a wrapped version.");
}
+ // Account switchers fetch the properties themselves and put the result straight into
+ // userPropertiesFuture, so wrapping the service on its own doesn't always stick.
+ // Everything that gates chat/multiplayer/realms reads them back through here.
+ @Inject(method = "userProperties", at = @At("RETURN"), cancellable = true)
+ public void onGetUserProperties(CallbackInfoReturnable<UserProperties> info) {
+ info.setReturnValue(NCRCore.FORCED_USER_PROPERTIES);
+ }
+
@Inject(method = "isNameBanned", at = @At("HEAD"), cancellable = true)
public void onCheckNameBan(CallbackInfoReturnable<Boolean> info) {
info.setReturnValue(Boolean.FALSE);
diff --git a/NeoForge/src/main/java/com/aizistral/nochatrestrictions/mixins/MixinYggdrasilUserApiService.java b/NeoForge/src/main/java/com/aizistral/nochatrestrictions/mixins/MixinYggdrasilUserApiService.java
deleted file mode 100644
index 0e99493..0000000
--- a/NeoForge/src/main/java/com/aizistral/nochatrestrictions/mixins/MixinYggdrasilUserApiService.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package com.aizistral.nochatrestrictions.mixins;
-
-import java.util.Map;
-import java.util.concurrent.Executor;
-
-import org.spongepowered.asm.mixin.Mixin;
-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.nochatrestrictions.core.NCRCore;
-import com.google.common.collect.ImmutableSet;
-import com.mojang.authlib.minecraft.TelemetrySession;
-import com.mojang.authlib.minecraft.UserApiService.UserFlag;
-import com.mojang.authlib.minecraft.UserApiService.UserProperties;
-import com.mojang.authlib.yggdrasil.YggdrasilUserApiService;
-
-/**
- * Applies the chat/multiplayer restriction removal directly on the concrete
- * service class instead of just wrapping it once at {@code Minecraft#createUserApiService}.
- *
- * In-game account switchers (e.g. IAS) build a brand new {@link YggdrasilUserApiService}
- * and swap it onto the Minecraft instance without going through the original wrapping
- * path, which is why restrictions used to come back after switching accounts. By hooking
- * the service class itself, every instance the game ever uses returns permissive
- * properties, regardless of who created it or when.
- */
-@Mixin(value = YggdrasilUserApiService.class, remap = false)
-public class MixinYggdrasilUserApiService {
-
- static {
- NCRCore.LOGGER.info("MixinYggdrasilUserApiService initialized succesfully.");
- }
-
- @Inject(method = "fetchProperties", at = @At("RETURN"), cancellable = true)
- private void onFetchProperties(CallbackInfoReturnable<UserProperties> info) {
- info.setReturnValue(NCRCore.FORCED_USER_PROPERTIES);
- }
-
- @Inject(method = "newTelemetrySession", at = @At("HEAD"), cancellable = true)
- private void onNewTelemetrySession(Executor executor, CallbackInfoReturnable<TelemetrySession> info) {
- info.setReturnValue(TelemetrySession.DISABLED);
- }
-
-}
diff --git a/NeoForge/src/main/resources/nochatrestrictions.mixins.json b/NeoForge/src/main/resources/nochatrestrictions.mixins.json
index c74587e..c9e96c5 100644
--- a/NeoForge/src/main/resources/nochatrestrictions.mixins.json
+++ b/NeoForge/src/main/resources/nochatrestrictions.mixins.json
@@ -5,8 +5,7 @@
"refmap": "nochatrestrictions.refmap.json",
"mixins": [],
"client": [
- "MixinMinecraft",
- "MixinYggdrasilUserApiService"
+ "MixinMinecraft"
],
"injectors": {
"defaultRequire": 1