Removed capes (They will be replaced in future with something else)

This commit is contained in:
Adubbz 2014-06-27 23:12:06 +10:00
parent 4fdbb24b3a
commit bc96f46538
3 changed files with 0 additions and 323 deletions

View file

@ -8,8 +8,6 @@ import biomesoplenty.common.eventhandler.gui.MainMenuEventHandler;
import biomesoplenty.common.eventhandler.gui.StartupWarningEventHandler;
import biomesoplenty.common.eventhandler.misc.BonemealEventHandler;
import biomesoplenty.common.eventhandler.misc.BucketEventHandler;
import biomesoplenty.common.eventhandler.misc.CapeEventHandler;
import biomesoplenty.common.eventhandler.misc.CapeEventHandlerOld;
import biomesoplenty.common.eventhandler.network.ConnectionEventHandler;
import biomesoplenty.common.eventhandler.potions.PotionParalysisEventHandler;
import biomesoplenty.common.eventhandler.potions.PotionPossessionEventHandler;
@ -67,7 +65,5 @@ public class BOPEventHandlers
{
MinecraftForge.EVENT_BUS.register(new BonemealEventHandler());
MinecraftForge.EVENT_BUS.register(new BucketEventHandler());
if (MinecraftForge.MC_VERSION == "1.7.10") MinecraftForge.EVENT_BUS.register(new CapeEventHandler());
else MinecraftForge.EVENT_BUS.register(new CapeEventHandlerOld());
}
}

View file

@ -1,134 +0,0 @@
package biomesoplenty.common.eventhandler.misc;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.UUID;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.AbstractClientPlayer;
import net.minecraftforge.client.event.RenderPlayerEvent;
import org.apache.logging.log4j.Level;
import biomesoplenty.common.utils.BOPLogger;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.relauncher.ReflectionHelper;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class CapeEventHandler
{
private final String serverLocation = "https://raw.githubusercontent.com/Glitchfiend/BiomesOPlenty/master/capes.txt";
private final int timeout = 1000;
private HashMap<String, String> cloaks = new HashMap<String, String>();
private ArrayList<AbstractClientPlayer> checkedPlayers = new ArrayList<AbstractClientPlayer>();
public static CapeEventHandler instance;
public CapeEventHandler()
{
buildCloakURLDatabase();
instance = this;
}
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onPreRenderSpecials(RenderPlayerEvent.Specials.Pre event)
{
if (Loader.isModLoaded("shadersmod"))
{
return;
}
if (event.entityPlayer instanceof AbstractClientPlayer)
{
AbstractClientPlayer abstractClientPlayer = (AbstractClientPlayer) event.entityPlayer;
if (!checkedPlayers.contains(abstractClientPlayer))
{
checkedPlayers.add(abstractClientPlayer);
try
{
Class SkinManager = Class.forName("net.minecraft.client.resources.SkinManager");
Class SkinAvailableCallback = Class.forName("net.minecraft.client.resources.SkinManager$SkinAvailableCallback");
Class UUIDTypeAdapter = Class.forName("com.mojang.util.UUIDTypeAdapter");
// getSkinManager()?
Object skinManager = ReflectionHelper.findMethod(Minecraft.class, Minecraft.getMinecraft(), new String[] { "func_152342_ad" }).invoke(Minecraft.getMinecraft());
String uuid = (String)ReflectionHelper.findMethod(UUIDTypeAdapter, null, new String[] { "fromUUID" }, UUID.class).invoke(null, abstractClientPlayer.getUniqueID());
if (cloaks.containsKey(uuid))
{
Class MinecraftProfileTexture = Class.forName("com.mojang.authlib.minecraft.MinecraftProfileTexture");
Class Type = Class.forName("com.mojang.authlib.minecraft.MinecraftProfileTexture$Type");
Object profileTexture = MinecraftProfileTexture.getConstructor(String.class).newInstance(cloaks.get(uuid));
ReflectionHelper.findMethod(SkinManager, skinManager, new String[] { "func_152789_a" }, MinecraftProfileTexture, Type, SkinAvailableCallback).invoke(skinManager, profileTexture, Type.getField("CAPE").get(null), abstractClientPlayer);
event.renderCape = true;
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
}
public void buildCloakURLDatabase()
{
URL url;
try
{
url = new URL(serverLocation);
URLConnection con = url.openConnection();
con.setConnectTimeout(timeout);
con.setReadTimeout(timeout);
InputStream io = con.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(io));
String str;
int linetracker = 1;
while ((str = br.readLine()) != null)
{
if ((!str.startsWith("--") || str.contains("--*--")) && !str.isEmpty())
{
str = str.replace("--*--", "");
if (str.contains(":"))
{
String uuid = str.substring(0, str.indexOf(":"));
String link = str.substring(str.indexOf(":") + 1);
cloaks.put(uuid, link);
}
else
{
BOPLogger.log(Level.WARN, "[capes.txt] Syntax error on line " + linetracker + ": " + str);
}
}
linetracker++;
}
br.close();
}
catch (MalformedURLException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}

View file

@ -1,185 +0,0 @@
package biomesoplenty.common.eventhandler.misc;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.HashMap;
import javax.swing.ImageIcon;
import biomesoplenty.api.BOPObfuscationHelper;
import net.minecraft.client.entity.AbstractClientPlayer;
import net.minecraft.client.renderer.ThreadDownloadImageData;
import net.minecraftforge.client.event.RenderPlayerEvent;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.relauncher.ReflectionHelper;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@Deprecated
/**This class is not to be altered in any way, shape or form unless it contains a severe bug. The only reason it remains is for 1.7.2 compatibility.**/
public class CapeEventHandlerOld
{
private final String serverLocation = "https://raw.githubusercontent.com/Glitchfiend/BiomesOPlenty/master/capes.txt";
private final int timeout = 1000;
private static final Graphics TEST_GRAPHICS = new BufferedImage(128, 128,
BufferedImage.TYPE_INT_RGB).getGraphics();
private HashMap<String, String> cloaks = new HashMap<String, String>();
private ArrayList<AbstractClientPlayer> capePlayers = new ArrayList<AbstractClientPlayer>();
public static CapeEventHandlerOld instance;
public CapeEventHandlerOld()
{
buildCloakURLDatabase();
instance = this;
}
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onPreRenderSpecials(RenderPlayerEvent.Specials.Pre event)
{
if (Loader.isModLoaded("shadersmod"))
{
return;
}
if (event.entityPlayer instanceof AbstractClientPlayer)
{
AbstractClientPlayer abstractClientPlayer = (AbstractClientPlayer) event.entityPlayer;
if (!capePlayers.contains(abstractClientPlayer))
{
String cloakURL = cloaks.get(event.entityPlayer.getDisplayName());
if (cloakURL == null)
{
return;
}
capePlayers.add(abstractClientPlayer);
ReflectionHelper.setPrivateValue(ThreadDownloadImageData.class, abstractClientPlayer.getTextureCape(), false, new String[]{"textureUploaded", "field_110559_g"});
new Thread(new CloakThread(abstractClientPlayer, cloakURL)).start();
event.renderCape = true;
}
}
}
public void buildCloakURLDatabase()
{
URL url;
try
{
url = new URL(serverLocation);
URLConnection con = url.openConnection();
con.setConnectTimeout(timeout);
con.setReadTimeout(timeout);
InputStream io = con.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(io));
String str;
int linetracker = 1;
while ((str = br.readLine()) != null)
{
if (!str.startsWith("--") && !str.isEmpty())
{
if (str.contains(":"))
{
String nick = str.substring(0, str.indexOf(":"));
String link = str.substring(str.indexOf(":") + 1);
new Thread(new CloakPreload(link)).start();
cloaks.put(nick, link);
}
else
{
System.err.println("[BiomesOPlenty] [capes.txt] Syntax error on line " + linetracker + ": " + str);
}
}
linetracker++;
}
br.close();
}
catch (MalformedURLException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
}
private class CloakThread implements Runnable
{
AbstractClientPlayer abstractClientPlayer;
String cloakURL;
public CloakThread(AbstractClientPlayer player, String cloak)
{
abstractClientPlayer = player;
cloakURL = cloak;
}
@Override
public void run()
{
try
{
Image cape = new ImageIcon(new URL(cloakURL)).getImage();
BufferedImage bo = new BufferedImage(cape.getWidth(null),
cape.getHeight(null), BufferedImage.TYPE_INT_ARGB);
bo.getGraphics().drawImage(cape, 0, 0, null);
ReflectionHelper.setPrivateValue(ThreadDownloadImageData.class, abstractClientPlayer.getTextureCape(), bo, new String[]{"bufferedImage", "field_110560_d"});
}
catch (MalformedURLException e)
{
e.printStackTrace();
}
}
}
private class CloakPreload implements Runnable
{
String cloakURL;
public CloakPreload(String link)
{
cloakURL = link;
}
@Override
public void run()
{
try
{
TEST_GRAPHICS
.drawImage(new ImageIcon(new URL(cloakURL)).getImage(),
0, 0, null);
}
catch (MalformedURLException e)
{
e.printStackTrace();
}
}
}
public void refreshCapes()
{
cloaks.clear();
capePlayers.clear();
buildCloakURLDatabase();
}
}