2016-03-16 17:49:28 +03:00
|
|
|
package emt.client.renderer;
|
2015-12-13 21:24:42 +03:00
|
|
|
|
2016-05-23 16:58:12 +03:00
|
|
|
import emt.EMT;
|
2016-03-16 17:49:28 +03:00
|
|
|
import emt.entity.EntityShield;
|
2015-12-16 14:47:38 +03:00
|
|
|
import net.minecraft.client.Minecraft;
|
2016-04-03 20:23:55 +03:00
|
|
|
import net.minecraft.client.renderer.GLAllocation;
|
2015-12-13 21:24:42 +03:00
|
|
|
import net.minecraft.client.renderer.Tessellator;
|
|
|
|
|
import net.minecraft.client.renderer.entity.Render;
|
|
|
|
|
import net.minecraft.entity.Entity;
|
|
|
|
|
import net.minecraft.util.MathHelper;
|
|
|
|
|
import net.minecraft.util.ResourceLocation;
|
2017-01-09 09:46:35 +01:00
|
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
|
import org.lwjgl.opengl.GL12;
|
|
|
|
|
|
|
|
|
|
import static org.lwjgl.opengl.GL11.*;
|
2015-12-13 21:24:42 +03:00
|
|
|
|
|
|
|
|
public class RenderShield extends Render {
|
2016-05-23 16:58:12 +03:00
|
|
|
private static final ResourceLocation shieldTexture = new ResourceLocation(EMT.TEXTURE_PATH, "textures/models/shield.png");
|
2016-04-03 20:23:55 +03:00
|
|
|
static int glCallList;
|
2016-03-17 18:25:51 +03:00
|
|
|
|
|
|
|
|
static {
|
2016-04-03 20:23:55 +03:00
|
|
|
glCallList = GLAllocation.generateDisplayLists(3);
|
|
|
|
|
GL11.glPushMatrix();
|
|
|
|
|
GL11.glNewList(glCallList, GL11.GL_COMPILE);
|
|
|
|
|
|
|
|
|
|
Tessellator tessellator = Tessellator.instance;
|
|
|
|
|
|
2015-12-14 19:32:25 +03:00
|
|
|
float sin1;
|
|
|
|
|
float cos1;
|
2016-03-17 18:25:51 +03:00
|
|
|
|
2015-12-14 19:32:25 +03:00
|
|
|
float sin2;
|
|
|
|
|
float cos2;
|
2016-03-17 18:25:51 +03:00
|
|
|
|
2016-04-03 20:23:55 +03:00
|
|
|
float hsin1 = -1;
|
|
|
|
|
float hcos1 = 0;
|
2016-03-17 18:25:51 +03:00
|
|
|
|
2015-12-14 19:32:25 +03:00
|
|
|
float hsin2;
|
|
|
|
|
float hcos2;
|
2016-03-17 18:25:51 +03:00
|
|
|
|
2016-04-03 20:23:55 +03:00
|
|
|
tessellator.startDrawingQuads();
|
|
|
|
|
for (float h = -90; h < 90; h += 15) {
|
2015-12-14 19:32:25 +03:00
|
|
|
sin1 = 0;
|
|
|
|
|
cos1 = 1;
|
2016-03-17 18:25:51 +03:00
|
|
|
|
2015-12-14 19:32:25 +03:00
|
|
|
hsin2 = MathHelper.sin((float) Math.toRadians(h + 15));
|
|
|
|
|
hcos2 = MathHelper.cos((float) Math.toRadians(h + 15));
|
2016-03-17 18:25:51 +03:00
|
|
|
|
2015-12-13 21:24:42 +03:00
|
|
|
for (float angle = 0; angle < 360; angle += 15) {
|
2015-12-14 19:32:25 +03:00
|
|
|
sin2 = MathHelper.sin((float) Math.toRadians(angle + 15));
|
|
|
|
|
cos2 = MathHelper.cos((float) Math.toRadians(angle + 15));
|
2016-03-17 18:25:51 +03:00
|
|
|
|
2016-04-03 20:23:55 +03:00
|
|
|
tessellator.addVertexWithUV(sin1 * hcos1 * 2, hsin1 * 2, cos1 * hcos1 * 2, 1, 1);
|
|
|
|
|
tessellator.addVertexWithUV(sin1 * hcos2 * 2, hsin2 * 2, cos1 * hcos2 * 2, 1, 0);
|
|
|
|
|
tessellator.addVertexWithUV(sin2 * hcos2 * 2, hsin2 * 2, cos2 * hcos2 * 2, 0, 0);
|
|
|
|
|
tessellator.addVertexWithUV(sin2 * hcos1 * 2, hsin1 * 2, cos2 * hcos1 * 2, 0, 1);
|
2016-03-17 18:25:51 +03:00
|
|
|
|
2015-12-14 19:32:25 +03:00
|
|
|
sin1 = sin2;
|
|
|
|
|
cos1 = cos2;
|
2015-12-13 21:24:42 +03:00
|
|
|
}
|
2016-03-17 18:25:51 +03:00
|
|
|
|
2015-12-14 19:32:25 +03:00
|
|
|
hsin1 = hsin2;
|
|
|
|
|
hcos1 = hcos2;
|
2015-12-13 21:24:42 +03:00
|
|
|
}
|
2016-04-03 20:23:55 +03:00
|
|
|
tessellator.draw();
|
|
|
|
|
|
|
|
|
|
GL11.glEndList();
|
2015-12-14 19:56:55 +03:00
|
|
|
}
|
|
|
|
|
|
2016-04-05 13:41:09 +03:00
|
|
|
@Override
|
2015-12-16 14:47:38 +03:00
|
|
|
public void doRender(Entity entityShield, double x, double y, double z, float par8, float par9) {
|
|
|
|
|
this.bindEntityTexture(entityShield);
|
2016-03-17 18:25:51 +03:00
|
|
|
|
2016-03-16 17:49:28 +03:00
|
|
|
glEnable(GL_ALPHA_TEST);
|
|
|
|
|
glAlphaFunc(GL_GREATER, 0);
|
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
|
|
|
glPushAttrib(GL_LIGHTING);
|
|
|
|
|
glDisable(GL_LIGHTING);
|
|
|
|
|
glDisable(GL_CULL_FACE);
|
2016-03-17 18:25:51 +03:00
|
|
|
|
2016-03-16 17:49:28 +03:00
|
|
|
glPushMatrix();
|
2016-04-03 20:23:55 +03:00
|
|
|
if (((EntityShield) entityShield).owner != null && !Minecraft.getMinecraft().thePlayer.getDisplayName().equals(((EntityShield) entityShield).owner.getDisplayName())) {
|
2016-03-16 17:49:28 +03:00
|
|
|
glTranslated(x, y, z);
|
2015-12-14 19:56:55 +03:00
|
|
|
}
|
2016-04-03 20:23:55 +03:00
|
|
|
|
2016-04-04 14:49:42 +03:00
|
|
|
glCallList(this.glCallList);
|
2016-03-17 18:25:51 +03:00
|
|
|
|
2016-03-16 17:49:28 +03:00
|
|
|
glPopMatrix();
|
|
|
|
|
glPopAttrib();
|
|
|
|
|
glDisable(GL12.GL_RESCALE_NORMAL);
|
2015-12-13 21:24:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected ResourceLocation getEntityTexture(Entity texture) {
|
|
|
|
|
return shieldTexture;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|