本文整理汇总了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);
}
示例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;
}
}