aboutsummaryrefslogtreecommitdiffstats
path: root/Forge/src
diff options
context:
space:
mode:
authorAizistral2026-01-27 16:22:45 +0100
committerAizistral2026-01-27 16:22:45 +0100
commit52dd4db7d99297031e4f2a073e5d62d93da35d56 (patch)
tree412a9ca495d43b804163a3e689a1aea4623cec27 /Forge/src
parent5ce84e68d7788ba437ebd2c484b649c8b1b059eb (diff)
Update mixins and code for 1.18.2
Diffstat (limited to 'Forge/src')
-rw-r--r--Forge/src/main/java/com/aizistral/nochatrestrictions/core/WrappedSocialInteractionsService.java41
-rw-r--r--Forge/src/main/java/com/aizistral/nochatrestrictions/core/WrappedUserApiService.java51
-rw-r--r--Forge/src/main/java/com/aizistral/nochatrestrictions/mixins/MixinMinecraft.java16
3 files changed, 59 insertions, 49 deletions
diff --git a/Forge/src/main/java/com/aizistral/nochatrestrictions/core/WrappedSocialInteractionsService.java b/Forge/src/main/java/com/aizistral/nochatrestrictions/core/WrappedSocialInteractionsService.java
deleted file mode 100644
index 1d3d2b1..0000000
--- a/Forge/src/main/java/com/aizistral/nochatrestrictions/core/WrappedSocialInteractionsService.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package com.aizistral.nochatrestrictions.core;
-
-import java.util.UUID;
-import com.mojang.authlib.minecraft.SocialInteractionsService;
-
-public class WrappedSocialInteractionsService implements SocialInteractionsService {
- private final SocialInteractionsService service;
-
- public WrappedSocialInteractionsService(SocialInteractionsService service) {
- if (service == null)
- throw new NullPointerException("'service' argument cannot be null!");
-
- this.service = service;
- }
-
- @Override
- public boolean serversAllowed() {
- return true;
- }
-
- @Override
- public boolean realmsAllowed() {
- return true;
- }
-
- @Override
- public boolean chatAllowed() {
- return true;
- }
-
- @Override
- public boolean telemetryAllowed() {
- return false;
- }
-
- @Override
- public boolean isBlockedPlayer(UUID playerID) {
- return this.service.isBlockedPlayer(playerID);
- }
-
-}
diff --git a/Forge/src/main/java/com/aizistral/nochatrestrictions/core/WrappedUserApiService.java b/Forge/src/main/java/com/aizistral/nochatrestrictions/core/WrappedUserApiService.java
new file mode 100644
index 0000000..2206cd8
--- /dev/null
+++ b/Forge/src/main/java/com/aizistral/nochatrestrictions/core/WrappedUserApiService.java
@@ -0,0 +1,51 @@
+package com.aizistral.nochatrestrictions.core;
+
+import java.util.UUID;
+import java.util.concurrent.Executor;
+
+import com.google.common.collect.ImmutableSet;
+import com.mojang.authlib.minecraft.TelemetrySession;
+import com.mojang.authlib.minecraft.UserApiService;
+
+public class WrappedUserApiService implements UserApiService {
+ private static final UserProperties FORCED_PROPERTIES;
+
+ static {
+ ImmutableSet.Builder<UserFlag> flags = ImmutableSet.builder();
+
+ flags.add(UserFlag.CHAT_ALLOWED); // always let the player access chat
+ flags.add(UserFlag.SERVERS_ALLOWED); // always let the player open multiplayer menu
+ flags.add(UserFlag.REALMS_ALLOWED); // always let the player open Realms menu
+ // flags.add(UserFlag.TELEMETRY_ENABLED); // not adding this for obvious reasons
+ // flags.add(UserFlag.PROFANITY_FILTER_ENABLED) // not adding this one either
+
+ FORCED_PROPERTIES = new UserProperties(flags.build());
+ }
+
+ private final UserApiService service;
+
+ public WrappedUserApiService(UserApiService service) {
+ this.service = service;
+ }
+
+ @Override
+ public UserProperties properties() {
+ return FORCED_PROPERTIES;
+ }
+
+ @Override
+ public boolean isBlockedPlayer(UUID playerID) {
+ return this.service.isBlockedPlayer(playerID);
+ }
+
+ @Override
+ public void refreshBlockList() {
+ this.service.refreshBlockList();
+ }
+
+ @Override
+ public TelemetrySession newTelemetrySession(Executor executor) {
+ return TelemetrySession.DISABLED;
+ }
+
+}
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 86c35d4..4b2b473 100644
--- a/Forge/src/main/java/com/aizistral/nochatrestrictions/mixins/MixinMinecraft.java
+++ b/Forge/src/main/java/com/aizistral/nochatrestrictions/mixins/MixinMinecraft.java
@@ -6,8 +6,8 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import com.aizistral.nochatrestrictions.core.NCRCore;
-import com.aizistral.nochatrestrictions.core.WrappedSocialInteractionsService;
-import com.mojang.authlib.minecraft.SocialInteractionsService;
+import com.aizistral.nochatrestrictions.core.WrappedUserApiService;
+import com.mojang.authlib.minecraft.UserApiService;
import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
import net.minecraft.client.Minecraft;
@@ -16,14 +16,14 @@ import net.minecraft.client.main.GameConfig;
@Mixin(Minecraft.class)
public class MixinMinecraft {
- @Inject(method = { "func_244735_a", "createSocialInteractions" }, at = @At("RETURN"), cancellable = true)
- public void onCreateSocialInteractions(YggdrasilAuthenticationService authService, GameConfig gameConfig,
- CallbackInfoReturnable<SocialInteractionsService> info) {
- SocialInteractionsService returnedService = info.getReturnValue();
+ @Inject(method = { "m_193585_", "createUserApiService" }, at = @At("RETURN"), cancellable = true)
+ public void onCreateUserApi(YggdrasilAuthenticationService authService, GameConfig gameConfig,
+ CallbackInfoReturnable<UserApiService> info) {
+ UserApiService returnedService = info.getReturnValue();
assert returnedService != null;
- info.setReturnValue(new WrappedSocialInteractionsService(returnedService));
+ info.setReturnValue(new WrappedUserApiService(returnedService));
- NCRCore.LOGGER.info("Successfully supplanted SocialInteractionsService with a wrapped version.");
+ NCRCore.LOGGER.info("Successfully supplanted UserApiService with a wrapped version.");
}
}