Take 2 at backwards compatibility. Cross your fingers.
This commit is contained in:
parent
0bcc061ce2
commit
4fdbb24b3a
5 changed files with 47 additions and 58 deletions
|
@ -1,3 +1,3 @@
|
|||
minecraft_version=1.7.10
|
||||
forge_version=10.13.0.1152
|
||||
minecraft_version=1.7.2
|
||||
forge_version=10.12.2.1147
|
||||
mod_version=2.0.2
|
||||
|
|
|
@ -32,8 +32,4 @@ public class BOPObfuscationHelper
|
|||
public static final String[] river = new String[] { "river", "field_76781_i" };
|
||||
public static final String[] roofedForest = new String[] { "roofedForest", "field_150585_R" };
|
||||
public static final String[] hell = new String[] { "hell", "field_76778_j" };
|
||||
|
||||
//AbstractClientPlayer
|
||||
@Deprecated
|
||||
public static final String[] getTextureCape = new String[] { "getTextureCape", "func_110310_o" };
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ 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;
|
||||
|
@ -66,6 +67,7 @@ public class BOPEventHandlers
|
|||
{
|
||||
MinecraftForge.EVENT_BUS.register(new BonemealEventHandler());
|
||||
MinecraftForge.EVENT_BUS.register(new BucketEventHandler());
|
||||
MinecraftForge.EVENT_BUS.register(new CapeEventHandler());
|
||||
if (MinecraftForge.MC_VERSION == "1.7.10") MinecraftForge.EVENT_BUS.register(new CapeEventHandler());
|
||||
else MinecraftForge.EVENT_BUS.register(new CapeEventHandlerOld());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,27 +9,24 @@ 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.minecraft.client.resources.SkinManager;
|
||||
import net.minecraftforge.client.event.RenderPlayerEvent;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
|
||||
import biomesoplenty.common.utils.BOPLogger;
|
||||
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||
import com.mojang.util.UUIDTypeAdapter;
|
||||
|
||||
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.github.com/Glitchfiend/BiomesOPlenty/master/capes.txt";
|
||||
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>();
|
||||
|
@ -59,18 +56,31 @@ public class CapeEventHandler
|
|||
{
|
||||
checkedPlayers.add(abstractClientPlayer);
|
||||
|
||||
// getSkinManager()?
|
||||
SkinManager skinManager = Minecraft.getMinecraft().func_152342_ad();
|
||||
|
||||
String uuid = UUIDTypeAdapter.fromUUID(abstractClientPlayer.getUniqueID());
|
||||
|
||||
if (cloaks.containsKey(uuid))
|
||||
try
|
||||
{
|
||||
MinecraftProfileTexture profileTexture = new MinecraftProfileTexture(cloaks.get(uuid));
|
||||
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");
|
||||
|
||||
skinManager.func_152789_a(profileTexture, MinecraftProfileTexture.Type.CAPE, abstractClientPlayer);
|
||||
|
||||
event.renderCape = true;
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -92,22 +102,19 @@ public class CapeEventHandler
|
|||
int linetracker = 1;
|
||||
while ((str = br.readLine()) != null)
|
||||
{
|
||||
if (!str.startsWith("--") && !str.isEmpty())
|
||||
if ((!str.startsWith("--") || str.contains("--*--")) && !str.isEmpty())
|
||||
{
|
||||
if (str.startsWith("*%"))
|
||||
str = str.replace("--*--", "");
|
||||
|
||||
if (str.contains(":"))
|
||||
{
|
||||
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);
|
||||
}
|
||||
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++;
|
||||
|
|
|
@ -29,7 +29,7 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
/**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.github.com/Glitchfiend/BiomesOPlenty/master/capes.txt";
|
||||
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,
|
||||
|
@ -68,15 +68,7 @@ public class CapeEventHandlerOld
|
|||
|
||||
capePlayers.add(abstractClientPlayer);
|
||||
|
||||
try
|
||||
{
|
||||
ThreadDownloadImageData threadDownloadImageData = (ThreadDownloadImageData)ReflectionHelper.findMethod(AbstractClientPlayer.class, abstractClientPlayer, BOPObfuscationHelper.getTextureCape).invoke(abstractClientPlayer);
|
||||
ReflectionHelper.setPrivateValue(ThreadDownloadImageData.class, threadDownloadImageData, false, new String[]{"textureUploaded", "field_110559_g"});
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
ReflectionHelper.setPrivateValue(ThreadDownloadImageData.class, abstractClientPlayer.getTextureCape(), false, new String[]{"textureUploaded", "field_110559_g"});
|
||||
|
||||
new Thread(new CloakThread(abstractClientPlayer, cloakURL)).start();
|
||||
event.renderCape = true;
|
||||
|
@ -107,7 +99,7 @@ public class CapeEventHandlerOld
|
|||
String nick = str.substring(0, str.indexOf(":"));
|
||||
String link = str.substring(str.indexOf(":") + 1);
|
||||
new Thread(new CloakPreload(link)).start();
|
||||
cloaks.put(nick, link);
|
||||
cloaks.put(nick, link);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -150,19 +142,11 @@ public class CapeEventHandlerOld
|
|||
cape.getHeight(null), BufferedImage.TYPE_INT_ARGB);
|
||||
bo.getGraphics().drawImage(cape, 0, 0, null);
|
||||
|
||||
try
|
||||
{
|
||||
ThreadDownloadImageData threadDownloadImageData = (ThreadDownloadImageData)ReflectionHelper.findMethod(AbstractClientPlayer.class, abstractClientPlayer, BOPObfuscationHelper.getTextureCape).invoke(abstractClientPlayer);
|
||||
ReflectionHelper.setPrivateValue(ThreadDownloadImageData.class, threadDownloadImageData, bo, new String[]{"bufferedImage", "field_110560_d"});
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
ReflectionHelper.setPrivateValue(ThreadDownloadImageData.class, abstractClientPlayer.getTextureCape(), bo, new String[]{"bufferedImage", "field_110560_d"});
|
||||
}
|
||||
catch (MalformedURLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue