|
| 1 | +package galena.galenacapes.mixin; |
| 2 | + |
| 3 | +import galena.galenacapes.Constants; |
| 4 | +import net.minecraft.client.Minecraft; |
| 5 | +import net.minecraft.client.multiplayer.PlayerInfo; |
| 6 | +import net.minecraft.client.player.AbstractClientPlayer; |
| 7 | +import net.minecraft.resources.ResourceLocation; |
| 8 | +import org.spongepowered.asm.mixin.Mixin; |
| 9 | +import org.spongepowered.asm.mixin.Shadow; |
| 10 | +import org.spongepowered.asm.mixin.injection.At; |
| 11 | +import org.spongepowered.asm.mixin.injection.Inject; |
| 12 | +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; |
| 13 | + |
| 14 | +import javax.annotation.Nullable; |
| 15 | +import java.util.Objects; |
| 16 | + |
| 17 | +@Mixin(AbstractClientPlayer.class) |
| 18 | +public abstract class AbstractClientPlayerMixin { |
| 19 | + |
| 20 | + /* |
| 21 | + @author: Xaidee |
| 22 | +
|
| 23 | + For the most recent version of this file please refer to https://github.com/Xaidee/Galena-Capes/blob/1.18/Common/src/main/java/galena/galenacapes/mixin/AbstractClientPlayerMixin.java |
| 24 | + */ |
| 25 | + |
| 26 | + @Shadow @Nullable |
| 27 | + protected abstract PlayerInfo getPlayerInfo(); |
| 28 | + |
| 29 | + @Inject(method= "getCloakTextureLocation()Lnet/minecraft/resources/ResourceLocation;", at=@At("RETURN"), cancellable = true) |
| 30 | + |
| 31 | + public void getCloakTextureLocation(CallbackInfoReturnable<ResourceLocation> cir) { |
| 32 | + assert Minecraft.getInstance().player != null; |
| 33 | + if(!(Objects.requireNonNull(this.getPlayerInfo()).getProfile().getId().equals(Minecraft.getInstance().player.getUUID()))) { |
| 34 | + cir.setReturnValue(null); |
| 35 | + } else { |
| 36 | + String username = this.getPlayerInfo().getProfile().getName(); |
| 37 | + |
| 38 | + for (int i = 0; Constants.Dev.size() > i; i++) { |
| 39 | + if (Constants.Dev.get(i).equals(username)) cir.setReturnValue(new ResourceLocation(Constants.MOD_ID, "textures/capes/dev.png")); |
| 40 | + } |
| 41 | + for (int i = 0; Constants.OPatreons.size() > i; i++) { |
| 42 | + if (Constants.OPatreons.get(i).equals(username)) cir.setReturnValue(new ResourceLocation(Constants.MOD_ID, "textures/capes/oreganized.png")); |
| 43 | + } |
| 44 | + for (int i = 0; Constants.OFPatreons.size() > i; i++) { |
| 45 | + if (Constants.OFPatreons.get(i).equals(username)) cir.setReturnValue(new ResourceLocation(Constants.MOD_ID, "textures/capes/overweightfarming.png")); |
| 46 | + } |
| 47 | + for (int i = 0; Constants.GPatreonsBlue.size() > i; i++) { |
| 48 | + if (Constants.GPatreonsBlue.get(i).equals(username)) cir.setReturnValue(new ResourceLocation(Constants.MOD_ID, "textures/capes/galosphere_blue.png")); |
| 49 | + } |
| 50 | + for (int i = 0; Constants.GPatreonsYellow.size() > i; i++) { |
| 51 | + if (Constants.GPatreonsYellow.get(i).equals(username)) cir.setReturnValue(new ResourceLocation(Constants.MOD_ID, "textures/capes/galosphere_yellow.png")); |
| 52 | + } |
| 53 | + for (int i = 0; Constants.CPatreons.size() > i; i++) { |
| 54 | + if (Constants.CPatreons.get(i).equals(username)) cir.setReturnValue(new ResourceLocation(Constants.MOD_ID, "textures/capes/coopperative.png")); |
| 55 | + } |
| 56 | + } |
| 57 | + } |
| 58 | +} |
0 commit comments