當前位置: 首頁>>代碼示例>>Java>>正文


Java ReflectionHelper類代碼示例

本文整理匯總了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);
    }
}
 
開發者ID:CreeperHost,項目名稱:CreeperHostGui,代碼行數:21,代碼來源:ServerSelectionListPublic.java

示例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);
    }
}
 
開發者ID:CreeperHost,項目名稱:CreeperHostGui,代碼行數:19,代碼來源:GuiMultiplayerPublic.java

示例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);
    }
}
 
開發者ID:CreeperHost,項目名稱:CreeperHostGui,代碼行數:19,代碼來源:GuiMultiplayerPublic.java

示例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);
    }
}
 
開發者ID:CreeperHost,項目名稱:CreeperHostGui,代碼行數:19,代碼來源:GuiMultiplayerPublic.java

示例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);
    }
}
 
開發者ID:CreeperHost,項目名稱:CreeperHostGui,代碼行數:19,代碼來源:GuiMultiplayerPublic.java

示例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);
}
 
開發者ID:jm-organization,項目名稱:connor41-etfuturum2,代碼行數:21,代碼來源:EntityRabbit.java

示例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();
		}
	}
}
 
開發者ID:jm-organization,項目名稱:connor41-etfuturum2,代碼行數:25,代碼來源:EntityTippedArrow.java

示例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) {
		}
}
 
開發者ID:jm-organization,項目名稱:connor41-etfuturum2,代碼行數:25,代碼來源:RabbitFoot.java

示例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);
}
 
開發者ID:sameer,項目名稱:ExtraUtilities,代碼行數:17,代碼來源:BlockColor.java

示例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();
    }
}
 
開發者ID:sameer,項目名稱:ExtraUtilities,代碼行數:18,代碼來源:CommandDumpLocalization.java

示例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();
		}
	}
}
 
開發者ID:roryclaasen,項目名稱:RorysMod,代碼行數:22,代碼來源:CoreHelper.java

示例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);
}
 
開發者ID:allaryin,項目名稱:FairyFactions,代碼行數:21,代碼來源:EntityFairy.java

示例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;
	}
}
 
開發者ID:allaryin,項目名稱:FairyFactions,代碼行數:26,代碼來源:FairyJob.java

示例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.");
  }
}
 
開發者ID:SleepyTrousers,項目名稱:EnderCore,代碼行數:30,代碼來源:ResourcePackAssembler.java

示例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;
}
 
開發者ID:Lomeli12,項目名稱:WIIEMC,代碼行數:17,代碼來源:ObfUtil.java


注:本文中的cpw.mods.fml.relauncher.ReflectionHelper類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。