package portables.client.render;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.*;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityFallingBlock;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityChest;
import net.minecraft.tileentity.TileEntityEnderChest;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import org.lwjgl.opengl.GL11;
@SideOnly(Side.CLIENT)
public class CustomRenderFallingSand extends Render
{
private final RenderBlocks sandRenderBlocks = new RenderBlocks();
public CustomRenderFallingSand()
{
this.shadowSize = 0.5F;
}
public void doRenderFallingSand(EntityFallingBlock entity, double par2, double par4, double par6, float par8, float par9)
{
World world = entity.worldObj;
Block block = Block.getBlockById(entity.field_145814_a);
if (Block.getIdFromBlock(world.getBlock(MathHelper.floor_double(entity.posX), MathHelper.floor_double(entity.posY), MathHelper.floor_double(entity.posZ))) != entity.field_145814_a)
{
GL11.glPushMatrix();
GL11.glTranslatef((float) par2, (float) par4, (float) par6);
this.bindEntityTexture(entity);
GL11.glDisable(GL11.GL_LIGHTING);
Tessellator tessellator;
if (block instanceof BlockAnvil && block.getRenderType() == 35)
{
this.sandRenderBlocks.blockAccess = world;
tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.setTranslation((double) ((float) (-MathHelper.floor_double(entity.posX)) - 0.5F), (double) ((float) (-MathHelper.floor_double(entity.posY)) - 0.5F), (double) ((float) (-MathHelper.floor_double(entity.posZ)) - 0.5F));
this.sandRenderBlocks.renderBlockAnvilMetadata((BlockAnvil) block, MathHelper.floor_double(entity.posX), MathHelper.floor_double(entity.posY), MathHelper.floor_double(entity.posZ), entity.field_145812_b);
tessellator.setTranslation(0.0D, 0.0D, 0.0D);
tessellator.draw();
} else if (block.getRenderType() == 27)
{
this.sandRenderBlocks.blockAccess = world;
tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.setTranslation((double) ((float) (-MathHelper.floor_double(entity.posX)) - 0.5F), (double) ((float) (-MathHelper.floor_double(entity.posY)) - 0.5F), (double) ((float) (-MathHelper.floor_double(entity.posZ)) - 0.5F));
this.sandRenderBlocks.renderBlockDragonEgg((BlockDragonEgg) block, MathHelper.floor_double(entity.posX), MathHelper.floor_double(entity.posY), MathHelper.floor_double(entity.posZ));
tessellator.setTranslation(0.0D, 0.0D, 0.0D);
tessellator.draw();
} else if (block.getRenderType() == 38)
{
this.sandRenderBlocks.blockAccess = world;
tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.setTranslation((double) ((float) (-MathHelper.floor_double(entity.posX)) - 0.5F), (double) ((float) (-MathHelper.floor_double(entity.posY)) - 0.5F), (double) ((float) (-MathHelper.floor_double(entity.posZ)) - 0.5F));
this.sandRenderBlocks.renderBlockHopper((BlockHopper) block, MathHelper.floor_double(entity.posX), MathHelper.floor_double(entity.posY), MathHelper.floor_double(entity.posZ));
tessellator.setTranslation(0.0D, 0.0D, 0.0D);
tessellator.draw();
} else if (block.getRenderType() == 25)
{
this.sandRenderBlocks.blockAccess = world;
tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.setTranslation((double) ((float) (-MathHelper.floor_double(entity.posX)) - 0.5F), (double) ((float) (-MathHelper.floor_double(entity.posY)) - 0.5F), (double) ((float) (-MathHelper.floor_double(entity.posZ)) - 0.5F));
this.sandRenderBlocks.renderBlockBrewingStand((BlockBrewingStand) block, MathHelper.floor_double(entity.posX), MathHelper.floor_double(entity.posY), MathHelper.floor_double(entity.posZ));
tessellator.setTranslation(0.0D, 0.0D, 0.0D);
tessellator.draw();
} else if (block.getRenderType() == 34)
{
this.sandRenderBlocks.blockAccess = world;
tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.setTranslation((double) ((float) (-MathHelper.floor_double(entity.posX)) - 0.5F), (double) ((float) (-MathHelper.floor_double(entity.posY)) - 0.5F), (double) ((float) (-MathHelper.floor_double(entity.posZ)) - 0.5F));
this.sandRenderBlocks.renderBlockBeacon((BlockBeacon) block, MathHelper.floor_double(entity.posX), MathHelper.floor_double(entity.posY), MathHelper.floor_double(entity.posZ));
tessellator.setTranslation(0.0D, 0.0D, 0.0D);
tessellator.draw();
} else if (block.getRenderType() == 22)
{
TileEntity tileChest = Block.getIdFromBlock(block) == 130 ? new TileEntityEnderChest() : new TileEntityChest();
this.sandRenderBlocks.blockAccess = world;
tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.setTranslation((double) ((float) (-MathHelper.floor_double(entity.posX)) + 12F), (double) ((float) (-MathHelper.floor_double(entity.posY)) + 12F), (double) ((float) (-MathHelper.floor_double(entity.posZ)) + 12F));
TileEntityRendererDispatcher.instance.renderTileEntityAt(tileChest, (-MathHelper.floor_double(entity.posX)) - 0.5F, (double) ((float) (-MathHelper.floor_double(entity.posY)) - 0.5F), (double) ((float) (-MathHelper.floor_double(entity.posZ)) - 0.5F), par8);
tessellator.setTranslation(0.0D, 0.0D, 0.0D);
tessellator.draw();
} else if (block.getRenderType() == 12)
{
this.sandRenderBlocks.blockAccess = world;
tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.setTranslation((double) ((float) (-MathHelper.floor_double(entity.posX)) - 0.5F), (double) ((float) (-MathHelper.floor_double(entity.posY)) - 0.5F), (double) ((float) (-MathHelper.floor_double(entity.posZ)) - 0.5F));
GL11.glRotatef(180, 0, 0, 1);
this.sandRenderBlocks.renderBlockLever((BlockLever) block, MathHelper.floor_double(entity.posX), MathHelper.floor_double(entity.posY), MathHelper.floor_double(entity.posZ));
tessellator.setTranslation(0.0D, 0.0D, 0.0D);
tessellator.draw();
} else if (block.getRenderType() == 21)
{
this.sandRenderBlocks.blockAccess = world;
tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.setTranslation((double) ((float) (-MathHelper.floor_double(entity.posX)) - 0.5F), (double) ((float) (-MathHelper.floor_double(entity.posY)) - 0.5F), (double) ((float) (-MathHelper.floor_double(entity.posZ)) - 0.5F));
this.sandRenderBlocks.renderBlockFenceGate((BlockFenceGate) block, MathHelper.floor_double(entity.posX), MathHelper.floor_double(entity.posY), MathHelper.floor_double(entity.posZ));
tessellator.setTranslation(0.0D, 0.0D, 0.0D);
tessellator.draw();
} else if (block != null)
{
this.sandRenderBlocks.setRenderBoundsFromBlock(block);
this.sandRenderBlocks.renderBlockSandFalling(block, world, MathHelper.floor_double(entity.posX), MathHelper.floor_double(entity.posY), MathHelper.floor_double(entity.posZ), entity.field_145812_b);
}
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glPopMatrix();
}
}
protected ResourceLocation getFallingSandTextures(EntityFallingBlock sand)
{
return TextureMap.locationBlocksTexture;
}
protected ResourceLocation getEntityTexture(Entity par1Entity)
{
return this.getFallingSandTextures((EntityFallingBlock) par1Entity);
}
public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9)
{
this.doRenderFallingSand((EntityFallingBlock) par1Entity, par2, par4, par6, par8, par9);
}
}