mirror of
https://github.com/refactorinqq/SLC-1.8.9.git
synced 2024-11-10 06:31:32 +01:00
Nick Hider
This commit is contained in:
parent
c6b324f384
commit
655c37daa8
@ -1,12 +0,0 @@
|
||||
package net.silentclient.client.mixin.accessors;
|
||||
|
||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||
import net.minecraft.client.network.NetworkPlayerInfo;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(AbstractClientPlayer.class)
|
||||
public interface AbstractClientPlayerAccessor {
|
||||
@Accessor
|
||||
NetworkPlayerInfo getPlayerInfo();
|
||||
}
|
@ -2,9 +2,9 @@ package net.silentclient.client.mixin.accessors;
|
||||
|
||||
import net.minecraft.client.network.NetworkPlayerInfo;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
@Mixin(NetworkPlayerInfo.class)
|
||||
public interface NetworkPlayerInfoAccessor {
|
||||
@Accessor("skinType") String silent$getSkinType();
|
||||
@Invoker("loadPlayerTextures") void silent$loadPlayerTextures();
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package net.silentclient.client.mixin.ducks;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.silentclient.client.cosmetics.*;
|
||||
import net.silentclient.client.cosmetics.dynamiccurved.DynamicCape;
|
||||
import net.silentclient.client.utils.types.PlayerResponse;
|
||||
@ -35,4 +34,5 @@ public interface AbstractClientPlayerExt {
|
||||
AnimatedResourceLocation silent$getCape();
|
||||
String silent$getNameClear();
|
||||
void silent$setNameClear(String a);
|
||||
Object silent$getPlayerInfo();
|
||||
}
|
||||
|
@ -0,0 +1,6 @@
|
||||
package net.silentclient.client.mixin.ducks;
|
||||
|
||||
public interface NetworkPlayerInfoExt {
|
||||
String silent$getSkinType();
|
||||
Object silent$getLocationSkin();
|
||||
}
|
@ -3,6 +3,7 @@ package net.silentclient.client.mixin.mixins;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||
import net.minecraft.client.network.NetworkPlayerInfo;
|
||||
import net.minecraft.client.renderer.texture.DynamicTexture;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StringUtils;
|
||||
@ -20,6 +21,7 @@ import net.silentclient.client.utils.Players;
|
||||
import net.silentclient.client.utils.SCTextureManager;
|
||||
import net.silentclient.client.utils.types.PlayerResponse;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
@ -30,6 +32,7 @@ import java.util.Random;
|
||||
|
||||
@Mixin(AbstractClientPlayer.class)
|
||||
public abstract class AbstractClientPlayerMixin implements AbstractClientPlayerExt {
|
||||
@Shadow private NetworkPlayerInfo playerInfo;
|
||||
@Unique private AnimatedResourceLocation silent$cape;
|
||||
@Unique private AnimatedResourceLocation silent$bandana;
|
||||
@Unique private HatData silent$hat;
|
||||
@ -276,4 +279,9 @@ public abstract class AbstractClientPlayerMixin implements AbstractClientPlayerE
|
||||
public void silent$setPlayerIcon(StaticResourceLocation a) {
|
||||
this.silent$playerIcon = a;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object silent$getPlayerInfo() {
|
||||
return this.playerInfo;
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,43 @@
|
||||
package net.silentclient.client.mixin.mixins;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.network.NetworkPlayerInfo;
|
||||
import net.minecraft.client.resources.DefaultPlayerSkin;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.silentclient.client.Client;
|
||||
import net.silentclient.client.admin.AdminRender;
|
||||
import net.silentclient.client.mixin.accessors.NetworkPlayerInfoAccessor;
|
||||
import net.silentclient.client.mixin.ducks.AbstractClientPlayerExt;
|
||||
import net.silentclient.client.mixin.ducks.NetworkPlayerInfoExt;
|
||||
import net.silentclient.client.mods.player.NickHiderMod;
|
||||
import net.silentclient.client.mods.render.AnimationsMod;
|
||||
import net.silentclient.client.utils.NetworkPlayerInfoOptimization;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(NetworkPlayerInfo.class)
|
||||
public abstract class NetworkPlayerInfoMixin {
|
||||
@Inject(method = "loadPlayerTextures", at = @At("HEAD"))
|
||||
public abstract class NetworkPlayerInfoMixin implements NetworkPlayerInfoExt {
|
||||
@Shadow public abstract GameProfile getGameProfile();
|
||||
|
||||
@Shadow @Final private GameProfile gameProfile;
|
||||
|
||||
@Shadow private String skinType;
|
||||
|
||||
@Shadow private ResourceLocation locationSkin;
|
||||
|
||||
@Shadow protected abstract void loadPlayerTextures();
|
||||
|
||||
@Inject(method = "loadPlayerTextures", at = @At("HEAD"), cancellable = true)
|
||||
public void optimizationOfLoadingTexturesStart(CallbackInfo ci) {
|
||||
if(NetworkPlayerInfoOptimization.isLoadingSkin) {
|
||||
ci.cancel();
|
||||
return;
|
||||
}
|
||||
NetworkPlayerInfoOptimization.isLoadingSkin = true;
|
||||
@ -28,4 +54,85 @@ public abstract class NetworkPlayerInfoMixin {
|
||||
NetworkPlayerInfoOptimization.isLoadingSkin = false;
|
||||
})).start();
|
||||
}
|
||||
|
||||
@Inject(method = "getLocationSkin", at = @At("HEAD"), cancellable = true)
|
||||
public void customSkinLocation(CallbackInfoReturnable<ResourceLocation> cir) {
|
||||
if(Minecraft.getMinecraft().currentScreen instanceof AdminRender) {
|
||||
cir.setReturnValue(new ResourceLocation("textures/entity/steve.png"));
|
||||
cir.cancel();
|
||||
return;
|
||||
}
|
||||
if(Client.getInstance().getModInstances().getNickHiderMod().isEnabled() && Client.getInstance().getSettingsManager().getSettingByClass(NickHiderMod.class, "Hide Skins").getValBoolean()) {
|
||||
if(Client.getInstance().getSettingsManager().getSettingByClass(NickHiderMod.class, "Use Own Skin For All").getValBoolean()) {
|
||||
if(((AbstractClientPlayerExt) Minecraft.getMinecraft().thePlayer).silent$getPlayerInfo() != null) {
|
||||
if (((NetworkPlayerInfoExt) ((AbstractClientPlayerExt) Minecraft.getMinecraft().thePlayer).silent$getPlayerInfo()).silent$getLocationSkin() == null)
|
||||
{
|
||||
((NetworkPlayerInfoAccessor) ((AbstractClientPlayerExt) Minecraft.getMinecraft().thePlayer).silent$getPlayerInfo()).silent$loadPlayerTextures();
|
||||
}
|
||||
cir.setReturnValue((ResourceLocation) Objects.firstNonNull(((NetworkPlayerInfoExt) ((AbstractClientPlayerExt) Minecraft.getMinecraft().thePlayer).silent$getPlayerInfo()).silent$getLocationSkin(), DefaultPlayerSkin.getDefaultSkin(this.gameProfile.getId())));
|
||||
cir.cancel();
|
||||
return;
|
||||
} else {
|
||||
cir.setReturnValue(DefaultPlayerSkin.getDefaultSkin(Minecraft.getMinecraft().thePlayer.getGameProfile().getId()));
|
||||
cir.cancel();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(this.gameProfile.getId().equals(Minecraft.getMinecraft().thePlayer.getGameProfile().getId()) && Client.getInstance().getSettingsManager().getSettingByClass(NickHiderMod.class, "Use Real Skin For Self").getValBoolean()) {
|
||||
if (this.locationSkin == null)
|
||||
{
|
||||
this.loadPlayerTextures();
|
||||
}
|
||||
cir.setReturnValue((ResourceLocation)Objects.firstNonNull(this.locationSkin, DefaultPlayerSkin.getDefaultSkin(this.gameProfile.getId())));
|
||||
cir.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
cir.setReturnValue(DefaultPlayerSkin.getDefaultSkin(this.gameProfile.getId()));
|
||||
cir.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "getSkinType", at = @At("HEAD"), cancellable = true)
|
||||
public void customSkinType(CallbackInfoReturnable<String> cir) {
|
||||
if(Client.getInstance().getModInstances().getModByClass(AnimationsMod.class).isEnabled() && Client.getInstance().getSettingsManager().getSettingByClass(AnimationsMod.class, "1.7 Skins").getValBoolean()) {
|
||||
cir.setReturnValue("default");
|
||||
cir.cancel();
|
||||
return;
|
||||
}
|
||||
if(Client.getInstance().getModInstances().getNickHiderMod().isEnabled() && Client.getInstance().getSettingsManager().getSettingByClass(NickHiderMod.class, "Hide Skins").getValBoolean() && !Client.getInstance().getSettingsManager().getSettingByClass(NickHiderMod.class, "Use Real Skin For Self").getValBoolean()) {
|
||||
if(Client.getInstance().getSettingsManager().getSettingByClass(NickHiderMod.class, "Use Own Skin For All").getValBoolean()) {
|
||||
if(((AbstractClientPlayerExt) Minecraft.getMinecraft().thePlayer).silent$getPlayerInfo() != null) {
|
||||
cir.setReturnValue(((NetworkPlayerInfoExt) ((AbstractClientPlayerExt) Minecraft.getMinecraft().thePlayer).silent$getPlayerInfo()).silent$getSkinType() == null ? DefaultPlayerSkin.getSkinType(this.gameProfile.getId()) : ((NetworkPlayerInfoExt) ((AbstractClientPlayerExt) Minecraft.getMinecraft().thePlayer).silent$getPlayerInfo()).silent$getSkinType());
|
||||
cir.cancel();
|
||||
return;
|
||||
} else {
|
||||
cir.setReturnValue(DefaultPlayerSkin.getSkinType(Minecraft.getMinecraft().thePlayer.getGameProfile().getId()));
|
||||
cir.cancel();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(this.gameProfile.getId().equals(Minecraft.getMinecraft().thePlayer.getGameProfile().getId()) && Client.getInstance().getSettingsManager().getSettingByClass(NickHiderMod.class, "Use Real Skin For Self").getValBoolean()) {
|
||||
cir.setReturnValue(this.skinType == null ? DefaultPlayerSkin.getSkinType(this.gameProfile.getId()) : this.skinType);
|
||||
cir.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
cir.setReturnValue(DefaultPlayerSkin.getSkinType(this.gameProfile.getId()));
|
||||
cir.cancel();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String silent$getSkinType() {
|
||||
return skinType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object silent$getLocationSkin() {
|
||||
return locationSkin;
|
||||
}
|
||||
}
|
||||
|
@ -113,6 +113,7 @@
|
||||
"mixins.GuiDisconnectedMixin",
|
||||
"accessors.optifine.CustomColorsAccessor",
|
||||
"accessors.optifine.ConfigAccessor",
|
||||
"mixins.NetworkPlayerInfoMixin"
|
||||
"mixins.NetworkPlayerInfoMixin",
|
||||
"accessors.NetworkPlayerInfoAccessor"
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user