Search in sources :

Example 1 with UnableToAccessFieldException

use of net.minecraftforge.fml.relauncher.ReflectionHelper.UnableToAccessFieldException in project EnderIO by SleepyTrousers.

the class UpgradeRenderManager method replaceCapeLayer.

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);
    }
}
Also used : AbstractClientPlayer(net.minecraft.client.entity.AbstractClientPlayer) LayerCape(net.minecraft.client.renderer.entity.layers.LayerCape) LayerRenderer(net.minecraft.client.renderer.entity.layers.LayerRenderer) CapeFilterLayer(crazypants.enderio.base.item.darksteel.upgrade.elytra.CapeFilterLayer) UnableToAccessFieldException(net.minecraftforge.fml.relauncher.ReflectionHelper.UnableToAccessFieldException)

Aggregations

CapeFilterLayer (crazypants.enderio.base.item.darksteel.upgrade.elytra.CapeFilterLayer)1 AbstractClientPlayer (net.minecraft.client.entity.AbstractClientPlayer)1 LayerCape (net.minecraft.client.renderer.entity.layers.LayerCape)1 LayerRenderer (net.minecraft.client.renderer.entity.layers.LayerRenderer)1 UnableToAccessFieldException (net.minecraftforge.fml.relauncher.ReflectionHelper.UnableToAccessFieldException)1