mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-24 22:04:49 +00:00
Get lasers rendering. I've yet to proxy it off, so THIS WILL CRASH DEDICATED SERVERS
This commit is contained in:
1 parent
733da7396f
commit
e35a673c8b
3 files changed
+99
-4
No files matched your search
@@ -0,0 +1,91 @@
|
||||
package mekanism.client.entity;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.api.Pos3D;
|
||||
import mekanism.client.render.MekanismRenderer;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.particle.EntityFX;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class EntityLaser extends EntityFX
|
||||
{
|
||||
double length;
|
||||
ForgeDirection direction;
|
||||
|
||||
public EntityLaser(World world, Coord4D start, Coord4D end, ForgeDirection direction)
|
||||
{
|
||||
super(world, (start.xCoord + end.xCoord)/2D + 0.5D, (start.yCoord + end.yCoord)/2D + 0.5D, (start.zCoord+end.zCoord)/2D + 0.5D);
|
||||
particleMaxAge = 1;
|
||||
particleRed = 1;
|
||||
particleGreen = 0;
|
||||
particleBlue = 0;
|
||||
particleAlpha = 0.3F;
|
||||
particleScale = 0.1F;
|
||||
length = new Pos3D(end).distance(new Pos3D(start));
|
||||
this.direction = direction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderParticle(Tessellator tessellator, float partialTick, float rotationX, float rotationXZ, float rotationZ, float rotationYZ, float rotationXY)
|
||||
{
|
||||
tessellator.draw();
|
||||
|
||||
GL11.glPushMatrix();
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation("mekanism", "particles/laser.png"));
|
||||
|
||||
float newX = (float)(this.prevPosX + (this.posX - this.prevPosX) * (double)partialTick - interpPosX);
|
||||
float newY = (float)(this.prevPosY + (this.posY - this.prevPosY) * (double)partialTick - interpPosY);
|
||||
float newZ = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * (double)partialTick - interpPosZ);
|
||||
|
||||
GL11.glTranslatef(newX, newY, newZ);
|
||||
|
||||
switch(direction)
|
||||
{
|
||||
case UP:
|
||||
case DOWN:
|
||||
default:
|
||||
break;
|
||||
case WEST:
|
||||
case EAST:
|
||||
GL11.glRotated(90, 0, 0, 1);
|
||||
break;
|
||||
case NORTH:
|
||||
case SOUTH:
|
||||
GL11.glRotated(90, 1, 0, 0);
|
||||
break;
|
||||
}
|
||||
GL11.glRotated(45, 0, 1, 0);
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setColorRGBA_F(particleRed, particleGreen, particleBlue, particleAlpha);
|
||||
tessellator.addVertexWithUV(-particleScale, -length/2, 0, 0, 0);
|
||||
tessellator.addVertexWithUV(-particleScale, length/2, 0, 0, 1);
|
||||
tessellator.addVertexWithUV(particleScale, length/2, 0, 1, 1);
|
||||
tessellator.addVertexWithUV(particleScale, -length/2, 0, 1, 0);
|
||||
tessellator.draw();
|
||||
|
||||
GL11.glRotated(90, 0, 1, 0);
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setColorRGBA_F(particleRed, particleGreen, particleBlue, particleAlpha);
|
||||
tessellator.addVertexWithUV(-particleScale, -length/2, 0, 0, 0);
|
||||
tessellator.addVertexWithUV(-particleScale, length/2, 0, 0, 1);
|
||||
tessellator.addVertexWithUV(particleScale, length/2, 0, 1, 1);
|
||||
tessellator.addVertexWithUV(particleScale, -length/2, 0, 1, 0);
|
||||
tessellator.draw();
|
||||
|
||||
GL11.glPopMatrix();
|
||||
|
||||
Minecraft.getMinecraft().renderEngine.bindTexture(MekanismRenderer.getBlocksTexture());
|
||||
tessellator.startDrawingQuads();
|
||||
}
|
||||
|
||||
public int getFXLayer()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user