RenderGlobal .java

net.minecraft.client.renderer.RenderGlobal (class, 2413 lines): members: ContainerLocalRenderInformation, renderEntityOutlineFramebuffer, skyVBO, starVBO.

net.minecraft.client.rendererclass2,413 linesclient111.2 KB

Implements

API Surface (40)

void onResourceManagerReload(IResourceManager resourceManager)
void makeEntityOutlineShader()
void renderEntityOutlineFramebuffer()
boolean isRenderEntityOutlines()
void setWorldAndLoadRenderers(WorldClient worldClientIn)
void loadRenderers()
void stopChunkUpdates()
void createBindEntityOutlineFbs(int width, int height)
void renderEntities(Entity renderViewEntity, ICamera camera, float partialTicks)
String getDebugInfoRenders()
String getDebugInfoEntities()
void setupTerrain(Entity viewEntity, double partialTicks, ICamera camera, int frameCount, boolean playerSpectator)
Vector3f getViewVector(Entity entityIn, double partialTicks)
int renderBlockLayer(EnumWorldBlockLayer blockLayerIn, double partialTicks, int pass, Entity entityIn)
void updateClouds()
void renderSky(float partialTicks, int pass)
void renderClouds(float partialTicks, int pass)
boolean hasCloudFog(double x, double y, double z, float partialTicks)
void updateChunks(long finishTimeNano)
void renderWorldBorder(Entity entityIn, float partialTicks)
void drawBlockDamageTexture(Tessellator tessellatorIn, WorldRenderer worldRendererIn, Entity entityIn, float partialTicks)
void drawSelectionBox(EntityPlayer player, MovingObjectPosition movingObjectPositionIn, int execute, float partialTicks)
void drawSelectionBoundingBox(AxisAlignedBB boundingBox)
void drawOutlinedBoundingBox(AxisAlignedBB boundingBox, int red, int green, int blue, int alpha)
void markBlockForUpdate(BlockPos pos)
void notifyLightSet(BlockPos pos)
void markBlockRangeForRenderUpdate(int x1, int y1, int z1, int x2, int y2, int z2)
void playRecord(String recordName, BlockPos blockPosIn)
void playSound(String soundName, double x, double y, double z, float volume, float pitch)
void playSoundToNearExcept(EntityPlayer except, String soundName, double x, double y, double z, float volume, float pitch)
void spawnParticle(int particleID, boolean ignoreRange, final double xCoord, final double yCoord, final double zCoord, double xOffset, double yOffset, double zOffset, int... parameters)
String call()
void onEntityAdded(Entity entityIn)
void onEntityRemoved(Entity entityIn)
void deleteAllDisplayLists()
void broadcastSound(int soundID, BlockPos pos, int data)
void playAuxSFX(EntityPlayer player, int sfxType, BlockPos blockPosIn, int data)
void sendBlockBreakProgress(int breakerId, BlockPos pos, int progress)
void setDisplayListEntitiesDirty()
void updateTileEntities(Collection<TileEntity> tileEntitiesToRemove, Collection<TileEntity> tileEntitiesToAdd)

Fields & Constants (55)

logger
locationMoonPhasesPng
locationSunPng
locationCloudsPng
locationEndSkyPng
locationForcefieldPng
mc
renderEngine
renderManager
theWorld
chunksToUpdate
renderInfos
setTileEntities
viewFrustum
starGLCallList
glSkyList
glSkyList2
vertexBufferFormat
starVBO
skyVBO
sky2VBO
cloudTickCounter
damagedBlocks
mapSoundPositions
destroyBlockIcons
entityOutlineFramebuffer
entityOutlineShader
frustumUpdatePosX
frustumUpdatePosY
frustumUpdatePosZ

…and 25 more (see full source).

String literals (48)

"textures/environment/moon_phases.png"
"textures/environment/sun.png"
"textures/environment/clouds.png"
"textures/environment/end_sky.png"
"textures/misc/forcefield.png"
"minecraft:blocks/destroy_stage_"
"shaders/post/entity_outline.json"
"final"
"Failed to load shader: "
"prepare"
"global"
"entityOutlines"
"entities"
"blockentities"
"camera"
"renderlistcamera"
"cull"
"culling"
"build near"
"translucent_sort"
"filterempty"
"render_"
"incomplete-switch"
"Exception while adding particle"

Code Graph: Dependencies (78)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

RenderGlobal.java2413 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.client.renderer;
2
3
import com.google.common.collect.Lists;
4
import com.google.common.collect.Maps;
5
import com.google.common.collect.Sets;
6
import com.google.gson.JsonSyntaxException;
7
import java.io.IOException;
8
import java.util.Collection;
9
import java.util.EnumSet;
10
import java.util.Iterator;
11
import java.util.List;
12
import java.util.Map;
13
import java.util.Queue;
14
import java.util.Random;
15
import java.util.Set;
16
import java.util.concurrent.Callable;
17
import net.minecraft.block.Block;
18
import net.minecraft.block.BlockChest;
19
import net.minecraft.block.BlockEnderChest;
20
import net.minecraft.block.BlockSign;
21
import net.minecraft.block.BlockSkull;
22
import net.minecraft.block.material.Material;
23
import net.minecraft.block.state.IBlockState;
24
import net.minecraft.client.Minecraft;
25
import net.minecraft.client.audio.ISound;
26
import net.minecraft.client.audio.PositionedSoundRecord;
27
import net.minecraft.client.multiplayer.WorldClient;
28
import net.minecraft.client.particle.EntityFX;
29
import net.minecraft.client.renderer.chunk.ChunkRenderDispatcher;
30
import net.minecraft.client.renderer.chunk.CompiledChunk;
31
import net.minecraft.client.renderer.chunk.IRenderChunkFactory;
32
import net.minecraft.client.renderer.chunk.ListChunkFactory;
33
import net.minecraft.client.renderer.chunk.RenderChunk;
34
import net.minecraft.client.renderer.chunk.VboChunkFactory;
35
import net.minecraft.client.renderer.chunk.VisGraph;
36
import net.minecraft.client.renderer.culling.ClippingHelper;
37
import net.minecraft.client.renderer.culling.ClippingHelperImpl;
38
import net.minecraft.client.renderer.culling.Frustum;
39
import net.minecraft.client.renderer.culling.ICamera;
40
import net.minecraft.client.renderer.entity.RenderManager;
41
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
42
import net.minecraft.client.renderer.texture.TextureManager;
43
import net.minecraft.client.renderer.texture.TextureMap;
44
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
45
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
46
import net.minecraft.client.renderer.vertex.VertexBuffer;
47
import net.minecraft.client.renderer.vertex.VertexFormat;
48
import net.minecraft.client.renderer.vertex.VertexFormatElement;
49
import net.minecraft.client.resources.IResourceManager;
50
import net.minecraft.client.resources.IResourceManagerReloadListener;
51
import net.minecraft.client.shader.Framebuffer;
52
import net.minecraft.client.shader.ShaderGroup;
53
import net.minecraft.client.shader.ShaderLinkHelper;
54
import net.minecraft.crash.CrashReport;
55
import net.minecraft.crash.CrashReportCategory;
56
import net.minecraft.entity.Entity;
57
import net.minecraft.entity.EntityLivingBase;
58
import net.minecraft.entity.player.EntityPlayer;
59
import net.minecraft.entity.projectile.EntityWitherSkull;
60
import net.minecraft.init.Blocks;
61
import net.minecraft.init.Items;
62
import net.minecraft.item.Item;
63
import net.minecraft.item.ItemDye;
64
import net.minecraft.item.ItemRecord;
65
import net.minecraft.tileentity.TileEntity;
66
import net.minecraft.tileentity.TileEntityChest;
67
import net.minecraft.util.AxisAlignedBB;
68
import net.minecraft.util.BlockPos;
69
import net.minecraft.util.ClassInheritanceMultiMap;
70
import net.minecraft.util.EnumFacing;
71
import net.minecraft.util.EnumParticleTypes;
72
import net.minecraft.util.EnumWorldBlockLayer;
73
import net.minecraft.util.MathHelper;
74
import net.minecraft.util.Matrix4f;
75
import net.minecraft.util.MovingObjectPosition;
76
import net.minecraft.util.ReportedException;
77
import net.minecraft.util.ResourceLocation;
78
import net.minecraft.util.Vec3;
79
import net.minecraft.util.Vector3d;
80
import net.minecraft.world.IWorldAccess;
81
import net.minecraft.world.border.WorldBorder;
82
import net.minecraft.world.chunk.Chunk;
83
import org.apache.logging.log4j.LogManager;
84
import org.apache.logging.log4j.Logger;
85
import org.lwjgl.opengl.GL11;
86
import org.lwjgl.util.vector.Vector3f;
87
import org.lwjgl.util.vector.Vector4f;
88
89
public class RenderGlobal implements IWorldAccess, IResourceManagerReloadListener
90
{
91
    private static final Logger logger = LogManager.getLogger();
92
    private static final ResourceLocation locationMoonPhasesPng = new ResourceLocation("textures/environment/moon_phases.png");
93
    private static final ResourceLocation locationSunPng = new ResourceLocation("textures/environment/sun.png");
94
    private static final ResourceLocation locationCloudsPng = new ResourceLocation("textures/environment/clouds.png");
95
    private static final ResourceLocation locationEndSkyPng = new ResourceLocation("textures/environment/end_sky.png");
96
    private static final ResourceLocation locationForcefieldPng = new ResourceLocation("textures/misc/forcefield.png");
97
98
    /** A reference to the Minecraft object. */
99
    private final Minecraft mc;
100
101
    /** The RenderEngine instance used by RenderGlobal */
102
    private final TextureManager renderEngine;
103
    private final RenderManager renderManager;
104
    private WorldClient theWorld;
105
    private Set<RenderChunk> chunksToUpdate = Sets.<RenderChunk>newLinkedHashSet();
106
    private List<RenderGlobal.ContainerLocalRenderInformation> renderInfos = Lists.<RenderGlobal.ContainerLocalRenderInformation>newArrayListWithCapacity(69696);
107
    private final Set<TileEntity> setTileEntities = Sets.<TileEntity>newHashSet();
108
    private ViewFrustum viewFrustum;
109
110
    /** The star GL Call list */
111
    private int starGLCallList = -1;
112
113
    /** OpenGL sky list */
114
    private int glSkyList = -1;
115
116
    /** OpenGL sky list 2 */
117
    private int glSkyList2 = -1;
118
    private VertexFormat vertexBufferFormat;
119
    private VertexBuffer starVBO;
120
    private VertexBuffer skyVBO;
121
    private VertexBuffer sky2VBO;
122
123
    /**
124
     * counts the cloud render updates. Used with mod to stagger some updates
125
     */
126
    private int cloudTickCounter;
127
    private final Map<Integer, DestroyBlockProgress> damagedBlocks = Maps.<Integer, DestroyBlockProgress>newHashMap();
128
    private final Map<BlockPos, ISound> mapSoundPositions = Maps.<BlockPos, ISound>newHashMap();
129
    private final TextureAtlasSprite[] destroyBlockIcons = new TextureAtlasSprite[10];
130
    private Framebuffer entityOutlineFramebuffer;
131
132
    /** Stores the shader group for the entity_outline shader */
133
    private ShaderGroup entityOutlineShader;
134
    private double frustumUpdatePosX = Double.MIN_VALUE;
135
    private double frustumUpdatePosY = Double.MIN_VALUE;
136
    private double frustumUpdatePosZ = Double.MIN_VALUE;
137
    private int frustumUpdatePosChunkX = Integer.MIN_VALUE;
138
    private int frustumUpdatePosChunkY = Integer.MIN_VALUE;
139
    private int frustumUpdatePosChunkZ = Integer.MIN_VALUE;
140
    private double lastViewEntityX = Double.MIN_VALUE;
141
    private double lastViewEntityY = Double.MIN_VALUE;
142
    private double lastViewEntityZ = Double.MIN_VALUE;
143
    private double lastViewEntityPitch = Double.MIN_VALUE;
144
    private double lastViewEntityYaw = Double.MIN_VALUE;
145
    private final ChunkRenderDispatcher renderDispatcher = new ChunkRenderDispatcher();
146
    private ChunkRenderContainer renderContainer;
147
    private int renderDistanceChunks = -1;
148
149
    /** Render entities startup counter (init value=2) */
150
    private int renderEntitiesStartupCounter = 2;
151
152
    /** Count entities total */
153
    private int countEntitiesTotal;
154
155
    /** Count entities rendered */
156
    private int countEntitiesRendered;
157
158
    /** Count entities hidden */
159
    private int countEntitiesHidden;
160
    private boolean debugFixTerrainFrustum = false;
161
    private ClippingHelper debugFixedClippingHelper;
162
    private final Vector4f[] debugTerrainMatrix = new Vector4f[8];
163
    private final Vector3d debugTerrainFrustumPosition = new Vector3d();
164
    private boolean vboEnabled = false;
165
    IRenderChunkFactory renderChunkFactory;
166
    private double prevRenderSortX;
167
    private double prevRenderSortY;
168
    private double prevRenderSortZ;
169
    private boolean displayListEntitiesDirty = true;
170
171
    public RenderGlobal(Minecraft mcIn)
172
    {
173
        this.mc = mcIn;
174
        this.renderManager = mcIn.getRenderManager();
175
        this.renderEngine = mcIn.getTextureManager();
176
        this.renderEngine.bindTexture(locationForcefieldPng);
177
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT);
178
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT);
179
        GlStateManager.bindTexture(0);
180
        this.updateDestroyBlockIcons();
181
        this.vboEnabled = OpenGlHelper.useVbo();
182
183
        if (this.vboEnabled)
184
        {
185
            this.renderContainer = new VboRenderList();
186
            this.renderChunkFactory = new VboChunkFactory();
187
        }
188
        else
189
        {
190
            this.renderContainer = new RenderList();
191
            this.renderChunkFactory = new ListChunkFactory();
192
        }
193
194
        this.vertexBufferFormat = new VertexFormat();
195
        this.vertexBufferFormat.addElement(new VertexFormatElement(0, VertexFormatElement.EnumType.FLOAT, VertexFormatElement.EnumUsage.POSITION, 3));
196
        this.generateStars();
197
        this.generateSky();
198
        this.generateSky2();
199
    }
200
201
    public void onResourceManagerReload(IResourceManager resourceManager)
202
    {
203
        this.updateDestroyBlockIcons();
204
    }
205
206
    private void updateDestroyBlockIcons()
207
    {
208
        TextureMap texturemap = this.mc.getTextureMapBlocks();
209
210
        for (int i = 0; i < this.destroyBlockIcons.length; ++i)
211
        {
212
            this.destroyBlockIcons[i] = texturemap.getAtlasSprite("minecraft:blocks/destroy_stage_" + i);
213
        }
214
    }
215
216
    /**
217
     * Creates the entity outline shader to be stored in RenderGlobal.entityOutlineShader
218
     */
219
    public void makeEntityOutlineShader()
220
    {
221
        if (OpenGlHelper.shadersSupported)
222
        {
223
            if (ShaderLinkHelper.getStaticShaderLinkHelper() == null)
224
            {
225
                ShaderLinkHelper.setNewStaticShaderLinkHelper();
226
            }
227
228
            ResourceLocation resourcelocation = new ResourceLocation("shaders/post/entity_outline.json");
229
230
            try
231
            {
232
                this.entityOutlineShader = new ShaderGroup(this.mc.getTextureManager(), this.mc.getResourceManager(), this.mc.getFramebuffer(), resourcelocation);
233
                this.entityOutlineShader.createBindFramebuffers(this.mc.displayWidth, this.mc.displayHeight);
234
                this.entityOutlineFramebuffer = this.entityOutlineShader.getFramebufferRaw("final");
235
            }
236
            catch (IOException ioexception)
237
            {
238
                logger.warn((String)("Failed to load shader: " + resourcelocation), (Throwable)ioexception);
239
                this.entityOutlineShader = null;
240
                this.entityOutlineFramebuffer = null;
241
            }
242
            catch (JsonSyntaxException jsonsyntaxexception)
243
            {
244
                logger.warn((String)("Failed to load shader: " + resourcelocation), (Throwable)jsonsyntaxexception);
245
                this.entityOutlineShader = null;
246
                this.entityOutlineFramebuffer = null;
247
            }
248
        }
249
        else
250
        {
251
            this.entityOutlineShader = null;
252
            this.entityOutlineFramebuffer = null;
253
        }
254
    }
255
256
    public void renderEntityOutlineFramebuffer()
257
    {
258
        if (this.isRenderEntityOutlines())
259
        {
260
            GlStateManager.enableBlend();
261
            GlStateManager.tryBlendFuncSeparate(770, 771, 0, 1);
262
            this.entityOutlineFramebuffer.framebufferRenderExt(this.mc.displayWidth, this.mc.displayHeight, false);
263
            GlStateManager.disableBlend();
264
        }
265
    }
266
267
    protected boolean isRenderEntityOutlines()
268
    {
269
        return this.entityOutlineFramebuffer != null && this.entityOutlineShader != null && this.mc.thePlayer != null && this.mc.thePlayer.isSpectator() && this.mc.gameSettings.keyBindSpectatorOutlines.isKeyDown();
270
    }
271
272
    private void generateSky2()
273
    {
274
        Tessellator tessellator = Tessellator.getInstance();
275
        WorldRenderer worldrenderer = tessellator.getWorldRenderer();
276
277
        if (this.sky2VBO != null)
278
        {
279
            this.sky2VBO.deleteGlBuffers();
280
        }
281
282
        if (this.glSkyList2 >= 0)
283
        {
284
            GLAllocation.deleteDisplayLists(this.glSkyList2);
285
            this.glSkyList2 = -1;
286
        }
287
288
        if (this.vboEnabled)
289
        {
290
            this.sky2VBO = new VertexBuffer(this.vertexBufferFormat);
291
            this.renderSky(worldrenderer, -16.0F, true);
292
            worldrenderer.finishDrawing();
293
            worldrenderer.reset();
294
            this.sky2VBO.bufferData(worldrenderer.getByteBuffer());
295
        }
296
        else
297
        {
298
            this.glSkyList2 = GLAllocation.generateDisplayLists(1);
299
            GL11.glNewList(this.glSkyList2, GL11.GL_COMPILE);
300
            this.renderSky(worldrenderer, -16.0F, true);
301
            tessellator.draw();
302
            GL11.glEndList();
303
        }
304
    }
305
306
    private void generateSky()
307
    {
308
        Tessellator tessellator = Tessellator.getInstance();
309
        WorldRenderer worldrenderer = tessellator.getWorldRenderer();
310
311
        if (this.skyVBO != null)
312
        {
313
            this.skyVBO.deleteGlBuffers();
314
        }
315
316
        if (this.glSkyList >= 0)
317
        {
318
            GLAllocation.deleteDisplayLists(this.glSkyList);
319
            this.glSkyList = -1;
320
        }
321
322
        if (this.vboEnabled)
323
        {
324
            this.skyVBO = new VertexBuffer(this.vertexBufferFormat);
325
            this.renderSky(worldrenderer, 16.0F, false);
326
            worldrenderer.finishDrawing();
327
            worldrenderer.reset();
328
            this.skyVBO.bufferData(worldrenderer.getByteBuffer());
329
        }
330
        else
331
        {
332
            this.glSkyList = GLAllocation.generateDisplayLists(1);
333
            GL11.glNewList(this.glSkyList, GL11.GL_COMPILE);
334
            this.renderSky(worldrenderer, 16.0F, false);
335
            tessellator.draw();
336
            GL11.glEndList();
337
        }
338
    }
339
340
    private void renderSky(WorldRenderer worldRendererIn, float posY, boolean reverseX)
341
    {
342
        int i = 64;
343
        int j = 6;
344
        worldRendererIn.begin(7, DefaultVertexFormats.POSITION);
345
346
        for (int k = -384; k <= 384; k += 64)
347
        {
348
            for (int l = -384; l <= 384; l += 64)
349
            {
350
                float f = (float)k;
351
                float f1 = (float)(k + 64);
352
353
                if (reverseX)
354
                {
355
                    f1 = (float)k;
356
                    f = (float)(k + 64);
357
                }
358
359
                worldRendererIn.pos((double)f, (double)posY, (double)l).endVertex();
360
                worldRendererIn.pos((double)f1, (double)posY, (double)l).endVertex();
361
                worldRendererIn.pos((double)f1, (double)posY, (double)(l + 64)).endVertex();
362
                worldRendererIn.pos((double)f, (double)posY, (double)(l + 64)).endVertex();
363
            }
364
        }
365
    }
366
367
    private void generateStars()
368
    {
369
        Tessellator tessellator = Tessellator.getInstance();
370
        WorldRenderer worldrenderer = tessellator.getWorldRenderer();
371
372
        if (this.starVBO != null)
373
        {
374
            this.starVBO.deleteGlBuffers();
375
        }
376
377
        if (this.starGLCallList >= 0)
378
        {
379
            GLAllocation.deleteDisplayLists(this.starGLCallList);
380
            this.starGLCallList = -1;
381
        }
382
383
        if (this.vboEnabled)
384
        {
385
            this.starVBO = new VertexBuffer(this.vertexBufferFormat);
386
            this.renderStars(worldrenderer);
387
            worldrenderer.finishDrawing();
388
            worldrenderer.reset();
389
            this.starVBO.bufferData(worldrenderer.getByteBuffer());
390
        }
391
        else
392
        {
393
            this.starGLCallList = GLAllocation.generateDisplayLists(1);
394
            GlStateManager.pushMatrix();
395
            GL11.glNewList(this.starGLCallList, GL11.GL_COMPILE);
396
            this.renderStars(worldrenderer);
397
            tessellator.draw();
398
            GL11.glEndList();
399
            GlStateManager.popMatrix();
400
        }
401
    }
402
403
    private void renderStars(WorldRenderer worldRendererIn)
404
    {
405
        Random random = new Random(10842L);
406
        worldRendererIn.begin(7, DefaultVertexFormats.POSITION);
407
408
        for (int i = 0; i < 1500; ++i)
409
        {
410
            double d0 = (double)(random.nextFloat() * 2.0F - 1.0F);
411
            double d1 = (double)(random.nextFloat() * 2.0F - 1.0F);
412
            double d2 = (double)(random.nextFloat() * 2.0F - 1.0F);
413
            double d3 = (double)(0.15F + random.nextFloat() * 0.1F);
414
            double d4 = d0 * d0 + d1 * d1 + d2 * d2;
415
416
            if (d4 < 1.0D && d4 > 0.01D)
417
            {
418
                d4 = 1.0D / Math.sqrt(d4);
419
                d0 = d0 * d4;
420
                d1 = d1 * d4;
421
                d2 = d2 * d4;
422
                double d5 = d0 * 100.0D;
423
                double d6 = d1 * 100.0D;
424
                double d7 = d2 * 100.0D;
425
                double d8 = Math.atan2(d0, d2);
426
                double d9 = Math.sin(d8);
427
                double d10 = Math.cos(d8);
428
                double d11 = Math.atan2(Math.sqrt(d0 * d0 + d2 * d2), d1);
429
                double d12 = Math.sin(d11);
430
                double d13 = Math.cos(d11);
431
                double d14 = random.nextDouble() * Math.PI * 2.0D;
432
                double d15 = Math.sin(d14);
433
                double d16 = Math.cos(d14);
434
435
                for (int j = 0; j < 4; ++j)
436
                {
437
                    double d17 = 0.0D;
438
                    double d18 = (double)((j & 2) - 1) * d3;
439
                    double d19 = (double)((j + 1 & 2) - 1) * d3;
440
                    double d20 = 0.0D;
441
                    double d21 = d18 * d16 - d19 * d15;
442
                    double d22 = d19 * d16 + d18 * d15;
443
                    double d23 = d21 * d12 + 0.0D * d13;
444
                    double d24 = 0.0D * d12 - d21 * d13;
445
                    double d25 = d24 * d9 - d22 * d10;
446
                    double d26 = d22 * d9 + d24 * d10;
447
                    worldRendererIn.pos(d5 + d25, d6 + d23, d7 + d26).endVertex();
448
                }
449
            }
450
        }
451
    }
452
453
    /**
454
     * set null to clear
455
     */
456
    public void setWorldAndLoadRenderers(WorldClient worldClientIn)
457
    {
458
        if (this.theWorld != null)
459
        {
460
            this.theWorld.removeWorldAccess(this);
461
        }
462
463
        this.frustumUpdatePosX = Double.MIN_VALUE;
464
        this.frustumUpdatePosY = Double.MIN_VALUE;
465
        this.frustumUpdatePosZ = Double.MIN_VALUE;
466
        this.frustumUpdatePosChunkX = Integer.MIN_VALUE;
467
        this.frustumUpdatePosChunkY = Integer.MIN_VALUE;
468
        this.frustumUpdatePosChunkZ = Integer.MIN_VALUE;
469
        this.renderManager.set(worldClientIn);
470
        this.theWorld = worldClientIn;
471
472
        if (worldClientIn != null)
473
        {
474
            worldClientIn.addWorldAccess(this);
475
            this.loadRenderers();
476
        }
477
    }
478
479
    /**
480
     * Loads all the renderers and sets up the basic settings usage
481
     */
482
    public void loadRenderers()
483
    {
484
        if (this.theWorld != null)
485
        {
486
            this.displayListEntitiesDirty = true;
487
            Blocks.leaves.setGraphicsLevel(this.mc.gameSettings.fancyGraphics);
488
            Blocks.leaves2.setGraphicsLevel(this.mc.gameSettings.fancyGraphics);
489
            this.renderDistanceChunks = this.mc.gameSettings.renderDistanceChunks;
490
            boolean flag = this.vboEnabled;
491
            this.vboEnabled = OpenGlHelper.useVbo();
492
493
            if (flag && !this.vboEnabled)
494
            {
495
                this.renderContainer = new RenderList();
496
                this.renderChunkFactory = new ListChunkFactory();
497
            }
498
            else if (!flag && this.vboEnabled)
499
            {
500
                this.renderContainer = new VboRenderList();
501
                this.renderChunkFactory = new VboChunkFactory();
502
            }
503
504
            if (flag != this.vboEnabled)
505
            {
506
                this.generateStars();
507
                this.generateSky();
508
                this.generateSky2();
509
            }
510
511
            if (this.viewFrustum != null)
512
            {
513
                this.viewFrustum.deleteGlResources();
514
            }
515
516
            this.stopChunkUpdates();
517
518
            synchronized (this.setTileEntities)
519
            {
520
                this.setTileEntities.clear();
521
            }
522
523
            this.viewFrustum = new ViewFrustum(this.theWorld, this.mc.gameSettings.renderDistanceChunks, this, this.renderChunkFactory);
524
525
            if (this.theWorld != null)
526
            {
527
                Entity entity = this.mc.getRenderViewEntity();
528
529
                if (entity != null)
530
                {
531
                    this.viewFrustum.updateChunkPositions(entity.posX, entity.posZ);
532
                }
533
            }
534
535
            this.renderEntitiesStartupCounter = 2;
536
        }
537
    }
538
539
    protected void stopChunkUpdates()
540
    {
541
        this.chunksToUpdate.clear();
542
        this.renderDispatcher.stopChunkUpdates();
543
    }
544
545
    public void createBindEntityOutlineFbs(int width, int height)
546
    {
547
        if (OpenGlHelper.shadersSupported)
548
        {
549
            if (this.entityOutlineShader != null)
550
            {
551
                this.entityOutlineShader.createBindFramebuffers(width, height);
552
            }
553
        }
554
    }
555
556
    public void renderEntities(Entity renderViewEntity, ICamera camera, float partialTicks)
557
    {
558
        if (this.renderEntitiesStartupCounter > 0)
559
        {
560
            --this.renderEntitiesStartupCounter;
561
        }
562
        else
563
        {
564
            double d0 = renderViewEntity.prevPosX + (renderViewEntity.posX - renderViewEntity.prevPosX) * (double)partialTicks;
565
            double d1 = renderViewEntity.prevPosY + (renderViewEntity.posY - renderViewEntity.prevPosY) * (double)partialTicks;
566
            double d2 = renderViewEntity.prevPosZ + (renderViewEntity.posZ - renderViewEntity.prevPosZ) * (double)partialTicks;
567
            this.theWorld.theProfiler.startSection("prepare");
568
            TileEntityRendererDispatcher.instance.cacheActiveRenderInfo(this.theWorld, this.mc.getTextureManager(), this.mc.fontRendererObj, this.mc.getRenderViewEntity(), partialTicks);
569
            this.renderManager.cacheActiveRenderInfo(this.theWorld, this.mc.fontRendererObj, this.mc.getRenderViewEntity(), this.mc.pointedEntity, this.mc.gameSettings, partialTicks);
570
            this.countEntitiesTotal = 0;
571
            this.countEntitiesRendered = 0;
572
            this.countEntitiesHidden = 0;
573
            Entity entity = this.mc.getRenderViewEntity();
574
            double d3 = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * (double)partialTicks;
575
            double d4 = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * (double)partialTicks;
576
            double d5 = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * (double)partialTicks;
577
            TileEntityRendererDispatcher.staticPlayerX = d3;
578
            TileEntityRendererDispatcher.staticPlayerY = d4;
579
            TileEntityRendererDispatcher.staticPlayerZ = d5;
580
            this.renderManager.setRenderPosition(d3, d4, d5);
581
            this.mc.entityRenderer.enableLightmap();
582
            this.theWorld.theProfiler.endStartSection("global");
583
            List<Entity> list = this.theWorld.getLoadedEntityList();
584
            this.countEntitiesTotal = list.size();
585
586
            for (int i = 0; i < this.theWorld.weatherEffects.size(); ++i)
587
            {
588
                Entity entity1 = (Entity)this.theWorld.weatherEffects.get(i);
589
                ++this.countEntitiesRendered;
590
591
                if (entity1.isInRangeToRender3d(d0, d1, d2))
592
                {
593
                    this.renderManager.renderEntitySimple(entity1, partialTicks);
594
                }
595
            }
596
597
            if (this.isRenderEntityOutlines())
598
            {
599
                GlStateManager.depthFunc(519);
600
                GlStateManager.disableFog();
601
                this.entityOutlineFramebuffer.framebufferClear();
602
                this.entityOutlineFramebuffer.bindFramebuffer(false);
603
                this.theWorld.theProfiler.endStartSection("entityOutlines");
604
                RenderHelper.disableStandardItemLighting();
605
                this.renderManager.setRenderOutlines(true);
606
607
                for (int j = 0; j < list.size(); ++j)
608
                {
609
                    Entity entity3 = (Entity)list.get(j);
610
                    boolean flag = this.mc.getRenderViewEntity() instanceof EntityLivingBase && ((EntityLivingBase)this.mc.getRenderViewEntity()).isPlayerSleeping();
611
                    boolean flag1 = entity3.isInRangeToRender3d(d0, d1, d2) && (entity3.ignoreFrustumCheck || camera.isBoundingBoxInFrustum(entity3.getEntityBoundingBox()) || entity3.riddenByEntity == this.mc.thePlayer) && entity3 instanceof EntityPlayer;
612
613
                    if ((entity3 != this.mc.getRenderViewEntity() || this.mc.gameSettings.thirdPersonView != 0 || flag) && flag1)
614
                    {
615
                        this.renderManager.renderEntitySimple(entity3, partialTicks);
616
                    }
617
                }
618
619
                this.renderManager.setRenderOutlines(false);
620
                RenderHelper.enableStandardItemLighting();
621
                GlStateManager.depthMask(false);
622
                this.entityOutlineShader.loadShaderGroup(partialTicks);
623
                GlStateManager.enableLighting();
624
                GlStateManager.depthMask(true);
625
                this.mc.getFramebuffer().bindFramebuffer(false);
626
                GlStateManager.enableFog();
627
                GlStateManager.enableBlend();
628
                GlStateManager.enableColorMaterial();
629
                GlStateManager.depthFunc(515);
630
                GlStateManager.enableDepth();
631
                GlStateManager.enableAlpha();
632
            }
633
634
            this.theWorld.theProfiler.endStartSection("entities");
635
            label738:
636
637
            for (RenderGlobal.ContainerLocalRenderInformation renderglobal$containerlocalrenderinformation : this.renderInfos)
638
            {
639
                Chunk chunk = this.theWorld.getChunkFromBlockCoords(renderglobal$containerlocalrenderinformation.renderChunk.getPosition());
640
                ClassInheritanceMultiMap<Entity> classinheritancemultimap = chunk.getEntityLists()[renderglobal$containerlocalrenderinformation.renderChunk.getPosition().getY() / 16];
641
642
                if (!classinheritancemultimap.isEmpty())
643
                {
644
                    Iterator iterator = classinheritancemultimap.iterator();
645
646
                    while (true)
647
                    {
648
                        Entity entity2;
649
                        boolean flag2;
650
651
                        while (true)
652
                        {
653
                            if (!iterator.hasNext())
654
                            {
655
                                continue label738;
656
                            }
657
658
                            entity2 = (Entity)iterator.next();
659
                            flag2 = this.renderManager.shouldRender(entity2, camera, d0, d1, d2) || entity2.riddenByEntity == this.mc.thePlayer;
660
661
                            if (!flag2)
662
                            {
663
                                break;
664
                            }
665
666
                            boolean flag3 = this.mc.getRenderViewEntity() instanceof EntityLivingBase ? ((EntityLivingBase)this.mc.getRenderViewEntity()).isPlayerSleeping() : false;
667
668
                            if ((entity2 != this.mc.getRenderViewEntity() || this.mc.gameSettings.thirdPersonView != 0 || flag3) && (entity2.posY < 0.0D || entity2.posY >= 256.0D || this.theWorld.isBlockLoaded(new BlockPos(entity2))))
669
                            {
670
                                ++this.countEntitiesRendered;
671
                                this.renderManager.renderEntitySimple(entity2, partialTicks);
672
                                break;
673
                            }
674
                        }
675
676
                        if (!flag2 && entity2 instanceof EntityWitherSkull)
677
                        {
678
                            this.mc.getRenderManager().renderWitherSkull(entity2, partialTicks);
679
                        }
680
                    }
681
                }
682
            }
683
684
            this.theWorld.theProfiler.endStartSection("blockentities");
685
            RenderHelper.enableStandardItemLighting();
686
687
            for (RenderGlobal.ContainerLocalRenderInformation renderglobal$containerlocalrenderinformation1 : this.renderInfos)
688
            {
689
                List<TileEntity> list1 = renderglobal$containerlocalrenderinformation1.renderChunk.getCompiledChunk().getTileEntities();
690
691
                if (!list1.isEmpty())
692
                {
693
                    for (TileEntity tileentity2 : list1)
694
                    {
695
                        TileEntityRendererDispatcher.instance.renderTileEntity(tileentity2, partialTicks, -1);
696
                    }
697
                }
698
            }
699
700
            synchronized (this.setTileEntities)
701
            {
702
                for (TileEntity tileentity : this.setTileEntities)
703
                {
704
                    TileEntityRendererDispatcher.instance.renderTileEntity(tileentity, partialTicks, -1);
705
                }
706
            }
707
708
            this.preRenderDamagedBlocks();
709
710
            for (DestroyBlockProgress destroyblockprogress : this.damagedBlocks.values())
711
            {
712
                BlockPos blockpos = destroyblockprogress.getPosition();
713
                TileEntity tileentity1 = this.theWorld.getTileEntity(blockpos);
714
715
                if (tileentity1 instanceof TileEntityChest)
716
                {
717
                    TileEntityChest tileentitychest = (TileEntityChest)tileentity1;
718
719
                    if (tileentitychest.adjacentChestXNeg != null)
720
                    {
721
                        blockpos = blockpos.offset(EnumFacing.WEST);
722
                        tileentity1 = this.theWorld.getTileEntity(blockpos);
723
                    }
724
                    else if (tileentitychest.adjacentChestZNeg != null)
725
                    {
726
                        blockpos = blockpos.offset(EnumFacing.NORTH);
727
                        tileentity1 = this.theWorld.getTileEntity(blockpos);
728
                    }
729
                }
730
731
                Block block = this.theWorld.getBlockState(blockpos).getBlock();
732
733
                if (tileentity1 != null && (block instanceof BlockChest || block instanceof BlockEnderChest || block instanceof BlockSign || block instanceof BlockSkull))
734
                {
735
                    TileEntityRendererDispatcher.instance.renderTileEntity(tileentity1, partialTicks, destroyblockprogress.getPartialBlockDamage());
736
                }
737
            }
738
739
            this.postRenderDamagedBlocks();
740
            this.mc.entityRenderer.disableLightmap();
741
            this.mc.mcProfiler.endSection();
742
        }
743
    }
744
745
    /**
746
     * Gets the render info for use on the Debug screen
747
     */
748
    public String getDebugInfoRenders()
749
    {
750
        int i = this.viewFrustum.renderChunks.length;
751
        int j = 0;
752
753
        for (RenderGlobal.ContainerLocalRenderInformation renderglobal$containerlocalrenderinformation : this.renderInfos)
754
        {
755
            CompiledChunk compiledchunk = renderglobal$containerlocalrenderinformation.renderChunk.compiledChunk;
756
757
            if (compiledchunk != CompiledChunk.DUMMY && !compiledchunk.isEmpty())
758
            {
759
                ++j;
760
            }
761
        }
762
763
        return String.format("C: %d/%d %sD: %d, %s", new Object[] {Integer.valueOf(j), Integer.valueOf(i), this.mc.renderChunksMany ? "(s) " : "", Integer.valueOf(this.renderDistanceChunks), this.renderDispatcher.getDebugInfo()});
764
    }
765
766
    /**
767
     * Gets the entities info for use on the Debug screen
768
     */
769
    public String getDebugInfoEntities()
770
    {
771
        return "E: " + this.countEntitiesRendered + "/" + this.countEntitiesTotal + ", B: " + this.countEntitiesHidden + ", I: " + (this.countEntitiesTotal - this.countEntitiesHidden - this.countEntitiesRendered);
772
    }
773
774
    public void setupTerrain(Entity viewEntity, double partialTicks, ICamera camera, int frameCount, boolean playerSpectator)
775
    {
776
        if (this.mc.gameSettings.renderDistanceChunks != this.renderDistanceChunks)
777
        {
778
            this.loadRenderers();
779
        }
780
781
        this.theWorld.theProfiler.startSection("camera");
782
        double d0 = viewEntity.posX - this.frustumUpdatePosX;
783
        double d1 = viewEntity.posY - this.frustumUpdatePosY;
784
        double d2 = viewEntity.posZ - this.frustumUpdatePosZ;
785
786
        if (this.frustumUpdatePosChunkX != viewEntity.chunkCoordX || this.frustumUpdatePosChunkY != viewEntity.chunkCoordY || this.frustumUpdatePosChunkZ != viewEntity.chunkCoordZ || d0 * d0 + d1 * d1 + d2 * d2 > 16.0D)
787
        {
788
            this.frustumUpdatePosX = viewEntity.posX;
789
            this.frustumUpdatePosY = viewEntity.posY;
790
            this.frustumUpdatePosZ = viewEntity.posZ;
791
            this.frustumUpdatePosChunkX = viewEntity.chunkCoordX;
792
            this.frustumUpdatePosChunkY = viewEntity.chunkCoordY;
793
            this.frustumUpdatePosChunkZ = viewEntity.chunkCoordZ;
794
            this.viewFrustum.updateChunkPositions(viewEntity.posX, viewEntity.posZ);
795
        }
796
797
        this.theWorld.theProfiler.endStartSection("renderlistcamera");
798
        double d3 = viewEntity.lastTickPosX + (viewEntity.posX - viewEntity.lastTickPosX) * partialTicks;
799
        double d4 = viewEntity.lastTickPosY + (viewEntity.posY - viewEntity.lastTickPosY) * partialTicks;
800
        double d5 = viewEntity.lastTickPosZ + (viewEntity.posZ - viewEntity.lastTickPosZ) * partialTicks;
801
        this.renderContainer.initialize(d3, d4, d5);
802
        this.theWorld.theProfiler.endStartSection("cull");
803
804
        if (this.debugFixedClippingHelper != null)
805
        {
806
            Frustum frustum = new Frustum(this.debugFixedClippingHelper);
807
            frustum.setPosition(this.debugTerrainFrustumPosition.x, this.debugTerrainFrustumPosition.y, this.debugTerrainFrustumPosition.z);
808
            camera = frustum;
809
        }
810
811
        this.mc.mcProfiler.endStartSection("culling");
812
        BlockPos blockpos1 = new BlockPos(d3, d4 + (double)viewEntity.getEyeHeight(), d5);
813
        RenderChunk renderchunk = this.viewFrustum.getRenderChunk(blockpos1);
814
        BlockPos blockpos = new BlockPos(MathHelper.floor_double(d3 / 16.0D) * 16, MathHelper.floor_double(d4 / 16.0D) * 16, MathHelper.floor_double(d5 / 16.0D) * 16);
815
        this.displayListEntitiesDirty = this.displayListEntitiesDirty || !this.chunksToUpdate.isEmpty() || viewEntity.posX != this.lastViewEntityX || viewEntity.posY != this.lastViewEntityY || viewEntity.posZ != this.lastViewEntityZ || (double)viewEntity.rotationPitch != this.lastViewEntityPitch || (double)viewEntity.rotationYaw != this.lastViewEntityYaw;
816
        this.lastViewEntityX = viewEntity.posX;
817
        this.lastViewEntityY = viewEntity.posY;
818
        this.lastViewEntityZ = viewEntity.posZ;
819
        this.lastViewEntityPitch = (double)viewEntity.rotationPitch;
820
        this.lastViewEntityYaw = (double)viewEntity.rotationYaw;
821
        boolean flag = this.debugFixedClippingHelper != null;
822
823
        if (!flag && this.displayListEntitiesDirty)
824
        {
825
            this.displayListEntitiesDirty = false;
826
            this.renderInfos = Lists.<RenderGlobal.ContainerLocalRenderInformation>newArrayList();
827
            Queue<RenderGlobal.ContainerLocalRenderInformation> queue = Lists.<RenderGlobal.ContainerLocalRenderInformation>newLinkedList();
828
            boolean flag1 = this.mc.renderChunksMany;
829
830
            if (renderchunk != null)
831
            {
832
                boolean flag2 = false;
833
                RenderGlobal.ContainerLocalRenderInformation renderglobal$containerlocalrenderinformation3 = new RenderGlobal.ContainerLocalRenderInformation(renderchunk, (EnumFacing)null, 0);
834
                Set<EnumFacing> set1 = this.getVisibleFacings(blockpos1);
835
836
                if (set1.size() == 1)
837
                {
838
                    Vector3f vector3f = this.getViewVector(viewEntity, partialTicks);
839
                    EnumFacing enumfacing = EnumFacing.getFacingFromVector(vector3f.x, vector3f.y, vector3f.z).getOpposite();
840
                    set1.remove(enumfacing);
841
                }
842
843
                if (set1.isEmpty())
844
                {
845
                    flag2 = true;
846
                }
847
848
                if (flag2 && !playerSpectator)
849
                {
850
                    this.renderInfos.add(renderglobal$containerlocalrenderinformation3);
851
                }
852
                else
853
                {
854
                    if (playerSpectator && this.theWorld.getBlockState(blockpos1).getBlock().isOpaqueCube())
855
                    {
856
                        flag1 = false;
857
                    }
858
859
                    renderchunk.setFrameIndex(frameCount);
860
                    queue.add(renderglobal$containerlocalrenderinformation3);
861
                }
862
            }
863
            else
864
            {
865
                int i = blockpos1.getY() > 0 ? 248 : 8;
866
867
                for (int j = -this.renderDistanceChunks; j <= this.renderDistanceChunks; ++j)
868
                {
869
                    for (int k = -this.renderDistanceChunks; k <= this.renderDistanceChunks; ++k)
870
                    {
871
                        RenderChunk renderchunk1 = this.viewFrustum.getRenderChunk(new BlockPos((j << 4) + 8, i, (k << 4) + 8));
872
873
                        if (renderchunk1 != null && ((ICamera)camera).isBoundingBoxInFrustum(renderchunk1.boundingBox))
874
                        {
875
                            renderchunk1.setFrameIndex(frameCount);
876
                            queue.add(new RenderGlobal.ContainerLocalRenderInformation(renderchunk1, (EnumFacing)null, 0));
877
                        }
878
                    }
879
                }
880
            }
881
882
            while (!((Queue)queue).isEmpty())
883
            {
884
                RenderGlobal.ContainerLocalRenderInformation renderglobal$containerlocalrenderinformation1 = (RenderGlobal.ContainerLocalRenderInformation)queue.poll();
885
                RenderChunk renderchunk3 = renderglobal$containerlocalrenderinformation1.renderChunk;
886
                EnumFacing enumfacing2 = renderglobal$containerlocalrenderinformation1.facing;
887
                BlockPos blockpos2 = renderchunk3.getPosition();
888
                this.renderInfos.add(renderglobal$containerlocalrenderinformation1);
889
890
                for (EnumFacing enumfacing1 : EnumFacing.values())
891
                {
892
                    RenderChunk renderchunk2 = this.getRenderChunkOffset(blockpos, renderchunk3, enumfacing1);
893
894
                    if ((!flag1 || !renderglobal$containerlocalrenderinformation1.setFacing.contains(enumfacing1.getOpposite())) && (!flag1 || enumfacing2 == null || renderchunk3.getCompiledChunk().isVisible(enumfacing2.getOpposite(), enumfacing1)) && renderchunk2 != null && renderchunk2.setFrameIndex(frameCount) && ((ICamera)camera).isBoundingBoxInFrustum(renderchunk2.boundingBox))
895
                    {
896
                        RenderGlobal.ContainerLocalRenderInformation renderglobal$containerlocalrenderinformation = new RenderGlobal.ContainerLocalRenderInformation(renderchunk2, enumfacing1, renderglobal$containerlocalrenderinformation1.counter + 1);
897
                        renderglobal$containerlocalrenderinformation.setFacing.addAll(renderglobal$containerlocalrenderinformation1.setFacing);
898
                        renderglobal$containerlocalrenderinformation.setFacing.add(enumfacing1);
899
                        queue.add(renderglobal$containerlocalrenderinformation);
900
                    }
901
                }
902
            }
903
        }
904
905
        if (this.debugFixTerrainFrustum)
906
        {
907
            this.fixTerrainFrustum(d3, d4, d5);
908
            this.debugFixTerrainFrustum = false;
909
        }
910
911
        this.renderDispatcher.clearChunkUpdates();
912
        Set<RenderChunk> set = this.chunksToUpdate;
913
        this.chunksToUpdate = Sets.<RenderChunk>newLinkedHashSet();
914
915
        for (RenderGlobal.ContainerLocalRenderInformation renderglobal$containerlocalrenderinformation2 : this.renderInfos)
916
        {
917
            RenderChunk renderchunk4 = renderglobal$containerlocalrenderinformation2.renderChunk;
918
919
            if (renderchunk4.isNeedsUpdate() || set.contains(renderchunk4))
920
            {
921
                this.displayListEntitiesDirty = true;
922
923
                if (this.isPositionInRenderChunk(blockpos, renderglobal$containerlocalrenderinformation2.renderChunk))
924
                {
925
                    this.mc.mcProfiler.startSection("build near");
926
                    this.renderDispatcher.updateChunkNow(renderchunk4);
927
                    renderchunk4.setNeedsUpdate(false);
928
                    this.mc.mcProfiler.endSection();
929
                }
930
                else
931
                {
932
                    this.chunksToUpdate.add(renderchunk4);
933
                }
934
            }
935
        }
936
937
        this.chunksToUpdate.addAll(set);
938
        this.mc.mcProfiler.endSection();
939
    }
940
941
    private boolean isPositionInRenderChunk(BlockPos pos, RenderChunk renderChunkIn)
942
    {
943
        BlockPos blockpos = renderChunkIn.getPosition();
944
        return MathHelper.abs_int(pos.getX() - blockpos.getX()) > 16 ? false : (MathHelper.abs_int(pos.getY() - blockpos.getY()) > 16 ? false : MathHelper.abs_int(pos.getZ() - blockpos.getZ()) <= 16);
945
    }
946
947
    private Set<EnumFacing> getVisibleFacings(BlockPos pos)
948
    {
949
        VisGraph visgraph = new VisGraph();
950
        BlockPos blockpos = new BlockPos(pos.getX() >> 4 << 4, pos.getY() >> 4 << 4, pos.getZ() >> 4 << 4);
951
        Chunk chunk = this.theWorld.getChunkFromBlockCoords(blockpos);
952
953
        for (BlockPos.MutableBlockPos blockpos$mutableblockpos : BlockPos.getAllInBoxMutable(blockpos, blockpos.add(15, 15, 15)))
954
        {
955
            if (chunk.getBlock(blockpos$mutableblockpos).isOpaqueCube())
956
            {
957
                visgraph.func_178606_a(blockpos$mutableblockpos);
958
            }
959
        }
960
        return visgraph.func_178609_b(pos);
961
    }
962
963
    /**
964
     * Returns RenderChunk offset from given RenderChunk in given direction, or null if it can't be seen by player at
965
     * given BlockPos.
966
     */
967
    private RenderChunk getRenderChunkOffset(BlockPos playerPos, RenderChunk renderChunkBase, EnumFacing facing)
968
    {
969
        BlockPos blockpos = renderChunkBase.getBlockPosOffset16(facing);
970
        return MathHelper.abs_int(playerPos.getX() - blockpos.getX()) > this.renderDistanceChunks * 16 ? null : (blockpos.getY() >= 0 && blockpos.getY() < 256 ? (MathHelper.abs_int(playerPos.getZ() - blockpos.getZ()) > this.renderDistanceChunks * 16 ? null : this.viewFrustum.getRenderChunk(blockpos)) : null);
971
    }
972
973
    private void fixTerrainFrustum(double x, double y, double z)
974
    {
975
        this.debugFixedClippingHelper = new ClippingHelperImpl();
976
        ((ClippingHelperImpl)this.debugFixedClippingHelper).init();
977
        Matrix4f matrix4f = new Matrix4f(this.debugFixedClippingHelper.modelviewMatrix);
978
        matrix4f.transpose();
979
        Matrix4f matrix4f1 = new Matrix4f(this.debugFixedClippingHelper.projectionMatrix);
980
        matrix4f1.transpose();
981
        Matrix4f matrix4f2 = new Matrix4f();
982
        Matrix4f.mul(matrix4f1, matrix4f, matrix4f2);
983
        matrix4f2.invert();
984
        this.debugTerrainFrustumPosition.x = x;
985
        this.debugTerrainFrustumPosition.y = y;
986
        this.debugTerrainFrustumPosition.z = z;
987
        this.debugTerrainMatrix[0] = new Vector4f(-1.0F, -1.0F, -1.0F, 1.0F);
988
        this.debugTerrainMatrix[1] = new Vector4f(1.0F, -1.0F, -1.0F, 1.0F);
989
        this.debugTerrainMatrix[2] = new Vector4f(1.0F, 1.0F, -1.0F, 1.0F);
990
        this.debugTerrainMatrix[3] = new Vector4f(-1.0F, 1.0F, -1.0F, 1.0F);
991
        this.debugTerrainMatrix[4] = new Vector4f(-1.0F, -1.0F, 1.0F, 1.0F);
992
        this.debugTerrainMatrix[5] = new Vector4f(1.0F, -1.0F, 1.0F, 1.0F);
993
        this.debugTerrainMatrix[6] = new Vector4f(1.0F, 1.0F, 1.0F, 1.0F);
994
        this.debugTerrainMatrix[7] = new Vector4f(-1.0F, 1.0F, 1.0F, 1.0F);
995
996
        for (int i = 0; i < 8; ++i)
997
        {
998
            Matrix4f.transform(matrix4f2, this.debugTerrainMatrix[i], this.debugTerrainMatrix[i]);
999
            this.debugTerrainMatrix[i].x /= this.debugTerrainMatrix[i].w;
1000
            this.debugTerrainMatrix[i].y /= this.debugTerrainMatrix[i].w;
1001
            this.debugTerrainMatrix[i].z /= this.debugTerrainMatrix[i].w;
1002
            this.debugTerrainMatrix[i].w = 1.0F;
1003
        }
1004
    }
1005
1006
    protected Vector3f getViewVector(Entity entityIn, double partialTicks)
1007
    {
1008
        float f = (float)((double)entityIn.prevRotationPitch + (double)(entityIn.rotationPitch - entityIn.prevRotationPitch) * partialTicks);
1009
        float f1 = (float)((double)entityIn.prevRotationYaw + (double)(entityIn.rotationYaw - entityIn.prevRotationYaw) * partialTicks);
1010
1011
        if (Minecraft.getMinecraft().gameSettings.thirdPersonView == 2)
1012
        {
1013
            f += 180.0F;
1014
        }
1015
1016
        float f2 = MathHelper.cos(-f1 * 0.017453292F - (float)Math.PI);
1017
        float f3 = MathHelper.sin(-f1 * 0.017453292F - (float)Math.PI);
1018
        float f4 = -MathHelper.cos(-f * 0.017453292F);
1019
        float f5 = MathHelper.sin(-f * 0.017453292F);
1020
        return new Vector3f(f3 * f4, f5, f2 * f4);
1021
    }
1022
1023
    public int renderBlockLayer(EnumWorldBlockLayer blockLayerIn, double partialTicks, int pass, Entity entityIn)
1024
    {
1025
        RenderHelper.disableStandardItemLighting();
1026
1027
        if (blockLayerIn == EnumWorldBlockLayer.TRANSLUCENT)
1028
        {
1029
            this.mc.mcProfiler.startSection("translucent_sort");
1030
            double d0 = entityIn.posX - this.prevRenderSortX;
1031
            double d1 = entityIn.posY - this.prevRenderSortY;
1032
            double d2 = entityIn.posZ - this.prevRenderSortZ;
1033
1034
            if (d0 * d0 + d1 * d1 + d2 * d2 > 1.0D)
1035
            {
1036
                this.prevRenderSortX = entityIn.posX;
1037
                this.prevRenderSortY = entityIn.posY;
1038
                this.prevRenderSortZ = entityIn.posZ;
1039
                int k = 0;
1040
1041
                for (RenderGlobal.ContainerLocalRenderInformation renderglobal$containerlocalrenderinformation : this.renderInfos)
1042
                {
1043
                    if (renderglobal$containerlocalrenderinformation.renderChunk.compiledChunk.isLayerStarted(blockLayerIn) && k++ < 15)
1044
                    {
1045
                        this.renderDispatcher.updateTransparencyLater(renderglobal$containerlocalrenderinformation.renderChunk);
1046
                    }
1047
                }
1048
            }
1049
1050
            this.mc.mcProfiler.endSection();
1051
        }
1052
1053
        this.mc.mcProfiler.startSection("filterempty");
1054
        int l = 0;
1055
        boolean flag = blockLayerIn == EnumWorldBlockLayer.TRANSLUCENT;
1056
        int i1 = flag ? this.renderInfos.size() - 1 : 0;
1057
        int i = flag ? -1 : this.renderInfos.size();
1058
        int j1 = flag ? -1 : 1;
1059
1060
        for (int j = i1; j != i; j += j1)
1061
        {
1062
            RenderChunk renderchunk = ((RenderGlobal.ContainerLocalRenderInformation)this.renderInfos.get(j)).renderChunk;
1063
1064
            if (!renderchunk.getCompiledChunk().isLayerEmpty(blockLayerIn))
1065
            {
1066
                ++l;
1067
                this.renderContainer.addRenderChunk(renderchunk, blockLayerIn);
1068
            }
1069
        }
1070
1071
        this.mc.mcProfiler.endStartSection("render_" + blockLayerIn);
1072
        this.renderBlockLayer(blockLayerIn);
1073
        this.mc.mcProfiler.endSection();
1074
        return l;
1075
    }
1076
1077
    @SuppressWarnings("incomplete-switch")
1078
    private void renderBlockLayer(EnumWorldBlockLayer blockLayerIn)
1079
    {
1080
        this.mc.entityRenderer.enableLightmap();
1081
1082
        if (OpenGlHelper.useVbo())
1083
        {
1084
            GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
1085
            OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit);
1086
            GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
1087
            OpenGlHelper.setClientActiveTexture(OpenGlHelper.lightmapTexUnit);
1088
            GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
1089
            OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit);
1090
            GL11.glEnableClientState(GL11.GL_COLOR_ARRAY);
1091
        }
1092
1093
        this.renderContainer.renderChunkLayer(blockLayerIn);
1094
1095
        if (OpenGlHelper.useVbo())
1096
        {
1097
            for (VertexFormatElement vertexformatelement : DefaultVertexFormats.BLOCK.getElements())
1098
            {
1099
                VertexFormatElement.EnumUsage vertexformatelement$enumusage = vertexformatelement.getUsage();
1100
                int i = vertexformatelement.getIndex();
1101
1102
                switch (vertexformatelement$enumusage)
1103
                {
1104
                    case POSITION:
1105
                        GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
1106
                        break;
1107
1108
                    case UV:
1109
                        OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit + i);
1110
                        GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
1111
                        OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit);
1112
                        break;
1113
1114
                    case COLOR:
1115
                        GL11.glDisableClientState(GL11.GL_COLOR_ARRAY);
1116
                        GlStateManager.resetColor();
1117
                }
1118
            }
1119
        }
1120
1121
        this.mc.entityRenderer.disableLightmap();
1122
    }
1123
1124
    private void cleanupDamagedBlocks(Iterator<DestroyBlockProgress> iteratorIn)
1125
    {
1126
        while (iteratorIn.hasNext())
1127
        {
1128
            DestroyBlockProgress destroyblockprogress = (DestroyBlockProgress)iteratorIn.next();
1129
            int i = destroyblockprogress.getCreationCloudUpdateTick();
1130
1131
            if (this.cloudTickCounter - i > 400)
1132
            {
1133
                iteratorIn.remove();
1134
            }
1135
        }
1136
    }
1137
1138
    public void updateClouds()
1139
    {
1140
        ++this.cloudTickCounter;
1141
1142
        if (this.cloudTickCounter % 20 == 0)
1143
        {
1144
            this.cleanupDamagedBlocks(this.damagedBlocks.values().iterator());
1145
        }
1146
    }
1147
1148
    private void renderSkyEnd()
1149
    {
1150
        GlStateManager.disableFog();
1151
        GlStateManager.disableAlpha();
1152
        GlStateManager.enableBlend();
1153
        GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
1154
        RenderHelper.disableStandardItemLighting();
1155
        GlStateManager.depthMask(false);
1156
        this.renderEngine.bindTexture(locationEndSkyPng);
1157
        Tessellator tessellator = Tessellator.getInstance();
1158
        WorldRenderer worldrenderer = tessellator.getWorldRenderer();
1159
1160
        for (int i = 0; i < 6; ++i)
1161
        {
1162
            GlStateManager.pushMatrix();
1163
1164
            if (i == 1)
1165
            {
1166
                GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F);
1167
            }
1168
1169
            if (i == 2)
1170
            {
1171
                GlStateManager.rotate(-90.0F, 1.0F, 0.0F, 0.0F);
1172
            }
1173
1174
            if (i == 3)
1175
            {
1176
                GlStateManager.rotate(180.0F, 1.0F, 0.0F, 0.0F);
1177
            }
1178
1179
            if (i == 4)
1180
            {
1181
                GlStateManager.rotate(90.0F, 0.0F, 0.0F, 1.0F);
1182
            }
1183
1184
            if (i == 5)
1185
            {
1186
                GlStateManager.rotate(-90.0F, 0.0F, 0.0F, 1.0F);
1187
            }
1188
1189
            worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
1190
            worldrenderer.pos(-100.0D, -100.0D, -100.0D).tex(0.0D, 0.0D).color(40, 40, 40, 255).endVertex();
1191
            worldrenderer.pos(-100.0D, -100.0D, 100.0D).tex(0.0D, 16.0D).color(40, 40, 40, 255).endVertex();
1192
            worldrenderer.pos(100.0D, -100.0D, 100.0D).tex(16.0D, 16.0D).color(40, 40, 40, 255).endVertex();
1193
            worldrenderer.pos(100.0D, -100.0D, -100.0D).tex(16.0D, 0.0D).color(40, 40, 40, 255).endVertex();
1194
            tessellator.draw();
1195
            GlStateManager.popMatrix();
1196
        }
1197
1198
        GlStateManager.depthMask(true);
1199
        GlStateManager.enableTexture2D();
1200
        GlStateManager.enableAlpha();
1201
    }
1202
1203
    public void renderSky(float partialTicks, int pass)
1204
    {
1205
        if (this.mc.theWorld.provider.getDimensionId() == 1)
1206
        {
1207
            this.renderSkyEnd();
1208
        }
1209
        else if (this.mc.theWorld.provider.isSurfaceWorld())
1210
        {
1211
            GlStateManager.disableTexture2D();
1212
            Vec3 vec3 = this.theWorld.getSkyColor(this.mc.getRenderViewEntity(), partialTicks);
1213
            float f = (float)vec3.xCoord;
1214
            float f1 = (float)vec3.yCoord;
1215
            float f2 = (float)vec3.zCoord;
1216
1217
            if (pass != 2)
1218
            {
1219
                float f3 = (f * 30.0F + f1 * 59.0F + f2 * 11.0F) / 100.0F;
1220
                float f4 = (f * 30.0F + f1 * 70.0F) / 100.0F;
1221
                float f5 = (f * 30.0F + f2 * 70.0F) / 100.0F;
1222
                f = f3;
1223
                f1 = f4;
1224
                f2 = f5;
1225
            }
1226
1227
            GlStateManager.color(f, f1, f2);
1228
            Tessellator tessellator = Tessellator.getInstance();
1229
            WorldRenderer worldrenderer = tessellator.getWorldRenderer();
1230
            GlStateManager.depthMask(false);
1231
            GlStateManager.enableFog();
1232
            GlStateManager.color(f, f1, f2);
1233
1234
            if (this.vboEnabled)
1235
            {
1236
                this.skyVBO.bindBuffer();
1237
                GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
1238
                GL11.glVertexPointer(3, GL11.GL_FLOAT, 12, 0L);
1239
                this.skyVBO.drawArrays(7);
1240
                this.skyVBO.unbindBuffer();
1241
                GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
1242
            }
1243
            else
1244
            {
1245
                GlStateManager.callList(this.glSkyList);
1246
            }
1247
1248
            GlStateManager.disableFog();
1249
            GlStateManager.disableAlpha();
1250
            GlStateManager.enableBlend();
1251
            GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
1252
            RenderHelper.disableStandardItemLighting();
1253
            float[] afloat = this.theWorld.provider.calcSunriseSunsetColors(this.theWorld.getCelestialAngle(partialTicks), partialTicks);
1254
1255
            if (afloat != null)
1256
            {
1257
                GlStateManager.disableTexture2D();
1258
                GlStateManager.shadeModel(7425);
1259
                GlStateManager.pushMatrix();
1260
                GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F);
1261
                GlStateManager.rotate(MathHelper.sin(this.theWorld.getCelestialAngleRadians(partialTicks)) < 0.0F ? 180.0F : 0.0F, 0.0F, 0.0F, 1.0F);
1262
                GlStateManager.rotate(90.0F, 0.0F, 0.0F, 1.0F);
1263
                float f6 = afloat[0];
1264
                float f7 = afloat[1];
1265
                float f8 = afloat[2];
1266
1267
                if (pass != 2)
1268
                {
1269
                    float f9 = (f6 * 30.0F + f7 * 59.0F + f8 * 11.0F) / 100.0F;
1270
                    float f10 = (f6 * 30.0F + f7 * 70.0F) / 100.0F;
1271
                    float f11 = (f6 * 30.0F + f8 * 70.0F) / 100.0F;
1272
                    f6 = f9;
1273
                    f7 = f10;
1274
                    f8 = f11;
1275
                }
1276
1277
                worldrenderer.begin(6, DefaultVertexFormats.POSITION_COLOR);
1278
                worldrenderer.pos(0.0D, 100.0D, 0.0D).color(f6, f7, f8, afloat[3]).endVertex();
1279
                int j = 16;
1280
1281
                for (int l = 0; l <= 16; ++l)
1282
                {
1283
                    float f21 = (float)l * (float)Math.PI * 2.0F / 16.0F;
1284
                    float f12 = MathHelper.sin(f21);
1285
                    float f13 = MathHelper.cos(f21);
1286
                    worldrenderer.pos((double)(f12 * 120.0F), (double)(f13 * 120.0F), (double)(-f13 * 40.0F * afloat[3])).color(afloat[0], afloat[1], afloat[2], 0.0F).endVertex();
1287
                }
1288
1289
                tessellator.draw();
1290
                GlStateManager.popMatrix();
1291
                GlStateManager.shadeModel(7424);
1292
            }
1293
1294
            GlStateManager.enableTexture2D();
1295
            GlStateManager.tryBlendFuncSeparate(770, 1, 1, 0);
1296
            GlStateManager.pushMatrix();
1297
            float f16 = 1.0F - this.theWorld.getRainStrength(partialTicks);
1298
            GlStateManager.color(1.0F, 1.0F, 1.0F, f16);
1299
            GlStateManager.rotate(-90.0F, 0.0F, 1.0F, 0.0F);
1300
            GlStateManager.rotate(this.theWorld.getCelestialAngle(partialTicks) * 360.0F, 1.0F, 0.0F, 0.0F);
1301
            float f17 = 30.0F;
1302
            this.renderEngine.bindTexture(locationSunPng);
1303
            worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX);
1304
            worldrenderer.pos((double)(-f17), 100.0D, (double)(-f17)).tex(0.0D, 0.0D).endVertex();
1305
            worldrenderer.pos((double)f17, 100.0D, (double)(-f17)).tex(1.0D, 0.0D).endVertex();
1306
            worldrenderer.pos((double)f17, 100.0D, (double)f17).tex(1.0D, 1.0D).endVertex();
1307
            worldrenderer.pos((double)(-f17), 100.0D, (double)f17).tex(0.0D, 1.0D).endVertex();
1308
            tessellator.draw();
1309
            f17 = 20.0F;
1310
            this.renderEngine.bindTexture(locationMoonPhasesPng);
1311
            int i = this.theWorld.getMoonPhase();
1312
            int k = i % 4;
1313
            int i1 = i / 4 % 2;
1314
            float f22 = (float)(k + 0) / 4.0F;
1315
            float f23 = (float)(i1 + 0) / 2.0F;
1316
            float f24 = (float)(k + 1) / 4.0F;
1317
            float f14 = (float)(i1 + 1) / 2.0F;
1318
            worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX);
1319
            worldrenderer.pos((double)(-f17), -100.0D, (double)f17).tex((double)f24, (double)f14).endVertex();
1320
            worldrenderer.pos((double)f17, -100.0D, (double)f17).tex((double)f22, (double)f14).endVertex();
1321
            worldrenderer.pos((double)f17, -100.0D, (double)(-f17)).tex((double)f22, (double)f23).endVertex();
1322
            worldrenderer.pos((double)(-f17), -100.0D, (double)(-f17)).tex((double)f24, (double)f23).endVertex();
1323
            tessellator.draw();
1324
            GlStateManager.disableTexture2D();
1325
            float f15 = this.theWorld.getStarBrightness(partialTicks) * f16;
1326
1327
            if (f15 > 0.0F)
1328
            {
1329
                GlStateManager.color(f15, f15, f15, f15);
1330
1331
                if (this.vboEnabled)
1332
                {
1333
                    this.starVBO.bindBuffer();
1334
                    GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
1335
                    GL11.glVertexPointer(3, GL11.GL_FLOAT, 12, 0L);
1336
                    this.starVBO.drawArrays(7);
1337
                    this.starVBO.unbindBuffer();
1338
                    GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
1339
                }
1340
                else
1341
                {
1342
                    GlStateManager.callList(this.starGLCallList);
1343
                }
1344
            }
1345
1346
            GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
1347
            GlStateManager.disableBlend();
1348
            GlStateManager.enableAlpha();
1349
            GlStateManager.enableFog();
1350
            GlStateManager.popMatrix();
1351
            GlStateManager.disableTexture2D();
1352
            GlStateManager.color(0.0F, 0.0F, 0.0F);
1353
            double d0 = this.mc.thePlayer.getPositionEyes(partialTicks).yCoord - this.theWorld.getHorizon();
1354
1355
            if (d0 < 0.0D)
1356
            {
1357
                GlStateManager.pushMatrix();
1358
                GlStateManager.translate(0.0F, 12.0F, 0.0F);
1359
1360
                if (this.vboEnabled)
1361
                {
1362
                    this.sky2VBO.bindBuffer();
1363
                    GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
1364
                    GL11.glVertexPointer(3, GL11.GL_FLOAT, 12, 0L);
1365
                    this.sky2VBO.drawArrays(7);
1366
                    this.sky2VBO.unbindBuffer();
1367
                    GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
1368
                }
1369
                else
1370
                {
1371
                    GlStateManager.callList(this.glSkyList2);
1372
                }
1373
1374
                GlStateManager.popMatrix();
1375
                float f18 = 1.0F;
1376
                float f19 = -((float)(d0 + 65.0D));
1377
                float f20 = -1.0F;
1378
                worldrenderer.begin(7, DefaultVertexFormats.POSITION_COLOR);
1379
                worldrenderer.pos(-1.0D, (double)f19, 1.0D).color(0, 0, 0, 255).endVertex();
1380
                worldrenderer.pos(1.0D, (double)f19, 1.0D).color(0, 0, 0, 255).endVertex();
1381
                worldrenderer.pos(1.0D, -1.0D, 1.0D).color(0, 0, 0, 255).endVertex();
1382
                worldrenderer.pos(-1.0D, -1.0D, 1.0D).color(0, 0, 0, 255).endVertex();
1383
                worldrenderer.pos(-1.0D, -1.0D, -1.0D).color(0, 0, 0, 255).endVertex();
1384
                worldrenderer.pos(1.0D, -1.0D, -1.0D).color(0, 0, 0, 255).endVertex();
1385
                worldrenderer.pos(1.0D, (double)f19, -1.0D).color(0, 0, 0, 255).endVertex();
1386
                worldrenderer.pos(-1.0D, (double)f19, -1.0D).color(0, 0, 0, 255).endVertex();
1387
                worldrenderer.pos(1.0D, -1.0D, -1.0D).color(0, 0, 0, 255).endVertex();
1388
                worldrenderer.pos(1.0D, -1.0D, 1.0D).color(0, 0, 0, 255).endVertex();
1389
                worldrenderer.pos(1.0D, (double)f19, 1.0D).color(0, 0, 0, 255).endVertex();
1390
                worldrenderer.pos(1.0D, (double)f19, -1.0D).color(0, 0, 0, 255).endVertex();
1391
                worldrenderer.pos(-1.0D, (double)f19, -1.0D).color(0, 0, 0, 255).endVertex();
1392
                worldrenderer.pos(-1.0D, (double)f19, 1.0D).color(0, 0, 0, 255).endVertex();
1393
                worldrenderer.pos(-1.0D, -1.0D, 1.0D).color(0, 0, 0, 255).endVertex();
1394
                worldrenderer.pos(-1.0D, -1.0D, -1.0D).color(0, 0, 0, 255).endVertex();
1395
                worldrenderer.pos(-1.0D, -1.0D, -1.0D).color(0, 0, 0, 255).endVertex();
1396
                worldrenderer.pos(-1.0D, -1.0D, 1.0D).color(0, 0, 0, 255).endVertex();
1397
                worldrenderer.pos(1.0D, -1.0D, 1.0D).color(0, 0, 0, 255).endVertex();
1398
                worldrenderer.pos(1.0D, -1.0D, -1.0D).color(0, 0, 0, 255).endVertex();
1399
                tessellator.draw();
1400
            }
1401
1402
            if (this.theWorld.provider.isSkyColored())
1403
            {
1404
                GlStateManager.color(f * 0.2F + 0.04F, f1 * 0.2F + 0.04F, f2 * 0.6F + 0.1F);
1405
            }
1406
            else
1407
            {
1408
                GlStateManager.color(f, f1, f2);
1409
            }
1410
1411
            GlStateManager.pushMatrix();
1412
            GlStateManager.translate(0.0F, -((float)(d0 - 16.0D)), 0.0F);
1413
            GlStateManager.callList(this.glSkyList2);
1414
            GlStateManager.popMatrix();
1415
            GlStateManager.enableTexture2D();
1416
            GlStateManager.depthMask(true);
1417
        }
1418
    }
1419
1420
    public void renderClouds(float partialTicks, int pass)
1421
    {
1422
        if (this.mc.theWorld.provider.isSurfaceWorld())
1423
        {
1424
            if (this.mc.gameSettings.shouldRenderClouds() == 2)
1425
            {
1426
                this.renderCloudsFancy(partialTicks, pass);
1427
            }
1428
            else
1429
            {
1430
                GlStateManager.disableCull();
1431
                float f = (float)(this.mc.getRenderViewEntity().lastTickPosY + (this.mc.getRenderViewEntity().posY - this.mc.getRenderViewEntity().lastTickPosY) * (double)partialTicks);
1432
                int i = 32;
1433
                int j = 8;
1434
                Tessellator tessellator = Tessellator.getInstance();
1435
                WorldRenderer worldrenderer = tessellator.getWorldRenderer();
1436
                this.renderEngine.bindTexture(locationCloudsPng);
1437
                GlStateManager.enableBlend();
1438
                GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
1439
                Vec3 vec3 = this.theWorld.getCloudColour(partialTicks);
1440
                float f1 = (float)vec3.xCoord;
1441
                float f2 = (float)vec3.yCoord;
1442
                float f3 = (float)vec3.zCoord;
1443
1444
                if (pass != 2)
1445
                {
1446
                    float f4 = (f1 * 30.0F + f2 * 59.0F + f3 * 11.0F) / 100.0F;
1447
                    float f5 = (f1 * 30.0F + f2 * 70.0F) / 100.0F;
1448
                    float f6 = (f1 * 30.0F + f3 * 70.0F) / 100.0F;
1449
                    f1 = f4;
1450
                    f2 = f5;
1451
                    f3 = f6;
1452
                }
1453
1454
                float f10 = 4.8828125E-4F;
1455
                double d2 = (double)((float)this.cloudTickCounter + partialTicks);
1456
                double d0 = this.mc.getRenderViewEntity().prevPosX + (this.mc.getRenderViewEntity().posX - this.mc.getRenderViewEntity().prevPosX) * (double)partialTicks + d2 * 0.029999999329447746D;
1457
                double d1 = this.mc.getRenderViewEntity().prevPosZ + (this.mc.getRenderViewEntity().posZ - this.mc.getRenderViewEntity().prevPosZ) * (double)partialTicks;
1458
                int k = MathHelper.floor_double(d0 / 2048.0D);
1459
                int l = MathHelper.floor_double(d1 / 2048.0D);
1460
                d0 = d0 - (double)(k * 2048);
1461
                d1 = d1 - (double)(l * 2048);
1462
                float f7 = this.theWorld.provider.getCloudHeight() - f + 0.33F;
1463
                float f8 = (float)(d0 * 4.8828125E-4D);
1464
                float f9 = (float)(d1 * 4.8828125E-4D);
1465
                worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
1466
1467
                for (int i1 = -256; i1 < 256; i1 += 32)
1468
                {
1469
                    for (int j1 = -256; j1 < 256; j1 += 32)
1470
                    {
1471
                        worldrenderer.pos((double)(i1 + 0), (double)f7, (double)(j1 + 32)).tex((double)((float)(i1 + 0) * 4.8828125E-4F + f8), (double)((float)(j1 + 32) * 4.8828125E-4F + f9)).color(f1, f2, f3, 0.8F).endVertex();
1472
                        worldrenderer.pos((double)(i1 + 32), (double)f7, (double)(j1 + 32)).tex((double)((float)(i1 + 32) * 4.8828125E-4F + f8), (double)((float)(j1 + 32) * 4.8828125E-4F + f9)).color(f1, f2, f3, 0.8F).endVertex();
1473
                        worldrenderer.pos((double)(i1 + 32), (double)f7, (double)(j1 + 0)).tex((double)((float)(i1 + 32) * 4.8828125E-4F + f8), (double)((float)(j1 + 0) * 4.8828125E-4F + f9)).color(f1, f2, f3, 0.8F).endVertex();
1474
                        worldrenderer.pos((double)(i1 + 0), (double)f7, (double)(j1 + 0)).tex((double)((float)(i1 + 0) * 4.8828125E-4F + f8), (double)((float)(j1 + 0) * 4.8828125E-4F + f9)).color(f1, f2, f3, 0.8F).endVertex();
1475
                    }
1476
                }
1477
1478
                tessellator.draw();
1479
                GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
1480
                GlStateManager.disableBlend();
1481
                GlStateManager.enableCull();
1482
            }
1483
        }
1484
    }
1485
1486
    /**
1487
     * Checks if the given position is to be rendered with cloud fog
1488
     */
1489
    public boolean hasCloudFog(double x, double y, double z, float partialTicks)
1490
    {
1491
        return false;
1492
    }
1493
1494
    private void renderCloudsFancy(float partialTicks, int pass)
1495
    {
1496
        GlStateManager.disableCull();
1497
        float f = (float)(this.mc.getRenderViewEntity().lastTickPosY + (this.mc.getRenderViewEntity().posY - this.mc.getRenderViewEntity().lastTickPosY) * (double)partialTicks);
1498
        Tessellator tessellator = Tessellator.getInstance();
1499
        WorldRenderer worldrenderer = tessellator.getWorldRenderer();
1500
        float f1 = 12.0F;
1501
        float f2 = 4.0F;
1502
        double d0 = (double)((float)this.cloudTickCounter + partialTicks);
1503
        double d1 = (this.mc.getRenderViewEntity().prevPosX + (this.mc.getRenderViewEntity().posX - this.mc.getRenderViewEntity().prevPosX) * (double)partialTicks + d0 * 0.029999999329447746D) / 12.0D;
1504
        double d2 = (this.mc.getRenderViewEntity().prevPosZ + (this.mc.getRenderViewEntity().posZ - this.mc.getRenderViewEntity().prevPosZ) * (double)partialTicks) / 12.0D + 0.33000001311302185D;
1505
        float f3 = this.theWorld.provider.getCloudHeight() - f + 0.33F;
1506
        int i = MathHelper.floor_double(d1 / 2048.0D);
1507
        int j = MathHelper.floor_double(d2 / 2048.0D);
1508
        d1 = d1 - (double)(i * 2048);
1509
        d2 = d2 - (double)(j * 2048);
1510
        this.renderEngine.bindTexture(locationCloudsPng);
1511
        GlStateManager.enableBlend();
1512
        GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
1513
        Vec3 vec3 = this.theWorld.getCloudColour(partialTicks);
1514
        float f4 = (float)vec3.xCoord;
1515
        float f5 = (float)vec3.yCoord;
1516
        float f6 = (float)vec3.zCoord;
1517
1518
        if (pass != 2)
1519
        {
1520
            float f7 = (f4 * 30.0F + f5 * 59.0F + f6 * 11.0F) / 100.0F;
1521
            float f8 = (f4 * 30.0F + f5 * 70.0F) / 100.0F;
1522
            float f9 = (f4 * 30.0F + f6 * 70.0F) / 100.0F;
1523
            f4 = f7;
1524
            f5 = f8;
1525
            f6 = f9;
1526
        }
1527
1528
        float f26 = f4 * 0.9F;
1529
        float f27 = f5 * 0.9F;
1530
        float f28 = f6 * 0.9F;
1531
        float f10 = f4 * 0.7F;
1532
        float f11 = f5 * 0.7F;
1533
        float f12 = f6 * 0.7F;
1534
        float f13 = f4 * 0.8F;
1535
        float f14 = f5 * 0.8F;
1536
        float f15 = f6 * 0.8F;
1537
        float f16 = 0.00390625F;
1538
        float f17 = (float)MathHelper.floor_double(d1) * 0.00390625F;
1539
        float f18 = (float)MathHelper.floor_double(d2) * 0.00390625F;
1540
        float f19 = (float)(d1 - (double)MathHelper.floor_double(d1));
1541
        float f20 = (float)(d2 - (double)MathHelper.floor_double(d2));
1542
        int k = 8;
1543
        int l = 4;
1544
        float f21 = 9.765625E-4F;
1545
        GlStateManager.scale(12.0F, 1.0F, 12.0F);
1546
1547
        for (int i1 = 0; i1 < 2; ++i1)
1548
        {
1549
            if (i1 == 0)
1550
            {
1551
                GlStateManager.colorMask(false, false, false, false);
1552
            }
1553
            else
1554
            {
1555
                switch (pass)
1556
                {
1557
                    case 0:
1558
                        GlStateManager.colorMask(false, true, true, true);
1559
                        break;
1560
1561
                    case 1:
1562
                        GlStateManager.colorMask(true, false, false, true);
1563
                        break;
1564
1565
                    case 2:
1566
                        GlStateManager.colorMask(true, true, true, true);
1567
                }
1568
            }
1569
1570
            for (int j1 = -3; j1 <= 4; ++j1)
1571
            {
1572
                for (int k1 = -3; k1 <= 4; ++k1)
1573
                {
1574
                    worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR_NORMAL);
1575
                    float f22 = (float)(j1 * 8);
1576
                    float f23 = (float)(k1 * 8);
1577
                    float f24 = f22 - f19;
1578
                    float f25 = f23 - f20;
1579
1580
                    if (f3 > -5.0F)
1581
                    {
1582
                        worldrenderer.pos((double)(f24 + 0.0F), (double)(f3 + 0.0F), (double)(f25 + 8.0F)).tex((double)((f22 + 0.0F) * 0.00390625F + f17), (double)((f23 + 8.0F) * 0.00390625F + f18)).color(f10, f11, f12, 0.8F).normal(0.0F, -1.0F, 0.0F).endVertex();
1583
                        worldrenderer.pos((double)(f24 + 8.0F), (double)(f3 + 0.0F), (double)(f25 + 8.0F)).tex((double)((f22 + 8.0F) * 0.00390625F + f17), (double)((f23 + 8.0F) * 0.00390625F + f18)).color(f10, f11, f12, 0.8F).normal(0.0F, -1.0F, 0.0F).endVertex();
1584
                        worldrenderer.pos((double)(f24 + 8.0F), (double)(f3 + 0.0F), (double)(f25 + 0.0F)).tex((double)((f22 + 8.0F) * 0.00390625F + f17), (double)((f23 + 0.0F) * 0.00390625F + f18)).color(f10, f11, f12, 0.8F).normal(0.0F, -1.0F, 0.0F).endVertex();
1585
                        worldrenderer.pos((double)(f24 + 0.0F), (double)(f3 + 0.0F), (double)(f25 + 0.0F)).tex((double)((f22 + 0.0F) * 0.00390625F + f17), (double)((f23 + 0.0F) * 0.00390625F + f18)).color(f10, f11, f12, 0.8F).normal(0.0F, -1.0F, 0.0F).endVertex();
1586
                    }
1587
1588
                    if (f3 <= 5.0F)
1589
                    {
1590
                        worldrenderer.pos((double)(f24 + 0.0F), (double)(f3 + 4.0F - 9.765625E-4F), (double)(f25 + 8.0F)).tex((double)((f22 + 0.0F) * 0.00390625F + f17), (double)((f23 + 8.0F) * 0.00390625F + f18)).color(f4, f5, f6, 0.8F).normal(0.0F, 1.0F, 0.0F).endVertex();
1591
                        worldrenderer.pos((double)(f24 + 8.0F), (double)(f3 + 4.0F - 9.765625E-4F), (double)(f25 + 8.0F)).tex((double)((f22 + 8.0F) * 0.00390625F + f17), (double)((f23 + 8.0F) * 0.00390625F + f18)).color(f4, f5, f6, 0.8F).normal(0.0F, 1.0F, 0.0F).endVertex();
1592
                        worldrenderer.pos((double)(f24 + 8.0F), (double)(f3 + 4.0F - 9.765625E-4F), (double)(f25 + 0.0F)).tex((double)((f22 + 8.0F) * 0.00390625F + f17), (double)((f23 + 0.0F) * 0.00390625F + f18)).color(f4, f5, f6, 0.8F).normal(0.0F, 1.0F, 0.0F).endVertex();
1593
                        worldrenderer.pos((double)(f24 + 0.0F), (double)(f3 + 4.0F - 9.765625E-4F), (double)(f25 + 0.0F)).tex((double)((f22 + 0.0F) * 0.00390625F + f17), (double)((f23 + 0.0F) * 0.00390625F + f18)).color(f4, f5, f6, 0.8F).normal(0.0F, 1.0F, 0.0F).endVertex();
1594
                    }
1595
1596
                    if (j1 > -1)
1597
                    {
1598
                        for (int l1 = 0; l1 < 8; ++l1)
1599
                        {
1600
                            worldrenderer.pos((double)(f24 + (float)l1 + 0.0F), (double)(f3 + 0.0F), (double)(f25 + 8.0F)).tex((double)((f22 + (float)l1 + 0.5F) * 0.00390625F + f17), (double)((f23 + 8.0F) * 0.00390625F + f18)).color(f26, f27, f28, 0.8F).normal(-1.0F, 0.0F, 0.0F).endVertex();
1601
                            worldrenderer.pos((double)(f24 + (float)l1 + 0.0F), (double)(f3 + 4.0F), (double)(f25 + 8.0F)).tex((double)((f22 + (float)l1 + 0.5F) * 0.00390625F + f17), (double)((f23 + 8.0F) * 0.00390625F + f18)).color(f26, f27, f28, 0.8F).normal(-1.0F, 0.0F, 0.0F).endVertex();
1602
                            worldrenderer.pos((double)(f24 + (float)l1 + 0.0F), (double)(f3 + 4.0F), (double)(f25 + 0.0F)).tex((double)((f22 + (float)l1 + 0.5F) * 0.00390625F + f17), (double)((f23 + 0.0F) * 0.00390625F + f18)).color(f26, f27, f28, 0.8F).normal(-1.0F, 0.0F, 0.0F).endVertex();
1603
                            worldrenderer.pos((double)(f24 + (float)l1 + 0.0F), (double)(f3 + 0.0F), (double)(f25 + 0.0F)).tex((double)((f22 + (float)l1 + 0.5F) * 0.00390625F + f17), (double)((f23 + 0.0F) * 0.00390625F + f18)).color(f26, f27, f28, 0.8F).normal(-1.0F, 0.0F, 0.0F).endVertex();
1604
                        }
1605
                    }
1606
1607
                    if (j1 <= 1)
1608
                    {
1609
                        for (int i2 = 0; i2 < 8; ++i2)
1610
                        {
1611
                            worldrenderer.pos((double)(f24 + (float)i2 + 1.0F - 9.765625E-4F), (double)(f3 + 0.0F), (double)(f25 + 8.0F)).tex((double)((f22 + (float)i2 + 0.5F) * 0.00390625F + f17), (double)((f23 + 8.0F) * 0.00390625F + f18)).color(f26, f27, f28, 0.8F).normal(1.0F, 0.0F, 0.0F).endVertex();
1612
                            worldrenderer.pos((double)(f24 + (float)i2 + 1.0F - 9.765625E-4F), (double)(f3 + 4.0F), (double)(f25 + 8.0F)).tex((double)((f22 + (float)i2 + 0.5F) * 0.00390625F + f17), (double)((f23 + 8.0F) * 0.00390625F + f18)).color(f26, f27, f28, 0.8F).normal(1.0F, 0.0F, 0.0F).endVertex();
1613
                            worldrenderer.pos((double)(f24 + (float)i2 + 1.0F - 9.765625E-4F), (double)(f3 + 4.0F), (double)(f25 + 0.0F)).tex((double)((f22 + (float)i2 + 0.5F) * 0.00390625F + f17), (double)((f23 + 0.0F) * 0.00390625F + f18)).color(f26, f27, f28, 0.8F).normal(1.0F, 0.0F, 0.0F).endVertex();
1614
                            worldrenderer.pos((double)(f24 + (float)i2 + 1.0F - 9.765625E-4F), (double)(f3 + 0.0F), (double)(f25 + 0.0F)).tex((double)((f22 + (float)i2 + 0.5F) * 0.00390625F + f17), (double)((f23 + 0.0F) * 0.00390625F + f18)).color(f26, f27, f28, 0.8F).normal(1.0F, 0.0F, 0.0F).endVertex();
1615
                        }
1616
                    }
1617
1618
                    if (k1 > -1)
1619
                    {
1620
                        for (int j2 = 0; j2 < 8; ++j2)
1621
                        {
1622
                            worldrenderer.pos((double)(f24 + 0.0F), (double)(f3 + 4.0F), (double)(f25 + (float)j2 + 0.0F)).tex((double)((f22 + 0.0F) * 0.00390625F + f17), (double)((f23 + (float)j2 + 0.5F) * 0.00390625F + f18)).color(f13, f14, f15, 0.8F).normal(0.0F, 0.0F, -1.0F).endVertex();
1623
                            worldrenderer.pos((double)(f24 + 8.0F), (double)(f3 + 4.0F), (double)(f25 + (float)j2 + 0.0F)).tex((double)((f22 + 8.0F) * 0.00390625F + f17), (double)((f23 + (float)j2 + 0.5F) * 0.00390625F + f18)).color(f13, f14, f15, 0.8F).normal(0.0F, 0.0F, -1.0F).endVertex();
1624
                            worldrenderer.pos((double)(f24 + 8.0F), (double)(f3 + 0.0F), (double)(f25 + (float)j2 + 0.0F)).tex((double)((f22 + 8.0F) * 0.00390625F + f17), (double)((f23 + (float)j2 + 0.5F) * 0.00390625F + f18)).color(f13, f14, f15, 0.8F).normal(0.0F, 0.0F, -1.0F).endVertex();
1625
                            worldrenderer.pos((double)(f24 + 0.0F), (double)(f3 + 0.0F), (double)(f25 + (float)j2 + 0.0F)).tex((double)((f22 + 0.0F) * 0.00390625F + f17), (double)((f23 + (float)j2 + 0.5F) * 0.00390625F + f18)).color(f13, f14, f15, 0.8F).normal(0.0F, 0.0F, -1.0F).endVertex();
1626
                        }
1627
                    }
1628
1629
                    if (k1 <= 1)
1630
                    {
1631
                        for (int k2 = 0; k2 < 8; ++k2)
1632
                        {
1633
                            worldrenderer.pos((double)(f24 + 0.0F), (double)(f3 + 4.0F), (double)(f25 + (float)k2 + 1.0F - 9.765625E-4F)).tex((double)((f22 + 0.0F) * 0.00390625F + f17), (double)((f23 + (float)k2 + 0.5F) * 0.00390625F + f18)).color(f13, f14, f15, 0.8F).normal(0.0F, 0.0F, 1.0F).endVertex();
1634
                            worldrenderer.pos((double)(f24 + 8.0F), (double)(f3 + 4.0F), (double)(f25 + (float)k2 + 1.0F - 9.765625E-4F)).tex((double)((f22 + 8.0F) * 0.00390625F + f17), (double)((f23 + (float)k2 + 0.5F) * 0.00390625F + f18)).color(f13, f14, f15, 0.8F).normal(0.0F, 0.0F, 1.0F).endVertex();
1635
                            worldrenderer.pos((double)(f24 + 8.0F), (double)(f3 + 0.0F), (double)(f25 + (float)k2 + 1.0F - 9.765625E-4F)).tex((double)((f22 + 8.0F) * 0.00390625F + f17), (double)((f23 + (float)k2 + 0.5F) * 0.00390625F + f18)).color(f13, f14, f15, 0.8F).normal(0.0F, 0.0F, 1.0F).endVertex();
1636
                            worldrenderer.pos((double)(f24 + 0.0F), (double)(f3 + 0.0F), (double)(f25 + (float)k2 + 1.0F - 9.765625E-4F)).tex((double)((f22 + 0.0F) * 0.00390625F + f17), (double)((f23 + (float)k2 + 0.5F) * 0.00390625F + f18)).color(f13, f14, f15, 0.8F).normal(0.0F, 0.0F, 1.0F).endVertex();
1637
                        }
1638
                    }
1639
1640
                    tessellator.draw();
1641
                }
1642
            }
1643
        }
1644
1645
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
1646
        GlStateManager.disableBlend();
1647
        GlStateManager.enableCull();
1648
    }
1649
1650
    public void updateChunks(long finishTimeNano)
1651
    {
1652
        this.displayListEntitiesDirty |= this.renderDispatcher.runChunkUploads(finishTimeNano);
1653
1654
        if (!this.chunksToUpdate.isEmpty())
1655
        {
1656
            Iterator<RenderChunk> iterator = this.chunksToUpdate.iterator();
1657
1658
            while (iterator.hasNext())
1659
            {
1660
                RenderChunk renderchunk = (RenderChunk)iterator.next();
1661
1662
                if (!this.renderDispatcher.updateChunkLater(renderchunk))
1663
                {
1664
                    break;
1665
                }
1666
1667
                renderchunk.setNeedsUpdate(false);
1668
                iterator.remove();
1669
                long i = finishTimeNano - System.nanoTime();
1670
1671
                if (i < 0L)
1672
                {
1673
                    break;
1674
                }
1675
            }
1676
        }
1677
    }
1678
1679
    public void renderWorldBorder(Entity entityIn, float partialTicks)
1680
    {
1681
        Tessellator tessellator = Tessellator.getInstance();
1682
        WorldRenderer worldrenderer = tessellator.getWorldRenderer();
1683
        WorldBorder worldborder = this.theWorld.getWorldBorder();
1684
        double d0 = (double)(this.mc.gameSettings.renderDistanceChunks * 16);
1685
1686
        if (entityIn.posX >= worldborder.maxX() - d0 || entityIn.posX <= worldborder.minX() + d0 || entityIn.posZ >= worldborder.maxZ() - d0 || entityIn.posZ <= worldborder.minZ() + d0)
1687
        {
1688
            double d1 = 1.0D - worldborder.getClosestDistance(entityIn) / d0;
1689
            d1 = Math.pow(d1, 4.0D);
1690
            double d2 = entityIn.lastTickPosX + (entityIn.posX - entityIn.lastTickPosX) * (double)partialTicks;
1691
            double d3 = entityIn.lastTickPosY + (entityIn.posY - entityIn.lastTickPosY) * (double)partialTicks;
1692
            double d4 = entityIn.lastTickPosZ + (entityIn.posZ - entityIn.lastTickPosZ) * (double)partialTicks;
1693
            GlStateManager.enableBlend();
1694
            GlStateManager.tryBlendFuncSeparate(770, 1, 1, 0);
1695
            this.renderEngine.bindTexture(locationForcefieldPng);
1696
            GlStateManager.depthMask(false);
1697
            GlStateManager.pushMatrix();
1698
            int i = worldborder.getStatus().getID();
1699
            float f = (float)(i >> 16 & 255) / 255.0F;
1700
            float f1 = (float)(i >> 8 & 255) / 255.0F;
1701
            float f2 = (float)(i & 255) / 255.0F;
1702
            GlStateManager.color(f, f1, f2, (float)d1);
1703
            GlStateManager.doPolygonOffset(-3.0F, -3.0F);
1704
            GlStateManager.enablePolygonOffset();
1705
            GlStateManager.alphaFunc(516, 0.1F);
1706
            GlStateManager.enableAlpha();
1707
            GlStateManager.disableCull();
1708
            float f3 = (float)(Minecraft.getSystemTime() % 3000L) / 3000.0F;
1709
            float f4 = 0.0F;
1710
            float f5 = 0.0F;
1711
            float f6 = 128.0F;
1712
            worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX);
1713
            worldrenderer.setTranslation(-d2, -d3, -d4);
1714
            double d5 = Math.max((double)MathHelper.floor_double(d4 - d0), worldborder.minZ());
1715
            double d6 = Math.min((double)MathHelper.ceiling_double_int(d4 + d0), worldborder.maxZ());
1716
1717
            if (d2 > worldborder.maxX() - d0)
1718
            {
1719
                float f7 = 0.0F;
1720
1721
                for (double d7 = d5; d7 < d6; f7 += 0.5F)
1722
                {
1723
                    double d8 = Math.min(1.0D, d6 - d7);
1724
                    float f8 = (float)d8 * 0.5F;
1725
                    worldrenderer.pos(worldborder.maxX(), 256.0D, d7).tex((double)(f3 + f7), (double)(f3 + 0.0F)).endVertex();
1726
                    worldrenderer.pos(worldborder.maxX(), 256.0D, d7 + d8).tex((double)(f3 + f8 + f7), (double)(f3 + 0.0F)).endVertex();
1727
                    worldrenderer.pos(worldborder.maxX(), 0.0D, d7 + d8).tex((double)(f3 + f8 + f7), (double)(f3 + 128.0F)).endVertex();
1728
                    worldrenderer.pos(worldborder.maxX(), 0.0D, d7).tex((double)(f3 + f7), (double)(f3 + 128.0F)).endVertex();
1729
                    ++d7;
1730
                }
1731
            }
1732
1733
            if (d2 < worldborder.minX() + d0)
1734
            {
1735
                float f9 = 0.0F;
1736
1737
                for (double d9 = d5; d9 < d6; f9 += 0.5F)
1738
                {
1739
                    double d12 = Math.min(1.0D, d6 - d9);
1740
                    float f12 = (float)d12 * 0.5F;
1741
                    worldrenderer.pos(worldborder.minX(), 256.0D, d9).tex((double)(f3 + f9), (double)(f3 + 0.0F)).endVertex();
1742
                    worldrenderer.pos(worldborder.minX(), 256.0D, d9 + d12).tex((double)(f3 + f12 + f9), (double)(f3 + 0.0F)).endVertex();
1743
                    worldrenderer.pos(worldborder.minX(), 0.0D, d9 + d12).tex((double)(f3 + f12 + f9), (double)(f3 + 128.0F)).endVertex();
1744
                    worldrenderer.pos(worldborder.minX(), 0.0D, d9).tex((double)(f3 + f9), (double)(f3 + 128.0F)).endVertex();
1745
                    ++d9;
1746
                }
1747
            }
1748
1749
            d5 = Math.max((double)MathHelper.floor_double(d2 - d0), worldborder.minX());
1750
            d6 = Math.min((double)MathHelper.ceiling_double_int(d2 + d0), worldborder.maxX());
1751
1752
            if (d4 > worldborder.maxZ() - d0)
1753
            {
1754
                float f10 = 0.0F;
1755
1756
                for (double d10 = d5; d10 < d6; f10 += 0.5F)
1757
                {
1758
                    double d13 = Math.min(1.0D, d6 - d10);
1759
                    float f13 = (float)d13 * 0.5F;
1760
                    worldrenderer.pos(d10, 256.0D, worldborder.maxZ()).tex((double)(f3 + f10), (double)(f3 + 0.0F)).endVertex();
1761
                    worldrenderer.pos(d10 + d13, 256.0D, worldborder.maxZ()).tex((double)(f3 + f13 + f10), (double)(f3 + 0.0F)).endVertex();
1762
                    worldrenderer.pos(d10 + d13, 0.0D, worldborder.maxZ()).tex((double)(f3 + f13 + f10), (double)(f3 + 128.0F)).endVertex();
1763
                    worldrenderer.pos(d10, 0.0D, worldborder.maxZ()).tex((double)(f3 + f10), (double)(f3 + 128.0F)).endVertex();
1764
                    ++d10;
1765
                }
1766
            }
1767
1768
            if (d4 < worldborder.minZ() + d0)
1769
            {
1770
                float f11 = 0.0F;
1771
1772
                for (double d11 = d5; d11 < d6; f11 += 0.5F)
1773
                {
1774
                    double d14 = Math.min(1.0D, d6 - d11);
1775
                    float f14 = (float)d14 * 0.5F;
1776
                    worldrenderer.pos(d11, 256.0D, worldborder.minZ()).tex((double)(f3 + f11), (double)(f3 + 0.0F)).endVertex();
1777
                    worldrenderer.pos(d11 + d14, 256.0D, worldborder.minZ()).tex((double)(f3 + f14 + f11), (double)(f3 + 0.0F)).endVertex();
1778
                    worldrenderer.pos(d11 + d14, 0.0D, worldborder.minZ()).tex((double)(f3 + f14 + f11), (double)(f3 + 128.0F)).endVertex();
1779
                    worldrenderer.pos(d11, 0.0D, worldborder.minZ()).tex((double)(f3 + f11), (double)(f3 + 128.0F)).endVertex();
1780
                    ++d11;
1781
                }
1782
            }
1783
1784
            tessellator.draw();
1785
            worldrenderer.setTranslation(0.0D, 0.0D, 0.0D);
1786
            GlStateManager.enableCull();
1787
            GlStateManager.disableAlpha();
1788
            GlStateManager.doPolygonOffset(0.0F, 0.0F);
1789
            GlStateManager.disablePolygonOffset();
1790
            GlStateManager.enableAlpha();
1791
            GlStateManager.disableBlend();
1792
            GlStateManager.popMatrix();
1793
            GlStateManager.depthMask(true);
1794
        }
1795
    }
1796
1797
    private void preRenderDamagedBlocks()
1798
    {
1799
        GlStateManager.tryBlendFuncSeparate(774, 768, 1, 0);
1800
        GlStateManager.enableBlend();
1801
        GlStateManager.color(1.0F, 1.0F, 1.0F, 0.5F);
1802
        GlStateManager.doPolygonOffset(-3.0F, -3.0F);
1803
        GlStateManager.enablePolygonOffset();
1804
        GlStateManager.alphaFunc(516, 0.1F);
1805
        GlStateManager.enableAlpha();
1806
        GlStateManager.pushMatrix();
1807
    }
1808
1809
    private void postRenderDamagedBlocks()
1810
    {
1811
        GlStateManager.disableAlpha();
1812
        GlStateManager.doPolygonOffset(0.0F, 0.0F);
1813
        GlStateManager.disablePolygonOffset();
1814
        GlStateManager.enableAlpha();
1815
        GlStateManager.depthMask(true);
1816
        GlStateManager.popMatrix();
1817
    }
1818
1819
    public void drawBlockDamageTexture(Tessellator tessellatorIn, WorldRenderer worldRendererIn, Entity entityIn, float partialTicks)
1820
    {
1821
        double d0 = entityIn.lastTickPosX + (entityIn.posX - entityIn.lastTickPosX) * (double)partialTicks;
1822
        double d1 = entityIn.lastTickPosY + (entityIn.posY - entityIn.lastTickPosY) * (double)partialTicks;
1823
        double d2 = entityIn.lastTickPosZ + (entityIn.posZ - entityIn.lastTickPosZ) * (double)partialTicks;
1824
1825
        if (!this.damagedBlocks.isEmpty())
1826
        {
1827
            this.renderEngine.bindTexture(TextureMap.locationBlocksTexture);
1828
            this.preRenderDamagedBlocks();
1829
            worldRendererIn.begin(7, DefaultVertexFormats.BLOCK);
1830
            worldRendererIn.setTranslation(-d0, -d1, -d2);
1831
            worldRendererIn.noColor();
1832
            Iterator<DestroyBlockProgress> iterator = this.damagedBlocks.values().iterator();
1833
1834
            while (iterator.hasNext())
1835
            {
1836
                DestroyBlockProgress destroyblockprogress = (DestroyBlockProgress)iterator.next();
1837
                BlockPos blockpos = destroyblockprogress.getPosition();
1838
                double d3 = (double)blockpos.getX() - d0;
1839
                double d4 = (double)blockpos.getY() - d1;
1840
                double d5 = (double)blockpos.getZ() - d2;
1841
                Block block = this.theWorld.getBlockState(blockpos).getBlock();
1842
1843
                if (!(block instanceof BlockChest) && !(block instanceof BlockEnderChest) && !(block instanceof BlockSign) && !(block instanceof BlockSkull))
1844
                {
1845
                    if (d3 * d3 + d4 * d4 + d5 * d5 > 1024.0D)
1846
                    {
1847
                        iterator.remove();
1848
                    }
1849
                    else
1850
                    {
1851
                        IBlockState iblockstate = this.theWorld.getBlockState(blockpos);
1852
1853
                        if (iblockstate.getBlock().getMaterial() != Material.air)
1854
                        {
1855
                            int i = destroyblockprogress.getPartialBlockDamage();
1856
                            TextureAtlasSprite textureatlassprite = this.destroyBlockIcons[i];
1857
                            BlockRendererDispatcher blockrendererdispatcher = this.mc.getBlockRendererDispatcher();
1858
                            blockrendererdispatcher.renderBlockDamage(iblockstate, blockpos, textureatlassprite, this.theWorld);
1859
                        }
1860
                    }
1861
                }
1862
            }
1863
1864
            tessellatorIn.draw();
1865
            worldRendererIn.setTranslation(0.0D, 0.0D, 0.0D);
1866
            this.postRenderDamagedBlocks();
1867
        }
1868
    }
1869
1870
    /**
1871
     * Draws the selection box for the player. Args: entityPlayer, rayTraceHit, i, itemStack, partialTickTime
1872
     *  
1873
     * @param execute If equals to 0 the method is executed
1874
     */
1875
    public void drawSelectionBox(EntityPlayer player, MovingObjectPosition movingObjectPositionIn, int execute, float partialTicks)
1876
    {
1877
        if (execute == 0 && movingObjectPositionIn.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
1878
        {
1879
            GlStateManager.enableBlend();
1880
            GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
1881
            GlStateManager.color(0.0F, 0.0F, 0.0F, 0.4F);
1882
            GL11.glLineWidth(2.0F);
1883
            GlStateManager.disableTexture2D();
1884
            GlStateManager.depthMask(false);
1885
            float f = 0.002F;
1886
            BlockPos blockpos = movingObjectPositionIn.getBlockPos();
1887
            Block block = this.theWorld.getBlockState(blockpos).getBlock();
1888
1889
            if (block.getMaterial() != Material.air && this.theWorld.getWorldBorder().contains(blockpos))
1890
            {
1891
                block.setBlockBoundsBasedOnState(this.theWorld, blockpos);
1892
                double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double)partialTicks;
1893
                double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double)partialTicks;
1894
                double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double)partialTicks;
1895
                drawSelectionBoundingBox(block.getSelectedBoundingBox(this.theWorld, blockpos).expand(0.0020000000949949026D, 0.0020000000949949026D, 0.0020000000949949026D).offset(-d0, -d1, -d2));
1896
            }
1897
1898
            GlStateManager.depthMask(true);
1899
            GlStateManager.enableTexture2D();
1900
            GlStateManager.disableBlend();
1901
        }
1902
    }
1903
1904
    public static void drawSelectionBoundingBox(AxisAlignedBB boundingBox)
1905
    {
1906
        Tessellator tessellator = Tessellator.getInstance();
1907
        WorldRenderer worldrenderer = tessellator.getWorldRenderer();
1908
        worldrenderer.begin(3, DefaultVertexFormats.POSITION);
1909
        worldrenderer.pos(boundingBox.minX, boundingBox.minY, boundingBox.minZ).endVertex();
1910
        worldrenderer.pos(boundingBox.maxX, boundingBox.minY, boundingBox.minZ).endVertex();
1911
        worldrenderer.pos(boundingBox.maxX, boundingBox.minY, boundingBox.maxZ).endVertex();
1912
        worldrenderer.pos(boundingBox.minX, boundingBox.minY, boundingBox.maxZ).endVertex();
1913
        worldrenderer.pos(boundingBox.minX, boundingBox.minY, boundingBox.minZ).endVertex();
1914
        tessellator.draw();
1915
        worldrenderer.begin(3, DefaultVertexFormats.POSITION);
1916
        worldrenderer.pos(boundingBox.minX, boundingBox.maxY, boundingBox.minZ).endVertex();
1917
        worldrenderer.pos(boundingBox.maxX, boundingBox.maxY, boundingBox.minZ).endVertex();
1918
        worldrenderer.pos(boundingBox.maxX, boundingBox.maxY, boundingBox.maxZ).endVertex();
1919
        worldrenderer.pos(boundingBox.minX, boundingBox.maxY, boundingBox.maxZ).endVertex();
1920
        worldrenderer.pos(boundingBox.minX, boundingBox.maxY, boundingBox.minZ).endVertex();
1921
        tessellator.draw();
1922
        worldrenderer.begin(1, DefaultVertexFormats.POSITION);
1923
        worldrenderer.pos(boundingBox.minX, boundingBox.minY, boundingBox.minZ).endVertex();
1924
        worldrenderer.pos(boundingBox.minX, boundingBox.maxY, boundingBox.minZ).endVertex();
1925
        worldrenderer.pos(boundingBox.maxX, boundingBox.minY, boundingBox.minZ).endVertex();
1926
        worldrenderer.pos(boundingBox.maxX, boundingBox.maxY, boundingBox.minZ).endVertex();
1927
        worldrenderer.pos(boundingBox.maxX, boundingBox.minY, boundingBox.maxZ).endVertex();
1928
        worldrenderer.pos(boundingBox.maxX, boundingBox.maxY, boundingBox.maxZ).endVertex();
1929
        worldrenderer.pos(boundingBox.minX, boundingBox.minY, boundingBox.maxZ).endVertex();
1930
        worldrenderer.pos(boundingBox.minX, boundingBox.maxY, boundingBox.maxZ).endVertex();
1931
        tessellator.draw();
1932
    }
1933
1934
    public static void drawOutlinedBoundingBox(AxisAlignedBB boundingBox, int red, int green, int blue, int alpha)
1935
    {
1936
        Tessellator tessellator = Tessellator.getInstance();
1937
        WorldRenderer worldrenderer = tessellator.getWorldRenderer();
1938
        worldrenderer.begin(3, DefaultVertexFormats.POSITION_COLOR);
1939
        worldrenderer.pos(boundingBox.minX, boundingBox.minY, boundingBox.minZ).color(red, green, blue, alpha).endVertex();
1940
        worldrenderer.pos(boundingBox.maxX, boundingBox.minY, boundingBox.minZ).color(red, green, blue, alpha).endVertex();
1941
        worldrenderer.pos(boundingBox.maxX, boundingBox.minY, boundingBox.maxZ).color(red, green, blue, alpha).endVertex();
1942
        worldrenderer.pos(boundingBox.minX, boundingBox.minY, boundingBox.maxZ).color(red, green, blue, alpha).endVertex();
1943
        worldrenderer.pos(boundingBox.minX, boundingBox.minY, boundingBox.minZ).color(red, green, blue, alpha).endVertex();
1944
        tessellator.draw();
1945
        worldrenderer.begin(3, DefaultVertexFormats.POSITION_COLOR);
1946
        worldrenderer.pos(boundingBox.minX, boundingBox.maxY, boundingBox.minZ).color(red, green, blue, alpha).endVertex();
1947
        worldrenderer.pos(boundingBox.maxX, boundingBox.maxY, boundingBox.minZ).color(red, green, blue, alpha).endVertex();
1948
        worldrenderer.pos(boundingBox.maxX, boundingBox.maxY, boundingBox.maxZ).color(red, green, blue, alpha).endVertex();
1949
        worldrenderer.pos(boundingBox.minX, boundingBox.maxY, boundingBox.maxZ).color(red, green, blue, alpha).endVertex();
1950
        worldrenderer.pos(boundingBox.minX, boundingBox.maxY, boundingBox.minZ).color(red, green, blue, alpha).endVertex();
1951
        tessellator.draw();
1952
        worldrenderer.begin(1, DefaultVertexFormats.POSITION_COLOR);
1953
        worldrenderer.pos(boundingBox.minX, boundingBox.minY, boundingBox.minZ).color(red, green, blue, alpha).endVertex();
1954
        worldrenderer.pos(boundingBox.minX, boundingBox.maxY, boundingBox.minZ).color(red, green, blue, alpha).endVertex();
1955
        worldrenderer.pos(boundingBox.maxX, boundingBox.minY, boundingBox.minZ).color(red, green, blue, alpha).endVertex();
1956
        worldrenderer.pos(boundingBox.maxX, boundingBox.maxY, boundingBox.minZ).color(red, green, blue, alpha).endVertex();
1957
        worldrenderer.pos(boundingBox.maxX, boundingBox.minY, boundingBox.maxZ).color(red, green, blue, alpha).endVertex();
1958
        worldrenderer.pos(boundingBox.maxX, boundingBox.maxY, boundingBox.maxZ).color(red, green, blue, alpha).endVertex();
1959
        worldrenderer.pos(boundingBox.minX, boundingBox.minY, boundingBox.maxZ).color(red, green, blue, alpha).endVertex();
1960
        worldrenderer.pos(boundingBox.minX, boundingBox.maxY, boundingBox.maxZ).color(red, green, blue, alpha).endVertex();
1961
        tessellator.draw();
1962
    }
1963
1964
    /**
1965
     * Marks the blocks in the given range for update
1966
     */
1967
    private void markBlocksForUpdate(int x1, int y1, int z1, int x2, int y2, int z2)
1968
    {
1969
        this.viewFrustum.markBlocksForUpdate(x1, y1, z1, x2, y2, z2);
1970
    }
1971
1972
    public void markBlockForUpdate(BlockPos pos)
1973
    {
1974
        int i = pos.getX();
1975
        int j = pos.getY();
1976
        int k = pos.getZ();
1977
        this.markBlocksForUpdate(i - 1, j - 1, k - 1, i + 1, j + 1, k + 1);
1978
    }
1979
1980
    public void notifyLightSet(BlockPos pos)
1981
    {
1982
        int i = pos.getX();
1983
        int j = pos.getY();
1984
        int k = pos.getZ();
1985
        this.markBlocksForUpdate(i - 1, j - 1, k - 1, i + 1, j + 1, k + 1);
1986
    }
1987
1988
    /**
1989
     * On the client, re-renders all blocks in this range, inclusive. On the server, does nothing. Args: min x, min y,
1990
     * min z, max x, max y, max z
1991
     */
1992
    public void markBlockRangeForRenderUpdate(int x1, int y1, int z1, int x2, int y2, int z2)
1993
    {
1994
        this.markBlocksForUpdate(x1 - 1, y1 - 1, z1 - 1, x2 + 1, y2 + 1, z2 + 1);
1995
    }
1996
1997
    public void playRecord(String recordName, BlockPos blockPosIn)
1998
    {
1999
        ISound isound = (ISound)this.mapSoundPositions.get(blockPosIn);
2000
2001
        if (isound != null)
2002
        {
2003
            this.mc.getSoundHandler().stopSound(isound);
2004
            this.mapSoundPositions.remove(blockPosIn);
2005
        }
2006
2007
        if (recordName != null)
2008
        {
2009
            ItemRecord itemrecord = ItemRecord.getRecord(recordName);
2010
2011
            if (itemrecord != null)
2012
            {
2013
                this.mc.ingameGUI.setRecordPlayingMessage(itemrecord.getRecordNameLocal());
2014
            }
2015
2016
            PositionedSoundRecord positionedsoundrecord = PositionedSoundRecord.create(new ResourceLocation(recordName), (float)blockPosIn.getX(), (float)blockPosIn.getY(), (float)blockPosIn.getZ());
2017
            this.mapSoundPositions.put(blockPosIn, positionedsoundrecord);
2018
            this.mc.getSoundHandler().playSound(positionedsoundrecord);
2019
        }
2020
    }
2021
2022
    /**
2023
     * Plays the specified sound. Arg: soundName, x, y, z, volume, pitch
2024
     */
2025
    public void playSound(String soundName, double x, double y, double z, float volume, float pitch)
2026
    {
2027
    }
2028
2029
    /**
2030
     * Plays sound to all near players except the player reference given
2031
     */
2032
    public void playSoundToNearExcept(EntityPlayer except, String soundName, double x, double y, double z, float volume, float pitch)
2033
    {
2034
    }
2035
2036
    public void spawnParticle(int particleID, boolean ignoreRange, final double xCoord, final double yCoord, final double zCoord, double xOffset, double yOffset, double zOffset, int... parameters)
2037
    {
2038
        try
2039
        {
2040
            this.spawnEntityFX(particleID, ignoreRange, xCoord, yCoord, zCoord, xOffset, yOffset, zOffset, parameters);
2041
        }
2042
        catch (Throwable throwable)
2043
        {
2044
            CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Exception while adding particle");
2045
            CrashReportCategory crashreportcategory = crashreport.makeCategory("Particle being added");
2046
            crashreportcategory.addCrashSection("ID", Integer.valueOf(particleID));
2047
2048
            if (parameters != null)
2049
            {
2050
                crashreportcategory.addCrashSection("Parameters", parameters);
2051
            }
2052
2053
            crashreportcategory.addCrashSectionCallable("Position", new Callable<String>()
2054
            {
2055
                public String call() throws Exception
2056
                {
2057
                    return CrashReportCategory.getCoordinateInfo(xCoord, yCoord, zCoord);
2058
                }
2059
            });
2060
            throw new ReportedException(crashreport);
2061
        }
2062
    }
2063
2064
    private void spawnParticle(EnumParticleTypes particleIn, double xCoord, double yCoord, double zCoord, double xOffset, double yOffset, double zOffset, int... parameters)
2065
    {
2066
        this.spawnParticle(particleIn.getParticleID(), particleIn.getShouldIgnoreRange(), xCoord, yCoord, zCoord, xOffset, yOffset, zOffset, parameters);
2067
    }
2068
2069
    private EntityFX spawnEntityFX(int particleID, boolean ignoreRange, double xCoord, double yCoord, double zCoord, double xOffset, double yOffset, double zOffset, int... parameters)
2070
    {
2071
        if (this.mc != null && this.mc.getRenderViewEntity() != null && this.mc.effectRenderer != null)
2072
        {
2073
            int i = this.mc.gameSettings.particleSetting;
2074
2075
            if (i == 1 && this.theWorld.rand.nextInt(3) == 0)
2076
            {
2077
                i = 2;
2078
            }
2079
2080
            double d0 = this.mc.getRenderViewEntity().posX - xCoord;
2081
            double d1 = this.mc.getRenderViewEntity().posY - yCoord;
2082
            double d2 = this.mc.getRenderViewEntity().posZ - zCoord;
2083
2084
            if (ignoreRange)
2085
            {
2086
                return this.mc.effectRenderer.spawnEffectParticle(particleID, xCoord, yCoord, zCoord, xOffset, yOffset, zOffset, parameters);
2087
            }
2088
            else
2089
            {
2090
                double d3 = 16.0D;
2091
                return d0 * d0 + d1 * d1 + d2 * d2 > 256.0D ? null : (i > 1 ? null : this.mc.effectRenderer.spawnEffectParticle(particleID, xCoord, yCoord, zCoord, xOffset, yOffset, zOffset, parameters));
2092
            }
2093
        }
2094
        else
2095
        {
2096
            return null;
2097
        }
2098
    }
2099
2100
    /**
2101
     * Called on all IWorldAccesses when an entity is created or loaded. On client worlds, starts downloading any
2102
     * necessary textures. On server worlds, adds the entity to the entity tracker.
2103
     */
2104
    public void onEntityAdded(Entity entityIn)
2105
    {
2106
    }
2107
2108
    /**
2109
     * Called on all IWorldAccesses when an entity is unloaded or destroyed. On client worlds, releases any downloaded
2110
     * textures. On server worlds, removes the entity from the entity tracker.
2111
     */
2112
    public void onEntityRemoved(Entity entityIn)
2113
    {
2114
    }
2115
2116
    /**
2117
     * Deletes all display lists
2118
     */
2119
    public void deleteAllDisplayLists()
2120
    {
2121
    }
2122
2123
    public void broadcastSound(int soundID, BlockPos pos, int data)
2124
    {
2125
        switch (soundID)
2126
        {
2127
            case 1013:
2128
            case 1018:
2129
                if (this.mc.getRenderViewEntity() != null)
2130
                {
2131
                    double d0 = (double)pos.getX() - this.mc.getRenderViewEntity().posX;
2132
                    double d1 = (double)pos.getY() - this.mc.getRenderViewEntity().posY;
2133
                    double d2 = (double)pos.getZ() - this.mc.getRenderViewEntity().posZ;
2134
                    double d3 = Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2);
2135
                    double d4 = this.mc.getRenderViewEntity().posX;
2136
                    double d5 = this.mc.getRenderViewEntity().posY;
2137
                    double d6 = this.mc.getRenderViewEntity().posZ;
2138
2139
                    if (d3 > 0.0D)
2140
                    {
2141
                        d4 += d0 / d3 * 2.0D;
2142
                        d5 += d1 / d3 * 2.0D;
2143
                        d6 += d2 / d3 * 2.0D;
2144
                    }
2145
2146
                    if (soundID == 1013)
2147
                    {
2148
                        this.theWorld.playSound(d4, d5, d6, "mob.wither.spawn", 1.0F, 1.0F, false);
2149
                    }
2150
                    else
2151
                    {
2152
                        this.theWorld.playSound(d4, d5, d6, "mob.enderdragon.end", 5.0F, 1.0F, false);
2153
                    }
2154
                }
2155
2156
            default:
2157
        }
2158
    }
2159
2160
    public void playAuxSFX(EntityPlayer player, int sfxType, BlockPos blockPosIn, int data)
2161
    {
2162
        Random random = this.theWorld.rand;
2163
2164
        switch (sfxType)
2165
        {
2166
            case 1000:
2167
                this.theWorld.playSoundAtPos(blockPosIn, "random.click", 1.0F, 1.0F, false);
2168
                break;
2169
2170
            case 1001:
2171
                this.theWorld.playSoundAtPos(blockPosIn, "random.click", 1.0F, 1.2F, false);
2172
                break;
2173
2174
            case 1002:
2175
                this.theWorld.playSoundAtPos(blockPosIn, "random.bow", 1.0F, 1.2F, false);
2176
                break;
2177
2178
            case 1003:
2179
                this.theWorld.playSoundAtPos(blockPosIn, "random.door_open", 1.0F, this.theWorld.rand.nextFloat() * 0.1F + 0.9F, false);
2180
                break;
2181
2182
            case 1004:
2183
                this.theWorld.playSoundAtPos(blockPosIn, "random.fizz", 0.5F, 2.6F + (random.nextFloat() - random.nextFloat()) * 0.8F, false);
2184
                break;
2185
2186
            case 1005:
2187
                if (Item.getItemById(data) instanceof ItemRecord)
2188
                {
2189
                    this.theWorld.playRecord(blockPosIn, "records." + ((ItemRecord)Item.getItemById(data)).recordName);
2190
                }
2191
                else
2192
                {
2193
                    this.theWorld.playRecord(blockPosIn, (String)null);
2194
                }
2195
2196
                break;
2197
2198
            case 1006:
2199
                this.theWorld.playSoundAtPos(blockPosIn, "random.door_close", 1.0F, this.theWorld.rand.nextFloat() * 0.1F + 0.9F, false);
2200
                break;
2201
2202
            case 1007:
2203
                this.theWorld.playSoundAtPos(blockPosIn, "mob.ghast.charge", 10.0F, (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F, false);
2204
                break;
2205
2206
            case 1008:
2207
                this.theWorld.playSoundAtPos(blockPosIn, "mob.ghast.fireball", 10.0F, (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F, false);
2208
                break;
2209
2210
            case 1009:
2211
                this.theWorld.playSoundAtPos(blockPosIn, "mob.ghast.fireball", 2.0F, (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F, false);
2212
                break;
2213
2214
            case 1010:
2215
                this.theWorld.playSoundAtPos(blockPosIn, "mob.zombie.wood", 2.0F, (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F, false);
2216
                break;
2217
2218
            case 1011:
2219
                this.theWorld.playSoundAtPos(blockPosIn, "mob.zombie.metal", 2.0F, (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F, false);
2220
                break;
2221
2222
            case 1012:
2223
                this.theWorld.playSoundAtPos(blockPosIn, "mob.zombie.woodbreak", 2.0F, (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F, false);
2224
                break;
2225
2226
            case 1014:
2227
                this.theWorld.playSoundAtPos(blockPosIn, "mob.wither.shoot", 2.0F, (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F, false);
2228
                break;
2229
2230
            case 1015:
2231
                this.theWorld.playSoundAtPos(blockPosIn, "mob.bat.takeoff", 0.05F, (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F, false);
2232
                break;
2233
2234
            case 1016:
2235
                this.theWorld.playSoundAtPos(blockPosIn, "mob.zombie.infect", 2.0F, (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F, false);
2236
                break;
2237
2238
            case 1017:
2239
                this.theWorld.playSoundAtPos(blockPosIn, "mob.zombie.unfect", 2.0F, (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F, false);
2240
                break;
2241
2242
            case 1020:
2243
                this.theWorld.playSoundAtPos(blockPosIn, "random.anvil_break", 1.0F, this.theWorld.rand.nextFloat() * 0.1F + 0.9F, false);
2244
                break;
2245
2246
            case 1021:
2247
                this.theWorld.playSoundAtPos(blockPosIn, "random.anvil_use", 1.0F, this.theWorld.rand.nextFloat() * 0.1F + 0.9F, false);
2248
                break;
2249
2250
            case 1022:
2251
                this.theWorld.playSoundAtPos(blockPosIn, "random.anvil_land", 0.3F, this.theWorld.rand.nextFloat() * 0.1F + 0.9F, false);
2252
                break;
2253
2254
            case 2000:
2255
                int l = data % 3 - 1;
2256
                int i = data / 3 % 3 - 1;
2257
                double d15 = (double)blockPosIn.getX() + (double)l * 0.6D + 0.5D;
2258
                double d17 = (double)blockPosIn.getY() + 0.5D;
2259
                double d19 = (double)blockPosIn.getZ() + (double)i * 0.6D + 0.5D;
2260
2261
                for (int k1 = 0; k1 < 10; ++k1)
2262
                {
2263
                    double d20 = random.nextDouble() * 0.2D + 0.01D;
2264
                    double d21 = d15 + (double)l * 0.01D + (random.nextDouble() - 0.5D) * (double)i * 0.5D;
2265
                    double d4 = d17 + (random.nextDouble() - 0.5D) * 0.5D;
2266
                    double d6 = d19 + (double)i * 0.01D + (random.nextDouble() - 0.5D) * (double)l * 0.5D;
2267
                    double d8 = (double)l * d20 + random.nextGaussian() * 0.01D;
2268
                    double d10 = -0.03D + random.nextGaussian() * 0.01D;
2269
                    double d12 = (double)i * d20 + random.nextGaussian() * 0.01D;
2270
                    this.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d21, d4, d6, d8, d10, d12, new int[0]);
2271
                }
2272
2273
                return;
2274
2275
            case 2001:
2276
                Block block = Block.getBlockById(data & 4095);
2277
2278
                if (block.getMaterial() != Material.air)
2279
                {
2280
                    this.mc.getSoundHandler().playSound(new PositionedSoundRecord(new ResourceLocation(block.stepSound.getBreakSound()), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getFrequency() * 0.8F, (float)blockPosIn.getX() + 0.5F, (float)blockPosIn.getY() + 0.5F, (float)blockPosIn.getZ() + 0.5F));
2281
                }
2282
2283
                this.mc.effectRenderer.addBlockDestroyEffects(blockPosIn, block.getStateFromMeta(data >> 12 & 255));
2284
                break;
2285
2286
            case 2002:
2287
                double d13 = (double)blockPosIn.getX();
2288
                double d14 = (double)blockPosIn.getY();
2289
                double d16 = (double)blockPosIn.getZ();
2290
2291
                for (int i1 = 0; i1 < 8; ++i1)
2292
                {
2293
                    this.spawnParticle(EnumParticleTypes.ITEM_CRACK, d13, d14, d16, random.nextGaussian() * 0.15D, random.nextDouble() * 0.2D, random.nextGaussian() * 0.15D, new int[] {Item.getIdFromItem(Items.potionitem), data});
2294
                }
2295
2296
                int j1 = Items.potionitem.getColorFromDamage(data);
2297
                float f = (float)(j1 >> 16 & 255) / 255.0F;
2298
                float f1 = (float)(j1 >> 8 & 255) / 255.0F;
2299
                float f2 = (float)(j1 >> 0 & 255) / 255.0F;
2300
                EnumParticleTypes enumparticletypes = EnumParticleTypes.SPELL;
2301
2302
                if (Items.potionitem.isEffectInstant(data))
2303
                {
2304
                    enumparticletypes = EnumParticleTypes.SPELL_INSTANT;
2305
                }
2306
2307
                for (int l1 = 0; l1 < 100; ++l1)
2308
                {
2309
                    double d22 = random.nextDouble() * 4.0D;
2310
                    double d23 = random.nextDouble() * Math.PI * 2.0D;
2311
                    double d24 = Math.cos(d23) * d22;
2312
                    double d9 = 0.01D + random.nextDouble() * 0.5D;
2313
                    double d11 = Math.sin(d23) * d22;
2314
                    EntityFX entityfx = this.spawnEntityFX(enumparticletypes.getParticleID(), enumparticletypes.getShouldIgnoreRange(), d13 + d24 * 0.1D, d14 + 0.3D, d16 + d11 * 0.1D, d24, d9, d11, new int[0]);
2315
2316
                    if (entityfx != null)
2317
                    {
2318
                        float f3 = 0.75F + random.nextFloat() * 0.25F;
2319
                        entityfx.setRBGColorF(f * f3, f1 * f3, f2 * f3);
2320
                        entityfx.multiplyVelocity((float)d22);
2321
                    }
2322
                }
2323
2324
                this.theWorld.playSoundAtPos(blockPosIn, "game.potion.smash", 1.0F, this.theWorld.rand.nextFloat() * 0.1F + 0.9F, false);
2325
                break;
2326
2327
            case 2003:
2328
                double d0 = (double)blockPosIn.getX() + 0.5D;
2329
                double d1 = (double)blockPosIn.getY();
2330
                double d2 = (double)blockPosIn.getZ() + 0.5D;
2331
2332
                for (int j = 0; j < 8; ++j)
2333
                {
2334
                    this.spawnParticle(EnumParticleTypes.ITEM_CRACK, d0, d1, d2, random.nextGaussian() * 0.15D, random.nextDouble() * 0.2D, random.nextGaussian() * 0.15D, new int[] {Item.getIdFromItem(Items.ender_eye)});
2335
                }
2336
2337
                for (double d18 = 0.0D; d18 < (Math.PI * 2D); d18 += 0.15707963267948966D)
2338
                {
2339
                    this.spawnParticle(EnumParticleTypes.PORTAL, d0 + Math.cos(d18) * 5.0D, d1 - 0.4D, d2 + Math.sin(d18) * 5.0D, Math.cos(d18) * -5.0D, 0.0D, Math.sin(d18) * -5.0D, new int[0]);
2340
                    this.spawnParticle(EnumParticleTypes.PORTAL, d0 + Math.cos(d18) * 5.0D, d1 - 0.4D, d2 + Math.sin(d18) * 5.0D, Math.cos(d18) * -7.0D, 0.0D, Math.sin(d18) * -7.0D, new int[0]);
2341
                }
2342
2343
                return;
2344
2345
            case 2004:
2346
                for (int k = 0; k < 20; ++k)
2347
                {
2348
                    double d3 = (double)blockPosIn.getX() + 0.5D + ((double)this.theWorld.rand.nextFloat() - 0.5D) * 2.0D;
2349
                    double d5 = (double)blockPosIn.getY() + 0.5D + ((double)this.theWorld.rand.nextFloat() - 0.5D) * 2.0D;
2350
                    double d7 = (double)blockPosIn.getZ() + 0.5D + ((double)this.theWorld.rand.nextFloat() - 0.5D) * 2.0D;
2351
                    this.theWorld.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d3, d5, d7, 0.0D, 0.0D, 0.0D, new int[0]);
2352
                    this.theWorld.spawnParticle(EnumParticleTypes.FLAME, d3, d5, d7, 0.0D, 0.0D, 0.0D, new int[0]);
2353
                }
2354
2355
                return;
2356
2357
            case 2005:
2358
                ItemDye.spawnBonemealParticles(this.theWorld, blockPosIn, data);
2359
        }
2360
    }
2361
2362
    public void sendBlockBreakProgress(int breakerId, BlockPos pos, int progress)
2363
    {
2364
        if (progress >= 0 && progress < 10)
2365
        {
2366
            DestroyBlockProgress destroyblockprogress = (DestroyBlockProgress)this.damagedBlocks.get(Integer.valueOf(breakerId));
2367
2368
            if (destroyblockprogress == null || destroyblockprogress.getPosition().getX() != pos.getX() || destroyblockprogress.getPosition().getY() != pos.getY() || destroyblockprogress.getPosition().getZ() != pos.getZ())
2369
            {
2370
                destroyblockprogress = new DestroyBlockProgress(breakerId, pos);
2371
                this.damagedBlocks.put(Integer.valueOf(breakerId), destroyblockprogress);
2372
            }
2373
2374
            destroyblockprogress.setPartialBlockDamage(progress);
2375
            destroyblockprogress.setCloudUpdateTick(this.cloudTickCounter);
2376
        }
2377
        else
2378
        {
2379
            this.damagedBlocks.remove(Integer.valueOf(breakerId));
2380
        }
2381
    }
2382
2383
    public void setDisplayListEntitiesDirty()
2384
    {
2385
        this.displayListEntitiesDirty = true;
2386
    }
2387
2388
    public void updateTileEntities(Collection<TileEntity> tileEntitiesToRemove, Collection<TileEntity> tileEntitiesToAdd)
2389
    {
2390
        synchronized (this.setTileEntities)
2391
        {
2392
            this.setTileEntities.removeAll(tileEntitiesToRemove);
2393
            this.setTileEntities.addAll(tileEntitiesToAdd);
2394
        }
2395
    }
2396
2397
    class ContainerLocalRenderInformation
2398
    {
2399
        final RenderChunk renderChunk;
2400
        final EnumFacing facing;
2401
        final Set<EnumFacing> setFacing;
2402
        final int counter;
2403
2404
        private ContainerLocalRenderInformation(RenderChunk renderChunkIn, EnumFacing facingIn, int counterIn)
2405
        {
2406
            this.setFacing = EnumSet.<EnumFacing>noneOf(EnumFacing.class);
2407
            this.renderChunk = renderChunkIn;
2408
            this.facing = facingIn;
2409
            this.counter = counterIn;
2410
        }
2411
    }
2412
}
2413

Deobfuscated MCP 1.8.9 source of RenderGlobal from Marcelektro/MavenMCP-1.8.9 (net/minecraft/client/renderer/RenderGlobal.java), stored verbatim.