    001package net.minecraft.client.renderer.tileentity;
    002
    003import cpw.mods.fml.relauncher.Side;
    004import cpw.mods.fml.relauncher.SideOnly;
    005import net.minecraft.client.gui.FontRenderer;
    006import net.minecraft.client.renderer.RenderEngine;
    007import net.minecraft.tileentity.TileEntity;
    008import net.minecraft.world.World;
    009import org.lwjgl.opengl.GL11;
    010
    011@SideOnly(Side.CLIENT)
    012public abstract class TileEntitySpecialRenderer
    013{
    014    /**
    015     * The TileEntityRenderer instance associated with this TileEntitySpecialRenderer
    016     */
    017    protected TileEntityRenderer tileEntityRenderer;
    018
    019    public abstract void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f);
    020
    021    /**
    022     * Binds a texture to the renderEngine given a filename from the JAR.
    023     */
    024    protected void bindTextureByName(String par1Str)
    025    {
    026        RenderEngine renderengine = this.tileEntityRenderer.renderEngine;
    027
    028        if (renderengine != null)
    029        {
    030            renderengine.bindTexture(par1Str);
    031        }
    032    }
    033
    034    /**
    035     * Binds a texture that Minecraft will attempt to load from the given URL.  (arguments: url, localFallback)
    036     */
    037    protected void bindTextureByURL(String par1Str, String par2Str)
    038    {
    039        RenderEngine renderengine = this.tileEntityRenderer.renderEngine;
    040
    041        if (renderengine != null)
    042        {
    043            GL11.glBindTexture(GL11.GL_TEXTURE_2D, renderengine.getTextureForDownloadableImage(par1Str, par2Str));
    044        }
    045
    046        renderengine.resetBoundTexture();
    047    }
    048
    049    /**
    050     * Associate a TileEntityRenderer with this TileEntitySpecialRenderer
    051     */
    052    public void setTileEntityRenderer(TileEntityRenderer par1TileEntityRenderer)
    053    {
    054        this.tileEntityRenderer = par1TileEntityRenderer;
    055    }
    056
    057    /**
    058     * Called when the ingame world being rendered changes (e.g. on world -> nether travel) due to using one renderer
    059     * per tile entity type, rather than instance
    060     */
    061    public void onWorldChange(World par1World) {}
    062
    063    public FontRenderer getFontRenderer()
    064    {
    065        return this.tileEntityRenderer.getFontRenderer();
    066    }
    067}