Add mixins to NeoForge project

This commit is contained in:
Aizistral
2026-01-28 23:23:50 +01:00
parent ecb57b5a88
commit 12cda5e4ca
4 changed files with 52 additions and 0 deletions

View File

@@ -33,6 +33,7 @@ runs {
// "REGISTRIES": For firing of registry events. // "REGISTRIES": For firing of registry events.
// "REGISTRYDUMP": For getting the contents of all registries. // "REGISTRYDUMP": For getting the contents of all registries.
systemProperty 'forge.logging.markers', 'REGISTRIES' systemProperty 'forge.logging.markers', 'REGISTRIES'
systemProperty 'mixin.env.disableRefMap', 'true'
// Recommended logging level for the console // Recommended logging level for the console
// You can set various levels here. // You can set various levels here.

View File

@@ -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);
}
}

View File

@@ -24,3 +24,6 @@ description="A mod dedicated to removing restrictions around the use of multipla
versionRange="1.20.2" versionRange="1.20.2"
ordering="NONE" ordering="NONE"
side="BOTH" side="BOTH"
[[mixins]]
config="nochatrestrictions.mixins.json"

View File

@@ -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
}
}