Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package melonslise.lambda.client.particle;
- import org.lwjgl.opengl.GL11;
- import melonslise.lambda.LambdaCore;
- import net.minecraft.client.Minecraft;
- import net.minecraft.client.particle.Particle;
- import net.minecraft.client.renderer.BufferBuilder;
- import net.minecraft.client.renderer.GlStateManager;
- import net.minecraft.client.renderer.Tessellator;
- import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
- import net.minecraft.entity.Entity;
- import net.minecraft.util.ResourceLocation;
- import net.minecraft.util.math.Vec3d;
- import net.minecraft.world.World;
- // TODO Use size instead of radius
- // TODO gravity too
- public class ParticleTauGlow extends Particle
- {
- protected static final ResourceLocation texture = new ResourceLocation(LambdaCore.ID, "textures/entities/tau_glow.png");
- protected double radius;
- public ParticleTauGlow(World world, double x, double y, double z, double radius)
- {
- super(world, x, y, z);
- this.radius = radius;
- }
- public ParticleTauGlow(World world, Vec3d point, double radius)
- {
- this(world, point.x, point.y, point.z, radius);
- }
- // TODO Alpha counter
- @Override
- public void onUpdate()
- {
- this.prevPosX = this.posX;
- this.prevPosY = this.posY;
- this.prevPosZ = this.posZ;
- this.particleAlpha -= 0.01F;
- if(this.particleAlpha <= 0F) this.setExpired();
- }
- public int getFXLayer()
- {
- return 3;
- }
- // TODO Shorten with helpers
- // TODO Interpolate
- @Override
- public void renderParticle(BufferBuilder buffer, Entity entity, float partialTick, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ)
- {
- Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
- GL11.glPushAttrib(GL11.GL_LIGHTING_BIT);
- GlStateManager.depthMask(false);
- GlStateManager.enableBlend();
- GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
- GlStateManager.alphaFunc(GL11.GL_GREATER, 0.003921569F);
- GlStateManager.disableLighting();
- GlStateManager.disableDepth();
- Vec3d position = new Vec3d
- (
- this.prevPosX + (this.posX - this.prevPosX) * (double) partialTick,
- this.prevPosY + (this.posY - this.prevPosY) * (double)partialTick,
- this.prevPosZ + (this.posZ - this.prevPosZ) * (double)partialTick
- );
- Vec3d offset[] = new Vec3d[]
- {
- new Vec3d(-(rotationX + rotationXY) * this.radius, -rotationZ * this.radius, -(rotationXZ + rotationYZ) * this.radius),
- new Vec3d((-rotationX + rotationXY) * this.radius, rotationZ * this.radius, (rotationXZ - rotationYZ) * this.radius),
- new Vec3d((rotationX + rotationXY) * this.radius, rotationZ * this.radius, (rotationXZ + rotationYZ) * this.radius),
- new Vec3d((rotationX - rotationXY) * this.radius, -rotationZ * this.radius, (-rotationXZ + rotationYZ) * this.radius)
- };
- /*
- if (this.particleAngle != 0F)
- {
- float f8 = this.particleAngle + (this.particleAngle - this.prevParticleAngle) * partialTick;
- double f9 = Math.cos((double) f8 * 0.5D);
- Vec3d camera = cameraViewDir.scale(Math.sin((double) f8 * 0.5D));
- for (int a = 0; a < 4; ++a)
- {
- offset[a] = camera.scale(2D * offset[a].dotProduct(camera)).add(offset[a].scale(f9 * f9 - camera.dotProduct(camera))).add(camera.crossProduct(offset[a]).scale(2D * f9));
- }
- }
- */
- buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
- buffer.pos(position.x - interpPosX + offset[0].x, position.y - interpPosY + offset[0].y, position.z - interpPosZ + offset[0].z).tex(0D, 0D).color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha).endVertex();
- buffer.pos(position.x - interpPosX + offset[1].x, position.y - interpPosY + offset[1].y, position.z - interpPosZ + offset[1].z).tex(0D, 1D).color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha).endVertex();
- buffer.pos(position.x - interpPosX + offset[2].x, position.y - interpPosY + offset[2].y, position.z - interpPosZ + offset[2].z).tex(1D, 1D).color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha).endVertex();
- buffer.pos(position.x - interpPosX + offset[3].x, position.y - interpPosY + offset[3].y, position.z - interpPosZ + offset[3].z).tex(1D, 0D).color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha).endVertex();
- Tessellator.getInstance().draw();
- GlStateManager.enableDepth();
- GlStateManager.alphaFunc(GL11.GL_GREATER, 0.1F);
- GlStateManager.disableBlend();
- GlStateManager.depthMask(true);
- GL11.glPopAttrib();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment