    001    package net.minecraft.src;
    002
    003    import cpw.mods.fml.common.Side;
    004    import cpw.mods.fml.common.asm.SideOnly;
    005    import java.nio.IntBuffer;
    006    import java.util.ArrayList;
    007    import java.util.Arrays;
    008    import java.util.Collections;
    009    import java.util.HashMap;
    010    import java.util.Iterator;
    011    import java.util.List;
    012    import java.util.Map;
    013    import java.util.Random;
    014
    015    import net.minecraft.client.Minecraft;
    016    import net.minecraftforge.client.SkyProvider;
    017
    018    import org.lwjgl.opengl.ARBOcclusionQuery;
    019    import org.lwjgl.opengl.GL11;
    020
    021    @SideOnly(Side.CLIENT)
    022    public class RenderGlobal implements IWorldAccess
    023    {
    024        public List tileEntities = new ArrayList();
    025        public WorldClient theWorld;
    026
    027        /** The RenderEngine instance used by RenderGlobal */
    028        public final RenderEngine renderEngine;
    029        private List worldRenderersToUpdate = new ArrayList();
    030        private WorldRenderer[] sortedWorldRenderers;
    031        private WorldRenderer[] worldRenderers;
    032        private int renderChunksWide;
    033        private int renderChunksTall;
    034        private int renderChunksDeep;
    035
    036        /** OpenGL render lists base */
    037        private int glRenderListBase;
    038
    039        /** A reference to the Minecraft object. */
    040        public Minecraft mc;
    041
    042        /** Global render blocks */
    043        public RenderBlocks globalRenderBlocks;
    044
    045        /** OpenGL occlusion query base */
    046        private IntBuffer glOcclusionQueryBase;
    047
    048        /** Is occlusion testing enabled */
    049        private boolean occlusionEnabled = false;
    050        private int cloudOffsetX = 0;
    051
    052        /** The star GL Call list */
    053        private int starGLCallList;
    054
    055        /** OpenGL sky list */
    056        private int glSkyList;
    057
    058        /** OpenGL sky list 2 */
    059        private int glSkyList2;
    060
    061        /** Minimum block X */
    062        private int minBlockX;
    063
    064        /** Minimum block Y */
    065        private int minBlockY;
    066
    067        /** Minimum block Z */
    068        private int minBlockZ;
    069
    070        /** Maximum block X */
    071        private int maxBlockX;
    072
    073        /** Maximum block Y */
    074        private int maxBlockY;
    075
    076        /** Maximum block Z */
    077        private int maxBlockZ;
    078        public Map field_72738_E = new HashMap();
    079        private int renderDistance = -1;
    080
    081        /** Render entities startup counter (init value=2) */
    082        private int renderEntitiesStartupCounter = 2;
    083
    084        /** Count entities total */
    085        private int countEntitiesTotal;
    086
    087        /** Count entities rendered */
    088        private int countEntitiesRendered;
    089
    090        /** Count entities hidden */
    091        private int countEntitiesHidden;
    092
    093        /** Dummy buffer (50k) not used */
    094        int[] dummyBuf50k = new int[50000];
    095
    096        /** Occlusion query result */
    097        IntBuffer occlusionResult = GLAllocation.createDirectIntBuffer(64);
    098
    099        /** How many renderers are loaded this frame that try to be rendered */
    100        private int renderersLoaded;
    101
    102        /** How many renderers are being clipped by the frustrum this frame */
    103        private int renderersBeingClipped;
    104
    105        /** How many renderers are being occluded this frame */
    106        private int renderersBeingOccluded;
    107
    108        /** How many renderers are actually being rendered this frame */
    109        private int renderersBeingRendered;
    110
    111        /**
    112         * How many renderers are skipping rendering due to not having a render pass this frame
    113         */
    114        private int renderersSkippingRenderPass;
    115
    116        /** Dummy render int */
    117        private int dummyRenderInt;
    118
    119        /** World renderers check index */
    120        private int worldRenderersCheckIndex;
    121
    122        /** List of OpenGL lists for the current render pass */
    123        private List glRenderLists = new ArrayList();
    124
    125        /** All render lists (fixed length 4) */
    126        private RenderList[] allRenderLists = new RenderList[] {new RenderList(), new RenderList(), new RenderList(), new RenderList()};
    127
    128        /**
    129         * Previous x position when the renderers were sorted. (Once the distance moves more than 4 units they will be
    130         * resorted)
    131         */
    132        double prevSortX = -9999.0D;
    133
    134        /**
    135         * Previous y position when the renderers were sorted. (Once the distance moves more than 4 units they will be
    136         * resorted)
    137         */
    138        double prevSortY = -9999.0D;
    139
    140        /**
    141         * Previous Z position when the renderers were sorted. (Once the distance moves more than 4 units they will be
    142         * resorted)
    143         */
    144        double prevSortZ = -9999.0D;
    145
    146        /**
    147         * The offset used to determine if a renderer is one of the sixteenth that are being updated this frame
    148         */
    149        int frustumCheckOffset = 0;
    150
    151        public RenderGlobal(Minecraft par1Minecraft, RenderEngine par2RenderEngine)
    152        {
    153            this.mc = par1Minecraft;
    154            this.renderEngine = par2RenderEngine;
    155            byte var3 = 34;
    156            byte var4 = 32;
    157            this.glRenderListBase = GLAllocation.generateDisplayLists(var3 * var3 * var4 * 3);
    158            this.occlusionEnabled = OpenGlCapsChecker.checkARBOcclusion();
    159
    160            if (this.occlusionEnabled)
    161            {
    162                this.occlusionResult.clear();
    163                this.glOcclusionQueryBase = GLAllocation.createDirectIntBuffer(var3 * var3 * var4);
    164                this.glOcclusionQueryBase.clear();
    165                this.glOcclusionQueryBase.position(0);
    166                this.glOcclusionQueryBase.limit(var3 * var3 * var4);
    167                ARBOcclusionQuery.glGenQueriesARB(this.glOcclusionQueryBase);
    168            }
    169
    170            this.starGLCallList = GLAllocation.generateDisplayLists(3);
    171            GL11.glPushMatrix();
    172            GL11.glNewList(this.starGLCallList, GL11.GL_COMPILE);
    173            this.renderStars();
    174            GL11.glEndList();
    175            GL11.glPopMatrix();
    176            Tessellator var5 = Tessellator.instance;
    177            this.glSkyList = this.starGLCallList + 1;
    178            GL11.glNewList(this.glSkyList, GL11.GL_COMPILE);
    179            byte var7 = 64;
    180            int var8 = 256 / var7 + 2;
    181            float var6 = 16.0F;
    182            int var9;
    183            int var10;
    184
    185            for (var9 = -var7 * var8; var9 <= var7 * var8; var9 += var7)
    186            {
    187                for (var10 = -var7 * var8; var10 <= var7 * var8; var10 += var7)
    188                {
    189                    var5.startDrawingQuads();
    190                    var5.addVertex((double)(var9 + 0), (double)var6, (double)(var10 + 0));
    191                    var5.addVertex((double)(var9 + var7), (double)var6, (double)(var10 + 0));
    192                    var5.addVertex((double)(var9 + var7), (double)var6, (double)(var10 + var7));
    193                    var5.addVertex((double)(var9 + 0), (double)var6, (double)(var10 + var7));
    194                    var5.draw();
    195                }
    196            }
    197
    198            GL11.glEndList();
    199            this.glSkyList2 = this.starGLCallList + 2;
    200            GL11.glNewList(this.glSkyList2, GL11.GL_COMPILE);
    201            var6 = -16.0F;
    202            var5.startDrawingQuads();
    203
    204            for (var9 = -var7 * var8; var9 <= var7 * var8; var9 += var7)
    205            {
    206                for (var10 = -var7 * var8; var10 <= var7 * var8; var10 += var7)
    207                {
    208                    var5.addVertex((double)(var9 + var7), (double)var6, (double)(var10 + 0));
    209                    var5.addVertex((double)(var9 + 0), (double)var6, (double)(var10 + 0));
    210                    var5.addVertex((double)(var9 + 0), (double)var6, (double)(var10 + var7));
    211                    var5.addVertex((double)(var9 + var7), (double)var6, (double)(var10 + var7));
    212                }
    213            }
    214
    215            var5.draw();
    216            GL11.glEndList();
    217        }
    218
    219        private void renderStars()
    220        {
    221            Random var1 = new Random(10842L);
    222            Tessellator var2 = Tessellator.instance;
    223            var2.startDrawingQuads();
    224
    225            for (int var3 = 0; var3 < 1500; ++var3)
    226            {
    227                double var4 = (double)(var1.nextFloat() * 2.0F - 1.0F);
    228                double var6 = (double)(var1.nextFloat() * 2.0F - 1.0F);
    229                double var8 = (double)(var1.nextFloat() * 2.0F - 1.0F);
    230                double var10 = (double)(0.15F + var1.nextFloat() * 0.1F);
    231                double var12 = var4 * var4 + var6 * var6 + var8 * var8;
    232
    233                if (var12 < 1.0D && var12 > 0.01D)
    234                {
    235                    var12 = 1.0D / Math.sqrt(var12);
    236                    var4 *= var12;
    237                    var6 *= var12;
    238                    var8 *= var12;
    239                    double var14 = var4 * 100.0D;
    240                    double var16 = var6 * 100.0D;
    241                    double var18 = var8 * 100.0D;
    242                    double var20 = Math.atan2(var4, var8);
    243                    double var22 = Math.sin(var20);
    244                    double var24 = Math.cos(var20);
    245                    double var26 = Math.atan2(Math.sqrt(var4 * var4 + var8 * var8), var6);
    246                    double var28 = Math.sin(var26);
    247                    double var30 = Math.cos(var26);
    248                    double var32 = var1.nextDouble() * Math.PI * 2.0D;
    249                    double var34 = Math.sin(var32);
    250                    double var36 = Math.cos(var32);
    251
    252                    for (int var38 = 0; var38 < 4; ++var38)
    253                    {
    254                        double var39 = 0.0D;
    255                        double var41 = (double)((var38 & 2) - 1) * var10;
    256                        double var43 = (double)((var38 + 1 & 2) - 1) * var10;
    257                        double var47 = var41 * var36 - var43 * var34;
    258                        double var49 = var43 * var36 + var41 * var34;
    259                        double var53 = var47 * var28 + var39 * var30;
    260                        double var55 = var39 * var28 - var47 * var30;
    261                        double var57 = var55 * var22 - var49 * var24;
    262                        double var61 = var49 * var22 + var55 * var24;
    263                        var2.addVertex(var14 + var57, var16 + var53, var18 + var61);
    264                    }
    265                }
    266            }
    267
    268            var2.draw();
    269        }
    270
    271        /**
    272         * set null to clear
    273         */
    274        public void setWorldAndLoadRenderers(WorldClient par1WorldClient)
    275        {
    276            if (this.theWorld != null)
    277            {
    278                this.theWorld.removeWorldAccess(this);
    279            }
    280
    281            this.prevSortX = -9999.0D;
    282            this.prevSortY = -9999.0D;
    283            this.prevSortZ = -9999.0D;
    284            RenderManager.instance.set(par1WorldClient);
    285            this.theWorld = par1WorldClient;
    286            this.globalRenderBlocks = new RenderBlocks(par1WorldClient);
    287
    288            if (par1WorldClient != null)
    289            {
    290                par1WorldClient.addWorldAccess(this);
    291                this.loadRenderers();
    292            }
    293        }
    294
    295        /**
    296         * Loads all the renderers and sets up the basic settings usage
    297         */
    298        public void loadRenderers()
    299        {
    300            if (this.theWorld != null)
    301            {
    302                Block.leaves.setGraphicsLevel(this.mc.gameSettings.fancyGraphics);
    303                this.renderDistance = this.mc.gameSettings.renderDistance;
    304                int var2;
    305                int var3;
    306
    307                if (this.worldRenderers != null)
    308                {
    309                    WorldRenderer[] var1 = this.worldRenderers;
    310                    var2 = var1.length;
    311
    312                    for (var3 = 0; var3 < var2; ++var3)
    313                    {
    314                        WorldRenderer var4 = var1[var3];
    315                        var4.stopRendering();
    316                    }
    317                }
    318
    319                int var7 = 64 << 3 - this.renderDistance;
    320
    321                if (var7 > 400)
    322                {
    323                    var7 = 400;
    324                }
    325
    326                this.renderChunksWide = var7 / 16 + 1;
    327                this.renderChunksTall = 16;
    328                this.renderChunksDeep = var7 / 16 + 1;
    329                this.worldRenderers = new WorldRenderer[this.renderChunksWide * this.renderChunksTall * this.renderChunksDeep];
    330                this.sortedWorldRenderers = new WorldRenderer[this.renderChunksWide * this.renderChunksTall * this.renderChunksDeep];
    331                var2 = 0;
    332                var3 = 0;
    333                this.minBlockX = 0;
    334                this.minBlockY = 0;
    335                this.minBlockZ = 0;
    336                this.maxBlockX = this.renderChunksWide;
    337                this.maxBlockY = this.renderChunksTall;
    338                this.maxBlockZ = this.renderChunksDeep;
    339                WorldRenderer var5;
    340
    341                for (Iterator var8 = this.worldRenderersToUpdate.iterator(); var8.hasNext(); var5.needsUpdate = false)
    342                {
    343                    var5 = (WorldRenderer)var8.next();
    344                }
    345
    346                this.worldRenderersToUpdate.clear();
    347                this.tileEntities.clear();
    348
    349                for (int var9 = 0; var9 < this.renderChunksWide; ++var9)
    350                {
    351                    for (int var10 = 0; var10 < this.renderChunksTall; ++var10)
    352                    {
    353                        for (int var6 = 0; var6 < this.renderChunksDeep; ++var6)
    354                        {
    355                            this.worldRenderers[(var6 * this.renderChunksTall + var10) * this.renderChunksWide + var9] = new WorldRenderer(this.theWorld, this.tileEntities, var9 * 16, var10 * 16, var6 * 16, this.glRenderListBase + var2);
    356
    357                            if (this.occlusionEnabled)
    358                            {
    359                                this.worldRenderers[(var6 * this.renderChunksTall + var10) * this.renderChunksWide + var9].glOcclusionQuery = this.glOcclusionQueryBase.get(var3);
    360                            }
    361
    362                            this.worldRenderers[(var6 * this.renderChunksTall + var10) * this.renderChunksWide + var9].isWaitingOnOcclusionQuery = false;
    363                            this.worldRenderers[(var6 * this.renderChunksTall + var10) * this.renderChunksWide + var9].isVisible = true;
    364                            this.worldRenderers[(var6 * this.renderChunksTall + var10) * this.renderChunksWide + var9].isInFrustum = true;
    365                            this.worldRenderers[(var6 * this.renderChunksTall + var10) * this.renderChunksWide + var9].chunkIndex = var3++;
    366                            this.worldRenderers[(var6 * this.renderChunksTall + var10) * this.renderChunksWide + var9].markDirty();
    367                            this.sortedWorldRenderers[(var6 * this.renderChunksTall + var10) * this.renderChunksWide + var9] = this.worldRenderers[(var6 * this.renderChunksTall + var10) * this.renderChunksWide + var9];
    368                            this.worldRenderersToUpdate.add(this.worldRenderers[(var6 * this.renderChunksTall + var10) * this.renderChunksWide + var9]);
    369                            var2 += 3;
    370                        }
    371                    }
    372                }
    373
    374                if (this.theWorld != null)
    375                {
    376                    EntityLiving var11 = this.mc.renderViewEntity;
    377
    378                    if (var11 != null)
    379                    {
    380                        this.markRenderersForNewPosition(MathHelper.floor_double(var11.posX), MathHelper.floor_double(var11.posY), MathHelper.floor_double(var11.posZ));
    381                        Arrays.sort(this.sortedWorldRenderers, new EntitySorter(var11));
    382                    }
    383                }
    384
    385                this.renderEntitiesStartupCounter = 2;
    386            }
    387        }
    388
    389        /**
    390         * Renders all entities within range and within the frustrum. Args: pos, frustrum, partialTickTime
    391         */
    392        public void renderEntities(Vec3 par1Vec3, ICamera par2ICamera, float par3)
    393        {
    394            if (this.renderEntitiesStartupCounter > 0)
    395            {
    396                --this.renderEntitiesStartupCounter;
    397            }
    398            else
    399            {
    400                this.theWorld.theProfiler.startSection("prepare");
    401                TileEntityRenderer.instance.cacheActiveRenderInfo(this.theWorld, this.renderEngine, this.mc.fontRenderer, this.mc.renderViewEntity, par3);
    402                RenderManager.instance.cacheActiveRenderInfo(this.theWorld, this.renderEngine, this.mc.fontRenderer, this.mc.renderViewEntity, this.mc.gameSettings, par3);
    403                this.countEntitiesTotal = 0;
    404                this.countEntitiesRendered = 0;
    405                this.countEntitiesHidden = 0;
    406                EntityLiving var4 = this.mc.renderViewEntity;
    407                RenderManager.renderPosX = var4.lastTickPosX + (var4.posX - var4.lastTickPosX) * (double)par3;
    408                RenderManager.renderPosY = var4.lastTickPosY + (var4.posY - var4.lastTickPosY) * (double)par3;
    409                RenderManager.renderPosZ = var4.lastTickPosZ + (var4.posZ - var4.lastTickPosZ) * (double)par3;
    410                TileEntityRenderer.staticPlayerX = var4.lastTickPosX + (var4.posX - var4.lastTickPosX) * (double)par3;
    411                TileEntityRenderer.staticPlayerY = var4.lastTickPosY + (var4.posY - var4.lastTickPosY) * (double)par3;
    412                TileEntityRenderer.staticPlayerZ = var4.lastTickPosZ + (var4.posZ - var4.lastTickPosZ) * (double)par3;
    413                this.mc.entityRenderer.enableLightmap((double)par3);
    414                this.theWorld.theProfiler.endStartSection("global");
    415                List var5 = this.theWorld.getLoadedEntityList();
    416                this.countEntitiesTotal = var5.size();
    417                int var6;
    418                Entity var7;
    419
    420                for (var6 = 0; var6 < this.theWorld.weatherEffects.size(); ++var6)
    421                {
    422                    var7 = (Entity)this.theWorld.weatherEffects.get(var6);
    423                    ++this.countEntitiesRendered;
    424
    425                    if (var7.isInRangeToRenderVec3D(par1Vec3))
    426                    {
    427                        RenderManager.instance.renderEntity(var7, par3);
    428                    }
    429                }
    430
    431                this.theWorld.theProfiler.endStartSection("entities");
    432
    433                for (var6 = 0; var6 < var5.size(); ++var6)
    434                {
    435                    var7 = (Entity)var5.get(var6);
    436
    437                    if (var7.isInRangeToRenderVec3D(par1Vec3) && (var7.ignoreFrustumCheck || par2ICamera.isBoundingBoxInFrustum(var7.boundingBox)) && (var7 != this.mc.renderViewEntity || this.mc.gameSettings.thirdPersonView != 0 || this.mc.renderViewEntity.isPlayerSleeping()) && this.theWorld.blockExists(MathHelper.floor_double(var7.posX), 0, MathHelper.floor_double(var7.posZ)))
    438                    {
    439                        ++this.countEntitiesRendered;
    440                        RenderManager.instance.renderEntity(var7, par3);
    441                    }
    442                }
    443
    444                this.theWorld.theProfiler.endStartSection("tileentities");
    445                RenderHelper.enableStandardItemLighting();
    446                Iterator var8 = this.tileEntities.iterator();
    447
    448                while (var8.hasNext())
    449                {
    450                    TileEntity var9 = (TileEntity)var8.next();
    451                    TileEntityRenderer.instance.renderTileEntity(var9, par3);
    452                }
    453
    454                this.mc.entityRenderer.disableLightmap((double)par3);
    455                this.theWorld.theProfiler.endSection();
    456            }
    457        }
    458
    459        /**
    460         * Gets the render info for use on the Debug screen
    461         */
    462        public String getDebugInfoRenders()
    463        {
    464            return "C: " + this.renderersBeingRendered + "/" + this.renderersLoaded + ". F: " + this.renderersBeingClipped + ", O: " + this.renderersBeingOccluded + ", E: " + this.renderersSkippingRenderPass;
    465        }
    466
    467        /**
    468         * Gets the entities info for use on the Debug screen
    469         */
    470        public String getDebugInfoEntities()
    471        {
    472            return "E: " + this.countEntitiesRendered + "/" + this.countEntitiesTotal + ". B: " + this.countEntitiesHidden + ", I: " + (this.countEntitiesTotal - this.countEntitiesHidden - this.countEntitiesRendered);
    473        }
    474
    475        /**
    476         * Goes through all the renderers setting new positions on them and those that have their position changed are
    477         * adding to be updated
    478         */
    479        private void markRenderersForNewPosition(int par1, int par2, int par3)
    480        {
    481            par1 -= 8;
    482            par2 -= 8;
    483            par3 -= 8;
    484            this.minBlockX = Integer.MAX_VALUE;
    485            this.minBlockY = Integer.MAX_VALUE;
    486            this.minBlockZ = Integer.MAX_VALUE;
    487            this.maxBlockX = Integer.MIN_VALUE;
    488            this.maxBlockY = Integer.MIN_VALUE;
    489            this.maxBlockZ = Integer.MIN_VALUE;
    490            int var4 = this.renderChunksWide * 16;
    491            int var5 = var4 / 2;
    492
    493            for (int var6 = 0; var6 < this.renderChunksWide; ++var6)
    494            {
    495                int var7 = var6 * 16;
    496                int var8 = var7 + var5 - par1;
    497
    498                if (var8 < 0)
    499                {
    500                    var8 -= var4 - 1;
    501                }
    502
    503                var8 /= var4;
    504                var7 -= var8 * var4;
    505
    506                if (var7 < this.minBlockX)
    507                {
    508                    this.minBlockX = var7;
    509                }
    510
    511                if (var7 > this.maxBlockX)
    512                {
    513                    this.maxBlockX = var7;
    514                }
    515
    516                for (int var9 = 0; var9 < this.renderChunksDeep; ++var9)
    517                {
    518                    int var10 = var9 * 16;
    519                    int var11 = var10 + var5 - par3;
    520
    521                    if (var11 < 0)
    522                    {
    523                        var11 -= var4 - 1;
    524                    }
    525
    526                    var11 /= var4;
    527                    var10 -= var11 * var4;
    528
    529                    if (var10 < this.minBlockZ)
    530                    {
    531                        this.minBlockZ = var10;
    532                    }
    533
    534                    if (var10 > this.maxBlockZ)
    535                    {
    536                        this.maxBlockZ = var10;
    537                    }
    538
    539                    for (int var12 = 0; var12 < this.renderChunksTall; ++var12)
    540                    {
    541                        int var13 = var12 * 16;
    542
    543                        if (var13 < this.minBlockY)
    544                        {
    545                            this.minBlockY = var13;
    546                        }
    547
    548                        if (var13 > this.maxBlockY)
    549                        {
    550                            this.maxBlockY = var13;
    551                        }
    552
    553                        WorldRenderer var14 = this.worldRenderers[(var9 * this.renderChunksTall + var12) * this.renderChunksWide + var6];
    554                        boolean var15 = var14.needsUpdate;
    555                        var14.setPosition(var7, var13, var10);
    556
    557                        if (!var15 && var14.needsUpdate)
    558                        {
    559                            this.worldRenderersToUpdate.add(var14);
    560                        }
    561                    }
    562                }
    563            }
    564        }
    565
    566        /**
    567         * Sorts all renderers based on the passed in entity. Args: entityLiving, renderPass, partialTickTime
    568         */
    569        public int sortAndRender(EntityLiving par1EntityLiving, int par2, double par3)
    570        {
    571            this.theWorld.theProfiler.startSection("sortchunks");
    572
    573            for (int var5 = 0; var5 < 10; ++var5)
    574            {
    575                this.worldRenderersCheckIndex = (this.worldRenderersCheckIndex + 1) % this.worldRenderers.length;
    576                WorldRenderer var6 = this.worldRenderers[this.worldRenderersCheckIndex];
    577
    578                if (var6.needsUpdate && !this.worldRenderersToUpdate.contains(var6))
    579                {
    580                    this.worldRenderersToUpdate.add(var6);
    581                }
    582            }
    583
    584            if (this.mc.gameSettings.renderDistance != this.renderDistance)
    585            {
    586                this.loadRenderers();
    587            }
    588
    589            if (par2 == 0)
    590            {
    591                this.renderersLoaded = 0;
    592                this.dummyRenderInt = 0;
    593                this.renderersBeingClipped = 0;
    594                this.renderersBeingOccluded = 0;
    595                this.renderersBeingRendered = 0;
    596                this.renderersSkippingRenderPass = 0;
    597            }
    598
    599            double var33 = par1EntityLiving.lastTickPosX + (par1EntityLiving.posX - par1EntityLiving.lastTickPosX) * par3;
    600            double var7 = par1EntityLiving.lastTickPosY + (par1EntityLiving.posY - par1EntityLiving.lastTickPosY) * par3;
    601            double var9 = par1EntityLiving.lastTickPosZ + (par1EntityLiving.posZ - par1EntityLiving.lastTickPosZ) * par3;
    602            double var11 = par1EntityLiving.posX - this.prevSortX;
    603            double var13 = par1EntityLiving.posY - this.prevSortY;
    604            double var15 = par1EntityLiving.posZ - this.prevSortZ;
    605
    606            if (var11 * var11 + var13 * var13 + var15 * var15 > 16.0D)
    607            {
    608                this.prevSortX = par1EntityLiving.posX;
    609                this.prevSortY = par1EntityLiving.posY;
    610                this.prevSortZ = par1EntityLiving.posZ;
    611                this.markRenderersForNewPosition(MathHelper.floor_double(par1EntityLiving.posX), MathHelper.floor_double(par1EntityLiving.posY), MathHelper.floor_double(par1EntityLiving.posZ));
    612                Arrays.sort(this.sortedWorldRenderers, new EntitySorter(par1EntityLiving));
    613            }
    614
    615            RenderHelper.disableStandardItemLighting();
    616            byte var17 = 0;
    617            int var34;
    618
    619            if (this.occlusionEnabled && this.mc.gameSettings.advancedOpengl && !this.mc.gameSettings.anaglyph && par2 == 0)
    620            {
    621                byte var18 = 0;
    622                int var19 = 16;
    623                this.checkOcclusionQueryResult(var18, var19);
    624
    625                for (int var20 = var18; var20 < var19; ++var20)
    626                {
    627                    this.sortedWorldRenderers[var20].isVisible = true;
    628                }
    629
    630                this.theWorld.theProfiler.endStartSection("render");
    631                var34 = var17 + this.renderSortedRenderers(var18, var19, par2, par3);
    632
    633                do
    634                {
    635                    this.theWorld.theProfiler.endStartSection("occ");
    636                    int var35 = var19;
    637                    var19 *= 2;
    638
    639                    if (var19 > this.sortedWorldRenderers.length)
    640                    {
    641                        var19 = this.sortedWorldRenderers.length;
    642                    }
    643
    644                    GL11.glDisable(GL11.GL_TEXTURE_2D);
    645                    GL11.glDisable(GL11.GL_LIGHTING);
    646                    GL11.glDisable(GL11.GL_ALPHA_TEST);
    647                    GL11.glDisable(GL11.GL_FOG);
    648                    GL11.glColorMask(false, false, false, false);
    649                    GL11.glDepthMask(false);
    650                    this.theWorld.theProfiler.startSection("check");
    651                    this.checkOcclusionQueryResult(var35, var19);
    652                    this.theWorld.theProfiler.endSection();
    653                    GL11.glPushMatrix();
    654                    float var36 = 0.0F;
    655                    float var21 = 0.0F;
    656                    float var22 = 0.0F;
    657
    658                    for (int var23 = var35; var23 < var19; ++var23)
    659                    {
    660                        if (this.sortedWorldRenderers[var23].skipAllRenderPasses())
    661                        {
    662                            this.sortedWorldRenderers[var23].isInFrustum = false;
    663                        }
    664                        else
    665                        {
    666                            if (!this.sortedWorldRenderers[var23].isInFrustum)
    667                            {
    668                                this.sortedWorldRenderers[var23].isVisible = true;
    669                            }
    670
    671                            if (this.sortedWorldRenderers[var23].isInFrustum && !this.sortedWorldRenderers[var23].isWaitingOnOcclusionQuery)
    672                            {
    673                                float var24 = MathHelper.sqrt_float(this.sortedWorldRenderers[var23].distanceToEntitySquared(par1EntityLiving));
    674                                int var25 = (int)(1.0F + var24 / 128.0F);
    675
    676                                if (this.cloudOffsetX % var25 == var23 % var25)
    677                                {
    678                                    WorldRenderer var26 = this.sortedWorldRenderers[var23];
    679                                    float var27 = (float)((double)var26.posXMinus - var33);
    680                                    float var28 = (float)((double)var26.posYMinus - var7);
    681                                    float var29 = (float)((double)var26.posZMinus - var9);
    682                                    float var30 = var27 - var36;
    683                                    float var31 = var28 - var21;
    684                                    float var32 = var29 - var22;
    685
    686                                    if (var30 != 0.0F || var31 != 0.0F || var32 != 0.0F)
    687                                    {
    688                                        GL11.glTranslatef(var30, var31, var32);
    689                                        var36 += var30;
    690                                        var21 += var31;
    691                                        var22 += var32;
    692                                    }
    693
    694                                    this.theWorld.theProfiler.startSection("bb");
    695                                    ARBOcclusionQuery.glBeginQueryARB(ARBOcclusionQuery.GL_SAMPLES_PASSED_ARB, this.sortedWorldRenderers[var23].glOcclusionQuery);
    696                                    this.sortedWorldRenderers[var23].callOcclusionQueryList();
    697                                    ARBOcclusionQuery.glEndQueryARB(ARBOcclusionQuery.GL_SAMPLES_PASSED_ARB);
    698                                    this.theWorld.theProfiler.endSection();
    699                                    this.sortedWorldRenderers[var23].isWaitingOnOcclusionQuery = true;
    700                                }
    701                            }
    702                        }
    703                    }
    704
    705                    GL11.glPopMatrix();
    706
    707                    if (this.mc.gameSettings.anaglyph)
    708                    {
    709                        if (EntityRenderer.anaglyphField == 0)
    710                        {
    711                            GL11.glColorMask(false, true, true, true);
    712                        }
    713                        else
    714                        {
    715                            GL11.glColorMask(true, false, false, true);
    716                        }
    717                    }
    718                    else
    719                    {
    720                        GL11.glColorMask(true, true, true, true);
    721                    }
    722
    723                    GL11.glDepthMask(true);
    724                    GL11.glEnable(GL11.GL_TEXTURE_2D);
    725                    GL11.glEnable(GL11.GL_ALPHA_TEST);
    726                    GL11.glEnable(GL11.GL_FOG);
    727                    this.theWorld.theProfiler.endStartSection("render");
    728                    var34 += this.renderSortedRenderers(var35, var19, par2, par3);
    729                }
    730                while (var19 < this.sortedWorldRenderers.length);
    731            }
    732            else
    733            {
    734                this.theWorld.theProfiler.endStartSection("render");
    735                var34 = var17 + this.renderSortedRenderers(0, this.sortedWorldRenderers.length, par2, par3);
    736            }
    737
    738            this.theWorld.theProfiler.endSection();
    739            return var34;
    740        }
    741
    742        private void checkOcclusionQueryResult(int par1, int par2)
    743        {
    744            for (int var3 = par1; var3 < par2; ++var3)
    745            {
    746                if (this.sortedWorldRenderers[var3].isWaitingOnOcclusionQuery)
    747                {
    748                    this.occlusionResult.clear();
    749                    ARBOcclusionQuery.glGetQueryObjectuARB(this.sortedWorldRenderers[var3].glOcclusionQuery, ARBOcclusionQuery.GL_QUERY_RESULT_AVAILABLE_ARB, this.occlusionResult);
    750
    751                    if (this.occlusionResult.get(0) != 0)
    752                    {
    753                        this.sortedWorldRenderers[var3].isWaitingOnOcclusionQuery = false;
    754                        this.occlusionResult.clear();
    755                        ARBOcclusionQuery.glGetQueryObjectuARB(this.sortedWorldRenderers[var3].glOcclusionQuery, ARBOcclusionQuery.GL_QUERY_RESULT_ARB, this.occlusionResult);
    756                        this.sortedWorldRenderers[var3].isVisible = this.occlusionResult.get(0) != 0;
    757                    }
    758                }
    759            }
    760        }
    761
    762        /**
    763         * Renders the sorted renders for the specified render pass. Args: startRenderer, numRenderers, renderPass,
    764         * partialTickTime
    765         */
    766        private int renderSortedRenderers(int par1, int par2, int par3, double par4)
    767        {
    768            this.glRenderLists.clear();
    769            int var6 = 0;
    770
    771            for (int var7 = par1; var7 < par2; ++var7)
    772            {
    773                if (par3 == 0)
    774                {
    775                    ++this.renderersLoaded;
    776
    777                    if (this.sortedWorldRenderers[var7].skipRenderPass[par3])
    778                    {
    779                        ++this.renderersSkippingRenderPass;
    780                    }
    781                    else if (!this.sortedWorldRenderers[var7].isInFrustum)
    782                    {
    783                        ++this.renderersBeingClipped;
    784                    }
    785                    else if (this.occlusionEnabled && !this.sortedWorldRenderers[var7].isVisible)
    786                    {
    787                        ++this.renderersBeingOccluded;
    788                    }
    789                    else
    790                    {
    791                        ++this.renderersBeingRendered;
    792                    }
    793                }
    794
    795                if (!this.sortedWorldRenderers[var7].skipRenderPass[par3] && this.sortedWorldRenderers[var7].isInFrustum && (!this.occlusionEnabled || this.sortedWorldRenderers[var7].isVisible))
    796                {
    797                    int var8 = this.sortedWorldRenderers[var7].getGLCallListForPass(par3);
    798
    799                    if (var8 >= 0)
    800                    {
    801                        this.glRenderLists.add(this.sortedWorldRenderers[var7]);
    802                        ++var6;
    803                    }
    804                }
    805            }
    806
    807            EntityLiving var19 = this.mc.renderViewEntity;
    808            double var20 = var19.lastTickPosX + (var19.posX - var19.lastTickPosX) * par4;
    809            double var10 = var19.lastTickPosY + (var19.posY - var19.lastTickPosY) * par4;
    810            double var12 = var19.lastTickPosZ + (var19.posZ - var19.lastTickPosZ) * par4;
    811            int var14 = 0;
    812            RenderList[] var15 = this.allRenderLists;
    813            int var16 = var15.length;
    814            int var17;
    815
    816            for (var17 = 0; var17 < var16; ++var17)
    817            {
    818                RenderList var18 = var15[var17];
    819                var18.func_78421_b();
    820            }
    821
    822            WorldRenderer var22;
    823
    824            for (Iterator var21 = this.glRenderLists.iterator(); var21.hasNext(); this.allRenderLists[var17].func_78420_a(var22.getGLCallListForPass(par3)))
    825            {
    826                var22 = (WorldRenderer)var21.next();
    827                var17 = -1;
    828
    829                for (int var23 = 0; var23 < var14; ++var23)
    830                {
    831                    if (this.allRenderLists[var23].func_78418_a(var22.posXMinus, var22.posYMinus, var22.posZMinus))
    832                    {
    833                        var17 = var23;
    834                    }
    835                }
    836
    837                if (var17 < 0)
    838                {
    839                    var17 = var14++;
    840                    this.allRenderLists[var17].func_78422_a(var22.posXMinus, var22.posYMinus, var22.posZMinus, var20, var10, var12);
    841                }
    842            }
    843
    844            this.renderAllRenderLists(par3, par4);
    845            return var6;
    846        }
    847
    848        /**
    849         * Render all render lists
    850         */
    851        public void renderAllRenderLists(int par1, double par2)
    852        {
    853            this.mc.entityRenderer.enableLightmap(par2);
    854            RenderList[] var4 = this.allRenderLists;
    855            int var5 = var4.length;
    856
    857            for (int var6 = 0; var6 < var5; ++var6)
    858            {
    859                RenderList var7 = var4[var6];
    860                var7.func_78419_a();
    861            }
    862
    863            this.mc.entityRenderer.disableLightmap(par2);
    864        }
    865
    866        public void updateClouds()
    867        {
    868            ++this.cloudOffsetX;
    869        }
    870
    871        /**
    872         * Renders the sky with the partial tick time. Args: partialTickTime
    873         */
    874        public void renderSky(float par1)
    875        {
    876            SkyProvider skyProvider = null;
    877            if ((skyProvider = this.mc.theWorld.provider.getSkyProvider()) != null)
    878            {
    879                skyProvider.render(par1, this.theWorld, mc);
    880                return;
    881            }
    882            if (this.mc.theWorld.provider.dimensionId == 1)
    883            {
    884                GL11.glDisable(GL11.GL_FOG);
    885                GL11.glDisable(GL11.GL_ALPHA_TEST);
    886                GL11.glEnable(GL11.GL_BLEND);
    887                GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    888                RenderHelper.disableStandardItemLighting();
    889                GL11.glDepthMask(false);
    890                this.renderEngine.bindTexture(this.renderEngine.getTexture("/misc/tunnel.png"));
    891                Tessellator var21 = Tessellator.instance;
    892
    893                for (int var22 = 0; var22 < 6; ++var22)
    894                {
    895                    GL11.glPushMatrix();
    896
    897                    if (var22 == 1)
    898                    {
    899                        GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F);
    900                    }
    901
    902                    if (var22 == 2)
    903                    {
    904                        GL11.glRotatef(-90.0F, 1.0F, 0.0F, 0.0F);
    905                    }
    906
    907                    if (var22 == 3)
    908                    {
    909                        GL11.glRotatef(180.0F, 1.0F, 0.0F, 0.0F);
    910                    }
    911
    912                    if (var22 == 4)
    913                    {
    914                        GL11.glRotatef(90.0F, 0.0F, 0.0F, 1.0F);
    915                    }
    916
    917                    if (var22 == 5)
    918                    {
    919                        GL11.glRotatef(-90.0F, 0.0F, 0.0F, 1.0F);
    920                    }
    921
    922                    var21.startDrawingQuads();
    923                    var21.setColorOpaque_I(2631720);
    924                    var21.addVertexWithUV(-100.0D, -100.0D, -100.0D, 0.0D, 0.0D);
    925                    var21.addVertexWithUV(-100.0D, -100.0D, 100.0D, 0.0D, 16.0D);
    926                    var21.addVertexWithUV(100.0D, -100.0D, 100.0D, 16.0D, 16.0D);
    927                    var21.addVertexWithUV(100.0D, -100.0D, -100.0D, 16.0D, 0.0D);
    928                    var21.draw();
    929                    GL11.glPopMatrix();
    930                }
    931
    932                GL11.glDepthMask(true);
    933                GL11.glEnable(GL11.GL_TEXTURE_2D);
    934                GL11.glEnable(GL11.GL_ALPHA_TEST);
    935            }
    936            else if (this.mc.theWorld.provider.isSurfaceWorld())
    937            {
    938                GL11.glDisable(GL11.GL_TEXTURE_2D);
    939                Vec3 var2 = this.theWorld.getSkyColor(this.mc.renderViewEntity, par1);
    940                float var3 = (float)var2.xCoord;
    941                float var4 = (float)var2.yCoord;
    942                float var5 = (float)var2.zCoord;
    943                float var8;
    944
    945                if (this.mc.gameSettings.anaglyph)
    946                {
    947                    float var6 = (var3 * 30.0F + var4 * 59.0F + var5 * 11.0F) / 100.0F;
    948                    float var7 = (var3 * 30.0F + var4 * 70.0F) / 100.0F;
    949                    var8 = (var3 * 30.0F + var5 * 70.0F) / 100.0F;
    950                    var3 = var6;
    951                    var4 = var7;
    952                    var5 = var8;
    953                }
    954
    955                GL11.glColor3f(var3, var4, var5);
    956                Tessellator var23 = Tessellator.instance;
    957                GL11.glDepthMask(false);
    958                GL11.glEnable(GL11.GL_FOG);
    959                GL11.glColor3f(var3, var4, var5);
    960                GL11.glCallList(this.glSkyList);
    961                GL11.glDisable(GL11.GL_FOG);
    962                GL11.glDisable(GL11.GL_ALPHA_TEST);
    963                GL11.glEnable(GL11.GL_BLEND);
    964                GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    965                RenderHelper.disableStandardItemLighting();
    966                float[] var24 = this.theWorld.provider.calcSunriseSunsetColors(this.theWorld.getCelestialAngle(par1), par1);
    967                float var9;
    968                float var10;
    969                float var11;
    970                float var12;
    971
    972                if (var24 != null)
    973                {
    974                    GL11.glDisable(GL11.GL_TEXTURE_2D);
    975                    GL11.glShadeModel(GL11.GL_SMOOTH);
    976                    GL11.glPushMatrix();
    977                    GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F);
    978                    GL11.glRotatef(MathHelper.sin(this.theWorld.getCelestialAngleRadians(par1)) < 0.0F ? 180.0F : 0.0F, 0.0F, 0.0F, 1.0F);
    979                    GL11.glRotatef(90.0F, 0.0F, 0.0F, 1.0F);
    980                    var8 = var24[0];
    981                    var9 = var24[1];
    982                    var10 = var24[2];
    983                    float var13;
    984
    985                    if (this.mc.gameSettings.anaglyph)
    986                    {
    987                        var11 = (var8 * 30.0F + var9 * 59.0F + var10 * 11.0F) / 100.0F;
    988                        var12 = (var8 * 30.0F + var9 * 70.0F) / 100.0F;
    989                        var13 = (var8 * 30.0F + var10 * 70.0F) / 100.0F;
    990                        var8 = var11;
    991                        var9 = var12;
    992                        var10 = var13;
    993                    }
    994
    995                    var23.startDrawing(6);
    996                    var23.setColorRGBA_F(var8, var9, var10, var24[3]);
    997                    var23.addVertex(0.0D, 100.0D, 0.0D);
    998                    byte var26 = 16;
    999                    var23.setColorRGBA_F(var24[0], var24[1], var24[2], 0.0F);
    1000
    1001                    for (int var27 = 0; var27 <= var26; ++var27)
    1002                    {
    1003                        var13 = (float)var27 * (float)Math.PI * 2.0F / (float)var26;
    1004                        float var14 = MathHelper.sin(var13);
    1005                        float var15 = MathHelper.cos(var13);
    1006                        var23.addVertex((double)(var14 * 120.0F), (double)(var15 * 120.0F), (double)(-var15 * 40.0F * var24[3]));
    1007                    }
    1008
    1009                    var23.draw();
    1010                    GL11.glPopMatrix();
    1011                    GL11.glShadeModel(GL11.GL_FLAT);
    1012                }
    1013
    1014                GL11.glEnable(GL11.GL_TEXTURE_2D);
    1015                GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
    1016                GL11.glPushMatrix();
    1017                var8 = 1.0F - this.theWorld.getRainStrength(par1);
    1018                var9 = 0.0F;
    1019                var10 = 0.0F;
    1020                var11 = 0.0F;
    1021                GL11.glColor4f(1.0F, 1.0F, 1.0F, var8);
    1022                GL11.glTranslatef(var9, var10, var11);
    1023                GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F);
    1024                GL11.glRotatef(this.theWorld.getCelestialAngle(par1) * 360.0F, 1.0F, 0.0F, 0.0F);
    1025                var12 = 30.0F;
    1026                GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.renderEngine.getTexture("/terrain/sun.png"));
    1027                var23.startDrawingQuads();
    1028                var23.addVertexWithUV((double)(-var12), 100.0D, (double)(-var12), 0.0D, 0.0D);
    1029                var23.addVertexWithUV((double)var12, 100.0D, (double)(-var12), 1.0D, 0.0D);
    1030                var23.addVertexWithUV((double)var12, 100.0D, (double)var12, 1.0D, 1.0D);
    1031                var23.addVertexWithUV((double)(-var12), 100.0D, (double)var12, 0.0D, 1.0D);
    1032                var23.draw();
    1033                var12 = 20.0F;
    1034                GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.renderEngine.getTexture("/terrain/moon_phases.png"));
    1035                int var28 = this.theWorld.getMoonPhase(par1);
    1036                int var30 = var28 % 4;
    1037                int var29 = var28 / 4 % 2;
    1038                float var16 = (float)(var30 + 0) / 4.0F;
    1039                float var17 = (float)(var29 + 0) / 2.0F;
    1040                float var18 = (float)(var30 + 1) / 4.0F;
    1041                float var19 = (float)(var29 + 1) / 2.0F;
    1042                var23.startDrawingQuads();
    1043                var23.addVertexWithUV((double)(-var12), -100.0D, (double)var12, (double)var18, (double)var19);
    1044                var23.addVertexWithUV((double)var12, -100.0D, (double)var12, (double)var16, (double)var19);
    1045                var23.addVertexWithUV((double)var12, -100.0D, (double)(-var12), (double)var16, (double)var17);
    1046                var23.addVertexWithUV((double)(-var12), -100.0D, (double)(-var12), (double)var18, (double)var17);
    1047                var23.draw();
    1048                GL11.glDisable(GL11.GL_TEXTURE_2D);
    1049                float var20 = this.theWorld.getStarBrightness(par1) * var8;
    1050
    1051                if (var20 > 0.0F)
    1052                {
    1053                    GL11.glColor4f(var20, var20, var20, var20);
    1054                    GL11.glCallList(this.starGLCallList);
    1055                }
    1056
    1057                GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    1058                GL11.glDisable(GL11.GL_BLEND);
    1059                GL11.glEnable(GL11.GL_ALPHA_TEST);
    1060                GL11.glEnable(GL11.GL_FOG);
    1061                GL11.glPopMatrix();
    1062                GL11.glDisable(GL11.GL_TEXTURE_2D);
    1063                GL11.glColor3f(0.0F, 0.0F, 0.0F);
    1064                double var25 = this.mc.thePlayer.getPosition(par1).yCoord - this.theWorld.getHorizon();
    1065
    1066                if (var25 < 0.0D)
    1067                {
    1068                    GL11.glPushMatrix();
    1069                    GL11.glTranslatef(0.0F, 12.0F, 0.0F);
    1070                    GL11.glCallList(this.glSkyList2);
    1071                    GL11.glPopMatrix();
    1072                    var10 = 1.0F;
    1073                    var11 = -((float)(var25 + 65.0D));
    1074                    var12 = -var10;
    1075                    var23.startDrawingQuads();
    1076                    var23.setColorRGBA_I(0, 255);
    1077                    var23.addVertex((double)(-var10), (double)var11, (double)var10);
    1078                    var23.addVertex((double)var10, (double)var11, (double)var10);
    1079                    var23.addVertex((double)var10, (double)var12, (double)var10);
    1080                    var23.addVertex((double)(-var10), (double)var12, (double)var10);
    1081                    var23.addVertex((double)(-var10), (double)var12, (double)(-var10));
    1082                    var23.addVertex((double)var10, (double)var12, (double)(-var10));
    1083                    var23.addVertex((double)var10, (double)var11, (double)(-var10));
    1084                    var23.addVertex((double)(-var10), (double)var11, (double)(-var10));
    1085                    var23.addVertex((double)var10, (double)var12, (double)(-var10));
    1086                    var23.addVertex((double)var10, (double)var12, (double)var10);
    1087                    var23.addVertex((double)var10, (double)var11, (double)var10);
    1088                    var23.addVertex((double)var10, (double)var11, (double)(-var10));
    1089                    var23.addVertex((double)(-var10), (double)var11, (double)(-var10));
    1090                    var23.addVertex((double)(-var10), (double)var11, (double)var10);
    1091                    var23.addVertex((double)(-var10), (double)var12, (double)var10);
    1092                    var23.addVertex((double)(-var10), (double)var12, (double)(-var10));
    1093                    var23.addVertex((double)(-var10), (double)var12, (double)(-var10));
    1094                    var23.addVertex((double)(-var10), (double)var12, (double)var10);
    1095                    var23.addVertex((double)var10, (double)var12, (double)var10);
    1096                    var23.addVertex((double)var10, (double)var12, (double)(-var10));
    1097                    var23.draw();
    1098                }
    1099
    1100                if (this.theWorld.provider.isSkyColored())
    1101                {
    1102                    GL11.glColor3f(var3 * 0.2F + 0.04F, var4 * 0.2F + 0.04F, var5 * 0.6F + 0.1F);
    1103                }
    1104                else
    1105                {
    1106                    GL11.glColor3f(var3, var4, var5);
    1107                }
    1108
    1109                GL11.glPushMatrix();
    1110                GL11.glTranslatef(0.0F, -((float)(var25 - 16.0D)), 0.0F);
    1111                GL11.glCallList(this.glSkyList2);
    1112                GL11.glPopMatrix();
    1113                GL11.glEnable(GL11.GL_TEXTURE_2D);
    1114                GL11.glDepthMask(true);
    1115            }
    1116        }
    1117
    1118        public void renderClouds(float par1)
    1119        {
    1120            if (this.mc.theWorld.provider.isSurfaceWorld())
    1121            {
    1122                if (this.mc.gameSettings.fancyGraphics)
    1123                {
    1124                    this.renderCloudsFancy(par1);
    1125                }
    1126                else
    1127                {
    1128                    GL11.glDisable(GL11.GL_CULL_FACE);
    1129                    float var2 = (float)(this.mc.renderViewEntity.lastTickPosY + (this.mc.renderViewEntity.posY - this.mc.renderViewEntity.lastTickPosY) * (double)par1);
    1130                    byte var3 = 32;
    1131                    int var4 = 256 / var3;
    1132                    Tessellator var5 = Tessellator.instance;
    1133                    GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.renderEngine.getTexture("/environment/clouds.png"));
    1134                    GL11.glEnable(GL11.GL_BLEND);
    1135                    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    1136                    Vec3 var6 = this.theWorld.drawClouds(par1);
    1137                    float var7 = (float)var6.xCoord;
    1138                    float var8 = (float)var6.yCoord;
    1139                    float var9 = (float)var6.zCoord;
    1140                    float var10;
    1141
    1142                    if (this.mc.gameSettings.anaglyph)
    1143                    {
    1144                        var10 = (var7 * 30.0F + var8 * 59.0F + var9 * 11.0F) / 100.0F;
    1145                        float var11 = (var7 * 30.0F + var8 * 70.0F) / 100.0F;
    1146                        float var12 = (var7 * 30.0F + var9 * 70.0F) / 100.0F;
    1147                        var7 = var10;
    1148                        var8 = var11;
    1149                        var9 = var12;
    1150                    }
    1151
    1152                    var10 = 4.8828125E-4F;
    1153                    double var24 = (double)((float)this.cloudOffsetX + par1);
    1154                    double var13 = this.mc.renderViewEntity.prevPosX + (this.mc.renderViewEntity.posX - this.mc.renderViewEntity.prevPosX) * (double)par1 + var24 * 0.029999999329447746D;
    1155                    double var15 = this.mc.renderViewEntity.prevPosZ + (this.mc.renderViewEntity.posZ - this.mc.renderViewEntity.prevPosZ) * (double)par1;
    1156                    int var17 = MathHelper.floor_double(var13 / 2048.0D);
    1157                    int var18 = MathHelper.floor_double(var15 / 2048.0D);
    1158                    var13 -= (double)(var17 * 2048);
    1159                    var15 -= (double)(var18 * 2048);
    1160                    float var19 = this.theWorld.provider.getCloudHeight() - var2 + 0.33F;
    1161                    float var20 = (float)(var13 * (double)var10);
    1162                    float var21 = (float)(var15 * (double)var10);
    1163                    var5.startDrawingQuads();
    1164                    var5.setColorRGBA_F(var7, var8, var9, 0.8F);
    1165
    1166                    for (int var22 = -var3 * var4; var22 < var3 * var4; var22 += var3)
    1167                    {
    1168                        for (int var23 = -var3 * var4; var23 < var3 * var4; var23 += var3)
    1169                        {
    1170                            var5.addVertexWithUV((double)(var22 + 0), (double)var19, (double)(var23 + var3), (double)((float)(var22 + 0) * var10 + var20), (double)((float)(var23 + var3) * var10 + var21));
    1171                            var5.addVertexWithUV((double)(var22 + var3), (double)var19, (double)(var23 + var3), (double)((float)(var22 + var3) * var10 + var20), (double)((float)(var23 + var3) * var10 + var21));
    1172                            var5.addVertexWithUV((double)(var22 + var3), (double)var19, (double)(var23 + 0), (double)((float)(var22 + var3) * var10 + var20), (double)((float)(var23 + 0) * var10 + var21));
    1173                            var5.addVertexWithUV((double)(var22 + 0), (double)var19, (double)(var23 + 0), (double)((float)(var22 + 0) * var10 + var20), (double)((float)(var23 + 0) * var10 + var21));
    1174                        }
    1175                    }
    1176
    1177                    var5.draw();
    1178                    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    1179                    GL11.glDisable(GL11.GL_BLEND);
    1180                    GL11.glEnable(GL11.GL_CULL_FACE);
    1181                }
    1182            }
    1183        }
    1184
    1185        public boolean func_72721_a(double par1, double par3, double par5, float par7)
    1186        {
    1187            return false;
    1188        }
    1189
    1190        /**
    1191         * Renders the 3d fancy clouds
    1192         */
    1193        public void renderCloudsFancy(float par1)
    1194        {
    1195            GL11.glDisable(GL11.GL_CULL_FACE);
    1196            float var2 = (float)(this.mc.renderViewEntity.lastTickPosY + (this.mc.renderViewEntity.posY - this.mc.renderViewEntity.lastTickPosY) * (double)par1);
    1197            Tessellator var3 = Tessellator.instance;
    1198            float var4 = 12.0F;
    1199            float var5 = 4.0F;
    1200            double var6 = (double)((float)this.cloudOffsetX + par1);
    1201            double var8 = (this.mc.renderViewEntity.prevPosX + (this.mc.renderViewEntity.posX - this.mc.renderViewEntity.prevPosX) * (double)par1 + var6 * 0.029999999329447746D) / (double)var4;
    1202            double var10 = (this.mc.renderViewEntity.prevPosZ + (this.mc.renderViewEntity.posZ - this.mc.renderViewEntity.prevPosZ) * (double)par1) / (double)var4 + 0.33000001311302185D;
    1203            float var12 = this.theWorld.provider.getCloudHeight() - var2 + 0.33F;
    1204            int var13 = MathHelper.floor_double(var8 / 2048.0D);
    1205            int var14 = MathHelper.floor_double(var10 / 2048.0D);
    1206            var8 -= (double)(var13 * 2048);
    1207            var10 -= (double)(var14 * 2048);
    1208            GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.renderEngine.getTexture("/environment/clouds.png"));
    1209            GL11.glEnable(GL11.GL_BLEND);
    1210            GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    1211            Vec3 var15 = this.theWorld.drawClouds(par1);
    1212            float var16 = (float)var15.xCoord;
    1213            float var17 = (float)var15.yCoord;
    1214            float var18 = (float)var15.zCoord;
    1215            float var19;
    1216            float var21;
    1217            float var20;
    1218
    1219            if (this.mc.gameSettings.anaglyph)
    1220            {
    1221                var19 = (var16 * 30.0F + var17 * 59.0F + var18 * 11.0F) / 100.0F;
    1222                var20 = (var16 * 30.0F + var17 * 70.0F) / 100.0F;
    1223                var21 = (var16 * 30.0F + var18 * 70.0F) / 100.0F;
    1224                var16 = var19;
    1225                var17 = var20;
    1226                var18 = var21;
    1227            }
    1228
    1229            var19 = (float)(var8 * 0.0D);
    1230            var20 = (float)(var10 * 0.0D);
    1231            var21 = 0.00390625F;
    1232            var19 = (float)MathHelper.floor_double(var8) * var21;
    1233            var20 = (float)MathHelper.floor_double(var10) * var21;
    1234            float var22 = (float)(var8 - (double)MathHelper.floor_double(var8));
    1235            float var23 = (float)(var10 - (double)MathHelper.floor_double(var10));
    1236            byte var24 = 8;
    1237            byte var25 = 4;
    1238            float var26 = 9.765625E-4F;
    1239            GL11.glScalef(var4, 1.0F, var4);
    1240
    1241            for (int var27 = 0; var27 < 2; ++var27)
    1242            {
    1243                if (var27 == 0)
    1244                {
    1245                    GL11.glColorMask(false, false, false, false);
    1246                }
    1247                else if (this.mc.gameSettings.anaglyph)
    1248                {
    1249                    if (EntityRenderer.anaglyphField == 0)
    1250                    {
    1251                        GL11.glColorMask(false, true, true, true);
    1252                    }
    1253                    else
    1254                    {
    1255                        GL11.glColorMask(true, false, false, true);
    1256                    }
    1257                }
    1258                else
    1259                {
    1260                    GL11.glColorMask(true, true, true, true);
    1261                }
    1262
    1263                for (int var28 = -var25 + 1; var28 <= var25; ++var28)
    1264                {
    1265                    for (int var29 = -var25 + 1; var29 <= var25; ++var29)
    1266                    {
    1267                        var3.startDrawingQuads();
    1268                        float var30 = (float)(var28 * var24);
    1269                        float var31 = (float)(var29 * var24);
    1270                        float var32 = var30 - var22;
    1271                        float var33 = var31 - var23;
    1272
    1273                        if (var12 > -var5 - 1.0F)
    1274                        {
    1275                            var3.setColorRGBA_F(var16 * 0.7F, var17 * 0.7F, var18 * 0.7F, 0.8F);
    1276                            var3.setNormal(0.0F, -1.0F, 0.0F);
    1277                            var3.addVertexWithUV((double)(var32 + 0.0F), (double)(var12 + 0.0F), (double)(var33 + (float)var24), (double)((var30 + 0.0F) * var21 + var19), (double)((var31 + (float)var24) * var21 + var20));
    1278                            var3.addVertexWithUV((double)(var32 + (float)var24), (double)(var12 + 0.0F), (double)(var33 + (float)var24), (double)((var30 + (float)var24) * var21 + var19), (double)((var31 + (float)var24) * var21 + var20));
    1279                            var3.addVertexWithUV((double)(var32 + (float)var24), (double)(var12 + 0.0F), (double)(var33 + 0.0F), (double)((var30 + (float)var24) * var21 + var19), (double)((var31 + 0.0F) * var21 + var20));
    1280                            var3.addVertexWithUV((double)(var32 + 0.0F), (double)(var12 + 0.0F), (double)(var33 + 0.0F), (double)((var30 + 0.0F) * var21 + var19), (double)((var31 + 0.0F) * var21 + var20));
    1281                        }
    1282
    1283                        if (var12 <= var5 + 1.0F)
    1284                        {
    1285                            var3.setColorRGBA_F(var16, var17, var18, 0.8F);
    1286                            var3.setNormal(0.0F, 1.0F, 0.0F);
    1287                            var3.addVertexWithUV((double)(var32 + 0.0F), (double)(var12 + var5 - var26), (double)(var33 + (float)var24), (double)((var30 + 0.0F) * var21 + var19), (double)((var31 + (float)var24) * var21 + var20));
    1288                            var3.addVertexWithUV((double)(var32 + (float)var24), (double)(var12 + var5 - var26), (double)(var33 + (float)var24), (double)((var30 + (float)var24) * var21 + var19), (double)((var31 + (float)var24) * var21 + var20));
    1289                            var3.addVertexWithUV((double)(var32 + (float)var24), (double)(var12 + var5 - var26), (double)(var33 + 0.0F), (double)((var30 + (float)var24) * var21 + var19), (double)((var31 + 0.0F) * var21 + var20));
    1290                            var3.addVertexWithUV((double)(var32 + 0.0F), (double)(var12 + var5 - var26), (double)(var33 + 0.0F), (double)((var30 + 0.0F) * var21 + var19), (double)((var31 + 0.0F) * var21 + var20));
    1291                        }
    1292
    1293                        var3.setColorRGBA_F(var16 * 0.9F, var17 * 0.9F, var18 * 0.9F, 0.8F);
    1294                        int var34;
    1295
    1296                        if (var28 > -1)
    1297                        {
    1298                            var3.setNormal(-1.0F, 0.0F, 0.0F);
    1299
    1300                            for (var34 = 0; var34 < var24; ++var34)
    1301                            {
    1302                                var3.addVertexWithUV((double)(var32 + (float)var34 + 0.0F), (double)(var12 + 0.0F), (double)(var33 + (float)var24), (double)((var30 + (float)var34 + 0.5F) * var21 + var19), (double)((var31 + (float)var24) * var21 + var20));
    1303                                var3.addVertexWithUV((double)(var32 + (float)var34 + 0.0F), (double)(var12 + var5), (double)(var33 + (float)var24), (double)((var30 + (float)var34 + 0.5F) * var21 + var19), (double)((var31 + (float)var24) * var21 + var20));
    1304                                var3.addVertexWithUV((double)(var32 + (float)var34 + 0.0F), (double)(var12 + var5), (double)(var33 + 0.0F), (double)((var30 + (float)var34 + 0.5F) * var21 + var19), (double)((var31 + 0.0F) * var21 + var20));
    1305                                var3.addVertexWithUV((double)(var32 + (float)var34 + 0.0F), (double)(var12 + 0.0F), (double)(var33 + 0.0F), (double)((var30 + (float)var34 + 0.5F) * var21 + var19), (double)((var31 + 0.0F) * var21 + var20));
    1306                            }
    1307                        }
    1308
    1309                        if (var28 <= 1)
    1310                        {
    1311                            var3.setNormal(1.0F, 0.0F, 0.0F);
    1312
    1313                            for (var34 = 0; var34 < var24; ++var34)
    1314                            {
    1315                                var3.addVertexWithUV((double)(var32 + (float)var34 + 1.0F - var26), (double)(var12 + 0.0F), (double)(var33 + (float)var24), (double)((var30 + (float)var34 + 0.5F) * var21 + var19), (double)((var31 + (float)var24) * var21 + var20));
    1316                                var3.addVertexWithUV((double)(var32 + (float)var34 + 1.0F - var26), (double)(var12 + var5), (double)(var33 + (float)var24), (double)((var30 + (float)var34 + 0.5F) * var21 + var19), (double)((var31 + (float)var24) * var21 + var20));
    1317                                var3.addVertexWithUV((double)(var32 + (float)var34 + 1.0F - var26), (double)(var12 + var5), (double)(var33 + 0.0F), (double)((var30 + (float)var34 + 0.5F) * var21 + var19), (double)((var31 + 0.0F) * var21 + var20));
    1318                                var3.addVertexWithUV((double)(var32 + (float)var34 + 1.0F - var26), (double)(var12 + 0.0F), (double)(var33 + 0.0F), (double)((var30 + (float)var34 + 0.5F) * var21 + var19), (double)((var31 + 0.0F) * var21 + var20));
    1319                            }
    1320                        }
    1321
    1322                        var3.setColorRGBA_F(var16 * 0.8F, var17 * 0.8F, var18 * 0.8F, 0.8F);
    1323
    1324                        if (var29 > -1)
    1325                        {
    1326                            var3.setNormal(0.0F, 0.0F, -1.0F);
    1327
    1328                            for (var34 = 0; var34 < var24; ++var34)
    1329                            {
    1330                                var3.addVertexWithUV((double)(var32 + 0.0F), (double)(var12 + var5), (double)(var33 + (float)var34 + 0.0F), (double)((var30 + 0.0F) * var21 + var19), (double)((var31 + (float)var34 + 0.5F) * var21 + var20));
    1331                                var3.addVertexWithUV((double)(var32 + (float)var24), (double)(var12 + var5), (double)(var33 + (float)var34 + 0.0F), (double)((var30 + (float)var24) * var21 + var19), (double)((var31 + (float)var34 + 0.5F) * var21 + var20));
    1332                                var3.addVertexWithUV((double)(var32 + (float)var24), (double)(var12 + 0.0F), (double)(var33 + (float)var34 + 0.0F), (double)((var30 + (float)var24) * var21 + var19), (double)((var31 + (float)var34 + 0.5F) * var21 + var20));
    1333                                var3.addVertexWithUV((double)(var32 + 0.0F), (double)(var12 + 0.0F), (double)(var33 + (float)var34 + 0.0F), (double)((var30 + 0.0F) * var21 + var19), (double)((var31 + (float)var34 + 0.5F) * var21 + var20));
    1334                            }
    1335                        }
    1336
    1337                        if (var29 <= 1)
    1338                        {
    1339                            var3.setNormal(0.0F, 0.0F, 1.0F);
    1340
    1341                            for (var34 = 0; var34 < var24; ++var34)
    1342                            {
    1343                                var3.addVertexWithUV((double)(var32 + 0.0F), (double)(var12 + var5), (double)(var33 + (float)var34 + 1.0F - var26), (double)((var30 + 0.0F) * var21 + var19), (double)((var31 + (float)var34 + 0.5F) * var21 + var20));
    1344                                var3.addVertexWithUV((double)(var32 + (float)var24), (double)(var12 + var5), (double)(var33 + (float)var34 + 1.0F - var26), (double)((var30 + (float)var24) * var21 + var19), (double)((var31 + (float)var34 + 0.5F) * var21 + var20));
    1345                                var3.addVertexWithUV((double)(var32 + (float)var24), (double)(var12 + 0.0F), (double)(var33 + (float)var34 + 1.0F - var26), (double)((var30 + (float)var24) * var21 + var19), (double)((var31 + (float)var34 + 0.5F) * var21 + var20));
    1346                                var3.addVertexWithUV((double)(var32 + 0.0F), (double)(var12 + 0.0F), (double)(var33 + (float)var34 + 1.0F - var26), (double)((var30 + 0.0F) * var21 + var19), (double)((var31 + (float)var34 + 0.5F) * var21 + var20));
    1347                            }
    1348                        }
    1349
    1350                        var3.draw();
    1351                    }
    1352                }
    1353            }
    1354
    1355            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    1356            GL11.glDisable(GL11.GL_BLEND);
    1357            GL11.glEnable(GL11.GL_CULL_FACE);
    1358        }
    1359
    1360        /**
    1361         * Updates some of the renderers sorted by distance from the player
    1362         */
    1363        public boolean updateRenderers(EntityLiving par1EntityLiving, boolean par2)
    1364        {
    1365            byte var3 = 2;
    1366            RenderSorter var4 = new RenderSorter(par1EntityLiving);
    1367            WorldRenderer[] var5 = new WorldRenderer[var3];
    1368            ArrayList var6 = null;
    1369            int var7 = this.worldRenderersToUpdate.size();
    1370            int var8 = 0;
    1371            this.theWorld.theProfiler.startSection("nearChunksSearch");
    1372            int var9;
    1373            WorldRenderer var10;
    1374            int var11;
    1375            int var12;
    1376            label136:
    1377
    1378            for (var9 = 0; var9 < var7; ++var9)
    1379            {
    1380                var10 = (WorldRenderer)this.worldRenderersToUpdate.get(var9);
    1381
    1382                if (var10 != null)
    1383                {
    1384                    if (!par2)
    1385                    {
    1386                        if (var10.distanceToEntitySquared(par1EntityLiving) > 256.0F)
    1387                        {
    1388                            for (var11 = 0; var11 < var3 && (var5[var11] == null || var4.doCompare(var5[var11], var10) <= 0); ++var11)
    1389                            {
    1390                                ;
    1391                            }
    1392
    1393                            --var11;
    1394
    1395                            if (var11 > 0)
    1396                            {
    1397                                var12 = var11;
    1398
    1399                                while (true)
    1400                                {
    1401                                    --var12;
    1402
    1403                                    if (var12 == 0)
    1404                                    {
    1405                                        var5[var11] = var10;
    1406                                        continue label136;
    1407                                    }
    1408
    1409                                    var5[var12 - 1] = var5[var12];
    1410                                }
    1411                            }
    1412
    1413                            continue;
    1414                        }
    1415                    }
    1416                    else if (!var10.isInFrustum)
    1417                    {
    1418                        continue;
    1419                    }
    1420
    1421                    if (var6 == null)
    1422                    {
    1423                        var6 = new ArrayList();
    1424                    }
    1425
    1426                    ++var8;
    1427                    var6.add(var10);
    1428                    this.worldRenderersToUpdate.set(var9, (Object)null);
    1429                }
    1430            }
    1431
    1432            this.theWorld.theProfiler.endSection();
    1433            this.theWorld.theProfiler.startSection("sort");
    1434
    1435            if (var6 != null)
    1436            {
    1437                if (var6.size() > 1)
    1438                {
    1439                    Collections.sort(var6, var4);
    1440                }
    1441
    1442                for (var9 = var6.size() - 1; var9 >= 0; --var9)
    1443                {
    1444                    var10 = (WorldRenderer)var6.get(var9);
    1445                    var10.updateRenderer();
    1446                    var10.needsUpdate = false;
    1447                }
    1448            }
    1449
    1450            this.theWorld.theProfiler.endSection();
    1451            var9 = 0;
    1452            this.theWorld.theProfiler.startSection("rebuild");
    1453            int var16;
    1454
    1455            for (var16 = var3 - 1; var16 >= 0; --var16)
    1456            {
    1457                WorldRenderer var17 = var5[var16];
    1458
    1459                if (var17 != null)
    1460                {
    1461                    if (!var17.isInFrustum && var16 != var3 - 1)
    1462                    {
    1463                        var5[var16] = null;
    1464                        var5[0] = null;
    1465                        break;
    1466                    }
    1467
    1468                    var5[var16].updateRenderer();
    1469                    var5[var16].needsUpdate = false;
    1470                    ++var9;
    1471                }
    1472            }
    1473
    1474            this.theWorld.theProfiler.endSection();
    1475            this.theWorld.theProfiler.startSection("cleanup");
    1476            var16 = 0;
    1477            var11 = 0;
    1478
    1479            for (var12 = this.worldRenderersToUpdate.size(); var16 != var12; ++var16)
    1480            {
    1481                WorldRenderer var13 = (WorldRenderer)this.worldRenderersToUpdate.get(var16);
    1482
    1483                if (var13 != null)
    1484                {
    1485                    boolean var14 = false;
    1486
    1487                    for (int var15 = 0; var15 < var3 && !var14; ++var15)
    1488                    {
    1489                        if (var13 == var5[var15])
    1490                        {
    1491                            var14 = true;
    1492                        }
    1493                    }
    1494
    1495                    if (!var14)
    1496                    {
    1497                        if (var11 != var16)
    1498                        {
    1499                            this.worldRenderersToUpdate.set(var11, var13);
    1500                        }
    1501
    1502                        ++var11;
    1503                    }
    1504                }
    1505            }
    1506
    1507            this.theWorld.theProfiler.endSection();
    1508            this.theWorld.theProfiler.startSection("trim");
    1509
    1510            while (true)
    1511            {
    1512                --var16;
    1513
    1514                if (var16 < var11)
    1515                {
    1516                    this.theWorld.theProfiler.endSection();
    1517                    return var7 == var8 + var9;
    1518                }
    1519
    1520                this.worldRenderersToUpdate.remove(var16);
    1521            }
    1522        }
    1523
    1524        public void drawBlockBreaking(EntityPlayer par1EntityPlayer, MovingObjectPosition par2MovingObjectPosition, int par3, ItemStack par4ItemStack, float par5)
    1525        {
    1526            Tessellator var6 = Tessellator.instance;
    1527            GL11.glEnable(GL11.GL_BLEND);
    1528            GL11.glEnable(GL11.GL_ALPHA_TEST);
    1529            GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
    1530            GL11.glColor4f(1.0F, 1.0F, 1.0F, (MathHelper.sin((float)Minecraft.getSystemTime() / 100.0F) * 0.2F + 0.4F) * 0.5F);
    1531
    1532            if (par3 != 0 && par4ItemStack != null)
    1533            {
    1534                GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    1535                float var7 = MathHelper.sin((float)Minecraft.getSystemTime() / 100.0F) * 0.2F + 0.8F;
    1536                GL11.glColor4f(var7, var7, var7, MathHelper.sin((float)Minecraft.getSystemTime() / 200.0F) * 0.2F + 0.5F);
    1537                int var8 = this.renderEngine.getTexture("/terrain.png");
    1538                GL11.glBindTexture(GL11.GL_TEXTURE_2D, var8);
    1539            }
    1540
    1541            GL11.glDisable(GL11.GL_BLEND);
    1542            GL11.glDisable(GL11.GL_ALPHA_TEST);
    1543        }
    1544
    1545        public void drawBlockDamageTexture(Tessellator par1Tessellator, EntityPlayer par2EntityPlayer, float par3)
    1546        {
    1547            drawBlockDamageTexture(par1Tessellator, (EntityLiving)par2EntityPlayer, par3);
    1548        }
    1549
    1550        public void drawBlockDamageTexture(Tessellator par1Tessellator, EntityLiving par2EntityPlayer, float par3)
    1551        {
    1552            double var4 = par2EntityPlayer.lastTickPosX + (par2EntityPlayer.posX - par2EntityPlayer.lastTickPosX) * (double)par3;
    1553            double var6 = par2EntityPlayer.lastTickPosY + (par2EntityPlayer.posY - par2EntityPlayer.lastTickPosY) * (double)par3;
    1554            double var8 = par2EntityPlayer.lastTickPosZ + (par2EntityPlayer.posZ - par2EntityPlayer.lastTickPosZ) * (double)par3;
    1555
    1556            if (!this.field_72738_E.isEmpty())
    1557            {
    1558                GL11.glBlendFunc(GL11.GL_DST_COLOR, GL11.GL_SRC_COLOR);
    1559                int var10 = this.renderEngine.getTexture("/terrain.png");
    1560                GL11.glBindTexture(GL11.GL_TEXTURE_2D, var10);
    1561                GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.5F);
    1562                GL11.glPushMatrix();
    1563                GL11.glDisable(GL11.GL_ALPHA_TEST);
    1564                GL11.glPolygonOffset(-3.0F, -3.0F);
    1565                GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL);
    1566                GL11.glEnable(GL11.GL_ALPHA_TEST);
    1567                par1Tessellator.startDrawingQuads();
    1568                par1Tessellator.setTranslation(-var4, -var6, -var8);
    1569                par1Tessellator.disableColor();
    1570                Iterator var11 = this.field_72738_E.values().iterator();
    1571
    1572                while (var11.hasNext())
    1573                {
    1574                    DestroyBlockProgress var12 = (DestroyBlockProgress)var11.next();
    1575                    double var13 = (double)var12.getPartialBlockX() - var4;
    1576                    double var15 = (double)var12.getPartialBlockY() - var6;
    1577                    double var17 = (double)var12.getPartialBlockZ() - var8;
    1578
    1579                    if (var13 * var13 + var15 * var15 + var17 * var17 > 1024.0D)
    1580                    {
    1581                        var11.remove();
    1582                    }
    1583                    else
    1584                    {
    1585                        int var19 = this.theWorld.getBlockId(var12.getPartialBlockX(), var12.getPartialBlockY(), var12.getPartialBlockZ());
    1586                        Block var20 = var19 > 0 ? Block.blocksList[var19] : null;
    1587
    1588                        if (var20 == null)
    1589                        {
    1590                            var20 = Block.stone;
    1591                        }
    1592
    1593                        this.globalRenderBlocks.renderBlockUsingTexture(var20, var12.getPartialBlockX(), var12.getPartialBlockY(), var12.getPartialBlockZ(), 240 + var12.getPartialBlockDamage());
    1594                    }
    1595                }
    1596
    1597                par1Tessellator.draw();
    1598                par1Tessellator.setTranslation(0.0D, 0.0D, 0.0D);
    1599                GL11.glDisable(GL11.GL_ALPHA_TEST);
    1600                GL11.glPolygonOffset(0.0F, 0.0F);
    1601                GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL);
    1602                GL11.glEnable(GL11.GL_ALPHA_TEST);
    1603                GL11.glDepthMask(true);
    1604                GL11.glPopMatrix();
    1605            }
    1606        }
    1607
    1608        /**
    1609         * Draws the selection box for the player. Args: entityPlayer, rayTraceHit, i, itemStack, partialTickTime
    1610         */
    1611        public void drawSelectionBox(EntityPlayer par1EntityPlayer, MovingObjectPosition par2MovingObjectPosition, int par3, ItemStack par4ItemStack, float par5)
    1612        {
    1613            if (par3 == 0 && par2MovingObjectPosition.typeOfHit == EnumMovingObjectType.TILE)
    1614            {
    1615                GL11.glEnable(GL11.GL_BLEND);
    1616                GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    1617                GL11.glColor4f(0.0F, 0.0F, 0.0F, 0.4F);
    1618                GL11.glLineWidth(2.0F);
    1619                GL11.glDisable(GL11.GL_TEXTURE_2D);
    1620                GL11.glDepthMask(false);
    1621                float var6 = 0.002F;
    1622                int var7 = this.theWorld.getBlockId(par2MovingObjectPosition.blockX, par2MovingObjectPosition.blockY, par2MovingObjectPosition.blockZ);
    1623
    1624                if (var7 > 0)
    1625                {
    1626                    Block.blocksList[var7].setBlockBoundsBasedOnState(this.theWorld, par2MovingObjectPosition.blockX, par2MovingObjectPosition.blockY, par2MovingObjectPosition.blockZ);
    1627                    double var8 = par1EntityPlayer.lastTickPosX + (par1EntityPlayer.posX - par1EntityPlayer.lastTickPosX) * (double)par5;
    1628                    double var10 = par1EntityPlayer.lastTickPosY + (par1EntityPlayer.posY - par1EntityPlayer.lastTickPosY) * (double)par5;
    1629                    double var12 = par1EntityPlayer.lastTickPosZ + (par1EntityPlayer.posZ - par1EntityPlayer.lastTickPosZ) * (double)par5;
    1630                    this.drawOutlinedBoundingBox(Block.blocksList[var7].getSelectedBoundingBoxFromPool(this.theWorld, par2MovingObjectPosition.blockX, par2MovingObjectPosition.blockY, par2MovingObjectPosition.blockZ).expand((double)var6, (double)var6, (double)var6).getOffsetBoundingBox(-var8, -var10, -var12));
    1631                }
    1632
    1633                GL11.glDepthMask(true);
    1634                GL11.glEnable(GL11.GL_TEXTURE_2D);
    1635                GL11.glDisable(GL11.GL_BLEND);
    1636            }
    1637        }
    1638
    1639        /**
    1640         * Draws lines for the edges of the bounding box.
    1641         */
    1642        private void drawOutlinedBoundingBox(AxisAlignedBB par1AxisAlignedBB)
    1643        {
    1644            Tessellator var2 = Tessellator.instance;
    1645            var2.startDrawing(3);
    1646            var2.addVertex(par1AxisAlignedBB.minX, par1AxisAlignedBB.minY, par1AxisAlignedBB.minZ);
    1647            var2.addVertex(par1AxisAlignedBB.maxX, par1AxisAlignedBB.minY, par1AxisAlignedBB.minZ);
    1648            var2.addVertex(par1AxisAlignedBB.maxX, par1AxisAlignedBB.minY, par1AxisAlignedBB.maxZ);
    1649            var2.addVertex(par1AxisAlignedBB.minX, par1AxisAlignedBB.minY, par1AxisAlignedBB.maxZ);
    1650            var2.addVertex(par1AxisAlignedBB.minX, par1AxisAlignedBB.minY, par1AxisAlignedBB.minZ);
    1651            var2.draw();
    1652            var2.startDrawing(3);
    1653            var2.addVertex(par1AxisAlignedBB.minX, par1AxisAlignedBB.maxY, par1AxisAlignedBB.minZ);
    1654            var2.addVertex(par1AxisAlignedBB.maxX, par1AxisAlignedBB.maxY, par1AxisAlignedBB.minZ);
    1655            var2.addVertex(par1AxisAlignedBB.maxX, par1AxisAlignedBB.maxY, par1AxisAlignedBB.maxZ);
    1656            var2.addVertex(par1AxisAlignedBB.minX, par1AxisAlignedBB.maxY, par1AxisAlignedBB.maxZ);
    1657            var2.addVertex(par1AxisAlignedBB.minX, par1AxisAlignedBB.maxY, par1AxisAlignedBB.minZ);
    1658            var2.draw();
    1659            var2.startDrawing(1);
    1660            var2.addVertex(par1AxisAlignedBB.minX, par1AxisAlignedBB.minY, par1AxisAlignedBB.minZ);
    1661            var2.addVertex(par1AxisAlignedBB.minX, par1AxisAlignedBB.maxY, par1AxisAlignedBB.minZ);
    1662            var2.addVertex(par1AxisAlignedBB.maxX, par1AxisAlignedBB.minY, par1AxisAlignedBB.minZ);
    1663            var2.addVertex(par1AxisAlignedBB.maxX, par1AxisAlignedBB.maxY, par1AxisAlignedBB.minZ);
    1664            var2.addVertex(par1AxisAlignedBB.maxX, par1AxisAlignedBB.minY, par1AxisAlignedBB.maxZ);
    1665            var2.addVertex(par1AxisAlignedBB.maxX, par1AxisAlignedBB.maxY, par1AxisAlignedBB.maxZ);
    1666            var2.addVertex(par1AxisAlignedBB.minX, par1AxisAlignedBB.minY, par1AxisAlignedBB.maxZ);
    1667            var2.addVertex(par1AxisAlignedBB.minX, par1AxisAlignedBB.maxY, par1AxisAlignedBB.maxZ);
    1668            var2.draw();
    1669        }
    1670
    1671        /**
    1672         * Marks the blocks in the given range for update
    1673         */
    1674        public void markBlocksForUpdate(int par1, int par2, int par3, int par4, int par5, int par6)
    1675        {
    1676            int var7 = MathHelper.bucketInt(par1, 16);
    1677            int var8 = MathHelper.bucketInt(par2, 16);
    1678            int var9 = MathHelper.bucketInt(par3, 16);
    1679            int var10 = MathHelper.bucketInt(par4, 16);
    1680            int var11 = MathHelper.bucketInt(par5, 16);
    1681            int var12 = MathHelper.bucketInt(par6, 16);
    1682
    1683            for (int var13 = var7; var13 <= var10; ++var13)
    1684            {
    1685                int var14 = var13 % this.renderChunksWide;
    1686
    1687                if (var14 < 0)
    1688                {
    1689                    var14 += this.renderChunksWide;
    1690                }
    1691
    1692                for (int var15 = var8; var15 <= var11; ++var15)
    1693                {
    1694                    int var16 = var15 % this.renderChunksTall;
    1695
    1696                    if (var16 < 0)
    1697                    {
    1698                        var16 += this.renderChunksTall;
    1699                    }
    1700
    1701                    for (int var17 = var9; var17 <= var12; ++var17)
    1702                    {
    1703                        int var18 = var17 % this.renderChunksDeep;
    1704
    1705                        if (var18 < 0)
    1706                        {
    1707                            var18 += this.renderChunksDeep;
    1708                        }
    1709
    1710                        int var19 = (var18 * this.renderChunksTall + var16) * this.renderChunksWide + var14;
    1711                        WorldRenderer var20 = this.worldRenderers[var19];
    1712
    1713                        if (var20 != null && !var20.needsUpdate)
    1714                        {
    1715                            this.worldRenderersToUpdate.add(var20);
    1716                            var20.markDirty();
    1717                        }
    1718                    }
    1719                }
    1720            }
    1721        }
    1722
    1723        /**
    1724         * Will mark the block and neighbors that their renderers need an update (could be all the same renderer
    1725         * potentially) Args: x, y, z
    1726         */
    1727        public void markBlockNeedsUpdate(int par1, int par2, int par3)
    1728        {
    1729            this.markBlocksForUpdate(par1 - 1, par2 - 1, par3 - 1, par1 + 1, par2 + 1, par3 + 1);
    1730        }
    1731
    1732        /**
    1733         * As of mc 1.2.3 this method has exactly the same signature and does exactly the same as markBlockNeedsUpdate
    1734         */
    1735        public void markBlockNeedsUpdate2(int par1, int par2, int par3)
    1736        {
    1737            this.markBlocksForUpdate(par1 - 1, par2 - 1, par3 - 1, par1 + 1, par2 + 1, par3 + 1);
    1738        }
    1739
    1740        /**
    1741         * Called across all registered IWorldAccess instances when a block range is invalidated. Args: minX, minY, minZ,
    1742         * maxX, maxY, maxZ
    1743         */
    1744        public void markBlockRangeNeedsUpdate(int par1, int par2, int par3, int par4, int par5, int par6)
    1745        {
    1746            this.markBlocksForUpdate(par1 - 1, par2 - 1, par3 - 1, par4 + 1, par5 + 1, par6 + 1);
    1747        }
    1748
    1749        /**
    1750         * Checks all renderers that previously weren't in the frustum and 1/16th of those that previously were in the
    1751         * frustum for frustum clipping Args: frustum, partialTickTime
    1752         */
    1753        public void clipRenderersByFrustum(ICamera par1ICamera, float par2)
    1754        {
    1755            for (int var3 = 0; var3 < this.worldRenderers.length; ++var3)
    1756            {
    1757                if (!this.worldRenderers[var3].skipAllRenderPasses() && (!this.worldRenderers[var3].isInFrustum || (var3 + this.frustumCheckOffset & 15) == 0))
    1758                {
    1759                    this.worldRenderers[var3].updateInFrustum(par1ICamera);
    1760                }
    1761            }
    1762
    1763            ++this.frustumCheckOffset;
    1764        }
    1765
    1766        /**
    1767         * Plays the specified record. Arg: recordName, x, y, z
    1768         */
    1769        public void playRecord(String par1Str, int par2, int par3, int par4)
    1770        {
    1771            if (par1Str != null)
    1772            {
    1773                this.mc.ingameGUI.setRecordPlayingMessage("C418 - " + par1Str);
    1774            }
    1775
    1776            this.mc.sndManager.playStreaming(par1Str, (float)par2, (float)par3, (float)par4, 1.0F, 1.0F);
    1777        }
    1778
    1779        /**
    1780         * Plays the specified sound. Arg: soundName, x, y, z, volume, pitch
    1781         */
    1782        public void playSound(String par1Str, double par2, double par4, double par6, float par8, float par9) {}
    1783
    1784        /**
    1785         * Spawns a particle. Arg: particleType, x, y, z, velX, velY, velZ
    1786         */
    1787        public void spawnParticle(String par1Str, double par2, double par4, double par6, double par8, double par10, double par12)
    1788        {
    1789            this.func_72726_b(par1Str, par2, par4, par6, par8, par10, par12);
    1790        }
    1791
    1792        public EntityFX func_72726_b(String par1Str, double par2, double par4, double par6, double par8, double par10, double par12)
    1793        {
    1794            if (this.mc != null && this.mc.renderViewEntity != null && this.mc.effectRenderer != null)
    1795            {
    1796                int var14 = this.mc.gameSettings.particleSetting;
    1797
    1798                if (var14 == 1 && this.theWorld.rand.nextInt(3) == 0)
    1799                {
    1800                    var14 = 2;
    1801                }
    1802
    1803                double var15 = this.mc.renderViewEntity.posX - par2;
    1804                double var17 = this.mc.renderViewEntity.posY - par4;
    1805                double var19 = this.mc.renderViewEntity.posZ - par6;
    1806                EntityFX var21 = null;
    1807                Object effectObject = null;
    1808
    1809                if (par1Str.equals("hugeexplosion"))
    1810                {
    1811                    this.mc.effectRenderer.addEffect(var21 = new EntityHugeExplodeFX(this.theWorld, par2, par4, par6, par8, par10, par12));
    1812                }
    1813                else if (par1Str.equals("largeexplode"))
    1814                {
    1815                    this.mc.effectRenderer.addEffect(var21 = new EntityLargeExplodeFX(this.renderEngine, this.theWorld, par2, par4, par6, par8, par10, par12));
    1816                }
    1817
    1818                if (var21 != null)
    1819                {
    1820                    return (EntityFX)var21;
    1821                }
    1822                else
    1823                {
    1824                    double var22 = 16.0D;
    1825
    1826                    if (var15 * var15 + var17 * var17 + var19 * var19 > var22 * var22)
    1827                    {
    1828                        return null;
    1829                    }
    1830                    else if (var14 > 1)
    1831                    {
    1832                        return null;
    1833                    }
    1834                    else
    1835                    {
    1836                        if (par1Str.equals("bubble"))
    1837                        {
    1838                            var21 = new EntityBubbleFX(this.theWorld, par2, par4, par6, par8, par10, par12);
    1839                        }
    1840                        else if (par1Str.equals("suspended"))
    1841                        {
    1842                            var21 = new EntitySuspendFX(this.theWorld, par2, par4, par6, par8, par10, par12);
    1843                        }
    1844                        else if (par1Str.equals("depthsuspend"))
    1845                        {
    1846                            var21 = new EntityAuraFX(this.theWorld, par2, par4, par6, par8, par10, par12);
    1847                        }
    1848                        else if (par1Str.equals("townaura"))
    1849                        {
    1850                            var21 = new EntityAuraFX(this.theWorld, par2, par4, par6, par8, par10, par12);
    1851                        }
    1852                        else if (par1Str.equals("crit"))
    1853                        {
    1854                            var21 = new EntityCritFX(this.theWorld, par2, par4, par6, par8, par10, par12);
    1855                        }
    1856                        else if (par1Str.equals("magicCrit"))
    1857                        {
    1858                            var21 = new EntityCritFX(this.theWorld, par2, par4, par6, par8, par10, par12);
    1859                            ((EntityFX)var21).setRBGColorF(((EntityFX)var21).getRedColorF() * 0.3F, ((EntityFX)var21).getGreenColorF() * 0.8F, ((EntityFX)var21).getBlueColorF());
    1860                            ((EntityFX)var21).setParticleTextureIndex(((EntityFX)var21).getParticleTextureIndex() + 1);
    1861                        }
    1862                        else if (par1Str.equals("smoke"))
    1863                        {
    1864                            var21 = new EntitySmokeFX(this.theWorld, par2, par4, par6, par8, par10, par12);
    1865                        }
    1866                        else if (par1Str.equals("mobSpell"))
    1867                        {
    1868                            var21 = new EntitySpellParticleFX(this.theWorld, par2, par4, par6, 0.0D, 0.0D, 0.0D);
    1869                            ((EntityFX)var21).setRBGColorF((float)par8, (float)par10, (float)par12);
    1870                        }
    1871                        else if (par1Str.equals("spell"))
    1872                        {
    1873                            var21 = new EntitySpellParticleFX(this.theWorld, par2, par4, par6, par8, par10, par12);
    1874                        }
    1875                        else if (par1Str.equals("instantSpell"))
    1876                        {
    1877                            var21 = new EntitySpellParticleFX(this.theWorld, par2, par4, par6, par8, par10, par12);
    1878                            ((EntitySpellParticleFX)var21).func_70589_b(144);
    1879                        }
    1880                        else if (par1Str.equals("note"))
    1881                        {
    1882                            var21 = new EntityNoteFX(this.theWorld, par2, par4, par6, par8, par10, par12);
    1883                        }
    1884                        else if (par1Str.equals("portal"))
    1885                        {
    1886                            var21 = new EntityPortalFX(this.theWorld, par2, par4, par6, par8, par10, par12);
    1887                        }
    1888                        else if (par1Str.equals("enchantmenttable"))
    1889                        {
    1890                            var21 = new EntityEnchantmentTableParticleFX(this.theWorld, par2, par4, par6, par8, par10, par12);
    1891                        }
    1892                        else if (par1Str.equals("explode"))
    1893                        {
    1894                            var21 = new EntityExplodeFX(this.theWorld, par2, par4, par6, par8, par10, par12);
    1895                        }
    1896                        else if (par1Str.equals("flame"))
    1897                        {
    1898                            var21 = new EntityFlameFX(this.theWorld, par2, par4, par6, par8, par10, par12);
    1899                        }
    1900                        else if (par1Str.equals("lava"))
    1901                        {
    1902                            var21 = new EntityLavaFX(this.theWorld, par2, par4, par6);
    1903                        }
    1904                        else if (par1Str.equals("footstep"))
    1905                        {
    1906                            var21 = new EntityFootStepFX(this.renderEngine, this.theWorld, par2, par4, par6);
    1907                        }
    1908                        else if (par1Str.equals("splash"))
    1909                        {
    1910                            var21 = new EntitySplashFX(this.theWorld, par2, par4, par6, par8, par10, par12);
    1911                        }
    1912                        else if (par1Str.equals("largesmoke"))
    1913                        {
    1914                            var21 = new EntitySmokeFX(this.theWorld, par2, par4, par6, par8, par10, par12, 2.5F);
    1915                        }
    1916                        else if (par1Str.equals("cloud"))
    1917                        {
    1918                            var21 = new EntityCloudFX(this.theWorld, par2, par4, par6, par8, par10, par12);
    1919                        }
    1920                        else if (par1Str.equals("reddust"))
    1921                        {
    1922                            var21 = new EntityReddustFX(this.theWorld, par2, par4, par6, (float)par8, (float)par10, (float)par12);
    1923                        }
    1924                        else if (par1Str.equals("snowballpoof"))
    1925                        {
    1926                            var21 = new EntityBreakingFX(this.theWorld, par2, par4, par6, Item.snowball);
    1927                            effectObject = Item.snowball;
    1928                        }
    1929                        else if (par1Str.equals("dripWater"))
    1930                        {
    1931                            var21 = new EntityDropParticleFX(this.theWorld, par2, par4, par6, Material.water);
    1932                        }
    1933                        else if (par1Str.equals("dripLava"))
    1934                        {
    1935                            var21 = new EntityDropParticleFX(this.theWorld, par2, par4, par6, Material.lava);
    1936                        }
    1937                        else if (par1Str.equals("snowshovel"))
    1938                        {
    1939                            var21 = new EntitySnowShovelFX(this.theWorld, par2, par4, par6, par8, par10, par12);
    1940                        }
    1941                        else if (par1Str.equals("slime"))
    1942                        {
    1943                            var21 = new EntityBreakingFX(this.theWorld, par2, par4, par6, Item.slimeBall);
    1944                            effectObject = Item.slimeBall;
    1945                        }
    1946                        else if (par1Str.equals("heart"))
    1947                        {
    1948                            var21 = new EntityHeartFX(this.theWorld, par2, par4, par6, par8, par10, par12);
    1949                        }
    1950                        else
    1951                        {
    1952                            int var24;
    1953
    1954                            if (par1Str.startsWith("iconcrack_"))
    1955                            {
    1956                                var24 = Integer.parseInt(par1Str.substring(par1Str.indexOf("_") + 1));
    1957                                var21 = new EntityBreakingFX(this.theWorld, par2, par4, par6, par8, par10, par12, Item.itemsList[var24]);
    1958                                effectObject = Item.itemsList[var24];
    1959                            }
    1960                            else if (par1Str.startsWith("tilecrack_"))
    1961                            {
    1962                                var24 = Integer.parseInt(par1Str.substring(par1Str.indexOf("_") + 1));
    1963                                var21 = new EntityDiggingFX(this.theWorld, par2, par4, par6, par8, par10, par12, Block.blocksList[var24], 0, 0);
    1964                                effectObject = Block.blocksList[var24];
    1965                            }
    1966                        }
    1967
    1968                        if (var21 != null)
    1969                        {
    1970                            this.mc.effectRenderer.addEffect((EntityFX)var21, effectObject);
    1971                        }
    1972
    1973                        return (EntityFX)var21;
    1974                    }
    1975                }
    1976            }
    1977            else
    1978            {
    1979                return null;
    1980            }
    1981        }
    1982
    1983        /**
    1984         * Start the skin for this entity downloading, if necessary, and increment its reference counter
    1985         */
    1986        public void obtainEntitySkin(Entity par1Entity)
    1987        {
    1988            par1Entity.updateCloak();
    1989
    1990            if (par1Entity.skinUrl != null)
    1991            {
    1992                this.renderEngine.obtainImageData(par1Entity.skinUrl, new ImageBufferDownload());
    1993            }
    1994
    1995            if (par1Entity.cloakUrl != null)
    1996            {
    1997                this.renderEngine.obtainImageData(par1Entity.cloakUrl, new ImageBufferDownload());
    1998            }
    1999        }
    2000
    2001        /**
    2002         * Decrement the reference counter for this entity's skin image data
    2003         */
    2004        public void releaseEntitySkin(Entity par1Entity)
    2005        {
    2006            if (par1Entity.skinUrl != null)
    2007            {
    2008                this.renderEngine.releaseImageData(par1Entity.skinUrl);
    2009            }
    2010
    2011            if (par1Entity.cloakUrl != null)
    2012            {
    2013                this.renderEngine.releaseImageData(par1Entity.cloakUrl);
    2014            }
    2015        }
    2016
    2017        public void func_72728_f()
    2018        {
    2019            GLAllocation.deleteDisplayLists(this.glRenderListBase);
    2020        }
    2021
    2022        /**
    2023         * Plays a pre-canned sound effect along with potentially auxiliary data-driven one-shot behaviour (particles, etc).
    2024         */
    2025        public void playAuxSFX(EntityPlayer par1EntityPlayer, int par2, int par3, int par4, int par5, int par6)
    2026        {
    2027            Random var7 = this.theWorld.rand;
    2028            double var8;
    2029            double var10;
    2030            double var12;
    2031            String var14;
    2032            int var15;
    2033            int var20;
    2034            double var23;
    2035            double var25;
    2036            double var27;
    2037            double var29;
    2038            double var39;
    2039
    2040            switch (par2)
    2041            {
    2042                case 1000:
    2043                    this.theWorld.playSound((double)par3, (double)par4, (double)par5, "random.click", 1.0F, 1.0F);
    2044                    break;
    2045                case 1001:
    2046                    this.theWorld.playSound((double)par3, (double)par4, (double)par5, "random.click", 1.0F, 1.2F);
    2047                    break;
    2048                case 1002:
    2049                    this.theWorld.playSound((double)par3, (double)par4, (double)par5, "random.bow", 1.0F, 1.2F);
    2050                    break;
    2051                case 1003:
    2052                    if (Math.random() < 0.5D)
    2053                    {
    2054                        this.theWorld.playSound((double)par3 + 0.5D, (double)par4 + 0.5D, (double)par5 + 0.5D, "random.door_open", 1.0F, this.theWorld.rand.nextFloat() * 0.1F + 0.9F);
    2055                    }
    2056                    else
    2057                    {
    2058                        this.theWorld.playSound((double)par3 + 0.5D, (double)par4 + 0.5D, (double)par5 + 0.5D, "random.door_close", 1.0F, this.theWorld.rand.nextFloat() * 0.1F + 0.9F);
    2059                    }
    2060
    2061                    break;
    2062                case 1004:
    2063                    this.theWorld.playSound((double)((float)par3 + 0.5F), (double)((float)par4 + 0.5F), (double)((float)par5 + 0.5F), "random.fizz", 0.5F, 2.6F + (var7.nextFloat() - var7.nextFloat()) * 0.8F);
    2064                    break;
    2065                case 1005:
    2066                    if (Item.itemsList[par6] instanceof ItemRecord)
    2067                    {
    2068                        this.theWorld.playRecord(((ItemRecord)Item.itemsList[par6]).recordName, par3, par4, par5);
    2069                    }
    2070                    else
    2071                    {
    2072                        this.theWorld.playRecord((String)null, par3, par4, par5);
    2073                    }
    2074
    2075                    break;
    2076                case 1007:
    2077                    this.theWorld.playSound((double)par3 + 0.5D, (double)par4 + 0.5D, (double)par5 + 0.5D, "mob.ghast.charge", 10.0F, (var7.nextFloat() - var7.nextFloat()) * 0.2F + 1.0F);
    2078                    break;
    2079                case 1008:
    2080                    this.theWorld.playSound((double)par3 + 0.5D, (double)par4 + 0.5D, (double)par5 + 0.5D, "mob.ghast.fireball", 10.0F, (var7.nextFloat() - var7.nextFloat()) * 0.2F + 1.0F);
    2081                    break;
    2082                case 1010:
    2083                    this.theWorld.playSound((double)par3 + 0.5D, (double)par4 + 0.5D, (double)par5 + 0.5D, "mob.zombie.wood", 2.0F, (var7.nextFloat() - var7.nextFloat()) * 0.2F + 1.0F);
    2084                    break;
    2085                case 1011:
    2086                    this.theWorld.playSound((double)par3 + 0.5D, (double)par4 + 0.5D, (double)par5 + 0.5D, "mob.zombie.metal", 2.0F, (var7.nextFloat() - var7.nextFloat()) * 0.2F + 1.0F);
    2087                    break;
    2088                case 1012:
    2089                    this.theWorld.playSound((double)par3 + 0.5D, (double)par4 + 0.5D, (double)par5 + 0.5D, "mob.zombie.woodbreak", 2.0F, (var7.nextFloat() - var7.nextFloat()) * 0.2F + 1.0F);
    2090                    break;
    2091                case 2000:
    2092                    int var33 = par6 % 3 - 1;
    2093                    int var9 = par6 / 3 % 3 - 1;
    2094                    var10 = (double)par3 + (double)var33 * 0.6D + 0.5D;
    2095                    var12 = (double)par4 + 0.5D;
    2096                    double var34 = (double)par5 + (double)var9 * 0.6D + 0.5D;
    2097
    2098                    for (int var35 = 0; var35 < 10; ++var35)
    2099                    {
    2100                        double var37 = var7.nextDouble() * 0.2D + 0.01D;
    2101                        double var38 = var10 + (double)var33 * 0.01D + (var7.nextDouble() - 0.5D) * (double)var9 * 0.5D;
    2102                        var39 = var12 + (var7.nextDouble() - 0.5D) * 0.5D;
    2103                        var23 = var34 + (double)var9 * 0.01D + (var7.nextDouble() - 0.5D) * (double)var33 * 0.5D;
    2104                        var25 = (double)var33 * var37 + var7.nextGaussian() * 0.01D;
    2105                        var27 = -0.03D + var7.nextGaussian() * 0.01D;
    2106                        var29 = (double)var9 * var37 + var7.nextGaussian() * 0.01D;
    2107                        this.spawnParticle("smoke", var38, var39, var23, var25, var27, var29);
    2108                    }
    2109
    2110                    return;
    2111                case 2001:
    2112                    var20 = par6 & 4095;
    2113
    2114                    if (var20 > 0)
    2115                    {
    2116                        Block var40 = Block.blocksList[var20];
    2117                        this.mc.sndManager.playSound(var40.stepSound.getBreakSound(), (float)par3 + 0.5F, (float)par4 + 0.5F, (float)par5 + 0.5F, (var40.stepSound.getVolume() + 1.0F) / 2.0F, var40.stepSound.getPitch() * 0.8F);
    2118                    }
    2119
    2120                    this.mc.effectRenderer.addBlockDestroyEffects(par3, par4, par5, par6 & 4095, par6 >> 12 & 255);
    2121                    break;
    2122                case 2002:
    2123                    var8 = (double)par3;
    2124                    var10 = (double)par4;
    2125                    var12 = (double)par5;
    2126                    var14 = "iconcrack_" + Item.potion.shiftedIndex;
    2127
    2128                    for (var15 = 0; var15 < 8; ++var15)
    2129                    {
    2130                        this.spawnParticle(var14, var8, var10, var12, var7.nextGaussian() * 0.15D, var7.nextDouble() * 0.2D, var7.nextGaussian() * 0.15D);
    2131                    }
    2132
    2133                    var15 = Item.potion.getColorFromDamage(par6, 0);
    2134                    float var16 = (float)(var15 >> 16 & 255) / 255.0F;
    2135                    float var17 = (float)(var15 >> 8 & 255) / 255.0F;
    2136                    float var18 = (float)(var15 >> 0 & 255) / 255.0F;
    2137                    String var19 = "spell";
    2138
    2139                    if (Item.potion.isEffectInstant(par6))
    2140                    {
    2141                        var19 = "instantSpell";
    2142                    }
    2143
    2144                    for (var20 = 0; var20 < 100; ++var20)
    2145                    {
    2146                        var39 = var7.nextDouble() * 4.0D;
    2147                        var23 = var7.nextDouble() * Math.PI * 2.0D;
    2148                        var25 = Math.cos(var23) * var39;
    2149                        var27 = 0.01D + var7.nextDouble() * 0.5D;
    2150                        var29 = Math.sin(var23) * var39;
    2151                        EntityFX var31 = this.func_72726_b(var19, var8 + var25 * 0.1D, var10 + 0.3D, var12 + var29 * 0.1D, var25, var27, var29);
    2152
    2153                        if (var31 != null)
    2154                        {
    2155                            float var32 = 0.75F + var7.nextFloat() * 0.25F;
    2156                            var31.setRBGColorF(var16 * var32, var17 * var32, var18 * var32);
    2157                            var31.multiplyVelocity((float)var39);
    2158                        }
    2159                    }
    2160
    2161                    this.theWorld.playSound((double)par3 + 0.5D, (double)par4 + 0.5D, (double)par5 + 0.5D, "random.glass", 1.0F, this.theWorld.rand.nextFloat() * 0.1F + 0.9F);
    2162                    break;
    2163                case 2003:
    2164                    var8 = (double)par3 + 0.5D;
    2165                    var10 = (double)par4;
    2166                    var12 = (double)par5 + 0.5D;
    2167                    var14 = "iconcrack_" + Item.eyeOfEnder.shiftedIndex;
    2168
    2169                    for (var15 = 0; var15 < 8; ++var15)
    2170                    {
    2171                        this.spawnParticle(var14, var8, var10, var12, var7.nextGaussian() * 0.15D, var7.nextDouble() * 0.2D, var7.nextGaussian() * 0.15D);
    2172                    }
    2173
    2174                    for (double var36 = 0.0D; var36 < (Math.PI * 2D); var36 += 0.15707963267948966D)
    2175                    {
    2176                        this.spawnParticle("portal", var8 + Math.cos(var36) * 5.0D, var10 - 0.4D, var12 + Math.sin(var36) * 5.0D, Math.cos(var36) * -5.0D, 0.0D, Math.sin(var36) * -5.0D);
    2177                        this.spawnParticle("portal", var8 + Math.cos(var36) * 5.0D, var10 - 0.4D, var12 + Math.sin(var36) * 5.0D, Math.cos(var36) * -7.0D, 0.0D, Math.sin(var36) * -7.0D);
    2178                    }
    2179
    2180                    return;
    2181                case 2004:
    2182                    for (int var21 = 0; var21 < 20; ++var21)
    2183                    {
    2184                        double var22 = (double)par3 + 0.5D + ((double)this.theWorld.rand.nextFloat() - 0.5D) * 2.0D;
    2185                        double var24 = (double)par4 + 0.5D + ((double)this.theWorld.rand.nextFloat() - 0.5D) * 2.0D;
    2186                        double var26 = (double)par5 + 0.5D + ((double)this.theWorld.rand.nextFloat() - 0.5D) * 2.0D;
    2187                        this.theWorld.spawnParticle("smoke", var22, var24, var26, 0.0D, 0.0D, 0.0D);
    2188                        this.theWorld.spawnParticle("flame", var22, var24, var26, 0.0D, 0.0D, 0.0D);
    2189                    }
    2190            }
    2191        }
    2192
    2193        /**
    2194         * Starts (or continues) destroying a block with given ID at the given coordinates for the given partially destroyed
    2195         * value
    2196         */
    2197        public void destroyBlockPartially(int par1, int par2, int par3, int par4, int par5)
    2198        {
    2199            if (par5 >= 0 && par5 < 10)
    2200            {
    2201                DestroyBlockProgress var6 = (DestroyBlockProgress)this.field_72738_E.get(Integer.valueOf(par1));
    2202
    2203                if (var6 == null || var6.getPartialBlockX() != par2 || var6.getPartialBlockY() != par3 || var6.getPartialBlockZ() != par4)
    2204                {
    2205                    var6 = new DestroyBlockProgress(par1, par2, par3, par4);
    2206                    this.field_72738_E.put(Integer.valueOf(par1), var6);
    2207                }
    2208
    2209                var6.setPartialBlockDamage(par5);
    2210            }
    2211            else
    2212            {
    2213                this.field_72738_E.remove(Integer.valueOf(par1));
    2214            }
    2215        }
    2216    }