diff options
| author | Aizistral | 2026-01-28 23:23:50 +0100 |
|---|---|---|
| committer | Aizistral | 2026-01-28 23:23:50 +0100 |
| commit | 12cda5e4ca99388ee03a59713220c7169051e821 (patch) | |
| tree | 70166dac0896105068f20c72744b40036d236f66 /NeoForge | |
| parent | ecb57b5a8882f8da0ae2d23bf0a2f7891db5f828 (diff) | |
Add mixins to NeoForge project
Diffstat (limited to 'NeoForge')
4 files changed, 52 insertions, 0 deletions
diff --git a/NeoForge/build.gradle b/NeoForge/build.gradle index db57ae0..929c690 100644 --- a/NeoForge/build.gradle +++ b/NeoForge/build.gradle @@ -33,6 +33,7 @@ runs { // "REGISTRIES": For firing of registry events. // "REGISTRYDUMP": For getting the contents of all registries. systemProperty 'forge.logging.markers', 'REGISTRIES' + systemProperty 'mixin.env.disableRefMap', 'true' // Recommended logging level for the console // You can set various levels here. diff --git a/NeoForge/src/main/java/com/aizistral/nochatrestrictions/mixins/MixinMinecraft.java b/NeoForge/src/main/java/com/aizistral/nochatrestrictions/mixins/MixinMinecraft.java new file mode 100644 index 0000000..eb2cebe --- /dev/null +++ b/NeoForge/src/main/java/com/aizistral/nochatrestrictions/mixins/MixinMinecraft.java @@ -0,0 +1,34 @@ +package com.aizistral.nochatrestrictions.mixins; + +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.aizistral.nochatrestrictions.core.WrappedUserApiService; +import com.mojang.authlib.minecraft.UserApiService; +import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.main.GameConfig; + +@Mixin(Minecraft.class) +public class MixinMinecraft { + + @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 WrappedUserApiService(returnedService)); + + NCRCore.LOGGER.info("Successfully supplanted UserApiService with a wrapped version."); + } + + @Inject(method = { "m_294837_", "isNameBanned" }, at = @At("HEAD"), cancellable = true) + public void onCheckNameBan(CallbackInfoReturnable<Boolean> info) { + info.setReturnValue(Boolean.FALSE); + } + +} diff --git a/NeoForge/src/main/resources/META-INF/mods.toml b/NeoForge/src/main/resources/META-INF/mods.toml index dd0f863..577cd3f 100644 --- a/NeoForge/src/main/resources/META-INF/mods.toml +++ b/NeoForge/src/main/resources/META-INF/mods.toml @@ -24,3 +24,6 @@ description="A mod dedicated to removing restrictions around the use of multipla versionRange="1.20.2" ordering="NONE" side="BOTH" + +[[mixins]] +config="nochatrestrictions.mixins.json" diff --git a/NeoForge/src/main/resources/nochatrestrictions.mixins.json b/NeoForge/src/main/resources/nochatrestrictions.mixins.json new file mode 100644 index 0000000..02723ef --- /dev/null +++ b/NeoForge/src/main/resources/nochatrestrictions.mixins.json @@ -0,0 +1,14 @@ +{ + "required": true, + "package": "com.aizistral.nochatrestrictions.mixins", + "compatibilityLevel": "JAVA_17", + "minVersion": "0.8", + "refmap": "nochatrestrictions.refmap.json", + "mixins": [], + "client": [ + "MixinMinecraft" + ], + "injectors": { + "defaultRequire": 1 + } +} |
