    001    package net.minecraft.client.renderer.entity;
    002
    003    import cpw.mods.fml.common.Side;
    004    import cpw.mods.fml.common.asm.SideOnly;
    005    import net.minecraft.client.renderer.OpenGlHelper;
    006    import net.minecraft.client.renderer.Tessellator;
    007    import net.minecraft.entity.Entity;
    008    import net.minecraft.entity.item.EntityPainting;
    009    import net.minecraft.util.EnumArt;
    010    import net.minecraft.util.MathHelper;
    011    import org.lwjgl.opengl.GL11;
    012    import org.lwjgl.opengl.GL12;
    013
    014    @SideOnly(Side.CLIENT)
    015    public class RenderPainting extends Render
    016    {
    017        public void renderThePainting(EntityPainting par1EntityPainting, double par2, double par4, double par6, float par8, float par9)
    018        {
    019            GL11.glPushMatrix();
    020            GL11.glTranslatef((float)par2, (float)par4, (float)par6);
    021            GL11.glRotatef(par8, 0.0F, 1.0F, 0.0F);
    022            GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    023            this.loadTexture("/art/kz.png");
    024            EnumArt var10 = par1EntityPainting.art;
    025            float var11 = 0.0625F;
    026            GL11.glScalef(var11, var11, var11);
    027            this.func_77010_a(par1EntityPainting, var10.sizeX, var10.sizeY, var10.offsetX, var10.offsetY);
    028            GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    029            GL11.glPopMatrix();
    030        }
    031
    032        private void func_77010_a(EntityPainting par1EntityPainting, int par2, int par3, int par4, int par5)
    033        {
    034            float var6 = (float)(-par2) / 2.0F;
    035            float var7 = (float)(-par3) / 2.0F;
    036            float var8 = 0.5F;
    037            float var9 = 0.75F;
    038            float var10 = 0.8125F;
    039            float var11 = 0.0F;
    040            float var12 = 0.0625F;
    041            float var13 = 0.75F;
    042            float var14 = 0.8125F;
    043            float var15 = 0.001953125F;
    044            float var16 = 0.001953125F;
    045            float var17 = 0.7519531F;
    046            float var18 = 0.7519531F;
    047            float var19 = 0.0F;
    048            float var20 = 0.0625F;
    049
    050            for (int var21 = 0; var21 < par2 / 16; ++var21)
    051            {
    052                for (int var22 = 0; var22 < par3 / 16; ++var22)
    053                {
    054                    float var23 = var6 + (float)((var21 + 1) * 16);
    055                    float var24 = var6 + (float)(var21 * 16);
    056                    float var25 = var7 + (float)((var22 + 1) * 16);
    057                    float var26 = var7 + (float)(var22 * 16);
    058                    this.func_77008_a(par1EntityPainting, (var23 + var24) / 2.0F, (var25 + var26) / 2.0F);
    059                    float var27 = (float)(par4 + par2 - var21 * 16) / 256.0F;
    060                    float var28 = (float)(par4 + par2 - (var21 + 1) * 16) / 256.0F;
    061                    float var29 = (float)(par5 + par3 - var22 * 16) / 256.0F;
    062                    float var30 = (float)(par5 + par3 - (var22 + 1) * 16) / 256.0F;
    063                    Tessellator var31 = Tessellator.instance;
    064                    var31.startDrawingQuads();
    065                    var31.setNormal(0.0F, 0.0F, -1.0F);
    066                    var31.addVertexWithUV((double)var23, (double)var26, (double)(-var8), (double)var28, (double)var29);
    067                    var31.addVertexWithUV((double)var24, (double)var26, (double)(-var8), (double)var27, (double)var29);
    068                    var31.addVertexWithUV((double)var24, (double)var25, (double)(-var8), (double)var27, (double)var30);
    069                    var31.addVertexWithUV((double)var23, (double)var25, (double)(-var8), (double)var28, (double)var30);
    070                    var31.setNormal(0.0F, 0.0F, 1.0F);
    071                    var31.addVertexWithUV((double)var23, (double)var25, (double)var8, (double)var9, (double)var11);
    072                    var31.addVertexWithUV((double)var24, (double)var25, (double)var8, (double)var10, (double)var11);
    073                    var31.addVertexWithUV((double)var24, (double)var26, (double)var8, (double)var10, (double)var12);
    074                    var31.addVertexWithUV((double)var23, (double)var26, (double)var8, (double)var9, (double)var12);
    075                    var31.setNormal(0.0F, 1.0F, 0.0F);
    076                    var31.addVertexWithUV((double)var23, (double)var25, (double)(-var8), (double)var13, (double)var15);
    077                    var31.addVertexWithUV((double)var24, (double)var25, (double)(-var8), (double)var14, (double)var15);
    078                    var31.addVertexWithUV((double)var24, (double)var25, (double)var8, (double)var14, (double)var16);
    079                    var31.addVertexWithUV((double)var23, (double)var25, (double)var8, (double)var13, (double)var16);
    080                    var31.setNormal(0.0F, -1.0F, 0.0F);
    081                    var31.addVertexWithUV((double)var23, (double)var26, (double)var8, (double)var13, (double)var15);
    082                    var31.addVertexWithUV((double)var24, (double)var26, (double)var8, (double)var14, (double)var15);
    083                    var31.addVertexWithUV((double)var24, (double)var26, (double)(-var8), (double)var14, (double)var16);
    084                    var31.addVertexWithUV((double)var23, (double)var26, (double)(-var8), (double)var13, (double)var16);
    085                    var31.setNormal(-1.0F, 0.0F, 0.0F);
    086                    var31.addVertexWithUV((double)var23, (double)var25, (double)var8, (double)var18, (double)var19);
    087                    var31.addVertexWithUV((double)var23, (double)var26, (double)var8, (double)var18, (double)var20);
    088                    var31.addVertexWithUV((double)var23, (double)var26, (double)(-var8), (double)var17, (double)var20);
    089                    var31.addVertexWithUV((double)var23, (double)var25, (double)(-var8), (double)var17, (double)var19);
    090                    var31.setNormal(1.0F, 0.0F, 0.0F);
    091                    var31.addVertexWithUV((double)var24, (double)var25, (double)(-var8), (double)var18, (double)var19);
    092                    var31.addVertexWithUV((double)var24, (double)var26, (double)(-var8), (double)var18, (double)var20);
    093                    var31.addVertexWithUV((double)var24, (double)var26, (double)var8, (double)var17, (double)var20);
    094                    var31.addVertexWithUV((double)var24, (double)var25, (double)var8, (double)var17, (double)var19);
    095                    var31.draw();
    096                }
    097            }
    098        }
    099
    100        private void func_77008_a(EntityPainting par1EntityPainting, float par2, float par3)
    101        {
    102            int var4 = MathHelper.floor_double(par1EntityPainting.posX);
    103            int var5 = MathHelper.floor_double(par1EntityPainting.posY + (double)(par3 / 16.0F));
    104            int var6 = MathHelper.floor_double(par1EntityPainting.posZ);
    105
    106            if (par1EntityPainting.hangingDirection == 2)
    107            {
    108                var4 = MathHelper.floor_double(par1EntityPainting.posX + (double)(par2 / 16.0F));
    109            }
    110
    111            if (par1EntityPainting.hangingDirection == 1)
    112            {
    113                var6 = MathHelper.floor_double(par1EntityPainting.posZ - (double)(par2 / 16.0F));
    114            }
    115
    116            if (par1EntityPainting.hangingDirection == 0)
    117            {
    118                var4 = MathHelper.floor_double(par1EntityPainting.posX - (double)(par2 / 16.0F));
    119            }
    120
    121            if (par1EntityPainting.hangingDirection == 3)
    122            {
    123                var6 = MathHelper.floor_double(par1EntityPainting.posZ + (double)(par2 / 16.0F));
    124            }
    125
    126            int var7 = this.renderManager.worldObj.getLightBrightnessForSkyBlocks(var4, var5, var6, 0);
    127            int var8 = var7 % 65536;
    128            int var9 = var7 / 65536;
    129            OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)var8, (float)var9);
    130            GL11.glColor3f(1.0F, 1.0F, 1.0F);
    131        }
    132
    133        /**
    134         * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
    135         * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic
    136         * (Render<T extends Entity) and this method has signature public void doRender(T entity, double d, double d1,
    137         * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
    138         */
    139        public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9)
    140        {
    141            this.renderThePainting((EntityPainting)par1Entity, par2, par4, par6, par8, par9);
    142        }
    143    }