Take 2 at backwards compatibility. Cross your fingers.

This commit is contained in:
Adubbz 2014-06-27 22:50:23 +10:00
parent 0bcc061ce2
commit 4fdbb24b3a
5 changed files with 47 additions and 58 deletions

View file

@ -1,3 +1,3 @@
minecraft_version=1.7.10 minecraft_version=1.7.2
forge_version=10.13.0.1152 forge_version=10.12.2.1147
mod_version=2.0.2 mod_version=2.0.2

View file

@ -32,8 +32,4 @@ public class BOPObfuscationHelper
public static final String[] river = new String[] { "river", "field_76781_i" }; 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[] roofedForest = new String[] { "roofedForest", "field_150585_R" };
public static final String[] hell = new String[] { "hell", "field_76778_j" }; public static final String[] hell = new String[] { "hell", "field_76778_j" };
//AbstractClientPlayer
@Deprecated
public static final String[] getTextureCape = new String[] { "getTextureCape", "func_110310_o" };
} }

View file

@ -9,6 +9,7 @@ import biomesoplenty.common.eventhandler.gui.StartupWarningEventHandler;
import biomesoplenty.common.eventhandler.misc.BonemealEventHandler; import biomesoplenty.common.eventhandler.misc.BonemealEventHandler;
import biomesoplenty.common.eventhandler.misc.BucketEventHandler; import biomesoplenty.common.eventhandler.misc.BucketEventHandler;
import biomesoplenty.common.eventhandler.misc.CapeEventHandler; import biomesoplenty.common.eventhandler.misc.CapeEventHandler;
import biomesoplenty.common.eventhandler.misc.CapeEventHandlerOld;
import biomesoplenty.common.eventhandler.network.ConnectionEventHandler; import biomesoplenty.common.eventhandler.network.ConnectionEventHandler;
import biomesoplenty.common.eventhandler.potions.PotionParalysisEventHandler; import biomesoplenty.common.eventhandler.potions.PotionParalysisEventHandler;
import biomesoplenty.common.eventhandler.potions.PotionPossessionEventHandler; import biomesoplenty.common.eventhandler.potions.PotionPossessionEventHandler;
@ -66,6 +67,7 @@ public class BOPEventHandlers
{ {
MinecraftForge.EVENT_BUS.register(new BonemealEventHandler()); MinecraftForge.EVENT_BUS.register(new BonemealEventHandler());
MinecraftForge.EVENT_BUS.register(new BucketEventHandler()); 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());
} }
} }

View file

@ -9,27 +9,24 @@ import java.net.URL;
import java.net.URLConnection; import java.net.URLConnection;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.UUID;
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.client.resources.SkinManager;
import net.minecraftforge.client.event.RenderPlayerEvent; import net.minecraftforge.client.event.RenderPlayerEvent;
import org.apache.logging.log4j.Level; import org.apache.logging.log4j.Level;
import biomesoplenty.common.utils.BOPLogger; 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.Loader;
import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.relauncher.ReflectionHelper;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
public class CapeEventHandler 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 final int timeout = 1000;
private HashMap<String, String> cloaks = new HashMap<String, String>(); private HashMap<String, String> cloaks = new HashMap<String, String>();
@ -59,18 +56,31 @@ public class CapeEventHandler
{ {
checkedPlayers.add(abstractClientPlayer); checkedPlayers.add(abstractClientPlayer);
// getSkinManager()? try
SkinManager skinManager = Minecraft.getMinecraft().func_152342_ad();
String uuid = UUIDTypeAdapter.fromUUID(abstractClientPlayer.getUniqueID());
if (cloaks.containsKey(uuid))
{ {
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); // 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());
event.renderCape = true; 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; int linetracker = 1;
while ((str = br.readLine()) != null) while ((str = br.readLine()) != null)
{ {
if (!str.startsWith("--") && !str.isEmpty()) if ((!str.startsWith("--") || str.contains("--*--")) && !str.isEmpty())
{ {
if (str.startsWith("*%")) str = str.replace("--*--", "");
{
str = str.replace("*%", "");
if (str.contains(":")) if (str.contains(":"))
{ {
String uuid = str.substring(0, str.indexOf(":")); String uuid = str.substring(0, str.indexOf(":"));
String link = str.substring(str.indexOf(":") + 1); String link = str.substring(str.indexOf(":") + 1);
cloaks.put(uuid, link); cloaks.put(uuid, link);
} }
else else
{ {
BOPLogger.log(Level.WARN, "[capes.txt] Syntax error on line " + linetracker + ": " + str); BOPLogger.log(Level.WARN, "[capes.txt] Syntax error on line " + linetracker + ": " + str);
}
} }
} }
linetracker++; linetracker++;

View file

@ -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.**/ /**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 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 final int timeout = 1000;
private static final Graphics TEST_GRAPHICS = new BufferedImage(128, 128, private static final Graphics TEST_GRAPHICS = new BufferedImage(128, 128,
@ -68,15 +68,7 @@ public class CapeEventHandlerOld
capePlayers.add(abstractClientPlayer); capePlayers.add(abstractClientPlayer);
try ReflectionHelper.setPrivateValue(ThreadDownloadImageData.class, abstractClientPlayer.getTextureCape(), false, new String[]{"textureUploaded", "field_110559_g"});
{
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();
}
new Thread(new CloakThread(abstractClientPlayer, cloakURL)).start(); new Thread(new CloakThread(abstractClientPlayer, cloakURL)).start();
event.renderCape = true; event.renderCape = true;
@ -150,19 +142,11 @@ public class CapeEventHandlerOld
cape.getHeight(null), BufferedImage.TYPE_INT_ARGB); cape.getHeight(null), BufferedImage.TYPE_INT_ARGB);
bo.getGraphics().drawImage(cape, 0, 0, null); bo.getGraphics().drawImage(cape, 0, 0, null);
try ReflectionHelper.setPrivateValue(ThreadDownloadImageData.class, abstractClientPlayer.getTextureCape(), bo, new String[]{"bufferedImage", "field_110560_d"});
{
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();
}
} }
catch (MalformedURLException e) catch (MalformedURLException e)
{ {
e.printStackTrace(); e.printStackTrace();
} }
} }
} }