/**
 * DeveloperCapes by Jadar
 * License: MIT License
 * (https://raw.github.com/jadar/DeveloperCapes/master/LICENSE)
 * version 4.0.0.x
 */
package com.jadarstudios.developercapes.cape;

import com.jadarstudios.developercapes.HDImageBuffer;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.AbstractClientPlayer;
import net.minecraft.client.renderer.ThreadDownloadImageData;
import net.minecraft.util.ResourceLocation;

import java.net.URL;

/**
 * Default Cape implementation
 * 
 * @author jadar
 */
public class StaticCape extends AbstractCape {

    public StaticCape(String name, URL url) {
        this.setName(name);
        this.setURL(url);
    }

    public StaticCape(String name) {
        this(name, null);
    }

    @Override
    public void loadTexture(AbstractClientPlayer player) {
        ResourceLocation location = this.getLocation();
        player.func_152121_a(MinecraftProfileTexture.Type.CAPE, location);

        Minecraft.getMinecraft().renderEngine.loadTexture(location, this.getTexture());
    }

    @Override
    public boolean isTextureLoaded(AbstractClientPlayer player) {
        ResourceLocation cape = player.getLocationCape();
        return cape != null;
    }

    public void setURL(URL url) {
        if (url == null) {
            this.texture = null;
            return;
        }
        this.texture = new ThreadDownloadImageData(null, url.toString(), null, new HDImageBuffer());
    }

    public void setName(String name) {
        this.name = name;
        this.location = new ResourceLocation("DevCapes/" + name);
    }
}
@@ -1,308 +1,124 @@
-/**%0A * DeveloperCapes by Jadar%0A * License: MIT License%0A * (https://raw.github.com/jadar/DeveloperCapes/master/LICENSE)%0A * version 4.0.0.x%0A */%0Apackage com.jadarstudios.developercapes.cape;%0A%0Aimport com.jadarstudios.developercapes.HDImageBuffer
+ import net.minecraft.client.network.NetworkPlayerInfo
 ;%0A
+ 
 import 
-com.mojang.authlib.minecraft.MinecraftProfileTexture
+net.minecraft.client.renderer.ThreadDownloadImageData
 ;%0A
+ 
 impo
@@ -138,24 +138,29 @@
 aft.
-client.Minecraft
+util.ResourceLocation
 ;%0Aim
@@ -181,152 +181,149 @@
 raft
-.client.entity.AbstractClientPlayer;%0Aimport net.minecraft.client.renderer.ThreadDownloadImageData;%0Aimport net.minecraft.util.ResourceLocation;%0A%0A
+forge.fml.common.ObfuscationReflectionHelper;%0Aimport net.minecraftforge.fml.relauncher.ReflectionHelper;%0A %0A import java.lang.reflect.Field;%0A 
 impo
@@ -343,13 +343,16 @@
 RL;%0A
-%0A
+ %0A 
 /**%0A
+ 
  * D
@@ -382,12 +382,18 @@
 ion%0A
+-
  * %0A
++ *%0A 
  * @
@@ -409,12 +409,14 @@
 dar%0A
+ 
  */%0A
+ 
 publ
@@ -462,63 +462,94 @@
 e %7B%0A
-%0A    public StaticCape(String name, URL url
+ @@ -41,16 +43,17 @@ public void loadTexture(AbstractClientPlayer player
 ) %7B%0A
+ %0A
         
 this
@@ -548,510 +548,447 @@
     
-this.setName(name);%0A        this.setURL(url);%0A    %7D%0A%0A    public Static
+ //mmdanggg2: using reflection to modify the private location
 Cape
-(String name) %7B%0A        this(name, null);
+, hacky but it works.%0A         try %7B
 %0A    
-%7D%0A%0A
     
-@Override%0A    public void loadTexture(AbstractClientPlayer player) %7B%0A        ResourceLocation location = this.getLocation();%0A        player.func_152121_a(MinecraftProfileTexture.Type.CAPE, location);%0A%0A        Minecraft.getMinecraft().renderEngine.loadTexture(location, this.getTexture()
+    Field playerInfoF = AbstractClientPlayer.class.getDeclaredField(%22playerInfo%22);%0A        %09Field playerInfoF = ReflectionHelper.findField(AbstractClientPlayer.class, %22playerInfo%22, %22field_175157_a%22);%0A             playerInfoF.setAccessible(true
 );%0A    
-%7D%0A%0A
     
-@Override%0A    public boolean isTextureLoaded(AbstractClientPlayer 
+     NetworkPlayerInfo nci = (NetworkPlayerInfo) playerInfoF.get(
 player)
+;%0A
  
-%7B
 %0A   
@@ -996,43 +996,76 @@
     
-ResourceL
+   Field l
 ocation
- c
+C
 ape
+F
  = 
-player.getL
+NetworkPlayerInfo.class.getDeclaredField(%22l
 ocat
@@ -1071,17 +1071,17 @@
 tionCape
-(
+%22
 );%0A     
@@ -1087,148 +1087,262 @@
     
-return cape != null;%0A    %7D%0A%0A    public void setURL(URL url) %7B%0A        if (url == null) %7B%0A            this.texture = null;%0A            return
+   Field locationCapeF = ReflectionHelper.findField(NetworkPlayerInfo.class, %22locationCape%22, %22field_178862_f%22);%0A             locationCapeF.setAccessible(true);%0A             locationCapeF.set(nci, location);%0A %0A             playerInfoF.setAccessible(false)
 ;%0A  
@@ -1351,252 +1351,204 @@
     
-%7D%0A
      
-   this.texture = new ThreadDownloadImageData(null, url.toString(), null, new HDImageBuffer()
+locationCapeF.setAccessible(false
 );%0A
+%0A
     
-%7D%0A%0A
     
-public void setName(String name) %7B%0A        this.name = name;%0A        this.location = new ResourceLocation(%22DevCapes/%22 + name);%0A    %7D%0A%7D
+ %7D catch (Exception e) %7B%0A             e.printStackTrace();%0A             DevCapes.getInstance().logger.error(%22Setting cape ResourceLocation failed!%22);%0A

Update StaticCape.java