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