blob: 862d381136a46ad7ec051ecd1199aa23967c1203 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
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.aizistral.nochatrestrictions.core.WrappedUserProperties;
import com.mojang.authlib.minecraft.UserApiService;
import com.mojang.authlib.minecraft.UserApiService.UserProperties;
import com.mojang.authlib.services.MinecraftServicesDiscoveryService;
import net.minecraft.client.Minecraft;
import net.minecraft.client.main.GameConfig;
@Mixin(value = Minecraft.class, remap = false)
public class MixinMinecraft {
@Inject(method = "createUserApiService", at = @At("RETURN"), cancellable = true)
private static void onCreateUserApi(MinecraftServicesDiscoveryService discoveryService, 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 = "userProperties", at = @At("RETURN"), cancellable = true)
private void onGetUserProperties(CallbackInfoReturnable<UserProperties> info) {
UserProperties properties = info.getReturnValue();
if (properties != null) {
info.setReturnValue(WrappedUserProperties.of(properties));
}
}
@Inject(method = "isNameBanned", at = @At("HEAD"), cancellable = true)
private void onCheckNameBan(CallbackInfoReturnable<Boolean> info) {
info.setReturnValue(Boolean.FALSE);
}
}
|