2021-01-24 19:52:54 +01:00

96 lines
3.7 KiB
Java

package com.hbm.particle;
import org.lwjgl.opengl.GL11;
import com.hbm.lib.RefStrings;
import com.hbm.main.ResourceManager;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.particle.EntityFX;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
@SideOnly(Side.CLIENT)
public class ParticleRift extends EntityFX {
private static final ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/particle/hadron.png");
private TextureManager theRenderEngine;
public ParticleRift(TextureManager texman, World world, double x, double y, double z) {
super(world, x, y, z);
this.theRenderEngine = texman;
this.particleMaxAge = 10;
}
public int getFXLayer() {
return 3;
}
public void renderParticle(Tessellator tess, float interp, float x, float y, float z, float tx, float tz) {
this.theRenderEngine.bindTexture(texture);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_BLEND);
GL11.glAlphaFunc(GL11.GL_GREATER, 0);
GL11.glDepthMask(false);
OpenGlHelper.glBlendFunc(GL11.GL_ONE_MINUS_DST_COLOR, GL11.GL_ONE_MINUS_SRC_COLOR, 1, 0);
RenderHelper.disableStandardItemLighting();
float pX = (float) (this.prevPosX + (this.posX - this.prevPosX) * (double) interp - interpPosX);
float pY = (float) (this.prevPosY + (this.posY - this.prevPosY) * (double) interp - interpPosY);
float pZ = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) interp - interpPosZ);
float scale = (this.particleAge + interp) * 0.5F;
GL11.glDisable(GL11.GL_TEXTURE_2D);
/*tess.startDrawingQuads();
tess.setNormal(0.0F, 1.0F, 0.0F);
tess.setBrightness(240);
this.particleAlpha = 1 - (((float)this.particleAge + interp) / (float)this.particleMaxAge);
float scale = (this.particleAge + interp) * 0.05F;
tess.setColorRGBA_F(1.0F, 1.0F, 1.0F, this.particleAlpha);
float pX = (float) (this.prevPosX + (this.posX - this.prevPosX) * (double) interp - interpPosX);
float pY = (float) (this.prevPosY + (this.posY - this.prevPosY) * (double) interp - interpPosY);
float pZ = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) interp - interpPosZ);
tess.addVertexWithUV((double)(pX - x * scale - tx * scale), (double)(pY - y * scale), (double)(pZ - z * scale - tz * scale), 1, 1);
tess.addVertexWithUV((double)(pX - x * scale + tx * scale), (double)(pY + y * scale), (double)(pZ - z * scale + tz * scale), 1, 0);
tess.addVertexWithUV((double)(pX + x * scale + tx * scale), (double)(pY + y * scale), (double)(pZ + z * scale + tz * scale), 0, 0);
tess.addVertexWithUV((double)(pX + x * scale - tx * scale), (double)(pY - y * scale), (double)(pZ + z * scale - tz * scale), 0, 1);
tess.draw();*/
GL11.glPushMatrix();
GL11.glTranslated(pX, pY, pZ);
GL11.glColor4f(1F, 1F, 1F, 1F);
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glScalef(scale, scale, scale);
ResourceManager.sphere_uv.renderAll();
GL11.glScalef(1.02F, 1.02F, 1.02F);
ResourceManager.sphere_uv.renderAll();
GL11.glScalef(1.05F, 1.05F, 1.05F);
ResourceManager.sphere_uv.renderAll();
GL11.glScalef(1.02F, 1.02F, 1.02F);
ResourceManager.sphere_uv.renderAll();
GL11.glScalef(1.05F, 1.05F, 1.05F);
ResourceManager.sphere_uv.renderAll();
GL11.glPopMatrix();
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glPolygonOffset(0.0F, 0.0F);
OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
GL11.glEnable(GL11.GL_LIGHTING);
}
}