From c648e2495327f7fe6ecfdda91d8075a9141dd5a7 Mon Sep 17 00:00:00 2001 From: Aizistral Date: Wed, 30 Sep 2026 00:28:00 +0200 Subject: Initial 26.3 port --- .../core/WrappedUserApiService.java | 6 +-- .../nochatrestrictions/mixins/MixinMinecraft.java | 4 +- .../MixinMinecraftServicesUserApiService.java | 60 +++++++++++++++++++++ .../mixins/MixinYggdrasilUserApiService.java | 63 ---------------------- 4 files changed, 64 insertions(+), 69 deletions(-) create mode 100644 Forge/src/main/java/com/aizistral/nochatrestrictions/mixins/MixinMinecraftServicesUserApiService.java delete mode 100644 Forge/src/main/java/com/aizistral/nochatrestrictions/mixins/MixinYggdrasilUserApiService.java (limited to 'Forge/src/main/java/com/aizistral/nochatrestrictions') diff --git a/Forge/src/main/java/com/aizistral/nochatrestrictions/core/WrappedUserApiService.java b/Forge/src/main/java/com/aizistral/nochatrestrictions/core/WrappedUserApiService.java index 1b653ee..248d102 100644 --- a/Forge/src/main/java/com/aizistral/nochatrestrictions/core/WrappedUserApiService.java +++ b/Forge/src/main/java/com/aizistral/nochatrestrictions/core/WrappedUserApiService.java @@ -1,19 +1,17 @@ package com.aizistral.nochatrestrictions.core; -import java.util.Map; import java.util.UUID; import java.util.concurrent.Executor; import org.jetbrains.annotations.Nullable; import com.aizistral.nochatrestrictions.config.NCRConfig; -import com.google.common.collect.ImmutableSet; import com.mojang.authlib.exceptions.AuthenticationException; import com.mojang.authlib.minecraft.TelemetrySession; import com.mojang.authlib.minecraft.UserApiService; import com.mojang.authlib.minecraft.report.AbuseReportLimits; -import com.mojang.authlib.yggdrasil.request.AbuseReportRequest; -import com.mojang.authlib.yggdrasil.response.KeyPairResponse; +import com.mojang.authlib.services.request.AbuseReportRequest; +import com.mojang.authlib.services.response.KeyPairResponse; public class WrappedUserApiService implements UserApiService { private final UserApiService service; 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 4dc6080..2a8f935 100644 --- a/Forge/src/main/java/com/aizistral/nochatrestrictions/mixins/MixinMinecraft.java +++ b/Forge/src/main/java/com/aizistral/nochatrestrictions/mixins/MixinMinecraft.java @@ -8,7 +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.yggdrasil.YggdrasilAuthenticationService; +import com.mojang.authlib.services.MinecraftServicesDiscoveryService; import net.minecraft.client.Minecraft; import net.minecraft.client.main.GameConfig; @@ -17,7 +17,7 @@ import net.minecraft.client.main.GameConfig; public class MixinMinecraft { @Inject(method = "createUserApiService", at = @At("RETURN"), cancellable = true) - private static void onCreateUserApi(YggdrasilAuthenticationService authService, GameConfig gameConfig, + private static void onCreateUserApi(MinecraftServicesDiscoveryService discoveryService, GameConfig gameConfig, CallbackInfoReturnable info) { UserApiService returnedService = info.getReturnValue(); assert returnedService != null; diff --git a/Forge/src/main/java/com/aizistral/nochatrestrictions/mixins/MixinMinecraftServicesUserApiService.java b/Forge/src/main/java/com/aizistral/nochatrestrictions/mixins/MixinMinecraftServicesUserApiService.java new file mode 100644 index 0000000..f38140b --- /dev/null +++ b/Forge/src/main/java/com/aizistral/nochatrestrictions/mixins/MixinMinecraftServicesUserApiService.java @@ -0,0 +1,60 @@ +package com.aizistral.nochatrestrictions.mixins; + +import java.util.concurrent.Executor; + +import org.jetbrains.annotations.Nullable; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +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.config.NCRConfig; +import com.aizistral.nochatrestrictions.core.NCRCore; +import com.aizistral.nochatrestrictions.core.WrappedUserProperties; +import com.mojang.authlib.minecraft.TelemetrySession; +import com.mojang.authlib.minecraft.UserApiService.UserProperties; +import com.mojang.authlib.services.MinecraftServicesUserApiService; + +/** + * 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 MinecraftServicesUserApiService} + * 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 = MinecraftServicesUserApiService.class, remap = false) +public class MixinMinecraftServicesUserApiService { + + static { + NCRCore.LOGGER.info("MixinMinecraftServicesUserApiService initialized successfully."); + } + + private @Unique @Nullable UserProperties wrappedProperties; + + @Inject(method = "fetchProperties", at = @At("RETURN"), cancellable = true) + private void onFetchProperties(CallbackInfoReturnable info) { + UserProperties original = info.getReturnValue(); + + if (original == null) + return; + else if (this.wrappedProperties != null) { + info.setReturnValue(this.wrappedProperties); + return; + } else { + info.setReturnValue(this.wrappedProperties = WrappedUserProperties.of(original)); + return; + } + } + + @Inject(method = "newTelemetrySession", at = @At("HEAD"), cancellable = true) + private void onNewTelemetrySession(Executor executor, CallbackInfoReturnable info) { + if (!NCRConfig.getInstance().allowTelemetry()) { + info.setReturnValue(TelemetrySession.DISABLED); + } + } + +} 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 4ff648d..0000000 --- a/Forge/src/main/java/com/aizistral/nochatrestrictions/mixins/MixinYggdrasilUserApiService.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.aizistral.nochatrestrictions.mixins; - -import java.util.Map; -import java.util.concurrent.Executor; - -import org.jetbrains.annotations.Nullable; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; -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.config.NCRConfig; -import com.aizistral.nochatrestrictions.core.NCRCore; -import com.aizistral.nochatrestrictions.core.WrappedUserProperties; -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."); - } - - private @Unique @Nullable UserProperties wrappedProperties; - - @Inject(method = "fetchProperties", at = @At("RETURN"), cancellable = true) - private void onFetchProperties(CallbackInfoReturnable info) { - UserProperties original = info.getReturnValue(); - - if (original == null) - return; - else if (this.wrappedProperties != null) { - info.setReturnValue(this.wrappedProperties); - return; - } else { - info.setReturnValue(this.wrappedProperties = WrappedUserProperties.of(original)); - return; - } - } - - @Inject(method = "newTelemetrySession", at = @At("HEAD"), cancellable = true) - private void onNewTelemetrySession(Executor executor, CallbackInfoReturnable info) { - if (!NCRConfig.getInstance().allowTelemetry()) { - info.setReturnValue(TelemetrySession.DISABLED); - } - } - -} -- cgit v1.2.3