Java 类net.minecraftforge.fml.relauncher.ReflectionHelper.UnableToAccessFieldException 实例源码

项目:justenoughdimensions    文件:CommandTeleportJED.java   
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");
        }
    }
}
项目:paintedbiomes    文件:PaintedBiomesEventHandler.java   
private void overrideBiomeProvider(int dimension, World world)
{
    // Don't accidentally re-wrap our own BiomeProvider...
    if (world.getBiomeProvider() instanceof BiomeProviderPaintedBiomes)
    {
        return;
    }

    PaintedBiomes.logger.info("Wrapping the BiomeProvider (of type {}) of dimension {} with {}",
            world.getBiomeProvider().getClass().getName(), dimension, BiomeProviderPaintedBiomes.class.getName());

    try
    {
        // Re-initialize the ImageHandler when a world loads, to update config values etc.
        ImageHandler imageHandler = ImageHandler.getImageHandler(dimension).init(world.getSeed());

        BiomeProvider newBiomeProvider = new BiomeProviderPaintedBiomes(world, world.getBiomeProvider(), imageHandler);
        ReflectionHelper.setPrivateValue(WorldProvider.class, world.provider, newBiomeProvider, "field_76578_c", "biomeProvider");
    }
    catch (UnableToAccessFieldException e)
    {
        PaintedBiomes.logger.error("Failed to wrap the BiomeProvider of dimension " + dimension);
    }
}
项目:enderutilities    文件:TeleportEntity.java   
private static void removeDragonBossBarHack(EntityPlayerMP player, WorldProviderEnd provider)
{
    // 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)
        {
            EnderUtilities.logger.warn("TP: Failed to get DragonFightManager#bossInfo");
        }
    }
}
项目:EnderIO    文件:UpgradeRenderManager.java   
private static void replaceCapeLayer(@Nonnull RenderPlayer renderLivingBase) {
  try {
    List<LayerRenderer<AbstractClientPlayer>> value = ReflectionHelper.getPrivateValue(RenderLivingBase.class, renderLivingBase, "layerRenderers",
        "field_177097_h");
    if (value != null) {
      LayerRenderer<AbstractClientPlayer> capeLayer = null;
      for (LayerRenderer<AbstractClientPlayer> layerRenderer : value) {
        if (layerRenderer instanceof LayerCape && !(layerRenderer instanceof CapeFilterLayer)) {
          capeLayer = layerRenderer;
          break;
        }
      }
      if (capeLayer != null) {
        renderLivingBase.addLayer(new CapeFilterLayer(capeLayer));
        value.remove(capeLayer);
      }
    }
  } catch (UnableToAccessFieldException e) {
    Log.warn("Unable to access RenderLivingBase.layerRenderers, reason: " + e);
  }
}
项目:CustomWorldGen    文件:ObfuscationReflectionHelper.java   
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;
    }
}
项目:CustomWorldGen    文件:ObfuscationReflectionHelper.java   
public static <T, E> void setPrivateValue(Class<? super T> classToAccess, T instance, E value, int fieldIndex)
{
    try
    {
        ReflectionHelper.setPrivateValue(classToAccess, instance, value, fieldIndex);
    }
    catch (UnableToAccessFieldException e)
    {
        FMLLog.log(Level.ERROR, e, "There was a problem setting field index %d on type %s", fieldIndex, classToAccess.getName());
        throw e;
    }
}
项目:paintedbiomes    文件:PaintedBiomesEventHandler.java   
private void overrideChunkProvider(int dimension, World world)
{
    Configs conf = Configs.getConfig(dimension);

    if (conf.overrideChunkProvider && world instanceof WorldServer)
    {
        IChunkGenerator newChunkProvider = this.getNewChunkProvider(world, conf.chunkProviderType, conf.chunkProviderOptions);

        if (newChunkProvider == null)
        {
            PaintedBiomes.logger.warn("Invalid/unknown ChunkProvider type '{}'", conf.chunkProviderType);
            return;
        }

        PaintedBiomes.logger.info("Attempting to override the ChunkProvider (of type {}) of dimension {} with {}",
                ((ChunkProviderServer)world.getChunkProvider()).chunkGenerator.getClass().getName(),
                dimension, newChunkProvider.getClass().getName());

        try
        {
            ReflectionHelper.setPrivateValue(ChunkProviderServer.class, (ChunkProviderServer)world.getChunkProvider(),
                    newChunkProvider, "field_186029_c", "chunkGenerator");
        }
        catch (UnableToAccessFieldException e)
        {
            PaintedBiomes.logger.warn("Failed to override the ChunkProvider for dimension {} with {}",
                    dimension, newChunkProvider.getClass().getName(), e);
        }
    }
}