    001    package net.minecraft.src;
    002
    003    import cpw.mods.fml.common.Side;
    004    import cpw.mods.fml.common.asm.SideOnly;
    005    import java.util.Random;
    006    import org.lwjgl.opengl.GL11;
    007    import org.lwjgl.opengl.GL12;
    008
    009    @SideOnly(Side.CLIENT)
    010    public class RenderPainting extends Render
    011    {
    012        /** RNG. */
    013        private Random rand = new Random();
    014
    015        public void renderThePainting(EntityPainting par1EntityPainting, double par2, double par4, double par6, float par8, float par9)
    016        {
    017            this.rand.setSeed(187L);
    018            GL11.glPushMatrix();
    019            GL11.glTranslatef((float)par2, (float)par4, (float)par6);
    020            GL11.glRotatef(par8, 0.0F, 1.0F, 0.0F);
    021            GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    022            this.loadTexture("/art/kz.png");
    023            EnumArt var10 = par1EntityPainting.art;
    024            float var11 = 0.0625F;
    025            GL11.glScalef(var11, var11, var11);
    026            this.func_77010_a(par1EntityPainting, var10.sizeX, var10.sizeY, var10.offsetX, var10.offsetY);
    027            GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    028            GL11.glPopMatrix();
    029        }
    030
    031        private void func_77010_a(EntityPainting par1EntityPainting, int par2, int par3, int par4, int par5)
    032        {
    033            float var6 = (float)(-par2) / 2.0F;
    034            float var7 = (float)(-par3) / 2.0F;
    035            float var8 = -0.5F;
    036            float var9 = 0.5F;
    037
    038            for (int var10 = 0; var10 < par2 / 16; ++var10)
    039            {
    040                for (int var11 = 0; var11 < par3 / 16; ++var11)
    041                {
    042                    float var12 = var6 + (float)((var10 + 1) * 16);
    043                    float var13 = var6 + (float)(var10 * 16);
    044                    float var14 = var7 + (float)((var11 + 1) * 16);
    045                    float var15 = var7 + (float)(var11 * 16);
    046                    this.func_77008_a(par1EntityPainting, (var12 + var13) / 2.0F, (var14 + var15) / 2.0F);
    047                    float var16 = (float)(par4 + par2 - var10 * 16) / 256.0F;
    048                    float var17 = (float)(par4 + par2 - (var10 + 1) * 16) / 256.0F;
    049                    float var18 = (float)(par5 + par3 - var11 * 16) / 256.0F;
    050                    float var19 = (float)(par5 + par3 - (var11 + 1) * 16) / 256.0F;
    051                    float var20 = 0.75F;
    052                    float var21 = 0.8125F;
    053                    float var22 = 0.0F;
    054                    float var23 = 0.0625F;
    055                    float var24 = 0.75F;
    056                    float var25 = 0.8125F;
    057                    float var26 = 0.001953125F;
    058                    float var27 = 0.001953125F;
    059                    float var28 = 0.7519531F;
    060                    float var29 = 0.7519531F;
    061                    float var30 = 0.0F;
    062                    float var31 = 0.0625F;
    063                    Tessellator var32 = Tessellator.instance;
    064                    var32.startDrawingQuads();
    065                    var32.setNormal(0.0F, 0.0F, -1.0F);
    066                    var32.addVertexWithUV((double)var12, (double)var15, (double)var8, (double)var17, (double)var18);
    067                    var32.addVertexWithUV((double)var13, (double)var15, (double)var8, (double)var16, (double)var18);
    068                    var32.addVertexWithUV((double)var13, (double)var14, (double)var8, (double)var16, (double)var19);
    069                    var32.addVertexWithUV((double)var12, (double)var14, (double)var8, (double)var17, (double)var19);
    070                    var32.setNormal(0.0F, 0.0F, 1.0F);
    071                    var32.addVertexWithUV((double)var12, (double)var14, (double)var9, (double)var20, (double)var22);
    072                    var32.addVertexWithUV((double)var13, (double)var14, (double)var9, (double)var21, (double)var22);
    073                    var32.addVertexWithUV((double)var13, (double)var15, (double)var9, (double)var21, (double)var23);
    074                    var32.addVertexWithUV((double)var12, (double)var15, (double)var9, (double)var20, (double)var23);
    075                    var32.setNormal(0.0F, 1.0F, 0.0F);
    076                    var32.addVertexWithUV((double)var12, (double)var14, (double)var8, (double)var24, (double)var26);
    077                    var32.addVertexWithUV((double)var13, (double)var14, (double)var8, (double)var25, (double)var26);
    078                    var32.addVertexWithUV((double)var13, (double)var14, (double)var9, (double)var25, (double)var27);
    079                    var32.addVertexWithUV((double)var12, (double)var14, (double)var9, (double)var24, (double)var27);
    080                    var32.setNormal(0.0F, -1.0F, 0.0F);
    081                    var32.addVertexWithUV((double)var12, (double)var15, (double)var9, (double)var24, (double)var26);
    082                    var32.addVertexWithUV((double)var13, (double)var15, (double)var9, (double)var25, (double)var26);
    083                    var32.addVertexWithUV((double)var13, (double)var15, (double)var8, (double)var25, (double)var27);
    084                    var32.addVertexWithUV((double)var12, (double)var15, (double)var8, (double)var24, (double)var27);
    085                    var32.setNormal(-1.0F, 0.0F, 0.0F);
    086                    var32.addVertexWithUV((double)var12, (double)var14, (double)var9, (double)var29, (double)var30);
    087                    var32.addVertexWithUV((double)var12, (double)var15, (double)var9, (double)var29, (double)var31);
    088                    var32.addVertexWithUV((double)var12, (double)var15, (double)var8, (double)var28, (double)var31);
    089                    var32.addVertexWithUV((double)var12, (double)var14, (double)var8, (double)var28, (double)var30);
    090                    var32.setNormal(1.0F, 0.0F, 0.0F);
    091                    var32.addVertexWithUV((double)var13, (double)var14, (double)var8, (double)var29, (double)var30);
    092                    var32.addVertexWithUV((double)var13, (double)var15, (double)var8, (double)var29, (double)var31);
    093                    var32.addVertexWithUV((double)var13, (double)var15, (double)var9, (double)var28, (double)var31);
    094                    var32.addVertexWithUV((double)var13, (double)var14, (double)var9, (double)var28, (double)var30);
    095                    var32.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.direction == 0)
    107            {
    108                var4 = MathHelper.floor_double(par1EntityPainting.posX + (double)(par2 / 16.0F));
    109            }
    110
    111            if (par1EntityPainting.direction == 1)
    112            {
    113                var6 = MathHelper.floor_double(par1EntityPainting.posZ - (double)(par2 / 16.0F));
    114            }
    115
    116            if (par1EntityPainting.direction == 2)
    117            {
    118                var4 = MathHelper.floor_double(par1EntityPainting.posX - (double)(par2 / 16.0F));
    119            }
    120
    121            if (par1EntityPainting.direction == 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    }