当前位置: 首页>>代码示例>>Java>>正文


Java ReflectionHelper.getClass方法代码示例

本文整理汇总了Java中net.minecraftforge.fml.relauncher.ReflectionHelper.getClass方法的典型用法代码示例。如果您正苦于以下问题:Java ReflectionHelper.getClass方法的具体用法?Java ReflectionHelper.getClass怎么用?Java ReflectionHelper.getClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraftforge.fml.relauncher.ReflectionHelper的用法示例。


在下文中一共展示了ReflectionHelper.getClass方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doImmenseEvil

import net.minecraftforge.fml.relauncher.ReflectionHelper; //导入方法依赖的package包/类
public static void doImmenseEvil() throws Exception {
    // de-finalise the grass colour field
    Field grass_color = ReflectionHelper.findField(BiomeColorHelper.class, GRASS_COLOR);
    grass_color.setAccessible(true);

    Field modifiers = Field.class.getDeclaredField("modifiers");

    AccessController.doPrivileged((PrivilegedAction) () -> {
        modifiers.setAccessible(true);
        return null;
    });

    modifiers.setInt(grass_color, grass_color.getModifiers() & ~Modifier.FINAL);

    // get the interface
    Class colorResolver = ReflectionHelper.getClass(Minecraft.class.getClassLoader(), COLOR_RESOLVER);

    // get what the field was so it can be wrapped
    Object wrappedResolver = grass_color.get(null);

    // get the version of the method used by the object to be wrapped - avoids exceptions for calling an abstract method
    Class wrappedResolverClass = wrappedResolver.getClass();
    Method wrappedGetColorAtPos = ReflectionHelper.findMethod(wrappedResolverClass, "getColorAtPos", "func_180283_a", Biome.class, BlockPos.class);

    // build a proxy
    Method getColorAtPos = ReflectionHelper.findMethod(colorResolver, "getColorAtPos", "func_180283_a", Biome.class, BlockPos.class);
    Object proxy = Proxy.newProxyInstance(colorResolver.getClassLoader(), new Class[] { colorResolver }, new GrassHandler(getColorAtPos, wrappedResolver, wrappedGetColorAtPos) );

    // set the field
    grass_color.set(null, proxy);
}
 
开发者ID:stuebz88,项目名称:modName,代码行数:32,代码来源:GrassColours.java

示例2: find

import net.minecraftforge.fml.relauncher.ReflectionHelper; //导入方法依赖的package包/类
private Iterable<Object> find(String className, String fieldName) {
    try {
        Class compost = ReflectionHelper.getClass(getClass().getClassLoader(), className);
        return (Iterable<Object>) ReflectionHelper.getPrivateValue(compost, null, fieldName);
    } catch (Throwable t) {
        Core.logWarning("Couldn't find erebus recipe: " + className + "." + fieldName);
        t.printStackTrace();
        return null;
    }
}
 
开发者ID:purpleposeidon,项目名称:Factorization,代码行数:11,代码来源:Compat_erebus.java


注:本文中的net.minecraftforge.fml.relauncher.ReflectionHelper.getClass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。