BiomesOPlenty/src/minecraft/biomesoplenty/items/projectiles/RenderDart.java

95 lines
3.8 KiB
Java
Raw Normal View History

2013-05-11 12:51:16 +00:00
package biomesoplenty.items.projectiles;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.resources.ResourceLocation;
2013-05-11 12:51:16 +00:00
import net.minecraft.entity.Entity;
import net.minecraft.util.MathHelper;
2013-05-16 13:50:12 +00:00
2013-05-11 12:51:16 +00:00
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
2013-05-16 13:50:12 +00:00
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
2013-05-11 12:51:16 +00:00
@SideOnly(Side.CLIENT)
public class RenderDart extends Render
{
2013-07-02 11:30:11 +00:00
public void renderDart(EntityDart par1EntityDart, double par2, double par4, double par6, float par8, float par9)
{
this.func_110777_b(par1EntityDart);
GL11.glPushMatrix();
GL11.glTranslatef((float)par2, (float)par4, (float)par6);
GL11.glRotatef(par1EntityDart.prevRotationYaw + (par1EntityDart.rotationYaw - par1EntityDart.prevRotationYaw) * par9 - 90.0F, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(par1EntityDart.prevRotationPitch + (par1EntityDart.rotationPitch - par1EntityDart.prevRotationPitch) * par9, 0.0F, 0.0F, 1.0F);
Tessellator tessellator = Tessellator.instance;
byte b0 = 0;
float f2 = 0.0F;
float f3 = 0.5F;
float f4 = (float)(0 + b0 * 10) / 32.0F;
float f5 = (float)(5 + b0 * 10) / 32.0F;
float f6 = 0.0F;
float f7 = 0.15625F;
float f8 = (float)(5 + b0 * 10) / 32.0F;
float f9 = (float)(10 + b0 * 10) / 32.0F;
float f10 = 0.05625F;
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
float f11 = (float)par1EntityDart.arrowShake - par9;
2013-05-16 13:50:12 +00:00
2013-07-02 11:30:11 +00:00
if (f11 > 0.0F)
{
float f12 = -MathHelper.sin(f11 * 3.0F) * f11;
GL11.glRotatef(f12, 0.0F, 0.0F, 1.0F);
}
2013-05-11 12:51:16 +00:00
2013-07-02 11:30:11 +00:00
GL11.glRotatef(45.0F, 1.0F, 0.0F, 0.0F);
GL11.glScalef(f10, f10, f10);
GL11.glTranslatef(-4.0F, 0.0F, 0.0F);
GL11.glNormal3f(f10, 0.0F, 0.0F);
tessellator.startDrawingQuads();
tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double)f6, (double)f8);
tessellator.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double)f7, (double)f8);
tessellator.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double)f7, (double)f9);
tessellator.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double)f6, (double)f9);
tessellator.draw();
GL11.glNormal3f(-f10, 0.0F, 0.0F);
tessellator.startDrawingQuads();
tessellator.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double)f6, (double)f8);
tessellator.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double)f7, (double)f8);
tessellator.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double)f7, (double)f9);
tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double)f6, (double)f9);
tessellator.draw();
2013-05-11 12:51:16 +00:00
2013-07-02 11:30:11 +00:00
for (int i = 0; i < 4; ++i)
{
GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F);
GL11.glNormal3f(0.0F, 0.0F, f10);
tessellator.startDrawingQuads();
tessellator.addVertexWithUV(-8.0D, -2.0D, 0.0D, (double)f2, (double)f4);
tessellator.addVertexWithUV(8.0D, -2.0D, 0.0D, (double)f3, (double)f4);
tessellator.addVertexWithUV(8.0D, 2.0D, 0.0D, (double)f3, (double)f5);
tessellator.addVertexWithUV(-8.0D, 2.0D, 0.0D, (double)f2, (double)f5);
tessellator.draw();
}
2013-05-11 12:51:16 +00:00
2013-07-02 11:30:11 +00:00
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
GL11.glPopMatrix();
}
2013-05-31 10:34:02 +00:00
2013-07-02 11:30:11 +00:00
@Override
2013-05-31 10:34:02 +00:00
public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9)
2013-07-02 11:30:11 +00:00
{
this.renderDart((EntityDart)par1Entity, par2, par4, par6, par8, par9);
}
@Override
protected ResourceLocation func_110775_a(Entity entity)
{
2013-07-02 11:30:11 +00:00
if (((EntityDart)entity).isPoisonous())
{
return new ResourceLocation("biomesoplenty:textures/projectiles/poisondart.png");
}
2013-07-02 11:30:11 +00:00
return new ResourceLocation("biomesoplenty:textures/projectiles/dart.png");
}
2013-05-11 12:51:16 +00:00
}