Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package io.github.phantamanta44.pcrossbow.client.fx;
- import net.minecraft.client.particle.EntityFX;
- import net.minecraft.client.renderer.Tessellator;
- import net.minecraft.util.Vec3;
- import net.minecraft.world.World;
- import org.lwjgl.opengl.GL11;
- public class EntityLaser extends EntityFX {
- private final Vec3 dir;
- private final double length;
- private final double intensity;
- private final int colour;
- public EntityLaser(World world, Vec3 start, Vec3 end, double intensity, int colour) {
- super(world, start.xCoord, start.yCoord, start.zCoord);
- dir = end.subtract(start).normalize();
- length = start.distanceTo(end);
- this.intensity = intensity;
- this.colour = colour;
- this.particleMaxAge = 5;
- }
- @Override
- public int getFXLayer() {
- return 1;
- }
- @Override
- public void renderParticle(Tessellator tess, float partialTick, float rotX, float rotXZ, float rotZ, float rotYZ, float rotXY) {
- tess.draw();
- GL11.glDisable(GL11.GL_TEXTURE_2D);
- GL11.glDisable(GL11.GL_LIGHTING);
- GL11.glEnable(GL11.GL_BLEND);
- GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
- tess.startDrawingQuads();
- GL11.glPushMatrix();
- GL11.glTranslated(0.5, 0.5, 0.5);
- GL11.glTranslated(
- this.prevPosX + (this.posX - this.prevPosX) * (double)partialTick - interpPosX,
- this.prevPosY + (this.posY - this.prevPosY) * (double)partialTick - interpPosY,
- this.prevPosZ + (this.posZ - this.prevPosZ) * (double)partialTick - interpPosZ);
- GL11.glRotated(90 + Math.atan2(dir.zCoord, dir.xCoord) * 180 / Math.PI, 0, 1, 0);
- GL11.glRotated(Math.atan2(dir.yCoord, dir.zCoord) * 180 / Math.PI, 1, 0, 0);
- tess.setColorRGBA_I(colour, 40);
- double lx = -0.125, ly = -0.125, lz = 0;
- double hx = 0.125, hy = 0.125, hz = length;
- tess.addVertex(hx, hy, hz);
- tess.addVertex(hx, ly, hz);
- tess.addVertex(hx, ly, lz);
- tess.addVertex(hx, hy, lz);
- tess.addVertex(lx, hy, lz);
- tess.addVertex(lx, ly, lz);
- tess.addVertex(lx, ly, hz);
- tess.addVertex(lx, hy, hz);
- tess.addVertex(hx, hy, lz);
- tess.addVertex(lx, hy, lz);
- tess.addVertex(lx, hy, hz);
- tess.addVertex(hx, hy, hz);
- tess.addVertex(hx, ly, hz);
- tess.addVertex(lx, ly, hz);
- tess.addVertex(lx, ly, lz);
- tess.addVertex(hx, ly, lz);
- tess.addVertex(hx, hy, hz);
- tess.addVertex(lx, hy, hz);
- tess.addVertex(lx, ly, hz);
- tess.addVertex(hx, ly, hz);
- tess.draw();
- GL11.glPopMatrix();
- GL11.glDisable(GL11.GL_BLEND);
- GL11.glEnable(GL11.GL_LIGHTING);
- GL11.glEnable(GL11.GL_TEXTURE_2D);
- tess.startDrawingQuads();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement