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


Java ReflectionHelper類代碼示例

本文整理匯總了Java中net.minecraftforge.fml.relauncher.ReflectionHelper的典型用法代碼示例。如果您正苦於以下問題:Java ReflectionHelper類的具體用法?Java ReflectionHelper怎麽用?Java ReflectionHelper使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ReflectionHelper類屬於net.minecraftforge.fml.relauncher包,在下文中一共展示了ReflectionHelper類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: shutupForge

import net.minecraftforge.fml.relauncher.ReflectionHelper; //導入依賴的package包/類
/**
 * Make forge not spew "dangerous alternative prefix" messages in this block.
 */
public static void shutupForge(Runnable op) {
    Logger log = (Logger) FMLLog.log;
    try {
        Object privateConfig = ReflectionHelper.findField(Logger.class, "privateConfig").get(log);
        Field intLevelF = ReflectionHelper.findField(privateConfig.getClass(), "intLevel");
        int intLevel = (int) intLevelF.get(privateConfig);
        intLevelF.set(privateConfig, 299); // disable WARN logging

        try {
            op.run();
        } finally {
            intLevelF.set(privateConfig, intLevel);
        }
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
}
 
開發者ID:DaedalusGame,項目名稱:Soot,代碼行數:21,代碼來源:Nope.java

示例2: makeOurList

import net.minecraftforge.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

示例3: setServerList

import net.minecraftforge.fml.relauncher.ReflectionHelper; //導入依賴的package包/類
private void setServerList(ServerListPublic 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

示例4: setLanServerDetector

import net.minecraftforge.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

示例5: setLanServerList

import net.minecraftforge.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

示例6: setServerListSelector

import net.minecraftforge.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

示例7: getTabLabel

import net.minecraftforge.fml.relauncher.ReflectionHelper; //導入依賴的package包/類
private static String getTabLabel(CreativeTabs tab)
{
    if (tabLabelField == null)
    {
        tabLabelField = ReflectionHelper.findField(CreativeTabs.class, "tabLabel", "field_78034_o", "o");
        tabLabelField.setAccessible(true);
    }

    try
    {
        return (String) tabLabelField.get(tab);
    } catch (IllegalAccessException e)
    {
        e.printStackTrace();
    }

    return null;
}
 
開發者ID:cubex2,項目名稱:customstuff4,代碼行數:19,代碼來源:ItemHelper.java

示例8: onRenderPlayer

import net.minecraftforge.fml.relauncher.ReflectionHelper; //導入依賴的package包/類
@SubscribeEvent
public static void onRenderPlayer(RenderPlayerEvent.Post event)
{
    EntityPlayer player = event.getEntityPlayer();
    String uuid = player.getUUID(player.getGameProfile()).toString();
    if(player instanceof AbstractClientPlayer && UUIDS.contains(uuid) && !done.contains(player))
    {
        AbstractClientPlayer clplayer = (AbstractClientPlayer) player;
        if(clplayer.hasPlayerInfo())
        {
            NetworkPlayerInfo info = ReflectionHelper.getPrivateValue(AbstractClientPlayer.class, clplayer, ObfuscatedNames.PLAYER_INFO);
            Map<MinecraftProfileTexture.Type, ResourceLocation> textures = ReflectionHelper.getPrivateValue(NetworkPlayerInfo.class, info, ObfuscatedNames.PLAYER_TEXTURES);
            ResourceLocation loc = new ResourceLocation("proxyslib", "textures/whoknows/special_cape.png");
            textures.put(MinecraftProfileTexture.Type.CAPE, loc);
            textures.put(MinecraftProfileTexture.Type.ELYTRA, loc);
            done.add(player);
        }
    }
}
 
開發者ID:ProxyNeko,項目名稱:Proxys-Lib,代碼行數:20,代碼來源:SpecialPeopleCapeHandler.java

示例9: onRenderPlayer

import net.minecraftforge.fml.relauncher.ReflectionHelper; //導入依賴的package包/類
@SubscribeEvent
public static void onRenderPlayer(RenderPlayerEvent.Post event)
{
    EntityPlayer player = event.getEntityPlayer();
    String uuid = player.getUUID(player.getGameProfile()).toString();
    if(player instanceof AbstractClientPlayer && UUIDS.contains(uuid) && !done.contains(player))
    {
        AbstractClientPlayer clplayer = (AbstractClientPlayer) player;
        if(clplayer.hasPlayerInfo())
        {
            NetworkPlayerInfo info = ReflectionHelper.getPrivateValue(AbstractClientPlayer.class, clplayer, ObfuscatedNames.PLAYER_INFO);
            Map<MinecraftProfileTexture.Type, ResourceLocation> textures = ReflectionHelper.getPrivateValue(NetworkPlayerInfo.class, info, ObfuscatedNames.PLAYER_TEXTURES);
            ResourceLocation loc = new ResourceLocation("proxyslib", "textures/whoknows/dev_cape.png");
            textures.put(MinecraftProfileTexture.Type.CAPE, loc);
            textures.put(MinecraftProfileTexture.Type.ELYTRA, loc);
            done.add(player);
        }
    }
}
 
開發者ID:ProxyNeko,項目名稱:Proxys-Lib,代碼行數:20,代碼來源:NekoCapeHandler.java

示例10: onUpdate

import net.minecraftforge.fml.relauncher.ReflectionHelper; //導入依賴的package包/類
@Override
   public void onUpdate(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected) {
	
	if (stack.getItemDamage() != 20)
		return;
	
	if (!(entity instanceof EntityPlayer) || (entity instanceof FakePlayer))
		return;
	
	if (itemSlot < ((EntityPlayer)entity).inventory.getHotbarSize()) {
		List<EntityLiving> entities = entity.worldObj.getEntitiesWithinAABB(EntityLiving.class, new AxisAlignedBB(entity.getPosition().add(-range, -range, -range), entity.getPosition().add(range, range, range)));
		
		for (EntityLiving ent : entities) {
			List<EntityAITaskEntry> entries = new ArrayList(ent.tasks.taskEntries);
			entries.addAll(new ArrayList(ent.targetTasks.taskEntries));
			
			for (EntityAITaskEntry entry : entries) {
				if (entry.action instanceof EntityAIAttackRangedBow) {
					makeSkellyShootSlower((EntityAIAttackRangedBow)entry.action);
				}
			}
			if (ent instanceof EntityCreeper)
				ReflectionHelper.setPrivateValue(EntityCreeper.class, (EntityCreeper)ent, 60, this.FUSETIME);
		}
	}
}
 
開發者ID:bafomdad,項目名稱:uniquecrops,代碼行數:27,代碼來源:ItemGeneric.java

示例11: GameData

import net.minecraftforge.fml.relauncher.ReflectionHelper; //導入依賴的package包/類
public GameData()
{
    iBlockRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.BLOCKS, Block.class, new ResourceLocation("minecraft:air"), MIN_BLOCK_ID, MAX_BLOCK_ID, true, BlockCallbacks.INSTANCE, BlockCallbacks.INSTANCE, BlockCallbacks.INSTANCE, BlockCallbacks.INSTANCE);
    iItemRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.ITEMS, Item.class, null, MIN_ITEM_ID, MAX_ITEM_ID, true, ItemCallbacks.INSTANCE, ItemCallbacks.INSTANCE, ItemCallbacks.INSTANCE, ItemCallbacks.INSTANCE);
    iPotionRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.POTIONS, Potion.class, null, MIN_POTION_ID, MAX_POTION_ID, false, PotionCallbacks.INSTANCE, PotionCallbacks.INSTANCE, PotionCallbacks.INSTANCE, null);
    iBiomeRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.BIOMES, Biome.class, null, MIN_BIOME_ID, MAX_BIOME_ID, false, BiomeCallbacks.INSTANCE, BiomeCallbacks.INSTANCE, BiomeCallbacks.INSTANCE, null);
    iSoundEventRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.SOUNDEVENTS, SoundEvent.class, null, MIN_SOUND_ID, MAX_SOUND_ID, false, null, null, null, null);
    ResourceLocation WATER = new ResourceLocation("water");
    iPotionTypeRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.POTIONTYPES, PotionType.class, WATER, MIN_POTIONTYPE_ID, MAX_POTIONTYPE_ID, false, null, null, null, null);
    iEnchantmentRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.ENCHANTMENTS, Enchantment.class, null, MIN_ENCHANTMENT_ID, MAX_ENCHANTMENT_ID, false, null, null, null, null);

    try
    {
        blockField = FinalFieldHelper.makeWritable(ReflectionHelper.findField(ItemBlock.class, "block", "field_150939" + "_a"));
    }
    catch (Exception e)
    {
        FMLLog.log(Level.FATAL, e, "Cannot access the 'block' field from ItemBlock, this is fatal!");
        throw Throwables.propagate(e);
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:22,代碼來源:GameData.java

示例12: findMethod

import net.minecraftforge.fml.relauncher.ReflectionHelper; //導入依賴的package包/類
/** Find a method with multiple method names (old reflection helper) */
public static <E> Method findMethod(Class<? super E> clazz, E instance, String[] methodNames, Class<?>... methodTypes)
{
    Exception failed = null;
    for (String methodName : methodNames)
    {
        try
        {
            Method m = clazz.getDeclaredMethod(methodName, methodTypes);
            m.setAccessible(true);
            return m;
        }
        catch (Exception e)
        {
            failed = e;
        }
    }
    throw new ReflectionHelper.UnableToFindMethodException(methodNames, failed);
}
 
開發者ID:sblectric,項目名稱:AdvancedCombat,代碼行數:20,代碼來源:ACUtils.java

示例13: initialize

import net.minecraftforge.fml.relauncher.ReflectionHelper; //導入依賴的package包/類
public static void initialize()
{
    inLove = ReflectionHelper.findField(EntityAnimal.class, "field_70881_d", "inLove");

    //Standard
    mutationSet.add(new AnimalMutation((world, pos, mother, father) -> spawnBabyAt(world,pos,new EntityCow(world)),100));
    mutationSet.add(new AnimalMutation((world, pos, mother, father) -> spawnBabyAt(world,pos,new EntitySheep(world)),100));
    mutationSet.add(new AnimalMutation((world, pos, mother, father) -> spawnBabyAt(world,pos,new EntityPig(world)),100));
    mutationSet.add(new AnimalMutation((world, pos, mother, father) -> spawnBabyAt(world,pos,new EntityChicken(world)),50)); //Lower chance for egg hatching animal

    //Parent species
    mutationSet.add(new AnimalMutation((world, pos, mother, father) -> spawnBabyAt(world,pos,mother.createChild(mother)),100));
    mutationSet.add(new AnimalMutation((world, pos, mother, father) -> spawnBabyAt(world,pos,father.createChild(father)),100));

    //Abominations
    mutationSet.add(new AnimalMutation((world, pos, mother, father) -> spawnEntityAt(world,pos,new EntitySilverfish(world)),200));
    mutationSet.add(new AnimalMutation((world, pos, mother, father) -> spawnEntityAt(world,pos,new EntityCaveSpider(world)),100));
    mutationSet.add(new AnimalMutation((world, pos, mother, father) -> spawnEntityAt(world,pos,new EntitySlime(world)),50));

    //Enviroment dependent
    mutationSet.add(new AnimalMutation((world, pos, mother, father) -> spawnEntityAt(world,pos,new EntitySquid(world)),0).setCustomWeight(AnimalCrossbreedHandler::getSquidWeight));
    mutationSet.add(new AnimalMutation((world, pos, mother, father) -> spawnBabyAt(world,pos,new EntityWolf(world)),0).setCustomWeight(AnimalCrossbreedHandler::getWolfWeight));
    mutationSet.add(new AnimalMutation((world, pos, mother, father) -> spawnBabyAt(world,pos,new EntityOcelot(world)),0).setCustomWeight(AnimalCrossbreedHandler::getOcelotWeight));
}
 
開發者ID:DaedalusGame,項目名稱:BetterWithAddons,代碼行數:25,代碼來源:AnimalCrossbreedHandler.java

示例14: update

import net.minecraftforge.fml.relauncher.ReflectionHelper; //導入依賴的package包/類
@Override
public void update() {
	World world = entity.getWorld();
	if(!world.isRemote && entity.ticksExisted()==Refs.TPS*5){
		//grab the list of records
		Map<String,ItemRecord> recordMap = ReflectionHelper.getPrivateValue(ItemRecord.class, (ItemRecord)Items.RECORD_13, "RECORDS","field_150928_b");//XXX recheck name when update
		Collection<ItemRecord> records = recordMap.values();
		//select a random number
		Random rand = new Random();
		int idx = rand.nextInt(records.size());
		//grab the record that matches our random number
		Iterator<ItemRecord> it = records.iterator();
		ItemRecord current=it.next();
		for(int i=1;i<idx;i++){
			current = it.next();
		}
		//spawn the record
		Utils.spawnItemCentered(world, getPos(), new ItemStack(current));
		//world.playSoundEffect(getPos().getX(), getPos().getY(), getPos().getZ(), "mob.chicken.plop", 0.5F, 0.8F + (world.rand.nextFloat() - world.rand.nextFloat()));
		world.playSound(null,getPos().getX(), getPos().getY(), getPos().getZ(), SoundEvents.ENTITY_CHICKEN_EGG, SoundCategory.BLOCKS, 0.5F, 0.8F + (world.rand.nextFloat() - world.rand.nextFloat()));
		this.onPatternBroken();//deactivate
	}
}
 
開發者ID:Xilef11,項目名稱:runesofwizardry-classics,代碼行數:24,代碼來源:RuneEntityMusic.java

示例15: getEntityLoot_Table

import net.minecraftforge.fml.relauncher.ReflectionHelper; //導入依賴的package包/類
private List<ItemStack> getEntityLoot_Table(EntityLiving el){
	ResourceLocation location = (ResourceLocation)ReflectionHelper.getPrivateValue(EntityLiving.class, el, "deathLootTable","field_184659_bA");
	if(location==null){
		Method getLT = ReflectionHelper.findMethod(EntityLiving.class,"getLootTable","func_184647_J");
		try {
			location = (ResourceLocation)getLT.invoke(el);
		} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
			RunesofWizardry_Classics.log().error("Exception when trying to get LootTable from entity: "+el.getName(),e);
			return getEntityLoot_Hacky(el);
		}
	}
	if(location==null){
		RunesofWizardry_Classics.log().warn(el.getName()+" does not have a LootTable. falling back to kill method");
		return getEntityLoot_Hacky(el);
	}
	LootTableManager manager = el.world.getLootTableManager();
	LootTable table = manager.getLootTableFromLocation(location);
	return LootUtils.tableToItemStacks(table);
}
 
開發者ID:Xilef11,項目名稱:runesofwizardry-classics,代碼行數:20,代碼來源:RuneResurrection.java


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