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