本文整理汇总了Java中cpw.mods.fml.relauncher.ReflectionHelper类的典型用法代码示例。如果您正苦于以下问题:Java ReflectionHelper类的具体用法?Java ReflectionHelper怎么用?Java ReflectionHelper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ReflectionHelper类属于cpw.mods.fml.relauncher包,在下文中一共展示了ReflectionHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: makeOurList
import cpw.mods.fml.relauncher.ReflectionHelper; //导入依赖的package包/类
private void makeOurList()
{
if (serverListInternetField == null)
{
if (serverListInternetField == null)
{
serverListInternetField = ReflectionHelper.findField(ServerSelectionList.class, "field_148198_l", "serverListInternet");
serverListInternetField.setAccessible(true);
}
}
try
{
ourList = (List<ServerListEntryPublic>) serverListInternetField.get(this);
}
catch (IllegalAccessException e)
{
CreeperHost.logger.warn("Reflection to get server list failed.", e);
}
}
示例2: setServerList
import cpw.mods.fml.relauncher.ReflectionHelper; //导入依赖的package包/类
private void setServerList(ServerList serverList)
{
ourSavedServerList = serverList;
if (savedServerListField == null)
{
savedServerListField = ReflectionHelper.findField(GuiMultiplayer.class, "field_146804_i", "savedServerList");
savedServerListField.setAccessible(true);
}
try
{
savedServerListField.set(this, serverList);
}
catch (IllegalAccessException e)
{
CreeperHost.logger.error("Unable to set server list", e);
}
}
示例3: setLanServerDetector
import cpw.mods.fml.relauncher.ReflectionHelper; //导入依赖的package包/类
private void setLanServerDetector(LanServerDetector.ThreadLanServerFind detector)
{
ourLanServerDetector = detector;
if (lanServerDetectorField == null)
{
lanServerDetectorField = ReflectionHelper.findField(GuiMultiplayer.class, "field_146800_B", "lanServerDetector");
lanServerDetectorField.setAccessible(true);
}
try
{
lanServerDetectorField.set(this, detector);
}
catch (IllegalAccessException e)
{
CreeperHost.logger.error("Unable to set server list", e);
}
}
示例4: setLanServerList
import cpw.mods.fml.relauncher.ReflectionHelper; //导入依赖的package包/类
private void setLanServerList(LanServerDetector.LanServerList detector)
{
ourLanServerList = detector;
if (lanServerListField == null)
{
lanServerListField = ReflectionHelper.findField(GuiMultiplayer.class, "field_146799_A", "lanServerList");
lanServerListField.setAccessible(true);
}
try
{
lanServerListField.set(this, detector);
}
catch (IllegalAccessException e)
{
CreeperHost.logger.error("Unable to set server list", e);
}
}
示例5: setServerListSelector
import cpw.mods.fml.relauncher.ReflectionHelper; //导入依赖的package包/类
private void setServerListSelector(ServerSelectionListPublic list)
{
ourServerListSelector = list;
if (serverListSelectorField == null)
{
serverListSelectorField = ReflectionHelper.findField(GuiMultiplayer.class, "field_146803_h", "serverListSelector");
serverListSelectorField.setAccessible(true);
}
try
{
serverListSelectorField.set(this, list);
}
catch (IllegalAccessException e)
{
CreeperHost.logger.error("Unable to set server list", e);
}
}
示例6: EntityRabbit
import cpw.mods.fml.relauncher.ReflectionHelper; //导入依赖的package包/类
public EntityRabbit(World world) {
super(world);
moveType = EntityRabbit.EnumMoveType.HOP;
carrotTicks = 0;
setSize(0.4F, 0.5F);
ReflectionHelper.setPrivateValue(EntityLiving.class, this, new EntityRabbit.RabbitJumpHelper(this), "jumpHelper", "field_70767_i");
ReflectionHelper.setPrivateValue(EntityLiving.class, this, new EntityRabbit.RabbitMoveHelper(), "moveHelper", "field_70765_h");
getNavigator().setAvoidsWater(true);
// navigator.func_179678_a(2.5F);
tasks.addTask(1, new EntityAISwimming(this));
tasks.addTask(1, new EntityRabbit.AIPanic(1.33D));
tasks.addTask(2, new EntityAIMate(this, 0.8D));
tasks.addTask(3, new EntityAITempt(this, 1.0D, Items.carrot, false));
tasks.addTask(5, new EntityRabbit.AIRaidFarm());
tasks.addTask(5, new EntityAIWander(this, 0.6D));
tasks.addTask(11, new EntityAIWatchClosest(this, EntityPlayer.class, 10.0F));
tasks.addTask(4, new EntityAIAvoidEntity(this, EntityWolf.class, 16.0F, 1.33D, 1.33D));
tasks.addTask(4, new EntityAIAvoidEntity(this, EntityPlayer.class, 16.0F, 0.8D, 1.33D));
setMovementSpeed(0.0D);
}
示例7: onCollideWithPlayer
import cpw.mods.fml.relauncher.ReflectionHelper; //导入依赖的package包/类
@Override
public void onCollideWithPlayer(EntityPlayer player) {
boolean inGround = false;
try {
inGround = ReflectionHelper.getPrivateValue(EntityArrow.class, this, "inGround", "field_70254_i");
} catch (Exception e) {
}
if (!worldObj.isRemote && inGround && arrowShake <= 0 && isEffectValid()) {
boolean flag = canBePickedUp == 1 || canBePickedUp == 2 && player.capabilities.isCreativeMode;
ItemStack stack = new ItemStack(ModItems.tipped_arrow);
TippedArrow.setEffect(stack, Potion.potionTypes[effect.getPotionID()], effect.getDuration());
if (canBePickedUp == 1 && !player.inventory.addItemStackToInventory(stack))
flag = false;
if (flag) {
playSound("random.pop", 0.2F, ((rand.nextFloat() - rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
player.onItemPickup(this, 1);
setDead();
}
}
}
示例8: RabbitFoot
import cpw.mods.fml.relauncher.ReflectionHelper; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public RabbitFoot() {
setTextureName("rabbit_foot");
setUnlocalizedName(Utils.getUnlocalisedName("rabbit_foot"));
setCreativeTab(EtFuturum.enableRabbit ? EtFuturum.creativeTab : null);
if (EtFuturum.enableRabbit)
try {
Field f = ReflectionHelper.findField(PotionHelper.class, "potionRequirements", "field_77927_l");
f.setAccessible(true);
HashMap<Integer, String> potionRequirements = (HashMap<Integer, String>) f.get(null);
potionRequirements.put(Potion.jump.getId(), "0 & 1 & !2 & 3");
Field f2 = ReflectionHelper.findField(PotionHelper.class, "potionAmplifiers", "field_77928_m");
f2.setAccessible(true);
HashMap<Integer, String> potionAmplifiers = (HashMap<Integer, String>) f2.get(null);
potionAmplifiers.put(Potion.jump.getId(), "5");
Field f3 = ReflectionHelper.findField(Potion.class, "liquidColor", "field_76414_N");
f3.setAccessible(true);
f3.set(Potion.jump, 0x22FF4C);
} catch (Exception e) {
}
}
示例9: BlockColor
import cpw.mods.fml.relauncher.ReflectionHelper; //导入依赖的package包/类
public BlockColor(final Block b, final String orename, final String texture) {
super(b.getMaterial());
this.curMetadata = 0;
this.customRecipe = null;
this.customRecipeNo = 0;
this.setHardness((Float)ReflectionHelper.getPrivateValue(Block.class, b, new String[] { "blockHardness", "field_149782_v" }));
this.setResistance((Float)ReflectionHelper.getPrivateValue(Block.class, b, new String[] { "blockResistance", "field_149781_w" }));
this.setStepSound(b.stepSound);
this.setBlockTextureName(texture);
this.setBlockName("extrautils:color_" + b.getUnlocalizedName().substring(5));
this.setLightLevel(b.getLightValue() / 15.0f);
this.setLightOpacity(b.getLightOpacity());
this.oreName = orename;
this.baseBlock = b;
ExtraUtils.colorblocks.add(this);
}
示例10: processCommand
import cpw.mods.fml.relauncher.ReflectionHelper; //导入依赖的package包/类
public void processCommand(final ICommandSender icommandsender, final String[] astring) {
final File f = new File(Minecraft.getMinecraft().mcDataDir, "extrautilities_localization.txt");
final Map<String, Properties> k = (Map<String, Properties>)ReflectionHelper.getPrivateValue((Class)LanguageRegistry.class, (Object)LanguageRegistry.instance(), new String[] { "modLanguageData" });
final String lang = FMLCommonHandler.instance().getCurrentLanguage();
final Properties p = k.get(lang);
String t = "";
for (final Map.Entry<Object, Object> entry : p.entrySet()) {
t = t + entry.getKey() + "=" + entry.getValue() + "\n";
}
try {
Files.write((CharSequence)t, f, Charsets.UTF_8);
LogHelper.info("Dumped Language data to " + f.getAbsolutePath(), new Object[0]);
}
catch (Exception exception) {
exception.printStackTrace();
}
}
示例11: 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();
}
}
}
示例12: 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);
}
示例13: getSheep
import cpw.mods.fml.relauncher.ReflectionHelper; //导入依赖的package包/类
public ArrayList getSheep( final World world ) {
final List list = world.getEntitiesWithinAABB( EntitySheep.class, fairy.boundingBox.expand( 5D, 5D, 5D ) );
if ( list.size() < 1 ) {
return null;
}
final ArrayList list2 = new ArrayList();
for ( int i = 0; i < list.size(); i++ ) {
final EntitySheep entity1 = (EntitySheep) list.get( i );
final int fleeingTick = ReflectionHelper.getPrivateValue(EntityCreature.class, entity1, MCP_FLEEINGTICK);
if ( fairy.canEntityBeSeen( entity1 ) && entity1.getHealth() > 0 && entity1.getEntityToAttack() == null
&& fleeingTick <= 0 && entity1.getGrowingAge() >= 0 && !entity1.getSheared() ) {
list2.add( entity1 );
}
}
if ( list2.size() <= 0 ) {
return null;
} else {
return list2;
}
}
示例14: inject
import cpw.mods.fml.relauncher.ReflectionHelper; //导入依赖的package包/类
/**
* Inserts the resource pack into the game. Enabling the resource pack will
* not be required, it will load automatically.
* <p>
* A cache of the pack zip will be kept in "resourcepack/[pack name].zip"
* where "resourcepack" is a folder at the same level as the directory passed
* into the constructor.
*/
public void inject() {
if (FMLCommonHandler.instance().getEffectiveSide().isClient()) {
try {
if (defaultResourcePacks == null) {
defaultResourcePacks = ReflectionHelper.getPrivateValue(Minecraft.class, Minecraft.getMinecraft(), "defaultResourcePacks", "field_110449_ao", "ap");
}
File dest = new File(dir.getParent() + "/resourcepack/" + zip.getName());
EnderFileUtils.safeDelete(dest);
FileUtils.copyFile(zip, dest);
EnderFileUtils.safeDelete(zip);
writeNewFile(new File(dest.getParent() + "/readme.txt"),
EnderCore.lang.localize("resourcepack.readme") + "\n\n" + EnderCore.lang.localize("resourcepack.readme2"));
defaultResourcePacks.add(new FileResourcePack(dest));
} catch (Exception e) {
EnderCore.logger.error("Failed to inject resource pack for mod {}", modid, e);
}
} else {
EnderCore.logger.info("Skipping resource pack, we are on a dedicated server.");
}
}
示例15: getField
import cpw.mods.fml.relauncher.ReflectionHelper; //导入依赖的package包/类
public static Field getField(Class<?> clazz, String... names) {
try {
Field[] fields = clazz.getDeclaredFields();
for (Field field : fields) {
for (String fieldName : names) {
if (field.getName().equalsIgnoreCase(fieldName)) {
field.setAccessible(true);
return field;
}
}
}
} catch (Exception e) {
throw new ReflectionHelper.UnableToFindFieldException(names, e);
}
return null;
}