custom skins for all!

This commit is contained in:
kirillsaint 2023-07-04 18:45:54 +06:00
parent d65ef3ab24
commit 133c46c01c
2 changed files with 15 additions and 11 deletions

View File

@ -20,6 +20,7 @@ import net.silentclient.client.mixin.ducks.AbstractClientPlayerExt;
import net.silentclient.client.mods.player.NickHiderMod; import net.silentclient.client.mods.player.NickHiderMod;
import net.silentclient.client.mods.render.AnimationsMod; import net.silentclient.client.mods.render.AnimationsMod;
import net.silentclient.client.mods.settings.CosmeticsMod; import net.silentclient.client.mods.settings.CosmeticsMod;
import net.silentclient.client.utils.CustomSkin;
import net.silentclient.client.utils.Players; import net.silentclient.client.utils.Players;
import net.silentclient.client.utils.SCTextureManager; import net.silentclient.client.utils.SCTextureManager;
import net.silentclient.client.utils.types.PlayerResponse; import net.silentclient.client.utils.types.PlayerResponse;
@ -55,6 +56,7 @@ public abstract class AbstractClientPlayerMixin implements AbstractClientPlayerE
@Unique private PlayerResponse.Account silent$account; @Unique private PlayerResponse.Account silent$account;
@Unique private String silent$capeType = "dynamic_curved"; @Unique private String silent$capeType = "dynamic_curved";
@Unique private boolean silent$shouldersBool = true; @Unique private boolean silent$shouldersBool = true;
@Unique private CustomSkin silent$customSkin = new CustomSkin();
@Inject(method = "<init>", at = @At("RETURN")) @Inject(method = "<init>", at = @At("RETURN"))
public void initCustom(World worldIn, GameProfile playerProfile, CallbackInfo ci) { public void initCustom(World worldIn, GameProfile playerProfile, CallbackInfo ci) {
@ -92,8 +94,8 @@ public abstract class AbstractClientPlayerMixin implements AbstractClientPlayerE
return; return;
} }
if(silent$getNameClear().toLowerCase().equals(Client.getInstance().getAccount().getUsername().toLowerCase()) && Client.getInstance().getAccount().getCustomSkin()) { if(Client.getInstance().getSettingsManager().getSettingByClass(CosmeticsMod.class, "Custom Skins").getValBoolean() && this.silent$getAccount() != null && this.silent$getAccount().getCustomSkin()) {
cir.setReturnValue(Client.getInstance().getAccount().getSkinType()); cir.setReturnValue(this.silent$getAccount().getSkinType());
cir.cancel(); cir.cancel();
} }
} }
@ -106,22 +108,22 @@ public abstract class AbstractClientPlayerMixin implements AbstractClientPlayerE
return; return;
} }
if(silent$getNameClear().toLowerCase().equals(Client.getInstance().getAccount().getUsername().toLowerCase()) && Client.getInstance().getAccount().getCustomSkin()) { if(Client.getInstance().getSettingsManager().getSettingByClass(CosmeticsMod.class, "Custom Skins").getValBoolean() && this.silent$getAccount() != null && this.silent$getAccount().getCustomSkin()) {
if(Client.getInstance().getCustomSkin().getLocation() == null && !Client.getInstance().getCustomSkin().isLoading()) { if(silent$customSkin.getLocation() == null && !silent$customSkin.isLoading()) {
Client.getInstance().getCustomSkin().setLoading(true); silent$customSkin.setLoading(true);
(new Thread("CustomSkinThread") { (new Thread("CustomSkinThread") {
public void run() { public void run() {
Client.logger.info("Downloading Custom Skin"); Client.logger.info("Downloading Custom Skin");
Client.getInstance().getCustomSkin().setImage(SCTextureManager.getImage("https://cdn.silentclient.net/skins/" + silent$nameClear.toLowerCase() + ".png")); silent$customSkin.setImage(SCTextureManager.getImage("https://cdn.silentclient.net/skins/" + silent$nameClear.toLowerCase() + ".png"));
} }
}).start(); }).start();
} }
if(Client.getInstance().getCustomSkin().getImage() != null && !Client.getInstance().getCustomSkin().isInitialized()) { if(silent$customSkin.getImage() != null && !silent$customSkin.isInitialized()) {
Client.getInstance().getCustomSkin().setLocation(Minecraft.getMinecraft().getTextureManager().getDynamicTextureLocation("custom_skin_" + new Random().nextLong(), new DynamicTexture(Client.getInstance().getCustomSkin().getImage()))); silent$customSkin.setLocation(Minecraft.getMinecraft().getTextureManager().getDynamicTextureLocation("custom_skin_" + new Random().nextLong(), new DynamicTexture(silent$customSkin.getImage())));
Client.getInstance().getCustomSkin().setInitialized(true); silent$customSkin.setInitialized(true);
} }
if(Client.getInstance().getCustomSkin().getLocation() != null) { if(silent$customSkin.getLocation() != null) {
cir.setReturnValue(Client.getInstance().getCustomSkin().getLocation()); cir.setReturnValue(silent$customSkin.getLocation());
cir.cancel(); cir.cancel();
} }
} }

View File

@ -35,6 +35,8 @@ public class CosmeticsMod extends Mod {
this.addBooleanSetting("Bandanas", this, true); this.addBooleanSetting("Bandanas", this, true);
this.addBooleanSetting("Hats", this, true); this.addBooleanSetting("Hats", this, true);
this.addBooleanSetting("Shields", this, true); this.addBooleanSetting("Shields", this, true);
this.addBooleanSetting("Custom Skins", this, true);
} }
@Override @Override