package client.renderer.entity;

import org.lwjgl.opengl.GL11;

import client.renderer.GlState;
import client.renderer.model.ModelDie;
import common.entity.projectile.EntityDie;
import common.item.projectile.ItemDie;

public class RenderDie extends Render<EntityDie> {
	private final ModelDie model = new ModelDie();

	public RenderDie(RenderManager renderManagerIn) {
		super(renderManagerIn);
	}

	protected String getEntityTexture(EntityDie entity) {
		return "textures/object/die_d" + ((ItemDie)entity.getItem()).getSides() + ".png";
	}

	public void doRender(EntityDie entity, double x, double y, double z, float partialTicks) {
		GL11.glPushMatrix();
		GL11.glTranslatef((float)x, (float)y + 0.05F, (float)z);
		this.bindEntityTexture(entity);
		if(entity.getValue() == 0)
			GL11.glRotatef((float)((entity.ticksExisted % 10) * (360 / 10)), 0.3f, 0.4f, 0.1f);
		GL11.glScalef(-0.1f, -0.1f, 0.1f);
		GlState.disableCull();
		this.model.render(entity, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F);
		GlState.enableCull();
		GL11.glPopMatrix();
		super.doRender(entity, x, y, z, partialTicks);
	}
}
