aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gtPlusPlus/core/client/renderer/RenderMiningExplosivesPrimed.java
blob: 259352367db961f149f6f0e805d721b4e886d2be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
package gtPlusPlus.core.client.renderer;

import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.entity.RenderTNTPrimed;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;

import org.lwjgl.opengl.GL11;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import gtPlusPlus.api.objects.Logger;
import gtPlusPlus.core.block.ModBlocks;
import gtPlusPlus.core.entity.EntityPrimedMiningExplosive;

@SideOnly(Side.CLIENT)
public class RenderMiningExplosivesPrimed extends RenderTNTPrimed {

    private final RenderBlocks blockRenderer = new RenderBlocks();

    public RenderMiningExplosivesPrimed() {
        this.shadowSize = 0.5F;
        Logger.WARNING("Rendering Mining Explosion. 1");
    }

    /**
     * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
     * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic
     * (Render<T extends Entity) and this method has signature public void func_76986_a(T entity, double d, double d1,
     * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
     */
    public void doRender(final EntityPrimedMiningExplosive entity, final double p_76986_2_, final double p_76986_4_,
        final double p_76986_6_, final float p_76986_8_, final float p_76986_9_) {
        Logger.WARNING("Rendering Mining Explosion. 2");
        GL11.glPushMatrix();
        GL11.glTranslatef((float) p_76986_2_, (float) p_76986_4_, (float) p_76986_6_);
        float f2;

        if (((entity.fuse - p_76986_9_) + 1.0F) < 10.0F) {
            f2 = 1.0F - (((entity.fuse - p_76986_9_) + 1.0F) / 10.0F);

            if (f2 < 0.0F) {
                f2 = 0.0F;
            }

            if (f2 > 1.0F) {
                f2 = 1.0F;
            }

            f2 *= f2;
            f2 *= f2;
            final float f3 = 1.0F + (f2 * 0.3F);
            GL11.glScalef(f3, f3, f3);
        }

        f2 = (1.0F - (((entity.fuse - p_76986_9_) + 1.0F) / 100.0F)) * 0.8F;
        this.bindEntityTexture(entity);
        this.blockRenderer.renderBlockAsItem(ModBlocks.blockMiningExplosive, 0, entity.getBrightness(p_76986_9_));

        if (((entity.fuse / 5) % 2) == 0) {
            GL11.glDisable(GL11.GL_TEXTURE_2D);
            GL11.glDisable(GL11.GL_LIGHTING);
            GL11.glEnable(GL11.GL_BLEND);
            GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_DST_ALPHA);
            GL11.glColor4f(1.0F, 1.0F, 1.0F, f2);
            this.blockRenderer.renderBlockAsItem(ModBlocks.blockMiningExplosive, 0, 1.0F);
            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
            GL11.glDisable(GL11.GL_BLEND);
            GL11.glEnable(GL11.GL_LIGHTING);
            GL11.glEnable(GL11.GL_TEXTURE_2D);
        }

        GL11.glPopMatrix();
    }

    /**
     * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
     */
    protected ResourceLocation getEntityTexture(final EntityPrimedMiningExplosive p_110775_1_) {
        return TextureMap.locationBlocksTexture;
    }

    /**
     * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
     */
    @Override
    protected ResourceLocation getEntityTexture(final Entity p_110775_1_) {
        Logger.WARNING("Rendering Mining Explosion. 4");
        return this.getEntityTexture((EntityPrimedMiningExplosive) p_110775_1_);
    }

    /**
     * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
     * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic
     * (Render<T extends Entity) and this method has signature public void func_76986_a(T entity, double d, double d1,
     * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
     */
    @Override
    public void doRender(final Entity p_76986_1_, final double p_76986_2_, final double p_76986_4_,
        final double p_76986_6_, final float p_76986_8_, final float p_76986_9_) {
        Logger.WARNING("Rendering Mining Explosion. 3");
        this.doRender(
            (EntityPrimedMiningExplosive) p_76986_1_,
            p_76986_2_,
            p_76986_4_,
            p_76986_6_,
            p_76986_8_,
            p_76986_9_);
    }
}