Fixed capes
This commit is contained in:
parent
50f7df5f98
commit
086dd83a57
3 changed files with 44 additions and 24 deletions
|
@ -1,13 +1,16 @@
|
||||||
package mekanism.client;
|
package mekanism.client;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
import mekanism.common.ObfuscatedNames;
|
import mekanism.common.ObfuscatedNames;
|
||||||
import mekanism.common.util.MekanismUtils;
|
import mekanism.common.util.MekanismUtils;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||||
import net.minecraft.client.renderer.IImageBuffer;
|
import net.minecraft.client.renderer.IImageBuffer;
|
||||||
import net.minecraft.client.renderer.ThreadDownloadImageData;
|
import net.minecraft.client.renderer.ThreadDownloadImageData;
|
||||||
|
import net.minecraft.client.renderer.texture.ITextureObject;
|
||||||
|
import net.minecraft.client.renderer.texture.TextureManager;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.StringUtils;
|
import net.minecraft.util.StringUtils;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
@ -40,7 +43,9 @@ public class CapeBufferDownload extends Thread
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
download();
|
download();
|
||||||
} catch(Exception e) {}
|
} catch(Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void download()
|
private void download()
|
||||||
|
@ -48,14 +53,10 @@ public class CapeBufferDownload extends Thread
|
||||||
try {
|
try {
|
||||||
resourceLocation = new ResourceLocation("mekanism/" + StringUtils.stripControlCodes(username));
|
resourceLocation = new ResourceLocation("mekanism/" + StringUtils.stripControlCodes(username));
|
||||||
|
|
||||||
Method method = MekanismUtils.getPrivateMethod(AbstractClientPlayer.class, ObfuscatedNames.AbstractClientPlayer_getDownloadImage, ResourceLocation.class, String.class, ResourceLocation.class, IImageBuffer.class);
|
capeImage = downloadCape();
|
||||||
Object obj = method.invoke(null, resourceLocation, staticCapeUrl, null, null);
|
} catch(Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
if(obj instanceof ThreadDownloadImageData)
|
}
|
||||||
{
|
|
||||||
capeImage = (ThreadDownloadImageData)obj;
|
|
||||||
}
|
|
||||||
} catch(Exception e) {}
|
|
||||||
|
|
||||||
downloaded = true;
|
downloaded = true;
|
||||||
}
|
}
|
||||||
|
@ -69,4 +70,27 @@ public class CapeBufferDownload extends Thread
|
||||||
{
|
{
|
||||||
return resourceLocation;
|
return resourceLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ThreadDownloadImageData downloadCape()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
File capeFile = new File(resourceLocation.getResourcePath() + ".png");
|
||||||
|
|
||||||
|
if(capeFile.exists())
|
||||||
|
{
|
||||||
|
capeFile.delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
TextureManager manager = Minecraft.getMinecraft().getTextureManager();
|
||||||
|
ThreadDownloadImageData data = new ThreadDownloadImageData(capeFile, staticCapeUrl, null, null);
|
||||||
|
|
||||||
|
manager.loadTexture(resourceLocation, data);
|
||||||
|
|
||||||
|
return data;
|
||||||
|
} catch(Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
package mekanism.client;
|
package mekanism.client;
|
||||||
|
|
||||||
|
import static mekanism.client.sound.SoundHandler.Channel.FLAMETHROWER;
|
||||||
|
import static mekanism.client.sound.SoundHandler.Channel.GASMASK;
|
||||||
|
import static mekanism.client.sound.SoundHandler.Channel.JETPACK;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
@ -26,12 +30,14 @@ import mekanism.common.network.PacketJetpackData.JetpackPacket;
|
||||||
import mekanism.common.network.PacketScubaTankData.ScubaTankDataMessage;
|
import mekanism.common.network.PacketScubaTankData.ScubaTankDataMessage;
|
||||||
import mekanism.common.network.PacketScubaTankData.ScubaTankPacket;
|
import mekanism.common.network.PacketScubaTankData.ScubaTankPacket;
|
||||||
import mekanism.common.util.MekanismUtils;
|
import mekanism.common.util.MekanismUtils;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.StringUtils;
|
import net.minecraft.util.StringUtils;
|
||||||
|
|
||||||
|
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||||
|
|
||||||
import cpw.mods.fml.client.FMLClientHandler;
|
import cpw.mods.fml.client.FMLClientHandler;
|
||||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||||
import cpw.mods.fml.common.gameevent.TickEvent.ClientTickEvent;
|
import cpw.mods.fml.common.gameevent.TickEvent.ClientTickEvent;
|
||||||
|
@ -39,10 +45,6 @@ import cpw.mods.fml.common.gameevent.TickEvent.Phase;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
import static mekanism.client.sound.SoundHandler.Channel.FLAMETHROWER;
|
|
||||||
import static mekanism.client.sound.SoundHandler.Channel.GASMASK;
|
|
||||||
import static mekanism.client.sound.SoundHandler.Channel.JETPACK;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Client-side tick handler for Mekanism. Used mainly for the update check upon startup.
|
* Client-side tick handler for Mekanism. Used mainly for the update check upon startup.
|
||||||
* @author AidanBrady
|
* @author AidanBrady
|
||||||
|
@ -150,8 +152,7 @@ public class ClientTickHandler
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
MekanismUtils.setPrivateValue(player, download.getImage(), AbstractClientPlayer.class, ObfuscatedNames.AbstractClientPlayer_downloadImageCape);
|
player.func_152121_a(MinecraftProfileTexture.Type.CAPE, download.getResourceLocation());
|
||||||
MekanismUtils.setPrivateValue(player, download.getResourceLocation(), AbstractClientPlayer.class, ObfuscatedNames.AbstractClientPlayer_locationCape);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(StringUtils.stripControlCodes(player.getCommandSenderName()).equals("aidancbrady"))
|
else if(StringUtils.stripControlCodes(player.getCommandSenderName()).equals("aidancbrady"))
|
||||||
|
@ -171,8 +172,7 @@ public class ClientTickHandler
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
MekanismUtils.setPrivateValue(player, download.getImage(), AbstractClientPlayer.class, ObfuscatedNames.AbstractClientPlayer_downloadImageCape);
|
player.func_152121_a(MinecraftProfileTexture.Type.CAPE, download.getResourceLocation());
|
||||||
MekanismUtils.setPrivateValue(player, download.getResourceLocation(), AbstractClientPlayer.class, ObfuscatedNames.AbstractClientPlayer_locationCape);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(Mekanism.donators.contains(StringUtils.stripControlCodes(player.getCommandSenderName())))
|
else if(Mekanism.donators.contains(StringUtils.stripControlCodes(player.getCommandSenderName())))
|
||||||
|
@ -192,8 +192,7 @@ public class ClientTickHandler
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
MekanismUtils.setPrivateValue(player, download.getImage(), AbstractClientPlayer.class, ObfuscatedNames.AbstractClientPlayer_downloadImageCape);
|
player.func_152121_a(MinecraftProfileTexture.Type.CAPE, download.getResourceLocation());
|
||||||
MekanismUtils.setPrivateValue(player, download.getResourceLocation(), AbstractClientPlayer.class, ObfuscatedNames.AbstractClientPlayer_locationCape);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,6 @@ public final class ObfuscatedNames
|
||||||
{
|
{
|
||||||
public static String[] TextureManager_listTickables = new String[] {"listTickables", "field_110583_b", "c"};
|
public static String[] TextureManager_listTickables = new String[] {"listTickables", "field_110583_b", "c"};
|
||||||
public static String[] Minecraft_timer = new String[] {"timer", "field_71428_T", "S"};
|
public static String[] Minecraft_timer = new String[] {"timer", "field_71428_T", "S"};
|
||||||
public static String[] AbstractClientPlayer_downloadImageCape = new String[] {"downloadImageCape", "field_110315_c", "c"};
|
|
||||||
public static String[] AbstractClientPlayer_locationCape = new String[] {"locationCape", "field_110313_e", "e"};
|
|
||||||
public static String[] AbstractClientPlayer_getDownloadImage = new String[] {"getDownloadImage", "func_110301_a", "a"};
|
|
||||||
public static String[] GuiContainer_xSize = new String[] {"xSize", "field_146999_f", "c"};
|
public static String[] GuiContainer_xSize = new String[] {"xSize", "field_146999_f", "c"};
|
||||||
public static String[] GuiContainer_ySize = new String[] {"ySize", "field_147000_g", "d"};
|
public static String[] GuiContainer_ySize = new String[] {"ySize", "field_147000_g", "d"};
|
||||||
public static String[] GuiContainer_guiLeft = new String[] {"guiLeft", "field_147003_i"};
|
public static String[] GuiContainer_guiLeft = new String[] {"guiLeft", "field_147003_i"};
|
||||||
|
|
Loading…
Reference in a new issue