| 1 | package thunder.hack.injection;
|
| 2 |
|
| 3 | import com.mojang.authlib.GameProfile;
|
| 4 | import org.spongepowered.asm.mixin.Mixin;
|
| 5 | import org.spongepowered.asm.mixin.Unique;
|
| 6 | import org.spongepowered.asm.mixin.injection.At;
|
| 7 | import org.spongepowered.asm.mixin.injection.Inject;
|
| 8 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
| 9 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
| 10 | import thunder.hack.core.manager.client.ModuleManager;
|
| 11 | import thunder.hack.utility.CapeHandler;
|
| 12 | import thunder.hack.utility.ThunderUtility;
|
| 13 |
|
| 14 | import java.io.BufferedReader;
|
| 15 | import java.io.InputStreamReader;
|
| 16 | import java.net.URI;
|
| 17 | import java.net.URL;
|
| 18 | import java.util.Objects;
|
| 19 | import net.minecraft.client.multiplayer.PlayerInfo;
|
| 20 | import net.minecraft.core.ClientAsset;
|
| 21 | import net.minecraft.resources.Identifier;
|
| 22 | import net.minecraft.util.Util;
|
| 23 | import net.minecraft.world.entity.player.PlayerSkin;
|
| 24 |
|
| 25 | @Mixin(PlayerInfo.class)
|
| 26 | public class MixinPlayerListEntry {
|
| 27 |
|
| 28 | @Unique
|
| 29 | private boolean loadedCapeTexture;
|
| 30 |
|
| 31 | @Unique
|
| 32 | private Identifier customCapeTexture;
|
| 33 |
|
| 34 | @Inject(method = "<init>(Lcom/mojang/authlib/GameProfile;Z)V", at = @At("TAIL"))
|
| 35 | private void initHook(GameProfile profile, boolean secureChatEnforced, CallbackInfo ci) {
|
| 36 | getTexture(profile);
|
| 37 | }
|
| 38 |
|
| 39 | @Inject(method = "getSkin", at = @At("TAIL"), cancellable = true)
|
| 40 | private void getCapeTexture(CallbackInfoReturnable<PlayerSkin> cir) {
|
| 41 | if (customCapeTexture != null) {
|
| 42 | PlayerSkin prev = cir.getReturnValue();
|
| 43 | ClientAsset.Texture cape = new ClientAsset.ResourceTexture(customCapeTexture);
|
| 44 | PlayerSkin newTextures = new PlayerSkin(prev.body(), cape, cape, prev.model(), prev.secure());
|
| 45 | cir.setReturnValue(newTextures);
|
| 46 | }
|
| 47 | }
|
| 48 |
|
| 49 | @Unique
|
| 50 | private void getTexture(GameProfile profile) {
|
| 51 | if (loadedCapeTexture) return;
|
| 52 | loadedCapeTexture = true;
|
| 53 | Util.backgroundExecutor().execute(() -> {
|
| 54 |
|
| 55 | if (ModuleManager.capes.isEnabled())
|
| 56 | CapeHandler.loadPlayerCape(profile, id -> {
|
| 57 | customCapeTexture = id;
|
| 58 | });
|
| 59 |
|
| 60 | if (!ModuleManager.capes.thCapes.getValue()) return;
|
| 61 |
|
| 62 | for (String str : ThunderUtility.starGazer) {
|
| 63 | if (profile.name().toLowerCase().equals(str.toLowerCase()))
|
| 64 | customCapeTexture = Identifier.fromNamespaceAndPath("thunderhack", "textures/capes/starcape.png");
|
| 65 | }
|
| 66 |
|
| 67 | try {
|
| 68 | URL capesList = URI.create("https://raw.githubusercontent.com/ulybaka1337/THRecodeImprovedUtil/main/capes/capeBase.txt").toURL();
|
| 69 | BufferedReader in = new BufferedReader(new InputStreamReader(capesList.openStream()));
|
| 70 | String inputLine;
|
| 71 | while ((inputLine = in.readLine()) != null) {
|
| 72 | String colune = inputLine.trim();
|
| 73 | String name = colune.split(":")[0];
|
| 74 | String cape = colune.split(":")[1];
|
| 75 | if (Objects.equals(profile.name(), name)) {
|
| 76 | customCapeTexture = Identifier.fromNamespaceAndPath("thunderhack", "textures/capes/" + cape + ".png");
|
| 77 | return;
|
| 78 | }
|
| 79 | }
|
| 80 | } catch (Exception ignored) {
|
| 81 | }
|
| 82 | });
|
| 83 | }
|
| 84 | }
|
| 85 |
|