Advertisement
TNT_Block

RenderGlobal

Dec 10th, 2019
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 120.28 KB | None | 0 0
  1. package net.minecraft.client.renderer;
  2.  
  3. import com.google.common.collect.Lists;
  4. import com.google.common.collect.Maps;
  5. import com.google.common.collect.Sets;
  6. import com.google.gson.JsonSyntaxException;
  7.  
  8. import de.cryptonicdev.cryptonic.module.render.PlayerESPMod;
  9.  
  10. import java.io.IOException;
  11. import java.util.ArrayDeque;
  12. import java.util.ArrayList;
  13. import java.util.Arrays;
  14. import java.util.Collection;
  15. import java.util.Collections;
  16. import java.util.Deque;
  17. import java.util.EnumSet;
  18. import java.util.HashSet;
  19. import java.util.Iterator;
  20. import java.util.LinkedHashSet;
  21. import java.util.List;
  22. import java.util.Map;
  23. import java.util.Random;
  24. import java.util.Set;
  25. import java.util.concurrent.Callable;
  26. import net.minecraft.block.Block;
  27. import net.minecraft.block.BlockChest;
  28. import net.minecraft.block.BlockEnderChest;
  29. import net.minecraft.block.BlockSign;
  30. import net.minecraft.block.BlockSkull;
  31. import net.minecraft.block.material.Material;
  32. import net.minecraft.block.state.IBlockState;
  33. import net.minecraft.client.Minecraft;
  34. import net.minecraft.client.audio.ISound;
  35. import net.minecraft.client.audio.PositionedSoundRecord;
  36. import net.minecraft.client.gui.FontRenderer;
  37. import net.minecraft.client.multiplayer.WorldClient;
  38. import net.minecraft.client.particle.EntityFX;
  39. import net.minecraft.client.renderer.chunk.ChunkRenderDispatcher;
  40. import net.minecraft.client.renderer.chunk.CompiledChunk;
  41. import net.minecraft.client.renderer.chunk.IRenderChunkFactory;
  42. import net.minecraft.client.renderer.chunk.ListChunkFactory;
  43. import net.minecraft.client.renderer.chunk.RenderChunk;
  44. import net.minecraft.client.renderer.chunk.VboChunkFactory;
  45. import net.minecraft.client.renderer.chunk.VisGraph;
  46. import net.minecraft.client.renderer.culling.ClippingHelper;
  47. import net.minecraft.client.renderer.culling.ClippingHelperImpl;
  48. import net.minecraft.client.renderer.culling.Frustum;
  49. import net.minecraft.client.renderer.culling.ICamera;
  50. import net.minecraft.client.renderer.entity.RenderManager;
  51. import net.minecraft.client.renderer.texture.TextureAtlasSprite;
  52. import net.minecraft.client.renderer.texture.TextureManager;
  53. import net.minecraft.client.renderer.texture.TextureMap;
  54. import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
  55. import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
  56. import net.minecraft.client.renderer.vertex.VertexBuffer;
  57. import net.minecraft.client.renderer.vertex.VertexFormat;
  58. import net.minecraft.client.renderer.vertex.VertexFormatElement;
  59. import net.minecraft.client.resources.IResourceManager;
  60. import net.minecraft.client.resources.IResourceManagerReloadListener;
  61. import net.minecraft.client.shader.Framebuffer;
  62. import net.minecraft.client.shader.ShaderGroup;
  63. import net.minecraft.client.shader.ShaderLinkHelper;
  64. import net.minecraft.crash.CrashReport;
  65. import net.minecraft.crash.CrashReportCategory;
  66. import net.minecraft.entity.Entity;
  67. import net.minecraft.entity.EntityLivingBase;
  68. import net.minecraft.entity.item.EntityItemFrame;
  69. import net.minecraft.entity.player.EntityPlayer;
  70. import net.minecraft.entity.projectile.EntityWitherSkull;
  71. import net.minecraft.init.Blocks;
  72. import net.minecraft.init.Items;
  73. import net.minecraft.item.Item;
  74. import net.minecraft.item.ItemDye;
  75. import net.minecraft.item.ItemRecord;
  76. import net.minecraft.tileentity.TileEntity;
  77. import net.minecraft.tileentity.TileEntityChest;
  78. import net.minecraft.tileentity.TileEntitySign;
  79. import net.minecraft.util.AxisAlignedBB;
  80. import net.minecraft.util.BlockPos;
  81. import net.minecraft.util.ClassInheritanceMultiMap;
  82. import net.minecraft.util.EnumFacing;
  83. import net.minecraft.util.EnumParticleTypes;
  84. import net.minecraft.util.EnumWorldBlockLayer;
  85. import net.minecraft.util.MathHelper;
  86. import net.minecraft.util.Matrix4f;
  87. import net.minecraft.util.MovingObjectPosition;
  88. import net.minecraft.util.ReportedException;
  89. import net.minecraft.util.ResourceLocation;
  90. import net.minecraft.util.Vec3;
  91. import net.minecraft.util.Vector3d;
  92. import net.minecraft.world.IWorldAccess;
  93. import net.minecraft.world.WorldProvider;
  94. import net.minecraft.world.border.WorldBorder;
  95. import net.minecraft.world.chunk.Chunk;
  96. import optifine.ChunkUtils;
  97. import optifine.CloudRenderer;
  98. import optifine.Config;
  99. import optifine.CustomColors;
  100. import optifine.CustomSky;
  101. import optifine.DynamicLights;
  102. import optifine.Lagometer;
  103. import optifine.RandomMobs;
  104. import optifine.Reflector;
  105. import optifine.RenderInfoLazy;
  106.  
  107. import org.apache.logging.log4j.LogManager;
  108. import org.apache.logging.log4j.Logger;
  109. import org.lwjgl.input.Keyboard;
  110. import org.lwjgl.opengl.GL11;
  111. import org.lwjgl.util.vector.Vector3f;
  112. import org.lwjgl.util.vector.Vector4f;
  113. import shadersmod.client.Shaders;
  114. import shadersmod.client.ShadersRender;
  115. import shadersmod.client.ShadowUtils;
  116.  
  117. public class RenderGlobal implements IWorldAccess, IResourceManagerReloadListener {
  118. private static final Logger logger = LogManager.getLogger();
  119. private static final ResourceLocation locationMoonPhasesPng = new ResourceLocation(
  120. "textures/environment/moon_phases.png");
  121. private static final ResourceLocation locationSunPng = new ResourceLocation("textures/environment/sun.png");
  122. private static final ResourceLocation locationCloudsPng = new ResourceLocation("textures/environment/clouds.png");
  123. private static final ResourceLocation locationEndSkyPng = new ResourceLocation("textures/environment/end_sky.png");
  124. private static final ResourceLocation locationForcefieldPng = new ResourceLocation("textures/misc/forcefield.png");
  125.  
  126. /** A reference to the Minecraft object. */
  127. public final Minecraft mc;
  128.  
  129. /** The RenderEngine instance used by RenderGlobal */
  130. private final TextureManager renderEngine;
  131. private final RenderManager renderManager;
  132. private WorldClient theWorld;
  133. private Set chunksToUpdate = Sets.newLinkedHashSet();
  134.  
  135. /** List of OpenGL lists for the current render pass */
  136. private List renderInfos = Lists.newArrayListWithCapacity(69696);
  137. private final Set field_181024_n = Sets.newHashSet();
  138. private ViewFrustum viewFrustum;
  139.  
  140. /** The star GL Call list */
  141. private int starGLCallList = -1;
  142.  
  143. /** OpenGL sky list */
  144. private int glSkyList = -1;
  145.  
  146. /** OpenGL sky list 2 */
  147. private int glSkyList2 = -1;
  148. private VertexFormat vertexBufferFormat;
  149. private VertexBuffer starVBO;
  150. private VertexBuffer skyVBO;
  151. private VertexBuffer sky2VBO;
  152.  
  153. /**
  154. * counts the cloud render updates. Used with mod to stagger some updates
  155. */
  156. private int cloudTickCounter;
  157.  
  158. /**
  159. * Stores blocks currently being broken. Key is entity ID of the thing doing the
  160. * breaking. Value is a DestroyBlockProgress
  161. */
  162. public final Map damagedBlocks = Maps.newHashMap();
  163.  
  164. /** Currently playing sounds. Type: HashMap<ChunkCoordinates, ISound> */
  165. private final Map mapSoundPositions = Maps.newHashMap();
  166. private final TextureAtlasSprite[] destroyBlockIcons = new TextureAtlasSprite[10];
  167. private Framebuffer entityOutlineFramebuffer;
  168.  
  169. /** Stores the shader group for the entity_outline shader */
  170. private ShaderGroup entityOutlineShader;
  171. private double frustumUpdatePosX = Double.MIN_VALUE;
  172. private double frustumUpdatePosY = Double.MIN_VALUE;
  173. private double frustumUpdatePosZ = Double.MIN_VALUE;
  174. private int frustumUpdatePosChunkX = Integer.MIN_VALUE;
  175. private int frustumUpdatePosChunkY = Integer.MIN_VALUE;
  176. private int frustumUpdatePosChunkZ = Integer.MIN_VALUE;
  177. private double lastViewEntityX = Double.MIN_VALUE;
  178. private double lastViewEntityY = Double.MIN_VALUE;
  179. private double lastViewEntityZ = Double.MIN_VALUE;
  180. private double lastViewEntityPitch = Double.MIN_VALUE;
  181. private double lastViewEntityYaw = Double.MIN_VALUE;
  182. private final ChunkRenderDispatcher renderDispatcher = new ChunkRenderDispatcher();
  183. private ChunkRenderContainer renderContainer;
  184. private int renderDistanceChunks = -1;
  185.  
  186. /** Render entities startup counter (init value=2) */
  187. private int renderEntitiesStartupCounter = 2;
  188.  
  189. /** Count entities total */
  190. private int countEntitiesTotal;
  191.  
  192. /** Count entities rendered */
  193. private int countEntitiesRendered;
  194.  
  195. /** Count entities hidden */
  196. private int countEntitiesHidden;
  197. private boolean debugFixTerrainFrustum = false;
  198. private ClippingHelper debugFixedClippingHelper;
  199. private final Vector4f[] debugTerrainMatrix = new Vector4f[8];
  200. private final Vector3d debugTerrainFrustumPosition = new Vector3d();
  201. private boolean vboEnabled = false;
  202. IRenderChunkFactory renderChunkFactory;
  203. private double prevRenderSortX;
  204. private double prevRenderSortY;
  205. private double prevRenderSortZ;
  206. public boolean displayListEntitiesDirty = true;
  207. private static final String __OBFID = "CL_00000954";
  208. private CloudRenderer cloudRenderer;
  209. public Entity renderedEntity;
  210. public Set chunksToResortTransparency = new LinkedHashSet();
  211. public Set chunksToUpdateForced = new LinkedHashSet();
  212. private Deque visibilityDeque = new ArrayDeque();
  213. private List renderInfosEntities = new ArrayList(1024);
  214. private List renderInfosTileEntities = new ArrayList(1024);
  215. private List renderInfosNormal = new ArrayList(1024);
  216. private List renderInfosEntitiesNormal = new ArrayList(1024);
  217. private List renderInfosTileEntitiesNormal = new ArrayList(1024);
  218. private List renderInfosShadow = new ArrayList(1024);
  219. private List renderInfosEntitiesShadow = new ArrayList(1024);
  220. private List renderInfosTileEntitiesShadow = new ArrayList(1024);
  221. private int renderDistance = 0;
  222. private int renderDistanceSq = 0;
  223. private static final Set SET_ALL_FACINGS = Collections
  224. .unmodifiableSet(new HashSet(Arrays.asList(EnumFacing.VALUES)));
  225. private int countTileEntitiesRendered;
  226.  
  227. public RenderGlobal(Minecraft mcIn) {
  228. this.cloudRenderer = new CloudRenderer(mcIn);
  229. this.mc = mcIn;
  230. this.renderManager = mcIn.getRenderManager();
  231. this.renderEngine = mcIn.getTextureManager();
  232. this.renderEngine.bindTexture(locationForcefieldPng);
  233. GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT);
  234. GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT);
  235. GlStateManager.bindTexture(0);
  236. this.updateDestroyBlockIcons();
  237. this.vboEnabled = OpenGlHelper.useVbo();
  238.  
  239. if (this.vboEnabled) {
  240. this.renderContainer = new VboRenderList();
  241. this.renderChunkFactory = new VboChunkFactory();
  242. } else {
  243. this.renderContainer = new RenderList();
  244. this.renderChunkFactory = new ListChunkFactory();
  245. }
  246.  
  247. this.vertexBufferFormat = new VertexFormat();
  248. this.vertexBufferFormat.func_181721_a(new VertexFormatElement(0, VertexFormatElement.EnumType.FLOAT,
  249. VertexFormatElement.EnumUsage.POSITION, 3));
  250. this.generateStars();
  251. this.generateSky();
  252. this.generateSky2();
  253. }
  254.  
  255. public void onResourceManagerReload(IResourceManager resourceManager) {
  256. this.updateDestroyBlockIcons();
  257. }
  258.  
  259. private void updateDestroyBlockIcons() {
  260. TextureMap texturemap = this.mc.getTextureMapBlocks();
  261.  
  262. for (int i = 0; i < this.destroyBlockIcons.length; ++i) {
  263. this.destroyBlockIcons[i] = texturemap.getAtlasSprite("minecraft:blocks/destroy_stage_" + i);
  264. }
  265. }
  266.  
  267. /**
  268. * Creates the entity outline shader to be stored in
  269. * RenderGlobal.entityOutlineShader
  270. */
  271. public void makeEntityOutlineShader() {
  272. if (OpenGlHelper.shadersSupported) {
  273. if (ShaderLinkHelper.getStaticShaderLinkHelper() == null) {
  274. ShaderLinkHelper.setNewStaticShaderLinkHelper();
  275. }
  276.  
  277. ResourceLocation resourcelocation = new ResourceLocation("shaders/post/entity_outline.json");
  278.  
  279. try {
  280. this.entityOutlineShader = new ShaderGroup(this.mc.getTextureManager(), this.mc.getResourceManager(),
  281. this.mc.getFramebuffer(), resourcelocation);
  282. this.entityOutlineShader.createBindFramebuffers(this.mc.displayWidth, this.mc.displayHeight);
  283. this.entityOutlineFramebuffer = this.entityOutlineShader.getFramebufferRaw("final");
  284. } catch (IOException ioexception) {
  285. logger.warn((String) ("Failed to load shader: " + resourcelocation), (Throwable) ioexception);
  286. this.entityOutlineShader = null;
  287. this.entityOutlineFramebuffer = null;
  288. } catch (JsonSyntaxException jsonsyntaxexception) {
  289. logger.warn((String) ("Failed to load shader: " + resourcelocation), (Throwable) jsonsyntaxexception);
  290. this.entityOutlineShader = null;
  291. this.entityOutlineFramebuffer = null;
  292. }
  293. } else {
  294. this.entityOutlineShader = null;
  295. this.entityOutlineFramebuffer = null;
  296. }
  297. }
  298.  
  299. public void renderEntityOutlineFramebuffer() {
  300. if (this.isRenderEntityOutlines()) {
  301. GlStateManager.enableBlend();
  302. GlStateManager.tryBlendFuncSeparate(770, 771, 0, 1);
  303. this.entityOutlineFramebuffer.framebufferRenderExt(this.mc.displayWidth, this.mc.displayHeight, false);
  304. GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
  305. GlStateManager.disableBlend();
  306. }
  307. }
  308.  
  309. protected boolean isRenderEntityOutlines() {
  310. return !Config.isFastRender() && !Config.isShaders() && !Config.isAntialiasing()
  311. ? this.entityOutlineFramebuffer != null && this.entityOutlineShader != null && this.mc.thePlayer != null
  312. && this.mc.thePlayer.isSpectator() && this.mc.gameSettings.keyBindSpectatorOutlines.isKeyDown()
  313. : false;
  314. }
  315.  
  316. private void generateSky2() {
  317. Tessellator tessellator = Tessellator.getInstance();
  318. WorldRenderer worldrenderer = tessellator.getWorldRenderer();
  319.  
  320. if (this.sky2VBO != null) {
  321. this.sky2VBO.deleteGlBuffers();
  322. }
  323.  
  324. if (this.glSkyList2 >= 0) {
  325. GLAllocation.deleteDisplayLists(this.glSkyList2);
  326. this.glSkyList2 = -1;
  327. }
  328.  
  329. if (this.vboEnabled) {
  330. this.sky2VBO = new VertexBuffer(this.vertexBufferFormat);
  331. this.renderSky(worldrenderer, -16.0F, true);
  332. worldrenderer.finishDrawing();
  333. worldrenderer.reset();
  334. this.sky2VBO.func_181722_a(worldrenderer.getByteBuffer());
  335. } else {
  336. this.glSkyList2 = GLAllocation.generateDisplayLists(1);
  337. GL11.glNewList(this.glSkyList2, GL11.GL_COMPILE);
  338. this.renderSky(worldrenderer, -16.0F, true);
  339. tessellator.draw();
  340. GL11.glEndList();
  341. }
  342. }
  343.  
  344. private void generateSky() {
  345. Tessellator tessellator = Tessellator.getInstance();
  346. WorldRenderer worldrenderer = tessellator.getWorldRenderer();
  347.  
  348. if (this.skyVBO != null) {
  349. this.skyVBO.deleteGlBuffers();
  350. }
  351.  
  352. if (this.glSkyList >= 0) {
  353. GLAllocation.deleteDisplayLists(this.glSkyList);
  354. this.glSkyList = -1;
  355. }
  356.  
  357. if (this.vboEnabled) {
  358. this.skyVBO = new VertexBuffer(this.vertexBufferFormat);
  359. this.renderSky(worldrenderer, 16.0F, false);
  360. worldrenderer.finishDrawing();
  361. worldrenderer.reset();
  362. this.skyVBO.func_181722_a(worldrenderer.getByteBuffer());
  363. } else {
  364. this.glSkyList = GLAllocation.generateDisplayLists(1);
  365. GL11.glNewList(this.glSkyList, GL11.GL_COMPILE);
  366. this.renderSky(worldrenderer, 16.0F, false);
  367. tessellator.draw();
  368. GL11.glEndList();
  369. }
  370. }
  371.  
  372. private void renderSky(WorldRenderer worldRendererIn, float p_174968_2_, boolean p_174968_3_) {
  373. boolean flag = true;
  374. boolean flag1 = true;
  375. worldRendererIn.begin(7, DefaultVertexFormats.POSITION);
  376.  
  377. for (int i = -384; i <= 384; i += 64) {
  378. for (int j = -384; j <= 384; j += 64) {
  379. float f = (float) i;
  380. float f1 = (float) (i + 64);
  381.  
  382. if (p_174968_3_) {
  383. f1 = (float) i;
  384. f = (float) (i + 64);
  385. }
  386.  
  387. worldRendererIn.pos((double) f, (double) p_174968_2_, (double) j).endVertex();
  388. worldRendererIn.pos((double) f1, (double) p_174968_2_, (double) j).endVertex();
  389. worldRendererIn.pos((double) f1, (double) p_174968_2_, (double) (j + 64)).endVertex();
  390. worldRendererIn.pos((double) f, (double) p_174968_2_, (double) (j + 64)).endVertex();
  391. }
  392. }
  393. }
  394.  
  395. private void generateStars() {
  396. Tessellator tessellator = Tessellator.getInstance();
  397. WorldRenderer worldrenderer = tessellator.getWorldRenderer();
  398.  
  399. if (this.starVBO != null) {
  400. this.starVBO.deleteGlBuffers();
  401. }
  402.  
  403. if (this.starGLCallList >= 0) {
  404. GLAllocation.deleteDisplayLists(this.starGLCallList);
  405. this.starGLCallList = -1;
  406. }
  407.  
  408. if (this.vboEnabled) {
  409. this.starVBO = new VertexBuffer(this.vertexBufferFormat);
  410. this.renderStars(worldrenderer);
  411. worldrenderer.finishDrawing();
  412. worldrenderer.reset();
  413. this.starVBO.func_181722_a(worldrenderer.getByteBuffer());
  414. } else {
  415. this.starGLCallList = GLAllocation.generateDisplayLists(1);
  416. GlStateManager.pushMatrix();
  417. GL11.glNewList(this.starGLCallList, GL11.GL_COMPILE);
  418. this.renderStars(worldrenderer);
  419. tessellator.draw();
  420. GL11.glEndList();
  421. GlStateManager.popMatrix();
  422. }
  423. }
  424.  
  425. private void renderStars(WorldRenderer worldRendererIn) {
  426. Random random = new Random(10842L);
  427. worldRendererIn.begin(7, DefaultVertexFormats.POSITION);
  428.  
  429. for (int i = 0; i < 1500; ++i) {
  430. double d0 = (double) (random.nextFloat() * 2.0F - 1.0F);
  431. double d1 = (double) (random.nextFloat() * 2.0F - 1.0F);
  432. double d2 = (double) (random.nextFloat() * 2.0F - 1.0F);
  433. double d3 = (double) (0.15F + random.nextFloat() * 0.1F);
  434. double d4 = d0 * d0 + d1 * d1 + d2 * d2;
  435.  
  436. if (d4 < 1.0D && d4 > 0.01D) {
  437. d4 = 1.0D / Math.sqrt(d4);
  438. d0 = d0 * d4;
  439. d1 = d1 * d4;
  440. d2 = d2 * d4;
  441. double d5 = d0 * 100.0D;
  442. double d6 = d1 * 100.0D;
  443. double d7 = d2 * 100.0D;
  444. double d8 = Math.atan2(d0, d2);
  445. double d9 = Math.sin(d8);
  446. double d10 = Math.cos(d8);
  447. double d11 = Math.atan2(Math.sqrt(d0 * d0 + d2 * d2), d1);
  448. double d12 = Math.sin(d11);
  449. double d13 = Math.cos(d11);
  450. double d14 = random.nextDouble() * Math.PI * 2.0D;
  451. double d15 = Math.sin(d14);
  452. double d16 = Math.cos(d14);
  453.  
  454. for (int j = 0; j < 4; ++j) {
  455. double d17 = 0.0D;
  456. double d18 = (double) ((j & 2) - 1) * d3;
  457. double d19 = (double) ((j + 1 & 2) - 1) * d3;
  458. double d20 = 0.0D;
  459. double d21 = d18 * d16 - d19 * d15;
  460. double d22 = d19 * d16 + d18 * d15;
  461. double d23 = d21 * d12 + 0.0D * d13;
  462. double d24 = 0.0D * d12 - d21 * d13;
  463. double d25 = d24 * d9 - d22 * d10;
  464. double d26 = d22 * d9 + d24 * d10;
  465. worldRendererIn.pos(d5 + d25, d6 + d23, d7 + d26).endVertex();
  466. }
  467. }
  468. }
  469. }
  470.  
  471. /**
  472. * set null to clear
  473. */
  474. public void setWorldAndLoadRenderers(WorldClient worldClientIn) {
  475. if (this.theWorld != null) {
  476. this.theWorld.removeWorldAccess(this);
  477. }
  478.  
  479. this.frustumUpdatePosX = Double.MIN_VALUE;
  480. this.frustumUpdatePosY = Double.MIN_VALUE;
  481. this.frustumUpdatePosZ = Double.MIN_VALUE;
  482. this.frustumUpdatePosChunkX = Integer.MIN_VALUE;
  483. this.frustumUpdatePosChunkY = Integer.MIN_VALUE;
  484. this.frustumUpdatePosChunkZ = Integer.MIN_VALUE;
  485. this.renderManager.set(worldClientIn);
  486. this.theWorld = worldClientIn;
  487.  
  488. if (Config.isDynamicLights()) {
  489. DynamicLights.clear();
  490. }
  491.  
  492. if (worldClientIn != null) {
  493. worldClientIn.addWorldAccess(this);
  494. this.loadRenderers();
  495. }
  496. }
  497.  
  498. /**
  499. * Loads all the renderers and sets up the basic settings usage
  500. */
  501. public void loadRenderers() {
  502. if (this.theWorld != null) {
  503. this.displayListEntitiesDirty = true;
  504. Blocks.leaves.setGraphicsLevel(Config.isTreesFancy());
  505. Blocks.leaves2.setGraphicsLevel(Config.isTreesFancy());
  506. BlockModelRenderer.updateAoLightValue();
  507.  
  508. if (Config.isDynamicLights()) {
  509. DynamicLights.clear();
  510. }
  511.  
  512. this.renderDistanceChunks = this.mc.gameSettings.renderDistanceChunks;
  513. this.renderDistance = this.renderDistanceChunks * 16;
  514. this.renderDistanceSq = this.renderDistance * this.renderDistance;
  515. boolean flag = this.vboEnabled;
  516. this.vboEnabled = OpenGlHelper.useVbo();
  517.  
  518. if (flag && !this.vboEnabled) {
  519. this.renderContainer = new RenderList();
  520. this.renderChunkFactory = new ListChunkFactory();
  521. } else if (!flag && this.vboEnabled) {
  522. this.renderContainer = new VboRenderList();
  523. this.renderChunkFactory = new VboChunkFactory();
  524. }
  525.  
  526. if (flag != this.vboEnabled) {
  527. this.generateStars();
  528. this.generateSky();
  529. this.generateSky2();
  530. }
  531.  
  532. if (this.viewFrustum != null) {
  533. this.viewFrustum.deleteGlResources();
  534. }
  535.  
  536. this.stopChunkUpdates();
  537. Set var5 = this.field_181024_n;
  538.  
  539. synchronized (this.field_181024_n) {
  540. this.field_181024_n.clear();
  541. }
  542.  
  543. this.viewFrustum = new ViewFrustum(this.theWorld, this.mc.gameSettings.renderDistanceChunks, this,
  544. this.renderChunkFactory);
  545.  
  546. if (this.theWorld != null) {
  547. Entity entity = this.mc.getRenderViewEntity();
  548.  
  549. if (entity != null) {
  550. this.viewFrustum.updateChunkPositions(entity.posX, entity.posZ);
  551. }
  552. }
  553.  
  554. this.renderEntitiesStartupCounter = 2;
  555. }
  556. }
  557.  
  558. protected void stopChunkUpdates() {
  559. this.chunksToUpdate.clear();
  560. this.renderDispatcher.stopChunkUpdates();
  561. }
  562.  
  563. public void createBindEntityOutlineFbs(int p_72720_1_, int p_72720_2_) {
  564. if (OpenGlHelper.shadersSupported && this.entityOutlineShader != null) {
  565. this.entityOutlineShader.createBindFramebuffers(p_72720_1_, p_72720_2_);
  566. }
  567. }
  568.  
  569. public void renderEntities(Entity renderViewEntity, ICamera camera, float partialTicks) {
  570. int i = 0;
  571.  
  572. if (Reflector.MinecraftForgeClient_getRenderPass.exists()) {
  573. i = Reflector.callInt(Reflector.MinecraftForgeClient_getRenderPass, new Object[0]);
  574. }
  575.  
  576. if (this.renderEntitiesStartupCounter > 0) {
  577. if (i > 0) {
  578. return;
  579. }
  580.  
  581. --this.renderEntitiesStartupCounter;
  582. } else {
  583. double d0 = renderViewEntity.prevPosX
  584. + (renderViewEntity.posX - renderViewEntity.prevPosX) * (double) partialTicks;
  585. double d1 = renderViewEntity.prevPosY
  586. + (renderViewEntity.posY - renderViewEntity.prevPosY) * (double) partialTicks;
  587. double d2 = renderViewEntity.prevPosZ
  588. + (renderViewEntity.posZ - renderViewEntity.prevPosZ) * (double) partialTicks;
  589. this.theWorld.theProfiler.startSection("prepare");
  590. TileEntityRendererDispatcher.instance.cacheActiveRenderInfo(this.theWorld, this.mc.getTextureManager(),
  591. this.mc.fontRendererObj, this.mc.getRenderViewEntity(), partialTicks);
  592. this.renderManager.cacheActiveRenderInfo(this.theWorld, this.mc.fontRendererObj,
  593. this.mc.getRenderViewEntity(), this.mc.pointedEntity, this.mc.gameSettings, partialTicks);
  594.  
  595. if (i == 0) {
  596. this.countEntitiesTotal = 0;
  597. this.countEntitiesRendered = 0;
  598. this.countEntitiesHidden = 0;
  599. this.countTileEntitiesRendered = 0;
  600. }
  601.  
  602. Entity entity = this.mc.getRenderViewEntity();
  603. double d3 = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * (double) partialTicks;
  604. double d4 = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * (double) partialTicks;
  605. double d5 = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * (double) partialTicks;
  606. TileEntityRendererDispatcher.staticPlayerX = d3;
  607. TileEntityRendererDispatcher.staticPlayerY = d4;
  608. TileEntityRendererDispatcher.staticPlayerZ = d5;
  609. this.renderManager.setRenderPosition(d3, d4, d5);
  610. this.mc.entityRenderer.enableLightmap();
  611. this.theWorld.theProfiler.endStartSection("global");
  612. List list = this.theWorld.getLoadedEntityList();
  613.  
  614. if (i == 0) {
  615. this.countEntitiesTotal = list.size();
  616. }
  617.  
  618. if (Config.isFogOff() && this.mc.entityRenderer.fogStandard) {
  619. GlStateManager.disableFog();
  620. }
  621.  
  622. boolean flag = Reflector.ForgeEntity_shouldRenderInPass.exists();
  623. boolean flag1 = Reflector.ForgeTileEntity_shouldRenderInPass.exists();
  624.  
  625. for (int j = 0; j < this.theWorld.weatherEffects.size(); ++j) {
  626. Entity entity1 = (Entity) this.theWorld.weatherEffects.get(j);
  627.  
  628. if (!flag || Reflector.callBoolean(entity1, Reflector.ForgeEntity_shouldRenderInPass,
  629. new Object[] { Integer.valueOf(i) })) {
  630. ++this.countEntitiesRendered;
  631.  
  632. if (entity1.isInRangeToRender3d(d0, d1, d2)) {
  633. this.renderManager.renderEntitySimple(entity1, partialTicks);
  634. }
  635. }
  636. }
  637.  
  638. if (this.isRenderEntityOutlines()) {
  639. GlStateManager.depthFunc(519);
  640. GlStateManager.disableFog();
  641. this.entityOutlineFramebuffer.framebufferClear();
  642. this.entityOutlineFramebuffer.bindFramebuffer(false);
  643. this.theWorld.theProfiler.endStartSection("entityOutlines");
  644. RenderHelper.disableStandardItemLighting();
  645. this.renderManager.setRenderOutlines(true);
  646.  
  647. for (int k = 0; k < list.size(); ++k) {
  648. Entity entity3 = (Entity) list.get(k);
  649.  
  650. if (!flag || Reflector.callBoolean(entity3, Reflector.ForgeEntity_shouldRenderInPass,
  651. new Object[] { Integer.valueOf(i) })) {
  652. boolean flag2 = this.mc.getRenderViewEntity() instanceof EntityLivingBase
  653. && ((EntityLivingBase) this.mc.getRenderViewEntity()).isPlayerSleeping();
  654. boolean flag3 = entity3.isInRangeToRender3d(d0, d1, d2)
  655. && (entity3.ignoreFrustumCheck
  656. || camera.isBoundingBoxInFrustum(entity3.getEntityBoundingBox())
  657. || entity3.riddenByEntity == this.mc.thePlayer)
  658. && entity3 instanceof EntityPlayer;
  659.  
  660. if ((entity3 != this.mc.getRenderViewEntity() || this.mc.gameSettings.thirdPersonView != 0
  661. || flag2) && flag3) {
  662. this.renderManager.renderEntitySimple(entity3, partialTicks);
  663. }
  664. }
  665. }
  666.  
  667. this.renderManager.setRenderOutlines(false);
  668. RenderHelper.enableStandardItemLighting();
  669. GlStateManager.depthMask(false);
  670. this.entityOutlineShader.loadShaderGroup(partialTicks);
  671. GlStateManager.enableLighting();
  672. GlStateManager.depthMask(true);
  673. this.mc.getFramebuffer().bindFramebuffer(false);
  674. GlStateManager.enableFog();
  675. GlStateManager.enableBlend();
  676. GlStateManager.enableColorMaterial();
  677. GlStateManager.depthFunc(515);
  678. GlStateManager.enableDepth();
  679. GlStateManager.enableAlpha();
  680. }
  681.  
  682. this.theWorld.theProfiler.endStartSection("entities");
  683. boolean flag7 = Config.isShaders();
  684.  
  685. if (flag7) {
  686. Shaders.beginEntities();
  687. }
  688.  
  689. Iterator iterator1 = this.renderInfosEntities.iterator();
  690. boolean flag4 = this.mc.gameSettings.fancyGraphics;
  691. this.mc.gameSettings.fancyGraphics = Config.isDroppedItemsFancy();
  692. label920:
  693.  
  694. while (iterator1.hasNext()) {
  695. RenderGlobal.ContainerLocalRenderInformation renderglobal$containerlocalrenderinformation = (RenderGlobal.ContainerLocalRenderInformation) iterator1
  696. .next();
  697. Chunk chunk = this.theWorld.getChunkFromBlockCoords(
  698. renderglobal$containerlocalrenderinformation.renderChunk.getPosition());
  699. ClassInheritanceMultiMap classinheritancemultimap = chunk
  700. .getEntityLists()[renderglobal$containerlocalrenderinformation.renderChunk.getPosition().getY()
  701. / 16];
  702.  
  703. if (!classinheritancemultimap.isEmpty()) {
  704. Iterator iterator = classinheritancemultimap.iterator();
  705.  
  706. while (true) {
  707. Entity entity2;
  708. boolean flag5;
  709.  
  710. while (true) {
  711. if (!iterator.hasNext()) {
  712. continue label920;
  713. }
  714.  
  715. entity2 = (Entity) iterator.next();
  716.  
  717. if (!flag || Reflector.callBoolean(entity2, Reflector.ForgeEntity_shouldRenderInPass,
  718. new Object[] { Integer.valueOf(i) })) {
  719. flag5 = this.renderManager.shouldRender(entity2, camera, d0, d1, d2)
  720. || entity2.riddenByEntity == this.mc.thePlayer;
  721.  
  722. if (!flag5) {
  723. break;
  724. }
  725.  
  726. boolean flag6 = this.mc.getRenderViewEntity() instanceof EntityLivingBase
  727. ? ((EntityLivingBase) this.mc.getRenderViewEntity()).isPlayerSleeping()
  728. : false;
  729.  
  730. if ((entity2 != this.mc.getRenderViewEntity()
  731. || this.mc.gameSettings.thirdPersonView != 0 || flag6)
  732. && (entity2.posY < 0.0D || entity2.posY >= 256.0D
  733. || this.theWorld.isBlockLoaded(new BlockPos(entity2)))) {
  734. ++this.countEntitiesRendered;
  735.  
  736. if (entity2.getClass() == EntityItemFrame.class) {
  737. entity2.renderDistanceWeight = 0.06D;
  738. }
  739.  
  740. this.renderedEntity = entity2;
  741.  
  742. if (flag7) {
  743. Shaders.nextEntity(entity2);
  744. }
  745.  
  746. this.renderManager.renderEntitySimple(entity2, partialTicks);
  747. this.renderedEntity = null;
  748. break;
  749. }
  750. }
  751. }
  752.  
  753. if (!flag5 && entity2 instanceof EntityWitherSkull) {
  754. if (flag7) {
  755. Shaders.nextEntity(entity2);
  756. }
  757.  
  758. this.mc.getRenderManager().renderWitherSkull(entity2, partialTicks);
  759. }
  760. }
  761. }
  762. }
  763.  
  764. this.mc.gameSettings.fancyGraphics = flag4;
  765. FontRenderer fontrenderer = TileEntityRendererDispatcher.instance.getFontRenderer();
  766.  
  767. if (flag7) {
  768. Shaders.endEntities();
  769. Shaders.beginBlockEntities();
  770. }
  771.  
  772. this.theWorld.theProfiler.endStartSection("blockentities");
  773. RenderHelper.enableStandardItemLighting();
  774.  
  775. if (Reflector.ForgeTileEntityRendererDispatcher_preDrawBatch.exists()) {
  776. Reflector.call(TileEntityRendererDispatcher.instance,
  777. Reflector.ForgeTileEntityRendererDispatcher_preDrawBatch, new Object[0]);
  778. }
  779.  
  780. label1385:
  781.  
  782. for (Object renderglobal$containerlocalrenderinformation10 : this.renderInfosTileEntities) {
  783. RenderGlobal.ContainerLocalRenderInformation renderglobal$containerlocalrenderinformation1 = (RenderGlobal.ContainerLocalRenderInformation) renderglobal$containerlocalrenderinformation10;
  784. List list1 = renderglobal$containerlocalrenderinformation1.renderChunk.getCompiledChunk()
  785. .getTileEntities();
  786.  
  787. if (!list1.isEmpty()) {
  788. Iterator iterator2 = list1.iterator();
  789.  
  790. while (true) {
  791. TileEntity tileentity;
  792.  
  793. while (true) {
  794. if (!iterator2.hasNext()) {
  795. continue label1385;
  796. }
  797.  
  798. tileentity = (TileEntity) iterator2.next();
  799.  
  800. if (!flag1) {
  801. break;
  802. }
  803.  
  804. if (Reflector.callBoolean(tileentity, Reflector.ForgeTileEntity_shouldRenderInPass,
  805. new Object[] { Integer.valueOf(i) })) {
  806. AxisAlignedBB axisalignedbb = (AxisAlignedBB) Reflector.call(tileentity,
  807. Reflector.ForgeTileEntity_getRenderBoundingBox, new Object[0]);
  808.  
  809. if (axisalignedbb == null || camera.isBoundingBoxInFrustum(axisalignedbb)) {
  810. break;
  811. }
  812. }
  813. }
  814.  
  815. Class oclass = tileentity.getClass();
  816.  
  817. if (oclass == TileEntitySign.class && !Config.zoomMode) {
  818. EntityPlayer entityplayer = this.mc.thePlayer;
  819. double d6 = tileentity.getDistanceSq(entityplayer.posX, entityplayer.posY,
  820. entityplayer.posZ);
  821.  
  822. if (d6 > 256.0D) {
  823. fontrenderer.enabled = false;
  824. }
  825. }
  826.  
  827. if (flag7) {
  828. Shaders.nextBlockEntity(tileentity);
  829. }
  830.  
  831. TileEntityRendererDispatcher.instance.renderTileEntity(tileentity, partialTicks, -1);
  832. ++this.countTileEntitiesRendered;
  833. fontrenderer.enabled = true;
  834. }
  835. }
  836. }
  837.  
  838. Set var32 = this.field_181024_n;
  839.  
  840. synchronized (this.field_181024_n) {
  841. for (Object tileentity1 : this.field_181024_n) {
  842. if (flag1) {
  843. if (!Reflector.callBoolean(tileentity1, Reflector.ForgeTileEntity_shouldRenderInPass,
  844. new Object[] { Integer.valueOf(i) })) {
  845. continue;
  846. }
  847. AxisAlignedBB axisalignedbb1 = (AxisAlignedBB) Reflector.call(tileentity1,
  848. Reflector.ForgeTileEntity_getRenderBoundingBox, new Object[0]);
  849.  
  850. if (axisalignedbb1 != null && !camera.isBoundingBoxInFrustum(axisalignedbb1)) {
  851. continue;
  852. }
  853. }
  854.  
  855. Class oclass1 = tileentity1.getClass();
  856.  
  857. if (oclass1 == TileEntitySign.class && !Config.zoomMode) {
  858. EntityPlayer entityplayer1 = this.mc.thePlayer;
  859. double d7 = ((TileEntity) tileentity1).getDistanceSq(entityplayer1.posX, entityplayer1.posY,
  860. entityplayer1.posZ);
  861.  
  862. if (d7 > 256.0D) {
  863. fontrenderer.enabled = false;
  864. }
  865. }
  866.  
  867. if (flag7) {
  868. Shaders.nextBlockEntity((TileEntity) tileentity1);
  869. }
  870.  
  871. TileEntityRendererDispatcher.instance.renderTileEntity((TileEntity) tileentity1, partialTicks, -1);
  872. fontrenderer.enabled = true;
  873. }
  874. }
  875.  
  876. if (Reflector.ForgeTileEntityRendererDispatcher_drawBatch.exists()) {
  877. Reflector.call(TileEntityRendererDispatcher.instance,
  878. Reflector.ForgeTileEntityRendererDispatcher_drawBatch, new Object[] { Integer.valueOf(i) });
  879. }
  880.  
  881. this.preRenderDamagedBlocks();
  882.  
  883. for (Object destroyblockprogress : this.damagedBlocks.values()) {
  884. BlockPos blockpos = ((DestroyBlockProgress) destroyblockprogress).getPosition();
  885. TileEntity tileentity2 = this.theWorld.getTileEntity(blockpos);
  886.  
  887. if (tileentity2 instanceof TileEntityChest) {
  888. TileEntityChest tileentitychest = (TileEntityChest) tileentity2;
  889.  
  890. if (tileentitychest.adjacentChestXNeg != null) {
  891. blockpos = blockpos.offset(EnumFacing.WEST);
  892. tileentity2 = this.theWorld.getTileEntity(blockpos);
  893. } else if (tileentitychest.adjacentChestZNeg != null) {
  894. blockpos = blockpos.offset(EnumFacing.NORTH);
  895. tileentity2 = this.theWorld.getTileEntity(blockpos);
  896. }
  897. }
  898.  
  899. Block block = this.theWorld.getBlockState(blockpos).getBlock();
  900. boolean flag8;
  901.  
  902. if (flag1) {
  903. flag8 = false;
  904.  
  905. if (tileentity2 != null
  906. && Reflector.callBoolean(tileentity2, Reflector.ForgeTileEntity_shouldRenderInPass,
  907. new Object[] { Integer.valueOf(i) })
  908. && Reflector.callBoolean(tileentity2, Reflector.ForgeTileEntity_canRenderBreaking,
  909. new Object[0])) {
  910. AxisAlignedBB axisalignedbb2 = (AxisAlignedBB) Reflector.call(tileentity2,
  911. Reflector.ForgeTileEntity_getRenderBoundingBox, new Object[0]);
  912.  
  913. if (axisalignedbb2 != null) {
  914. flag8 = camera.isBoundingBoxInFrustum(axisalignedbb2);
  915. }
  916. }
  917. } else {
  918. flag8 = tileentity2 != null && (block instanceof BlockChest || block instanceof BlockEnderChest
  919. || block instanceof BlockSign || block instanceof BlockSkull);
  920. }
  921.  
  922. if (flag8) {
  923. if (flag7) {
  924. Shaders.nextBlockEntity(tileentity2);
  925. }
  926.  
  927. TileEntityRendererDispatcher.instance.renderTileEntity(tileentity2, partialTicks,
  928. ((DestroyBlockProgress) destroyblockprogress).getPartialBlockDamage());
  929. }
  930. }
  931.  
  932. this.postRenderDamagedBlocks();
  933. this.mc.entityRenderer.disableLightmap();
  934. this.mc.mcProfiler.endSection();
  935. }
  936. }
  937.  
  938. /**
  939. * Gets the render info for use on the Debug screen
  940. */
  941. public String getDebugInfoRenders() {
  942. int i = this.viewFrustum.renderChunks.length;
  943. int j = 0;
  944.  
  945. for (Object renderglobal$containerlocalrenderinformation0 : this.renderInfos) {
  946. RenderGlobal.ContainerLocalRenderInformation renderglobal$containerlocalrenderinformation = (RenderGlobal.ContainerLocalRenderInformation) renderglobal$containerlocalrenderinformation0;
  947. CompiledChunk compiledchunk = renderglobal$containerlocalrenderinformation.renderChunk.compiledChunk;
  948.  
  949. if (compiledchunk != CompiledChunk.DUMMY && !compiledchunk.isEmpty()) {
  950. ++j;
  951. }
  952. }
  953.  
  954. return String.format("C: %d/%d %sD: %d, %s",
  955. new Object[] { Integer.valueOf(j), Integer.valueOf(i), this.mc.renderChunksMany ? "(s) " : "",
  956. Integer.valueOf(this.renderDistanceChunks), this.renderDispatcher.getDebugInfo() });
  957. }
  958.  
  959. /**
  960. * Gets the entities info for use on the Debug screen
  961. */
  962. public String getDebugInfoEntities() {
  963. return "E: " + this.countEntitiesRendered + "/" + this.countEntitiesTotal + ", B: " + this.countEntitiesHidden
  964. + ", I: " + (this.countEntitiesTotal - this.countEntitiesHidden - this.countEntitiesRendered) + ", "
  965. + Config.getVersionDebug();
  966. }
  967.  
  968. public void setupTerrain(Entity viewEntity, double partialTicks, ICamera camera, int frameCount,
  969. boolean playerSpectator) {
  970. if (this.mc.gameSettings.renderDistanceChunks != this.renderDistanceChunks) {
  971. this.loadRenderers();
  972. }
  973.  
  974. this.theWorld.theProfiler.startSection("camera");
  975. double d0 = viewEntity.posX - this.frustumUpdatePosX;
  976. double d1 = viewEntity.posY - this.frustumUpdatePosY;
  977. double d2 = viewEntity.posZ - this.frustumUpdatePosZ;
  978.  
  979. if (this.frustumUpdatePosChunkX != viewEntity.chunkCoordX
  980. || this.frustumUpdatePosChunkY != viewEntity.chunkCoordY
  981. || this.frustumUpdatePosChunkZ != viewEntity.chunkCoordZ || d0 * d0 + d1 * d1 + d2 * d2 > 16.0D) {
  982. this.frustumUpdatePosX = viewEntity.posX;
  983. this.frustumUpdatePosY = viewEntity.posY;
  984. this.frustumUpdatePosZ = viewEntity.posZ;
  985. this.frustumUpdatePosChunkX = viewEntity.chunkCoordX;
  986. this.frustumUpdatePosChunkY = viewEntity.chunkCoordY;
  987. this.frustumUpdatePosChunkZ = viewEntity.chunkCoordZ;
  988. this.viewFrustum.updateChunkPositions(viewEntity.posX, viewEntity.posZ);
  989. }
  990.  
  991. if (Config.isDynamicLights()) {
  992. DynamicLights.update(this);
  993. }
  994.  
  995. this.theWorld.theProfiler.endStartSection("renderlistcamera");
  996. double d3 = viewEntity.lastTickPosX + (viewEntity.posX - viewEntity.lastTickPosX) * partialTicks;
  997. double d4 = viewEntity.lastTickPosY + (viewEntity.posY - viewEntity.lastTickPosY) * partialTicks;
  998. double d5 = viewEntity.lastTickPosZ + (viewEntity.posZ - viewEntity.lastTickPosZ) * partialTicks;
  999. this.renderContainer.initialize(d3, d4, d5);
  1000. this.theWorld.theProfiler.endStartSection("cull");
  1001.  
  1002. if (this.debugFixedClippingHelper != null) {
  1003. Frustum frustum = new Frustum(this.debugFixedClippingHelper);
  1004. frustum.setPosition(this.debugTerrainFrustumPosition.field_181059_a,
  1005. this.debugTerrainFrustumPosition.field_181060_b, this.debugTerrainFrustumPosition.field_181061_c);
  1006. camera = frustum;
  1007. }
  1008.  
  1009. this.mc.mcProfiler.endStartSection("culling");
  1010. BlockPos blockpos2 = new BlockPos(d3, d4 + (double) viewEntity.getEyeHeight(), d5);
  1011. RenderChunk renderchunk = this.viewFrustum.getRenderChunk(blockpos2);
  1012. BlockPos blockpos = new BlockPos(MathHelper.floor_double(d3 / 16.0D) * 16,
  1013. MathHelper.floor_double(d4 / 16.0D) * 16, MathHelper.floor_double(d5 / 16.0D) * 16);
  1014. this.displayListEntitiesDirty = this.displayListEntitiesDirty || !this.chunksToUpdate.isEmpty()
  1015. || viewEntity.posX != this.lastViewEntityX || viewEntity.posY != this.lastViewEntityY
  1016. || viewEntity.posZ != this.lastViewEntityZ
  1017. || (double) viewEntity.rotationPitch != this.lastViewEntityPitch
  1018. || (double) viewEntity.rotationYaw != this.lastViewEntityYaw;
  1019. this.lastViewEntityX = viewEntity.posX;
  1020. this.lastViewEntityY = viewEntity.posY;
  1021. this.lastViewEntityZ = viewEntity.posZ;
  1022. this.lastViewEntityPitch = (double) viewEntity.rotationPitch;
  1023. this.lastViewEntityYaw = (double) viewEntity.rotationYaw;
  1024. boolean flag = this.debugFixedClippingHelper != null;
  1025. Lagometer.timerVisibility.start();
  1026.  
  1027. if (Shaders.isShadowPass) {
  1028. this.renderInfos = this.renderInfosShadow;
  1029. this.renderInfosEntities = this.renderInfosEntitiesShadow;
  1030. this.renderInfosTileEntities = this.renderInfosTileEntitiesShadow;
  1031.  
  1032. if (!flag && this.displayListEntitiesDirty) {
  1033. this.renderInfos.clear();
  1034. this.renderInfosEntities.clear();
  1035. this.renderInfosTileEntities.clear();
  1036. RenderInfoLazy renderinfolazy = new RenderInfoLazy();
  1037. Iterator<RenderChunk> iterator = ShadowUtils.makeShadowChunkIterator(this.theWorld, partialTicks,
  1038. viewEntity, this.renderDistanceChunks, this.viewFrustum);
  1039.  
  1040. while (iterator.hasNext()) {
  1041. RenderChunk renderchunk1 = (RenderChunk) iterator.next();
  1042.  
  1043. if (renderchunk1 != null) {
  1044. renderinfolazy.setRenderChunk(renderchunk1);
  1045.  
  1046. if (!renderchunk1.compiledChunk.isEmpty() || renderchunk1.isNeedsUpdate()) {
  1047. this.renderInfos.add(renderinfolazy.getRenderInfo());
  1048. }
  1049.  
  1050. BlockPos blockpos1 = renderchunk1.getPosition();
  1051.  
  1052. if (ChunkUtils.hasEntities(this.theWorld.getChunkFromBlockCoords(blockpos1))) {
  1053. this.renderInfosEntities.add(renderinfolazy.getRenderInfo());
  1054. }
  1055.  
  1056. if (renderchunk1.getCompiledChunk().getTileEntities().size() > 0) {
  1057. this.renderInfosTileEntities.add(renderinfolazy.getRenderInfo());
  1058. }
  1059. }
  1060. }
  1061. }
  1062. } else {
  1063. this.renderInfos = this.renderInfosNormal;
  1064. this.renderInfosEntities = this.renderInfosEntitiesNormal;
  1065. this.renderInfosTileEntities = this.renderInfosTileEntitiesNormal;
  1066. }
  1067.  
  1068. if (!flag && this.displayListEntitiesDirty && !Shaders.isShadowPass) {
  1069. this.displayListEntitiesDirty = false;
  1070. this.renderInfos.clear();
  1071. this.renderInfosEntities.clear();
  1072. this.renderInfosTileEntities.clear();
  1073. this.visibilityDeque.clear();
  1074. Deque deque = this.visibilityDeque;
  1075. boolean flag1 = this.mc.renderChunksMany;
  1076.  
  1077. if (renderchunk != null) {
  1078. boolean flag2 = false;
  1079. RenderGlobal.ContainerLocalRenderInformation renderglobal$containerlocalrenderinformation3 = new RenderGlobal.ContainerLocalRenderInformation(
  1080. renderchunk, (EnumFacing) null, 0, (Object) null);
  1081. Set set1 = SET_ALL_FACINGS;
  1082.  
  1083. if (set1.size() == 1) {
  1084. Vector3f vector3f = this.getViewVector(viewEntity, partialTicks);
  1085. EnumFacing enumfacing = EnumFacing.getFacingFromVector(vector3f.x, vector3f.y, vector3f.z)
  1086. .getOpposite();
  1087. set1.remove(enumfacing);
  1088. }
  1089.  
  1090. if (set1.isEmpty()) {
  1091. flag2 = true;
  1092. }
  1093.  
  1094. if (flag2 && !playerSpectator) {
  1095. this.renderInfos.add(renderglobal$containerlocalrenderinformation3);
  1096. } else {
  1097. if (playerSpectator && this.theWorld.getBlockState(blockpos2).getBlock().isOpaqueCube()) {
  1098. flag1 = false;
  1099. }
  1100.  
  1101. renderchunk.setFrameIndex(frameCount);
  1102. deque.add(renderglobal$containerlocalrenderinformation3);
  1103. }
  1104. } else {
  1105. int i = blockpos2.getY() > 0 ? 248 : 8;
  1106.  
  1107. for (int j = -this.renderDistanceChunks; j <= this.renderDistanceChunks; ++j) {
  1108. for (int k = -this.renderDistanceChunks; k <= this.renderDistanceChunks; ++k) {
  1109. RenderChunk renderchunk2 = this.viewFrustum
  1110. .getRenderChunk(new BlockPos((j << 4) + 8, i, (k << 4) + 8));
  1111.  
  1112. if (renderchunk2 != null
  1113. && ((ICamera) camera).isBoundingBoxInFrustum(renderchunk2.boundingBox)) {
  1114. renderchunk2.setFrameIndex(frameCount);
  1115. deque.add(new RenderGlobal.ContainerLocalRenderInformation(renderchunk2, (EnumFacing) null,
  1116. 0, (Object) null));
  1117. }
  1118. }
  1119. }
  1120. }
  1121.  
  1122. EnumFacing[] aenumfacing = EnumFacing.VALUES;
  1123. int l = aenumfacing.length;
  1124.  
  1125. while (!deque.isEmpty()) {
  1126. RenderGlobal.ContainerLocalRenderInformation renderglobal$containerlocalrenderinformation1 = (RenderGlobal.ContainerLocalRenderInformation) deque
  1127. .poll();
  1128. RenderChunk renderchunk4 = renderglobal$containerlocalrenderinformation1.renderChunk;
  1129. EnumFacing enumfacing2 = renderglobal$containerlocalrenderinformation1.facing;
  1130. BlockPos blockpos3 = renderchunk4.getPosition();
  1131.  
  1132. if (!renderchunk4.compiledChunk.isEmpty() || renderchunk4.isNeedsUpdate()) {
  1133. this.renderInfos.add(renderglobal$containerlocalrenderinformation1);
  1134. }
  1135.  
  1136. if (ChunkUtils.hasEntities(this.theWorld.getChunkFromBlockCoords(blockpos3))) {
  1137. this.renderInfosEntities.add(renderglobal$containerlocalrenderinformation1);
  1138. }
  1139.  
  1140. if (renderchunk4.getCompiledChunk().getTileEntities().size() > 0) {
  1141. this.renderInfosTileEntities.add(renderglobal$containerlocalrenderinformation1);
  1142. }
  1143.  
  1144. for (int i1 = 0; i1 < l; ++i1) {
  1145. EnumFacing enumfacing1 = aenumfacing[i1];
  1146.  
  1147. if ((!flag1 || !renderglobal$containerlocalrenderinformation1.setFacing
  1148. .contains(enumfacing1.getOpposite()))
  1149. && (!flag1 || enumfacing2 == null || renderchunk4.getCompiledChunk()
  1150. .isVisible(enumfacing2.getOpposite(), enumfacing1))) {
  1151. RenderChunk renderchunk3 = this.func_181562_a(blockpos2, renderchunk4, enumfacing1);
  1152.  
  1153. if (renderchunk3 != null && renderchunk3.setFrameIndex(frameCount)
  1154. && ((ICamera) camera).isBoundingBoxInFrustum(renderchunk3.boundingBox)) {
  1155. RenderGlobal.ContainerLocalRenderInformation renderglobal$containerlocalrenderinformation = new RenderGlobal.ContainerLocalRenderInformation(
  1156. renderchunk3, enumfacing1,
  1157. renderglobal$containerlocalrenderinformation1.counter + 1, (Object) null);
  1158. renderglobal$containerlocalrenderinformation.setFacing
  1159. .addAll(renderglobal$containerlocalrenderinformation1.setFacing);
  1160. renderglobal$containerlocalrenderinformation.setFacing.add(enumfacing1);
  1161. deque.add(renderglobal$containerlocalrenderinformation);
  1162. }
  1163. }
  1164. }
  1165. }
  1166. }
  1167.  
  1168. if (this.debugFixTerrainFrustum) {
  1169. this.fixTerrainFrustum(d3, d4, d5);
  1170. this.debugFixTerrainFrustum = false;
  1171. }
  1172.  
  1173. Lagometer.timerVisibility.end();
  1174.  
  1175. if (Shaders.isShadowPass) {
  1176. Shaders.mcProfilerEndSection();
  1177. } else {
  1178. this.renderDispatcher.clearChunkUpdates();
  1179. Set set = this.chunksToUpdate;
  1180. this.chunksToUpdate = Sets.newLinkedHashSet();
  1181. Iterator iterator1 = this.renderInfos.iterator();
  1182. Lagometer.timerChunkUpdate.start();
  1183.  
  1184. while (iterator1.hasNext()) {
  1185. RenderGlobal.ContainerLocalRenderInformation renderglobal$containerlocalrenderinformation2 = (RenderGlobal.ContainerLocalRenderInformation) iterator1
  1186. .next();
  1187. RenderChunk renderchunk5 = renderglobal$containerlocalrenderinformation2.renderChunk;
  1188.  
  1189. if (renderchunk5.isNeedsUpdate() || set.contains(renderchunk5)) {
  1190. this.displayListEntitiesDirty = true;
  1191.  
  1192. if (this.isPositionInRenderChunk(blockpos,
  1193. renderglobal$containerlocalrenderinformation2.renderChunk)) {
  1194. if (!renderchunk5.isPlayerUpdate()) {
  1195. this.chunksToUpdateForced.add(renderchunk5);
  1196. } else {
  1197. this.mc.mcProfiler.startSection("build near");
  1198. this.renderDispatcher.updateChunkNow(renderchunk5);
  1199. renderchunk5.setNeedsUpdate(false);
  1200. this.mc.mcProfiler.endSection();
  1201. }
  1202. } else {
  1203. this.chunksToUpdate.add(renderchunk5);
  1204. }
  1205. }
  1206. }
  1207.  
  1208. Lagometer.timerChunkUpdate.end();
  1209. this.chunksToUpdate.addAll(set);
  1210. this.mc.mcProfiler.endSection();
  1211. }
  1212. }
  1213.  
  1214. private boolean isPositionInRenderChunk(BlockPos pos, RenderChunk renderChunkIn) {
  1215. BlockPos blockpos = renderChunkIn.getPosition();
  1216. return MathHelper.abs_int(pos.getX() - blockpos.getX()) > 16 ? false
  1217. : (MathHelper.abs_int(pos.getY() - blockpos.getY()) > 16 ? false
  1218. : MathHelper.abs_int(pos.getZ() - blockpos.getZ()) <= 16);
  1219. }
  1220.  
  1221. private Set getVisibleFacings(BlockPos pos) {
  1222. VisGraph visgraph = new VisGraph();
  1223. BlockPos blockpos = new BlockPos(pos.getX() >> 4 << 4, pos.getY() >> 4 << 4, pos.getZ() >> 4 << 4);
  1224. Chunk chunk = this.theWorld.getChunkFromBlockCoords(blockpos);
  1225.  
  1226. for (BlockPos.MutableBlockPos blockpos$mutableblockpos : BlockPos.getAllInBoxMutable(blockpos,
  1227. blockpos.add(15, 15, 15))) {
  1228. if (chunk.getBlock(blockpos$mutableblockpos).isOpaqueCube()) {
  1229. visgraph.func_178606_a(blockpos$mutableblockpos);
  1230. }
  1231. }
  1232. return visgraph.func_178609_b(pos);
  1233. }
  1234.  
  1235. private RenderChunk func_181562_a(BlockPos p_181562_1_, RenderChunk p_181562_2_, EnumFacing p_181562_3_) {
  1236. BlockPos blockpos = p_181562_2_.getPositionOffset16(p_181562_3_);
  1237.  
  1238. if (blockpos.getY() >= 0 && blockpos.getY() < 256) {
  1239. int i = MathHelper.abs_int(p_181562_1_.getX() - blockpos.getX());
  1240. int j = MathHelper.abs_int(p_181562_1_.getZ() - blockpos.getZ());
  1241.  
  1242. if (Config.isFogOff()) {
  1243. if (i > this.renderDistance || j > this.renderDistance) {
  1244. return null;
  1245. }
  1246. } else {
  1247. int k = i * i + j * j;
  1248.  
  1249. if (k > this.renderDistanceSq) {
  1250. return null;
  1251. }
  1252. }
  1253.  
  1254. return this.viewFrustum.getRenderChunk(blockpos);
  1255. } else {
  1256. return null;
  1257. }
  1258. }
  1259.  
  1260. private void fixTerrainFrustum(double x, double y, double z) {
  1261. this.debugFixedClippingHelper = new ClippingHelperImpl();
  1262. ((ClippingHelperImpl) this.debugFixedClippingHelper).init();
  1263. Matrix4f matrix4f = new Matrix4f(this.debugFixedClippingHelper.modelviewMatrix);
  1264. matrix4f.transpose();
  1265. Matrix4f matrix4f1 = new Matrix4f(this.debugFixedClippingHelper.projectionMatrix);
  1266. matrix4f1.transpose();
  1267. Matrix4f matrix4f2 = new Matrix4f();
  1268. Matrix4f.mul(matrix4f1, matrix4f, matrix4f2);
  1269. matrix4f2.invert();
  1270. this.debugTerrainFrustumPosition.field_181059_a = x;
  1271. this.debugTerrainFrustumPosition.field_181060_b = y;
  1272. this.debugTerrainFrustumPosition.field_181061_c = z;
  1273. this.debugTerrainMatrix[0] = new Vector4f(-1.0F, -1.0F, -1.0F, 1.0F);
  1274. this.debugTerrainMatrix[1] = new Vector4f(1.0F, -1.0F, -1.0F, 1.0F);
  1275. this.debugTerrainMatrix[2] = new Vector4f(1.0F, 1.0F, -1.0F, 1.0F);
  1276. this.debugTerrainMatrix[3] = new Vector4f(-1.0F, 1.0F, -1.0F, 1.0F);
  1277. this.debugTerrainMatrix[4] = new Vector4f(-1.0F, -1.0F, 1.0F, 1.0F);
  1278. this.debugTerrainMatrix[5] = new Vector4f(1.0F, -1.0F, 1.0F, 1.0F);
  1279. this.debugTerrainMatrix[6] = new Vector4f(1.0F, 1.0F, 1.0F, 1.0F);
  1280. this.debugTerrainMatrix[7] = new Vector4f(-1.0F, 1.0F, 1.0F, 1.0F);
  1281.  
  1282. for (int i = 0; i < 8; ++i) {
  1283. Matrix4f.transform(matrix4f2, this.debugTerrainMatrix[i], this.debugTerrainMatrix[i]);
  1284. this.debugTerrainMatrix[i].x /= this.debugTerrainMatrix[i].w;
  1285. this.debugTerrainMatrix[i].y /= this.debugTerrainMatrix[i].w;
  1286. this.debugTerrainMatrix[i].z /= this.debugTerrainMatrix[i].w;
  1287. this.debugTerrainMatrix[i].w = 1.0F;
  1288. }
  1289. }
  1290.  
  1291. protected Vector3f getViewVector(Entity entityIn, double partialTicks) {
  1292. float f = (float) ((double) entityIn.prevRotationPitch
  1293. + (double) (entityIn.rotationPitch - entityIn.prevRotationPitch) * partialTicks);
  1294. float f1 = (float) ((double) entityIn.prevRotationYaw
  1295. + (double) (entityIn.rotationYaw - entityIn.prevRotationYaw) * partialTicks);
  1296.  
  1297. if (Minecraft.getMinecraft().gameSettings.thirdPersonView == 2) {
  1298. f += 180.0F;
  1299. }
  1300.  
  1301. float f2 = MathHelper.cos(-f1 * 0.017453292F - (float) Math.PI);
  1302. float f3 = MathHelper.sin(-f1 * 0.017453292F - (float) Math.PI);
  1303. float f4 = -MathHelper.cos(-f * 0.017453292F);
  1304. float f5 = MathHelper.sin(-f * 0.017453292F);
  1305. return new Vector3f(f3 * f4, f5, f2 * f4);
  1306. }
  1307.  
  1308. public int renderBlockLayer(EnumWorldBlockLayer blockLayerIn, double partialTicks, int pass, Entity entityIn) {
  1309. RenderHelper.disableStandardItemLighting();
  1310.  
  1311. if (blockLayerIn == EnumWorldBlockLayer.TRANSLUCENT) {
  1312. this.mc.mcProfiler.startSection("translucent_sort");
  1313. double d0 = entityIn.posX - this.prevRenderSortX;
  1314. double d1 = entityIn.posY - this.prevRenderSortY;
  1315. double d2 = entityIn.posZ - this.prevRenderSortZ;
  1316.  
  1317. if (d0 * d0 + d1 * d1 + d2 * d2 > 1.0D) {
  1318. this.prevRenderSortX = entityIn.posX;
  1319. this.prevRenderSortY = entityIn.posY;
  1320. this.prevRenderSortZ = entityIn.posZ;
  1321. int k = 0;
  1322. Iterator iterator = this.renderInfos.iterator();
  1323. this.chunksToResortTransparency.clear();
  1324.  
  1325. while (iterator.hasNext()) {
  1326. RenderGlobal.ContainerLocalRenderInformation renderglobal$containerlocalrenderinformation = (RenderGlobal.ContainerLocalRenderInformation) iterator
  1327. .next();
  1328.  
  1329. if (renderglobal$containerlocalrenderinformation.renderChunk.compiledChunk
  1330. .isLayerStarted(blockLayerIn) && k++ < 15) {
  1331. this.chunksToResortTransparency.add(renderglobal$containerlocalrenderinformation.renderChunk);
  1332. }
  1333. }
  1334. }
  1335.  
  1336. this.mc.mcProfiler.endSection();
  1337. }
  1338.  
  1339. this.mc.mcProfiler.startSection("filterempty");
  1340. int l = 0;
  1341. boolean flag = blockLayerIn == EnumWorldBlockLayer.TRANSLUCENT;
  1342. int i1 = flag ? this.renderInfos.size() - 1 : 0;
  1343. int i = flag ? -1 : this.renderInfos.size();
  1344. int j1 = flag ? -1 : 1;
  1345.  
  1346. for (int j = i1; j != i; j += j1) {
  1347. RenderChunk renderchunk = ((RenderGlobal.ContainerLocalRenderInformation) this.renderInfos
  1348. .get(j)).renderChunk;
  1349.  
  1350. if (!renderchunk.getCompiledChunk().isLayerEmpty(blockLayerIn)) {
  1351. ++l;
  1352. this.renderContainer.addRenderChunk(renderchunk, blockLayerIn);
  1353. }
  1354. }
  1355.  
  1356. if (l == 0) {
  1357. this.mc.mcProfiler.endSection();
  1358. return l;
  1359. } else {
  1360. if (Config.isFogOff() && this.mc.entityRenderer.fogStandard) {
  1361. GlStateManager.disableFog();
  1362. }
  1363.  
  1364. this.mc.mcProfiler.endStartSection("render_" + blockLayerIn);
  1365. this.renderBlockLayer(blockLayerIn);
  1366. this.mc.mcProfiler.endSection();
  1367. return l;
  1368. }
  1369. }
  1370.  
  1371. @SuppressWarnings("incomplete-switch")
  1372. private void renderBlockLayer(EnumWorldBlockLayer blockLayerIn) {
  1373. this.mc.entityRenderer.enableLightmap();
  1374.  
  1375. if (OpenGlHelper.useVbo()) {
  1376. GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
  1377. OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit);
  1378. GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
  1379. OpenGlHelper.setClientActiveTexture(OpenGlHelper.lightmapTexUnit);
  1380. GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
  1381. OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit);
  1382. GL11.glEnableClientState(GL11.GL_COLOR_ARRAY);
  1383. }
  1384.  
  1385. if (Config.isShaders()) {
  1386. ShadersRender.preRenderChunkLayer(blockLayerIn);
  1387. }
  1388.  
  1389. this.renderContainer.renderChunkLayer(blockLayerIn);
  1390.  
  1391. if (Config.isShaders()) {
  1392. ShadersRender.postRenderChunkLayer(blockLayerIn);
  1393. }
  1394.  
  1395. if (OpenGlHelper.useVbo()) {
  1396. for (VertexFormatElement vertexformatelement : DefaultVertexFormats.BLOCK.getElements()) {
  1397. VertexFormatElement.EnumUsage vertexformatelement$enumusage = vertexformatelement.getUsage();
  1398. int i = vertexformatelement.getIndex();
  1399.  
  1400. switch (RenderGlobal.RenderGlobal$2.field_178037_a[vertexformatelement$enumusage.ordinal()]) {
  1401. case 1:
  1402. GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
  1403. break;
  1404.  
  1405. case 2:
  1406. OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit + i);
  1407. GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
  1408. OpenGlHelper.setClientActiveTexture(OpenGlHelper.defaultTexUnit);
  1409. break;
  1410.  
  1411. case 3:
  1412. GL11.glDisableClientState(GL11.GL_COLOR_ARRAY);
  1413. GlStateManager.resetColor();
  1414. }
  1415. }
  1416. }
  1417.  
  1418. this.mc.entityRenderer.disableLightmap();
  1419. }
  1420.  
  1421. private void cleanupDamagedBlocks(Iterator iteratorIn) {
  1422. while (iteratorIn.hasNext()) {
  1423. DestroyBlockProgress destroyblockprogress = (DestroyBlockProgress) iteratorIn.next();
  1424. int i = destroyblockprogress.getCreationCloudUpdateTick();
  1425.  
  1426. if (this.cloudTickCounter - i > 400) {
  1427. iteratorIn.remove();
  1428. }
  1429. }
  1430. }
  1431.  
  1432. public void updateClouds() {
  1433. if (Config.isShaders() && Keyboard.isKeyDown(61) && Keyboard.isKeyDown(19)) {
  1434. Shaders.uninit();
  1435. Shaders.loadShaderPack();
  1436. }
  1437.  
  1438. ++this.cloudTickCounter;
  1439.  
  1440. if (this.cloudTickCounter % 20 == 0) {
  1441. this.cleanupDamagedBlocks(this.damagedBlocks.values().iterator());
  1442. }
  1443. }
  1444.  
  1445. private void renderSkyEnd() {
  1446. if (Config.isSkyEnabled()) {
  1447. GlStateManager.disableFog();
  1448. GlStateManager.disableAlpha();
  1449. GlStateManager.enableBlend();
  1450. GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
  1451. RenderHelper.disableStandardItemLighting();
  1452. GlStateManager.depthMask(false);
  1453. this.renderEngine.bindTexture(locationEndSkyPng);
  1454. Tessellator tessellator = Tessellator.getInstance();
  1455. WorldRenderer worldrenderer = tessellator.getWorldRenderer();
  1456.  
  1457. for (int i = 0; i < 6; ++i) {
  1458. GlStateManager.pushMatrix();
  1459.  
  1460. if (i == 1) {
  1461. GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F);
  1462. }
  1463.  
  1464. if (i == 2) {
  1465. GlStateManager.rotate(-90.0F, 1.0F, 0.0F, 0.0F);
  1466. }
  1467.  
  1468. if (i == 3) {
  1469. GlStateManager.rotate(180.0F, 1.0F, 0.0F, 0.0F);
  1470. }
  1471.  
  1472. if (i == 4) {
  1473. GlStateManager.rotate(90.0F, 0.0F, 0.0F, 1.0F);
  1474. }
  1475.  
  1476. if (i == 5) {
  1477. GlStateManager.rotate(-90.0F, 0.0F, 0.0F, 1.0F);
  1478. }
  1479.  
  1480. worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
  1481. worldrenderer.pos(-100.0D, -100.0D, -100.0D).tex(0.0D, 0.0D).color(40, 40, 40, 255).endVertex();
  1482. worldrenderer.pos(-100.0D, -100.0D, 100.0D).tex(0.0D, 16.0D).color(40, 40, 40, 255).endVertex();
  1483. worldrenderer.pos(100.0D, -100.0D, 100.0D).tex(16.0D, 16.0D).color(40, 40, 40, 255).endVertex();
  1484. worldrenderer.pos(100.0D, -100.0D, -100.0D).tex(16.0D, 0.0D).color(40, 40, 40, 255).endVertex();
  1485. tessellator.draw();
  1486. GlStateManager.popMatrix();
  1487. }
  1488.  
  1489. GlStateManager.depthMask(true);
  1490. GlStateManager.enableTexture2D();
  1491. GlStateManager.enableAlpha();
  1492. }
  1493. }
  1494.  
  1495. public void renderSky(float partialTicks, int pass) {
  1496. if (Reflector.ForgeWorldProvider_getSkyRenderer.exists()) {
  1497. WorldProvider worldprovider = this.mc.theWorld.provider;
  1498. Object object = Reflector.call(worldprovider, Reflector.ForgeWorldProvider_getSkyRenderer, new Object[0]);
  1499.  
  1500. if (object != null) {
  1501. Reflector.callVoid(object, Reflector.IRenderHandler_render,
  1502. new Object[] { Float.valueOf(partialTicks), this.theWorld, this.mc });
  1503. return;
  1504. }
  1505. }
  1506.  
  1507. if (this.mc.theWorld.provider.getDimensionId() == 1) {
  1508. this.renderSkyEnd();
  1509. } else if (this.mc.theWorld.provider.isSurfaceWorld()) {
  1510. GlStateManager.disableTexture2D();
  1511. boolean flag1 = Config.isShaders();
  1512.  
  1513. if (flag1) {
  1514. Shaders.disableTexture2D();
  1515. }
  1516.  
  1517. Vec3 vec3 = this.theWorld.getSkyColor(this.mc.getRenderViewEntity(), partialTicks);
  1518. vec3 = CustomColors.getSkyColor(vec3, this.mc.theWorld, this.mc.getRenderViewEntity().posX,
  1519. this.mc.getRenderViewEntity().posY + 1.0D, this.mc.getRenderViewEntity().posZ);
  1520.  
  1521. if (flag1) {
  1522. Shaders.setSkyColor(vec3);
  1523. }
  1524.  
  1525. float f = (float) vec3.xCoord;
  1526. float f1 = (float) vec3.yCoord;
  1527. float f2 = (float) vec3.zCoord;
  1528.  
  1529. if (pass != 2) {
  1530. float f3 = (f * 30.0F + f1 * 59.0F + f2 * 11.0F) / 100.0F;
  1531. float f4 = (f * 30.0F + f1 * 70.0F) / 100.0F;
  1532. float f5 = (f * 30.0F + f2 * 70.0F) / 100.0F;
  1533. f = f3;
  1534. f1 = f4;
  1535. f2 = f5;
  1536. }
  1537.  
  1538. GlStateManager.color(f, f1, f2);
  1539. Tessellator tessellator = Tessellator.getInstance();
  1540. WorldRenderer worldrenderer = tessellator.getWorldRenderer();
  1541. GlStateManager.depthMask(false);
  1542. GlStateManager.enableFog();
  1543.  
  1544. if (flag1) {
  1545. Shaders.enableFog();
  1546. }
  1547.  
  1548. GlStateManager.color(f, f1, f2);
  1549.  
  1550. if (flag1) {
  1551. Shaders.preSkyList();
  1552. }
  1553.  
  1554. if (Config.isSkyEnabled()) {
  1555. if (this.vboEnabled) {
  1556. this.skyVBO.bindBuffer();
  1557. GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
  1558. GL11.glVertexPointer(3, GL11.GL_FLOAT, 12, 0L);
  1559. this.skyVBO.drawArrays(7);
  1560. this.skyVBO.unbindBuffer();
  1561. GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
  1562. } else {
  1563. GlStateManager.callList(this.glSkyList);
  1564. }
  1565. }
  1566.  
  1567. GlStateManager.disableFog();
  1568.  
  1569. if (flag1) {
  1570. Shaders.disableFog();
  1571. }
  1572.  
  1573. GlStateManager.disableAlpha();
  1574. GlStateManager.enableBlend();
  1575. GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
  1576. RenderHelper.disableStandardItemLighting();
  1577. float[] afloat = this.theWorld.provider
  1578. .calcSunriseSunsetColors(this.theWorld.getCelestialAngle(partialTicks), partialTicks);
  1579.  
  1580. if (afloat != null && Config.isSunMoonEnabled()) {
  1581. GlStateManager.disableTexture2D();
  1582.  
  1583. if (flag1) {
  1584. Shaders.disableTexture2D();
  1585. }
  1586.  
  1587. GlStateManager.shadeModel(7425);
  1588. GlStateManager.pushMatrix();
  1589. GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F);
  1590. GlStateManager.rotate(
  1591. MathHelper.sin(this.theWorld.getCelestialAngleRadians(partialTicks)) < 0.0F ? 180.0F : 0.0F,
  1592. 0.0F, 0.0F, 1.0F);
  1593. GlStateManager.rotate(90.0F, 0.0F, 0.0F, 1.0F);
  1594. float f6 = afloat[0];
  1595. float f7 = afloat[1];
  1596. float f8 = afloat[2];
  1597.  
  1598. if (pass != 2) {
  1599. float f9 = (f6 * 30.0F + f7 * 59.0F + f8 * 11.0F) / 100.0F;
  1600. float f10 = (f6 * 30.0F + f7 * 70.0F) / 100.0F;
  1601. float f11 = (f6 * 30.0F + f8 * 70.0F) / 100.0F;
  1602. f6 = f9;
  1603. f7 = f10;
  1604. f8 = f11;
  1605. }
  1606.  
  1607. worldrenderer.begin(6, DefaultVertexFormats.POSITION_COLOR);
  1608. worldrenderer.pos(0.0D, 100.0D, 0.0D).color(f6, f7, f8, afloat[3]).endVertex();
  1609. boolean flag = true;
  1610.  
  1611. for (int i = 0; i <= 16; ++i) {
  1612. float f20 = (float) i * (float) Math.PI * 2.0F / 16.0F;
  1613. float f12 = MathHelper.sin(f20);
  1614. float f13 = MathHelper.cos(f20);
  1615. worldrenderer
  1616. .pos((double) (f12 * 120.0F), (double) (f13 * 120.0F), (double) (-f13 * 40.0F * afloat[3]))
  1617. .color(afloat[0], afloat[1], afloat[2], 0.0F).endVertex();
  1618. }
  1619.  
  1620. tessellator.draw();
  1621. GlStateManager.popMatrix();
  1622. GlStateManager.shadeModel(7424);
  1623. }
  1624.  
  1625. GlStateManager.enableTexture2D();
  1626.  
  1627. if (flag1) {
  1628. Shaders.enableTexture2D();
  1629. }
  1630.  
  1631. GlStateManager.tryBlendFuncSeparate(770, 1, 1, 0);
  1632. GlStateManager.pushMatrix();
  1633. float f15 = 1.0F - this.theWorld.getRainStrength(partialTicks);
  1634. GlStateManager.color(1.0F, 1.0F, 1.0F, f15);
  1635. GlStateManager.rotate(-90.0F, 0.0F, 1.0F, 0.0F);
  1636. CustomSky.renderSky(this.theWorld, this.renderEngine, this.theWorld.getCelestialAngle(partialTicks), f15);
  1637.  
  1638. if (flag1) {
  1639. Shaders.preCelestialRotate();
  1640. }
  1641.  
  1642. GlStateManager.rotate(this.theWorld.getCelestialAngle(partialTicks) * 360.0F, 1.0F, 0.0F, 0.0F);
  1643.  
  1644. if (flag1) {
  1645. Shaders.postCelestialRotate();
  1646. }
  1647.  
  1648. float f16 = 30.0F;
  1649.  
  1650. if (Config.isSunTexture()) {
  1651. this.renderEngine.bindTexture(locationSunPng);
  1652. worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX);
  1653. worldrenderer.pos((double) (-f16), 100.0D, (double) (-f16)).tex(0.0D, 0.0D).endVertex();
  1654. worldrenderer.pos((double) f16, 100.0D, (double) (-f16)).tex(1.0D, 0.0D).endVertex();
  1655. worldrenderer.pos((double) f16, 100.0D, (double) f16).tex(1.0D, 1.0D).endVertex();
  1656. worldrenderer.pos((double) (-f16), 100.0D, (double) f16).tex(0.0D, 1.0D).endVertex();
  1657. tessellator.draw();
  1658. }
  1659.  
  1660. f16 = 20.0F;
  1661.  
  1662. if (Config.isMoonTexture()) {
  1663. this.renderEngine.bindTexture(locationMoonPhasesPng);
  1664. int l = this.theWorld.getMoonPhase();
  1665. int j = l % 4;
  1666. int k = l / 4 % 2;
  1667. float f21 = (float) (j + 0) / 4.0F;
  1668. float f22 = (float) (k + 0) / 2.0F;
  1669. float f23 = (float) (j + 1) / 4.0F;
  1670. float f14 = (float) (k + 1) / 2.0F;
  1671. worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX);
  1672. worldrenderer.pos((double) (-f16), -100.0D, (double) f16).tex((double) f23, (double) f14).endVertex();
  1673. worldrenderer.pos((double) f16, -100.0D, (double) f16).tex((double) f21, (double) f14).endVertex();
  1674. worldrenderer.pos((double) f16, -100.0D, (double) (-f16)).tex((double) f21, (double) f22).endVertex();
  1675. worldrenderer.pos((double) (-f16), -100.0D, (double) (-f16)).tex((double) f23, (double) f22)
  1676. .endVertex();
  1677. tessellator.draw();
  1678. }
  1679.  
  1680. GlStateManager.disableTexture2D();
  1681.  
  1682. if (flag1) {
  1683. Shaders.disableTexture2D();
  1684. }
  1685.  
  1686. float f24 = this.theWorld.getStarBrightness(partialTicks) * f15;
  1687.  
  1688. if (f24 > 0.0F && Config.isStarsEnabled() && !CustomSky.hasSkyLayers(this.theWorld)) {
  1689. GlStateManager.color(f24, f24, f24, f24);
  1690.  
  1691. if (this.vboEnabled) {
  1692. this.starVBO.bindBuffer();
  1693. GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
  1694. GL11.glVertexPointer(3, GL11.GL_FLOAT, 12, 0L);
  1695. this.starVBO.drawArrays(7);
  1696. this.starVBO.unbindBuffer();
  1697. GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
  1698. } else {
  1699. GlStateManager.callList(this.starGLCallList);
  1700. }
  1701. }
  1702.  
  1703. GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
  1704. GlStateManager.disableBlend();
  1705. GlStateManager.enableAlpha();
  1706. GlStateManager.enableFog();
  1707.  
  1708. if (flag1) {
  1709. Shaders.enableFog();
  1710. }
  1711.  
  1712. GlStateManager.popMatrix();
  1713. GlStateManager.disableTexture2D();
  1714.  
  1715. if (flag1) {
  1716. Shaders.disableTexture2D();
  1717. }
  1718.  
  1719. GlStateManager.color(0.0F, 0.0F, 0.0F);
  1720. double d0 = this.mc.thePlayer.getPositionEyes(partialTicks).yCoord - this.theWorld.getHorizon();
  1721.  
  1722. if (d0 < 0.0D) {
  1723. GlStateManager.pushMatrix();
  1724. GlStateManager.translate(0.0F, 12.0F, 0.0F);
  1725.  
  1726. if (this.vboEnabled) {
  1727. this.sky2VBO.bindBuffer();
  1728. GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
  1729. GL11.glVertexPointer(3, GL11.GL_FLOAT, 12, 0L);
  1730. this.sky2VBO.drawArrays(7);
  1731. this.sky2VBO.unbindBuffer();
  1732. GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
  1733. } else {
  1734. GlStateManager.callList(this.glSkyList2);
  1735. }
  1736.  
  1737. GlStateManager.popMatrix();
  1738. float f17 = 1.0F;
  1739. float f18 = -((float) (d0 + 65.0D));
  1740. float f19 = -1.0F;
  1741. worldrenderer.begin(7, DefaultVertexFormats.POSITION_COLOR);
  1742. worldrenderer.pos(-1.0D, (double) f18, 1.0D).color(0, 0, 0, 255).endVertex();
  1743. worldrenderer.pos(1.0D, (double) f18, 1.0D).color(0, 0, 0, 255).endVertex();
  1744. worldrenderer.pos(1.0D, -1.0D, 1.0D).color(0, 0, 0, 255).endVertex();
  1745. worldrenderer.pos(-1.0D, -1.0D, 1.0D).color(0, 0, 0, 255).endVertex();
  1746. worldrenderer.pos(-1.0D, -1.0D, -1.0D).color(0, 0, 0, 255).endVertex();
  1747. worldrenderer.pos(1.0D, -1.0D, -1.0D).color(0, 0, 0, 255).endVertex();
  1748. worldrenderer.pos(1.0D, (double) f18, -1.0D).color(0, 0, 0, 255).endVertex();
  1749. worldrenderer.pos(-1.0D, (double) f18, -1.0D).color(0, 0, 0, 255).endVertex();
  1750. worldrenderer.pos(1.0D, -1.0D, -1.0D).color(0, 0, 0, 255).endVertex();
  1751. worldrenderer.pos(1.0D, -1.0D, 1.0D).color(0, 0, 0, 255).endVertex();
  1752. worldrenderer.pos(1.0D, (double) f18, 1.0D).color(0, 0, 0, 255).endVertex();
  1753. worldrenderer.pos(1.0D, (double) f18, -1.0D).color(0, 0, 0, 255).endVertex();
  1754. worldrenderer.pos(-1.0D, (double) f18, -1.0D).color(0, 0, 0, 255).endVertex();
  1755. worldrenderer.pos(-1.0D, (double) f18, 1.0D).color(0, 0, 0, 255).endVertex();
  1756. worldrenderer.pos(-1.0D, -1.0D, 1.0D).color(0, 0, 0, 255).endVertex();
  1757. worldrenderer.pos(-1.0D, -1.0D, -1.0D).color(0, 0, 0, 255).endVertex();
  1758. worldrenderer.pos(-1.0D, -1.0D, -1.0D).color(0, 0, 0, 255).endVertex();
  1759. worldrenderer.pos(-1.0D, -1.0D, 1.0D).color(0, 0, 0, 255).endVertex();
  1760. worldrenderer.pos(1.0D, -1.0D, 1.0D).color(0, 0, 0, 255).endVertex();
  1761. worldrenderer.pos(1.0D, -1.0D, -1.0D).color(0, 0, 0, 255).endVertex();
  1762. tessellator.draw();
  1763. }
  1764.  
  1765. if (this.theWorld.provider.isSkyColored()) {
  1766. GlStateManager.color(f * 0.2F + 0.04F, f1 * 0.2F + 0.04F, f2 * 0.6F + 0.1F);
  1767. } else {
  1768. GlStateManager.color(f, f1, f2);
  1769. }
  1770.  
  1771. if (this.mc.gameSettings.renderDistanceChunks <= 4) {
  1772. GlStateManager.color(this.mc.entityRenderer.fogColorRed, this.mc.entityRenderer.fogColorGreen,
  1773. this.mc.entityRenderer.fogColorBlue);
  1774. }
  1775.  
  1776. GlStateManager.pushMatrix();
  1777. GlStateManager.translate(0.0F, -((float) (d0 - 16.0D)), 0.0F);
  1778.  
  1779. if (Config.isSkyEnabled()) {
  1780. GlStateManager.callList(this.glSkyList2);
  1781. }
  1782.  
  1783. GlStateManager.popMatrix();
  1784. GlStateManager.enableTexture2D();
  1785.  
  1786. if (flag1) {
  1787. Shaders.enableTexture2D();
  1788. }
  1789.  
  1790. GlStateManager.depthMask(true);
  1791. }
  1792. }
  1793.  
  1794. public void renderClouds(float partialTicks, int pass) {
  1795. if (!Config.isCloudsOff()) {
  1796. if (Reflector.ForgeWorldProvider_getCloudRenderer.exists()) {
  1797. WorldProvider worldprovider = this.mc.theWorld.provider;
  1798. Object object = Reflector.call(worldprovider, Reflector.ForgeWorldProvider_getCloudRenderer,
  1799. new Object[0]);
  1800.  
  1801. if (object != null) {
  1802. Reflector.callVoid(object, Reflector.IRenderHandler_render,
  1803. new Object[] { Float.valueOf(partialTicks), this.theWorld, this.mc });
  1804. return;
  1805. }
  1806. }
  1807.  
  1808. if (this.mc.theWorld.provider.isSurfaceWorld()) {
  1809. if (Config.isShaders()) {
  1810. Shaders.beginClouds();
  1811. }
  1812.  
  1813. if (Config.isCloudsFancy()) {
  1814. this.renderCloudsFancy(partialTicks, pass);
  1815. } else {
  1816. this.cloudRenderer.prepareToRender(false, this.cloudTickCounter, partialTicks);
  1817. partialTicks = 0.0F;
  1818. GlStateManager.disableCull();
  1819. float f9 = (float) (this.mc.getRenderViewEntity().lastTickPosY
  1820. + (this.mc.getRenderViewEntity().posY - this.mc.getRenderViewEntity().lastTickPosY)
  1821. * (double) partialTicks);
  1822. boolean flag = true;
  1823. boolean flag1 = true;
  1824. Tessellator tessellator = Tessellator.getInstance();
  1825. WorldRenderer worldrenderer = tessellator.getWorldRenderer();
  1826. this.renderEngine.bindTexture(locationCloudsPng);
  1827. GlStateManager.enableBlend();
  1828. GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
  1829.  
  1830. if (this.cloudRenderer.shouldUpdateGlList()) {
  1831. this.cloudRenderer.startUpdateGlList();
  1832. Vec3 vec3 = this.theWorld.getCloudColour(partialTicks);
  1833. float f = (float) vec3.xCoord;
  1834. float f1 = (float) vec3.yCoord;
  1835. float f2 = (float) vec3.zCoord;
  1836.  
  1837. if (pass != 2) {
  1838. float f3 = (f * 30.0F + f1 * 59.0F + f2 * 11.0F) / 100.0F;
  1839. float f4 = (f * 30.0F + f1 * 70.0F) / 100.0F;
  1840. float f5 = (f * 30.0F + f2 * 70.0F) / 100.0F;
  1841. f = f3;
  1842. f1 = f4;
  1843. f2 = f5;
  1844. }
  1845.  
  1846. float f10 = 4.8828125E-4F;
  1847. double d2 = (double) ((float) this.cloudTickCounter + partialTicks);
  1848. double d0 = this.mc.getRenderViewEntity().prevPosX
  1849. + (this.mc.getRenderViewEntity().posX - this.mc.getRenderViewEntity().prevPosX)
  1850. * (double) partialTicks
  1851. + d2 * 0.029999999329447746D;
  1852. double d1 = this.mc.getRenderViewEntity().prevPosZ
  1853. + (this.mc.getRenderViewEntity().posZ - this.mc.getRenderViewEntity().prevPosZ)
  1854. * (double) partialTicks;
  1855. int i = MathHelper.floor_double(d0 / 2048.0D);
  1856. int j = MathHelper.floor_double(d1 / 2048.0D);
  1857. d0 = d0 - (double) (i * 2048);
  1858. d1 = d1 - (double) (j * 2048);
  1859. float f6 = this.theWorld.provider.getCloudHeight() - f9 + 0.33F;
  1860. f6 = f6 + this.mc.gameSettings.ofCloudsHeight * 128.0F;
  1861. float f7 = (float) (d0 * 4.8828125E-4D);
  1862. float f8 = (float) (d1 * 4.8828125E-4D);
  1863. worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
  1864.  
  1865. for (int k = -256; k < 256; k += 32) {
  1866. for (int l = -256; l < 256; l += 32) {
  1867. worldrenderer.pos((double) (k + 0), (double) f6, (double) (l + 32))
  1868. .tex((double) ((float) (k + 0) * 4.8828125E-4F + f7),
  1869. (double) ((float) (l + 32) * 4.8828125E-4F + f8))
  1870. .color(f, f1, f2, 0.8F).endVertex();
  1871. worldrenderer.pos((double) (k + 32), (double) f6, (double) (l + 32))
  1872. .tex((double) ((float) (k + 32) * 4.8828125E-4F + f7),
  1873. (double) ((float) (l + 32) * 4.8828125E-4F + f8))
  1874. .color(f, f1, f2, 0.8F).endVertex();
  1875. worldrenderer.pos((double) (k + 32), (double) f6, (double) (l + 0))
  1876. .tex((double) ((float) (k + 32) * 4.8828125E-4F + f7),
  1877. (double) ((float) (l + 0) * 4.8828125E-4F + f8))
  1878. .color(f, f1, f2, 0.8F).endVertex();
  1879. worldrenderer.pos((double) (k + 0), (double) f6, (double) (l + 0))
  1880. .tex((double) ((float) (k + 0) * 4.8828125E-4F + f7),
  1881. (double) ((float) (l + 0) * 4.8828125E-4F + f8))
  1882. .color(f, f1, f2, 0.8F).endVertex();
  1883. }
  1884. }
  1885.  
  1886. tessellator.draw();
  1887. this.cloudRenderer.endUpdateGlList();
  1888. }
  1889.  
  1890. this.cloudRenderer.renderGlList();
  1891. GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
  1892. GlStateManager.disableBlend();
  1893. GlStateManager.enableCull();
  1894. }
  1895.  
  1896. if (Config.isShaders()) {
  1897. Shaders.endClouds();
  1898. }
  1899. }
  1900. }
  1901. }
  1902.  
  1903. /**
  1904. * Checks if the given position is to be rendered with cloud fog
  1905. */
  1906. public boolean hasCloudFog(double x, double y, double z, float partialTicks) {
  1907. return false;
  1908. }
  1909.  
  1910. private void renderCloudsFancy(float partialTicks, int pass) {
  1911. this.cloudRenderer.prepareToRender(true, this.cloudTickCounter, partialTicks);
  1912. partialTicks = 0.0F;
  1913. GlStateManager.disableCull();
  1914. float f = (float) (this.mc.getRenderViewEntity().lastTickPosY
  1915. + (this.mc.getRenderViewEntity().posY - this.mc.getRenderViewEntity().lastTickPosY)
  1916. * (double) partialTicks);
  1917. Tessellator tessellator = Tessellator.getInstance();
  1918. WorldRenderer worldrenderer = tessellator.getWorldRenderer();
  1919. float f1 = 12.0F;
  1920. float f2 = 4.0F;
  1921. double d0 = (double) ((float) this.cloudTickCounter + partialTicks);
  1922. double d1 = (this.mc.getRenderViewEntity().prevPosX
  1923. + (this.mc.getRenderViewEntity().posX - this.mc.getRenderViewEntity().prevPosX) * (double) partialTicks
  1924. + d0 * 0.029999999329447746D) / 12.0D;
  1925. double d2 = (this.mc.getRenderViewEntity().prevPosZ
  1926. + (this.mc.getRenderViewEntity().posZ - this.mc.getRenderViewEntity().prevPosZ) * (double) partialTicks)
  1927. / 12.0D + 0.33000001311302185D;
  1928. float f3 = this.theWorld.provider.getCloudHeight() - f + 0.33F;
  1929. f3 = f3 + this.mc.gameSettings.ofCloudsHeight * 128.0F;
  1930. int i = MathHelper.floor_double(d1 / 2048.0D);
  1931. int j = MathHelper.floor_double(d2 / 2048.0D);
  1932. d1 = d1 - (double) (i * 2048);
  1933. d2 = d2 - (double) (j * 2048);
  1934. this.renderEngine.bindTexture(locationCloudsPng);
  1935. GlStateManager.enableBlend();
  1936. GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
  1937. Vec3 vec3 = this.theWorld.getCloudColour(partialTicks);
  1938. float f4 = (float) vec3.xCoord;
  1939. float f5 = (float) vec3.yCoord;
  1940. float f6 = (float) vec3.zCoord;
  1941.  
  1942. if (pass != 2) {
  1943. float f7 = (f4 * 30.0F + f5 * 59.0F + f6 * 11.0F) / 100.0F;
  1944. float f8 = (f4 * 30.0F + f5 * 70.0F) / 100.0F;
  1945. float f9 = (f4 * 30.0F + f6 * 70.0F) / 100.0F;
  1946. f4 = f7;
  1947. f5 = f8;
  1948. f6 = f9;
  1949. }
  1950.  
  1951. float f26 = f4 * 0.9F;
  1952. float f27 = f5 * 0.9F;
  1953. float f28 = f6 * 0.9F;
  1954. float f10 = f4 * 0.7F;
  1955. float f11 = f5 * 0.7F;
  1956. float f12 = f6 * 0.7F;
  1957. float f13 = f4 * 0.8F;
  1958. float f14 = f5 * 0.8F;
  1959. float f15 = f6 * 0.8F;
  1960. float f16 = 0.00390625F;
  1961. float f17 = (float) MathHelper.floor_double(d1) * 0.00390625F;
  1962. float f18 = (float) MathHelper.floor_double(d2) * 0.00390625F;
  1963. float f19 = (float) (d1 - (double) MathHelper.floor_double(d1));
  1964. float f20 = (float) (d2 - (double) MathHelper.floor_double(d2));
  1965. boolean flag = true;
  1966. boolean flag1 = true;
  1967. float f21 = 9.765625E-4F;
  1968. GlStateManager.scale(12.0F, 1.0F, 12.0F);
  1969.  
  1970. for (int k = 0; k < 2; ++k) {
  1971. if (k == 0) {
  1972. GlStateManager.colorMask(false, false, false, false);
  1973. } else {
  1974. switch (pass) {
  1975. case 0:
  1976. GlStateManager.colorMask(false, true, true, true);
  1977. break;
  1978.  
  1979. case 1:
  1980. GlStateManager.colorMask(true, false, false, true);
  1981. break;
  1982.  
  1983. case 2:
  1984. GlStateManager.colorMask(true, true, true, true);
  1985. }
  1986. }
  1987.  
  1988. this.cloudRenderer.renderGlList();
  1989. }
  1990.  
  1991. if (this.cloudRenderer.shouldUpdateGlList()) {
  1992. this.cloudRenderer.startUpdateGlList();
  1993.  
  1994. for (int j1 = -3; j1 <= 4; ++j1) {
  1995. for (int l = -3; l <= 4; ++l) {
  1996. worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR_NORMAL);
  1997. float f22 = (float) (j1 * 8);
  1998. float f23 = (float) (l * 8);
  1999. float f24 = f22 - f19;
  2000. float f25 = f23 - f20;
  2001.  
  2002. if (f3 > -5.0F) {
  2003. worldrenderer.pos((double) (f24 + 0.0F), (double) (f3 + 0.0F), (double) (f25 + 8.0F))
  2004. .tex((double) ((f22 + 0.0F) * 0.00390625F + f17),
  2005. (double) ((f23 + 8.0F) * 0.00390625F + f18))
  2006. .color(f10, f11, f12, 0.8F).normal(0.0F, -1.0F, 0.0F).endVertex();
  2007. worldrenderer.pos((double) (f24 + 8.0F), (double) (f3 + 0.0F), (double) (f25 + 8.0F))
  2008. .tex((double) ((f22 + 8.0F) * 0.00390625F + f17),
  2009. (double) ((f23 + 8.0F) * 0.00390625F + f18))
  2010. .color(f10, f11, f12, 0.8F).normal(0.0F, -1.0F, 0.0F).endVertex();
  2011. worldrenderer.pos((double) (f24 + 8.0F), (double) (f3 + 0.0F), (double) (f25 + 0.0F))
  2012. .tex((double) ((f22 + 8.0F) * 0.00390625F + f17),
  2013. (double) ((f23 + 0.0F) * 0.00390625F + f18))
  2014. .color(f10, f11, f12, 0.8F).normal(0.0F, -1.0F, 0.0F).endVertex();
  2015. worldrenderer.pos((double) (f24 + 0.0F), (double) (f3 + 0.0F), (double) (f25 + 0.0F))
  2016. .tex((double) ((f22 + 0.0F) * 0.00390625F + f17),
  2017. (double) ((f23 + 0.0F) * 0.00390625F + f18))
  2018. .color(f10, f11, f12, 0.8F).normal(0.0F, -1.0F, 0.0F).endVertex();
  2019. }
  2020.  
  2021. if (f3 <= 5.0F) {
  2022. worldrenderer
  2023. .pos((double) (f24 + 0.0F), (double) (f3 + 4.0F - 9.765625E-4F), (double) (f25 + 8.0F))
  2024. .tex((double) ((f22 + 0.0F) * 0.00390625F + f17),
  2025. (double) ((f23 + 8.0F) * 0.00390625F + f18))
  2026. .color(f4, f5, f6, 0.8F).normal(0.0F, 1.0F, 0.0F).endVertex();
  2027. worldrenderer
  2028. .pos((double) (f24 + 8.0F), (double) (f3 + 4.0F - 9.765625E-4F), (double) (f25 + 8.0F))
  2029. .tex((double) ((f22 + 8.0F) * 0.00390625F + f17),
  2030. (double) ((f23 + 8.0F) * 0.00390625F + f18))
  2031. .color(f4, f5, f6, 0.8F).normal(0.0F, 1.0F, 0.0F).endVertex();
  2032. worldrenderer
  2033. .pos((double) (f24 + 8.0F), (double) (f3 + 4.0F - 9.765625E-4F), (double) (f25 + 0.0F))
  2034. .tex((double) ((f22 + 8.0F) * 0.00390625F + f17),
  2035. (double) ((f23 + 0.0F) * 0.00390625F + f18))
  2036. .color(f4, f5, f6, 0.8F).normal(0.0F, 1.0F, 0.0F).endVertex();
  2037. worldrenderer
  2038. .pos((double) (f24 + 0.0F), (double) (f3 + 4.0F - 9.765625E-4F), (double) (f25 + 0.0F))
  2039. .tex((double) ((f22 + 0.0F) * 0.00390625F + f17),
  2040. (double) ((f23 + 0.0F) * 0.00390625F + f18))
  2041. .color(f4, f5, f6, 0.8F).normal(0.0F, 1.0F, 0.0F).endVertex();
  2042. }
  2043.  
  2044. if (j1 > -1) {
  2045. for (int i1 = 0; i1 < 8; ++i1) {
  2046. worldrenderer
  2047. .pos((double) (f24 + (float) i1 + 0.0F), (double) (f3 + 0.0F),
  2048. (double) (f25 + 8.0F))
  2049. .tex((double) ((f22 + (float) i1 + 0.5F) * 0.00390625F + f17),
  2050. (double) ((f23 + 8.0F) * 0.00390625F + f18))
  2051. .color(f26, f27, f28, 0.8F).normal(-1.0F, 0.0F, 0.0F).endVertex();
  2052. worldrenderer
  2053. .pos((double) (f24 + (float) i1 + 0.0F), (double) (f3 + 4.0F),
  2054. (double) (f25 + 8.0F))
  2055. .tex((double) ((f22 + (float) i1 + 0.5F) * 0.00390625F + f17),
  2056. (double) ((f23 + 8.0F) * 0.00390625F + f18))
  2057. .color(f26, f27, f28, 0.8F).normal(-1.0F, 0.0F, 0.0F).endVertex();
  2058. worldrenderer
  2059. .pos((double) (f24 + (float) i1 + 0.0F), (double) (f3 + 4.0F),
  2060. (double) (f25 + 0.0F))
  2061. .tex((double) ((f22 + (float) i1 + 0.5F) * 0.00390625F + f17),
  2062. (double) ((f23 + 0.0F) * 0.00390625F + f18))
  2063. .color(f26, f27, f28, 0.8F).normal(-1.0F, 0.0F, 0.0F).endVertex();
  2064. worldrenderer
  2065. .pos((double) (f24 + (float) i1 + 0.0F), (double) (f3 + 0.0F),
  2066. (double) (f25 + 0.0F))
  2067. .tex((double) ((f22 + (float) i1 + 0.5F) * 0.00390625F + f17),
  2068. (double) ((f23 + 0.0F) * 0.00390625F + f18))
  2069. .color(f26, f27, f28, 0.8F).normal(-1.0F, 0.0F, 0.0F).endVertex();
  2070. }
  2071. }
  2072.  
  2073. if (j1 <= 1) {
  2074. for (int k1 = 0; k1 < 8; ++k1) {
  2075. worldrenderer
  2076. .pos((double) (f24 + (float) k1 + 1.0F - 9.765625E-4F), (double) (f3 + 0.0F),
  2077. (double) (f25 + 8.0F))
  2078. .tex((double) ((f22 + (float) k1 + 0.5F) * 0.00390625F + f17),
  2079. (double) ((f23 + 8.0F) * 0.00390625F + f18))
  2080. .color(f26, f27, f28, 0.8F).normal(1.0F, 0.0F, 0.0F).endVertex();
  2081. worldrenderer
  2082. .pos((double) (f24 + (float) k1 + 1.0F - 9.765625E-4F), (double) (f3 + 4.0F),
  2083. (double) (f25 + 8.0F))
  2084. .tex((double) ((f22 + (float) k1 + 0.5F) * 0.00390625F + f17),
  2085. (double) ((f23 + 8.0F) * 0.00390625F + f18))
  2086. .color(f26, f27, f28, 0.8F).normal(1.0F, 0.0F, 0.0F).endVertex();
  2087. worldrenderer
  2088. .pos((double) (f24 + (float) k1 + 1.0F - 9.765625E-4F), (double) (f3 + 4.0F),
  2089. (double) (f25 + 0.0F))
  2090. .tex((double) ((f22 + (float) k1 + 0.5F) * 0.00390625F + f17),
  2091. (double) ((f23 + 0.0F) * 0.00390625F + f18))
  2092. .color(f26, f27, f28, 0.8F).normal(1.0F, 0.0F, 0.0F).endVertex();
  2093. worldrenderer
  2094. .pos((double) (f24 + (float) k1 + 1.0F - 9.765625E-4F), (double) (f3 + 0.0F),
  2095. (double) (f25 + 0.0F))
  2096. .tex((double) ((f22 + (float) k1 + 0.5F) * 0.00390625F + f17),
  2097. (double) ((f23 + 0.0F) * 0.00390625F + f18))
  2098. .color(f26, f27, f28, 0.8F).normal(1.0F, 0.0F, 0.0F).endVertex();
  2099. }
  2100. }
  2101.  
  2102. if (l > -1) {
  2103. for (int l1 = 0; l1 < 8; ++l1) {
  2104. worldrenderer
  2105. .pos((double) (f24 + 0.0F), (double) (f3 + 4.0F),
  2106. (double) (f25 + (float) l1 + 0.0F))
  2107. .tex((double) ((f22 + 0.0F) * 0.00390625F + f17),
  2108. (double) ((f23 + (float) l1 + 0.5F) * 0.00390625F + f18))
  2109. .color(f13, f14, f15, 0.8F).normal(0.0F, 0.0F, -1.0F).endVertex();
  2110. worldrenderer
  2111. .pos((double) (f24 + 8.0F), (double) (f3 + 4.0F),
  2112. (double) (f25 + (float) l1 + 0.0F))
  2113. .tex((double) ((f22 + 8.0F) * 0.00390625F + f17),
  2114. (double) ((f23 + (float) l1 + 0.5F) * 0.00390625F + f18))
  2115. .color(f13, f14, f15, 0.8F).normal(0.0F, 0.0F, -1.0F).endVertex();
  2116. worldrenderer
  2117. .pos((double) (f24 + 8.0F), (double) (f3 + 0.0F),
  2118. (double) (f25 + (float) l1 + 0.0F))
  2119. .tex((double) ((f22 + 8.0F) * 0.00390625F + f17),
  2120. (double) ((f23 + (float) l1 + 0.5F) * 0.00390625F + f18))
  2121. .color(f13, f14, f15, 0.8F).normal(0.0F, 0.0F, -1.0F).endVertex();
  2122. worldrenderer
  2123. .pos((double) (f24 + 0.0F), (double) (f3 + 0.0F),
  2124. (double) (f25 + (float) l1 + 0.0F))
  2125. .tex((double) ((f22 + 0.0F) * 0.00390625F + f17),
  2126. (double) ((f23 + (float) l1 + 0.5F) * 0.00390625F + f18))
  2127. .color(f13, f14, f15, 0.8F).normal(0.0F, 0.0F, -1.0F).endVertex();
  2128. }
  2129. }
  2130.  
  2131. if (l <= 1) {
  2132. for (int i2 = 0; i2 < 8; ++i2) {
  2133. worldrenderer
  2134. .pos((double) (f24 + 0.0F), (double) (f3 + 4.0F),
  2135. (double) (f25 + (float) i2 + 1.0F - 9.765625E-4F))
  2136. .tex((double) ((f22 + 0.0F) * 0.00390625F + f17),
  2137. (double) ((f23 + (float) i2 + 0.5F) * 0.00390625F + f18))
  2138. .color(f13, f14, f15, 0.8F).normal(0.0F, 0.0F, 1.0F).endVertex();
  2139. worldrenderer
  2140. .pos((double) (f24 + 8.0F), (double) (f3 + 4.0F),
  2141. (double) (f25 + (float) i2 + 1.0F - 9.765625E-4F))
  2142. .tex((double) ((f22 + 8.0F) * 0.00390625F + f17),
  2143. (double) ((f23 + (float) i2 + 0.5F) * 0.00390625F + f18))
  2144. .color(f13, f14, f15, 0.8F).normal(0.0F, 0.0F, 1.0F).endVertex();
  2145. worldrenderer
  2146. .pos((double) (f24 + 8.0F), (double) (f3 + 0.0F),
  2147. (double) (f25 + (float) i2 + 1.0F - 9.765625E-4F))
  2148. .tex((double) ((f22 + 8.0F) * 0.00390625F + f17),
  2149. (double) ((f23 + (float) i2 + 0.5F) * 0.00390625F + f18))
  2150. .color(f13, f14, f15, 0.8F).normal(0.0F, 0.0F, 1.0F).endVertex();
  2151. worldrenderer
  2152. .pos((double) (f24 + 0.0F), (double) (f3 + 0.0F),
  2153. (double) (f25 + (float) i2 + 1.0F - 9.765625E-4F))
  2154. .tex((double) ((f22 + 0.0F) * 0.00390625F + f17),
  2155. (double) ((f23 + (float) i2 + 0.5F) * 0.00390625F + f18))
  2156. .color(f13, f14, f15, 0.8F).normal(0.0F, 0.0F, 1.0F).endVertex();
  2157. }
  2158. }
  2159.  
  2160. tessellator.draw();
  2161. }
  2162. }
  2163.  
  2164. this.cloudRenderer.endUpdateGlList();
  2165. }
  2166.  
  2167. GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
  2168. GlStateManager.disableBlend();
  2169. GlStateManager.enableCull();
  2170. }
  2171.  
  2172. public void updateChunks(long finishTimeNano) {
  2173. finishTimeNano = (long) ((double) finishTimeNano + 1.0E8D);
  2174. this.displayListEntitiesDirty |= this.renderDispatcher.runChunkUploads(finishTimeNano);
  2175.  
  2176. if (this.chunksToUpdateForced.size() > 0) {
  2177. Iterator iterator = this.chunksToUpdateForced.iterator();
  2178.  
  2179. while (iterator.hasNext()) {
  2180. RenderChunk renderchunk = (RenderChunk) iterator.next();
  2181.  
  2182. if (!this.renderDispatcher.updateChunkLater(renderchunk)) {
  2183. break;
  2184. }
  2185.  
  2186. renderchunk.setNeedsUpdate(false);
  2187. iterator.remove();
  2188. this.chunksToUpdate.remove(renderchunk);
  2189. this.chunksToResortTransparency.remove(renderchunk);
  2190. }
  2191. }
  2192.  
  2193. if (this.chunksToResortTransparency.size() > 0) {
  2194. Iterator iterator2 = this.chunksToResortTransparency.iterator();
  2195.  
  2196. if (iterator2.hasNext()) {
  2197. RenderChunk renderchunk2 = (RenderChunk) iterator2.next();
  2198.  
  2199. if (this.renderDispatcher.updateTransparencyLater(renderchunk2)) {
  2200. iterator2.remove();
  2201. }
  2202. }
  2203. }
  2204.  
  2205. int j = 0;
  2206. int k = Config.getUpdatesPerFrame();
  2207. int i = k * 2;
  2208. Iterator iterator1 = this.chunksToUpdate.iterator();
  2209.  
  2210. while (iterator1.hasNext()) {
  2211. RenderChunk renderchunk1 = (RenderChunk) iterator1.next();
  2212.  
  2213. if (!this.renderDispatcher.updateChunkLater(renderchunk1)) {
  2214. break;
  2215. }
  2216.  
  2217. renderchunk1.setNeedsUpdate(false);
  2218. iterator1.remove();
  2219.  
  2220. if (renderchunk1.getCompiledChunk().isEmpty() && k < i) {
  2221. ++k;
  2222. }
  2223.  
  2224. ++j;
  2225.  
  2226. if (j >= k) {
  2227. break;
  2228. }
  2229. }
  2230. }
  2231.  
  2232. public void renderWorldBorder(Entity p_180449_1_, float partialTicks) {
  2233. Tessellator tessellator = Tessellator.getInstance();
  2234. WorldRenderer worldrenderer = tessellator.getWorldRenderer();
  2235. WorldBorder worldborder = this.theWorld.getWorldBorder();
  2236. double d0 = (double) (this.mc.gameSettings.renderDistanceChunks * 16);
  2237.  
  2238. if (p_180449_1_.posX >= worldborder.maxX() - d0 || p_180449_1_.posX <= worldborder.minX() + d0
  2239. || p_180449_1_.posZ >= worldborder.maxZ() - d0 || p_180449_1_.posZ <= worldborder.minZ() + d0) {
  2240. double d1 = 1.0D - worldborder.getClosestDistance(p_180449_1_) / d0;
  2241. d1 = Math.pow(d1, 4.0D);
  2242. double d2 = p_180449_1_.lastTickPosX
  2243. + (p_180449_1_.posX - p_180449_1_.lastTickPosX) * (double) partialTicks;
  2244. double d3 = p_180449_1_.lastTickPosY
  2245. + (p_180449_1_.posY - p_180449_1_.lastTickPosY) * (double) partialTicks;
  2246. double d4 = p_180449_1_.lastTickPosZ
  2247. + (p_180449_1_.posZ - p_180449_1_.lastTickPosZ) * (double) partialTicks;
  2248. GlStateManager.enableBlend();
  2249. GlStateManager.tryBlendFuncSeparate(770, 1, 1, 0);
  2250. this.renderEngine.bindTexture(locationForcefieldPng);
  2251. GlStateManager.depthMask(false);
  2252. GlStateManager.pushMatrix();
  2253. int i = worldborder.getStatus().getID();
  2254. float f = (float) (i >> 16 & 255) / 255.0F;
  2255. float f1 = (float) (i >> 8 & 255) / 255.0F;
  2256. float f2 = (float) (i & 255) / 255.0F;
  2257. GlStateManager.color(f, f1, f2, (float) d1);
  2258. GlStateManager.doPolygonOffset(-3.0F, -3.0F);
  2259. GlStateManager.enablePolygonOffset();
  2260. GlStateManager.alphaFunc(516, 0.1F);
  2261. GlStateManager.enableAlpha();
  2262. GlStateManager.disableCull();
  2263. float f3 = (float) (Minecraft.getSystemTime() % 3000L) / 3000.0F;
  2264. float f4 = 0.0F;
  2265. float f5 = 0.0F;
  2266. float f6 = 128.0F;
  2267. worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX);
  2268. worldrenderer.setTranslation(-d2, -d3, -d4);
  2269. double d5 = Math.max((double) MathHelper.floor_double(d4 - d0), worldborder.minZ());
  2270. double d6 = Math.min((double) MathHelper.ceiling_double_int(d4 + d0), worldborder.maxZ());
  2271.  
  2272. if (d2 > worldborder.maxX() - d0) {
  2273. float f7 = 0.0F;
  2274.  
  2275. for (double d7 = d5; d7 < d6; f7 += 0.5F) {
  2276. double d8 = Math.min(1.0D, d6 - d7);
  2277. float f8 = (float) d8 * 0.5F;
  2278. worldrenderer.pos(worldborder.maxX(), 256.0D, d7).tex((double) (f3 + f7), (double) (f3 + 0.0F))
  2279. .endVertex();
  2280. worldrenderer.pos(worldborder.maxX(), 256.0D, d7 + d8)
  2281. .tex((double) (f3 + f8 + f7), (double) (f3 + 0.0F)).endVertex();
  2282. worldrenderer.pos(worldborder.maxX(), 0.0D, d7 + d8)
  2283. .tex((double) (f3 + f8 + f7), (double) (f3 + 128.0F)).endVertex();
  2284. worldrenderer.pos(worldborder.maxX(), 0.0D, d7).tex((double) (f3 + f7), (double) (f3 + 128.0F))
  2285. .endVertex();
  2286. ++d7;
  2287. }
  2288. }
  2289.  
  2290. if (d2 < worldborder.minX() + d0) {
  2291. float f9 = 0.0F;
  2292.  
  2293. for (double d9 = d5; d9 < d6; f9 += 0.5F) {
  2294. double d12 = Math.min(1.0D, d6 - d9);
  2295. float f12 = (float) d12 * 0.5F;
  2296. worldrenderer.pos(worldborder.minX(), 256.0D, d9).tex((double) (f3 + f9), (double) (f3 + 0.0F))
  2297. .endVertex();
  2298. worldrenderer.pos(worldborder.minX(), 256.0D, d9 + d12)
  2299. .tex((double) (f3 + f12 + f9), (double) (f3 + 0.0F)).endVertex();
  2300. worldrenderer.pos(worldborder.minX(), 0.0D, d9 + d12)
  2301. .tex((double) (f3 + f12 + f9), (double) (f3 + 128.0F)).endVertex();
  2302. worldrenderer.pos(worldborder.minX(), 0.0D, d9).tex((double) (f3 + f9), (double) (f3 + 128.0F))
  2303. .endVertex();
  2304. ++d9;
  2305. }
  2306. }
  2307.  
  2308. d5 = Math.max((double) MathHelper.floor_double(d2 - d0), worldborder.minX());
  2309. d6 = Math.min((double) MathHelper.ceiling_double_int(d2 + d0), worldborder.maxX());
  2310.  
  2311. if (d4 > worldborder.maxZ() - d0) {
  2312. float f10 = 0.0F;
  2313.  
  2314. for (double d10 = d5; d10 < d6; f10 += 0.5F) {
  2315. double d13 = Math.min(1.0D, d6 - d10);
  2316. float f13 = (float) d13 * 0.5F;
  2317. worldrenderer.pos(d10, 256.0D, worldborder.maxZ()).tex((double) (f3 + f10), (double) (f3 + 0.0F))
  2318. .endVertex();
  2319. worldrenderer.pos(d10 + d13, 256.0D, worldborder.maxZ())
  2320. .tex((double) (f3 + f13 + f10), (double) (f3 + 0.0F)).endVertex();
  2321. worldrenderer.pos(d10 + d13, 0.0D, worldborder.maxZ())
  2322. .tex((double) (f3 + f13 + f10), (double) (f3 + 128.0F)).endVertex();
  2323. worldrenderer.pos(d10, 0.0D, worldborder.maxZ()).tex((double) (f3 + f10), (double) (f3 + 128.0F))
  2324. .endVertex();
  2325. ++d10;
  2326. }
  2327. }
  2328.  
  2329. if (d4 < worldborder.minZ() + d0) {
  2330. float f11 = 0.0F;
  2331.  
  2332. for (double d11 = d5; d11 < d6; f11 += 0.5F) {
  2333. double d14 = Math.min(1.0D, d6 - d11);
  2334. float f14 = (float) d14 * 0.5F;
  2335. worldrenderer.pos(d11, 256.0D, worldborder.minZ()).tex((double) (f3 + f11), (double) (f3 + 0.0F))
  2336. .endVertex();
  2337. worldrenderer.pos(d11 + d14, 256.0D, worldborder.minZ())
  2338. .tex((double) (f3 + f14 + f11), (double) (f3 + 0.0F)).endVertex();
  2339. worldrenderer.pos(d11 + d14, 0.0D, worldborder.minZ())
  2340. .tex((double) (f3 + f14 + f11), (double) (f3 + 128.0F)).endVertex();
  2341. worldrenderer.pos(d11, 0.0D, worldborder.minZ()).tex((double) (f3 + f11), (double) (f3 + 128.0F))
  2342. .endVertex();
  2343. ++d11;
  2344. }
  2345. }
  2346.  
  2347. tessellator.draw();
  2348. worldrenderer.setTranslation(0.0D, 0.0D, 0.0D);
  2349. GlStateManager.enableCull();
  2350. GlStateManager.disableAlpha();
  2351. GlStateManager.doPolygonOffset(0.0F, 0.0F);
  2352. GlStateManager.disablePolygonOffset();
  2353. GlStateManager.enableAlpha();
  2354. GlStateManager.disableBlend();
  2355. GlStateManager.popMatrix();
  2356. GlStateManager.depthMask(true);
  2357. }
  2358. }
  2359.  
  2360. private void preRenderDamagedBlocks() {
  2361. GlStateManager.tryBlendFuncSeparate(774, 768, 1, 0);
  2362. GlStateManager.enableBlend();
  2363. GlStateManager.color(1.0F, 1.0F, 1.0F, 0.5F);
  2364. GlStateManager.doPolygonOffset(-3.0F, -3.0F);
  2365. GlStateManager.enablePolygonOffset();
  2366. GlStateManager.alphaFunc(516, 0.1F);
  2367. GlStateManager.enableAlpha();
  2368. GlStateManager.pushMatrix();
  2369.  
  2370. if (Config.isShaders()) {
  2371. ShadersRender.beginBlockDamage();
  2372. }
  2373. }
  2374.  
  2375. private void postRenderDamagedBlocks() {
  2376. GlStateManager.disableAlpha();
  2377. GlStateManager.doPolygonOffset(0.0F, 0.0F);
  2378. GlStateManager.disablePolygonOffset();
  2379. GlStateManager.enableAlpha();
  2380. GlStateManager.depthMask(true);
  2381. GlStateManager.popMatrix();
  2382.  
  2383. if (Config.isShaders()) {
  2384. ShadersRender.endBlockDamage();
  2385. }
  2386. }
  2387.  
  2388. public void drawBlockDamageTexture(Tessellator tessellatorIn, WorldRenderer worldRendererIn, Entity entityIn,
  2389. float partialTicks) {
  2390. double d0 = entityIn.lastTickPosX + (entityIn.posX - entityIn.lastTickPosX) * (double) partialTicks;
  2391. double d1 = entityIn.lastTickPosY + (entityIn.posY - entityIn.lastTickPosY) * (double) partialTicks;
  2392. double d2 = entityIn.lastTickPosZ + (entityIn.posZ - entityIn.lastTickPosZ) * (double) partialTicks;
  2393.  
  2394. if (!this.damagedBlocks.isEmpty()) {
  2395. this.renderEngine.bindTexture(TextureMap.locationBlocksTexture);
  2396. this.preRenderDamagedBlocks();
  2397. worldRendererIn.begin(7, DefaultVertexFormats.BLOCK);
  2398. worldRendererIn.setTranslation(-d0, -d1, -d2);
  2399. worldRendererIn.markDirty();
  2400. Iterator iterator = this.damagedBlocks.values().iterator();
  2401.  
  2402. while (iterator.hasNext()) {
  2403. DestroyBlockProgress destroyblockprogress = (DestroyBlockProgress) iterator.next();
  2404. BlockPos blockpos = destroyblockprogress.getPosition();
  2405. double d3 = (double) blockpos.getX() - d0;
  2406. double d4 = (double) blockpos.getY() - d1;
  2407. double d5 = (double) blockpos.getZ() - d2;
  2408. Block block = this.theWorld.getBlockState(blockpos).getBlock();
  2409. boolean flag;
  2410.  
  2411. if (Reflector.ForgeTileEntity_canRenderBreaking.exists()) {
  2412. boolean flag1 = block instanceof BlockChest || block instanceof BlockEnderChest
  2413. || block instanceof BlockSign || block instanceof BlockSkull;
  2414.  
  2415. if (!flag1) {
  2416. TileEntity tileentity = this.theWorld.getTileEntity(blockpos);
  2417.  
  2418. if (tileentity != null) {
  2419. flag1 = Reflector.callBoolean(tileentity, Reflector.ForgeTileEntity_canRenderBreaking,
  2420. new Object[0]);
  2421. }
  2422. }
  2423.  
  2424. flag = !flag1;
  2425. } else {
  2426. flag = !(block instanceof BlockChest) && !(block instanceof BlockEnderChest)
  2427. && !(block instanceof BlockSign) && !(block instanceof BlockSkull);
  2428. }
  2429.  
  2430. if (flag) {
  2431. if (d3 * d3 + d4 * d4 + d5 * d5 > 1024.0D) {
  2432. iterator.remove();
  2433. } else {
  2434. IBlockState iblockstate = this.theWorld.getBlockState(blockpos);
  2435.  
  2436. if (iblockstate.getBlock().getMaterial() != Material.air) {
  2437. int i = destroyblockprogress.getPartialBlockDamage();
  2438. TextureAtlasSprite textureatlassprite = this.destroyBlockIcons[i];
  2439. BlockRendererDispatcher blockrendererdispatcher = this.mc.getBlockRendererDispatcher();
  2440. blockrendererdispatcher.renderBlockDamage(iblockstate, blockpos, textureatlassprite,
  2441. this.theWorld);
  2442. }
  2443. }
  2444. }
  2445. }
  2446.  
  2447. tessellatorIn.draw();
  2448. worldRendererIn.setTranslation(0.0D, 0.0D, 0.0D);
  2449. this.postRenderDamagedBlocks();
  2450. }
  2451. }
  2452.  
  2453. /**
  2454. * Draws the selection box for the player. Args: entityPlayer, rayTraceHit, i,
  2455. * itemStack, partialTickTime
  2456. */
  2457. public void drawSelectionBox(EntityPlayer player, MovingObjectPosition movingObjectPositionIn, int p_72731_3_,
  2458. float partialTicks) {
  2459. if (p_72731_3_ == 0 && movingObjectPositionIn.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
  2460. GlStateManager.enableBlend();
  2461. GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
  2462. GlStateManager.color(0.0F, 0.0F, 0.0F, 0.4F);
  2463. GL11.glLineWidth(2.0F);
  2464. GlStateManager.disableTexture2D();
  2465.  
  2466. if (Config.isShaders()) {
  2467. Shaders.disableTexture2D();
  2468. }
  2469.  
  2470. GlStateManager.depthMask(false);
  2471. float f = 0.002F;
  2472. BlockPos blockpos = movingObjectPositionIn.getBlockPos();
  2473. Block block = this.theWorld.getBlockState(blockpos).getBlock();
  2474.  
  2475. if (block.getMaterial() != Material.air && this.theWorld.getWorldBorder().contains(blockpos)) {
  2476. block.setBlockBoundsBasedOnState(this.theWorld, blockpos);
  2477. double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double) partialTicks;
  2478. double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double) partialTicks;
  2479. double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double) partialTicks;
  2480. func_181561_a(block.getSelectedBoundingBox(this.theWorld, blockpos)
  2481. .expand(0.0020000000949949026D, 0.0020000000949949026D, 0.0020000000949949026D)
  2482. .offset(-d0, -d1, -d2));
  2483. }
  2484.  
  2485. GlStateManager.depthMask(true);
  2486. GlStateManager.enableTexture2D();
  2487.  
  2488. if (Config.isShaders()) {
  2489. Shaders.enableTexture2D();
  2490. }
  2491.  
  2492. GlStateManager.disableBlend();
  2493. }
  2494. }
  2495.  
  2496. public static void func_181561_a(AxisAlignedBB p_181561_0_) {
  2497. Tessellator tessellator = Tessellator.getInstance();
  2498. WorldRenderer worldrenderer = tessellator.getWorldRenderer();
  2499. worldrenderer.begin(3, DefaultVertexFormats.POSITION);
  2500. worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.minZ).endVertex();
  2501. worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.minZ).endVertex();
  2502. worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.maxZ).endVertex();
  2503. worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.maxZ).endVertex();
  2504. worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.minZ).endVertex();
  2505. tessellator.draw();
  2506. worldrenderer.begin(3, DefaultVertexFormats.POSITION);
  2507. worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.minZ).endVertex();
  2508. worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.minZ).endVertex();
  2509. worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.maxZ).endVertex();
  2510. worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.maxZ).endVertex();
  2511. worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.minZ).endVertex();
  2512. tessellator.draw();
  2513. worldrenderer.begin(1, DefaultVertexFormats.POSITION);
  2514. worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.minZ).endVertex();
  2515. worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.minZ).endVertex();
  2516. worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.minZ).endVertex();
  2517. worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.minZ).endVertex();
  2518. worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.minY, p_181561_0_.maxZ).endVertex();
  2519. worldrenderer.pos(p_181561_0_.maxX, p_181561_0_.maxY, p_181561_0_.maxZ).endVertex();
  2520. worldrenderer.pos(p_181561_0_.minX, p_181561_0_.minY, p_181561_0_.maxZ).endVertex();
  2521. worldrenderer.pos(p_181561_0_.minX, p_181561_0_.maxY, p_181561_0_.maxZ).endVertex();
  2522. tessellator.draw();
  2523. }
  2524.  
  2525. public static void func_181563_a(AxisAlignedBB p_181563_0_, int p_181563_1_, int p_181563_2_, int p_181563_3_,
  2526. int p_181563_4_) {
  2527. Tessellator tessellator = Tessellator.getInstance();
  2528. WorldRenderer worldrenderer = tessellator.getWorldRenderer();
  2529. worldrenderer.begin(3, DefaultVertexFormats.POSITION_COLOR);
  2530. worldrenderer.pos(p_181563_0_.minX, p_181563_0_.minY, p_181563_0_.minZ)
  2531. .color(p_181563_1_, p_181563_2_, p_181563_3_, p_181563_4_).endVertex();
  2532. worldrenderer.pos(p_181563_0_.maxX, p_181563_0_.minY, p_181563_0_.minZ)
  2533. .color(p_181563_1_, p_181563_2_, p_181563_3_, p_181563_4_).endVertex();
  2534. worldrenderer.pos(p_181563_0_.maxX, p_181563_0_.minY, p_181563_0_.maxZ)
  2535. .color(p_181563_1_, p_181563_2_, p_181563_3_, p_181563_4_).endVertex();
  2536. worldrenderer.pos(p_181563_0_.minX, p_181563_0_.minY, p_181563_0_.maxZ)
  2537. .color(p_181563_1_, p_181563_2_, p_181563_3_, p_181563_4_).endVertex();
  2538. worldrenderer.pos(p_181563_0_.minX, p_181563_0_.minY, p_181563_0_.minZ)
  2539. .color(p_181563_1_, p_181563_2_, p_181563_3_, p_181563_4_).endVertex();
  2540. tessellator.draw();
  2541. worldrenderer.begin(3, DefaultVertexFormats.POSITION_COLOR);
  2542. worldrenderer.pos(p_181563_0_.minX, p_181563_0_.maxY, p_181563_0_.minZ)
  2543. .color(p_181563_1_, p_181563_2_, p_181563_3_, p_181563_4_).endVertex();
  2544. worldrenderer.pos(p_181563_0_.maxX, p_181563_0_.maxY, p_181563_0_.minZ)
  2545. .color(p_181563_1_, p_181563_2_, p_181563_3_, p_181563_4_).endVertex();
  2546. worldrenderer.pos(p_181563_0_.maxX, p_181563_0_.maxY, p_181563_0_.maxZ)
  2547. .color(p_181563_1_, p_181563_2_, p_181563_3_, p_181563_4_).endVertex();
  2548. worldrenderer.pos(p_181563_0_.minX, p_181563_0_.maxY, p_181563_0_.maxZ)
  2549. .color(p_181563_1_, p_181563_2_, p_181563_3_, p_181563_4_).endVertex();
  2550. worldrenderer.pos(p_181563_0_.minX, p_181563_0_.maxY, p_181563_0_.minZ)
  2551. .color(p_181563_1_, p_181563_2_, p_181563_3_, p_181563_4_).endVertex();
  2552. tessellator.draw();
  2553. worldrenderer.begin(1, DefaultVertexFormats.POSITION_COLOR);
  2554. worldrenderer.pos(p_181563_0_.minX, p_181563_0_.minY, p_181563_0_.minZ)
  2555. .color(p_181563_1_, p_181563_2_, p_181563_3_, p_181563_4_).endVertex();
  2556. worldrenderer.pos(p_181563_0_.minX, p_181563_0_.maxY, p_181563_0_.minZ)
  2557. .color(p_181563_1_, p_181563_2_, p_181563_3_, p_181563_4_).endVertex();
  2558. worldrenderer.pos(p_181563_0_.maxX, p_181563_0_.minY, p_181563_0_.minZ)
  2559. .color(p_181563_1_, p_181563_2_, p_181563_3_, p_181563_4_).endVertex();
  2560. worldrenderer.pos(p_181563_0_.maxX, p_181563_0_.maxY, p_181563_0_.minZ)
  2561. .color(p_181563_1_, p_181563_2_, p_181563_3_, p_181563_4_).endVertex();
  2562. worldrenderer.pos(p_181563_0_.maxX, p_181563_0_.minY, p_181563_0_.maxZ)
  2563. .color(p_181563_1_, p_181563_2_, p_181563_3_, p_181563_4_).endVertex();
  2564. worldrenderer.pos(p_181563_0_.maxX, p_181563_0_.maxY, p_181563_0_.maxZ)
  2565. .color(p_181563_1_, p_181563_2_, p_181563_3_, p_181563_4_).endVertex();
  2566. worldrenderer.pos(p_181563_0_.minX, p_181563_0_.minY, p_181563_0_.maxZ)
  2567. .color(p_181563_1_, p_181563_2_, p_181563_3_, p_181563_4_).endVertex();
  2568. worldrenderer.pos(p_181563_0_.minX, p_181563_0_.maxY, p_181563_0_.maxZ)
  2569. .color(p_181563_1_, p_181563_2_, p_181563_3_, p_181563_4_).endVertex();
  2570. tessellator.draw();
  2571. }
  2572.  
  2573. /**
  2574. * Marks the blocks in the given range for update
  2575. */
  2576. private void markBlocksForUpdate(int x1, int y1, int z1, int x2, int y2, int z2) {
  2577. this.viewFrustum.markBlocksForUpdate(x1, y1, z1, x2, y2, z2);
  2578. }
  2579.  
  2580. public void markBlockForUpdate(BlockPos pos) {
  2581. int i = pos.getX();
  2582. int j = pos.getY();
  2583. int k = pos.getZ();
  2584. this.markBlocksForUpdate(i - 1, j - 1, k - 1, i + 1, j + 1, k + 1);
  2585. }
  2586.  
  2587. public void notifyLightSet(BlockPos pos) {
  2588. int i = pos.getX();
  2589. int j = pos.getY();
  2590. int k = pos.getZ();
  2591. this.markBlocksForUpdate(i - 1, j - 1, k - 1, i + 1, j + 1, k + 1);
  2592. }
  2593.  
  2594. /**
  2595. * On the client, re-renders all blocks in this range, inclusive. On the server,
  2596. * does nothing. Args: min x, min y, min z, max x, max y, max z
  2597. */
  2598. public void markBlockRangeForRenderUpdate(int x1, int y1, int z1, int x2, int y2, int z2) {
  2599. this.markBlocksForUpdate(x1 - 1, y1 - 1, z1 - 1, x2 + 1, y2 + 1, z2 + 1);
  2600. }
  2601.  
  2602. public void playRecord(String recordName, BlockPos blockPosIn) {
  2603. ISound isound = (ISound) this.mapSoundPositions.get(blockPosIn);
  2604.  
  2605. if (isound != null) {
  2606. this.mc.getSoundHandler().stopSound(isound);
  2607. this.mapSoundPositions.remove(blockPosIn);
  2608. }
  2609.  
  2610. if (recordName != null) {
  2611. ItemRecord itemrecord = ItemRecord.getRecord(recordName);
  2612.  
  2613. if (itemrecord != null) {
  2614. this.mc.ingameGUI.setRecordPlayingMessage(itemrecord.getRecordNameLocal());
  2615. }
  2616.  
  2617. ResourceLocation resourcelocation = null;
  2618.  
  2619. if (Reflector.ForgeItemRecord_getRecordResource.exists() && itemrecord != null) {
  2620. resourcelocation = (ResourceLocation) Reflector.call(itemrecord,
  2621. Reflector.ForgeItemRecord_getRecordResource, new Object[] { recordName });
  2622. }
  2623.  
  2624. if (resourcelocation == null) {
  2625. resourcelocation = new ResourceLocation(recordName);
  2626. }
  2627.  
  2628. PositionedSoundRecord positionedsoundrecord = PositionedSoundRecord.create(resourcelocation,
  2629. (float) blockPosIn.getX(), (float) blockPosIn.getY(), (float) blockPosIn.getZ());
  2630. this.mapSoundPositions.put(blockPosIn, positionedsoundrecord);
  2631. this.mc.getSoundHandler().playSound(positionedsoundrecord);
  2632. }
  2633. }
  2634.  
  2635. /**
  2636. * Plays the specified sound. Arg: soundName, x, y, z, volume, pitch
  2637. */
  2638. public void playSound(String soundName, double x, double y, double z, float volume, float pitch) {
  2639. }
  2640.  
  2641. /**
  2642. * Plays sound to all near players except the player reference given
  2643. */
  2644. public void playSoundToNearExcept(EntityPlayer except, String soundName, double x, double y, double z, float volume,
  2645. float pitch) {
  2646. }
  2647.  
  2648. public void spawnParticle(int particleID, boolean ignoreRange, final double xCoord, final double yCoord,
  2649. final double zCoord, double xOffset, double yOffset, double zOffset, int... p_180442_15_) {
  2650. try {
  2651. this.spawnEntityFX(particleID, ignoreRange, xCoord, yCoord, zCoord, xOffset, yOffset, zOffset,
  2652. p_180442_15_);
  2653. } catch (Throwable throwable) {
  2654. CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Exception while adding particle");
  2655. CrashReportCategory crashreportcategory = crashreport.makeCategory("Particle being added");
  2656. crashreportcategory.addCrashSection("ID", Integer.valueOf(particleID));
  2657.  
  2658. if (p_180442_15_ != null) {
  2659. crashreportcategory.addCrashSection("Parameters", p_180442_15_);
  2660. }
  2661.  
  2662. crashreportcategory.addCrashSectionCallable("Position", new Callable() {
  2663. private static final String __OBFID = "CL_00000955";
  2664.  
  2665. public String call() throws Exception {
  2666. return CrashReportCategory.getCoordinateInfo(xCoord, yCoord, zCoord);
  2667. }
  2668. });
  2669. throw new ReportedException(crashreport);
  2670. }
  2671. }
  2672.  
  2673. private void spawnParticle(EnumParticleTypes particleIn, double p_174972_2_, double p_174972_4_, double p_174972_6_,
  2674. double p_174972_8_, double p_174972_10_, double p_174972_12_, int... p_174972_14_) {
  2675. this.spawnParticle(particleIn.getParticleID(), particleIn.getShouldIgnoreRange(), p_174972_2_, p_174972_4_,
  2676. p_174972_6_, p_174972_8_, p_174972_10_, p_174972_12_, p_174972_14_);
  2677. }
  2678.  
  2679. private EntityFX spawnEntityFX(int p_174974_1_, boolean ignoreRange, double p_174974_3_, double p_174974_5_,
  2680. double p_174974_7_, double p_174974_9_, double p_174974_11_, double p_174974_13_, int... p_174974_15_) {
  2681. if (this.mc != null && this.mc.getRenderViewEntity() != null && this.mc.effectRenderer != null) {
  2682. int i = this.mc.gameSettings.particleSetting;
  2683.  
  2684. if (i == 1 && this.theWorld.rand.nextInt(3) == 0) {
  2685. i = 2;
  2686. }
  2687.  
  2688. double d0 = this.mc.getRenderViewEntity().posX - p_174974_3_;
  2689. double d1 = this.mc.getRenderViewEntity().posY - p_174974_5_;
  2690. double d2 = this.mc.getRenderViewEntity().posZ - p_174974_7_;
  2691.  
  2692. if (p_174974_1_ == EnumParticleTypes.EXPLOSION_HUGE.getParticleID() && !Config.isAnimatedExplosion()) {
  2693. return null;
  2694. } else if (p_174974_1_ == EnumParticleTypes.EXPLOSION_LARGE.getParticleID()
  2695. && !Config.isAnimatedExplosion()) {
  2696. return null;
  2697. } else if (p_174974_1_ == EnumParticleTypes.EXPLOSION_NORMAL.getParticleID()
  2698. && !Config.isAnimatedExplosion()) {
  2699. return null;
  2700. } else if (p_174974_1_ == EnumParticleTypes.SUSPENDED.getParticleID() && !Config.isWaterParticles()) {
  2701. return null;
  2702. } else if (p_174974_1_ == EnumParticleTypes.SUSPENDED_DEPTH.getParticleID() && !Config.isVoidParticles()) {
  2703. return null;
  2704. } else if (p_174974_1_ == EnumParticleTypes.SMOKE_NORMAL.getParticleID() && !Config.isAnimatedSmoke()) {
  2705. return null;
  2706. } else if (p_174974_1_ == EnumParticleTypes.SMOKE_LARGE.getParticleID() && !Config.isAnimatedSmoke()) {
  2707. return null;
  2708. } else if (p_174974_1_ == EnumParticleTypes.SPELL_MOB.getParticleID() && !Config.isPotionParticles()) {
  2709. return null;
  2710. } else if (p_174974_1_ == EnumParticleTypes.SPELL_MOB_AMBIENT.getParticleID()
  2711. && !Config.isPotionParticles()) {
  2712. return null;
  2713. } else if (p_174974_1_ == EnumParticleTypes.SPELL.getParticleID() && !Config.isPotionParticles()) {
  2714. return null;
  2715. } else if (p_174974_1_ == EnumParticleTypes.SPELL_INSTANT.getParticleID() && !Config.isPotionParticles()) {
  2716. return null;
  2717. } else if (p_174974_1_ == EnumParticleTypes.SPELL_WITCH.getParticleID() && !Config.isPotionParticles()) {
  2718. return null;
  2719. } else if (p_174974_1_ == EnumParticleTypes.PORTAL.getParticleID() && !Config.isAnimatedPortal()) {
  2720. return null;
  2721. } else if (p_174974_1_ == EnumParticleTypes.FLAME.getParticleID() && !Config.isAnimatedFlame()) {
  2722. return null;
  2723. } else if (p_174974_1_ == EnumParticleTypes.REDSTONE.getParticleID() && !Config.isAnimatedRedstone()) {
  2724. return null;
  2725. } else if (p_174974_1_ == EnumParticleTypes.DRIP_WATER.getParticleID() && !Config.isDrippingWaterLava()) {
  2726. return null;
  2727. } else if (p_174974_1_ == EnumParticleTypes.DRIP_LAVA.getParticleID() && !Config.isDrippingWaterLava()) {
  2728. return null;
  2729. } else if (p_174974_1_ == EnumParticleTypes.FIREWORKS_SPARK.getParticleID()
  2730. && !Config.isFireworkParticles()) {
  2731. return null;
  2732. } else if (ignoreRange) {
  2733. return this.mc.effectRenderer.spawnEffectParticle(p_174974_1_, p_174974_3_, p_174974_5_, p_174974_7_,
  2734. p_174974_9_, p_174974_11_, p_174974_13_, p_174974_15_);
  2735. } else {
  2736. double d3 = 16.0D;
  2737. double d4 = 256.0D;
  2738.  
  2739. if (p_174974_1_ == EnumParticleTypes.CRIT.getParticleID()) {
  2740. d4 = 38416.0D;
  2741. }
  2742.  
  2743. if (d0 * d0 + d1 * d1 + d2 * d2 > d4) {
  2744. return null;
  2745. } else if (i > 1) {
  2746. return null;
  2747. } else {
  2748. EntityFX entityfx = this.mc.effectRenderer.spawnEffectParticle(p_174974_1_, p_174974_3_,
  2749. p_174974_5_, p_174974_7_, p_174974_9_, p_174974_11_, p_174974_13_, p_174974_15_);
  2750.  
  2751. if (p_174974_1_ == EnumParticleTypes.WATER_BUBBLE.getParticleID()) {
  2752. CustomColors.updateWaterFX(entityfx, this.theWorld, p_174974_3_, p_174974_5_, p_174974_7_);
  2753. }
  2754.  
  2755. if (p_174974_1_ == EnumParticleTypes.WATER_SPLASH.getParticleID()) {
  2756. CustomColors.updateWaterFX(entityfx, this.theWorld, p_174974_3_, p_174974_5_, p_174974_7_);
  2757. }
  2758.  
  2759. if (p_174974_1_ == EnumParticleTypes.WATER_DROP.getParticleID()) {
  2760. CustomColors.updateWaterFX(entityfx, this.theWorld, p_174974_3_, p_174974_5_, p_174974_7_);
  2761. }
  2762.  
  2763. if (p_174974_1_ == EnumParticleTypes.TOWN_AURA.getParticleID()) {
  2764. CustomColors.updateMyceliumFX(entityfx);
  2765. }
  2766.  
  2767. if (p_174974_1_ == EnumParticleTypes.PORTAL.getParticleID()) {
  2768. CustomColors.updatePortalFX(entityfx);
  2769. }
  2770.  
  2771. if (p_174974_1_ == EnumParticleTypes.REDSTONE.getParticleID()) {
  2772. CustomColors.updateReddustFX(entityfx, this.theWorld, p_174974_3_, p_174974_5_, p_174974_7_);
  2773. }
  2774.  
  2775. return entityfx;
  2776. }
  2777. }
  2778. } else {
  2779. return null;
  2780. }
  2781. }
  2782.  
  2783. /**
  2784. * Called on all IWorldAccesses when an entity is created or loaded. On client
  2785. * worlds, starts downloading any necessary textures. On server worlds, adds the
  2786. * entity to the entity tracker.
  2787. */
  2788. public void onEntityAdded(Entity entityIn) {
  2789. RandomMobs.entityLoaded(entityIn, this.theWorld);
  2790.  
  2791. if (Config.isDynamicLights()) {
  2792. DynamicLights.entityAdded(entityIn, this);
  2793. }
  2794. }
  2795.  
  2796. /**
  2797. * Called on all IWorldAccesses when an entity is unloaded or destroyed. On
  2798. * client worlds, releases any downloaded textures. On server worlds, removes
  2799. * the entity from the entity tracker.
  2800. */
  2801. public void onEntityRemoved(Entity entityIn) {
  2802. if (Config.isDynamicLights()) {
  2803. DynamicLights.entityRemoved(entityIn, this);
  2804. }
  2805. }
  2806.  
  2807. /**
  2808. * Deletes all display lists
  2809. */
  2810. public void deleteAllDisplayLists() {
  2811. }
  2812.  
  2813. public void broadcastSound(int p_180440_1_, BlockPos p_180440_2_, int p_180440_3_) {
  2814. switch (p_180440_1_) {
  2815. case 1013:
  2816. case 1018:
  2817. if (this.mc.getRenderViewEntity() != null) {
  2818. double d0 = (double) p_180440_2_.getX() - this.mc.getRenderViewEntity().posX;
  2819. double d1 = (double) p_180440_2_.getY() - this.mc.getRenderViewEntity().posY;
  2820. double d2 = (double) p_180440_2_.getZ() - this.mc.getRenderViewEntity().posZ;
  2821. double d3 = Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2);
  2822. double d4 = this.mc.getRenderViewEntity().posX;
  2823. double d5 = this.mc.getRenderViewEntity().posY;
  2824. double d6 = this.mc.getRenderViewEntity().posZ;
  2825.  
  2826. if (d3 > 0.0D) {
  2827. d4 += d0 / d3 * 2.0D;
  2828. d5 += d1 / d3 * 2.0D;
  2829. d6 += d2 / d3 * 2.0D;
  2830. }
  2831.  
  2832. if (p_180440_1_ == 1013) {
  2833. this.theWorld.playSound(d4, d5, d6, "mob.wither.spawn", 1.0F, 1.0F, false);
  2834. } else {
  2835. this.theWorld.playSound(d4, d5, d6, "mob.enderdragon.end", 5.0F, 1.0F, false);
  2836. }
  2837. }
  2838.  
  2839. default:
  2840. }
  2841. }
  2842.  
  2843. public void playAuxSFX(EntityPlayer player, int sfxType, BlockPos blockPosIn, int p_180439_4_) {
  2844. Random random = this.theWorld.rand;
  2845.  
  2846. switch (sfxType) {
  2847. case 1000:
  2848. this.theWorld.playSoundAtPos(blockPosIn, "random.click", 1.0F, 1.0F, false);
  2849. break;
  2850.  
  2851. case 1001:
  2852. this.theWorld.playSoundAtPos(blockPosIn, "random.click", 1.0F, 1.2F, false);
  2853. break;
  2854.  
  2855. case 1002:
  2856. this.theWorld.playSoundAtPos(blockPosIn, "random.bow", 1.0F, 1.2F, false);
  2857. break;
  2858.  
  2859. case 1003:
  2860. this.theWorld.playSoundAtPos(blockPosIn, "random.door_open", 1.0F,
  2861. this.theWorld.rand.nextFloat() * 0.1F + 0.9F, false);
  2862. break;
  2863.  
  2864. case 1004:
  2865. this.theWorld.playSoundAtPos(blockPosIn, "random.fizz", 0.5F,
  2866. 2.6F + (random.nextFloat() - random.nextFloat()) * 0.8F, false);
  2867. break;
  2868.  
  2869. case 1005:
  2870. if (Item.getItemById(p_180439_4_) instanceof ItemRecord) {
  2871. this.theWorld.playRecord(blockPosIn,
  2872. "records." + ((ItemRecord) Item.getItemById(p_180439_4_)).recordName);
  2873. } else {
  2874. this.theWorld.playRecord(blockPosIn, (String) null);
  2875. }
  2876.  
  2877. break;
  2878.  
  2879. case 1006:
  2880. this.theWorld.playSoundAtPos(blockPosIn, "random.door_close", 1.0F,
  2881. this.theWorld.rand.nextFloat() * 0.1F + 0.9F, false);
  2882. break;
  2883.  
  2884. case 1007:
  2885. this.theWorld.playSoundAtPos(blockPosIn, "mob.ghast.charge", 10.0F,
  2886. (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F, false);
  2887. break;
  2888.  
  2889. case 1008:
  2890. this.theWorld.playSoundAtPos(blockPosIn, "mob.ghast.fireball", 10.0F,
  2891. (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F, false);
  2892. break;
  2893.  
  2894. case 1009:
  2895. this.theWorld.playSoundAtPos(blockPosIn, "mob.ghast.fireball", 2.0F,
  2896. (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F, false);
  2897. break;
  2898.  
  2899. case 1010:
  2900. this.theWorld.playSoundAtPos(blockPosIn, "mob.zombie.wood", 2.0F,
  2901. (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F, false);
  2902. break;
  2903.  
  2904. case 1011:
  2905. this.theWorld.playSoundAtPos(blockPosIn, "mob.zombie.metal", 2.0F,
  2906. (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F, false);
  2907. break;
  2908.  
  2909. case 1012:
  2910. this.theWorld.playSoundAtPos(blockPosIn, "mob.zombie.woodbreak", 2.0F,
  2911. (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F, false);
  2912. break;
  2913.  
  2914. case 1014:
  2915. this.theWorld.playSoundAtPos(blockPosIn, "mob.wither.shoot", 2.0F,
  2916. (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F, false);
  2917. break;
  2918.  
  2919. case 1015:
  2920. this.theWorld.playSoundAtPos(blockPosIn, "mob.bat.takeoff", 0.05F,
  2921. (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F, false);
  2922. break;
  2923.  
  2924. case 1016:
  2925. this.theWorld.playSoundAtPos(blockPosIn, "mob.zombie.infect", 2.0F,
  2926. (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F, false);
  2927. break;
  2928.  
  2929. case 1017:
  2930. this.theWorld.playSoundAtPos(blockPosIn, "mob.zombie.unfect", 2.0F,
  2931. (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F, false);
  2932. break;
  2933.  
  2934. case 1020:
  2935. this.theWorld.playSoundAtPos(blockPosIn, "random.anvil_break", 1.0F,
  2936. this.theWorld.rand.nextFloat() * 0.1F + 0.9F, false);
  2937. break;
  2938.  
  2939. case 1021:
  2940. this.theWorld.playSoundAtPos(blockPosIn, "random.anvil_use", 1.0F,
  2941. this.theWorld.rand.nextFloat() * 0.1F + 0.9F, false);
  2942. break;
  2943.  
  2944. case 1022:
  2945. this.theWorld.playSoundAtPos(blockPosIn, "random.anvil_land", 0.3F,
  2946. this.theWorld.rand.nextFloat() * 0.1F + 0.9F, false);
  2947. break;
  2948.  
  2949. case 2000:
  2950. int k = p_180439_4_ % 3 - 1;
  2951. int l = p_180439_4_ / 3 % 3 - 1;
  2952. double d13 = (double) blockPosIn.getX() + (double) k * 0.6D + 0.5D;
  2953. double d15 = (double) blockPosIn.getY() + 0.5D;
  2954. double d19 = (double) blockPosIn.getZ() + (double) l * 0.6D + 0.5D;
  2955.  
  2956. for (int l1 = 0; l1 < 10; ++l1) {
  2957. double d20 = random.nextDouble() * 0.2D + 0.01D;
  2958. double d21 = d13 + (double) k * 0.01D + (random.nextDouble() - 0.5D) * (double) l * 0.5D;
  2959. double d22 = d15 + (random.nextDouble() - 0.5D) * 0.5D;
  2960. double d23 = d19 + (double) l * 0.01D + (random.nextDouble() - 0.5D) * (double) k * 0.5D;
  2961. double d24 = (double) k * d20 + random.nextGaussian() * 0.01D;
  2962. double d9 = -0.03D + random.nextGaussian() * 0.01D;
  2963. double d10 = (double) l * d20 + random.nextGaussian() * 0.01D;
  2964. this.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d21, d22, d23, d24, d9, d10, new int[0]);
  2965. }
  2966.  
  2967. return;
  2968.  
  2969. case 2001:
  2970. Block block = Block.getBlockById(p_180439_4_ & 4095);
  2971.  
  2972. if (block.getMaterial() != Material.air) {
  2973. this.mc.getSoundHandler()
  2974. .playSound(new PositionedSoundRecord(new ResourceLocation(block.stepSound.getBreakSound()),
  2975. (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getFrequency() * 0.8F,
  2976. (float) blockPosIn.getX() + 0.5F, (float) blockPosIn.getY() + 0.5F,
  2977. (float) blockPosIn.getZ() + 0.5F));
  2978. }
  2979.  
  2980. this.mc.effectRenderer.addBlockDestroyEffects(blockPosIn, block.getStateFromMeta(p_180439_4_ >> 12 & 255));
  2981. break;
  2982.  
  2983. case 2002:
  2984. double d11 = (double) blockPosIn.getX();
  2985. double d12 = (double) blockPosIn.getY();
  2986. double d14 = (double) blockPosIn.getZ();
  2987.  
  2988. for (int i1 = 0; i1 < 8; ++i1) {
  2989. this.spawnParticle(EnumParticleTypes.ITEM_CRACK, d11, d12, d14, random.nextGaussian() * 0.15D,
  2990. random.nextDouble() * 0.2D, random.nextGaussian() * 0.15D,
  2991. new int[] { Item.getIdFromItem(Items.potionitem), p_180439_4_ });
  2992. }
  2993.  
  2994. int j1 = Items.potionitem.getColorFromDamage(p_180439_4_);
  2995. float f = (float) (j1 >> 16 & 255) / 255.0F;
  2996. float f1 = (float) (j1 >> 8 & 255) / 255.0F;
  2997. float f2 = (float) (j1 >> 0 & 255) / 255.0F;
  2998. EnumParticleTypes enumparticletypes = EnumParticleTypes.SPELL;
  2999.  
  3000. if (Items.potionitem.isEffectInstant(p_180439_4_)) {
  3001. enumparticletypes = EnumParticleTypes.SPELL_INSTANT;
  3002. }
  3003.  
  3004. for (int k1 = 0; k1 < 100; ++k1) {
  3005. double d16 = random.nextDouble() * 4.0D;
  3006. double d17 = random.nextDouble() * Math.PI * 2.0D;
  3007. double d18 = Math.cos(d17) * d16;
  3008. double d7 = 0.01D + random.nextDouble() * 0.5D;
  3009. double d8 = Math.sin(d17) * d16;
  3010. EntityFX entityfx = this.spawnEntityFX(enumparticletypes.getParticleID(),
  3011. enumparticletypes.getShouldIgnoreRange(), d11 + d18 * 0.1D, d12 + 0.3D, d14 + d8 * 0.1D, d18,
  3012. d7, d8, new int[0]);
  3013.  
  3014. if (entityfx != null) {
  3015. float f3 = 0.75F + random.nextFloat() * 0.25F;
  3016. entityfx.setRBGColorF(f * f3, f1 * f3, f2 * f3);
  3017. entityfx.multiplyVelocity((float) d16);
  3018. }
  3019. }
  3020.  
  3021. this.theWorld.playSoundAtPos(blockPosIn, "game.potion.smash", 1.0F,
  3022. this.theWorld.rand.nextFloat() * 0.1F + 0.9F, false);
  3023. break;
  3024.  
  3025. case 2003:
  3026. double var7 = (double) blockPosIn.getX() + 0.5D;
  3027. double var9 = (double) blockPosIn.getY();
  3028. double var11 = (double) blockPosIn.getZ() + 0.5D;
  3029.  
  3030. for (int var13 = 0; var13 < 8; ++var13) {
  3031. this.spawnParticle(EnumParticleTypes.ITEM_CRACK, var7, var9, var11, random.nextGaussian() * 0.15D,
  3032. random.nextDouble() * 0.2D, random.nextGaussian() * 0.15D,
  3033. new int[] { Item.getIdFromItem(Items.ender_eye) });
  3034. }
  3035.  
  3036. for (double var32 = 0.0D; var32 < (Math.PI * 2D); var32 += 0.15707963267948966D) {
  3037. this.spawnParticle(EnumParticleTypes.PORTAL, var7 + Math.cos(var32) * 5.0D, var9 - 0.4D,
  3038. var11 + Math.sin(var32) * 5.0D, Math.cos(var32) * -5.0D, 0.0D, Math.sin(var32) * -5.0D,
  3039. new int[0]);
  3040. this.spawnParticle(EnumParticleTypes.PORTAL, var7 + Math.cos(var32) * 5.0D, var9 - 0.4D,
  3041. var11 + Math.sin(var32) * 5.0D, Math.cos(var32) * -7.0D, 0.0D, Math.sin(var32) * -7.0D,
  3042. new int[0]);
  3043. }
  3044.  
  3045. return;
  3046.  
  3047. case 2004:
  3048. for (int var18 = 0; var18 < 20; ++var18) {
  3049. double d3 = (double) blockPosIn.getX() + 0.5D + ((double) this.theWorld.rand.nextFloat() - 0.5D) * 2.0D;
  3050. double d4 = (double) blockPosIn.getY() + 0.5D + ((double) this.theWorld.rand.nextFloat() - 0.5D) * 2.0D;
  3051. double d5 = (double) blockPosIn.getZ() + 0.5D + ((double) this.theWorld.rand.nextFloat() - 0.5D) * 2.0D;
  3052. this.theWorld.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d3, d4, d5, 0.0D, 0.0D, 0.0D, new int[0]);
  3053. this.theWorld.spawnParticle(EnumParticleTypes.FLAME, d3, d4, d5, 0.0D, 0.0D, 0.0D, new int[0]);
  3054. }
  3055.  
  3056. return;
  3057.  
  3058. case 2005:
  3059. ItemDye.spawnBonemealParticles(this.theWorld, blockPosIn, p_180439_4_);
  3060. }
  3061. }
  3062.  
  3063. public void sendBlockBreakProgress(int breakerId, BlockPos pos, int progress) {
  3064. if (progress >= 0 && progress < 10) {
  3065. DestroyBlockProgress destroyblockprogress = (DestroyBlockProgress) this.damagedBlocks
  3066. .get(Integer.valueOf(breakerId));
  3067.  
  3068. if (destroyblockprogress == null || destroyblockprogress.getPosition().getX() != pos.getX()
  3069. || destroyblockprogress.getPosition().getY() != pos.getY()
  3070. || destroyblockprogress.getPosition().getZ() != pos.getZ()) {
  3071. destroyblockprogress = new DestroyBlockProgress(breakerId, pos);
  3072. this.damagedBlocks.put(Integer.valueOf(breakerId), destroyblockprogress);
  3073. }
  3074.  
  3075. destroyblockprogress.setPartialBlockDamage(progress);
  3076. destroyblockprogress.setCloudUpdateTick(this.cloudTickCounter);
  3077. } else {
  3078. this.damagedBlocks.remove(Integer.valueOf(breakerId));
  3079. }
  3080. }
  3081.  
  3082. public void setDisplayListEntitiesDirty() {
  3083. this.displayListEntitiesDirty = true;
  3084. }
  3085.  
  3086. public void resetClouds() {
  3087. this.cloudRenderer.reset();
  3088. }
  3089.  
  3090. public int getCountRenderers() {
  3091. return this.viewFrustum.renderChunks.length;
  3092. }
  3093.  
  3094. public int getCountActiveRenderers() {
  3095. return this.renderInfos.size();
  3096. }
  3097.  
  3098. public int getCountEntitiesRendered() {
  3099. return this.countEntitiesRendered;
  3100. }
  3101.  
  3102. public int getCountTileEntitiesRendered() {
  3103. return this.countTileEntitiesRendered;
  3104. }
  3105.  
  3106. public RenderChunk getRenderChunk(BlockPos p_getRenderChunk_1_) {
  3107. return this.viewFrustum.getRenderChunk(p_getRenderChunk_1_);
  3108. }
  3109.  
  3110. public RenderChunk getRenderChunk(RenderChunk p_getRenderChunk_1_, EnumFacing p_getRenderChunk_2_) {
  3111. if (p_getRenderChunk_1_ == null) {
  3112. return null;
  3113. } else {
  3114. BlockPos blockpos = p_getRenderChunk_1_.func_181701_a(p_getRenderChunk_2_);
  3115. return this.viewFrustum.getRenderChunk(blockpos);
  3116. }
  3117. }
  3118.  
  3119. public WorldClient getWorld() {
  3120. return this.theWorld;
  3121. }
  3122.  
  3123. public void func_181023_a(Collection p_181023_1_, Collection p_181023_2_) {
  3124. Set set = this.field_181024_n;
  3125.  
  3126. synchronized (this.field_181024_n) {
  3127. this.field_181024_n.removeAll(p_181023_1_);
  3128. this.field_181024_n.addAll(p_181023_2_);
  3129. }
  3130. }
  3131.  
  3132. static final class RenderGlobal$2 {
  3133. static final int[] field_178037_a = new int[VertexFormatElement.EnumUsage.values().length];
  3134. private static final String __OBFID = "CL_00002535";
  3135.  
  3136. static {
  3137. try {
  3138. field_178037_a[VertexFormatElement.EnumUsage.POSITION.ordinal()] = 1;
  3139. } catch (NoSuchFieldError var3) {
  3140. ;
  3141. }
  3142.  
  3143. try {
  3144. field_178037_a[VertexFormatElement.EnumUsage.UV.ordinal()] = 2;
  3145. } catch (NoSuchFieldError var2) {
  3146. ;
  3147. }
  3148.  
  3149. try {
  3150. field_178037_a[VertexFormatElement.EnumUsage.COLOR.ordinal()] = 3;
  3151. } catch (NoSuchFieldError var1) {
  3152. ;
  3153. }
  3154. }
  3155. }
  3156.  
  3157. public static class ContainerLocalRenderInformation {
  3158. final RenderChunk renderChunk;
  3159. final EnumFacing facing;
  3160. final Set setFacing;
  3161. final int counter;
  3162. private static final String __OBFID = "CL_00002534";
  3163.  
  3164. public ContainerLocalRenderInformation(RenderChunk p_i4_1_, EnumFacing p_i4_2_, int p_i4_3_) {
  3165. this.setFacing = EnumSet.noneOf(EnumFacing.class);
  3166. this.renderChunk = p_i4_1_;
  3167. this.facing = p_i4_2_;
  3168. this.counter = p_i4_3_;
  3169. }
  3170.  
  3171. ContainerLocalRenderInformation(RenderChunk p_i5_1_, EnumFacing p_i5_2_, int p_i5_3_, Object p_i5_4_) {
  3172. this(p_i5_1_, p_i5_2_, p_i5_3_);
  3173. }
  3174. }
  3175. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement