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