package uk.co.wehavecookies56.kk.client.fx;
import org.lwjgl.opengl.GL11;
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.VertexBuffer;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
public class EntityParticleFXTest extends Particle {
ResourceLocation texture;
public EntityParticleFXTest (ResourceLocation texture, World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn, float alpha) {
super(worldIn, xCoordIn, yCoordIn, zCoordIn, xSpeedIn, ySpeedIn, zSpeedIn);
this.texture = texture;
double newrand = (float) Math.random();
setGravity(.005F);
setScale(5F);
setMaxAge(10);
setAlphaF(alpha);
//setRBGColorF(0x255, 0x0, 0x0);
}
@Override
public void renderParticle (VertexBuffer worldRenderer, Entity entityIn, float partialTicks, float par3, float par4, float par5, float par6, float par7) {
Minecraft.getMinecraft().renderEngine.bindTexture(texture);
Tessellator tess = Tessellator.getInstance();
GL11.glDepthMask(false);
GL11.glEnable(GL11.GL_BLEND);
GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glAlphaFunc(GL11.GL_GREATER, 0.003921569F);
worldRenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
float scale = 0.1F*particleScale;
float x = (float)(prevPosX + (posX - prevPosX) * partialTicks - interpPosX);
float y = (float)(prevPosY + (posY - prevPosY) * partialTicks - interpPosY);
float z = (float)(prevPosZ + (posZ - prevPosZ) * partialTicks - interpPosZ);
worldRenderer.pos(x - par3 * scale - par6 * scale, y - par4 * scale, z - par5 * scale - par7 * scale).tex(0, 0).color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha).endVertex();
worldRenderer.pos(x - par3 * scale + par6 * scale, y + par4 * scale, z - par5 * scale + par7 * scale).tex(1, 0).color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha).endVertex();
worldRenderer.pos(x + par3 * scale + par6 * scale, y + par4 * scale, z + par5 * scale + par7 * scale).tex(1, 1).color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha).endVertex();
worldRenderer.pos(x + par3 * scale - par6 * scale, y - par4 * scale, z + par5 * scale - par7 * scale).tex(0, 1).color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha).endVertex();
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 128.0F, 128.0F);
tess.draw();
GL11.glDisable(GL11.GL_BLEND);
GL11.glDepthMask(true);
GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
}
public EntityParticleFXTest setGravity(float gravity){
particleGravity = gravity;
return this;
}
public EntityParticleFXTest setScale(float scale){
particleScale = scale;
return this;
}
@Override
public int getBrightnessForRender(float p_189214_1_) {
return 100;
}
@Override
public int getFXLayer () {
return 3;
}
}