Performance patch part 1
Changes: - Fix chunks not rendering - Optifine zoom - Minimal entity updates - Fix some of Notch's shit code
This commit is contained in:
parent
3b165b26ff
commit
484b7b9e9b
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -1,2 +1,2 @@
|
||||||
|
gradle/
|
||||||
*.class
|
desktopRuntime/
|
|
@ -11,5 +11,6 @@
|
||||||
<classpathentry kind="lib" path="jars/lwjgl_util.jar"/>
|
<classpathentry kind="lib" path="jars/lwjgl_util.jar"/>
|
||||||
<classpathentry kind="lib" path="jars/lwjgl.jar"/>
|
<classpathentry kind="lib" path="jars/lwjgl.jar"/>
|
||||||
<classpathentry kind="lib" path="jars/lwjgl-opengles.jar"/>
|
<classpathentry kind="lib" path="jars/lwjgl-opengles.jar"/>
|
||||||
|
<classpathentry kind="lib" path="jars/Java-WebSocket-1.5.1-with-dependencies.jar"/>
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|
|
@ -2,8 +2,4 @@ package net.PeytonPlayz585.opengl;
|
||||||
|
|
||||||
public class GL11 extends EaglerAdapterGL30 {
|
public class GL11 extends EaglerAdapterGL30 {
|
||||||
|
|
||||||
public static void glPixelStorei(int glUnpackAlignment, int i) {
|
|
||||||
_wglPixelStorei(glUnpackAlignment, i);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -568,6 +568,12 @@ public abstract class Entity {
|
||||||
this.setPosition(this.posX, this.posY, this.posZ);
|
this.setPosition(this.posX, this.posY, this.posZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isInRangeToRenderDist(double var1) {
|
||||||
|
double var3 = this.boundingBox.getAverageEdgeLength();
|
||||||
|
var3 *= 64.0D * this.field_619_ac;
|
||||||
|
return var1 < var3 * var3;
|
||||||
|
}
|
||||||
|
|
||||||
public float getDistanceToEntity(Entity var1) {
|
public float getDistanceToEntity(Entity var1) {
|
||||||
float var2 = (float)(this.posX - var1.posX);
|
float var2 = (float)(this.posX - var1.posX);
|
||||||
float var3 = (float)(this.posY - var1.posY);
|
float var3 = (float)(this.posY - var1.posY);
|
||||||
|
|
|
@ -194,8 +194,50 @@ public class EntityLiving extends Entity {
|
||||||
this.field_9324_Y = var9;
|
this.field_9324_Y = var9;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean canSkipUpdate() {
|
||||||
|
if (this.hurtTime > 0) {
|
||||||
|
return false;
|
||||||
|
} else if (this.field_9311_be < 20) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
World world = this.worldObj;
|
||||||
|
|
||||||
|
if (world == null) {
|
||||||
|
return false;
|
||||||
|
} else if (world.playerEntities.size() != 1) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
Entity entity = (Entity)world.playerEntities.get(0);
|
||||||
|
double d0 = Math.max(Math.abs(this.posX - entity.posX) - 16.0D, 0.0D);
|
||||||
|
double d1 = Math.max(Math.abs(this.posZ - entity.posZ) - 16.0D, 0.0D);
|
||||||
|
double d2 = d0 * d0 + d1 * d1;
|
||||||
|
return !this.isInRangeToRenderDist(d2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onUpdateMinimal() {
|
||||||
|
++this.field_9344_ag;
|
||||||
|
|
||||||
|
if (this instanceof EntityMobs) {
|
||||||
|
float f = this.getEntityBrightness(1.0F);
|
||||||
|
|
||||||
|
if (f > 0.5F) {
|
||||||
|
this.field_9344_ag += 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.func_418_b_();
|
||||||
|
}
|
||||||
|
|
||||||
public void onUpdate() {
|
public void onUpdate() {
|
||||||
super.onUpdate();
|
|
||||||
|
if(this.canSkipUpdate()) {
|
||||||
|
this.onUpdateMinimal();
|
||||||
|
} else {
|
||||||
|
super.onUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
this.onLivingUpdate();
|
this.onLivingUpdate();
|
||||||
double var1 = this.posX - this.prevPosX;
|
double var1 = this.posX - this.prevPosX;
|
||||||
double var3 = this.posZ - this.prevPosZ;
|
double var3 = this.posZ - this.prevPosZ;
|
||||||
|
|
|
@ -12,6 +12,10 @@ import net.PeytonPlayz585.util.glu.GLU;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
|
||||||
public class EntityRenderer {
|
public class EntityRenderer {
|
||||||
|
|
||||||
|
private MouseFilter mouseFilterXAxis = new MouseFilter();
|
||||||
|
private MouseFilter mouseFilterYAxis = new MouseFilter();
|
||||||
|
|
||||||
private Minecraft mc;
|
private Minecraft mc;
|
||||||
private float field_1387_i = 0.0F;
|
private float field_1387_i = 0.0F;
|
||||||
public ItemRenderer field_1395_a;
|
public ItemRenderer field_1395_a;
|
||||||
|
@ -28,6 +32,8 @@ public class EntityRenderer {
|
||||||
private float field_1382_n;
|
private float field_1382_n;
|
||||||
private float field_1381_o;
|
private float field_1381_o;
|
||||||
|
|
||||||
|
private static boolean zoomMode = false;
|
||||||
|
|
||||||
private GameOverlayFramebuffer overlayFramebuffer;
|
private GameOverlayFramebuffer overlayFramebuffer;
|
||||||
|
|
||||||
public EntityRenderer(Minecraft var1) {
|
public EntityRenderer(Minecraft var1) {
|
||||||
|
@ -112,6 +118,27 @@ public class EntityRenderer {
|
||||||
var3 = 60.0F;
|
var3 = 60.0F;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean flag = false;
|
||||||
|
if(this.mc.currentScreen == null) {
|
||||||
|
flag = Keyboard.isKeyDown(this.mc.gameSettings.keyBindZoom.keyCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(flag) {
|
||||||
|
if(!zoomMode) {
|
||||||
|
zoomMode = true;
|
||||||
|
this.mc.gameSettings.ofZoom = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(zoomMode) {
|
||||||
|
var3 /= 4.0F;
|
||||||
|
}
|
||||||
|
} else if(zoomMode) {
|
||||||
|
zoomMode = false;
|
||||||
|
this.mc.gameSettings.ofZoom = false;
|
||||||
|
this.mouseFilterXAxis = new MouseFilter();
|
||||||
|
this.mouseFilterYAxis = new MouseFilter();
|
||||||
|
}
|
||||||
|
|
||||||
if(var2.health <= 0) {
|
if(var2.health <= 0) {
|
||||||
float var4 = (float)var2.deathTime + var1;
|
float var4 = (float)var2.deathTime + var1;
|
||||||
var3 /= (1.0F - 500.0F / (var4 + 500.0F)) * 2.0F + 1.0F;
|
var3 /= (1.0F - 500.0F / (var4 + 500.0F)) * 2.0F + 1.0F;
|
||||||
|
@ -285,6 +312,11 @@ public class EntityRenderer {
|
||||||
var6 = -1;
|
var6 = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(this.mc.gameSettings.ofZoom) {
|
||||||
|
var4 = this.mouseFilterXAxis.func_22386_a(var4, 0.05F * var3);
|
||||||
|
var5 = this.mouseFilterYAxis.func_22386_a(var5, 0.05F * var3);
|
||||||
|
}
|
||||||
|
|
||||||
this.mc.thePlayer.func_346_d(var4, var5 * (float)var6);
|
this.mc.thePlayer.func_346_d(var4, var5 * (float)var6);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,9 @@ public class EntitySorter implements Comparator {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int a(WorldRenderer var1, WorldRenderer var2) {
|
public int a(WorldRenderer var1, WorldRenderer var2) {
|
||||||
return var1.func_1202_a(this.field_1594_a) < var2.func_1202_a(this.field_1594_a) ? -1 : 1;
|
float f = var1.func_1202_a(field_1594_a);
|
||||||
|
float f1 = var2.func_1202_a(field_1594_a) ;
|
||||||
|
return f == f1 ? 0 : f >= f1 ? 1 : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int compare(Object var1, Object var2) {
|
public int compare(Object var1, Object var2) {
|
||||||
|
|
|
@ -35,13 +35,15 @@ public class GameSettings {
|
||||||
public KeyBinding keyBindChat = new KeyBinding("Chat", 20);
|
public KeyBinding keyBindChat = new KeyBinding("Chat", 20);
|
||||||
public KeyBinding keyBindToggleFog = new KeyBinding("Toggle fog", 33);
|
public KeyBinding keyBindToggleFog = new KeyBinding("Toggle fog", 33);
|
||||||
public KeyBinding keyBindSneak = new KeyBinding("Sneak", 42);
|
public KeyBinding keyBindSneak = new KeyBinding("Sneak", 42);
|
||||||
public KeyBinding[] keyBindings = new KeyBinding[]{this.keyBindForward, this.keyBindLeft, this.keyBindBack, this.keyBindRight, this.keyBindJump, this.keyBindSneak, this.keyBindDrop, this.keyBindInventory, this.keyBindChat, this.keyBindToggleFog};
|
public KeyBinding keyBindZoom = new KeyBinding("Zoom", 46);
|
||||||
|
public KeyBinding[] keyBindings = new KeyBinding[]{this.keyBindForward, this.keyBindLeft, this.keyBindBack, this.keyBindRight, this.keyBindJump, this.keyBindSneak, this.keyBindDrop, this.keyBindInventory, this.keyBindChat, this.keyBindToggleFog, this.keyBindZoom};
|
||||||
protected Minecraft mc;
|
protected Minecraft mc;
|
||||||
public int numberOfOptions = 10;
|
public int numberOfOptions = 10;
|
||||||
public int difficulty = 2;
|
public int difficulty = 2;
|
||||||
public boolean thirdPersonView = false;
|
public boolean thirdPersonView = false;
|
||||||
public String field_12259_z = "";
|
public String field_12259_z = "";
|
||||||
public String username = "";
|
public String username = "";
|
||||||
|
public boolean ofZoom = false;
|
||||||
|
|
||||||
public GameSettings(Minecraft var1) {
|
public GameSettings(Minecraft var1) {
|
||||||
this.mc = var1;
|
this.mc = var1;
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class GuiGameOver extends GuiScreen {
|
||||||
GL11.glScalef(2.0F, 2.0F, 2.0F);
|
GL11.glScalef(2.0F, 2.0F, 2.0F);
|
||||||
this.drawCenteredString(this.fontRenderer, "Game over!", this.width / 2 / 2, 30, 16777215);
|
this.drawCenteredString(this.fontRenderer, "Game over!", this.width / 2 / 2, 30, 16777215);
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
this.drawCenteredString(this.fontRenderer, "Score: &e" + this.mc.thePlayer.func_6417_t(), this.width / 2, 100, 16777215);
|
this.drawCenteredString(this.fontRenderer, "Score: " + this.mc.thePlayer.func_6417_t(), this.width / 2, 100, 16777215);
|
||||||
super.drawScreen(var1, var2, var3);
|
super.drawScreen(var1, var2, var3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
19
src/main/java/net/minecraft/src/MouseFilter.java
Normal file
19
src/main/java/net/minecraft/src/MouseFilter.java
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
package net.minecraft.src;
|
||||||
|
|
||||||
|
public class MouseFilter {
|
||||||
|
private float field_22388_a;
|
||||||
|
private float field_22387_b;
|
||||||
|
private float field_22389_c;
|
||||||
|
|
||||||
|
public float func_22386_a(float var1, float var2) {
|
||||||
|
this.field_22388_a += var1;
|
||||||
|
var1 = (this.field_22388_a - this.field_22387_b) * var2;
|
||||||
|
this.field_22389_c += (var1 - this.field_22389_c) * 0.5F;
|
||||||
|
if(var1 > 0.0F && var1 > this.field_22389_c || var1 < 0.0F && var1 < this.field_22389_c) {
|
||||||
|
var1 = this.field_22389_c;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.field_22387_b += var1;
|
||||||
|
return var1;
|
||||||
|
}
|
||||||
|
}
|
|
@ -47,7 +47,8 @@ public class RenderList {
|
||||||
|
|
||||||
if(this.field_1236_g.remaining() > 0) {
|
if(this.field_1236_g.remaining() > 0) {
|
||||||
GL11.glPushMatrix();
|
GL11.glPushMatrix();
|
||||||
GL11.glTranslatef((float)this.field_1242_a - this.field_1239_d, (float)this.field_1241_b - this.field_1238_e, (float)this.field_1240_c - this.field_1237_f);
|
//What the fuck notch???
|
||||||
|
GL11.glTranslatef(this.field_1242_a - this.field_1239_d, this.field_1241_b - this.field_1238_e, this.field_1240_c - this.field_1237_f);
|
||||||
GL11.glCallLists(this.field_1236_g);
|
GL11.glCallLists(this.field_1236_g);
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ public class WorldProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void generateLightBrightnessTable() {
|
protected void generateLightBrightnessTable() {
|
||||||
float var1 = 0.05F;
|
float var1 = 0.2F;
|
||||||
|
|
||||||
for(int var2 = 0; var2 <= 15; ++var2) {
|
for(int var2 = 0; var2 <= 15; ++var2) {
|
||||||
float var3 = 1.0F - (float)var2 / 15.0F;
|
float var3 = 1.0F - (float)var2 / 15.0F;
|
||||||
|
@ -63,8 +63,9 @@ public class WorldProvider {
|
||||||
public float[] func_4097_b(float var1, float var2) {
|
public float[] func_4097_b(float var1, float var2) {
|
||||||
float var3 = 0.4F;
|
float var3 = 0.4F;
|
||||||
float var4 = MathHelper.cos(var1 * (float)Math.PI * 2.0F) - 0.0F;
|
float var4 = MathHelper.cos(var1 * (float)Math.PI * 2.0F) - 0.0F;
|
||||||
if(var4 >= -var3 && var4 <= var3) {
|
float var5 = 0F;
|
||||||
float var6 = (var4) / var3 * 0.5F + 0.5F;
|
if(var4 >= var5 - var3 && var4 <= var5 + var3) {
|
||||||
|
float var6 = (var4 - var5) / var3 * 0.5F + 0.5F;
|
||||||
float var7 = 1.0F - (1.0F - MathHelper.sin(var6 * (float)Math.PI)) * 0.99F;
|
float var7 = 1.0F - (1.0F - MathHelper.sin(var6 * (float)Math.PI)) * 0.99F;
|
||||||
var7 *= var7;
|
var7 *= var7;
|
||||||
this.field_4217_f[0] = var6 * 0.3F + 0.7F;
|
this.field_4217_f[0] = var6 * 0.3F + 0.7F;
|
||||||
|
|
|
@ -68,9 +68,9 @@ public class WorldRenderer {
|
||||||
this.field_1753_k = var3 - this.field_1750_n;
|
this.field_1753_k = var3 - this.field_1750_n;
|
||||||
float var4 = 2.0F;
|
float var4 = 2.0F;
|
||||||
this.field_1736_v = AxisAlignedBB.getBoundingBox((double)((float)var1 - var4), (double)((float)var2 - var4), (double)((float)var3 - var4), (double)((float)(var1 + this.field_1758_f) + var4), (double)((float)(var2 + this.field_1757_g) + var4), (double)((float)(var3 + this.field_1756_h) + var4));
|
this.field_1736_v = AxisAlignedBB.getBoundingBox((double)((float)var1 - var4), (double)((float)var2 - var4), (double)((float)var3 - var4), (double)((float)(var1 + this.field_1758_f) + var4), (double)((float)(var2 + this.field_1757_g) + var4), (double)((float)(var3 + this.field_1756_h) + var4));
|
||||||
GL11.glNewList(this.field_1744_C + 2, GL11.GL_COMPILE);
|
//GL11.glNewList(this.field_1744_C + 2, GL11.GL_COMPILE);
|
||||||
//RenderItem.renderAABB(AxisAlignedBB.getBoundingBoxFromPool((double)((float)this.field_1752_l - var4), (double)((float)this.field_1751_m - var4), (double)((float)this.field_1750_n - var4), (double)((float)(this.field_1752_l + this.field_1758_f) + var4), (double)((float)(this.field_1751_m + this.field_1757_g) + var4), (double)((float)(this.field_1750_n + this.field_1756_h) + var4)));
|
//RenderItem.renderAABB(AxisAlignedBB.getBoundingBoxFromPool((double)((float)this.field_1752_l - var4), (double)((float)this.field_1751_m - var4), (double)((float)this.field_1750_n - var4), (double)((float)(this.field_1752_l + this.field_1758_f) + var4), (double)((float)(this.field_1751_m + this.field_1757_g) + var4), (double)((float)(this.field_1750_n + this.field_1756_h) + var4)));
|
||||||
GL11.glEndList();
|
//GL11.glEndList();
|
||||||
this.MarkDirty();
|
this.MarkDirty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -204,7 +204,8 @@ public class WorldRenderer {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean func_1196_e() {
|
public boolean func_1196_e() {
|
||||||
return !this.field_1739_E ? false : this.field_1748_p[0] && this.field_1748_p[1];
|
return !this.field_1739_E ? false : (this.field_1748_p[0] && this.field_1748_p[1]
|
||||||
|
&& !this.needsUpdate); // What the fuck!?
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MarkDirty() {
|
public void MarkDirty() {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user