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


Java ReflectionHelper.getPrivateValue方法代碼示例

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


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

示例1: 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

示例2: 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

示例3: addModDirectory

import net.minecraftforge.fml.relauncher.ReflectionHelper; //導入方法依賴的package包/類
@Override
public void addModDirectory(Path dir) {
	List<IResourcePack> resPacks =
			ReflectionHelper.getPrivateValue(Minecraft.class, Minecraft.getMinecraft(), "field_110449_ao",
					"defaultResourcePacks");
	resPacks.add(new FolderResourcePack(dir.toFile()));
	try (DirectoryStream<Path> dirStream = Files.newDirectoryStream(dir)) {
		for (Path subPath : dirStream) {
			if (Files.isRegularFile(subPath)) {
				if (subPath.toString().endsWith(".zip")) {
					resPacks.add(new FileResourcePack(subPath.toFile()));
				}
			}
		}
	} catch (IOException e) {
		Throwables.propagate(e);
	}
}
 
開發者ID:hea3ven,項目名稱:CommonUtils,代碼行數:19,代碼來源:ResourceScannerClient.java

示例4: process

import net.minecraftforge.fml.relauncher.ReflectionHelper; //導入方法依賴的package包/類
@Override
public void process(ITypesetter out, String arg) throws TruthError {
    if (arg.equalsIgnoreCase("entity")) {
        BiMap<Class<? extends Entity>, EntityRegistry.EntityRegistration> registrationMap;
        registrationMap = ReflectionHelper.getPrivateValue(EntityRegistry.class, EntityRegistry.instance(), "entityClassRegistrations");
        for (EntityRegistry.EntityRegistration reg : registrationMap.values()) {
            out.write("\\u{" + reg.getEntityName() + "}");
            out.write("\\nlRegistered by: " + reg.getContainer().getDisplayVersion());
            out.write("\\nTracking range: " + reg.getTrackingRange());
            out.write("\\nlLocation sync frequency: " + reg.getUpdateFrequency());
            out.write("\\nlSends velocity updates: " + reg.sendsVelocityUpdates());
            out.write("\\nl");
        }
    } else if (arg.equalsIgnoreCase("tileentity")) {
        //See: GameRegistry.registerTileEntity();
        out.write("TODO: too lazy to add an AT just for this...");
    } else {
        for (String s : new String[] {
                "entity",
                "tileentity"
        }) {
            out.write("\\{cgi/registry/" + s + "}{" + s +"}\n\n");
        }
    }
}
 
開發者ID:purpleposeidon,項目名稱:Factorization,代碼行數:26,代碼來源:RegistrationViewer.java

示例5: 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

示例6: removeDragonBossBarHack

import net.minecraftforge.fml.relauncher.ReflectionHelper; //導入方法依賴的package包/類
private void removeDragonBossBarHack(EntityPlayerMP player, WorldProviderEnd provider)
{
    // FIXME 1.9 - Somewhat ugly way to clear the Boss Info stuff when teleporting FROM The End
    DragonFightManager manager = provider.getDragonFightManager();

    if (manager != null)
    {
        try
        {
            BossInfoServer bossInfo = ReflectionHelper.getPrivateValue(DragonFightManager.class, manager, "field_186109_c", "bossInfo");
            if (bossInfo != null)
            {
                bossInfo.removePlayer(player);
            }
        }
        catch (UnableToAccessFieldException e)
        {
            JustEnoughDimensions.logger.warn("tpj: Failed to get DragonFightManager#bossInfo");
        }
    }
}
 
開發者ID:maruohon,項目名稱:justenoughdimensions,代碼行數:22,代碼來源:CommandTeleportJED.java

示例7: process

import net.minecraftforge.fml.relauncher.ReflectionHelper; //導入方法依賴的package包/類
@Override
public void process(ITypesetter out, String arg) throws TruthError {
    try {
        GameRegistry.generateWorld(0, 0, null, null, null);
    } catch (NullPointerException e) {
        // lazy way of making the sortedGeneratorList not be null. Swallow the exception whole.
    }
    List<IWorldGenerator> sortedGeneratorList = ReflectionHelper.getPrivateValue(GameRegistry.class, null, "sortedGeneratorList");
    out.write("\\title{Sorted World Generators}\n\n");
    if (sortedGeneratorList == null) {
        out.write("Failed to load generator list!");
        return;
    }

    for (IWorldGenerator gen : sortedGeneratorList) {
        out.write(gen.toString() + "\n\n");
    }
}
 
開發者ID:purpleposeidon,項目名稱:Factorization,代碼行數:19,代碼來源:WorldgenViewer.java

示例8: getStackWithInventory

import net.minecraftforge.fml.relauncher.ReflectionHelper; //導入方法依賴的package包/類
public static ItemStack getStackWithInventory(TileEntity te) {
	if (Mods.IRONCHESTS.isLoaded() && te != null && te.getWorld() != null && te.getWorld().getBlockState(te.getPos()) != null) {
		IronChestType type = ReflectionHelper.getPrivateValue(TileEntityIronChest.class, (TileEntityIronChest) te, "chestType");
		Item block = Item.getItemFromBlock(te.getWorld().getBlockState(te.getPos()).getBlock());
		ItemStack itemstack = new ItemStack(block, 1, type.ordinal());
		NBTTagCompound nbttagcompound = new NBTTagCompound();
		te.writeToNBT(nbttagcompound);
		itemstack.setTagInfo("BlockEntityTag", nbttagcompound);
		return itemstack;
	}
	return null;
}
 
開發者ID:p455w0rd,項目名稱:EndermanEvolution,代碼行數:13,代碼來源:IronChests.java

示例9: loadTextures

import net.minecraftforge.fml.relauncher.ReflectionHelper; //導入方法依賴的package包/類
@SubscribeEvent
public void loadTextures(TextureStitchEvent.Pre event) {
	
	try {
		Map<String, TextureAtlasSprite> mapRegisteredSprites = ReflectionHelper.getPrivateValue(TextureMap.class, event.getMap(), FIELD);
		for (int i = 1; i < 6; i++)
			mapRegisteredSprites.put("uniquecrops:blocks/invisibilia" + i, new UCInvisibiliaStitch("uniquecrops:blocks/invisibilia" + i));
		mapRegisteredSprites.put("uniquecrops:blocks/dyeplant5", new UCDyePlantStitch("uniquecrops:blocks/dyeplant5"));
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
開發者ID:bafomdad,項目名稱:uniquecrops,代碼行數:13,代碼來源:UCEventHandlerClient.java

示例10: getPrivateValue

import net.minecraftforge.fml.relauncher.ReflectionHelper; //導入方法依賴的package包/類
public static <T, E> T getPrivateValue(Class<? super E> classToAccess, E instance, int fieldIndex)
{
    try
    {
        return ReflectionHelper.getPrivateValue(classToAccess, instance, fieldIndex);
    }
    catch (UnableToAccessFieldException e)
    {
        FMLLog.log(Level.ERROR, e, "There was a problem getting field index %d from %s", fieldIndex, classToAccess.getName());
        throw e;
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:13,代碼來源:ObfuscationReflectionHelper.java

示例11: getIntFromKey

import net.minecraftforge.fml.relauncher.ReflectionHelper; //導入方法依賴的package包/類
public static Integer getIntFromKey(String key){
    Map<String, Integer> keyMap = (Map<String, Integer>) ReflectionHelper.getPrivateValue(Keyboard.class, null, "keyMap");
    for (Map.Entry<String, Integer> entry : keyMap.entrySet()) {
        if (key.equalsIgnoreCase(entry.getKey())) {
            return entry.getValue();
        }
    }
    return null;
}
 
開發者ID:Matts,項目名稱:MacroKey,代碼行數:10,代碼來源:KeyHelper.java

示例12: onModelPost

import net.minecraftforge.fml.relauncher.ReflectionHelper; //導入方法依賴的package包/類
@SubscribeEvent
	public void onModelPost(ModelBakeEvent event)
	{
		if (!Environment.debug())
			return;
		Map<ResourceLocation, ModelStates> map = Maps.newHashMap();
		List<ModelStates> list = Lists.newArrayList();
		Set<ModelResourceLocation> set = ReflectionHelper.getPrivateValue(ModelLoader.class, event.getModelLoader(),
				"missingVariants");
//		IRegistry modelReg = event.modelRegistry;
//		Object missingModel = modelReg.getArgs(MISS);
		for (ModelResourceLocation missing : set)
		{
			ResourceLocation location = new ResourceLocation(missing.getResourceDomain(), missing.getResourcePath());
			if (map.containsKey(location))
				map.get(location).addVariant(missing.getVariant());
			else
			{
				ModelStates temp = new ModelStates(missing);
				map.put(location, temp);
			}
		}
		Gson gson = this.buildGson();
		try
		{
			for (final ModelStates state : list)
				if (state.vars.size() == 1 && state.vars.get(0).equals("inventory"))
					this.writeItem(state, gson);
				else
					this.writeBlock(state, gson);
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}
		standard = null;
	}
 
開發者ID:InfinityStudio,項目名稱:InspiringWorld,代碼行數:38,代碼來源:ModelReporter.java

示例13: getMaterials

import net.minecraftforge.fml.relauncher.ReflectionHelper; //導入方法依賴的package包/類
private static Set<ResourceLocation> getMaterials(IResourcePack resPack, String name) {
	if (resPack instanceof FolderResourcePack) {
		File rootDir =
				ReflectionHelper.getPrivateValue(AbstractResourcePack.class, (FolderResourcePack) resPack,
						"field_110597_b", "resourcePackFile");
		return getResourcesFromDir(Paths.get(rootDir.toString()), name);
	} else if (resPack instanceof FileResourcePack) {
		ZipFile packFile = getZipFromResPack((FileResourcePack) resPack);
		return getResourcesFromZip(packFile, name);
	} else
		return Sets.newHashSet();
}
 
開發者ID:hea3ven,項目名稱:CommonUtils,代碼行數:13,代碼來源:ResourceScannerClient.java

示例14: find

import net.minecraftforge.fml.relauncher.ReflectionHelper; //導入方法依賴的package包/類
private Iterable<Object> find(String className, String fieldName) {
    try {
        Class compost = ReflectionHelper.getClass(getClass().getClassLoader(), className);
        return (Iterable<Object>) ReflectionHelper.getPrivateValue(compost, null, fieldName);
    } catch (Throwable t) {
        Core.logWarning("Couldn't find erebus recipe: " + className + "." + fieldName);
        t.printStackTrace();
        return null;
    }
}
 
開發者ID:purpleposeidon,項目名稱:Factorization,代碼行數:11,代碼來源:Compat_erebus.java

示例15: addVanillaBrewingRecipes

import net.minecraftforge.fml.relauncher.ReflectionHelper; //導入方法依賴的package包/類
public void addVanillaBrewingRecipes(ArrayList<DrawableRecipe> recipes) {
    ArrayList<ItemStack> ingredients = new ArrayList<ItemStack>();

    ArrayList<Object> typeConversions = ReflectionHelper.getPrivateValue(PotionHelper.class, null, 0);
    ArrayList<Object> itemConversions = ReflectionHelper.getPrivateValue(PotionHelper.class, null, 1);

    addIngredients(ingredients, typeConversions);
    addIngredients(ingredients, itemConversions);

    ArrayList<ItemStack> knownPotions = new ArrayList<ItemStack>();
    ItemStack waterBottle = PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), PotionTypes.WATER);
    knownPotions.add(waterBottle);

    int brewingStep = 1;
    boolean foundNewPotions;
    do {
        List<ItemStack> newPotions = getNewPotions(knownPotions, ingredients, recipes);
        foundNewPotions = !newPotions.isEmpty();
        knownPotions.addAll(newPotions);

        brewingStep++;
        if (brewingStep > 100) {
            FMLCommonHandler.instance().raiseException(null, "Calculation of vanilla brewing recipes is broken, aborting after 100 brewing steps.", false);
            return;
        }
    } while (foundNewPotions);
}
 
開發者ID:Creysys,項目名稱:GuideBook,代碼行數:28,代碼來源:RecipeHandlerBrewing.java


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