Files
Electro-Magic-Tools/src/main/java/emt/client/renderer/RenderLaser.java
T

69 lines
2.0 KiB
Java
Raw Normal View History

2016-03-16 17:49:28 +03:00
package emt.client.renderer;
2014-03-29 12:13:50 +01:00
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
2016-03-16 17:49:28 +03:00
2017-01-15 20:26:57 +01:00
import emt.EMT;
import emt.entity.EntityLaser;
2014-04-17 22:27:40 +02:00
public class RenderLaser extends Render {
2014-03-29 12:13:50 +01:00
private static final ResourceLocation laserTexture = new ResourceLocation(EMT.TEXTURE_PATH, "textures/models/lasermodel.png");
2014-03-29 12:13:50 +01:00
2016-04-05 13:41:09 +03:00
@Override
public void doRender(Entity entityLaser, double x, double y, double z, float par8, float pTick) {
2015-12-06 19:47:41 +03:00
this.bindEntityTexture(entityLaser);
GL11.glPushMatrix();
2015-12-13 21:24:42 +03:00
GL11.glTranslated(x, y, z);
GL11.glRotatef(entityLaser.rotationYaw - 90, 0, 1, 0);
GL11.glRotatef(entityLaser.rotationPitch, 0, 0, 1);
2016-04-05 13:41:09 +03:00
Tessellator tess = Tessellator.instance;
2015-12-06 19:47:41 +03:00
byte b0 = 0;
2015-12-13 21:24:42 +03:00
float f2 = 0.4f;
float f3 = 0.7f;
float f4 = (float) (0 + b0 * 10) / 32f;
float f5 = (float) (5 + b0 * 10) / 32f;
2015-12-06 19:47:41 +03:00
float f10 = 0.05625F;
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
2014-03-29 12:13:50 +01:00
2015-12-13 21:24:42 +03:00
GL11.glRotatef(45, 1, 0, 0);
2015-12-06 19:47:41 +03:00
GL11.glScalef(f10, f10, f10);
2015-12-13 21:24:42 +03:00
GL11.glTranslatef(-4, 0, 0);
GL11.glPushAttrib(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_LIGHTING);
2014-03-29 12:13:50 +01:00
2015-12-06 19:47:41 +03:00
for (int i = 0; i < 4; ++i) {
2015-12-13 21:24:42 +03:00
GL11.glRotatef(90, 1, 0, 0);
GL11.glNormal3f(0, 0, f10);
2016-04-05 13:41:09 +03:00
tess.startDrawingQuads();
tess.addVertexWithUV(-8, 0, 0, f2, f4);
tess.addVertexWithUV(8, 0, 0, f3, f4);
tess.addVertexWithUV(8, 4, 0, f3, f5);
tess.addVertexWithUV(-8, 4, 0, f2, f5);
tess.draw();
2015-12-13 21:24:42 +03:00
2016-04-05 13:41:09 +03:00
tess.startDrawingQuads();
tess.addVertexWithUV(8, 0, 0, f2, f4);
tess.addVertexWithUV(-8, 0, 0, f3, f4);
tess.addVertexWithUV(-8, 4, 0, f3, f5);
tess.addVertexWithUV(8, 4, 0, f2, f5);
tess.draw();
2015-12-06 19:47:41 +03:00
}
2015-12-13 21:24:42 +03:00
GL11.glPopAttrib();
2015-12-06 19:47:41 +03:00
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
GL11.glPopMatrix();
}
2014-03-29 12:13:50 +01:00
2015-12-06 19:47:41 +03:00
protected ResourceLocation getArrowTextures(EntityLaser entityLaser) {
return laserTexture;
}
2014-03-29 12:13:50 +01:00
2016-04-05 13:41:09 +03:00
@Override
protected ResourceLocation getEntityTexture(Entity entity) {
return this.getArrowTextures((EntityLaser) entity);
2015-12-06 19:47:41 +03:00
}
2014-03-29 12:13:50 +01:00
}