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
|
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
|
||||||
|
|
|
@ -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" };
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,20 +56,33 @@ public class CapeEventHandler
|
||||||
{
|
{
|
||||||
checkedPlayers.add(abstractClientPlayer);
|
checkedPlayers.add(abstractClientPlayer);
|
||||||
|
|
||||||
// getSkinManager()?
|
try
|
||||||
SkinManager skinManager = Minecraft.getMinecraft().func_152342_ad();
|
{
|
||||||
|
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");
|
||||||
|
|
||||||
String uuid = UUIDTypeAdapter.fromUUID(abstractClientPlayer.getUniqueID());
|
// 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))
|
if (cloaks.containsKey(uuid))
|
||||||
{
|
{
|
||||||
MinecraftProfileTexture profileTexture = new MinecraftProfileTexture(cloaks.get(uuid));
|
Class MinecraftProfileTexture = Class.forName("com.mojang.authlib.minecraft.MinecraftProfileTexture");
|
||||||
|
Class Type = Class.forName("com.mojang.authlib.minecraft.MinecraftProfileTexture$Type");
|
||||||
|
|
||||||
skinManager.func_152789_a(profileTexture, MinecraftProfileTexture.Type.CAPE, abstractClientPlayer);
|
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;
|
event.renderCape = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,11 +102,9 @@ 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(":"))
|
||||||
{
|
{
|
||||||
|
@ -109,7 +117,6 @@ public class CapeEventHandler
|
||||||
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++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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,15 +142,7 @@ 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)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue