package client.renderer.tileentity;

import org.lwjgl.opengl.GL11;

import client.Client;
import client.renderer.GlState;
import client.renderer.blockmodel.IBakedModel;
import client.renderer.entity.RenderItem;
import client.renderer.texture.TextureMap;
import common.item.ItemStack;
import common.tileentity.TileEntityItemPipe;

public class ItemPipeRenderer extends ElementRenderer<TileEntityItemPipe> {
	public void renderElements(TileEntityItemPipe te, double x, double y, double z, float partialTicks) {
		ItemStack itemstack = te.getDisplayedItem();
		if(itemstack == null)
			return;
		Client.CLIENT.getTextureManager().bindTexture(TextureMap.BLOCKS);
		GlState.enableRescaleNormal();
		GlState.alphaFunc(GL11.GL_GREATER, 0.1F);
		GlState.enableBlend();
		GlState.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
		RenderItem itemRenderer = Client.CLIENT.getRenderItem();
		IBakedModel ibakedmodel = itemRenderer.getItemModelMesher().getItemModel(itemstack);
		GL11.glPushMatrix();
		GL11.glTranslatef((float)x + 0.5F, (float)y + 0.5f, (float)z + 0.5F);
		if(ibakedmodel.isGui3d())
			GL11.glScalef(0.5F, 0.5F, 0.5F);
		itemRenderer.renderItem(itemstack, ibakedmodel);
		GL11.glPopMatrix();
		GlState.disableRescaleNormal();
		GlState.disableBlend();
	}
}
