本文整理汇总了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);
}
}
}
示例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);
}
}
}
示例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);
}
}
示例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");
}
}
}
示例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
}
}
示例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");
}
}
}
示例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");
}
}
示例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;
}
示例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();
}
}
示例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;
}
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
}
示例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);
}