001package net.minecraft.client.renderer; 002 003import cpw.mods.fml.relauncher.Side; 004import cpw.mods.fml.relauncher.SideOnly; 005import java.awt.image.BufferedImage; 006import java.nio.FloatBuffer; 007import java.util.List; 008import java.util.Random; 009import net.minecraft.block.Block; 010import net.minecraft.block.material.Material; 011import net.minecraft.client.Minecraft; 012import net.minecraft.client.entity.EntityPlayerSP; 013import net.minecraft.client.gui.ScaledResolution; 014import net.minecraft.client.multiplayer.WorldClient; 015import net.minecraft.client.particle.EffectRenderer; 016import net.minecraft.client.particle.EntityRainFX; 017import net.minecraft.client.particle.EntitySmokeFX; 018import net.minecraft.client.renderer.culling.ClippingHelperImpl; 019import net.minecraft.client.renderer.culling.Frustrum; 020import net.minecraft.crash.CrashReport; 021import net.minecraft.crash.CrashReportCategory; 022import net.minecraft.entity.Entity; 023import net.minecraft.entity.EntityLiving; 024import net.minecraft.entity.boss.BossStatus; 025import net.minecraft.entity.player.EntityPlayer; 026import net.minecraft.potion.Potion; 027import net.minecraft.util.AxisAlignedBB; 028import net.minecraft.util.MathHelper; 029import net.minecraft.util.MouseFilter; 030import net.minecraft.util.MovingObjectPosition; 031import net.minecraft.util.ReportedException; 032import net.minecraft.util.Vec3; 033import net.minecraft.world.biome.BiomeGenBase; 034import org.lwjgl.input.Mouse; 035import org.lwjgl.opengl.Display; 036import org.lwjgl.opengl.GL11; 037import org.lwjgl.opengl.GLContext; 038import org.lwjgl.util.glu.GLU; 039 040import net.minecraftforge.client.ForgeHooksClient; 041import net.minecraftforge.client.event.DrawBlockHighlightEvent; 042import net.minecraftforge.client.event.RenderWorldLastEvent; 043import net.minecraftforge.common.MinecraftForge; 044 045@SideOnly(Side.CLIENT) 046public class EntityRenderer 047{ 048 public static boolean anaglyphEnable = false; 049 050 /** Anaglyph field (0=R, 1=GB) */ 051 public static int anaglyphField; 052 053 /** A reference to the Minecraft object. */ 054 private Minecraft mc; 055 private float farPlaneDistance = 0.0F; 056 public ItemRenderer itemRenderer; 057 058 /** Entity renderer update count */ 059 private int rendererUpdateCount; 060 061 /** Pointed entity */ 062 private Entity pointedEntity = null; 063 private MouseFilter mouseFilterXAxis = new MouseFilter(); 064 private MouseFilter mouseFilterYAxis = new MouseFilter(); 065 066 /** Mouse filter dummy 1 */ 067 private MouseFilter mouseFilterDummy1 = new MouseFilter(); 068 069 /** Mouse filter dummy 2 */ 070 private MouseFilter mouseFilterDummy2 = new MouseFilter(); 071 072 /** Mouse filter dummy 3 */ 073 private MouseFilter mouseFilterDummy3 = new MouseFilter(); 074 075 /** Mouse filter dummy 4 */ 076 private MouseFilter mouseFilterDummy4 = new MouseFilter(); 077 private float thirdPersonDistance = 4.0F; 078 079 /** Third person distance temp */ 080 private float thirdPersonDistanceTemp = 4.0F; 081 private float debugCamYaw = 0.0F; 082 private float prevDebugCamYaw = 0.0F; 083 private float debugCamPitch = 0.0F; 084 private float prevDebugCamPitch = 0.0F; 085 086 /** Smooth cam yaw */ 087 private float smoothCamYaw; 088 089 /** Smooth cam pitch */ 090 private float smoothCamPitch; 091 092 /** Smooth cam filter X */ 093 private float smoothCamFilterX; 094 095 /** Smooth cam filter Y */ 096 private float smoothCamFilterY; 097 098 /** Smooth cam partial ticks */ 099 private float smoothCamPartialTicks; 100 private float debugCamFOV = 0.0F; 101 private float prevDebugCamFOV = 0.0F; 102 private float camRoll = 0.0F; 103 private float prevCamRoll = 0.0F; 104 105 /** 106 * The texture id of the blocklight/skylight texture used for lighting effects 107 */ 108 public int lightmapTexture; 109 110 /** 111 * Colors computed in updateLightmap() and loaded into the lightmap emptyTexture 112 */ 113 private int[] lightmapColors; 114 115 /** FOV modifier hand */ 116 private float fovModifierHand; 117 118 /** FOV modifier hand prev */ 119 private float fovModifierHandPrev; 120 121 /** FOV multiplier temp */ 122 private float fovMultiplierTemp; 123 private float field_82831_U; 124 private float field_82832_V; 125 126 /** Cloud fog mode */ 127 private boolean cloudFog = false; 128 private double cameraZoom = 1.0D; 129 private double cameraYaw = 0.0D; 130 private double cameraPitch = 0.0D; 131 132 /** Previous frame time in milliseconds */ 133 private long prevFrameTime = Minecraft.getSystemTime(); 134 135 /** End time of last render (ns) */ 136 private long renderEndNanoTime = 0L; 137 138 /** 139 * Is set, updateCameraAndRender() calls updateLightmap(); set by updateTorchFlicker() 140 */ 141 private boolean lightmapUpdateNeeded = false; 142 143 /** Torch flicker X */ 144 float torchFlickerX = 0.0F; 145 146 /** Torch flicker DX */ 147 float torchFlickerDX = 0.0F; 148 149 /** Torch flicker Y */ 150 float torchFlickerY = 0.0F; 151 152 /** Torch flicker DY */ 153 float torchFlickerDY = 0.0F; 154 private Random random = new Random(); 155 156 /** Rain sound counter */ 157 private int rainSoundCounter = 0; 158 159 /** Rain X coords */ 160 float[] rainXCoords; 161 162 /** Rain Y coords */ 163 float[] rainYCoords; 164 volatile int field_78523_k = 0; 165 volatile int field_78520_l = 0; 166 167 /** Fog color buffer */ 168 FloatBuffer fogColorBuffer = GLAllocation.createDirectFloatBuffer(16); 169 170 /** red component of the fog color */ 171 float fogColorRed; 172 173 /** green component of the fog color */ 174 float fogColorGreen; 175 176 /** blue component of the fog color */ 177 float fogColorBlue; 178 179 /** Fog color 2 */ 180 private float fogColor2; 181 182 /** Fog color 1 */ 183 private float fogColor1; 184 185 /** 186 * Debug view direction (0=OFF, 1=Front, 2=Right, 3=Back, 4=Left, 5=TiltLeft, 6=TiltRight) 187 */ 188 public int debugViewDirection; 189 190 public EntityRenderer(Minecraft par1Minecraft) 191 { 192 this.mc = par1Minecraft; 193 this.itemRenderer = new ItemRenderer(par1Minecraft); 194 this.lightmapTexture = par1Minecraft.renderEngine.allocateAndSetupTexture(new BufferedImage(16, 16, 1)); 195 this.lightmapColors = new int[256]; 196 } 197 198 /** 199 * Updates the entity renderer 200 */ 201 public void updateRenderer() 202 { 203 this.updateFovModifierHand(); 204 this.updateTorchFlicker(); 205 this.fogColor2 = this.fogColor1; 206 this.thirdPersonDistanceTemp = this.thirdPersonDistance; 207 this.prevDebugCamYaw = this.debugCamYaw; 208 this.prevDebugCamPitch = this.debugCamPitch; 209 this.prevDebugCamFOV = this.debugCamFOV; 210 this.prevCamRoll = this.camRoll; 211 float var1; 212 float var2; 213 214 if (this.mc.gameSettings.smoothCamera) 215 { 216 var1 = this.mc.gameSettings.mouseSensitivity * 0.6F + 0.2F; 217 var2 = var1 * var1 * var1 * 8.0F; 218 this.smoothCamFilterX = this.mouseFilterXAxis.smooth(this.smoothCamYaw, 0.05F * var2); 219 this.smoothCamFilterY = this.mouseFilterYAxis.smooth(this.smoothCamPitch, 0.05F * var2); 220 this.smoothCamPartialTicks = 0.0F; 221 this.smoothCamYaw = 0.0F; 222 this.smoothCamPitch = 0.0F; 223 } 224 225 if (this.mc.renderViewEntity == null) 226 { 227 this.mc.renderViewEntity = this.mc.thePlayer; 228 } 229 230 var1 = this.mc.theWorld.getLightBrightness(MathHelper.floor_double(this.mc.renderViewEntity.posX), MathHelper.floor_double(this.mc.renderViewEntity.posY), MathHelper.floor_double(this.mc.renderViewEntity.posZ)); 231 var2 = (float)(3 - this.mc.gameSettings.renderDistance) / 3.0F; 232 float var3 = var1 * (1.0F - var2) + var2; 233 this.fogColor1 += (var3 - this.fogColor1) * 0.1F; 234 ++this.rendererUpdateCount; 235 this.itemRenderer.updateEquippedItem(); 236 this.addRainParticles(); 237 this.field_82832_V = this.field_82831_U; 238 239 if (BossStatus.field_82825_d) 240 { 241 this.field_82831_U += 0.05F; 242 243 if (this.field_82831_U > 1.0F) 244 { 245 this.field_82831_U = 1.0F; 246 } 247 248 BossStatus.field_82825_d = false; 249 } 250 else if (this.field_82831_U > 0.0F) 251 { 252 this.field_82831_U -= 0.0125F; 253 } 254 } 255 256 /** 257 * Finds what block or object the mouse is over at the specified partial tick time. Args: partialTickTime 258 */ 259 public void getMouseOver(float par1) 260 { 261 if (this.mc.renderViewEntity != null) 262 { 263 if (this.mc.theWorld != null) 264 { 265 double var2 = (double)this.mc.playerController.getBlockReachDistance(); 266 this.mc.objectMouseOver = this.mc.renderViewEntity.rayTrace(var2, par1); 267 double var4 = var2; 268 Vec3 var6 = this.mc.renderViewEntity.getPosition(par1); 269 270 if (this.mc.playerController.extendedReach()) 271 { 272 var2 = 6.0D; 273 var4 = 6.0D; 274 } 275 else 276 { 277 if (var2 > 3.0D) 278 { 279 var4 = 3.0D; 280 } 281 282 var2 = var4; 283 } 284 285 if (this.mc.objectMouseOver != null) 286 { 287 var4 = this.mc.objectMouseOver.hitVec.distanceTo(var6); 288 } 289 290 Vec3 var7 = this.mc.renderViewEntity.getLook(par1); 291 Vec3 var8 = var6.addVector(var7.xCoord * var2, var7.yCoord * var2, var7.zCoord * var2); 292 this.pointedEntity = null; 293 float var9 = 1.0F; 294 List var10 = this.mc.theWorld.getEntitiesWithinAABBExcludingEntity(this.mc.renderViewEntity, this.mc.renderViewEntity.boundingBox.addCoord(var7.xCoord * var2, var7.yCoord * var2, var7.zCoord * var2).expand((double)var9, (double)var9, (double)var9)); 295 double var11 = var4; 296 297 for (int var13 = 0; var13 < var10.size(); ++var13) 298 { 299 Entity var14 = (Entity)var10.get(var13); 300 301 if (var14.canBeCollidedWith()) 302 { 303 float var15 = var14.getCollisionBorderSize(); 304 AxisAlignedBB var16 = var14.boundingBox.expand((double)var15, (double)var15, (double)var15); 305 MovingObjectPosition var17 = var16.calculateIntercept(var6, var8); 306 307 if (var16.isVecInside(var6)) 308 { 309 if (0.0D < var11 || var11 == 0.0D) 310 { 311 this.pointedEntity = var14; 312 var11 = 0.0D; 313 } 314 } 315 else if (var17 != null) 316 { 317 double var18 = var6.distanceTo(var17.hitVec); 318 319 if (var18 < var11 || var11 == 0.0D) 320 { 321 this.pointedEntity = var14; 322 var11 = var18; 323 } 324 } 325 } 326 } 327 328 if (this.pointedEntity != null && (var11 < var4 || this.mc.objectMouseOver == null)) 329 { 330 this.mc.objectMouseOver = new MovingObjectPosition(this.pointedEntity); 331 } 332 } 333 } 334 } 335 336 /** 337 * Update FOV modifier hand 338 */ 339 private void updateFovModifierHand() 340 { 341 if (mc.renderViewEntity instanceof EntityPlayerSP) 342 { 343 EntityPlayerSP var1 = (EntityPlayerSP)this.mc.renderViewEntity; 344 this.fovMultiplierTemp = var1.getFOVMultiplier(); 345 } 346 else 347 { 348 this.fovMultiplierTemp = mc.thePlayer.getFOVMultiplier(); 349 } 350 this.fovModifierHandPrev = this.fovModifierHand; 351 this.fovModifierHand += (this.fovMultiplierTemp - this.fovModifierHand) * 0.5F; 352 } 353 354 /** 355 * Changes the field of view of the player depending on if they are underwater or not 356 */ 357 private float getFOVModifier(float par1, boolean par2) 358 { 359 if (this.debugViewDirection > 0) 360 { 361 return 90.0F; 362 } 363 else 364 { 365 EntityLiving var3 = (EntityLiving)this.mc.renderViewEntity; 366 float var4 = 70.0F; 367 368 if (par2) 369 { 370 var4 += this.mc.gameSettings.fovSetting * 40.0F; 371 var4 *= this.fovModifierHandPrev + (this.fovModifierHand - this.fovModifierHandPrev) * par1; 372 } 373 374 if (var3.getHealth() <= 0) 375 { 376 float var5 = (float)var3.deathTime + par1; 377 var4 /= (1.0F - 500.0F / (var5 + 500.0F)) * 2.0F + 1.0F; 378 } 379 380 int var6 = ActiveRenderInfo.getBlockIdAtEntityViewpoint(this.mc.theWorld, var3, par1); 381 382 if (var6 != 0 && Block.blocksList[var6].blockMaterial == Material.water) 383 { 384 var4 = var4 * 60.0F / 70.0F; 385 } 386 387 return var4 + this.prevDebugCamFOV + (this.debugCamFOV - this.prevDebugCamFOV) * par1; 388 } 389 } 390 391 private void hurtCameraEffect(float par1) 392 { 393 EntityLiving var2 = this.mc.renderViewEntity; 394 float var3 = (float)var2.hurtTime - par1; 395 float var4; 396 397 if (var2.getHealth() <= 0) 398 { 399 var4 = (float)var2.deathTime + par1; 400 GL11.glRotatef(40.0F - 8000.0F / (var4 + 200.0F), 0.0F, 0.0F, 1.0F); 401 } 402 403 if (var3 >= 0.0F) 404 { 405 var3 /= (float)var2.maxHurtTime; 406 var3 = MathHelper.sin(var3 * var3 * var3 * var3 * (float)Math.PI); 407 var4 = var2.attackedAtYaw; 408 GL11.glRotatef(-var4, 0.0F, 1.0F, 0.0F); 409 GL11.glRotatef(-var3 * 14.0F, 0.0F, 0.0F, 1.0F); 410 GL11.glRotatef(var4, 0.0F, 1.0F, 0.0F); 411 } 412 } 413 414 /** 415 * Setups all the GL settings for view bobbing. Args: partialTickTime 416 */ 417 private void setupViewBobbing(float par1) 418 { 419 if (this.mc.renderViewEntity instanceof EntityPlayer) 420 { 421 EntityPlayer var2 = (EntityPlayer)this.mc.renderViewEntity; 422 float var3 = var2.distanceWalkedModified - var2.prevDistanceWalkedModified; 423 float var4 = -(var2.distanceWalkedModified + var3 * par1); 424 float var5 = var2.prevCameraYaw + (var2.cameraYaw - var2.prevCameraYaw) * par1; 425 float var6 = var2.prevCameraPitch + (var2.cameraPitch - var2.prevCameraPitch) * par1; 426 GL11.glTranslatef(MathHelper.sin(var4 * (float)Math.PI) * var5 * 0.5F, -Math.abs(MathHelper.cos(var4 * (float)Math.PI) * var5), 0.0F); 427 GL11.glRotatef(MathHelper.sin(var4 * (float)Math.PI) * var5 * 3.0F, 0.0F, 0.0F, 1.0F); 428 GL11.glRotatef(Math.abs(MathHelper.cos(var4 * (float)Math.PI - 0.2F) * var5) * 5.0F, 1.0F, 0.0F, 0.0F); 429 GL11.glRotatef(var6, 1.0F, 0.0F, 0.0F); 430 } 431 } 432 433 /** 434 * sets up player's eye (or camera in third person mode) 435 */ 436 private void orientCamera(float par1) 437 { 438 EntityLiving var2 = this.mc.renderViewEntity; 439 float var3 = var2.yOffset - 1.62F; 440 double var4 = var2.prevPosX + (var2.posX - var2.prevPosX) * (double)par1; 441 double var6 = var2.prevPosY + (var2.posY - var2.prevPosY) * (double)par1 - (double)var3; 442 double var8 = var2.prevPosZ + (var2.posZ - var2.prevPosZ) * (double)par1; 443 GL11.glRotatef(this.prevCamRoll + (this.camRoll - this.prevCamRoll) * par1, 0.0F, 0.0F, 1.0F); 444 445 if (var2.isPlayerSleeping()) 446 { 447 var3 = (float)((double)var3 + 1.0D); 448 GL11.glTranslatef(0.0F, 0.3F, 0.0F); 449 450 if (!this.mc.gameSettings.debugCamEnable) 451 { 452 ForgeHooksClient.orientBedCamera(mc, var2); 453 GL11.glRotatef(var2.prevRotationYaw + (var2.rotationYaw - var2.prevRotationYaw) * par1 + 180.0F, 0.0F, -1.0F, 0.0F); 454 GL11.glRotatef(var2.prevRotationPitch + (var2.rotationPitch - var2.prevRotationPitch) * par1, -1.0F, 0.0F, 0.0F); 455 } 456 } 457 else if (this.mc.gameSettings.thirdPersonView > 0) 458 { 459 double var27 = (double)(this.thirdPersonDistanceTemp + (this.thirdPersonDistance - this.thirdPersonDistanceTemp) * par1); 460 float var13; 461 float var28; 462 463 if (this.mc.gameSettings.debugCamEnable) 464 { 465 var28 = this.prevDebugCamYaw + (this.debugCamYaw - this.prevDebugCamYaw) * par1; 466 var13 = this.prevDebugCamPitch + (this.debugCamPitch - this.prevDebugCamPitch) * par1; 467 GL11.glTranslatef(0.0F, 0.0F, (float)(-var27)); 468 GL11.glRotatef(var13, 1.0F, 0.0F, 0.0F); 469 GL11.glRotatef(var28, 0.0F, 1.0F, 0.0F); 470 } 471 else 472 { 473 var28 = var2.rotationYaw; 474 var13 = var2.rotationPitch; 475 476 if (this.mc.gameSettings.thirdPersonView == 2) 477 { 478 var13 += 180.0F; 479 } 480 481 double var14 = (double)(-MathHelper.sin(var28 / 180.0F * (float)Math.PI) * MathHelper.cos(var13 / 180.0F * (float)Math.PI)) * var27; 482 double var16 = (double)(MathHelper.cos(var28 / 180.0F * (float)Math.PI) * MathHelper.cos(var13 / 180.0F * (float)Math.PI)) * var27; 483 double var18 = (double)(-MathHelper.sin(var13 / 180.0F * (float)Math.PI)) * var27; 484 485 for (int var20 = 0; var20 < 8; ++var20) 486 { 487 float var21 = (float)((var20 & 1) * 2 - 1); 488 float var22 = (float)((var20 >> 1 & 1) * 2 - 1); 489 float var23 = (float)((var20 >> 2 & 1) * 2 - 1); 490 var21 *= 0.1F; 491 var22 *= 0.1F; 492 var23 *= 0.1F; 493 MovingObjectPosition var24 = this.mc.theWorld.rayTraceBlocks(this.mc.theWorld.getWorldVec3Pool().getVecFromPool(var4 + (double)var21, var6 + (double)var22, var8 + (double)var23), this.mc.theWorld.getWorldVec3Pool().getVecFromPool(var4 - var14 + (double)var21 + (double)var23, var6 - var18 + (double)var22, var8 - var16 + (double)var23)); 494 495 if (var24 != null) 496 { 497 double var25 = var24.hitVec.distanceTo(this.mc.theWorld.getWorldVec3Pool().getVecFromPool(var4, var6, var8)); 498 499 if (var25 < var27) 500 { 501 var27 = var25; 502 } 503 } 504 } 505 506 if (this.mc.gameSettings.thirdPersonView == 2) 507 { 508 GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); 509 } 510 511 GL11.glRotatef(var2.rotationPitch - var13, 1.0F, 0.0F, 0.0F); 512 GL11.glRotatef(var2.rotationYaw - var28, 0.0F, 1.0F, 0.0F); 513 GL11.glTranslatef(0.0F, 0.0F, (float)(-var27)); 514 GL11.glRotatef(var28 - var2.rotationYaw, 0.0F, 1.0F, 0.0F); 515 GL11.glRotatef(var13 - var2.rotationPitch, 1.0F, 0.0F, 0.0F); 516 } 517 } 518 else 519 { 520 GL11.glTranslatef(0.0F, 0.0F, -0.1F); 521 } 522 523 if (!this.mc.gameSettings.debugCamEnable) 524 { 525 GL11.glRotatef(var2.prevRotationPitch + (var2.rotationPitch - var2.prevRotationPitch) * par1, 1.0F, 0.0F, 0.0F); 526 GL11.glRotatef(var2.prevRotationYaw + (var2.rotationYaw - var2.prevRotationYaw) * par1 + 180.0F, 0.0F, 1.0F, 0.0F); 527 } 528 529 GL11.glTranslatef(0.0F, var3, 0.0F); 530 var4 = var2.prevPosX + (var2.posX - var2.prevPosX) * (double)par1; 531 var6 = var2.prevPosY + (var2.posY - var2.prevPosY) * (double)par1 - (double)var3; 532 var8 = var2.prevPosZ + (var2.posZ - var2.prevPosZ) * (double)par1; 533 this.cloudFog = this.mc.renderGlobal.hasCloudFog(var4, var6, var8, par1); 534 } 535 536 /** 537 * sets up projection, view effects, camera position/rotation 538 */ 539 private void setupCameraTransform(float par1, int par2) 540 { 541 this.farPlaneDistance = (float)(256 >> this.mc.gameSettings.renderDistance); 542 GL11.glMatrixMode(GL11.GL_PROJECTION); 543 GL11.glLoadIdentity(); 544 float var3 = 0.07F; 545 546 if (this.mc.gameSettings.anaglyph) 547 { 548 GL11.glTranslatef((float)(-(par2 * 2 - 1)) * var3, 0.0F, 0.0F); 549 } 550 551 if (this.cameraZoom != 1.0D) 552 { 553 GL11.glTranslatef((float)this.cameraYaw, (float)(-this.cameraPitch), 0.0F); 554 GL11.glScaled(this.cameraZoom, this.cameraZoom, 1.0D); 555 } 556 557 GLU.gluPerspective(this.getFOVModifier(par1, true), (float)this.mc.displayWidth / (float)this.mc.displayHeight, 0.05F, this.farPlaneDistance * 2.0F); 558 float var4; 559 560 if (this.mc.playerController.func_78747_a()) 561 { 562 var4 = 0.6666667F; 563 GL11.glScalef(1.0F, var4, 1.0F); 564 } 565 566 GL11.glMatrixMode(GL11.GL_MODELVIEW); 567 GL11.glLoadIdentity(); 568 569 if (this.mc.gameSettings.anaglyph) 570 { 571 GL11.glTranslatef((float)(par2 * 2 - 1) * 0.1F, 0.0F, 0.0F); 572 } 573 574 this.hurtCameraEffect(par1); 575 576 if (this.mc.gameSettings.viewBobbing) 577 { 578 this.setupViewBobbing(par1); 579 } 580 581 var4 = this.mc.thePlayer.prevTimeInPortal + (this.mc.thePlayer.timeInPortal - this.mc.thePlayer.prevTimeInPortal) * par1; 582 583 if (var4 > 0.0F) 584 { 585 byte var5 = 20; 586 587 if (this.mc.thePlayer.isPotionActive(Potion.confusion)) 588 { 589 var5 = 7; 590 } 591 592 float var6 = 5.0F / (var4 * var4 + 5.0F) - var4 * 0.04F; 593 var6 *= var6; 594 GL11.glRotatef(((float)this.rendererUpdateCount + par1) * (float)var5, 0.0F, 1.0F, 1.0F); 595 GL11.glScalef(1.0F / var6, 1.0F, 1.0F); 596 GL11.glRotatef(-((float)this.rendererUpdateCount + par1) * (float)var5, 0.0F, 1.0F, 1.0F); 597 } 598 599 this.orientCamera(par1); 600 601 if (this.debugViewDirection > 0) 602 { 603 int var7 = this.debugViewDirection - 1; 604 605 if (var7 == 1) 606 { 607 GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); 608 } 609 610 if (var7 == 2) 611 { 612 GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); 613 } 614 615 if (var7 == 3) 616 { 617 GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F); 618 } 619 620 if (var7 == 4) 621 { 622 GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F); 623 } 624 625 if (var7 == 5) 626 { 627 GL11.glRotatef(-90.0F, 1.0F, 0.0F, 0.0F); 628 } 629 } 630 } 631 632 /** 633 * Render player hand 634 */ 635 private void renderHand(float par1, int par2) 636 { 637 if (this.debugViewDirection <= 0) 638 { 639 GL11.glMatrixMode(GL11.GL_PROJECTION); 640 GL11.glLoadIdentity(); 641 float var3 = 0.07F; 642 643 if (this.mc.gameSettings.anaglyph) 644 { 645 GL11.glTranslatef((float)(-(par2 * 2 - 1)) * var3, 0.0F, 0.0F); 646 } 647 648 if (this.cameraZoom != 1.0D) 649 { 650 GL11.glTranslatef((float)this.cameraYaw, (float)(-this.cameraPitch), 0.0F); 651 GL11.glScaled(this.cameraZoom, this.cameraZoom, 1.0D); 652 } 653 654 GLU.gluPerspective(this.getFOVModifier(par1, false), (float)this.mc.displayWidth / (float)this.mc.displayHeight, 0.05F, this.farPlaneDistance * 2.0F); 655 656 if (this.mc.playerController.func_78747_a()) 657 { 658 float var4 = 0.6666667F; 659 GL11.glScalef(1.0F, var4, 1.0F); 660 } 661 662 GL11.glMatrixMode(GL11.GL_MODELVIEW); 663 GL11.glLoadIdentity(); 664 665 if (this.mc.gameSettings.anaglyph) 666 { 667 GL11.glTranslatef((float)(par2 * 2 - 1) * 0.1F, 0.0F, 0.0F); 668 } 669 670 GL11.glPushMatrix(); 671 this.hurtCameraEffect(par1); 672 673 if (this.mc.gameSettings.viewBobbing) 674 { 675 this.setupViewBobbing(par1); 676 } 677 678 if (this.mc.gameSettings.thirdPersonView == 0 && !this.mc.renderViewEntity.isPlayerSleeping() && !this.mc.gameSettings.hideGUI && !this.mc.playerController.func_78747_a()) 679 { 680 this.enableLightmap((double)par1); 681 this.itemRenderer.renderItemInFirstPerson(par1); 682 this.disableLightmap((double)par1); 683 } 684 685 GL11.glPopMatrix(); 686 687 if (this.mc.gameSettings.thirdPersonView == 0 && !this.mc.renderViewEntity.isPlayerSleeping()) 688 { 689 this.itemRenderer.renderOverlays(par1); 690 this.hurtCameraEffect(par1); 691 } 692 693 if (this.mc.gameSettings.viewBobbing) 694 { 695 this.setupViewBobbing(par1); 696 } 697 } 698 } 699 700 /** 701 * Disable secondary texture unit used by lightmap 702 */ 703 public void disableLightmap(double par1) 704 { 705 OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); 706 GL11.glDisable(GL11.GL_TEXTURE_2D); 707 OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); 708 } 709 710 /** 711 * Enable lightmap in secondary texture unit 712 */ 713 public void enableLightmap(double par1) 714 { 715 OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); 716 GL11.glMatrixMode(GL11.GL_TEXTURE); 717 GL11.glLoadIdentity(); 718 float var3 = 0.00390625F; 719 GL11.glScalef(var3, var3, var3); 720 GL11.glTranslatef(8.0F, 8.0F, 8.0F); 721 GL11.glMatrixMode(GL11.GL_MODELVIEW); 722 this.mc.renderEngine.bindTexture(this.lightmapTexture); 723 GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); 724 GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); 725 GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); 726 GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); 727 GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP); 728 GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP); 729 GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); 730 GL11.glEnable(GL11.GL_TEXTURE_2D); 731 OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); 732 } 733 734 /** 735 * Recompute a random value that is applied to block color in updateLightmap() 736 */ 737 private void updateTorchFlicker() 738 { 739 this.torchFlickerDX = (float)((double)this.torchFlickerDX + (Math.random() - Math.random()) * Math.random() * Math.random()); 740 this.torchFlickerDY = (float)((double)this.torchFlickerDY + (Math.random() - Math.random()) * Math.random() * Math.random()); 741 this.torchFlickerDX = (float)((double)this.torchFlickerDX * 0.9D); 742 this.torchFlickerDY = (float)((double)this.torchFlickerDY * 0.9D); 743 this.torchFlickerX += (this.torchFlickerDX - this.torchFlickerX) * 1.0F; 744 this.torchFlickerY += (this.torchFlickerDY - this.torchFlickerY) * 1.0F; 745 this.lightmapUpdateNeeded = true; 746 } 747 748 private void updateLightmap(float par1) 749 { 750 WorldClient var2 = this.mc.theWorld; 751 752 if (var2 != null) 753 { 754 for (int var3 = 0; var3 < 256; ++var3) 755 { 756 float var4 = var2.getSunBrightness(1.0F) * 0.95F + 0.05F; 757 float var5 = var2.provider.lightBrightnessTable[var3 / 16] * var4; 758 float var6 = var2.provider.lightBrightnessTable[var3 % 16] * (this.torchFlickerX * 0.1F + 1.5F); 759 760 if (var2.lastLightningBolt > 0) 761 { 762 var5 = var2.provider.lightBrightnessTable[var3 / 16]; 763 } 764 765 float var7 = var5 * (var2.getSunBrightness(1.0F) * 0.65F + 0.35F); 766 float var8 = var5 * (var2.getSunBrightness(1.0F) * 0.65F + 0.35F); 767 float var11 = var6 * ((var6 * 0.6F + 0.4F) * 0.6F + 0.4F); 768 float var12 = var6 * (var6 * var6 * 0.6F + 0.4F); 769 float var13 = var7 + var6; 770 float var14 = var8 + var11; 771 float var15 = var5 + var12; 772 var13 = var13 * 0.96F + 0.03F; 773 var14 = var14 * 0.96F + 0.03F; 774 var15 = var15 * 0.96F + 0.03F; 775 float var16; 776 777 if (this.field_82831_U > 0.0F) 778 { 779 var16 = this.field_82832_V + (this.field_82831_U - this.field_82832_V) * par1; 780 var13 = var13 * (1.0F - var16) + var13 * 0.7F * var16; 781 var14 = var14 * (1.0F - var16) + var14 * 0.6F * var16; 782 var15 = var15 * (1.0F - var16) + var15 * 0.6F * var16; 783 } 784 785 if (var2.provider.dimensionId == 1) 786 { 787 var13 = 0.22F + var6 * 0.75F; 788 var14 = 0.28F + var11 * 0.75F; 789 var15 = 0.25F + var12 * 0.75F; 790 } 791 792 float var17; 793 794 if (this.mc.thePlayer.isPotionActive(Potion.nightVision)) 795 { 796 var16 = this.getNightVisionBrightness(this.mc.thePlayer, par1); 797 var17 = 1.0F / var13; 798 799 if (var17 > 1.0F / var14) 800 { 801 var17 = 1.0F / var14; 802 } 803 804 if (var17 > 1.0F / var15) 805 { 806 var17 = 1.0F / var15; 807 } 808 809 var13 = var13 * (1.0F - var16) + var13 * var17 * var16; 810 var14 = var14 * (1.0F - var16) + var14 * var17 * var16; 811 var15 = var15 * (1.0F - var16) + var15 * var17 * var16; 812 } 813 814 if (var13 > 1.0F) 815 { 816 var13 = 1.0F; 817 } 818 819 if (var14 > 1.0F) 820 { 821 var14 = 1.0F; 822 } 823 824 if (var15 > 1.0F) 825 { 826 var15 = 1.0F; 827 } 828 829 var16 = this.mc.gameSettings.gammaSetting; 830 var17 = 1.0F - var13; 831 float var18 = 1.0F - var14; 832 float var19 = 1.0F - var15; 833 var17 = 1.0F - var17 * var17 * var17 * var17; 834 var18 = 1.0F - var18 * var18 * var18 * var18; 835 var19 = 1.0F - var19 * var19 * var19 * var19; 836 var13 = var13 * (1.0F - var16) + var17 * var16; 837 var14 = var14 * (1.0F - var16) + var18 * var16; 838 var15 = var15 * (1.0F - var16) + var19 * var16; 839 var13 = var13 * 0.96F + 0.03F; 840 var14 = var14 * 0.96F + 0.03F; 841 var15 = var15 * 0.96F + 0.03F; 842 843 if (var13 > 1.0F) 844 { 845 var13 = 1.0F; 846 } 847 848 if (var14 > 1.0F) 849 { 850 var14 = 1.0F; 851 } 852 853 if (var15 > 1.0F) 854 { 855 var15 = 1.0F; 856 } 857 858 if (var13 < 0.0F) 859 { 860 var13 = 0.0F; 861 } 862 863 if (var14 < 0.0F) 864 { 865 var14 = 0.0F; 866 } 867 868 if (var15 < 0.0F) 869 { 870 var15 = 0.0F; 871 } 872 873 short var20 = 255; 874 int var21 = (int)(var13 * 255.0F); 875 int var22 = (int)(var14 * 255.0F); 876 int var23 = (int)(var15 * 255.0F); 877 this.lightmapColors[var3] = var20 << 24 | var21 << 16 | var22 << 8 | var23; 878 } 879 880 this.mc.renderEngine.createTextureFromBytes(this.lightmapColors, 16, 16, this.lightmapTexture); 881 } 882 } 883 884 /** 885 * Gets the night vision brightness 886 */ 887 private float getNightVisionBrightness(EntityPlayer par1EntityPlayer, float par2) 888 { 889 int var3 = par1EntityPlayer.getActivePotionEffect(Potion.nightVision).getDuration(); 890 return var3 > 200 ? 1.0F : 0.7F + MathHelper.sin(((float)var3 - par2) * (float)Math.PI * 0.2F) * 0.3F; 891 } 892 893 /** 894 * Will update any inputs that effect the camera angle (mouse) and then render the world and GUI 895 */ 896 public void updateCameraAndRender(float par1) 897 { 898 this.mc.mcProfiler.startSection("lightTex"); 899 900 if (this.lightmapUpdateNeeded) 901 { 902 this.updateLightmap(par1); 903 } 904 905 this.mc.mcProfiler.endSection(); 906 boolean var2 = Display.isActive(); 907 908 if (!var2 && this.mc.gameSettings.pauseOnLostFocus && (!this.mc.gameSettings.touchscreen || !Mouse.isButtonDown(1))) 909 { 910 if (Minecraft.getSystemTime() - this.prevFrameTime > 500L) 911 { 912 this.mc.displayInGameMenu(); 913 } 914 } 915 else 916 { 917 this.prevFrameTime = Minecraft.getSystemTime(); 918 } 919 920 this.mc.mcProfiler.startSection("mouse"); 921 922 if (this.mc.inGameHasFocus && var2) 923 { 924 this.mc.mouseHelper.mouseXYChange(); 925 float var3 = this.mc.gameSettings.mouseSensitivity * 0.6F + 0.2F; 926 float var4 = var3 * var3 * var3 * 8.0F; 927 float var5 = (float)this.mc.mouseHelper.deltaX * var4; 928 float var6 = (float)this.mc.mouseHelper.deltaY * var4; 929 byte var7 = 1; 930 931 if (this.mc.gameSettings.invertMouse) 932 { 933 var7 = -1; 934 } 935 936 if (this.mc.gameSettings.smoothCamera) 937 { 938 this.smoothCamYaw += var5; 939 this.smoothCamPitch += var6; 940 float var8 = par1 - this.smoothCamPartialTicks; 941 this.smoothCamPartialTicks = par1; 942 var5 = this.smoothCamFilterX * var8; 943 var6 = this.smoothCamFilterY * var8; 944 this.mc.thePlayer.setAngles(var5, var6 * (float)var7); 945 } 946 else 947 { 948 this.mc.thePlayer.setAngles(var5, var6 * (float)var7); 949 } 950 } 951 952 this.mc.mcProfiler.endSection(); 953 954 if (!this.mc.skipRenderWorld) 955 { 956 anaglyphEnable = this.mc.gameSettings.anaglyph; 957 ScaledResolution var13 = new ScaledResolution(this.mc.gameSettings, this.mc.displayWidth, this.mc.displayHeight); 958 int var14 = var13.getScaledWidth(); 959 int var15 = var13.getScaledHeight(); 960 int var16 = Mouse.getX() * var14 / this.mc.displayWidth; 961 int var17 = var15 - Mouse.getY() * var15 / this.mc.displayHeight - 1; 962 int var18 = performanceToFps(this.mc.gameSettings.limitFramerate); 963 964 if (this.mc.theWorld != null) 965 { 966 this.mc.mcProfiler.startSection("level"); 967 968 if (this.mc.gameSettings.limitFramerate == 0) 969 { 970 this.renderWorld(par1, 0L); 971 } 972 else 973 { 974 this.renderWorld(par1, this.renderEndNanoTime + (long)(1000000000 / var18)); 975 } 976 977 this.renderEndNanoTime = System.nanoTime(); 978 this.mc.mcProfiler.endStartSection("gui"); 979 980 if (!this.mc.gameSettings.hideGUI || this.mc.currentScreen != null) 981 { 982 this.mc.ingameGUI.renderGameOverlay(par1, this.mc.currentScreen != null, var16, var17); 983 } 984 985 this.mc.mcProfiler.endSection(); 986 } 987 else 988 { 989 GL11.glViewport(0, 0, this.mc.displayWidth, this.mc.displayHeight); 990 GL11.glMatrixMode(GL11.GL_PROJECTION); 991 GL11.glLoadIdentity(); 992 GL11.glMatrixMode(GL11.GL_MODELVIEW); 993 GL11.glLoadIdentity(); 994 this.setupOverlayRendering(); 995 this.renderEndNanoTime = System.nanoTime(); 996 } 997 998 if (this.mc.currentScreen != null) 999 { 1000 GL11.glClear(256); 1001 1002 try 1003 { 1004 this.mc.currentScreen.drawScreen(var16, var17, par1); 1005 } 1006 catch (Throwable var12) 1007 { 1008 CrashReport var10 = CrashReport.makeCrashReport(var12, "Rendering screen"); 1009 CrashReportCategory var11 = var10.makeCategory("Screen render details"); 1010 var11.addCrashSectionCallable("Screen name", new CallableScreenName(this)); 1011 var11.addCrashSectionCallable("Mouse location", new CallableMouseLocation(this, var16, var17)); 1012 var11.addCrashSectionCallable("Screen size", new CallableScreenSize(this, var13)); 1013 throw new ReportedException(var10); 1014 } 1015 1016 if (this.mc.currentScreen != null && this.mc.currentScreen.guiParticles != null) 1017 { 1018 this.mc.currentScreen.guiParticles.draw(par1); 1019 } 1020 } 1021 } 1022 } 1023 1024 public void renderWorld(float par1, long par2) 1025 { 1026 this.mc.mcProfiler.startSection("lightTex"); 1027 1028 if (this.lightmapUpdateNeeded) 1029 { 1030 this.updateLightmap(par1); 1031 } 1032 1033 GL11.glEnable(GL11.GL_CULL_FACE); 1034 GL11.glEnable(GL11.GL_DEPTH_TEST); 1035 1036 if (this.mc.renderViewEntity == null) 1037 { 1038 this.mc.renderViewEntity = this.mc.thePlayer; 1039 } 1040 1041 this.mc.mcProfiler.endStartSection("pick"); 1042 this.getMouseOver(par1); 1043 EntityLiving var4 = this.mc.renderViewEntity; 1044 RenderGlobal var5 = this.mc.renderGlobal; 1045 EffectRenderer var6 = this.mc.effectRenderer; 1046 double var7 = var4.lastTickPosX + (var4.posX - var4.lastTickPosX) * (double)par1; 1047 double var9 = var4.lastTickPosY + (var4.posY - var4.lastTickPosY) * (double)par1; 1048 double var11 = var4.lastTickPosZ + (var4.posZ - var4.lastTickPosZ) * (double)par1; 1049 this.mc.mcProfiler.endStartSection("center"); 1050 1051 for (int var13 = 0; var13 < 2; ++var13) 1052 { 1053 if (this.mc.gameSettings.anaglyph) 1054 { 1055 anaglyphField = var13; 1056 1057 if (anaglyphField == 0) 1058 { 1059 GL11.glColorMask(false, true, true, false); 1060 } 1061 else 1062 { 1063 GL11.glColorMask(true, false, false, false); 1064 } 1065 } 1066 1067 this.mc.mcProfiler.endStartSection("clear"); 1068 GL11.glViewport(0, 0, this.mc.displayWidth, this.mc.displayHeight); 1069 this.updateFogColor(par1); 1070 GL11.glClear(16640); 1071 GL11.glEnable(GL11.GL_CULL_FACE); 1072 this.mc.mcProfiler.endStartSection("camera"); 1073 this.setupCameraTransform(par1, var13); 1074 ActiveRenderInfo.updateRenderInfo(this.mc.thePlayer, this.mc.gameSettings.thirdPersonView == 2); 1075 this.mc.mcProfiler.endStartSection("frustrum"); 1076 ClippingHelperImpl.getInstance(); 1077 1078 if (this.mc.gameSettings.renderDistance < 2) 1079 { 1080 this.setupFog(-1, par1); 1081 this.mc.mcProfiler.endStartSection("sky"); 1082 var5.renderSky(par1); 1083 } 1084 1085 GL11.glEnable(GL11.GL_FOG); 1086 this.setupFog(1, par1); 1087 1088 if (this.mc.gameSettings.ambientOcclusion) 1089 { 1090 GL11.glShadeModel(GL11.GL_SMOOTH); 1091 } 1092 1093 this.mc.mcProfiler.endStartSection("culling"); 1094 Frustrum var14 = new Frustrum(); 1095 var14.setPosition(var7, var9, var11); 1096 this.mc.renderGlobal.clipRenderersByFrustum(var14, par1); 1097 1098 if (var13 == 0) 1099 { 1100 this.mc.mcProfiler.endStartSection("updatechunks"); 1101 1102 while (!this.mc.renderGlobal.updateRenderers(var4, false) && par2 != 0L) 1103 { 1104 long var15 = par2 - System.nanoTime(); 1105 1106 if (var15 < 0L || var15 > 1000000000L) 1107 { 1108 break; 1109 } 1110 } 1111 } 1112 1113 if (var4.posY < 128.0D) 1114 { 1115 this.renderCloudsCheck(var5, par1); 1116 } 1117 1118 this.setupFog(0, par1); 1119 GL11.glEnable(GL11.GL_FOG); 1120 GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.mc.renderEngine.getTexture("/terrain.png")); 1121 RenderHelper.disableStandardItemLighting(); 1122 this.mc.mcProfiler.endStartSection("terrain"); 1123 var5.sortAndRender(var4, 0, (double)par1); 1124 GL11.glShadeModel(GL11.GL_FLAT); 1125 EntityPlayer var17; 1126 1127 if (this.debugViewDirection == 0) 1128 { 1129 RenderHelper.enableStandardItemLighting(); 1130 this.mc.mcProfiler.endStartSection("entities"); 1131 ForgeHooksClient.setRenderPass(0); 1132 var5.renderEntities(var4.getPosition(par1), var14, par1); 1133 ForgeHooksClient.setRenderPass(-1); 1134 this.enableLightmap((double)par1); 1135 this.mc.mcProfiler.endStartSection("litParticles"); 1136 var6.renderLitParticles(var4, par1); 1137 RenderHelper.disableStandardItemLighting(); 1138 this.setupFog(0, par1); 1139 this.mc.mcProfiler.endStartSection("particles"); 1140 var6.renderParticles(var4, par1); 1141 this.disableLightmap((double)par1); 1142 1143 if (this.mc.objectMouseOver != null && var4.isInsideOfMaterial(Material.water) && var4 instanceof EntityPlayer && !this.mc.gameSettings.hideGUI) 1144 { 1145 var17 = (EntityPlayer)var4; 1146 GL11.glDisable(GL11.GL_ALPHA_TEST); 1147 this.mc.mcProfiler.endStartSection("outline"); 1148 if (!ForgeHooksClient.onDrawBlockHighlight(var5, var17, mc.objectMouseOver, 0, var17.inventory.getCurrentItem(), par1)) 1149 { 1150 var5.drawBlockBreaking(var17, this.mc.objectMouseOver, 0, var17.inventory.getCurrentItem(), par1); 1151 var5.drawSelectionBox(var17, this.mc.objectMouseOver, 0, var17.inventory.getCurrentItem(), par1); 1152 } 1153 GL11.glEnable(GL11.GL_ALPHA_TEST); 1154 } 1155 } 1156 1157 GL11.glDisable(GL11.GL_BLEND); 1158 GL11.glEnable(GL11.GL_CULL_FACE); 1159 GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); 1160 GL11.glDepthMask(true); 1161 this.setupFog(0, par1); 1162 GL11.glEnable(GL11.GL_BLEND); 1163 GL11.glDisable(GL11.GL_CULL_FACE); 1164 GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.mc.renderEngine.getTexture("/terrain.png")); 1165 1166 if (this.mc.gameSettings.fancyGraphics) 1167 { 1168 this.mc.mcProfiler.endStartSection("water"); 1169 1170 if (this.mc.gameSettings.ambientOcclusion) 1171 { 1172 GL11.glShadeModel(GL11.GL_SMOOTH); 1173 } 1174 1175 GL11.glColorMask(false, false, false, false); 1176 int var18 = var5.sortAndRender(var4, 1, (double)par1); 1177 1178 if (this.mc.gameSettings.anaglyph) 1179 { 1180 if (anaglyphField == 0) 1181 { 1182 GL11.glColorMask(false, true, true, true); 1183 } 1184 else 1185 { 1186 GL11.glColorMask(true, false, false, true); 1187 } 1188 } 1189 else 1190 { 1191 GL11.glColorMask(true, true, true, true); 1192 } 1193 1194 if (var18 > 0) 1195 { 1196 var5.renderAllRenderLists(1, (double)par1); 1197 } 1198 1199 GL11.glShadeModel(GL11.GL_FLAT); 1200 } 1201 else 1202 { 1203 this.mc.mcProfiler.endStartSection("water"); 1204 var5.sortAndRender(var4, 1, (double)par1); 1205 } 1206 1207 RenderHelper.enableStandardItemLighting(); 1208 this.mc.mcProfiler.endStartSection("entities"); 1209 ForgeHooksClient.setRenderPass(1); 1210 var5.renderEntities(var4.getPosition(par1), var14, par1); 1211 ForgeHooksClient.setRenderPass(-1); 1212 RenderHelper.disableStandardItemLighting(); 1213 1214 GL11.glDepthMask(true); 1215 GL11.glEnable(GL11.GL_CULL_FACE); 1216 GL11.glDisable(GL11.GL_BLEND); 1217 1218 if (this.cameraZoom == 1.0D && var4 instanceof EntityPlayer && !this.mc.gameSettings.hideGUI && this.mc.objectMouseOver != null && !var4.isInsideOfMaterial(Material.water)) 1219 { 1220 var17 = (EntityPlayer)var4; 1221 GL11.glDisable(GL11.GL_ALPHA_TEST); 1222 this.mc.mcProfiler.endStartSection("outline"); 1223 if (!ForgeHooksClient.onDrawBlockHighlight(var5, var17, mc.objectMouseOver, 0, var17.inventory.getCurrentItem(), par1)) 1224 { 1225 var5.drawBlockBreaking(var17, this.mc.objectMouseOver, 0, var17.inventory.getCurrentItem(), par1); 1226 var5.drawSelectionBox(var17, this.mc.objectMouseOver, 0, var17.inventory.getCurrentItem(), par1); 1227 } 1228 GL11.glEnable(GL11.GL_ALPHA_TEST); 1229 } 1230 1231 this.mc.mcProfiler.endStartSection("destroyProgress"); 1232 GL11.glEnable(GL11.GL_BLEND); 1233 GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE); 1234 var5.drawBlockDamageTexture(Tessellator.instance, var4, par1); 1235 GL11.glDisable(GL11.GL_BLEND); 1236 this.mc.mcProfiler.endStartSection("weather"); 1237 this.renderRainSnow(par1); 1238 GL11.glDisable(GL11.GL_FOG); 1239 1240 if (var4.posY >= 128.0D) 1241 { 1242 this.renderCloudsCheck(var5, par1); 1243 } 1244 1245 this.mc.mcProfiler.endStartSection("FRenderLast"); 1246 ForgeHooksClient.dispatchRenderLast(var5, par1); 1247 1248 this.mc.mcProfiler.endStartSection("hand"); 1249 1250 if (this.cameraZoom == 1.0D) 1251 { 1252 GL11.glClear(256); 1253 this.renderHand(par1, var13); 1254 } 1255 1256 if (!this.mc.gameSettings.anaglyph) 1257 { 1258 this.mc.mcProfiler.endSection(); 1259 return; 1260 } 1261 } 1262 1263 GL11.glColorMask(true, true, true, false); 1264 this.mc.mcProfiler.endSection(); 1265 } 1266 1267 /** 1268 * Render clouds if enabled 1269 */ 1270 private void renderCloudsCheck(RenderGlobal par1RenderGlobal, float par2) 1271 { 1272 if (this.mc.gameSettings.shouldRenderClouds()) 1273 { 1274 this.mc.mcProfiler.endStartSection("clouds"); 1275 GL11.glPushMatrix(); 1276 this.setupFog(0, par2); 1277 GL11.glEnable(GL11.GL_FOG); 1278 par1RenderGlobal.renderClouds(par2); 1279 GL11.glDisable(GL11.GL_FOG); 1280 this.setupFog(1, par2); 1281 GL11.glPopMatrix(); 1282 } 1283 } 1284 1285 private void addRainParticles() 1286 { 1287 float var1 = this.mc.theWorld.getRainStrength(1.0F); 1288 1289 if (!this.mc.gameSettings.fancyGraphics) 1290 { 1291 var1 /= 2.0F; 1292 } 1293 1294 if (var1 != 0.0F) 1295 { 1296 this.random.setSeed((long)this.rendererUpdateCount * 312987231L); 1297 EntityLiving var2 = this.mc.renderViewEntity; 1298 WorldClient var3 = this.mc.theWorld; 1299 int var4 = MathHelper.floor_double(var2.posX); 1300 int var5 = MathHelper.floor_double(var2.posY); 1301 int var6 = MathHelper.floor_double(var2.posZ); 1302 byte var7 = 10; 1303 double var8 = 0.0D; 1304 double var10 = 0.0D; 1305 double var12 = 0.0D; 1306 int var14 = 0; 1307 int var15 = (int)(100.0F * var1 * var1); 1308 1309 if (this.mc.gameSettings.particleSetting == 1) 1310 { 1311 var15 >>= 1; 1312 } 1313 else if (this.mc.gameSettings.particleSetting == 2) 1314 { 1315 var15 = 0; 1316 } 1317 1318 for (int var16 = 0; var16 < var15; ++var16) 1319 { 1320 int var17 = var4 + this.random.nextInt(var7) - this.random.nextInt(var7); 1321 int var18 = var6 + this.random.nextInt(var7) - this.random.nextInt(var7); 1322 int var19 = var3.getPrecipitationHeight(var17, var18); 1323 int var20 = var3.getBlockId(var17, var19 - 1, var18); 1324 BiomeGenBase var21 = var3.getBiomeGenForCoords(var17, var18); 1325 1326 if (var19 <= var5 + var7 && var19 >= var5 - var7 && var21.canSpawnLightningBolt() && var21.getFloatTemperature() >= 0.2F) 1327 { 1328 float var22 = this.random.nextFloat(); 1329 float var23 = this.random.nextFloat(); 1330 1331 if (var20 > 0) 1332 { 1333 if (Block.blocksList[var20].blockMaterial == Material.lava) 1334 { 1335 this.mc.effectRenderer.addEffect(new EntitySmokeFX(var3, (double)((float)var17 + var22), (double)((float)var19 + 0.1F) - Block.blocksList[var20].getBlockBoundsMinY(), (double)((float)var18 + var23), 0.0D, 0.0D, 0.0D)); 1336 } 1337 else 1338 { 1339 ++var14; 1340 1341 if (this.random.nextInt(var14) == 0) 1342 { 1343 var8 = (double)((float)var17 + var22); 1344 var10 = (double)((float)var19 + 0.1F) - Block.blocksList[var20].getBlockBoundsMinY(); 1345 var12 = (double)((float)var18 + var23); 1346 } 1347 1348 this.mc.effectRenderer.addEffect(new EntityRainFX(var3, (double)((float)var17 + var22), (double)((float)var19 + 0.1F) - Block.blocksList[var20].getBlockBoundsMinY(), (double)((float)var18 + var23))); 1349 } 1350 } 1351 } 1352 } 1353 1354 if (var14 > 0 && this.random.nextInt(3) < this.rainSoundCounter++) 1355 { 1356 this.rainSoundCounter = 0; 1357 1358 if (var10 > var2.posY + 1.0D && var3.getPrecipitationHeight(MathHelper.floor_double(var2.posX), MathHelper.floor_double(var2.posZ)) > MathHelper.floor_double(var2.posY)) 1359 { 1360 this.mc.theWorld.playSound(var8, var10, var12, "ambient.weather.rain", 0.1F, 0.5F, false); 1361 } 1362 else 1363 { 1364 this.mc.theWorld.playSound(var8, var10, var12, "ambient.weather.rain", 0.2F, 1.0F, false); 1365 } 1366 } 1367 } 1368 } 1369 1370 /** 1371 * Render rain and snow 1372 */ 1373 protected void renderRainSnow(float par1) 1374 { 1375 float var2 = this.mc.theWorld.getRainStrength(par1); 1376 1377 if (var2 > 0.0F) 1378 { 1379 this.enableLightmap((double)par1); 1380 1381 if (this.rainXCoords == null) 1382 { 1383 this.rainXCoords = new float[1024]; 1384 this.rainYCoords = new float[1024]; 1385 1386 for (int var3 = 0; var3 < 32; ++var3) 1387 { 1388 for (int var4 = 0; var4 < 32; ++var4) 1389 { 1390 float var5 = (float)(var4 - 16); 1391 float var6 = (float)(var3 - 16); 1392 float var7 = MathHelper.sqrt_float(var5 * var5 + var6 * var6); 1393 this.rainXCoords[var3 << 5 | var4] = -var6 / var7; 1394 this.rainYCoords[var3 << 5 | var4] = var5 / var7; 1395 } 1396 } 1397 } 1398 1399 EntityLiving var41 = this.mc.renderViewEntity; 1400 WorldClient var42 = this.mc.theWorld; 1401 int var43 = MathHelper.floor_double(var41.posX); 1402 int var44 = MathHelper.floor_double(var41.posY); 1403 int var45 = MathHelper.floor_double(var41.posZ); 1404 Tessellator var8 = Tessellator.instance; 1405 GL11.glDisable(GL11.GL_CULL_FACE); 1406 GL11.glNormal3f(0.0F, 1.0F, 0.0F); 1407 GL11.glEnable(GL11.GL_BLEND); 1408 GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); 1409 GL11.glAlphaFunc(GL11.GL_GREATER, 0.01F); 1410 GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.mc.renderEngine.getTexture("/environment/snow.png")); 1411 double var9 = var41.lastTickPosX + (var41.posX - var41.lastTickPosX) * (double)par1; 1412 double var11 = var41.lastTickPosY + (var41.posY - var41.lastTickPosY) * (double)par1; 1413 double var13 = var41.lastTickPosZ + (var41.posZ - var41.lastTickPosZ) * (double)par1; 1414 int var15 = MathHelper.floor_double(var11); 1415 byte var16 = 5; 1416 1417 if (this.mc.gameSettings.fancyGraphics) 1418 { 1419 var16 = 10; 1420 } 1421 1422 boolean var17 = false; 1423 byte var18 = -1; 1424 float var19 = (float)this.rendererUpdateCount + par1; 1425 1426 if (this.mc.gameSettings.fancyGraphics) 1427 { 1428 var16 = 10; 1429 } 1430 1431 GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); 1432 var17 = false; 1433 1434 for (int var20 = var45 - var16; var20 <= var45 + var16; ++var20) 1435 { 1436 for (int var21 = var43 - var16; var21 <= var43 + var16; ++var21) 1437 { 1438 int var22 = (var20 - var45 + 16) * 32 + var21 - var43 + 16; 1439 float var23 = this.rainXCoords[var22] * 0.5F; 1440 float var24 = this.rainYCoords[var22] * 0.5F; 1441 BiomeGenBase var25 = var42.getBiomeGenForCoords(var21, var20); 1442 1443 if (var25.canSpawnLightningBolt() || var25.getEnableSnow()) 1444 { 1445 int var26 = var42.getPrecipitationHeight(var21, var20); 1446 int var27 = var44 - var16; 1447 int var28 = var44 + var16; 1448 1449 if (var27 < var26) 1450 { 1451 var27 = var26; 1452 } 1453 1454 if (var28 < var26) 1455 { 1456 var28 = var26; 1457 } 1458 1459 float var29 = 1.0F; 1460 int var30 = var26; 1461 1462 if (var26 < var15) 1463 { 1464 var30 = var15; 1465 } 1466 1467 if (var27 != var28) 1468 { 1469 this.random.setSeed((long)(var21 * var21 * 3121 + var21 * 45238971 ^ var20 * var20 * 418711 + var20 * 13761)); 1470 float var31 = var25.getFloatTemperature(); 1471 double var35; 1472 float var32; 1473 1474 if (var42.getWorldChunkManager().getTemperatureAtHeight(var31, var26) >= 0.15F) 1475 { 1476 if (var18 != 0) 1477 { 1478 if (var18 >= 0) 1479 { 1480 var8.draw(); 1481 } 1482 1483 var18 = 0; 1484 GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.mc.renderEngine.getTexture("/environment/rain.png")); 1485 var8.startDrawingQuads(); 1486 } 1487 1488 var32 = ((float)(this.rendererUpdateCount + var21 * var21 * 3121 + var21 * 45238971 + var20 * var20 * 418711 + var20 * 13761 & 31) + par1) / 32.0F * (3.0F + this.random.nextFloat()); 1489 double var33 = (double)((float)var21 + 0.5F) - var41.posX; 1490 var35 = (double)((float)var20 + 0.5F) - var41.posZ; 1491 float var37 = MathHelper.sqrt_double(var33 * var33 + var35 * var35) / (float)var16; 1492 float var38 = 1.0F; 1493 var8.setBrightness(var42.getLightBrightnessForSkyBlocks(var21, var30, var20, 0)); 1494 var8.setColorRGBA_F(var38, var38, var38, ((1.0F - var37 * var37) * 0.5F + 0.5F) * var2); 1495 var8.setTranslation(-var9 * 1.0D, -var11 * 1.0D, -var13 * 1.0D); 1496 var8.addVertexWithUV((double)((float)var21 - var23) + 0.5D, (double)var27, (double)((float)var20 - var24) + 0.5D, (double)(0.0F * var29), (double)((float)var27 * var29 / 4.0F + var32 * var29)); 1497 var8.addVertexWithUV((double)((float)var21 + var23) + 0.5D, (double)var27, (double)((float)var20 + var24) + 0.5D, (double)(1.0F * var29), (double)((float)var27 * var29 / 4.0F + var32 * var29)); 1498 var8.addVertexWithUV((double)((float)var21 + var23) + 0.5D, (double)var28, (double)((float)var20 + var24) + 0.5D, (double)(1.0F * var29), (double)((float)var28 * var29 / 4.0F + var32 * var29)); 1499 var8.addVertexWithUV((double)((float)var21 - var23) + 0.5D, (double)var28, (double)((float)var20 - var24) + 0.5D, (double)(0.0F * var29), (double)((float)var28 * var29 / 4.0F + var32 * var29)); 1500 var8.setTranslation(0.0D, 0.0D, 0.0D); 1501 } 1502 else 1503 { 1504 if (var18 != 1) 1505 { 1506 if (var18 >= 0) 1507 { 1508 var8.draw(); 1509 } 1510 1511 var18 = 1; 1512 GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.mc.renderEngine.getTexture("/environment/snow.png")); 1513 var8.startDrawingQuads(); 1514 } 1515 1516 var32 = ((float)(this.rendererUpdateCount & 511) + par1) / 512.0F; 1517 float var46 = this.random.nextFloat() + var19 * 0.01F * (float)this.random.nextGaussian(); 1518 float var34 = this.random.nextFloat() + var19 * (float)this.random.nextGaussian() * 0.001F; 1519 var35 = (double)((float)var21 + 0.5F) - var41.posX; 1520 double var47 = (double)((float)var20 + 0.5F) - var41.posZ; 1521 float var39 = MathHelper.sqrt_double(var35 * var35 + var47 * var47) / (float)var16; 1522 float var40 = 1.0F; 1523 var8.setBrightness((var42.getLightBrightnessForSkyBlocks(var21, var30, var20, 0) * 3 + 15728880) / 4); 1524 var8.setColorRGBA_F(var40, var40, var40, ((1.0F - var39 * var39) * 0.3F + 0.5F) * var2); 1525 var8.setTranslation(-var9 * 1.0D, -var11 * 1.0D, -var13 * 1.0D); 1526 var8.addVertexWithUV((double)((float)var21 - var23) + 0.5D, (double)var27, (double)((float)var20 - var24) + 0.5D, (double)(0.0F * var29 + var46), (double)((float)var27 * var29 / 4.0F + var32 * var29 + var34)); 1527 var8.addVertexWithUV((double)((float)var21 + var23) + 0.5D, (double)var27, (double)((float)var20 + var24) + 0.5D, (double)(1.0F * var29 + var46), (double)((float)var27 * var29 / 4.0F + var32 * var29 + var34)); 1528 var8.addVertexWithUV((double)((float)var21 + var23) + 0.5D, (double)var28, (double)((float)var20 + var24) + 0.5D, (double)(1.0F * var29 + var46), (double)((float)var28 * var29 / 4.0F + var32 * var29 + var34)); 1529 var8.addVertexWithUV((double)((float)var21 - var23) + 0.5D, (double)var28, (double)((float)var20 - var24) + 0.5D, (double)(0.0F * var29 + var46), (double)((float)var28 * var29 / 4.0F + var32 * var29 + var34)); 1530 var8.setTranslation(0.0D, 0.0D, 0.0D); 1531 } 1532 } 1533 } 1534 } 1535 } 1536 1537 if (var18 >= 0) 1538 { 1539 var8.draw(); 1540 } 1541 1542 GL11.glEnable(GL11.GL_CULL_FACE); 1543 GL11.glDisable(GL11.GL_BLEND); 1544 GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F); 1545 this.disableLightmap((double)par1); 1546 } 1547 } 1548 1549 /** 1550 * Setup orthogonal projection for rendering GUI screen overlays 1551 */ 1552 public void setupOverlayRendering() 1553 { 1554 ScaledResolution var1 = new ScaledResolution(this.mc.gameSettings, this.mc.displayWidth, this.mc.displayHeight); 1555 GL11.glClear(256); 1556 GL11.glMatrixMode(GL11.GL_PROJECTION); 1557 GL11.glLoadIdentity(); 1558 GL11.glOrtho(0.0D, var1.getScaledWidth_double(), var1.getScaledHeight_double(), 0.0D, 1000.0D, 3000.0D); 1559 GL11.glMatrixMode(GL11.GL_MODELVIEW); 1560 GL11.glLoadIdentity(); 1561 GL11.glTranslatef(0.0F, 0.0F, -2000.0F); 1562 } 1563 1564 /** 1565 * calculates fog and calls glClearColor 1566 */ 1567 private void updateFogColor(float par1) 1568 { 1569 WorldClient var2 = this.mc.theWorld; 1570 EntityLiving var3 = this.mc.renderViewEntity; 1571 float var4 = 1.0F / (float)(4 - this.mc.gameSettings.renderDistance); 1572 var4 = 1.0F - (float)Math.pow((double)var4, 0.25D); 1573 Vec3 var5 = var2.getSkyColor(this.mc.renderViewEntity, par1); 1574 float var6 = (float)var5.xCoord; 1575 float var7 = (float)var5.yCoord; 1576 float var8 = (float)var5.zCoord; 1577 Vec3 var9 = var2.getFogColor(par1); 1578 this.fogColorRed = (float)var9.xCoord; 1579 this.fogColorGreen = (float)var9.yCoord; 1580 this.fogColorBlue = (float)var9.zCoord; 1581 float var11; 1582 1583 if (this.mc.gameSettings.renderDistance < 2) 1584 { 1585 Vec3 var10 = MathHelper.sin(var2.getCelestialAngleRadians(par1)) > 0.0F ? var2.getWorldVec3Pool().getVecFromPool(-1.0D, 0.0D, 0.0D) : var2.getWorldVec3Pool().getVecFromPool(1.0D, 0.0D, 0.0D); 1586 var11 = (float)var3.getLook(par1).dotProduct(var10); 1587 1588 if (var11 < 0.0F) 1589 { 1590 var11 = 0.0F; 1591 } 1592 1593 if (var11 > 0.0F) 1594 { 1595 float[] var12 = var2.provider.calcSunriseSunsetColors(var2.getCelestialAngle(par1), par1); 1596 1597 if (var12 != null) 1598 { 1599 var11 *= var12[3]; 1600 this.fogColorRed = this.fogColorRed * (1.0F - var11) + var12[0] * var11; 1601 this.fogColorGreen = this.fogColorGreen * (1.0F - var11) + var12[1] * var11; 1602 this.fogColorBlue = this.fogColorBlue * (1.0F - var11) + var12[2] * var11; 1603 } 1604 } 1605 } 1606 1607 this.fogColorRed += (var6 - this.fogColorRed) * var4; 1608 this.fogColorGreen += (var7 - this.fogColorGreen) * var4; 1609 this.fogColorBlue += (var8 - this.fogColorBlue) * var4; 1610 float var19 = var2.getRainStrength(par1); 1611 float var20; 1612 1613 if (var19 > 0.0F) 1614 { 1615 var11 = 1.0F - var19 * 0.5F; 1616 var20 = 1.0F - var19 * 0.4F; 1617 this.fogColorRed *= var11; 1618 this.fogColorGreen *= var11; 1619 this.fogColorBlue *= var20; 1620 } 1621 1622 var11 = var2.getWeightedThunderStrength(par1); 1623 1624 if (var11 > 0.0F) 1625 { 1626 var20 = 1.0F - var11 * 0.5F; 1627 this.fogColorRed *= var20; 1628 this.fogColorGreen *= var20; 1629 this.fogColorBlue *= var20; 1630 } 1631 1632 int var21 = ActiveRenderInfo.getBlockIdAtEntityViewpoint(this.mc.theWorld, var3, par1); 1633 1634 if (this.cloudFog) 1635 { 1636 Vec3 var13 = var2.drawClouds(par1); 1637 this.fogColorRed = (float)var13.xCoord; 1638 this.fogColorGreen = (float)var13.yCoord; 1639 this.fogColorBlue = (float)var13.zCoord; 1640 } 1641 else if (var21 != 0 && Block.blocksList[var21].blockMaterial == Material.water) 1642 { 1643 this.fogColorRed = 0.02F; 1644 this.fogColorGreen = 0.02F; 1645 this.fogColorBlue = 0.2F; 1646 } 1647 else if (var21 != 0 && Block.blocksList[var21].blockMaterial == Material.lava) 1648 { 1649 this.fogColorRed = 0.6F; 1650 this.fogColorGreen = 0.1F; 1651 this.fogColorBlue = 0.0F; 1652 } 1653 1654 float var22 = this.fogColor2 + (this.fogColor1 - this.fogColor2) * par1; 1655 this.fogColorRed *= var22; 1656 this.fogColorGreen *= var22; 1657 this.fogColorBlue *= var22; 1658 double var14 = (var3.lastTickPosY + (var3.posY - var3.lastTickPosY) * (double)par1) * var2.provider.getVoidFogYFactor(); 1659 1660 if (var3.isPotionActive(Potion.blindness)) 1661 { 1662 int var16 = var3.getActivePotionEffect(Potion.blindness).getDuration(); 1663 1664 if (var16 < 20) 1665 { 1666 var14 *= (double)(1.0F - (float)var16 / 20.0F); 1667 } 1668 else 1669 { 1670 var14 = 0.0D; 1671 } 1672 } 1673 1674 if (var14 < 1.0D) 1675 { 1676 if (var14 < 0.0D) 1677 { 1678 var14 = 0.0D; 1679 } 1680 1681 var14 *= var14; 1682 this.fogColorRed = (float)((double)this.fogColorRed * var14); 1683 this.fogColorGreen = (float)((double)this.fogColorGreen * var14); 1684 this.fogColorBlue = (float)((double)this.fogColorBlue * var14); 1685 } 1686 1687 float var23; 1688 1689 if (this.field_82831_U > 0.0F) 1690 { 1691 var23 = this.field_82832_V + (this.field_82831_U - this.field_82832_V) * par1; 1692 this.fogColorRed = this.fogColorRed * (1.0F - var23) + this.fogColorRed * 0.7F * var23; 1693 this.fogColorGreen = this.fogColorGreen * (1.0F - var23) + this.fogColorGreen * 0.6F * var23; 1694 this.fogColorBlue = this.fogColorBlue * (1.0F - var23) + this.fogColorBlue * 0.6F * var23; 1695 } 1696 1697 float var17; 1698 1699 if (var3.isPotionActive(Potion.nightVision)) 1700 { 1701 var23 = this.getNightVisionBrightness(this.mc.thePlayer, par1); 1702 var17 = 1.0F / this.fogColorRed; 1703 1704 if (var17 > 1.0F / this.fogColorGreen) 1705 { 1706 var17 = 1.0F / this.fogColorGreen; 1707 } 1708 1709 if (var17 > 1.0F / this.fogColorBlue) 1710 { 1711 var17 = 1.0F / this.fogColorBlue; 1712 } 1713 1714 this.fogColorRed = this.fogColorRed * (1.0F - var23) + this.fogColorRed * var17 * var23; 1715 this.fogColorGreen = this.fogColorGreen * (1.0F - var23) + this.fogColorGreen * var17 * var23; 1716 this.fogColorBlue = this.fogColorBlue * (1.0F - var23) + this.fogColorBlue * var17 * var23; 1717 } 1718 1719 if (this.mc.gameSettings.anaglyph) 1720 { 1721 var23 = (this.fogColorRed * 30.0F + this.fogColorGreen * 59.0F + this.fogColorBlue * 11.0F) / 100.0F; 1722 var17 = (this.fogColorRed * 30.0F + this.fogColorGreen * 70.0F) / 100.0F; 1723 float var18 = (this.fogColorRed * 30.0F + this.fogColorBlue * 70.0F) / 100.0F; 1724 this.fogColorRed = var23; 1725 this.fogColorGreen = var17; 1726 this.fogColorBlue = var18; 1727 } 1728 1729 GL11.glClearColor(this.fogColorRed, this.fogColorGreen, this.fogColorBlue, 0.0F); 1730 } 1731 1732 /** 1733 * Sets up the fog to be rendered. If the arg passed in is -1 the fog starts at 0 and goes to 80% of far plane 1734 * distance and is used for sky rendering. 1735 */ 1736 private void setupFog(int par1, float par2) 1737 { 1738 EntityLiving var3 = this.mc.renderViewEntity; 1739 boolean var4 = false; 1740 1741 if (var3 instanceof EntityPlayer) 1742 { 1743 var4 = ((EntityPlayer)var3).capabilities.isCreativeMode; 1744 } 1745 1746 if (par1 == 999) 1747 { 1748 GL11.glFog(GL11.GL_FOG_COLOR, this.setFogColorBuffer(0.0F, 0.0F, 0.0F, 1.0F)); 1749 GL11.glFogi(GL11.GL_FOG_MODE, GL11.GL_LINEAR); 1750 GL11.glFogf(GL11.GL_FOG_START, 0.0F); 1751 GL11.glFogf(GL11.GL_FOG_END, 8.0F); 1752 1753 if (GLContext.getCapabilities().GL_NV_fog_distance) 1754 { 1755 GL11.glFogi(34138, 34139); 1756 } 1757 1758 GL11.glFogf(GL11.GL_FOG_START, 0.0F); 1759 } 1760 else 1761 { 1762 GL11.glFog(GL11.GL_FOG_COLOR, this.setFogColorBuffer(this.fogColorRed, this.fogColorGreen, this.fogColorBlue, 1.0F)); 1763 GL11.glNormal3f(0.0F, -1.0F, 0.0F); 1764 GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); 1765 int var5 = ActiveRenderInfo.getBlockIdAtEntityViewpoint(this.mc.theWorld, var3, par2); 1766 float var6; 1767 1768 if (var3.isPotionActive(Potion.blindness)) 1769 { 1770 var6 = 5.0F; 1771 int var7 = var3.getActivePotionEffect(Potion.blindness).getDuration(); 1772 1773 if (var7 < 20) 1774 { 1775 var6 = 5.0F + (this.farPlaneDistance - 5.0F) * (1.0F - (float)var7 / 20.0F); 1776 } 1777 1778 GL11.glFogi(GL11.GL_FOG_MODE, GL11.GL_LINEAR); 1779 1780 if (par1 < 0) 1781 { 1782 GL11.glFogf(GL11.GL_FOG_START, 0.0F); 1783 GL11.glFogf(GL11.GL_FOG_END, var6 * 0.8F); 1784 } 1785 else 1786 { 1787 GL11.glFogf(GL11.GL_FOG_START, var6 * 0.25F); 1788 GL11.glFogf(GL11.GL_FOG_END, var6); 1789 } 1790 1791 if (GLContext.getCapabilities().GL_NV_fog_distance) 1792 { 1793 GL11.glFogi(34138, 34139); 1794 } 1795 } 1796 else 1797 { 1798 float var8; 1799 float var9; 1800 float var10; 1801 float var11; 1802 float var12; 1803 1804 if (this.cloudFog) 1805 { 1806 GL11.glFogi(GL11.GL_FOG_MODE, GL11.GL_EXP); 1807 GL11.glFogf(GL11.GL_FOG_DENSITY, 0.1F); 1808 var6 = 1.0F; 1809 var12 = 1.0F; 1810 var8 = 1.0F; 1811 1812 if (this.mc.gameSettings.anaglyph) 1813 { 1814 var9 = (var6 * 30.0F + var12 * 59.0F + var8 * 11.0F) / 100.0F; 1815 var10 = (var6 * 30.0F + var12 * 70.0F) / 100.0F; 1816 var11 = (var6 * 30.0F + var8 * 70.0F) / 100.0F; 1817 } 1818 } 1819 else if (var5 > 0 && Block.blocksList[var5].blockMaterial == Material.water) 1820 { 1821 GL11.glFogi(GL11.GL_FOG_MODE, GL11.GL_EXP); 1822 1823 if (var3.isPotionActive(Potion.waterBreathing)) 1824 { 1825 GL11.glFogf(GL11.GL_FOG_DENSITY, 0.05F); 1826 } 1827 else 1828 { 1829 GL11.glFogf(GL11.GL_FOG_DENSITY, 0.1F); 1830 } 1831 1832 var6 = 0.4F; 1833 var12 = 0.4F; 1834 var8 = 0.9F; 1835 1836 if (this.mc.gameSettings.anaglyph) 1837 { 1838 var9 = (var6 * 30.0F + var12 * 59.0F + var8 * 11.0F) / 100.0F; 1839 var10 = (var6 * 30.0F + var12 * 70.0F) / 100.0F; 1840 var11 = (var6 * 30.0F + var8 * 70.0F) / 100.0F; 1841 } 1842 } 1843 else if (var5 > 0 && Block.blocksList[var5].blockMaterial == Material.lava) 1844 { 1845 GL11.glFogi(GL11.GL_FOG_MODE, GL11.GL_EXP); 1846 GL11.glFogf(GL11.GL_FOG_DENSITY, 2.0F); 1847 var6 = 0.4F; 1848 var12 = 0.3F; 1849 var8 = 0.3F; 1850 1851 if (this.mc.gameSettings.anaglyph) 1852 { 1853 var9 = (var6 * 30.0F + var12 * 59.0F + var8 * 11.0F) / 100.0F; 1854 var10 = (var6 * 30.0F + var12 * 70.0F) / 100.0F; 1855 var11 = (var6 * 30.0F + var8 * 70.0F) / 100.0F; 1856 } 1857 } 1858 else 1859 { 1860 var6 = this.farPlaneDistance; 1861 1862 if (this.mc.theWorld.provider.getWorldHasVoidParticles() && !var4) 1863 { 1864 double var13 = (double)((var3.getBrightnessForRender(par2) & 15728640) >> 20) / 16.0D + (var3.lastTickPosY + (var3.posY - var3.lastTickPosY) * (double)par2 + 4.0D) / 32.0D; 1865 1866 if (var13 < 1.0D) 1867 { 1868 if (var13 < 0.0D) 1869 { 1870 var13 = 0.0D; 1871 } 1872 1873 var13 *= var13; 1874 var9 = 100.0F * (float)var13; 1875 1876 if (var9 < 5.0F) 1877 { 1878 var9 = 5.0F; 1879 } 1880 1881 if (var6 > var9) 1882 { 1883 var6 = var9; 1884 } 1885 } 1886 } 1887 1888 GL11.glFogi(GL11.GL_FOG_MODE, GL11.GL_LINEAR); 1889 1890 if (par1 < 0) 1891 { 1892 GL11.glFogf(GL11.GL_FOG_START, 0.0F); 1893 GL11.glFogf(GL11.GL_FOG_END, var6 * 0.8F); 1894 } 1895 else 1896 { 1897 GL11.glFogf(GL11.GL_FOG_START, var6 * 0.25F); 1898 GL11.glFogf(GL11.GL_FOG_END, var6); 1899 } 1900 1901 if (GLContext.getCapabilities().GL_NV_fog_distance) 1902 { 1903 GL11.glFogi(34138, 34139); 1904 } 1905 1906 if (this.mc.theWorld.provider.doesXZShowFog((int)var3.posX, (int)var3.posZ)) 1907 { 1908 GL11.glFogf(GL11.GL_FOG_START, var6 * 0.05F); 1909 GL11.glFogf(GL11.GL_FOG_END, Math.min(var6, 192.0F) * 0.5F); 1910 } 1911 } 1912 } 1913 1914 GL11.glEnable(GL11.GL_COLOR_MATERIAL); 1915 GL11.glColorMaterial(GL11.GL_FRONT, GL11.GL_AMBIENT); 1916 } 1917 } 1918 1919 /** 1920 * Update and return fogColorBuffer with the RGBA values passed as arguments 1921 */ 1922 private FloatBuffer setFogColorBuffer(float par1, float par2, float par3, float par4) 1923 { 1924 this.fogColorBuffer.clear(); 1925 this.fogColorBuffer.put(par1).put(par2).put(par3).put(par4); 1926 this.fogColorBuffer.flip(); 1927 return this.fogColorBuffer; 1928 } 1929 1930 /** 1931 * Converts performance value (0-2) to FPS (35-200) 1932 */ 1933 public static int performanceToFps(int par0) 1934 { 1935 short var1 = 200; 1936 1937 if (par0 == 1) 1938 { 1939 var1 = 120; 1940 } 1941 1942 if (par0 == 2) 1943 { 1944 var1 = 35; 1945 } 1946 1947 return var1; 1948 } 1949 1950 /** 1951 * Get minecraft reference from the EntityRenderer 1952 */ 1953 static Minecraft getRendererMinecraft(EntityRenderer par0EntityRenderer) 1954 { 1955 return par0EntityRenderer.mc; 1956 } 1957}