Java Code Examples for net.minecraftforge.fml.relauncher.ReflectionHelper.UnableToAccessFieldException

The following are top voted examples for showing how to use net.minecraftforge.fml.relauncher.ReflectionHelper.UnableToAccessFieldException. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: justenoughdimensions   File: CommandTeleportJED.java   View source code 6 votes vote down vote up
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");
        }
    }
}
 
Example 2
Project: paintedbiomes   File: PaintedBiomesEventHandler.java   View source code 6 votes vote down vote up
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);
    }
}
 
Example 3
Project: enderutilities   File: TeleportEntity.java   View source code 6 votes vote down vote up
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");
        }
    }
}
 
Example 4
Project: EnderIO   File: UpgradeRenderManager.java   View source code 6 votes vote down vote up
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);
  }
}
 
Example 5
Project: CustomWorldGen   File: ObfuscationReflectionHelper.java   View source code 5 votes vote down vote up
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;
    }
}
 
Example 6
Project: CustomWorldGen   File: ObfuscationReflectionHelper.java   View source code 5 votes vote down vote up
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;
    }
}
 
Example 7
Project: paintedbiomes   File: PaintedBiomesEventHandler.java   View source code 5 votes vote down vote up
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);
        }
    }
}