Search in sources :

Example 1 with LayerRenderer

use of net.minecraft.client.renderer.entity.layers.LayerRenderer in project Galacticraft by micdoodle8.

the class RenderPlayerGC method addGCLayers.

private void addGCLayers() {
    Field f1 = null;
    Field f2 = null;
    Field f3 = null;
    try {
        f1 = LayerArmorBase.class.getDeclaredField(GCCoreUtil.isDeobfuscated() ? "renderer" : "field_177190_a");
        f1.setAccessible(true);
    } catch (Exception ignore) {
    }
    // The following code removes the vanilla skull and item layer renderers and replaces them with the Galacticraft ones
    int itemLayerIndex = -1;
    int skullLayerIndex = -1;
    for (int i = 0; i < this.layerRenderers.size(); i++) {
        LayerRenderer layer = this.layerRenderers.get(i);
        if (layer instanceof LayerHeldItem) {
            itemLayerIndex = i;
        }
        if (layer instanceof LayerArmorBase) {
            if (f1 != null) {
                try {
                    f1.set(layer, this);
                } catch (Exception ignore) {
                }
            }
        } else if (layer instanceof LayerCustomHead) {
            skullLayerIndex = i;
        }
    }
    if (skullLayerIndex >= 0) {
        this.setLayer(skullLayerIndex, new LayerCustomHead(this.getMainModel().bipedHead));
    }
    if (itemLayerIndex >= 0 && !ConfigManagerCore.disableVehicleCameraChanges) {
        this.setLayer(itemLayerIndex, new LayerHeldItemGC(this));
    }
    this.addLayer(new LayerOxygenTanks(this));
    this.addLayer(new LayerOxygenGear(this));
    this.addLayer(new LayerOxygenMask(this));
    this.addLayer(new LayerOxygenParachute(this));
    this.addLayer(new LayerFrequencyModule(this));
    if (GalacticraftCore.isPlanetsLoaded) {
        this.addLayer(new LayerThermalPadding(this));
        RenderPlayerGC.thermalPaddingTexture0 = new ResourceLocation("galacticraftplanets", "textures/misc/thermal_padding_0.png");
        RenderPlayerGC.thermalPaddingTexture1 = new ResourceLocation("galacticraftplanets", "textures/misc/thermal_padding_1.png");
        RenderPlayerGC.thermalPaddingTexture1_T2 = new ResourceLocation("galacticraftplanets", "textures/misc/thermal_padding_t2_1.png");
        RenderPlayerGC.heatShieldTexture = new ResourceLocation("galacticraftplanets", "textures/misc/shield.png");
        this.addLayer(new LayerShield(this));
    }
}
Also used : LayerHeldItem(net.minecraft.client.renderer.entity.layers.LayerHeldItem) LayerRenderer(net.minecraft.client.renderer.entity.layers.LayerRenderer) LayerCustomHead(net.minecraft.client.renderer.entity.layers.LayerCustomHead) Field(java.lang.reflect.Field) ResourceLocation(net.minecraft.util.ResourceLocation) LayerArmorBase(net.minecraft.client.renderer.entity.layers.LayerArmorBase)

Example 2 with LayerRenderer

use of net.minecraft.client.renderer.entity.layers.LayerRenderer 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

LayerRenderer (net.minecraft.client.renderer.entity.layers.LayerRenderer)2 CapeFilterLayer (crazypants.enderio.base.item.darksteel.upgrade.elytra.CapeFilterLayer)1 Field (java.lang.reflect.Field)1 AbstractClientPlayer (net.minecraft.client.entity.AbstractClientPlayer)1 LayerArmorBase (net.minecraft.client.renderer.entity.layers.LayerArmorBase)1 LayerCape (net.minecraft.client.renderer.entity.layers.LayerCape)1 LayerCustomHead (net.minecraft.client.renderer.entity.layers.LayerCustomHead)1 LayerHeldItem (net.minecraft.client.renderer.entity.layers.LayerHeldItem)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 UnableToAccessFieldException (net.minecraftforge.fml.relauncher.ReflectionHelper.UnableToAccessFieldException)1