当前位置: 首页>>代码示例>>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;未经允许,请勿转载。