當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。