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