Java 类cpw.mods.fml.relauncher.ReflectionHelper.UnableToAccessFieldException 实例源码

项目:TRHS_Club_Mod_2016    文件:ObfuscationReflectionHelper.java   
public static <T, E> T getPrivateValue(Class<? super E> classToAccess, E instance, int fieldIndex)
{
    try
    {
        return ReflectionHelper.getPrivateValue(classToAccess, instance, fieldIndex);
    }
    catch (UnableToAccessFieldException e)
    {
        FMLLog.log(Level.ERROR, e, "There was a problem getting field index %d from %s", fieldIndex, classToAccess.getName());
        throw e;
    }
}
项目:TRHS_Club_Mod_2016    文件:ObfuscationReflectionHelper.java   
public static <T, E> void setPrivateValue(Class<? super T> classToAccess, T instance, E value, int fieldIndex)
{
    try
    {
        ReflectionHelper.setPrivateValue(classToAccess, instance, value, fieldIndex);
    }
    catch (UnableToAccessFieldException e)
    {
        FMLLog.log(Level.ERROR, e, "There was a problem setting field index %d on type %s", fieldIndex, classToAccess.getName());
        throw e;
    }
}
项目:CauldronGit    文件:ObfuscationReflectionHelper.java   
public static <T, E> T getPrivateValue(Class<? super E> classToAccess, E instance, int fieldIndex)
{
    try
    {
        return ReflectionHelper.getPrivateValue(classToAccess, instance, fieldIndex);
    }
    catch (UnableToAccessFieldException e)
    {
        FMLLog.log(Level.ERROR, e, "There was a problem getting field index %d from %s", fieldIndex, classToAccess.getName());
        throw e;
    }
}
项目:CauldronGit    文件:ObfuscationReflectionHelper.java   
public static <T, E> void setPrivateValue(Class<? super T> classToAccess, T instance, E value, int fieldIndex)
{
    try
    {
        ReflectionHelper.setPrivateValue(classToAccess, instance, value, fieldIndex);
    }
    catch (UnableToAccessFieldException e)
    {
        FMLLog.log(Level.ERROR, e, "There was a problem setting field index %d on type %s", fieldIndex, classToAccess.getName());
        throw e;
    }
}
项目:ZeroQuest    文件:UnsafeReflectionHelper.java   
public static <T, E> void setFinalValue(Class<? super T> classToAccess, T instance, E value, int fieldIndex) {
    try {
        Field f = classToAccess.getDeclaredFields()[fieldIndex];
        f.setAccessible(true);
        setFinal(f, false);
        f.set(instance, value);
        setFinal(f, true);
    } catch (Exception e) {
        throw new UnableToAccessFieldException(new String[0], e);
    }
}
项目:ZeroQuest    文件:UnsafeReflectionHelper.java   
public static <T, E> void setFinalValue(Class<? super T> classToAccess, T instance, E value, String... fieldNames) {
    try {
        Field f = ReflectionHelper.findField(classToAccess, fieldNames);
        setFinal(f, false);
        f.set(instance, value);
        setFinal(f, true);
    } catch (Exception e) {
        throw new UnableToAccessFieldException(fieldNames, e);
    }
}
项目:Cauldron    文件:ObfuscationReflectionHelper.java   
public static <T, E> T getPrivateValue(Class<? super E> classToAccess, E instance, int fieldIndex)
{
    try
    {
        return ReflectionHelper.getPrivateValue(classToAccess, instance, fieldIndex);
    }
    catch (UnableToAccessFieldException e)
    {
        FMLLog.log(Level.ERROR, e, "There was a problem getting field index %d from %s", fieldIndex, classToAccess.getName());
        throw e;
    }
}
项目:Cauldron    文件:ObfuscationReflectionHelper.java   
public static <T, E> void setPrivateValue(Class<? super T> classToAccess, T instance, E value, int fieldIndex)
{
    try
    {
        ReflectionHelper.setPrivateValue(classToAccess, instance, value, fieldIndex);
    }
    catch (UnableToAccessFieldException e)
    {
        FMLLog.log(Level.ERROR, e, "There was a problem setting field index %d on type %s", fieldIndex, classToAccess.getName());
        throw e;
    }
}
项目:Cauldron    文件:ObfuscationReflectionHelper.java   
public static <T, E> T getPrivateValue(Class<? super E> classToAccess, E instance, int fieldIndex)
{
    try
    {
        return ReflectionHelper.getPrivateValue(classToAccess, instance, fieldIndex);
    }
    catch (UnableToAccessFieldException e)
    {
        FMLLog.log(Level.ERROR, e, "There was a problem getting field index %d from %s", fieldIndex, classToAccess.getName());
        throw e;
    }
}
项目:Cauldron    文件:ObfuscationReflectionHelper.java   
public static <T, E> void setPrivateValue(Class<? super T> classToAccess, T instance, E value, int fieldIndex)
{
    try
    {
        ReflectionHelper.setPrivateValue(classToAccess, instance, value, fieldIndex);
    }
    catch (UnableToAccessFieldException e)
    {
        FMLLog.log(Level.ERROR, e, "There was a problem setting field index %d on type %s", fieldIndex, classToAccess.getName());
        throw e;
    }
}
项目:Cauldron    文件:ObfuscationReflectionHelper.java   
public static <T, E> T getPrivateValue(Class<? super E> classToAccess, E instance, int fieldIndex)
{
    try
    {
        return ReflectionHelper.getPrivateValue(classToAccess, instance, fieldIndex);
    }
    catch (UnableToAccessFieldException e)
    {
        FMLLog.log(Level.ERROR, e, "There was a problem getting field index %d from %s", fieldIndex, classToAccess.getName());
        throw e;
    }
}
项目:Cauldron    文件:ObfuscationReflectionHelper.java   
public static <T, E> void setPrivateValue(Class<? super T> classToAccess, T instance, E value, int fieldIndex)
{
    try
    {
        ReflectionHelper.setPrivateValue(classToAccess, instance, value, fieldIndex);
    }
    catch (UnableToAccessFieldException e)
    {
        FMLLog.log(Level.ERROR, e, "There was a problem setting field index %d on type %s", fieldIndex, classToAccess.getName());
        throw e;
    }
}
项目:RuneCraftery    文件:ObfuscationReflectionHelper.java   
@SuppressWarnings("unchecked")
public static <T, E> T getPrivateValue(Class<? super E> classToAccess, E instance, int fieldIndex)
{
    try
    {
        return ReflectionHelper.getPrivateValue(classToAccess, instance, fieldIndex);
    }
    catch (UnableToAccessFieldException e)
    {
        FMLLog.log(Level.SEVERE, e, "There was a problem getting field index %d from %s", fieldIndex, classToAccess.getName());
        throw e;
    }
}
项目:RuneCraftery    文件:ObfuscationReflectionHelper.java   
public static <T, E> void setPrivateValue(Class<? super T> classToAccess, T instance, E value, int fieldIndex)
{
    try
    {
        ReflectionHelper.setPrivateValue(classToAccess, instance, value, fieldIndex);
    }
    catch (UnableToAccessFieldException e)
    {
        FMLLog.log(Level.SEVERE, e, "There was a problem setting field index %d on type %s", fieldIndex, classToAccess.getName());
        throw e;
    }
}
项目:RuneCraftery    文件:ObfuscationReflectionHelper.java   
@SuppressWarnings("unchecked")
public static <T, E> T getPrivateValue(Class<? super E> classToAccess, E instance, int fieldIndex)
{
    try
    {
        return ReflectionHelper.getPrivateValue(classToAccess, instance, fieldIndex);
    }
    catch (UnableToAccessFieldException e)
    {
        FMLLog.log(Level.SEVERE, e, "There was a problem getting field index %d from %s", fieldIndex, classToAccess.getName());
        throw e;
    }
}
项目:RuneCraftery    文件:ObfuscationReflectionHelper.java   
public static <T, E> void setPrivateValue(Class<? super T> classToAccess, T instance, E value, int fieldIndex)
{
    try
    {
        ReflectionHelper.setPrivateValue(classToAccess, instance, value, fieldIndex);
    }
    catch (UnableToAccessFieldException e)
    {
        FMLLog.log(Level.SEVERE, e, "There was a problem setting field index %d on type %s", fieldIndex, classToAccess.getName());
        throw e;
    }
}
项目:BetterNutritionMod    文件:ObfuscationReflectionHelper.java   
@SuppressWarnings("unchecked")
public static <T, E> T getPrivateValue(Class<? super E> classToAccess, E instance, int fieldIndex)
{
    try
    {
        return ReflectionHelper.getPrivateValue(classToAccess, instance, fieldIndex);
    }
    catch (UnableToAccessFieldException e)
    {
        FMLLog.log(Level.SEVERE, e, "There was a problem getting field index %d from %s", fieldIndex, classToAccess.getName());
        throw e;
    }
}
项目:BetterNutritionMod    文件:ObfuscationReflectionHelper.java   
public static <T, E> void setPrivateValue(Class<? super T> classToAccess, T instance, E value, int fieldIndex)
{
    try
    {
        ReflectionHelper.setPrivateValue(classToAccess, instance, value, fieldIndex);
    }
    catch (UnableToAccessFieldException e)
    {
        FMLLog.log(Level.SEVERE, e, "There was a problem setting field index %d on type %s", fieldIndex, classToAccess.getName());
        throw e;
    }
}
项目:Morph    文件:ModelHelper.java   
public static ModelRenderer getPotentialArm(ModelBase parent)
{
    if(parent != null)
    {
        Class clz = parent.getClass();
           if(armMappings.containsKey(clz))
           {
               return armMappings.get(clz);
           }
        if(clz == ModelHorse.class)
        {
            ModelHorse dummy = new ModelHorse();

            ModelRenderer leg = new ModelRenderer(dummy, 60, 29);
            leg.addBox(-1.1F, -1.0F, -2.1F, 3, 8, 4);
            leg.setRotationPoint(-4.0F, 9.0F, -8.0F);

            ModelRenderer shin = new ModelRenderer(dummy, 60, 41);
            shin.addBox(-1.1F, 0.0F, -1.6F, 3, 5, 3);
            shin.setRotationPoint(0.0F, 7.0F, 0.0F);
            leg.addChild(shin);

            ModelRenderer hoof = new ModelRenderer(dummy, 60, 51);
            hoof.addBox(-1.6F, 5.1F, -2.1F, 4, 3, 4);
            hoof.setRotationPoint(0.0F, 0.0F, 0.0F);

            shin.addChild(hoof);

            return leg;
        }
        else
        {
            while(clz != ModelBase.class && ModelBase.class.isAssignableFrom(clz))
            {
                try
                {
                    Field[] fields = clz.getDeclaredFields();
                    for(Field f : fields)
                    {
                        f.setAccessible(true);
                        if(f.getType() == ModelRenderer.class)
                        {
                            if(clz == ModelBiped.class && (f.getName().equalsIgnoreCase("bipedRightArm") || f.getName().equalsIgnoreCase("f") || f.getName().equalsIgnoreCase("field_78112_f")) || 
                                clz == ModelQuadruped.class && (f.getName().equalsIgnoreCase("leg3") || f.getName().equalsIgnoreCase("e") || f.getName().equalsIgnoreCase("field_78147_e")) ||
                                clz == ModelCreeper.class && (f.getName().equalsIgnoreCase("leg3") || f.getName().equalsIgnoreCase("f") || f.getName().equalsIgnoreCase("field_78129_f")) ||
                                clz == ModelIronGolem.class && (f.getName().equalsIgnoreCase("ironGolemRightArm") || f.getName().equalsIgnoreCase("c") || f.getName().equalsIgnoreCase("field_78177_c")) ||
                                clz == ModelSpider.class && (f.getName().equalsIgnoreCase("spiderLeg7") || f.getName().equalsIgnoreCase("j") || f.getName().equalsIgnoreCase("field_78210_j")) ||
                                clz == ModelWolf.class && (f.getName().equalsIgnoreCase("wolfLeg3") || f.getName().equalsIgnoreCase("e") || f.getName().equalsIgnoreCase("field_78182_e")) ||
                                clz == ModelOcelot.class && (f.getName().equalsIgnoreCase("ocelotFrontRightLeg") || f.getName().equalsIgnoreCase("d") || f.getName().equalsIgnoreCase("field_78157_d")) ||
                                clz != ModelBiped.class && clz != ModelQuadruped.class && clz != ModelCreeper.class && clz != ModelIronGolem.class && clz != ModelSpider.class && clz != ModelWolf.class && clz != ModelOcelot.class &&  
                                (f.getName().contains("Right") || f.getName().contains("right")) && (f.getName().contains("arm") || f.getName().contains("hand") || f.getName().contains("Arm") || f.getName().contains("Hand")))
                            {
                                ModelRenderer arm = (ModelRenderer)f.get(parent);
                                if(arm != null)
                                {
                                    return arm; // Add normal parent fields
                                }
                            }
                        }
                        else if(f.getType() == ModelRenderer[].class && clz == ModelSquid.class && (f.getName().equalsIgnoreCase("squidTentacles") || f.getName().equalsIgnoreCase("b") || f.getName().equalsIgnoreCase("field_78201_b")))
                        {
                            return ((ModelRenderer[])f.get(parent))[0];
                        }
                    }
                    clz = clz.getSuperclass();
                }
                catch(Exception e)
                {
                    throw new UnableToAccessFieldException(new String[0], e);
                }
            }
        }
    }

    return null;
}