summaryrefslogtreecommitdiff
path: root/java/darkknight/jewelrycraft/particles/EntityFlatShadowFX.java
blob: 923947e33a57ea26b98e2618e080061cda58f23f (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
package darkknight.jewelrycraft.particles;

import java.util.Iterator;
import java.util.List;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;

import org.lwjgl.opengl.GL11;

public class EntityFlatShadowFX extends EntityFX
{
    float moteParticleScale;
    
    public EntityFlatShadowFX(World world, double x, double y, double z, float size, float maxAge)
    {
        super(world, x, y, z, 0D, 0D, 0D);        
        particleMaxAge = (int) (28D / (Math.random() * 0.3D + 0.7D) * maxAge);
        particleGravity = 0F;
        motionX = motionY = motionZ = 0;
        particleScale = size;
        noClip = true;
        setSize(0.1F, 0.1F);
    }
    
    @Override
    public void renderParticle(Tessellator tessellator, float partialTicks, float minX, float minY, float minZ, float maxX, float maxZ)
    {
        tessellator.draw();
        ResourceLocation particle = new ResourceLocation("jewelrycraft", "textures/particle/shadows.png");
        Minecraft.getMinecraft().renderEngine.bindTexture(particle);
        tessellator.startDrawingQuads();
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GL11.glDepthMask(false);
        float scale = 1F * particleScale;
        float x = (float) (posX - interpPosX);
        float y = (float) (posX - interpPosY);
        float z = (float) (posZ - interpPosZ);
        tessellator.setColorRGBA_F(0F, 0F, 0F, 1F);
        tessellator.addVertexWithUV(x - minX * scale - maxX * scale, y + minY * scale, z - minZ * scale - maxZ * scale, 0, 0);
        tessellator.addVertexWithUV(x - minX * scale + maxX * scale, y + minY * scale, z - minZ * scale + maxZ * scale, 1, 0);
        tessellator.addVertexWithUV(x + minX * scale + maxX * scale, y + minY * scale, z + minZ * scale + maxZ * scale, 1, 1);
        tessellator.addVertexWithUV(x + minX * scale - maxX * scale, y + minY * scale, z + minZ * scale - maxZ * scale, 0, 1);
        tessellator.draw();
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glDepthMask(true);
        tessellator.startDrawingQuads();
    }
    
    @Override
    public void onUpdate()
    {
        this.prevPosX = this.posX;
        this.prevPosY = this.posY;
        this.prevPosZ = this.posZ;
        motionX = motionY = motionZ = 0;
        
        if (this.particleAge++ >= this.particleMaxAge)
        {
            this.setDead();
        }
    }
    
    public int getFXLayer()
    {
        return 0;
    }
    
}