本文整理汇总了Java中cpw.mods.fml.relauncher.ReflectionHelper.findMethod方法的典型用法代码示例。如果您正苦于以下问题:Java ReflectionHelper.findMethod方法的具体用法?Java ReflectionHelper.findMethod怎么用?Java ReflectionHelper.findMethod使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cpw.mods.fml.relauncher.ReflectionHelper
的用法示例。
在下文中一共展示了ReflectionHelper.findMethod方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: notifyPlayers
import cpw.mods.fml.relauncher.ReflectionHelper; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
public static void notifyPlayers(WorldServer world) {
if (RorysConfig.enableSleepInDay) {
if (world.getWorldTime() == RorysConfig.sleepDayTime) {
world.provider.resetRainAndThunder();
Iterator iterator = world.playerEntities.iterator();
while (iterator.hasNext()) {
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
entityplayer.addChatMessage(new ChatComponentText(String.format(StatCollector.translateToLocal("message.rorysmod.sleeping.wakeup"), EnumChatFormatting.AQUA + entityplayer.getDisplayName() + EnumChatFormatting.WHITE)));
}
}
} else {
Method wakeAllPlayers = ReflectionHelper.findMethod(WorldServer.class, world, new String[] { "wakeAllPlayers", "func_73053_d" });
try {
wakeAllPlayers.invoke(world, new Object[] {});
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
e.printStackTrace();
}
}
}
示例2: doHeal
import cpw.mods.fml.relauncher.ReflectionHelper; //导入方法依赖的package包/类
private void doHeal(EntityLivingBase guy) {
armSwing(!didSwing); // Swings arm and heals the specified person.
EntityPotion potion = new EntityPotion(worldObj, this,
handPotion().getItemDamage());
worldObj.spawnEntityInWorld(potion);
// potion.onImpact(new MovingObjectPosition(guy));
try {
final Method onImpact = ReflectionHelper.findMethod(
EntityPotion.class, potion, MCP_ONIMPACT,
MovingObjectPosition.class);
onImpact.invoke(potion, new MovingObjectPosition(guy));
} catch (Exception e) {
e.printStackTrace();
}
setPathToEntity((PathEntity) null);
healTime = 200;
setRarePotion(rand.nextInt(4) == 0);
}
示例3: drawString
import cpw.mods.fml.relauncher.ReflectionHelper; //导入方法依赖的package包/类
@Override
public int drawString(String text, int x, int y, int color, boolean dropShadow) {
if (dropShadow) {
Method renderString = ReflectionHelper.findMethod(FontRenderer.class, this, renderStringObfNames,
String.class, int.class, int.class, int.class, boolean.class);
try {
renderString.invoke(this, text, x, y+1, color, true);
renderString.invoke(this, text, x, y-1, color, true);
renderString.invoke(this, text, x-1, y, color, true);
renderString.invoke(this, text, x+1, y, color, true);
} catch (Exception e) {}
return super.drawString(text, x, y, color, false);
} else {
return super.drawString(text, x, y, color, false);
}
}
示例4: resetTimer
import cpw.mods.fml.relauncher.ReflectionHelper; //导入方法依赖的package包/类
public void resetTimer(final MobSpawnerBaseLogic logic) {
if (this.cache == null) {
this.cache = ReflectionHelper.findMethod((Class)MobSpawnerBaseLogic.class, (Object)logic, new String[] { "resetTimer", "func_98273_j" }, new Class[0]);
}
try {
this.cache.invoke(logic, new Object[0]);
}
catch (Exception e) {
e.printStackTrace();
}
}
示例5: run
import cpw.mods.fml.relauncher.ReflectionHelper; //导入方法依赖的package包/类
@Override
public void run(){
try {
if(getAsieSplashMethod == null) {
Class okuTickHandler = Class.forName("okushama.drama.TickHandlerClient");
okuTickHandlerInstance = okuTickHandler.newInstance();
getAsieSplashMethod = ReflectionHelper.findMethod(okuTickHandler, okuTickHandlerInstance, new String[]{"asieSplash"});
}
cachedLine = (String)getAsieSplashMethod.invoke(okuTickHandlerInstance);
} catch(Exception e) {
Log.warning("Reflection failed on the Drama Splash getter!");
e.printStackTrace();
failed = true;
}
}
示例6: getSilkTouchBlock
import cpw.mods.fml.relauncher.ReflectionHelper; //导入方法依赖的package包/类
private static ItemStack getSilkTouchBlock(Block block, int meta){
ItemStack stack = silkTouchBlocks.get(Block.getIdFromBlock(block));
if(stack == null) {
Method method = ReflectionHelper.findMethod(Block.class, block, new String[]{"func_149644_j", "createStackedBlock"}, int.class);
try {
stack = (ItemStack)method.invoke(block, meta);
} catch(Exception e) {
Log.error("Reflection failed when trying to get a silk touch block!");
e.printStackTrace();
}
silkTouchBlocks.put(Block.getIdFromBlock(block), stack);
}
return stack.copy();
}
示例7: findMethod
import cpw.mods.fml.relauncher.ReflectionHelper; //导入方法依赖的package包/类
public static <E> Method findMethod(Class<? super E> clazz, String[] methodNames, Class<?>... methodTypes) {
return ReflectionHelper.findMethod(clazz, null, methodNames, methodTypes);
}