001package net.minecraft.client.renderer.entity;
002
003import cpw.mods.fml.relauncher.Side;
004import cpw.mods.fml.relauncher.SideOnly;
005import net.minecraft.block.Block;
006import net.minecraft.block.BlockAnvil;
007import net.minecraft.block.BlockDragonEgg;
008import net.minecraft.client.renderer.RenderBlocks;
009import net.minecraft.client.renderer.Tessellator;
010import net.minecraft.entity.Entity;
011import net.minecraft.entity.item.EntityFallingSand;
012import net.minecraft.util.MathHelper;
013import net.minecraft.world.World;
014import org.lwjgl.opengl.GL11;
015
016@SideOnly(Side.CLIENT)
017public class RenderFallingSand extends Render
018{
019    private RenderBlocks sandRenderBlocks = new RenderBlocks();
020
021    public RenderFallingSand()
022    {
023        this.shadowSize = 0.5F;
024    }
025
026    /**
027     * The actual render method that is used in doRender
028     */
029    public void doRenderFallingSand(EntityFallingSand par1EntityFallingSand, double par2, double par4, double par6, float par8, float par9)
030    {
031        World world = par1EntityFallingSand.getWorld();
032        Block block = Block.blocksList[par1EntityFallingSand.blockID];
033
034        if (world.getBlockId(MathHelper.floor_double(par1EntityFallingSand.posX), MathHelper.floor_double(par1EntityFallingSand.posY), MathHelper.floor_double(par1EntityFallingSand.posZ)) != par1EntityFallingSand.blockID)
035        {
036            GL11.glPushMatrix();
037            GL11.glTranslatef((float)par2, (float)par4, (float)par6);
038            this.loadTexture("/terrain.png");
039            GL11.glDisable(GL11.GL_LIGHTING);
040            Tessellator tessellator;
041
042            if (block instanceof BlockAnvil && block.getRenderType() == 35)
043            {
044                this.sandRenderBlocks.blockAccess = world;
045                tessellator = Tessellator.instance;
046                tessellator.startDrawingQuads();
047                tessellator.setTranslation((double)((float)(-MathHelper.floor_double(par1EntityFallingSand.posX)) - 0.5F), (double)((float)(-MathHelper.floor_double(par1EntityFallingSand.posY)) - 0.5F), (double)((float)(-MathHelper.floor_double(par1EntityFallingSand.posZ)) - 0.5F));
048                this.sandRenderBlocks.renderBlockAnvilMetadata((BlockAnvil)block, MathHelper.floor_double(par1EntityFallingSand.posX), MathHelper.floor_double(par1EntityFallingSand.posY), MathHelper.floor_double(par1EntityFallingSand.posZ), par1EntityFallingSand.metadata);
049                tessellator.setTranslation(0.0D, 0.0D, 0.0D);
050                tessellator.draw();
051            }
052            else if (block.getRenderType() == 27)
053            {
054                this.sandRenderBlocks.blockAccess = world;
055                tessellator = Tessellator.instance;
056                tessellator.startDrawingQuads();
057                tessellator.setTranslation((double)((float)(-MathHelper.floor_double(par1EntityFallingSand.posX)) - 0.5F), (double)((float)(-MathHelper.floor_double(par1EntityFallingSand.posY)) - 0.5F), (double)((float)(-MathHelper.floor_double(par1EntityFallingSand.posZ)) - 0.5F));
058                this.sandRenderBlocks.renderBlockDragonEgg((BlockDragonEgg)block, MathHelper.floor_double(par1EntityFallingSand.posX), MathHelper.floor_double(par1EntityFallingSand.posY), MathHelper.floor_double(par1EntityFallingSand.posZ));
059                tessellator.setTranslation(0.0D, 0.0D, 0.0D);
060                tessellator.draw();
061            }
062            else if (block != null)
063            {
064                this.sandRenderBlocks.setRenderBoundsFromBlock(block);
065                this.sandRenderBlocks.renderBlockSandFalling(block, world, MathHelper.floor_double(par1EntityFallingSand.posX), MathHelper.floor_double(par1EntityFallingSand.posY), MathHelper.floor_double(par1EntityFallingSand.posZ), par1EntityFallingSand.metadata);
066            }
067
068            GL11.glEnable(GL11.GL_LIGHTING);
069            GL11.glPopMatrix();
070        }
071    }
072
073    /**
074     * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
075     * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic
076     * (Render<T extends Entity) and this method has signature public void doRender(T entity, double d, double d1,
077     * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
078     */
079    public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9)
080    {
081        this.doRenderFallingSand((EntityFallingSand)par1Entity, par2, par4, par6, par8, par9);
082    }
083}