Skip to content

Instantly share code, notes, and snippets.

@Knux14
Created February 8, 2014 17:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Knux14/8887556 to your computer and use it in GitHub Desktop.
Save Knux14/8887556 to your computer and use it in GitHub Desktop.
package fr.Knux14.Stuffies.Flycar;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelBoat;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import fr.Knux14.Stuffies.Stuffies;
import fr.Knux14.Stuffies.Vars;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.model.ModelBase;
import net.minecraft.entity.Entity;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
@SideOnly(Side.CLIENT)
public class RenderFlycar extends Render
{
private static final ResourceLocation texture = new ResourceLocation(Vars.id + ":" + "textures/flycar/entity.png");
protected ModelBase modelFC;
public RenderFlycar()
{
this.shadowSize = 0.5F;
this.modelFC = new ModelFlycar();
}
public void renderFC(EntityFlycar flycar, double par2, double par4, double par6, float par8, float par9)
{
GL11.glPushMatrix();
GL11.glTranslatef((float)par2, (float)par4 + .4f, (float)par6);
GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F);
float f4 = 0.75F;
GL11.glScalef(f4, f4, f4);
GL11.glScalef(1.0F / f4, 1.0F / f4, 1.0F / f4);
this.bindEntityTexture(flycar);
GL11.glScalef(-1.0F, -1.0F, 1.0F);
this.modelFC.render(flycar, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
GL11.glPopMatrix();
// flycar.name tag
String name = flycar.name;
FontRenderer fontrenderer = this.getFontRendererFromRenderManager();
float f = 1.6F;
float f1 = 0.016666668F * f;
GL11.glPushMatrix();
GL11.glTranslatef((float)par2 + 0.0F, (float)par4 + flycar.height + 0.5F, (float)par6);
GL11.glNormal3f(0.0F, 1.0F, 0.0F);
GL11.glRotatef(-this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
GL11.glScalef(-f1, -f1, f1);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDepthMask(false);
GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
Tessellator tessellator = Tessellator.instance;
byte b0 = 0;
GL11.glDisable(GL11.GL_TEXTURE_2D);
tessellator.startDrawingQuads();
int j = fontrenderer.getStringWidth(name) / 2;
tessellator.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0.25F);
tessellator.addVertex((double)(-j - 1), (double)(-1 + b0), 0.0D);
tessellator.addVertex((double)(-j - 1), (double)(8 + b0), 0.0D);
tessellator.addVertex((double)(j + 1), (double)(8 + b0), 0.0D);
tessellator.addVertex((double)(j + 1), (double)(-1 + b0), 0.0D);
tessellator.draw();
GL11.glEnable(GL11.GL_TEXTURE_2D);
fontrenderer.drawString(name, -fontrenderer.getStringWidth(name) / 2, b0, 553648127);
GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glDepthMask(true);
fontrenderer.drawString(name, -fontrenderer.getStringWidth(name) / 2, b0, -1);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_BLEND);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glPopMatrix();
}
protected ResourceLocation getFCTextures(EntityFlycar fc)
{
return texture;
}
protected ResourceLocation getEntityTexture(Entity par1Entity)
{
return this.getFCTextures((EntityFlycar)par1Entity);
}
public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9)
{
this.renderFC((EntityFlycar)par1Entity, par2, par4, par6, par8, par9);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment