Hopefully fixed crash
This commit is contained in:
parent
3caf04ef4a
commit
9d94e55ece
4 changed files with 39 additions and 18 deletions
|
@ -7,6 +7,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.ObfuscatedNames;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||
|
@ -52,9 +53,9 @@ public class ClientTickHandler implements ITickHandler
|
|||
} catch(Exception e) {}
|
||||
}
|
||||
|
||||
if(MekanismUtils.getPrivateValue(player, AbstractClientPlayer.class, "field_110315_c") != newCape)
|
||||
if(MekanismUtils.getPrivateValue(player, AbstractClientPlayer.class, ObfuscatedNames.AbstractClientPlayer_downloadImageCape) != newCape)
|
||||
{
|
||||
MekanismUtils.setPrivateValue(player, newCape, AbstractClientPlayer.class, "field_110315_c");
|
||||
MekanismUtils.setPrivateValue(player, newCape, AbstractClientPlayer.class, ObfuscatedNames.AbstractClientPlayer_downloadImageCape);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -62,7 +63,7 @@ public class ClientTickHandler implements ITickHandler
|
|||
{
|
||||
if(player instanceof AbstractClientPlayer)
|
||||
{
|
||||
return (ResourceLocation)MekanismUtils.getPrivateValue(player, AbstractClientPlayer.class, "field_110313_e");
|
||||
return (ResourceLocation)MekanismUtils.getPrivateValue(player, AbstractClientPlayer.class, ObfuscatedNames.AbstractClientPlayer_locationCape);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.Arrays;
|
|||
import java.util.List;
|
||||
|
||||
import mekanism.common.ISpecialBounds;
|
||||
import mekanism.common.ObfuscatedNames;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
@ -334,7 +335,7 @@ public class MekanismRenderer
|
|||
public static TextureMap getTextureMap(int type)
|
||||
{
|
||||
try {
|
||||
List l = (List)MekanismUtils.getPrivateValue(Minecraft.getMinecraft().renderEngine, TextureManager.class, "listTickables");
|
||||
List l = (List)MekanismUtils.getPrivateValue(Minecraft.getMinecraft().renderEngine, TextureManager.class, ObfuscatedNames.TextureManager_listTickables);
|
||||
|
||||
for(Object obj : l)
|
||||
{
|
||||
|
@ -386,7 +387,7 @@ public class MekanismRenderer
|
|||
public static float getPartialTicks()
|
||||
{
|
||||
try {
|
||||
Timer t = (Timer)MekanismUtils.getPrivateValue(Minecraft.getMinecraft(), Minecraft.class, "timer");
|
||||
Timer t = (Timer)MekanismUtils.getPrivateValue(Minecraft.getMinecraft(), Minecraft.class, ObfuscatedNames.Minecraft_timer);
|
||||
return t.renderPartialTicks;
|
||||
} catch(Exception e) {}
|
||||
|
||||
|
|
9
common/mekanism/common/ObfuscatedNames.java
Normal file
9
common/mekanism/common/ObfuscatedNames.java
Normal file
|
@ -0,0 +1,9 @@
|
|||
package mekanism.common;
|
||||
|
||||
public final class ObfuscatedNames
|
||||
{
|
||||
public static String[] TextureManager_listTickables = new String[] {"listTickables", "c"};
|
||||
public static String[] Minecraft_timer = new String[] {"timer", "S"};
|
||||
public static String[] AbstractClientPlayer_downloadImageCape = new String[] {"downloadImageCape", "c"};
|
||||
public static String[] AbstractClientPlayer_locationCape = new String[] {"locationCape", "e"};
|
||||
}
|
|
@ -866,15 +866,20 @@ public final class MekanismUtils
|
|||
* @param field - name of declared field
|
||||
* @return value as an Object, cast as necessary
|
||||
*/
|
||||
public static Object getPrivateValue(Object obj, Class c, String field)
|
||||
public static Object getPrivateValue(Object obj, Class c, String[] fields)
|
||||
{
|
||||
try {
|
||||
Field f = c.getDeclaredField(field);
|
||||
f.setAccessible(true);
|
||||
return f.get(obj);
|
||||
} catch(Exception e) {
|
||||
return null;
|
||||
for(String field : fields)
|
||||
{
|
||||
try {
|
||||
Field f = c.getDeclaredField(field);
|
||||
f.setAccessible(true);
|
||||
return f.get(obj);
|
||||
} catch(Exception e) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -884,13 +889,18 @@ public final class MekanismUtils
|
|||
* @param c - Class the operation will be performed on
|
||||
* @param field - name of declared field
|
||||
*/
|
||||
public static void setPrivateValue(Object obj, Object value, Class c, String field)
|
||||
public static void setPrivateValue(Object obj, Object value, Class c, String[] fields)
|
||||
{
|
||||
try {
|
||||
Field f = c.getDeclaredField(field);
|
||||
f.setAccessible(true);
|
||||
f.set(obj, value);
|
||||
} catch(Exception e) {}
|
||||
for(String field : fields)
|
||||
{
|
||||
try {
|
||||
Field f = c.getDeclaredField(field);
|
||||
f.setAccessible(true);
|
||||
f.set(obj, value);
|
||||
} catch(Exception e) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue