本文整理匯總了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;
}
}