| 1 | package net.minecraft.client.renderer;
|
| 2 |
|
| 3 | import com.google.common.base.Predicate;
|
| 4 | import com.google.common.base.Predicates;
|
| 5 | import com.google.gson.JsonSyntaxException;
|
| 6 | import java.io.IOException;
|
| 7 | import java.nio.FloatBuffer;
|
| 8 | import java.util.List;
|
| 9 | import java.util.Random;
|
| 10 | import java.util.concurrent.Callable;
|
| 11 | import net.minecraft.block.Block;
|
| 12 | import net.minecraft.block.BlockBed;
|
| 13 | import net.minecraft.block.material.Material;
|
| 14 | import net.minecraft.block.state.IBlockState;
|
| 15 | import net.minecraft.client.Minecraft;
|
| 16 | import net.minecraft.client.entity.AbstractClientPlayer;
|
| 17 | import net.minecraft.client.gui.MapItemRenderer;
|
| 18 | import net.minecraft.client.gui.ScaledResolution;
|
| 19 | import net.minecraft.client.particle.EffectRenderer;
|
| 20 | import net.minecraft.client.renderer.culling.ClippingHelperImpl;
|
| 21 | import net.minecraft.client.renderer.culling.Frustum;
|
| 22 | import net.minecraft.client.renderer.culling.ICamera;
|
| 23 | import net.minecraft.client.renderer.texture.DynamicTexture;
|
| 24 | import net.minecraft.client.renderer.texture.TextureMap;
|
| 25 | import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
| 26 | import net.minecraft.client.resources.IResourceManager;
|
| 27 | import net.minecraft.client.resources.IResourceManagerReloadListener;
|
| 28 | import net.minecraft.client.shader.ShaderGroup;
|
| 29 | import net.minecraft.client.shader.ShaderLinkHelper;
|
| 30 | import net.minecraft.crash.CrashReport;
|
| 31 | import net.minecraft.crash.CrashReportCategory;
|
| 32 | import net.minecraft.enchantment.EnchantmentHelper;
|
| 33 | import net.minecraft.entity.Entity;
|
| 34 | import net.minecraft.entity.EntityLivingBase;
|
| 35 | import net.minecraft.entity.boss.BossStatus;
|
| 36 | import net.minecraft.entity.item.EntityItemFrame;
|
| 37 | import net.minecraft.entity.monster.EntityCreeper;
|
| 38 | import net.minecraft.entity.monster.EntityEnderman;
|
| 39 | import net.minecraft.entity.monster.EntitySpider;
|
| 40 | import net.minecraft.entity.passive.EntityAnimal;
|
| 41 | import net.minecraft.entity.player.EntityPlayer;
|
| 42 | import net.minecraft.init.Blocks;
|
| 43 | import net.minecraft.inventory.IInventory;
|
| 44 | import net.minecraft.item.ItemStack;
|
| 45 | import net.minecraft.potion.Potion;
|
| 46 | import net.minecraft.util.AxisAlignedBB;
|
| 47 | import net.minecraft.util.BlockPos;
|
| 48 | import net.minecraft.util.EntitySelectors;
|
| 49 | import net.minecraft.util.EnumFacing;
|
| 50 | import net.minecraft.util.EnumParticleTypes;
|
| 51 | import net.minecraft.util.EnumWorldBlockLayer;
|
| 52 | import net.minecraft.util.MathHelper;
|
| 53 | import net.minecraft.util.MouseFilter;
|
| 54 | import net.minecraft.util.MovingObjectPosition;
|
| 55 | import net.minecraft.util.ReportedException;
|
| 56 | import net.minecraft.util.ResourceLocation;
|
| 57 | import net.minecraft.util.Vec3;
|
| 58 | import net.minecraft.world.World;
|
| 59 | import net.minecraft.world.WorldSettings;
|
| 60 | import net.minecraft.world.biome.BiomeGenBase;
|
| 61 | import org.apache.logging.log4j.LogManager;
|
| 62 | import org.apache.logging.log4j.Logger;
|
| 63 | import org.lwjgl.input.Mouse;
|
| 64 | import org.lwjgl.opengl.Display;
|
| 65 | import org.lwjgl.opengl.GL11;
|
| 66 | import org.lwjgl.opengl.GLContext;
|
| 67 | import org.lwjgl.util.glu.Project;
|
| 68 |
|
| 69 | public class EntityRenderer implements IResourceManagerReloadListener
|
| 70 | {
|
| 71 | private static final Logger logger = LogManager.getLogger();
|
| 72 | private static final ResourceLocation locationRainPng = new ResourceLocation("textures/environment/rain.png");
|
| 73 | private static final ResourceLocation locationSnowPng = new ResourceLocation("textures/environment/snow.png");
|
| 74 | public static boolean anaglyphEnable;
|
| 75 |
|
| 76 | /** Anaglyph field (0=R, 1=GB) */
|
| 77 | public static int anaglyphField;
|
| 78 |
|
| 79 | /** A reference to the Minecraft object. */
|
| 80 | private Minecraft mc;
|
| 81 | private final IResourceManager resourceManager;
|
| 82 | private Random random = new Random();
|
| 83 | private float farPlaneDistance;
|
| 84 | public final ItemRenderer itemRenderer;
|
| 85 | private final MapItemRenderer theMapItemRenderer;
|
| 86 |
|
| 87 | /** Entity renderer update count */
|
| 88 | private int rendererUpdateCount;
|
| 89 |
|
| 90 | /** Pointed entity */
|
| 91 | private Entity pointedEntity;
|
| 92 | private MouseFilter mouseFilterXAxis = new MouseFilter();
|
| 93 | private MouseFilter mouseFilterYAxis = new MouseFilter();
|
| 94 | private float thirdPersonDistance = 4.0F;
|
| 95 |
|
| 96 | /** Third person distance temp */
|
| 97 | private float thirdPersonDistanceTemp = 4.0F;
|
| 98 |
|
| 99 | /** Smooth cam yaw */
|
| 100 | private float smoothCamYaw;
|
| 101 |
|
| 102 | /** Smooth cam pitch */
|
| 103 | private float smoothCamPitch;
|
| 104 |
|
| 105 | /** Smooth cam filter X */
|
| 106 | private float smoothCamFilterX;
|
| 107 |
|
| 108 | /** Smooth cam filter Y */
|
| 109 | private float smoothCamFilterY;
|
| 110 |
|
| 111 | /** Smooth cam partial ticks */
|
| 112 | private float smoothCamPartialTicks;
|
| 113 |
|
| 114 | /** FOV modifier hand */
|
| 115 | private float fovModifierHand;
|
| 116 |
|
| 117 | /** FOV modifier hand prev */
|
| 118 | private float fovModifierHandPrev;
|
| 119 | private float bossColorModifier;
|
| 120 | private float bossColorModifierPrev;
|
| 121 |
|
| 122 | /** Cloud fog mode */
|
| 123 | private boolean cloudFog;
|
| 124 | private boolean renderHand = true;
|
| 125 | private boolean drawBlockOutline = true;
|
| 126 |
|
| 127 | /** Previous frame time in milliseconds */
|
| 128 | private long prevFrameTime = Minecraft.getSystemTime();
|
| 129 |
|
| 130 | /** End time of last render (ns) */
|
| 131 | private long renderEndNanoTime;
|
| 132 |
|
| 133 | /**
|
| 134 | * The texture id of the blocklight/skylight texture used for lighting effects
|
| 135 | */
|
| 136 | private final DynamicTexture lightmapTexture;
|
| 137 |
|
| 138 | /**
|
| 139 | * Colors computed in updateLightmap() and loaded into the lightmap emptyTexture
|
| 140 | */
|
| 141 | private final int[] lightmapColors;
|
| 142 | private final ResourceLocation locationLightMap;
|
| 143 |
|
| 144 | /**
|
| 145 | * Is set, updateCameraAndRender() calls updateLightmap(); set by updateTorchFlicker()
|
| 146 | */
|
| 147 | private boolean lightmapUpdateNeeded;
|
| 148 |
|
| 149 | /** Torch flicker X */
|
| 150 | private float torchFlickerX;
|
| 151 | private float torchFlickerDX;
|
| 152 |
|
| 153 | /** Rain sound counter */
|
| 154 | private int rainSoundCounter;
|
| 155 | private float[] rainXCoords = new float[1024];
|
| 156 | private float[] rainYCoords = new float[1024];
|
| 157 |
|
| 158 | /** Fog color buffer */
|
| 159 | private FloatBuffer fogColorBuffer = GLAllocation.createDirectFloatBuffer(16);
|
| 160 | private float fogColorRed;
|
| 161 | private float fogColorGreen;
|
| 162 | private float fogColorBlue;
|
| 163 |
|
| 164 | /** Fog color 2 */
|
| 165 | private float fogColor2;
|
| 166 |
|
| 167 | /** Fog color 1 */
|
| 168 | private float fogColor1;
|
| 169 | private int debugViewDirection = 0;
|
| 170 | private boolean debugView = false;
|
| 171 | private double cameraZoom = 1.0D;
|
| 172 | private double cameraYaw;
|
| 173 | private double cameraPitch;
|
| 174 | private ShaderGroup theShaderGroup;
|
| 175 | private static final ResourceLocation[] shaderResourceLocations = new ResourceLocation[] {new ResourceLocation("shaders/post/notch.json"), new ResourceLocation("shaders/post/fxaa.json"), new ResourceLocation("shaders/post/art.json"), new ResourceLocation("shaders/post/bumpy.json"), new ResourceLocation("shaders/post/blobs2.json"), new ResourceLocation("shaders/post/pencil.json"), new ResourceLocation("shaders/post/color_convolve.json"), new ResourceLocation("shaders/post/deconverge.json"), new ResourceLocation("shaders/post/flip.json"), new ResourceLocation("shaders/post/invert.json"), new ResourceLocation("shaders/post/ntsc.json"), new ResourceLocation("shaders/post/outline.json"), new ResourceLocation("shaders/post/phosphor.json"), new ResourceLocation("shaders/post/scan_pincushion.json"), new ResourceLocation("shaders/post/sobel.json"), new ResourceLocation("shaders/post/bits.json"), new ResourceLocation("shaders/post/desaturate.json"), new ResourceLocation("shaders/post/green.json"), new ResourceLocation("shaders/post/blur.json"), new ResourceLocation("shaders/post/wobble.json"), new ResourceLocation("shaders/post/blobs.json"), new ResourceLocation("shaders/post/antialias.json"), new ResourceLocation("shaders/post/creeper.json"), new ResourceLocation("shaders/post/spider.json")};
|
| 176 | public static final int shaderCount = shaderResourceLocations.length;
|
| 177 | private int shaderIndex;
|
| 178 | private boolean useShader;
|
| 179 | private int frameCount;
|
| 180 |
|
| 181 | public EntityRenderer(Minecraft mcIn, IResourceManager resourceManagerIn)
|
| 182 | {
|
| 183 | this.shaderIndex = shaderCount;
|
| 184 | this.useShader = false;
|
| 185 | this.frameCount = 0;
|
| 186 | this.mc = mcIn;
|
| 187 | this.resourceManager = resourceManagerIn;
|
| 188 | this.itemRenderer = mcIn.getItemRenderer();
|
| 189 | this.theMapItemRenderer = new MapItemRenderer(mcIn.getTextureManager());
|
| 190 | this.lightmapTexture = new DynamicTexture(16, 16);
|
| 191 | this.locationLightMap = mcIn.getTextureManager().getDynamicTextureLocation("lightMap", this.lightmapTexture);
|
| 192 | this.lightmapColors = this.lightmapTexture.getTextureData();
|
| 193 | this.theShaderGroup = null;
|
| 194 |
|
| 195 | for (int i = 0; i < 32; ++i)
|
| 196 | {
|
| 197 | for (int j = 0; j < 32; ++j)
|
| 198 | {
|
| 199 | float f = (float)(j - 16);
|
| 200 | float f1 = (float)(i - 16);
|
| 201 | float f2 = MathHelper.sqrt_float(f * f + f1 * f1);
|
| 202 | this.rainXCoords[i << 5 | j] = -f1 / f2;
|
| 203 | this.rainYCoords[i << 5 | j] = f / f2;
|
| 204 | }
|
| 205 | }
|
| 206 | }
|
| 207 |
|
| 208 | public boolean isShaderActive()
|
| 209 | {
|
| 210 | return OpenGlHelper.shadersSupported && this.theShaderGroup != null;
|
| 211 | }
|
| 212 |
|
| 213 | public void stopUseShader()
|
| 214 | {
|
| 215 | if (this.theShaderGroup != null)
|
| 216 | {
|
| 217 | this.theShaderGroup.deleteShaderGroup();
|
| 218 | }
|
| 219 |
|
| 220 | this.theShaderGroup = null;
|
| 221 | this.shaderIndex = shaderCount;
|
| 222 | }
|
| 223 |
|
| 224 | public void switchUseShader()
|
| 225 | {
|
| 226 | this.useShader = !this.useShader;
|
| 227 | }
|
| 228 |
|
| 229 | /**
|
| 230 | * What shader to use when spectating this entity
|
| 231 | */
|
| 232 | public void loadEntityShader(Entity entityIn)
|
| 233 | {
|
| 234 | if (OpenGlHelper.shadersSupported)
|
| 235 | {
|
| 236 | if (this.theShaderGroup != null)
|
| 237 | {
|
| 238 | this.theShaderGroup.deleteShaderGroup();
|
| 239 | }
|
| 240 |
|
| 241 | this.theShaderGroup = null;
|
| 242 |
|
| 243 | if (entityIn instanceof EntityCreeper)
|
| 244 | {
|
| 245 | this.loadShader(new ResourceLocation("shaders/post/creeper.json"));
|
| 246 | }
|
| 247 | else if (entityIn instanceof EntitySpider)
|
| 248 | {
|
| 249 | this.loadShader(new ResourceLocation("shaders/post/spider.json"));
|
| 250 | }
|
| 251 | else if (entityIn instanceof EntityEnderman)
|
| 252 | {
|
| 253 | this.loadShader(new ResourceLocation("shaders/post/invert.json"));
|
| 254 | }
|
| 255 | }
|
| 256 | }
|
| 257 |
|
| 258 | public void activateNextShader()
|
| 259 | {
|
| 260 | if (OpenGlHelper.shadersSupported)
|
| 261 | {
|
| 262 | if (this.mc.getRenderViewEntity() instanceof EntityPlayer)
|
| 263 | {
|
| 264 | if (this.theShaderGroup != null)
|
| 265 | {
|
| 266 | this.theShaderGroup.deleteShaderGroup();
|
| 267 | }
|
| 268 |
|
| 269 | this.shaderIndex = (this.shaderIndex + 1) % (shaderResourceLocations.length + 1);
|
| 270 |
|
| 271 | if (this.shaderIndex != shaderCount)
|
| 272 | {
|
| 273 | this.loadShader(shaderResourceLocations[this.shaderIndex]);
|
| 274 | }
|
| 275 | else
|
| 276 | {
|
| 277 | this.theShaderGroup = null;
|
| 278 | }
|
| 279 | }
|
| 280 | }
|
| 281 | }
|
| 282 |
|
| 283 | private void loadShader(ResourceLocation resourceLocationIn)
|
| 284 | {
|
| 285 | try
|
| 286 | {
|
| 287 | this.theShaderGroup = new ShaderGroup(this.mc.getTextureManager(), this.resourceManager, this.mc.getFramebuffer(), resourceLocationIn);
|
| 288 | this.theShaderGroup.createBindFramebuffers(this.mc.displayWidth, this.mc.displayHeight);
|
| 289 | this.useShader = true;
|
| 290 | }
|
| 291 | catch (IOException ioexception)
|
| 292 | {
|
| 293 | logger.warn((String)("Failed to load shader: " + resourceLocationIn), (Throwable)ioexception);
|
| 294 | this.shaderIndex = shaderCount;
|
| 295 | this.useShader = false;
|
| 296 | }
|
| 297 | catch (JsonSyntaxException jsonsyntaxexception)
|
| 298 | {
|
| 299 | logger.warn((String)("Failed to load shader: " + resourceLocationIn), (Throwable)jsonsyntaxexception);
|
| 300 | this.shaderIndex = shaderCount;
|
| 301 | this.useShader = false;
|
| 302 | }
|
| 303 | }
|
| 304 |
|
| 305 | public void onResourceManagerReload(IResourceManager resourceManager)
|
| 306 | {
|
| 307 | if (this.theShaderGroup != null)
|
| 308 | {
|
| 309 | this.theShaderGroup.deleteShaderGroup();
|
| 310 | }
|
| 311 |
|
| 312 | this.theShaderGroup = null;
|
| 313 |
|
| 314 | if (this.shaderIndex != shaderCount)
|
| 315 | {
|
| 316 | this.loadShader(shaderResourceLocations[this.shaderIndex]);
|
| 317 | }
|
| 318 | else
|
| 319 | {
|
| 320 | this.loadEntityShader(this.mc.getRenderViewEntity());
|
| 321 | }
|
| 322 | }
|
| 323 |
|
| 324 | /**
|
| 325 | * Updates the entity renderer
|
| 326 | */
|
| 327 | public void updateRenderer()
|
| 328 | {
|
| 329 | if (OpenGlHelper.shadersSupported && ShaderLinkHelper.getStaticShaderLinkHelper() == null)
|
| 330 | {
|
| 331 | ShaderLinkHelper.setNewStaticShaderLinkHelper();
|
| 332 | }
|
| 333 |
|
| 334 | this.updateFovModifierHand();
|
| 335 | this.updateTorchFlicker();
|
| 336 | this.fogColor2 = this.fogColor1;
|
| 337 | this.thirdPersonDistanceTemp = this.thirdPersonDistance;
|
| 338 |
|
| 339 | if (this.mc.gameSettings.smoothCamera)
|
| 340 | {
|
| 341 | float f = this.mc.gameSettings.mouseSensitivity * 0.6F + 0.2F;
|
| 342 | float f1 = f * f * f * 8.0F;
|
| 343 | this.smoothCamFilterX = this.mouseFilterXAxis.smooth(this.smoothCamYaw, 0.05F * f1);
|
| 344 | this.smoothCamFilterY = this.mouseFilterYAxis.smooth(this.smoothCamPitch, 0.05F * f1);
|
| 345 | this.smoothCamPartialTicks = 0.0F;
|
| 346 | this.smoothCamYaw = 0.0F;
|
| 347 | this.smoothCamPitch = 0.0F;
|
| 348 | }
|
| 349 | else
|
| 350 | {
|
| 351 | this.smoothCamFilterX = 0.0F;
|
| 352 | this.smoothCamFilterY = 0.0F;
|
| 353 | this.mouseFilterXAxis.reset();
|
| 354 | this.mouseFilterYAxis.reset();
|
| 355 | }
|
| 356 |
|
| 357 | if (this.mc.getRenderViewEntity() == null)
|
| 358 | {
|
| 359 | this.mc.setRenderViewEntity(this.mc.thePlayer);
|
| 360 | }
|
| 361 |
|
| 362 | float f3 = this.mc.theWorld.getLightBrightness(new BlockPos(this.mc.getRenderViewEntity()));
|
| 363 | float f4 = (float)this.mc.gameSettings.renderDistanceChunks / 32.0F;
|
| 364 | float f2 = f3 * (1.0F - f4) + f4;
|
| 365 | this.fogColor1 += (f2 - this.fogColor1) * 0.1F;
|
| 366 | ++this.rendererUpdateCount;
|
| 367 | this.itemRenderer.updateEquippedItem();
|
| 368 | this.addRainParticles();
|
| 369 | this.bossColorModifierPrev = this.bossColorModifier;
|
| 370 |
|
| 371 | if (BossStatus.hasColorModifier)
|
| 372 | {
|
| 373 | this.bossColorModifier += 0.05F;
|
| 374 |
|
| 375 | if (this.bossColorModifier > 1.0F)
|
| 376 | {
|
| 377 | this.bossColorModifier = 1.0F;
|
| 378 | }
|
| 379 |
|
| 380 | BossStatus.hasColorModifier = false;
|
| 381 | }
|
| 382 | else if (this.bossColorModifier > 0.0F)
|
| 383 | {
|
| 384 | this.bossColorModifier -= 0.0125F;
|
| 385 | }
|
| 386 | }
|
| 387 |
|
| 388 | public ShaderGroup getShaderGroup()
|
| 389 | {
|
| 390 | return this.theShaderGroup;
|
| 391 | }
|
| 392 |
|
| 393 | public void updateShaderGroupSize(int width, int height)
|
| 394 | {
|
| 395 | if (OpenGlHelper.shadersSupported)
|
| 396 | {
|
| 397 | if (this.theShaderGroup != null)
|
| 398 | {
|
| 399 | this.theShaderGroup.createBindFramebuffers(width, height);
|
| 400 | }
|
| 401 |
|
| 402 | this.mc.renderGlobal.createBindEntityOutlineFbs(width, height);
|
| 403 | }
|
| 404 | }
|
| 405 |
|
| 406 | /**
|
| 407 | * Finds what block or object the mouse is over at the specified partial tick time. Args: partialTickTime
|
| 408 | */
|
| 409 | public void getMouseOver(float partialTicks)
|
| 410 | {
|
| 411 | Entity entity = this.mc.getRenderViewEntity();
|
| 412 |
|
| 413 | if (entity != null)
|
| 414 | {
|
| 415 | if (this.mc.theWorld != null)
|
| 416 | {
|
| 417 | this.mc.mcProfiler.startSection("pick");
|
| 418 | this.mc.pointedEntity = null;
|
| 419 | double d0 = (double)this.mc.playerController.getBlockReachDistance();
|
| 420 | this.mc.objectMouseOver = entity.rayTrace(d0, partialTicks);
|
| 421 | double d1 = d0;
|
| 422 | Vec3 vec3 = entity.getPositionEyes(partialTicks);
|
| 423 | boolean flag = false;
|
| 424 | int i = 3;
|
| 425 |
|
| 426 | if (this.mc.playerController.extendedReach())
|
| 427 | {
|
| 428 | d0 = 6.0D;
|
| 429 | d1 = 6.0D;
|
| 430 | }
|
| 431 | else
|
| 432 | {
|
| 433 | if (d0 > 3.0D)
|
| 434 | {
|
| 435 | flag = true;
|
| 436 | }
|
| 437 | }
|
| 438 |
|
| 439 | if (this.mc.objectMouseOver != null)
|
| 440 | {
|
| 441 | d1 = this.mc.objectMouseOver.hitVec.distanceTo(vec3);
|
| 442 | }
|
| 443 |
|
| 444 | Vec3 vec31 = entity.getLook(partialTicks);
|
| 445 | Vec3 vec32 = vec3.addVector(vec31.xCoord * d0, vec31.yCoord * d0, vec31.zCoord * d0);
|
| 446 | this.pointedEntity = null;
|
| 447 | Vec3 vec33 = null;
|
| 448 | float f = 1.0F;
|
| 449 | List<Entity> list = this.mc.theWorld.getEntitiesInAABBexcluding(entity, entity.getEntityBoundingBox().addCoord(vec31.xCoord * d0, vec31.yCoord * d0, vec31.zCoord * d0).expand((double)f, (double)f, (double)f), Predicates.and(EntitySelectors.NOT_SPECTATING, new Predicate<Entity>()
|
| 450 | {
|
| 451 | public boolean apply(Entity p_apply_1_)
|
| 452 | {
|
| 453 | return p_apply_1_.canBeCollidedWith();
|
| 454 | }
|
| 455 | }));
|
| 456 | double d2 = d1;
|
| 457 |
|
| 458 | for (int j = 0; j < list.size(); ++j)
|
| 459 | {
|
| 460 | Entity entity1 = (Entity)list.get(j);
|
| 461 | float f1 = entity1.getCollisionBorderSize();
|
| 462 | AxisAlignedBB axisalignedbb = entity1.getEntityBoundingBox().expand((double)f1, (double)f1, (double)f1);
|
| 463 | MovingObjectPosition movingobjectposition = axisalignedbb.calculateIntercept(vec3, vec32);
|
| 464 |
|
| 465 | if (axisalignedbb.isVecInside(vec3))
|
| 466 | {
|
| 467 | if (d2 >= 0.0D)
|
| 468 | {
|
| 469 | this.pointedEntity = entity1;
|
| 470 | vec33 = movingobjectposition == null ? vec3 : movingobjectposition.hitVec;
|
| 471 | d2 = 0.0D;
|
| 472 | }
|
| 473 | }
|
| 474 | else if (movingobjectposition != null)
|
| 475 | {
|
| 476 | double d3 = vec3.distanceTo(movingobjectposition.hitVec);
|
| 477 |
|
| 478 | if (d3 < d2 || d2 == 0.0D)
|
| 479 | {
|
| 480 | if (entity1 == entity.ridingEntity)
|
| 481 | {
|
| 482 | if (d2 == 0.0D)
|
| 483 | {
|
| 484 | this.pointedEntity = entity1;
|
| 485 | vec33 = movingobjectposition.hitVec;
|
| 486 | }
|
| 487 | }
|
| 488 | else
|
| 489 | {
|
| 490 | this.pointedEntity = entity1;
|
| 491 | vec33 = movingobjectposition.hitVec;
|
| 492 | d2 = d3;
|
| 493 | }
|
| 494 | }
|
| 495 | }
|
| 496 | }
|
| 497 |
|
| 498 | if (this.pointedEntity != null && flag && vec3.distanceTo(vec33) > 3.0D)
|
| 499 | {
|
| 500 | this.pointedEntity = null;
|
| 501 | this.mc.objectMouseOver = new MovingObjectPosition(MovingObjectPosition.MovingObjectType.MISS, vec33, (EnumFacing)null, new BlockPos(vec33));
|
| 502 | }
|
| 503 |
|
| 504 | if (this.pointedEntity != null && (d2 < d1 || this.mc.objectMouseOver == null))
|
| 505 | {
|
| 506 | this.mc.objectMouseOver = new MovingObjectPosition(this.pointedEntity, vec33);
|
| 507 |
|
| 508 | if (this.pointedEntity instanceof EntityLivingBase || this.pointedEntity instanceof EntityItemFrame)
|
| 509 | {
|
| 510 | this.mc.pointedEntity = this.pointedEntity;
|
| 511 | }
|
| 512 | }
|
| 513 |
|
| 514 | this.mc.mcProfiler.endSection();
|
| 515 | }
|
| 516 | }
|
| 517 | }
|
| 518 |
|
| 519 | /**
|
| 520 | * Update FOV modifier hand
|
| 521 | */
|
| 522 | private void updateFovModifierHand()
|
| 523 | {
|
| 524 | float f = 1.0F;
|
| 525 |
|
| 526 | if (this.mc.getRenderViewEntity() instanceof AbstractClientPlayer)
|
| 527 | {
|
| 528 | AbstractClientPlayer abstractclientplayer = (AbstractClientPlayer)this.mc.getRenderViewEntity();
|
| 529 | f = abstractclientplayer.getFovModifier();
|
| 530 | }
|
| 531 |
|
| 532 | this.fovModifierHandPrev = this.fovModifierHand;
|
| 533 | this.fovModifierHand += (f - this.fovModifierHand) * 0.5F;
|
| 534 |
|
| 535 | if (this.fovModifierHand > 1.5F)
|
| 536 | {
|
| 537 | this.fovModifierHand = 1.5F;
|
| 538 | }
|
| 539 |
|
| 540 | if (this.fovModifierHand < 0.1F)
|
| 541 | {
|
| 542 | this.fovModifierHand = 0.1F;
|
| 543 | }
|
| 544 | }
|
| 545 |
|
| 546 | /**
|
| 547 | * Changes the field of view of the player depending on if they are underwater or not
|
| 548 | *
|
| 549 | * @param useFOVSetting If true the FOV set in the settings will be use in the calculation
|
| 550 | */
|
| 551 | private float getFOVModifier(float partialTicks, boolean useFOVSetting)
|
| 552 | {
|
| 553 | if (this.debugView)
|
| 554 | {
|
| 555 | return 90.0F;
|
| 556 | }
|
| 557 | else
|
| 558 | {
|
| 559 | Entity entity = this.mc.getRenderViewEntity();
|
| 560 | float f = 70.0F;
|
| 561 |
|
| 562 | if (useFOVSetting)
|
| 563 | {
|
| 564 | f = this.mc.gameSettings.fovSetting;
|
| 565 | f = f * (this.fovModifierHandPrev + (this.fovModifierHand - this.fovModifierHandPrev) * partialTicks);
|
| 566 | }
|
| 567 |
|
| 568 | if (entity instanceof EntityLivingBase && ((EntityLivingBase)entity).getHealth() <= 0.0F)
|
| 569 | {
|
| 570 | float f1 = (float)((EntityLivingBase)entity).deathTime + partialTicks;
|
| 571 | f /= (1.0F - 500.0F / (f1 + 500.0F)) * 2.0F + 1.0F;
|
| 572 | }
|
| 573 |
|
| 574 | Block block = ActiveRenderInfo.getBlockAtEntityViewpoint(this.mc.theWorld, entity, partialTicks);
|
| 575 |
|
| 576 | if (block.getMaterial() == Material.water)
|
| 577 | {
|
| 578 | f = f * 60.0F / 70.0F;
|
| 579 | }
|
| 580 |
|
| 581 | return f;
|
| 582 | }
|
| 583 | }
|
| 584 |
|
| 585 | private void hurtCameraEffect(float partialTicks)
|
| 586 | {
|
| 587 | if (this.mc.getRenderViewEntity() instanceof EntityLivingBase)
|
| 588 | {
|
| 589 | EntityLivingBase entitylivingbase = (EntityLivingBase)this.mc.getRenderViewEntity();
|
| 590 | float f = (float)entitylivingbase.hurtTime - partialTicks;
|
| 591 |
|
| 592 | if (entitylivingbase.getHealth() <= 0.0F)
|
| 593 | {
|
| 594 | float f1 = (float)entitylivingbase.deathTime + partialTicks;
|
| 595 | GlStateManager.rotate(40.0F - 8000.0F / (f1 + 200.0F), 0.0F, 0.0F, 1.0F);
|
| 596 | }
|
| 597 |
|
| 598 | if (f < 0.0F)
|
| 599 | {
|
| 600 | return;
|
| 601 | }
|
| 602 |
|
| 603 | f = f / (float)entitylivingbase.maxHurtTime;
|
| 604 | f = MathHelper.sin(f * f * f * f * (float)Math.PI);
|
| 605 | float f2 = entitylivingbase.attackedAtYaw;
|
| 606 | GlStateManager.rotate(-f2, 0.0F, 1.0F, 0.0F);
|
| 607 | GlStateManager.rotate(-f * 14.0F, 0.0F, 0.0F, 1.0F);
|
| 608 | GlStateManager.rotate(f2, 0.0F, 1.0F, 0.0F);
|
| 609 | }
|
| 610 | }
|
| 611 |
|
| 612 | /**
|
| 613 | * Setups all the GL settings for view bobbing. Args: partialTickTime
|
| 614 | */
|
| 615 | private void setupViewBobbing(float partialTicks)
|
| 616 | {
|
| 617 | if (this.mc.getRenderViewEntity() instanceof EntityPlayer)
|
| 618 | {
|
| 619 | EntityPlayer entityplayer = (EntityPlayer)this.mc.getRenderViewEntity();
|
| 620 | float f = entityplayer.distanceWalkedModified - entityplayer.prevDistanceWalkedModified;
|
| 621 | float f1 = -(entityplayer.distanceWalkedModified + f * partialTicks);
|
| 622 | float f2 = entityplayer.prevCameraYaw + (entityplayer.cameraYaw - entityplayer.prevCameraYaw) * partialTicks;
|
| 623 | float f3 = entityplayer.prevCameraPitch + (entityplayer.cameraPitch - entityplayer.prevCameraPitch) * partialTicks;
|
| 624 | GlStateManager.translate(MathHelper.sin(f1 * (float)Math.PI) * f2 * 0.5F, -Math.abs(MathHelper.cos(f1 * (float)Math.PI) * f2), 0.0F);
|
| 625 | GlStateManager.rotate(MathHelper.sin(f1 * (float)Math.PI) * f2 * 3.0F, 0.0F, 0.0F, 1.0F);
|
| 626 | GlStateManager.rotate(Math.abs(MathHelper.cos(f1 * (float)Math.PI - 0.2F) * f2) * 5.0F, 1.0F, 0.0F, 0.0F);
|
| 627 | GlStateManager.rotate(f3, 1.0F, 0.0F, 0.0F);
|
| 628 | }
|
| 629 | }
|
| 630 |
|
| 631 | /**
|
| 632 | * sets up player's eye (or camera in third person mode)
|
| 633 | */
|
| 634 | private void orientCamera(float partialTicks)
|
| 635 | {
|
| 636 | Entity entity = this.mc.getRenderViewEntity();
|
| 637 | float f = entity.getEyeHeight();
|
| 638 | double d0 = entity.prevPosX + (entity.posX - entity.prevPosX) * (double)partialTicks;
|
| 639 | double d1 = entity.prevPosY + (entity.posY - entity.prevPosY) * (double)partialTicks + (double)f;
|
| 640 | double d2 = entity.prevPosZ + (entity.posZ - entity.prevPosZ) * (double)partialTicks;
|
| 641 |
|
| 642 | if (entity instanceof EntityLivingBase && ((EntityLivingBase)entity).isPlayerSleeping())
|
| 643 | {
|
| 644 | f = (float)((double)f + 1.0D);
|
| 645 | GlStateManager.translate(0.0F, 0.3F, 0.0F);
|
| 646 |
|
| 647 | if (!this.mc.gameSettings.debugCamEnable)
|
| 648 | {
|
| 649 | BlockPos blockpos = new BlockPos(entity);
|
| 650 | IBlockState iblockstate = this.mc.theWorld.getBlockState(blockpos);
|
| 651 | Block block = iblockstate.getBlock();
|
| 652 |
|
| 653 | if (block == Blocks.bed)
|
| 654 | {
|
| 655 | int j = ((EnumFacing)iblockstate.getValue(BlockBed.FACING)).getHorizontalIndex();
|
| 656 | GlStateManager.rotate((float)(j * 90), 0.0F, 1.0F, 0.0F);
|
| 657 | }
|
| 658 |
|
| 659 | GlStateManager.rotate(entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw) * partialTicks + 180.0F, 0.0F, -1.0F, 0.0F);
|
| 660 | GlStateManager.rotate(entity.prevRotationPitch + (entity.rotationPitch - entity.prevRotationPitch) * partialTicks, -1.0F, 0.0F, 0.0F);
|
| 661 | }
|
| 662 | }
|
| 663 | else if (this.mc.gameSettings.thirdPersonView > 0)
|
| 664 | {
|
| 665 | double d3 = (double)(this.thirdPersonDistanceTemp + (this.thirdPersonDistance - this.thirdPersonDistanceTemp) * partialTicks);
|
| 666 |
|
| 667 | if (this.mc.gameSettings.debugCamEnable)
|
| 668 | {
|
| 669 | GlStateManager.translate(0.0F, 0.0F, (float)(-d3));
|
| 670 | }
|
| 671 | else
|
| 672 | {
|
| 673 | float f1 = entity.rotationYaw;
|
| 674 | float f2 = entity.rotationPitch;
|
| 675 |
|
| 676 | if (this.mc.gameSettings.thirdPersonView == 2)
|
| 677 | {
|
| 678 | f2 += 180.0F;
|
| 679 | }
|
| 680 |
|
| 681 | double d4 = (double)(-MathHelper.sin(f1 / 180.0F * (float)Math.PI) * MathHelper.cos(f2 / 180.0F * (float)Math.PI)) * d3;
|
| 682 | double d5 = (double)(MathHelper.cos(f1 / 180.0F * (float)Math.PI) * MathHelper.cos(f2 / 180.0F * (float)Math.PI)) * d3;
|
| 683 | double d6 = (double)(-MathHelper.sin(f2 / 180.0F * (float)Math.PI)) * d3;
|
| 684 |
|
| 685 | for (int i = 0; i < 8; ++i)
|
| 686 | {
|
| 687 | float f3 = (float)((i & 1) * 2 - 1);
|
| 688 | float f4 = (float)((i >> 1 & 1) * 2 - 1);
|
| 689 | float f5 = (float)((i >> 2 & 1) * 2 - 1);
|
| 690 | f3 = f3 * 0.1F;
|
| 691 | f4 = f4 * 0.1F;
|
| 692 | f5 = f5 * 0.1F;
|
| 693 | MovingObjectPosition movingobjectposition = this.mc.theWorld.rayTraceBlocks(new Vec3(d0 + (double)f3, d1 + (double)f4, d2 + (double)f5), new Vec3(d0 - d4 + (double)f3 + (double)f5, d1 - d6 + (double)f4, d2 - d5 + (double)f5));
|
| 694 |
|
| 695 | if (movingobjectposition != null)
|
| 696 | {
|
| 697 | double d7 = movingobjectposition.hitVec.distanceTo(new Vec3(d0, d1, d2));
|
| 698 |
|
| 699 | if (d7 < d3)
|
| 700 | {
|
| 701 | d3 = d7;
|
| 702 | }
|
| 703 | }
|
| 704 | }
|
| 705 |
|
| 706 | if (this.mc.gameSettings.thirdPersonView == 2)
|
| 707 | {
|
| 708 | GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F);
|
| 709 | }
|
| 710 |
|
| 711 | GlStateManager.rotate(entity.rotationPitch - f2, 1.0F, 0.0F, 0.0F);
|
| 712 | GlStateManager.rotate(entity.rotationYaw - f1, 0.0F, 1.0F, 0.0F);
|
| 713 | GlStateManager.translate(0.0F, 0.0F, (float)(-d3));
|
| 714 | GlStateManager.rotate(f1 - entity.rotationYaw, 0.0F, 1.0F, 0.0F);
|
| 715 | GlStateManager.rotate(f2 - entity.rotationPitch, 1.0F, 0.0F, 0.0F);
|
| 716 | }
|
| 717 | }
|
| 718 | else
|
| 719 | {
|
| 720 | GlStateManager.translate(0.0F, 0.0F, -0.1F);
|
| 721 | }
|
| 722 |
|
| 723 | if (!this.mc.gameSettings.debugCamEnable)
|
| 724 | {
|
| 725 | GlStateManager.rotate(entity.prevRotationPitch + (entity.rotationPitch - entity.prevRotationPitch) * partialTicks, 1.0F, 0.0F, 0.0F);
|
| 726 |
|
| 727 | if (entity instanceof EntityAnimal)
|
| 728 | {
|
| 729 | EntityAnimal entityanimal = (EntityAnimal)entity;
|
| 730 | GlStateManager.rotate(entityanimal.prevRotationYawHead + (entityanimal.rotationYawHead - entityanimal.prevRotationYawHead) * partialTicks + 180.0F, 0.0F, 1.0F, 0.0F);
|
| 731 | }
|
| 732 | else
|
| 733 | {
|
| 734 | GlStateManager.rotate(entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw) * partialTicks + 180.0F, 0.0F, 1.0F, 0.0F);
|
| 735 | }
|
| 736 | }
|
| 737 |
|
| 738 | GlStateManager.translate(0.0F, -f, 0.0F);
|
| 739 | d0 = entity.prevPosX + (entity.posX - entity.prevPosX) * (double)partialTicks;
|
| 740 | d1 = entity.prevPosY + (entity.posY - entity.prevPosY) * (double)partialTicks + (double)f;
|
| 741 | d2 = entity.prevPosZ + (entity.posZ - entity.prevPosZ) * (double)partialTicks;
|
| 742 | this.cloudFog = this.mc.renderGlobal.hasCloudFog(d0, d1, d2, partialTicks);
|
| 743 | }
|
| 744 |
|
| 745 | /**
|
| 746 | * sets up projection, view effects, camera position/rotation
|
| 747 | */
|
| 748 | private void setupCameraTransform(float partialTicks, int pass)
|
| 749 | {
|
| 750 | this.farPlaneDistance = (float)(this.mc.gameSettings.renderDistanceChunks * 16);
|
| 751 | GlStateManager.matrixMode(5889);
|
| 752 | GlStateManager.loadIdentity();
|
| 753 | float f = 0.07F;
|
| 754 |
|
| 755 | if (this.mc.gameSettings.anaglyph)
|
| 756 | {
|
| 757 | GlStateManager.translate((float)(-(pass * 2 - 1)) * f, 0.0F, 0.0F);
|
| 758 | }
|
| 759 |
|
| 760 | if (this.cameraZoom != 1.0D)
|
| 761 | {
|
| 762 | GlStateManager.translate((float)this.cameraYaw, (float)(-this.cameraPitch), 0.0F);
|
| 763 | GlStateManager.scale(this.cameraZoom, this.cameraZoom, 1.0D);
|
| 764 | }
|
| 765 |
|
| 766 | Project.gluPerspective(this.getFOVModifier(partialTicks, true), (float)this.mc.displayWidth / (float)this.mc.displayHeight, 0.05F, this.farPlaneDistance * MathHelper.SQRT_2);
|
| 767 | GlStateManager.matrixMode(5888);
|
| 768 | GlStateManager.loadIdentity();
|
| 769 |
|
| 770 | if (this.mc.gameSettings.anaglyph)
|
| 771 | {
|
| 772 | GlStateManager.translate((float)(pass * 2 - 1) * 0.1F, 0.0F, 0.0F);
|
| 773 | }
|
| 774 |
|
| 775 | this.hurtCameraEffect(partialTicks);
|
| 776 |
|
| 777 | if (this.mc.gameSettings.viewBobbing)
|
| 778 | {
|
| 779 | this.setupViewBobbing(partialTicks);
|
| 780 | }
|
| 781 |
|
| 782 | float f1 = this.mc.thePlayer.prevTimeInPortal + (this.mc.thePlayer.timeInPortal - this.mc.thePlayer.prevTimeInPortal) * partialTicks;
|
| 783 |
|
| 784 | if (f1 > 0.0F)
|
| 785 | {
|
| 786 | int i = 20;
|
| 787 |
|
| 788 | if (this.mc.thePlayer.isPotionActive(Potion.confusion))
|
| 789 | {
|
| 790 | i = 7;
|
| 791 | }
|
| 792 |
|
| 793 | float f2 = 5.0F / (f1 * f1 + 5.0F) - f1 * 0.04F;
|
| 794 | f2 = f2 * f2;
|
| 795 | GlStateManager.rotate(((float)this.rendererUpdateCount + partialTicks) * (float)i, 0.0F, 1.0F, 1.0F);
|
| 796 | GlStateManager.scale(1.0F / f2, 1.0F, 1.0F);
|
| 797 | GlStateManager.rotate(-((float)this.rendererUpdateCount + partialTicks) * (float)i, 0.0F, 1.0F, 1.0F);
|
| 798 | }
|
| 799 |
|
| 800 | this.orientCamera(partialTicks);
|
| 801 |
|
| 802 | if (this.debugView)
|
| 803 | {
|
| 804 | switch (this.debugViewDirection)
|
| 805 | {
|
| 806 | case 0:
|
| 807 | GlStateManager.rotate(90.0F, 0.0F, 1.0F, 0.0F);
|
| 808 | break;
|
| 809 |
|
| 810 | case 1:
|
| 811 | GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F);
|
| 812 | break;
|
| 813 |
|
| 814 | case 2:
|
| 815 | GlStateManager.rotate(-90.0F, 0.0F, 1.0F, 0.0F);
|
| 816 | break;
|
| 817 |
|
| 818 | case 3:
|
| 819 | GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F);
|
| 820 | break;
|
| 821 |
|
| 822 | case 4:
|
| 823 | GlStateManager.rotate(-90.0F, 1.0F, 0.0F, 0.0F);
|
| 824 | }
|
| 825 | }
|
| 826 | }
|
| 827 |
|
| 828 | /**
|
| 829 | * Render player hand
|
| 830 | */
|
| 831 | private void renderHand(float partialTicks, int xOffset)
|
| 832 | {
|
| 833 | if (!this.debugView)
|
| 834 | {
|
| 835 | GlStateManager.matrixMode(5889);
|
| 836 | GlStateManager.loadIdentity();
|
| 837 | float f = 0.07F;
|
| 838 |
|
| 839 | if (this.mc.gameSettings.anaglyph)
|
| 840 | {
|
| 841 | GlStateManager.translate((float)(-(xOffset * 2 - 1)) * f, 0.0F, 0.0F);
|
| 842 | }
|
| 843 |
|
| 844 | Project.gluPerspective(this.getFOVModifier(partialTicks, false), (float)this.mc.displayWidth / (float)this.mc.displayHeight, 0.05F, this.farPlaneDistance * 2.0F);
|
| 845 | GlStateManager.matrixMode(5888);
|
| 846 | GlStateManager.loadIdentity();
|
| 847 |
|
| 848 | if (this.mc.gameSettings.anaglyph)
|
| 849 | {
|
| 850 | GlStateManager.translate((float)(xOffset * 2 - 1) * 0.1F, 0.0F, 0.0F);
|
| 851 | }
|
| 852 |
|
| 853 | GlStateManager.pushMatrix();
|
| 854 | this.hurtCameraEffect(partialTicks);
|
| 855 |
|
| 856 | if (this.mc.gameSettings.viewBobbing)
|
| 857 | {
|
| 858 | this.setupViewBobbing(partialTicks);
|
| 859 | }
|
| 860 |
|
| 861 | boolean flag = this.mc.getRenderViewEntity() instanceof EntityLivingBase && ((EntityLivingBase)this.mc.getRenderViewEntity()).isPlayerSleeping();
|
| 862 |
|
| 863 | if (this.mc.gameSettings.thirdPersonView == 0 && !flag && !this.mc.gameSettings.hideGUI && !this.mc.playerController.isSpectator())
|
| 864 | {
|
| 865 | this.enableLightmap();
|
| 866 | this.itemRenderer.renderItemInFirstPerson(partialTicks);
|
| 867 | this.disableLightmap();
|
| 868 | }
|
| 869 |
|
| 870 | GlStateManager.popMatrix();
|
| 871 |
|
| 872 | if (this.mc.gameSettings.thirdPersonView == 0 && !flag)
|
| 873 | {
|
| 874 | this.itemRenderer.renderOverlays(partialTicks);
|
| 875 | this.hurtCameraEffect(partialTicks);
|
| 876 | }
|
| 877 |
|
| 878 | if (this.mc.gameSettings.viewBobbing)
|
| 879 | {
|
| 880 | this.setupViewBobbing(partialTicks);
|
| 881 | }
|
| 882 | }
|
| 883 | }
|
| 884 |
|
| 885 | public void disableLightmap()
|
| 886 | {
|
| 887 | GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit);
|
| 888 | GlStateManager.disableTexture2D();
|
| 889 | GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit);
|
| 890 | }
|
| 891 |
|
| 892 | public void enableLightmap()
|
| 893 | {
|
| 894 | GlStateManager.setActiveTexture(OpenGlHelper.lightmapTexUnit);
|
| 895 | GlStateManager.matrixMode(5890);
|
| 896 | GlStateManager.loadIdentity();
|
| 897 | float f = 0.00390625F;
|
| 898 | GlStateManager.scale(f, f, f);
|
| 899 | GlStateManager.translate(8.0F, 8.0F, 8.0F);
|
| 900 | GlStateManager.matrixMode(5888);
|
| 901 | this.mc.getTextureManager().bindTexture(this.locationLightMap);
|
| 902 | GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
|
| 903 | GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
|
| 904 | GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP);
|
| 905 | GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP);
|
| 906 | GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
| 907 | GlStateManager.enableTexture2D();
|
| 908 | GlStateManager.setActiveTexture(OpenGlHelper.defaultTexUnit);
|
| 909 | }
|
| 910 |
|
| 911 | /**
|
| 912 | * Recompute a random value that is applied to block color in updateLightmap()
|
| 913 | */
|
| 914 | private void updateTorchFlicker()
|
| 915 | {
|
| 916 | this.torchFlickerDX = (float)((double)this.torchFlickerDX + (Math.random() - Math.random()) * Math.random() * Math.random());
|
| 917 | this.torchFlickerDX = (float)((double)this.torchFlickerDX * 0.9D);
|
| 918 | this.torchFlickerX += (this.torchFlickerDX - this.torchFlickerX) * 1.0F;
|
| 919 | this.lightmapUpdateNeeded = true;
|
| 920 | }
|
| 921 |
|
| 922 | private void updateLightmap(float partialTicks)
|
| 923 | {
|
| 924 | if (this.lightmapUpdateNeeded)
|
| 925 | {
|
| 926 | this.mc.mcProfiler.startSection("lightTex");
|
| 927 | World world = this.mc.theWorld;
|
| 928 |
|
| 929 | if (world != null)
|
| 930 | {
|
| 931 | float f = world.getSunBrightness(1.0F);
|
| 932 | float f1 = f * 0.95F + 0.05F;
|
| 933 |
|
| 934 | for (int i = 0; i < 256; ++i)
|
| 935 | {
|
| 936 | float f2 = world.provider.getLightBrightnessTable()[i / 16] * f1;
|
| 937 | float f3 = world.provider.getLightBrightnessTable()[i % 16] * (this.torchFlickerX * 0.1F + 1.5F);
|
| 938 |
|
| 939 | if (world.getLastLightningBolt() > 0)
|
| 940 | {
|
| 941 | f2 = world.provider.getLightBrightnessTable()[i / 16];
|
| 942 | }
|
| 943 |
|
| 944 | float f4 = f2 * (f * 0.65F + 0.35F);
|
| 945 | float f5 = f2 * (f * 0.65F + 0.35F);
|
| 946 | float f6 = f3 * ((f3 * 0.6F + 0.4F) * 0.6F + 0.4F);
|
| 947 | float f7 = f3 * (f3 * f3 * 0.6F + 0.4F);
|
| 948 | float f8 = f4 + f3;
|
| 949 | float f9 = f5 + f6;
|
| 950 | float f10 = f2 + f7;
|
| 951 | f8 = f8 * 0.96F + 0.03F;
|
| 952 | f9 = f9 * 0.96F + 0.03F;
|
| 953 | f10 = f10 * 0.96F + 0.03F;
|
| 954 |
|
| 955 | if (this.bossColorModifier > 0.0F)
|
| 956 | {
|
| 957 | float f11 = this.bossColorModifierPrev + (this.bossColorModifier - this.bossColorModifierPrev) * partialTicks;
|
| 958 | f8 = f8 * (1.0F - f11) + f8 * 0.7F * f11;
|
| 959 | f9 = f9 * (1.0F - f11) + f9 * 0.6F * f11;
|
| 960 | f10 = f10 * (1.0F - f11) + f10 * 0.6F * f11;
|
| 961 | }
|
| 962 |
|
| 963 | if (world.provider.getDimensionId() == 1)
|
| 964 | {
|
| 965 | f8 = 0.22F + f3 * 0.75F;
|
| 966 | f9 = 0.28F + f6 * 0.75F;
|
| 967 | f10 = 0.25F + f7 * 0.75F;
|
| 968 | }
|
| 969 |
|
| 970 | if (this.mc.thePlayer.isPotionActive(Potion.nightVision))
|
| 971 | {
|
| 972 | float f15 = this.getNightVisionBrightness(this.mc.thePlayer, partialTicks);
|
| 973 | float f12 = 1.0F / f8;
|
| 974 |
|
| 975 | if (f12 > 1.0F / f9)
|
| 976 | {
|
| 977 | f12 = 1.0F / f9;
|
| 978 | }
|
| 979 |
|
| 980 | if (f12 > 1.0F / f10)
|
| 981 | {
|
| 982 | f12 = 1.0F / f10;
|
| 983 | }
|
| 984 |
|
| 985 | f8 = f8 * (1.0F - f15) + f8 * f12 * f15;
|
| 986 | f9 = f9 * (1.0F - f15) + f9 * f12 * f15;
|
| 987 | f10 = f10 * (1.0F - f15) + f10 * f12 * f15;
|
| 988 | }
|
| 989 |
|
| 990 | if (f8 > 1.0F)
|
| 991 | {
|
| 992 | f8 = 1.0F;
|
| 993 | }
|
| 994 |
|
| 995 | if (f9 > 1.0F)
|
| 996 | {
|
| 997 | f9 = 1.0F;
|
| 998 | }
|
| 999 |
|
| 1000 | if (f10 > 1.0F)
|
| 1001 | {
|
| 1002 | f10 = 1.0F;
|
| 1003 | }
|
| 1004 |
|
| 1005 | float f16 = this.mc.gameSettings.gammaSetting;
|
| 1006 | float f17 = 1.0F - f8;
|
| 1007 | float f13 = 1.0F - f9;
|
| 1008 | float f14 = 1.0F - f10;
|
| 1009 | f17 = 1.0F - f17 * f17 * f17 * f17;
|
| 1010 | f13 = 1.0F - f13 * f13 * f13 * f13;
|
| 1011 | f14 = 1.0F - f14 * f14 * f14 * f14;
|
| 1012 | f8 = f8 * (1.0F - f16) + f17 * f16;
|
| 1013 | f9 = f9 * (1.0F - f16) + f13 * f16;
|
| 1014 | f10 = f10 * (1.0F - f16) + f14 * f16;
|
| 1015 | f8 = f8 * 0.96F + 0.03F;
|
| 1016 | f9 = f9 * 0.96F + 0.03F;
|
| 1017 | f10 = f10 * 0.96F + 0.03F;
|
| 1018 |
|
| 1019 | if (f8 > 1.0F)
|
| 1020 | {
|
| 1021 | f8 = 1.0F;
|
| 1022 | }
|
| 1023 |
|
| 1024 | if (f9 > 1.0F)
|
| 1025 | {
|
| 1026 | f9 = 1.0F;
|
| 1027 | }
|
| 1028 |
|
| 1029 | if (f10 > 1.0F)
|
| 1030 | {
|
| 1031 | f10 = 1.0F;
|
| 1032 | }
|
| 1033 |
|
| 1034 | if (f8 < 0.0F)
|
| 1035 | {
|
| 1036 | f8 = 0.0F;
|
| 1037 | }
|
| 1038 |
|
| 1039 | if (f9 < 0.0F)
|
| 1040 | {
|
| 1041 | f9 = 0.0F;
|
| 1042 | }
|
| 1043 |
|
| 1044 | if (f10 < 0.0F)
|
| 1045 | {
|
| 1046 | f10 = 0.0F;
|
| 1047 | }
|
| 1048 |
|
| 1049 | int j = 255;
|
| 1050 | int k = (int)(f8 * 255.0F);
|
| 1051 | int l = (int)(f9 * 255.0F);
|
| 1052 | int i1 = (int)(f10 * 255.0F);
|
| 1053 | this.lightmapColors[i] = j << 24 | k << 16 | l << 8 | i1;
|
| 1054 | }
|
| 1055 |
|
| 1056 | this.lightmapTexture.updateDynamicTexture();
|
| 1057 | this.lightmapUpdateNeeded = false;
|
| 1058 | this.mc.mcProfiler.endSection();
|
| 1059 | }
|
| 1060 | }
|
| 1061 | }
|
| 1062 |
|
| 1063 | private float getNightVisionBrightness(EntityLivingBase entitylivingbaseIn, float partialTicks)
|
| 1064 | {
|
| 1065 | int i = entitylivingbaseIn.getActivePotionEffect(Potion.nightVision).getDuration();
|
| 1066 | return i > 200 ? 1.0F : 0.7F + MathHelper.sin(((float)i - partialTicks) * (float)Math.PI * 0.2F) * 0.3F;
|
| 1067 | }
|
| 1068 |
|
| 1069 | public void updateCameraAndRender(float partialTicks, long nanoTime)
|
| 1070 | {
|
| 1071 | boolean flag = Display.isActive();
|
| 1072 |
|
| 1073 | if (!flag && this.mc.gameSettings.pauseOnLostFocus && (!this.mc.gameSettings.touchscreen || !Mouse.isButtonDown(1)))
|
| 1074 | {
|
| 1075 | if (Minecraft.getSystemTime() - this.prevFrameTime > 500L)
|
| 1076 | {
|
| 1077 | this.mc.displayInGameMenu();
|
| 1078 | }
|
| 1079 | }
|
| 1080 | else
|
| 1081 | {
|
| 1082 | this.prevFrameTime = Minecraft.getSystemTime();
|
| 1083 | }
|
| 1084 |
|
| 1085 | this.mc.mcProfiler.startSection("mouse");
|
| 1086 |
|
| 1087 | if (flag && Minecraft.isRunningOnMac && this.mc.inGameHasFocus && !Mouse.isInsideWindow())
|
| 1088 | {
|
| 1089 | Mouse.setGrabbed(false);
|
| 1090 | Mouse.setCursorPosition(Display.getWidth() / 2, Display.getHeight() / 2);
|
| 1091 | Mouse.setGrabbed(true);
|
| 1092 | }
|
| 1093 |
|
| 1094 | if (this.mc.inGameHasFocus && flag)
|
| 1095 | {
|
| 1096 | this.mc.mouseHelper.mouseXYChange();
|
| 1097 | float f = this.mc.gameSettings.mouseSensitivity * 0.6F + 0.2F;
|
| 1098 | float f1 = f * f * f * 8.0F;
|
| 1099 | float f2 = (float)this.mc.mouseHelper.deltaX * f1;
|
| 1100 | float f3 = (float)this.mc.mouseHelper.deltaY * f1;
|
| 1101 | int i = 1;
|
| 1102 |
|
| 1103 | if (this.mc.gameSettings.invertMouse)
|
| 1104 | {
|
| 1105 | i = -1;
|
| 1106 | }
|
| 1107 |
|
| 1108 | if (this.mc.gameSettings.smoothCamera)
|
| 1109 | {
|
| 1110 | this.smoothCamYaw += f2;
|
| 1111 | this.smoothCamPitch += f3;
|
| 1112 | float f4 = partialTicks - this.smoothCamPartialTicks;
|
| 1113 | this.smoothCamPartialTicks = partialTicks;
|
| 1114 | f2 = this.smoothCamFilterX * f4;
|
| 1115 | f3 = this.smoothCamFilterY * f4;
|
| 1116 | this.mc.thePlayer.setAngles(f2, f3 * (float)i);
|
| 1117 | }
|
| 1118 | else
|
| 1119 | {
|
| 1120 | this.smoothCamYaw = 0.0F;
|
| 1121 | this.smoothCamPitch = 0.0F;
|
| 1122 | this.mc.thePlayer.setAngles(f2, f3 * (float)i);
|
| 1123 | }
|
| 1124 | }
|
| 1125 |
|
| 1126 | this.mc.mcProfiler.endSection();
|
| 1127 |
|
| 1128 | if (!this.mc.skipRenderWorld)
|
| 1129 | {
|
| 1130 | anaglyphEnable = this.mc.gameSettings.anaglyph;
|
| 1131 | final ScaledResolution scaledresolution = new ScaledResolution(this.mc);
|
| 1132 | int i1 = scaledresolution.getScaledWidth();
|
| 1133 | int j1 = scaledresolution.getScaledHeight();
|
| 1134 | final int k1 = Mouse.getX() * i1 / this.mc.displayWidth;
|
| 1135 | final int l1 = j1 - Mouse.getY() * j1 / this.mc.displayHeight - 1;
|
| 1136 | int i2 = this.mc.gameSettings.limitFramerate;
|
| 1137 |
|
| 1138 | if (this.mc.theWorld != null)
|
| 1139 | {
|
| 1140 | this.mc.mcProfiler.startSection("level");
|
| 1141 | int j = Math.min(Minecraft.getDebugFPS(), i2);
|
| 1142 | j = Math.max(j, 60);
|
| 1143 | long k = System.nanoTime() - nanoTime;
|
| 1144 | long l = Math.max((long)(1000000000 / j / 4) - k, 0L);
|
| 1145 | this.renderWorld(partialTicks, System.nanoTime() + l);
|
| 1146 |
|
| 1147 | if (OpenGlHelper.shadersSupported)
|
| 1148 | {
|
| 1149 | this.mc.renderGlobal.renderEntityOutlineFramebuffer();
|
| 1150 |
|
| 1151 | if (this.theShaderGroup != null && this.useShader)
|
| 1152 | {
|
| 1153 | GlStateManager.matrixMode(5890);
|
| 1154 | GlStateManager.pushMatrix();
|
| 1155 | GlStateManager.loadIdentity();
|
| 1156 | this.theShaderGroup.loadShaderGroup(partialTicks);
|
| 1157 | GlStateManager.popMatrix();
|
| 1158 | }
|
| 1159 |
|
| 1160 | this.mc.getFramebuffer().bindFramebuffer(true);
|
| 1161 | }
|
| 1162 |
|
| 1163 | this.renderEndNanoTime = System.nanoTime();
|
| 1164 | this.mc.mcProfiler.endStartSection("gui");
|
| 1165 |
|
| 1166 | if (!this.mc.gameSettings.hideGUI || this.mc.currentScreen != null)
|
| 1167 | {
|
| 1168 | GlStateManager.alphaFunc(516, 0.1F);
|
| 1169 | this.mc.ingameGUI.renderGameOverlay(partialTicks);
|
| 1170 | }
|
| 1171 |
|
| 1172 | this.mc.mcProfiler.endSection();
|
| 1173 | }
|
| 1174 | else
|
| 1175 | {
|
| 1176 | GlStateManager.viewport(0, 0, this.mc.displayWidth, this.mc.displayHeight);
|
| 1177 | GlStateManager.matrixMode(5889);
|
| 1178 | GlStateManager.loadIdentity();
|
| 1179 | GlStateManager.matrixMode(5888);
|
| 1180 | GlStateManager.loadIdentity();
|
| 1181 | this.setupOverlayRendering();
|
| 1182 | this.renderEndNanoTime = System.nanoTime();
|
| 1183 | }
|
| 1184 |
|
| 1185 | if (this.mc.currentScreen != null)
|
| 1186 | {
|
| 1187 | GlStateManager.clear(256);
|
| 1188 |
|
| 1189 | try
|
| 1190 | {
|
| 1191 | this.mc.currentScreen.drawScreen(k1, l1, partialTicks);
|
| 1192 | }
|
| 1193 | catch (Throwable throwable)
|
| 1194 | {
|
| 1195 | CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Rendering screen");
|
| 1196 | CrashReportCategory crashreportcategory = crashreport.makeCategory("Screen render details");
|
| 1197 | crashreportcategory.addCrashSectionCallable("Screen name", new Callable<String>()
|
| 1198 | {
|
| 1199 | public String call() throws Exception
|
| 1200 | {
|
| 1201 | return EntityRenderer.this.mc.currentScreen.getClass().getCanonicalName();
|
| 1202 | }
|
| 1203 | });
|
| 1204 | crashreportcategory.addCrashSectionCallable("Mouse location", new Callable<String>()
|
| 1205 | {
|
| 1206 | public String call() throws Exception
|
| 1207 | {
|
| 1208 | return String.format("Scaled: (%d, %d). Absolute: (%d, %d)", new Object[] {Integer.valueOf(k1), Integer.valueOf(l1), Integer.valueOf(Mouse.getX()), Integer.valueOf(Mouse.getY())});
|
| 1209 | }
|
| 1210 | });
|
| 1211 | crashreportcategory.addCrashSectionCallable("Screen size", new Callable<String>()
|
| 1212 | {
|
| 1213 | public String call() throws Exception
|
| 1214 | {
|
| 1215 | return String.format("Scaled: (%d, %d). Absolute: (%d, %d). Scale factor of %d", new Object[] {Integer.valueOf(scaledresolution.getScaledWidth()), Integer.valueOf(scaledresolution.getScaledHeight()), Integer.valueOf(EntityRenderer.this.mc.displayWidth), Integer.valueOf(EntityRenderer.this.mc.displayHeight), Integer.valueOf(scaledresolution.getScaleFactor())});
|
| 1216 | }
|
| 1217 | });
|
| 1218 | throw new ReportedException(crashreport);
|
| 1219 | }
|
| 1220 | }
|
| 1221 | }
|
| 1222 | }
|
| 1223 |
|
| 1224 | public void renderStreamIndicator(float partialTicks)
|
| 1225 | {
|
| 1226 | this.setupOverlayRendering();
|
| 1227 | this.mc.ingameGUI.renderStreamIndicator(new ScaledResolution(this.mc));
|
| 1228 | }
|
| 1229 |
|
| 1230 | private boolean isDrawBlockOutline()
|
| 1231 | {
|
| 1232 | if (!this.drawBlockOutline)
|
| 1233 | {
|
| 1234 | return false;
|
| 1235 | }
|
| 1236 | else
|
| 1237 | {
|
| 1238 | Entity entity = this.mc.getRenderViewEntity();
|
| 1239 | boolean flag = entity instanceof EntityPlayer && !this.mc.gameSettings.hideGUI;
|
| 1240 |
|
| 1241 | if (flag && !((EntityPlayer)entity).capabilities.allowEdit)
|
| 1242 | {
|
| 1243 | ItemStack itemstack = ((EntityPlayer)entity).getCurrentEquippedItem();
|
| 1244 |
|
| 1245 | if (this.mc.objectMouseOver != null && this.mc.objectMouseOver.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
|
| 1246 | {
|
| 1247 | BlockPos blockpos = this.mc.objectMouseOver.getBlockPos();
|
| 1248 | Block block = this.mc.theWorld.getBlockState(blockpos).getBlock();
|
| 1249 |
|
| 1250 | if (this.mc.playerController.getCurrentGameType() == WorldSettings.GameType.SPECTATOR)
|
| 1251 | {
|
| 1252 | flag = block.hasTileEntity() && this.mc.theWorld.getTileEntity(blockpos) instanceof IInventory;
|
| 1253 | }
|
| 1254 | else
|
| 1255 | {
|
| 1256 | flag = itemstack != null && (itemstack.canDestroy(block) || itemstack.canPlaceOn(block));
|
| 1257 | }
|
| 1258 | }
|
| 1259 | }
|
| 1260 |
|
| 1261 | return flag;
|
| 1262 | }
|
| 1263 | }
|
| 1264 |
|
| 1265 | private void renderWorldDirections(float partialTicks)
|
| 1266 | {
|
| 1267 | if (this.mc.gameSettings.showDebugInfo && !this.mc.gameSettings.hideGUI && !this.mc.thePlayer.hasReducedDebug() && !this.mc.gameSettings.reducedDebugInfo)
|
| 1268 | {
|
| 1269 | Entity entity = this.mc.getRenderViewEntity();
|
| 1270 | GlStateManager.enableBlend();
|
| 1271 | GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
|
| 1272 | GL11.glLineWidth(1.0F);
|
| 1273 | GlStateManager.disableTexture2D();
|
| 1274 | GlStateManager.depthMask(false);
|
| 1275 | GlStateManager.pushMatrix();
|
| 1276 | GlStateManager.matrixMode(5888);
|
| 1277 | GlStateManager.loadIdentity();
|
| 1278 | this.orientCamera(partialTicks);
|
| 1279 | GlStateManager.translate(0.0F, entity.getEyeHeight(), 0.0F);
|
| 1280 | RenderGlobal.drawOutlinedBoundingBox(new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.005D, 1.0E-4D, 1.0E-4D), 255, 0, 0, 255);
|
| 1281 | RenderGlobal.drawOutlinedBoundingBox(new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0E-4D, 1.0E-4D, 0.005D), 0, 0, 255, 255);
|
| 1282 | RenderGlobal.drawOutlinedBoundingBox(new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0E-4D, 0.0033D, 1.0E-4D), 0, 255, 0, 255);
|
| 1283 | GlStateManager.popMatrix();
|
| 1284 | GlStateManager.depthMask(true);
|
| 1285 | GlStateManager.enableTexture2D();
|
| 1286 | GlStateManager.disableBlend();
|
| 1287 | }
|
| 1288 | }
|
| 1289 |
|
| 1290 | public void renderWorld(float partialTicks, long finishTimeNano)
|
| 1291 | {
|
| 1292 | this.updateLightmap(partialTicks);
|
| 1293 |
|
| 1294 | if (this.mc.getRenderViewEntity() == null)
|
| 1295 | {
|
| 1296 | this.mc.setRenderViewEntity(this.mc.thePlayer);
|
| 1297 | }
|
| 1298 |
|
| 1299 | this.getMouseOver(partialTicks);
|
| 1300 | GlStateManager.enableDepth();
|
| 1301 | GlStateManager.enableAlpha();
|
| 1302 | GlStateManager.alphaFunc(516, 0.5F);
|
| 1303 | this.mc.mcProfiler.startSection("center");
|
| 1304 |
|
| 1305 | if (this.mc.gameSettings.anaglyph)
|
| 1306 | {
|
| 1307 | anaglyphField = 0;
|
| 1308 | GlStateManager.colorMask(false, true, true, false);
|
| 1309 | this.renderWorldPass(0, partialTicks, finishTimeNano);
|
| 1310 | anaglyphField = 1;
|
| 1311 | GlStateManager.colorMask(true, false, false, false);
|
| 1312 | this.renderWorldPass(1, partialTicks, finishTimeNano);
|
| 1313 | GlStateManager.colorMask(true, true, true, false);
|
| 1314 | }
|
| 1315 | else
|
| 1316 | {
|
| 1317 | this.renderWorldPass(2, partialTicks, finishTimeNano);
|
| 1318 | }
|
| 1319 |
|
| 1320 | this.mc.mcProfiler.endSection();
|
| 1321 | }
|
| 1322 |
|
| 1323 | private void renderWorldPass(int pass, float partialTicks, long finishTimeNano)
|
| 1324 | {
|
| 1325 | RenderGlobal renderglobal = this.mc.renderGlobal;
|
| 1326 | EffectRenderer effectrenderer = this.mc.effectRenderer;
|
| 1327 | boolean flag = this.isDrawBlockOutline();
|
| 1328 | GlStateManager.enableCull();
|
| 1329 | this.mc.mcProfiler.endStartSection("clear");
|
| 1330 | GlStateManager.viewport(0, 0, this.mc.displayWidth, this.mc.displayHeight);
|
| 1331 | this.updateFogColor(partialTicks);
|
| 1332 | GlStateManager.clear(16640);
|
| 1333 | this.mc.mcProfiler.endStartSection("camera");
|
| 1334 | this.setupCameraTransform(partialTicks, pass);
|
| 1335 | ActiveRenderInfo.updateRenderInfo(this.mc.thePlayer, this.mc.gameSettings.thirdPersonView == 2);
|
| 1336 | this.mc.mcProfiler.endStartSection("frustum");
|
| 1337 | ClippingHelperImpl.getInstance();
|
| 1338 | this.mc.mcProfiler.endStartSection("culling");
|
| 1339 | ICamera icamera = new Frustum();
|
| 1340 | Entity entity = this.mc.getRenderViewEntity();
|
| 1341 | double d0 = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * (double)partialTicks;
|
| 1342 | double d1 = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * (double)partialTicks;
|
| 1343 | double d2 = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * (double)partialTicks;
|
| 1344 | icamera.setPosition(d0, d1, d2);
|
| 1345 |
|
| 1346 | if (this.mc.gameSettings.renderDistanceChunks >= 4)
|
| 1347 | {
|
| 1348 | this.setupFog(-1, partialTicks);
|
| 1349 | this.mc.mcProfiler.endStartSection("sky");
|
| 1350 | GlStateManager.matrixMode(5889);
|
| 1351 | GlStateManager.loadIdentity();
|
| 1352 | Project.gluPerspective(this.getFOVModifier(partialTicks, true), (float)this.mc.displayWidth / (float)this.mc.displayHeight, 0.05F, this.farPlaneDistance * 2.0F);
|
| 1353 | GlStateManager.matrixMode(5888);
|
| 1354 | renderglobal.renderSky(partialTicks, pass);
|
| 1355 | GlStateManager.matrixMode(5889);
|
| 1356 | GlStateManager.loadIdentity();
|
| 1357 | Project.gluPerspective(this.getFOVModifier(partialTicks, true), (float)this.mc.displayWidth / (float)this.mc.displayHeight, 0.05F, this.farPlaneDistance * MathHelper.SQRT_2);
|
| 1358 | GlStateManager.matrixMode(5888);
|
| 1359 | }
|
| 1360 |
|
| 1361 | this.setupFog(0, partialTicks);
|
| 1362 | GlStateManager.shadeModel(7425);
|
| 1363 |
|
| 1364 | if (entity.posY + (double)entity.getEyeHeight() < 128.0D)
|
| 1365 | {
|
| 1366 | this.renderCloudsCheck(renderglobal, partialTicks, pass);
|
| 1367 | }
|
| 1368 |
|
| 1369 | this.mc.mcProfiler.endStartSection("prepareterrain");
|
| 1370 | this.setupFog(0, partialTicks);
|
| 1371 | this.mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
|
| 1372 | RenderHelper.disableStandardItemLighting();
|
| 1373 | this.mc.mcProfiler.endStartSection("terrain_setup");
|
| 1374 | renderglobal.setupTerrain(entity, (double)partialTicks, icamera, this.frameCount++, this.mc.thePlayer.isSpectator());
|
| 1375 |
|
| 1376 | if (pass == 0 || pass == 2)
|
| 1377 | {
|
| 1378 | this.mc.mcProfiler.endStartSection("updatechunks");
|
| 1379 | this.mc.renderGlobal.updateChunks(finishTimeNano);
|
| 1380 | }
|
| 1381 |
|
| 1382 | this.mc.mcProfiler.endStartSection("terrain");
|
| 1383 | GlStateManager.matrixMode(5888);
|
| 1384 | GlStateManager.pushMatrix();
|
| 1385 | GlStateManager.disableAlpha();
|
| 1386 | renderglobal.renderBlockLayer(EnumWorldBlockLayer.SOLID, (double)partialTicks, pass, entity);
|
| 1387 | GlStateManager.enableAlpha();
|
| 1388 | renderglobal.renderBlockLayer(EnumWorldBlockLayer.CUTOUT_MIPPED, (double)partialTicks, pass, entity);
|
| 1389 | this.mc.getTextureManager().getTexture(TextureMap.locationBlocksTexture).setBlurMipmap(false, false);
|
| 1390 | renderglobal.renderBlockLayer(EnumWorldBlockLayer.CUTOUT, (double)partialTicks, pass, entity);
|
| 1391 | this.mc.getTextureManager().getTexture(TextureMap.locationBlocksTexture).restoreLastBlurMipmap();
|
| 1392 | GlStateManager.shadeModel(7424);
|
| 1393 | GlStateManager.alphaFunc(516, 0.1F);
|
| 1394 |
|
| 1395 | if (!this.debugView)
|
| 1396 | {
|
| 1397 | GlStateManager.matrixMode(5888);
|
| 1398 | GlStateManager.popMatrix();
|
| 1399 | GlStateManager.pushMatrix();
|
| 1400 | RenderHelper.enableStandardItemLighting();
|
| 1401 | this.mc.mcProfiler.endStartSection("entities");
|
| 1402 | renderglobal.renderEntities(entity, icamera, partialTicks);
|
| 1403 | RenderHelper.disableStandardItemLighting();
|
| 1404 | this.disableLightmap();
|
| 1405 | GlStateManager.matrixMode(5888);
|
| 1406 | GlStateManager.popMatrix();
|
| 1407 | GlStateManager.pushMatrix();
|
| 1408 |
|
| 1409 | if (this.mc.objectMouseOver != null && entity.isInsideOfMaterial(Material.water) && flag)
|
| 1410 | {
|
| 1411 | EntityPlayer entityplayer = (EntityPlayer)entity;
|
| 1412 | GlStateManager.disableAlpha();
|
| 1413 | this.mc.mcProfiler.endStartSection("outline");
|
| 1414 | renderglobal.drawSelectionBox(entityplayer, this.mc.objectMouseOver, 0, partialTicks);
|
| 1415 | GlStateManager.enableAlpha();
|
| 1416 | }
|
| 1417 | }
|
| 1418 |
|
| 1419 | GlStateManager.matrixMode(5888);
|
| 1420 | GlStateManager.popMatrix();
|
| 1421 |
|
| 1422 | if (flag && this.mc.objectMouseOver != null && !entity.isInsideOfMaterial(Material.water))
|
| 1423 | {
|
| 1424 | EntityPlayer entityplayer1 = (EntityPlayer)entity;
|
| 1425 | GlStateManager.disableAlpha();
|
| 1426 | this.mc.mcProfiler.endStartSection("outline");
|
| 1427 | renderglobal.drawSelectionBox(entityplayer1, this.mc.objectMouseOver, 0, partialTicks);
|
| 1428 | GlStateManager.enableAlpha();
|
| 1429 | }
|
| 1430 |
|
| 1431 | this.mc.mcProfiler.endStartSection("destroyProgress");
|
| 1432 | GlStateManager.enableBlend();
|
| 1433 | GlStateManager.tryBlendFuncSeparate(770, 1, 1, 0);
|
| 1434 | this.mc.getTextureManager().getTexture(TextureMap.locationBlocksTexture).setBlurMipmap(false, false);
|
| 1435 | renderglobal.drawBlockDamageTexture(Tessellator.getInstance(), Tessellator.getInstance().getWorldRenderer(), entity, partialTicks);
|
| 1436 | this.mc.getTextureManager().getTexture(TextureMap.locationBlocksTexture).restoreLastBlurMipmap();
|
| 1437 | GlStateManager.disableBlend();
|
| 1438 |
|
| 1439 | if (!this.debugView)
|
| 1440 | {
|
| 1441 | this.enableLightmap();
|
| 1442 | this.mc.mcProfiler.endStartSection("litParticles");
|
| 1443 | effectrenderer.renderLitParticles(entity, partialTicks);
|
| 1444 | RenderHelper.disableStandardItemLighting();
|
| 1445 | this.setupFog(0, partialTicks);
|
| 1446 | this.mc.mcProfiler.endStartSection("particles");
|
| 1447 | effectrenderer.renderParticles(entity, partialTicks);
|
| 1448 | this.disableLightmap();
|
| 1449 | }
|
| 1450 |
|
| 1451 | GlStateManager.depthMask(false);
|
| 1452 | GlStateManager.enableCull();
|
| 1453 | this.mc.mcProfiler.endStartSection("weather");
|
| 1454 | this.renderRainSnow(partialTicks);
|
| 1455 | GlStateManager.depthMask(true);
|
| 1456 | renderglobal.renderWorldBorder(entity, partialTicks);
|
| 1457 | GlStateManager.disableBlend();
|
| 1458 | GlStateManager.enableCull();
|
| 1459 | GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
|
| 1460 | GlStateManager.alphaFunc(516, 0.1F);
|
| 1461 | this.setupFog(0, partialTicks);
|
| 1462 | GlStateManager.enableBlend();
|
| 1463 | GlStateManager.depthMask(false);
|
| 1464 | this.mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
|
| 1465 | GlStateManager.shadeModel(7425);
|
| 1466 | this.mc.mcProfiler.endStartSection("translucent");
|
| 1467 | renderglobal.renderBlockLayer(EnumWorldBlockLayer.TRANSLUCENT, (double)partialTicks, pass, entity);
|
| 1468 | GlStateManager.shadeModel(7424);
|
| 1469 | GlStateManager.depthMask(true);
|
| 1470 | GlStateManager.enableCull();
|
| 1471 | GlStateManager.disableBlend();
|
| 1472 | GlStateManager.disableFog();
|
| 1473 |
|
| 1474 | if (entity.posY + (double)entity.getEyeHeight() >= 128.0D)
|
| 1475 | {
|
| 1476 | this.mc.mcProfiler.endStartSection("aboveClouds");
|
| 1477 | this.renderCloudsCheck(renderglobal, partialTicks, pass);
|
| 1478 | }
|
| 1479 |
|
| 1480 | this.mc.mcProfiler.endStartSection("hand");
|
| 1481 |
|
| 1482 | if (this.renderHand)
|
| 1483 | {
|
| 1484 | GlStateManager.clear(256);
|
| 1485 | this.renderHand(partialTicks, pass);
|
| 1486 | this.renderWorldDirections(partialTicks);
|
| 1487 | }
|
| 1488 | }
|
| 1489 |
|
| 1490 | private void renderCloudsCheck(RenderGlobal renderGlobalIn, float partialTicks, int pass)
|
| 1491 | {
|
| 1492 | if (this.mc.gameSettings.shouldRenderClouds() != 0)
|
| 1493 | {
|
| 1494 | this.mc.mcProfiler.endStartSection("clouds");
|
| 1495 | GlStateManager.matrixMode(5889);
|
| 1496 | GlStateManager.loadIdentity();
|
| 1497 | Project.gluPerspective(this.getFOVModifier(partialTicks, true), (float)this.mc.displayWidth / (float)this.mc.displayHeight, 0.05F, this.farPlaneDistance * 4.0F);
|
| 1498 | GlStateManager.matrixMode(5888);
|
| 1499 | GlStateManager.pushMatrix();
|
| 1500 | this.setupFog(0, partialTicks);
|
| 1501 | renderGlobalIn.renderClouds(partialTicks, pass);
|
| 1502 | GlStateManager.disableFog();
|
| 1503 | GlStateManager.popMatrix();
|
| 1504 | GlStateManager.matrixMode(5889);
|
| 1505 | GlStateManager.loadIdentity();
|
| 1506 | Project.gluPerspective(this.getFOVModifier(partialTicks, true), (float)this.mc.displayWidth / (float)this.mc.displayHeight, 0.05F, this.farPlaneDistance * MathHelper.SQRT_2);
|
| 1507 | GlStateManager.matrixMode(5888);
|
| 1508 | }
|
| 1509 | }
|
| 1510 |
|
| 1511 | private void addRainParticles()
|
| 1512 | {
|
| 1513 | float f = this.mc.theWorld.getRainStrength(1.0F);
|
| 1514 |
|
| 1515 | if (!this.mc.gameSettings.fancyGraphics)
|
| 1516 | {
|
| 1517 | f /= 2.0F;
|
| 1518 | }
|
| 1519 |
|
| 1520 | if (f != 0.0F)
|
| 1521 | {
|
| 1522 | this.random.setSeed((long)this.rendererUpdateCount * 312987231L);
|
| 1523 | Entity entity = this.mc.getRenderViewEntity();
|
| 1524 | World world = this.mc.theWorld;
|
| 1525 | BlockPos blockpos = new BlockPos(entity);
|
| 1526 | int i = 10;
|
| 1527 | double d0 = 0.0D;
|
| 1528 | double d1 = 0.0D;
|
| 1529 | double d2 = 0.0D;
|
| 1530 | int j = 0;
|
| 1531 | int k = (int)(100.0F * f * f);
|
| 1532 |
|
| 1533 | if (this.mc.gameSettings.particleSetting == 1)
|
| 1534 | {
|
| 1535 | k >>= 1;
|
| 1536 | }
|
| 1537 | else if (this.mc.gameSettings.particleSetting == 2)
|
| 1538 | {
|
| 1539 | k = 0;
|
| 1540 | }
|
| 1541 |
|
| 1542 | for (int l = 0; l < k; ++l)
|
| 1543 | {
|
| 1544 | BlockPos blockpos1 = world.getPrecipitationHeight(blockpos.add(this.random.nextInt(i) - this.random.nextInt(i), 0, this.random.nextInt(i) - this.random.nextInt(i)));
|
| 1545 | BiomeGenBase biomegenbase = world.getBiomeGenForCoords(blockpos1);
|
| 1546 | BlockPos blockpos2 = blockpos1.down();
|
| 1547 | Block block = world.getBlockState(blockpos2).getBlock();
|
| 1548 |
|
| 1549 | if (blockpos1.getY() <= blockpos.getY() + i && blockpos1.getY() >= blockpos.getY() - i && biomegenbase.canRain() && biomegenbase.getFloatTemperature(blockpos1) >= 0.15F)
|
| 1550 | {
|
| 1551 | double d3 = this.random.nextDouble();
|
| 1552 | double d4 = this.random.nextDouble();
|
| 1553 |
|
| 1554 | if (block.getMaterial() == Material.lava)
|
| 1555 | {
|
| 1556 | this.mc.theWorld.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, (double)blockpos1.getX() + d3, (double)((float)blockpos1.getY() + 0.1F) - block.getBlockBoundsMinY(), (double)blockpos1.getZ() + d4, 0.0D, 0.0D, 0.0D, new int[0]);
|
| 1557 | }
|
| 1558 | else if (block.getMaterial() != Material.air)
|
| 1559 | {
|
| 1560 | block.setBlockBoundsBasedOnState(world, blockpos2);
|
| 1561 | ++j;
|
| 1562 |
|
| 1563 | if (this.random.nextInt(j) == 0)
|
| 1564 | {
|
| 1565 | d0 = (double)blockpos2.getX() + d3;
|
| 1566 | d1 = (double)((float)blockpos2.getY() + 0.1F) + block.getBlockBoundsMaxY() - 1.0D;
|
| 1567 | d2 = (double)blockpos2.getZ() + d4;
|
| 1568 | }
|
| 1569 |
|
| 1570 | this.mc.theWorld.spawnParticle(EnumParticleTypes.WATER_DROP, (double)blockpos2.getX() + d3, (double)((float)blockpos2.getY() + 0.1F) + block.getBlockBoundsMaxY(), (double)blockpos2.getZ() + d4, 0.0D, 0.0D, 0.0D, new int[0]);
|
| 1571 | }
|
| 1572 | }
|
| 1573 | }
|
| 1574 |
|
| 1575 | if (j > 0 && this.random.nextInt(3) < this.rainSoundCounter++)
|
| 1576 | {
|
| 1577 | this.rainSoundCounter = 0;
|
| 1578 |
|
| 1579 | if (d1 > (double)(blockpos.getY() + 1) && world.getPrecipitationHeight(blockpos).getY() > MathHelper.floor_float((float)blockpos.getY()))
|
| 1580 | {
|
| 1581 | this.mc.theWorld.playSound(d0, d1, d2, "ambient.weather.rain", 0.1F, 0.5F, false);
|
| 1582 | }
|
| 1583 | else
|
| 1584 | {
|
| 1585 | this.mc.theWorld.playSound(d0, d1, d2, "ambient.weather.rain", 0.2F, 1.0F, false);
|
| 1586 | }
|
| 1587 | }
|
| 1588 | }
|
| 1589 | }
|
| 1590 |
|
| 1591 | /**
|
| 1592 | * Render rain and snow
|
| 1593 | */
|
| 1594 | protected void renderRainSnow(float partialTicks)
|
| 1595 | {
|
| 1596 | float f = this.mc.theWorld.getRainStrength(partialTicks);
|
| 1597 |
|
| 1598 | if (f > 0.0F)
|
| 1599 | {
|
| 1600 | this.enableLightmap();
|
| 1601 | Entity entity = this.mc.getRenderViewEntity();
|
| 1602 | World world = this.mc.theWorld;
|
| 1603 | int i = MathHelper.floor_double(entity.posX);
|
| 1604 | int j = MathHelper.floor_double(entity.posY);
|
| 1605 | int k = MathHelper.floor_double(entity.posZ);
|
| 1606 | Tessellator tessellator = Tessellator.getInstance();
|
| 1607 | WorldRenderer worldrenderer = tessellator.getWorldRenderer();
|
| 1608 | GlStateManager.disableCull();
|
| 1609 | GL11.glNormal3f(0.0F, 1.0F, 0.0F);
|
| 1610 | GlStateManager.enableBlend();
|
| 1611 | GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
|
| 1612 | GlStateManager.alphaFunc(516, 0.1F);
|
| 1613 | double d0 = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * (double)partialTicks;
|
| 1614 | double d1 = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * (double)partialTicks;
|
| 1615 | double d2 = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * (double)partialTicks;
|
| 1616 | int l = MathHelper.floor_double(d1);
|
| 1617 | int i1 = 5;
|
| 1618 |
|
| 1619 | if (this.mc.gameSettings.fancyGraphics)
|
| 1620 | {
|
| 1621 | i1 = 10;
|
| 1622 | }
|
| 1623 |
|
| 1624 | int j1 = -1;
|
| 1625 | float f1 = (float)this.rendererUpdateCount + partialTicks;
|
| 1626 | worldrenderer.setTranslation(-d0, -d1, -d2);
|
| 1627 | GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
| 1628 | BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
|
| 1629 |
|
| 1630 | for (int k1 = k - i1; k1 <= k + i1; ++k1)
|
| 1631 | {
|
| 1632 | for (int l1 = i - i1; l1 <= i + i1; ++l1)
|
| 1633 | {
|
| 1634 | int i2 = (k1 - k + 16) * 32 + l1 - i + 16;
|
| 1635 | double d3 = (double)this.rainXCoords[i2] * 0.5D;
|
| 1636 | double d4 = (double)this.rainYCoords[i2] * 0.5D;
|
| 1637 | blockpos$mutableblockpos.set(l1, 0, k1);
|
| 1638 | BiomeGenBase biomegenbase = world.getBiomeGenForCoords(blockpos$mutableblockpos);
|
| 1639 |
|
| 1640 | if (biomegenbase.canRain() || biomegenbase.getEnableSnow())
|
| 1641 | {
|
| 1642 | int j2 = world.getPrecipitationHeight(blockpos$mutableblockpos).getY();
|
| 1643 | int k2 = j - i1;
|
| 1644 | int l2 = j + i1;
|
| 1645 |
|
| 1646 | if (k2 < j2)
|
| 1647 | {
|
| 1648 | k2 = j2;
|
| 1649 | }
|
| 1650 |
|
| 1651 | if (l2 < j2)
|
| 1652 | {
|
| 1653 | l2 = j2;
|
| 1654 | }
|
| 1655 |
|
| 1656 | int i3 = j2;
|
| 1657 |
|
| 1658 | if (j2 < l)
|
| 1659 | {
|
| 1660 | i3 = l;
|
| 1661 | }
|
| 1662 |
|
| 1663 | if (k2 != l2)
|
| 1664 | {
|
| 1665 | this.random.setSeed((long)(l1 * l1 * 3121 + l1 * 45238971 ^ k1 * k1 * 418711 + k1 * 13761));
|
| 1666 | blockpos$mutableblockpos.set(l1, k2, k1);
|
| 1667 | float f2 = biomegenbase.getFloatTemperature(blockpos$mutableblockpos);
|
| 1668 |
|
| 1669 | if (world.getWorldChunkManager().getTemperatureAtHeight(f2, j2) >= 0.15F)
|
| 1670 | {
|
| 1671 | if (j1 != 0)
|
| 1672 | {
|
| 1673 | if (j1 >= 0)
|
| 1674 | {
|
| 1675 | tessellator.draw();
|
| 1676 | }
|
| 1677 |
|
| 1678 | j1 = 0;
|
| 1679 | this.mc.getTextureManager().bindTexture(locationRainPng);
|
| 1680 | worldrenderer.begin(7, DefaultVertexFormats.PARTICLE_POSITION_TEX_COLOR_LMAP);
|
| 1681 | }
|
| 1682 |
|
| 1683 | double d5 = ((double)(this.rendererUpdateCount + l1 * l1 * 3121 + l1 * 45238971 + k1 * k1 * 418711 + k1 * 13761 & 31) + (double)partialTicks) / 32.0D * (3.0D + this.random.nextDouble());
|
| 1684 | double d6 = (double)((float)l1 + 0.5F) - entity.posX;
|
| 1685 | double d7 = (double)((float)k1 + 0.5F) - entity.posZ;
|
| 1686 | float f3 = MathHelper.sqrt_double(d6 * d6 + d7 * d7) / (float)i1;
|
| 1687 | float f4 = ((1.0F - f3 * f3) * 0.5F + 0.5F) * f;
|
| 1688 | blockpos$mutableblockpos.set(l1, i3, k1);
|
| 1689 | int j3 = world.getCombinedLight(blockpos$mutableblockpos, 0);
|
| 1690 | int k3 = j3 >> 16 & 65535;
|
| 1691 | int l3 = j3 & 65535;
|
| 1692 | worldrenderer.pos((double)l1 - d3 + 0.5D, (double)k2, (double)k1 - d4 + 0.5D).tex(0.0D, (double)k2 * 0.25D + d5).color(1.0F, 1.0F, 1.0F, f4).lightmap(k3, l3).endVertex();
|
| 1693 | worldrenderer.pos((double)l1 + d3 + 0.5D, (double)k2, (double)k1 + d4 + 0.5D).tex(1.0D, (double)k2 * 0.25D + d5).color(1.0F, 1.0F, 1.0F, f4).lightmap(k3, l3).endVertex();
|
| 1694 | worldrenderer.pos((double)l1 + d3 + 0.5D, (double)l2, (double)k1 + d4 + 0.5D).tex(1.0D, (double)l2 * 0.25D + d5).color(1.0F, 1.0F, 1.0F, f4).lightmap(k3, l3).endVertex();
|
| 1695 | worldrenderer.pos((double)l1 - d3 + 0.5D, (double)l2, (double)k1 - d4 + 0.5D).tex(0.0D, (double)l2 * 0.25D + d5).color(1.0F, 1.0F, 1.0F, f4).lightmap(k3, l3).endVertex();
|
| 1696 | }
|
| 1697 | else
|
| 1698 | {
|
| 1699 | if (j1 != 1)
|
| 1700 | {
|
| 1701 | if (j1 >= 0)
|
| 1702 | {
|
| 1703 | tessellator.draw();
|
| 1704 | }
|
| 1705 |
|
| 1706 | j1 = 1;
|
| 1707 | this.mc.getTextureManager().bindTexture(locationSnowPng);
|
| 1708 | worldrenderer.begin(7, DefaultVertexFormats.PARTICLE_POSITION_TEX_COLOR_LMAP);
|
| 1709 | }
|
| 1710 |
|
| 1711 | double d8 = (double)(((float)(this.rendererUpdateCount & 511) + partialTicks) / 512.0F);
|
| 1712 | double d9 = this.random.nextDouble() + (double)f1 * 0.01D * (double)((float)this.random.nextGaussian());
|
| 1713 | double d10 = this.random.nextDouble() + (double)(f1 * (float)this.random.nextGaussian()) * 0.001D;
|
| 1714 | double d11 = (double)((float)l1 + 0.5F) - entity.posX;
|
| 1715 | double d12 = (double)((float)k1 + 0.5F) - entity.posZ;
|
| 1716 | float f6 = MathHelper.sqrt_double(d11 * d11 + d12 * d12) / (float)i1;
|
| 1717 | float f5 = ((1.0F - f6 * f6) * 0.3F + 0.5F) * f;
|
| 1718 | blockpos$mutableblockpos.set(l1, i3, k1);
|
| 1719 | int i4 = (world.getCombinedLight(blockpos$mutableblockpos, 0) * 3 + 15728880) / 4;
|
| 1720 | int j4 = i4 >> 16 & 65535;
|
| 1721 | int k4 = i4 & 65535;
|
| 1722 | worldrenderer.pos((double)l1 - d3 + 0.5D, (double)k2, (double)k1 - d4 + 0.5D).tex(0.0D + d9, (double)k2 * 0.25D + d8 + d10).color(1.0F, 1.0F, 1.0F, f5).lightmap(j4, k4).endVertex();
|
| 1723 | worldrenderer.pos((double)l1 + d3 + 0.5D, (double)k2, (double)k1 + d4 + 0.5D).tex(1.0D + d9, (double)k2 * 0.25D + d8 + d10).color(1.0F, 1.0F, 1.0F, f5).lightmap(j4, k4).endVertex();
|
| 1724 | worldrenderer.pos((double)l1 + d3 + 0.5D, (double)l2, (double)k1 + d4 + 0.5D).tex(1.0D + d9, (double)l2 * 0.25D + d8 + d10).color(1.0F, 1.0F, 1.0F, f5).lightmap(j4, k4).endVertex();
|
| 1725 | worldrenderer.pos((double)l1 - d3 + 0.5D, (double)l2, (double)k1 - d4 + 0.5D).tex(0.0D + d9, (double)l2 * 0.25D + d8 + d10).color(1.0F, 1.0F, 1.0F, f5).lightmap(j4, k4).endVertex();
|
| 1726 | }
|
| 1727 | }
|
| 1728 | }
|
| 1729 | }
|
| 1730 | }
|
| 1731 |
|
| 1732 | if (j1 >= 0)
|
| 1733 | {
|
| 1734 | tessellator.draw();
|
| 1735 | }
|
| 1736 |
|
| 1737 | worldrenderer.setTranslation(0.0D, 0.0D, 0.0D);
|
| 1738 | GlStateManager.enableCull();
|
| 1739 | GlStateManager.disableBlend();
|
| 1740 | GlStateManager.alphaFunc(516, 0.1F);
|
| 1741 | this.disableLightmap();
|
| 1742 | }
|
| 1743 | }
|
| 1744 |
|
| 1745 | /**
|
| 1746 | * Setup orthogonal projection for rendering GUI screen overlays
|
| 1747 | */
|
| 1748 | public void setupOverlayRendering()
|
| 1749 | {
|
| 1750 | ScaledResolution scaledresolution = new ScaledResolution(this.mc);
|
| 1751 | GlStateManager.clear(256);
|
| 1752 | GlStateManager.matrixMode(5889);
|
| 1753 | GlStateManager.loadIdentity();
|
| 1754 | GlStateManager.ortho(0.0D, scaledresolution.getScaledWidth_double(), scaledresolution.getScaledHeight_double(), 0.0D, 1000.0D, 3000.0D);
|
| 1755 | GlStateManager.matrixMode(5888);
|
| 1756 | GlStateManager.loadIdentity();
|
| 1757 | GlStateManager.translate(0.0F, 0.0F, -2000.0F);
|
| 1758 | }
|
| 1759 |
|
| 1760 | /**
|
| 1761 | * calculates fog and calls glClearColor
|
| 1762 | */
|
| 1763 | private void updateFogColor(float partialTicks)
|
| 1764 | {
|
| 1765 | World world = this.mc.theWorld;
|
| 1766 | Entity entity = this.mc.getRenderViewEntity();
|
| 1767 | float f = 0.25F + 0.75F * (float)this.mc.gameSettings.renderDistanceChunks / 32.0F;
|
| 1768 | f = 1.0F - (float)Math.pow((double)f, 0.25D);
|
| 1769 | Vec3 vec3 = world.getSkyColor(this.mc.getRenderViewEntity(), partialTicks);
|
| 1770 | float f1 = (float)vec3.xCoord;
|
| 1771 | float f2 = (float)vec3.yCoord;
|
| 1772 | float f3 = (float)vec3.zCoord;
|
| 1773 | Vec3 vec31 = world.getFogColor(partialTicks);
|
| 1774 | this.fogColorRed = (float)vec31.xCoord;
|
| 1775 | this.fogColorGreen = (float)vec31.yCoord;
|
| 1776 | this.fogColorBlue = (float)vec31.zCoord;
|
| 1777 |
|
| 1778 | if (this.mc.gameSettings.renderDistanceChunks >= 4)
|
| 1779 | {
|
| 1780 | double d0 = -1.0D;
|
| 1781 | Vec3 vec32 = MathHelper.sin(world.getCelestialAngleRadians(partialTicks)) > 0.0F ? new Vec3(d0, 0.0D, 0.0D) : new Vec3(1.0D, 0.0D, 0.0D);
|
| 1782 | float f5 = (float)entity.getLook(partialTicks).dotProduct(vec32);
|
| 1783 |
|
| 1784 | if (f5 < 0.0F)
|
| 1785 | {
|
| 1786 | f5 = 0.0F;
|
| 1787 | }
|
| 1788 |
|
| 1789 | if (f5 > 0.0F)
|
| 1790 | {
|
| 1791 | float[] afloat = world.provider.calcSunriseSunsetColors(world.getCelestialAngle(partialTicks), partialTicks);
|
| 1792 |
|
| 1793 | if (afloat != null)
|
| 1794 | {
|
| 1795 | f5 = f5 * afloat[3];
|
| 1796 | this.fogColorRed = this.fogColorRed * (1.0F - f5) + afloat[0] * f5;
|
| 1797 | this.fogColorGreen = this.fogColorGreen * (1.0F - f5) + afloat[1] * f5;
|
| 1798 | this.fogColorBlue = this.fogColorBlue * (1.0F - f5) + afloat[2] * f5;
|
| 1799 | }
|
| 1800 | }
|
| 1801 | }
|
| 1802 |
|
| 1803 | this.fogColorRed += (f1 - this.fogColorRed) * f;
|
| 1804 | this.fogColorGreen += (f2 - this.fogColorGreen) * f;
|
| 1805 | this.fogColorBlue += (f3 - this.fogColorBlue) * f;
|
| 1806 | float f8 = world.getRainStrength(partialTicks);
|
| 1807 |
|
| 1808 | if (f8 > 0.0F)
|
| 1809 | {
|
| 1810 | float f4 = 1.0F - f8 * 0.5F;
|
| 1811 | float f10 = 1.0F - f8 * 0.4F;
|
| 1812 | this.fogColorRed *= f4;
|
| 1813 | this.fogColorGreen *= f4;
|
| 1814 | this.fogColorBlue *= f10;
|
| 1815 | }
|
| 1816 |
|
| 1817 | float f9 = world.getThunderStrength(partialTicks);
|
| 1818 |
|
| 1819 | if (f9 > 0.0F)
|
| 1820 | {
|
| 1821 | float f11 = 1.0F - f9 * 0.5F;
|
| 1822 | this.fogColorRed *= f11;
|
| 1823 | this.fogColorGreen *= f11;
|
| 1824 | this.fogColorBlue *= f11;
|
| 1825 | }
|
| 1826 |
|
| 1827 | Block block = ActiveRenderInfo.getBlockAtEntityViewpoint(this.mc.theWorld, entity, partialTicks);
|
| 1828 |
|
| 1829 | if (this.cloudFog)
|
| 1830 | {
|
| 1831 | Vec3 vec33 = world.getCloudColour(partialTicks);
|
| 1832 | this.fogColorRed = (float)vec33.xCoord;
|
| 1833 | this.fogColorGreen = (float)vec33.yCoord;
|
| 1834 | this.fogColorBlue = (float)vec33.zCoord;
|
| 1835 | }
|
| 1836 | else if (block.getMaterial() == Material.water)
|
| 1837 | {
|
| 1838 | float f12 = (float)EnchantmentHelper.getRespiration(entity) * 0.2F;
|
| 1839 |
|
| 1840 | if (entity instanceof EntityLivingBase && ((EntityLivingBase)entity).isPotionActive(Potion.waterBreathing))
|
| 1841 | {
|
| 1842 | f12 = f12 * 0.3F + 0.6F;
|
| 1843 | }
|
| 1844 |
|
| 1845 | this.fogColorRed = 0.02F + f12;
|
| 1846 | this.fogColorGreen = 0.02F + f12;
|
| 1847 | this.fogColorBlue = 0.2F + f12;
|
| 1848 | }
|
| 1849 | else if (block.getMaterial() == Material.lava)
|
| 1850 | {
|
| 1851 | this.fogColorRed = 0.6F;
|
| 1852 | this.fogColorGreen = 0.1F;
|
| 1853 | this.fogColorBlue = 0.0F;
|
| 1854 | }
|
| 1855 |
|
| 1856 | float f13 = this.fogColor2 + (this.fogColor1 - this.fogColor2) * partialTicks;
|
| 1857 | this.fogColorRed *= f13;
|
| 1858 | this.fogColorGreen *= f13;
|
| 1859 | this.fogColorBlue *= f13;
|
| 1860 | double d1 = (entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * (double)partialTicks) * world.provider.getVoidFogYFactor();
|
| 1861 |
|
| 1862 | if (entity instanceof EntityLivingBase && ((EntityLivingBase)entity).isPotionActive(Potion.blindness))
|
| 1863 | {
|
| 1864 | int i = ((EntityLivingBase)entity).getActivePotionEffect(Potion.blindness).getDuration();
|
| 1865 |
|
| 1866 | if (i < 20)
|
| 1867 | {
|
| 1868 | d1 *= (double)(1.0F - (float)i / 20.0F);
|
| 1869 | }
|
| 1870 | else
|
| 1871 | {
|
| 1872 | d1 = 0.0D;
|
| 1873 | }
|
| 1874 | }
|
| 1875 |
|
| 1876 | if (d1 < 1.0D)
|
| 1877 | {
|
| 1878 | if (d1 < 0.0D)
|
| 1879 | {
|
| 1880 | d1 = 0.0D;
|
| 1881 | }
|
| 1882 |
|
| 1883 | d1 = d1 * d1;
|
| 1884 | this.fogColorRed = (float)((double)this.fogColorRed * d1);
|
| 1885 | this.fogColorGreen = (float)((double)this.fogColorGreen * d1);
|
| 1886 | this.fogColorBlue = (float)((double)this.fogColorBlue * d1);
|
| 1887 | }
|
| 1888 |
|
| 1889 | if (this.bossColorModifier > 0.0F)
|
| 1890 | {
|
| 1891 | float f14 = this.bossColorModifierPrev + (this.bossColorModifier - this.bossColorModifierPrev) * partialTicks;
|
| 1892 | this.fogColorRed = this.fogColorRed * (1.0F - f14) + this.fogColorRed * 0.7F * f14;
|
| 1893 | this.fogColorGreen = this.fogColorGreen * (1.0F - f14) + this.fogColorGreen * 0.6F * f14;
|
| 1894 | this.fogColorBlue = this.fogColorBlue * (1.0F - f14) + this.fogColorBlue * 0.6F * f14;
|
| 1895 | }
|
| 1896 |
|
| 1897 | if (entity instanceof EntityLivingBase && ((EntityLivingBase)entity).isPotionActive(Potion.nightVision))
|
| 1898 | {
|
| 1899 | float f15 = this.getNightVisionBrightness((EntityLivingBase)entity, partialTicks);
|
| 1900 | float f6 = 1.0F / this.fogColorRed;
|
| 1901 |
|
| 1902 | if (f6 > 1.0F / this.fogColorGreen)
|
| 1903 | {
|
| 1904 | f6 = 1.0F / this.fogColorGreen;
|
| 1905 | }
|
| 1906 |
|
| 1907 | if (f6 > 1.0F / this.fogColorBlue)
|
| 1908 | {
|
| 1909 | f6 = 1.0F / this.fogColorBlue;
|
| 1910 | }
|
| 1911 |
|
| 1912 | this.fogColorRed = this.fogColorRed * (1.0F - f15) + this.fogColorRed * f6 * f15;
|
| 1913 | this.fogColorGreen = this.fogColorGreen * (1.0F - f15) + this.fogColorGreen * f6 * f15;
|
| 1914 | this.fogColorBlue = this.fogColorBlue * (1.0F - f15) + this.fogColorBlue * f6 * f15;
|
| 1915 | }
|
| 1916 |
|
| 1917 | if (this.mc.gameSettings.anaglyph)
|
| 1918 | {
|
| 1919 | float f16 = (this.fogColorRed * 30.0F + this.fogColorGreen * 59.0F + this.fogColorBlue * 11.0F) / 100.0F;
|
| 1920 | float f17 = (this.fogColorRed * 30.0F + this.fogColorGreen * 70.0F) / 100.0F;
|
| 1921 | float f7 = (this.fogColorRed * 30.0F + this.fogColorBlue * 70.0F) / 100.0F;
|
| 1922 | this.fogColorRed = f16;
|
| 1923 | this.fogColorGreen = f17;
|
| 1924 | this.fogColorBlue = f7;
|
| 1925 | }
|
| 1926 |
|
| 1927 | GlStateManager.clearColor(this.fogColorRed, this.fogColorGreen, this.fogColorBlue, 0.0F);
|
| 1928 | }
|
| 1929 |
|
| 1930 | /**
|
| 1931 | * 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
|
| 1932 | * distance and is used for sky rendering.
|
| 1933 | *
|
| 1934 | * @param startCoords If is -1 the fog start at 0.0
|
| 1935 | */
|
| 1936 | private void setupFog(int startCoords, float partialTicks)
|
| 1937 | {
|
| 1938 | Entity entity = this.mc.getRenderViewEntity();
|
| 1939 | boolean flag = false;
|
| 1940 |
|
| 1941 | if (entity instanceof EntityPlayer)
|
| 1942 | {
|
| 1943 | flag = ((EntityPlayer)entity).capabilities.isCreativeMode;
|
| 1944 | }
|
| 1945 |
|
| 1946 | GL11.glFog(GL11.GL_FOG_COLOR, (FloatBuffer)this.setFogColorBuffer(this.fogColorRed, this.fogColorGreen, this.fogColorBlue, 1.0F));
|
| 1947 | GL11.glNormal3f(0.0F, -1.0F, 0.0F);
|
| 1948 | GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
| 1949 | Block block = ActiveRenderInfo.getBlockAtEntityViewpoint(this.mc.theWorld, entity, partialTicks);
|
| 1950 |
|
| 1951 | if (entity instanceof EntityLivingBase && ((EntityLivingBase)entity).isPotionActive(Potion.blindness))
|
| 1952 | {
|
| 1953 | float f1 = 5.0F;
|
| 1954 | int i = ((EntityLivingBase)entity).getActivePotionEffect(Potion.blindness).getDuration();
|
| 1955 |
|
| 1956 | if (i < 20)
|
| 1957 | {
|
| 1958 | f1 = 5.0F + (this.farPlaneDistance - 5.0F) * (1.0F - (float)i / 20.0F);
|
| 1959 | }
|
| 1960 |
|
| 1961 | GlStateManager.setFog(9729);
|
| 1962 |
|
| 1963 | if (startCoords == -1)
|
| 1964 | {
|
| 1965 | GlStateManager.setFogStart(0.0F);
|
| 1966 | GlStateManager.setFogEnd(f1 * 0.8F);
|
| 1967 | }
|
| 1968 | else
|
| 1969 | {
|
| 1970 | GlStateManager.setFogStart(f1 * 0.25F);
|
| 1971 | GlStateManager.setFogEnd(f1);
|
| 1972 | }
|
| 1973 |
|
| 1974 | if (GLContext.getCapabilities().GL_NV_fog_distance)
|
| 1975 | {
|
| 1976 | GL11.glFogi(34138, 34139);
|
| 1977 | }
|
| 1978 | }
|
| 1979 | else if (this.cloudFog)
|
| 1980 | {
|
| 1981 | GlStateManager.setFog(2048);
|
| 1982 | GlStateManager.setFogDensity(0.1F);
|
| 1983 | }
|
| 1984 | else if (block.getMaterial() == Material.water)
|
| 1985 | {
|
| 1986 | GlStateManager.setFog(2048);
|
| 1987 |
|
| 1988 | if (entity instanceof EntityLivingBase && ((EntityLivingBase)entity).isPotionActive(Potion.waterBreathing))
|
| 1989 | {
|
| 1990 | GlStateManager.setFogDensity(0.01F);
|
| 1991 | }
|
| 1992 | else
|
| 1993 | {
|
| 1994 | GlStateManager.setFogDensity(0.1F - (float)EnchantmentHelper.getRespiration(entity) * 0.03F);
|
| 1995 | }
|
| 1996 | }
|
| 1997 | else if (block.getMaterial() == Material.lava)
|
| 1998 | {
|
| 1999 | GlStateManager.setFog(2048);
|
| 2000 | GlStateManager.setFogDensity(2.0F);
|
| 2001 | }
|
| 2002 | else
|
| 2003 | {
|
| 2004 | float f = this.farPlaneDistance;
|
| 2005 | GlStateManager.setFog(9729);
|
| 2006 |
|
| 2007 | if (startCoords == -1)
|
| 2008 | {
|
| 2009 | GlStateManager.setFogStart(0.0F);
|
| 2010 | GlStateManager.setFogEnd(f);
|
| 2011 | }
|
| 2012 | else
|
| 2013 | {
|
| 2014 | GlStateManager.setFogStart(f * 0.75F);
|
| 2015 | GlStateManager.setFogEnd(f);
|
| 2016 | }
|
| 2017 |
|
| 2018 | if (GLContext.getCapabilities().GL_NV_fog_distance)
|
| 2019 | {
|
| 2020 | GL11.glFogi(34138, 34139);
|
| 2021 | }
|
| 2022 |
|
| 2023 | if (this.mc.theWorld.provider.doesXZShowFog((int)entity.posX, (int)entity.posZ))
|
| 2024 | {
|
| 2025 | GlStateManager.setFogStart(f * 0.05F);
|
| 2026 | GlStateManager.setFogEnd(Math.min(f, 192.0F) * 0.5F);
|
| 2027 | }
|
| 2028 | }
|
| 2029 |
|
| 2030 | GlStateManager.enableColorMaterial();
|
| 2031 | GlStateManager.enableFog();
|
| 2032 | GlStateManager.colorMaterial(1028, 4608);
|
| 2033 | }
|
| 2034 |
|
| 2035 | /**
|
| 2036 | * Update and return fogColorBuffer with the RGBA values passed as arguments
|
| 2037 | */
|
| 2038 | private FloatBuffer setFogColorBuffer(float red, float green, float blue, float alpha)
|
| 2039 | {
|
| 2040 | this.fogColorBuffer.clear();
|
| 2041 | this.fogColorBuffer.put(red).put(green).put(blue).put(alpha);
|
| 2042 | this.fogColorBuffer.flip();
|
| 2043 | return this.fogColorBuffer;
|
| 2044 | }
|
| 2045 |
|
| 2046 | public MapItemRenderer getMapItemRenderer()
|
| 2047 | {
|
| 2048 | return this.theMapItemRenderer;
|
| 2049 | }
|
| 2050 | }
|
| 2051 |
|