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:
PeytonPlayz595 2024-10-13 01:57:10 -04:00
parent 3b165b26ff
commit 484b7b9e9b
13 changed files with 120 additions and 17 deletions

4
.gitignore vendored
View File

@ -1,2 +1,2 @@
*.class
gradle/
desktopRuntime/

View File

@ -11,5 +11,6 @@
<classpathentry kind="lib" path="jars/lwjgl_util.jar"/>
<classpathentry kind="lib" path="jars/lwjgl.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"/>
</classpath>

View File

@ -2,8 +2,4 @@ package net.PeytonPlayz585.opengl;
public class GL11 extends EaglerAdapterGL30 {
public static void glPixelStorei(int glUnpackAlignment, int i) {
_wglPixelStorei(glUnpackAlignment, i);
}
}

View File

@ -567,6 +567,12 @@ public abstract class Entity {
this.rotationPitch = var8;
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) {
float var2 = (float)(this.posX - var1.posX);

View File

@ -193,9 +193,51 @@ public class EntityLiving extends Entity {
this.field_9350_ad = (double)var8;
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() {
super.onUpdate();
if(this.canSkipUpdate()) {
this.onUpdateMinimal();
} else {
super.onUpdate();
}
this.onLivingUpdate();
double var1 = this.posX - this.prevPosX;
double var3 = this.posZ - this.prevPosZ;

View File

@ -12,6 +12,10 @@ import net.PeytonPlayz585.util.glu.GLU;
import net.minecraft.client.Minecraft;
public class EntityRenderer {
private MouseFilter mouseFilterXAxis = new MouseFilter();
private MouseFilter mouseFilterYAxis = new MouseFilter();
private Minecraft mc;
private float field_1387_i = 0.0F;
public ItemRenderer field_1395_a;
@ -28,6 +32,8 @@ public class EntityRenderer {
private float field_1382_n;
private float field_1381_o;
private static boolean zoomMode = false;
private GameOverlayFramebuffer overlayFramebuffer;
public EntityRenderer(Minecraft var1) {
@ -111,6 +117,27 @@ public class EntityRenderer {
if(var2.isInsideOfMaterial(Material.water)) {
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) {
float var4 = (float)var2.deathTime + var1;
@ -284,6 +311,11 @@ public class EntityRenderer {
if(this.mc.gameSettings.invertMouse) {
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);
}

View File

@ -10,7 +10,9 @@ public class EntitySorter implements Comparator {
}
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) {

View File

@ -35,13 +35,15 @@ public class GameSettings {
public KeyBinding keyBindChat = new KeyBinding("Chat", 20);
public KeyBinding keyBindToggleFog = new KeyBinding("Toggle fog", 33);
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;
public int numberOfOptions = 10;
public int difficulty = 2;
public boolean thirdPersonView = false;
public String field_12259_z = "";
public String username = "";
public boolean ofZoom = false;
public GameSettings(Minecraft var1) {
this.mc = var1;

View File

@ -38,7 +38,7 @@ public class GuiGameOver extends GuiScreen {
GL11.glScalef(2.0F, 2.0F, 2.0F);
this.drawCenteredString(this.fontRenderer, "Game over!", this.width / 2 / 2, 30, 16777215);
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);
}

View 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;
}
}

View File

@ -47,7 +47,8 @@ public class RenderList {
if(this.field_1236_g.remaining() > 0) {
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.glPopMatrix();
}

View File

@ -17,7 +17,7 @@ public class WorldProvider {
}
protected void generateLightBrightnessTable() {
float var1 = 0.05F;
float var1 = 0.2F;
for(int var2 = 0; var2 <= 15; ++var2) {
float var3 = 1.0F - (float)var2 / 15.0F;
@ -63,8 +63,9 @@ public class WorldProvider {
public float[] func_4097_b(float var1, float var2) {
float var3 = 0.4F;
float var4 = MathHelper.cos(var1 * (float)Math.PI * 2.0F) - 0.0F;
if(var4 >= -var3 && var4 <= var3) {
float var6 = (var4) / var3 * 0.5F + 0.5F;
float var5 = 0F;
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;
var7 *= var7;
this.field_4217_f[0] = var6 * 0.3F + 0.7F;

View File

@ -68,9 +68,9 @@ public class WorldRenderer {
this.field_1753_k = var3 - this.field_1750_n;
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));
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)));
GL11.glEndList();
//GL11.glEndList();
this.MarkDirty();
}
}
@ -204,7 +204,8 @@ public class WorldRenderer {
}
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() {