Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.lang.reflect.Method;
- import java.util.HashMap;
- import java.util.Map;
- import net.minecraft.client.Minecraft;
- import net.minecraft.client.entity.EntityPlayerSP;
- import net.minecraft.entity.Entity;
- import net.minecraft.entity.EntityLivingBase;
- import net.minecraft.entity.player.EntityPlayer;
- import sun.reflect.ConstantPool;
- public class PoolChecker {
- private static final Map<Class, Double> map = new HashMap();
- static{
- addClass(EntityPlayerSP.class);
- addClass(Minecraft.class);
- addClass(EntityPlayer.class);
- addClass(EntityLivingBase.class);
- addClass(Entity.class);
- }
- private static void addClass(Class cl){
- map.put(cl, getHash(cl));
- }
- public static boolean check(Class cl){
- return map.containsKey(cl) && map.get(cl)==getHash(cl);
- }
- public static void recheck(){
- for(Class key : map.keySet()){
- if(map.get(key)!=getHash(key)){
- //TO-DO
- }
- }
- }
- private static double getHash(Class cl){
- Method getConstantPool;
- try {
- getConstantPool = Class.class.getDeclaredMethod("getConstantPool");
- getConstantPool.setAccessible(true);
- } catch (NoSuchMethodException e) {
- throw new RuntimeException(e);
- }
- double result = 0;
- try {
- ConstantPool constantPool = (ConstantPool) getConstantPool.invoke(cl);
- for(int i = 0; i<constantPool.getSize();i++){
- try {
- long l = constantPool.getLongAt(i);
- result+=l;
- } catch (IllegalArgumentException e) {
- try {
- double d = constantPool.getDoubleAt(i);
- result+=d;
- } catch (IllegalArgumentException ed) {
- try {
- float f = constantPool.getFloatAt(i);
- result+=f;
- } catch (IllegalArgumentException edzz) {
- }
- }
- }
- }
- } catch (Exception e) {
- }
- return result;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement