MASSIVE BOOST & MEMORY LEAK FIX!

This commit is contained in:
PeytonPlayz595 2023-07-19 17:11:45 -04:00
parent 40d2195d48
commit 7b66ffceac
9 changed files with 2238 additions and 2262 deletions

4419
js/app.js

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>Main page</title>
<title>Shadow Client Classic</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<script type="text/javascript" charset="utf-8" src="app.js"></script>
<script type = text/javascript>
@ -9,12 +9,12 @@
alert("Offline Download is not yet supported, please upload all the game files to a HTTP(s) server");
} else {
window.addEventListener("load", function() {
window.classicConfig = ["game_frame","resources.epk"];
window.classicConfig = ["game","resources.mc"];
main();
});
}
</script>
</head>
<body style="margin:0px;width:100vw;height:100vh;" id="game_frame">
<body style="margin:0px;width:100vw;height:100vh;" id="game">
</body>
</html>

View File

@ -464,7 +464,7 @@ public final class Minecraft implements Runnable {
Collections.sort(var82.minecraft.levelRenderer.chunks, new ChunkDirtyDistanceComparator(var126));
var98 = var101.chunks.size() - 1;
int var105;
if((var105 = var101.chunks.size() / 2) > 3) {
if((var105 = var101.chunks.size()) > 3) {
var105 = 3;
}
@ -638,6 +638,7 @@ public final class Minecraft implements Runnable {
GL11.glColor4f(1.0F, 1.0F, 1.0F, (MathHelper.sin((float)System.currentTimeMillis() / 100.0F) * 0.2F + 0.4F) * 0.5F);
if(var89.cracks > 0.0F) {
GL11.glBlendFunc(774, 768);
var108 = new TextureLocation("/terrain.png").bindTexture();
GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.5F);
GL11.glPushMatrix();
Block var10000 = (var114 = var89.level.getTile(var102.x, var102.y, var102.z)) > 0?Block.blocks[var114]:null;

View File

@ -17,7 +17,7 @@ public final class LevelRenderer {
public Level level;
public int listId;
public IntBuffer buffer = GLAllocation.createDirectIntBuffer(4096);
public IntBuffer buffer = GLAllocation.createDirectIntBuffer(65536);
public List<Chunk> chunks = new ArrayList<Chunk>();
private Chunk[] loadQueue;
public Chunk[] chunkCache;
@ -26,7 +26,7 @@ public final class LevelRenderer {
private int zChunks;
private int baseListId;
public Minecraft minecraft;
private int[] chunkDataCache = new int[1024];
private int[] chunkDataCache = new int[4096];
public int ticks = 0;
private float lastLoadX = -9999.0F;
private float lastLoadY = -9999.0F;
@ -37,7 +37,7 @@ public final class LevelRenderer {
public LevelRenderer(Minecraft var1) {
this.minecraft = var1;
this.listId = GL11.glGenLists(2);
this.baseListId = GL11.glGenLists(4096);
this.baseListId = GL11.glGenLists(4096 << 6 << 1);
}
public final void refresh() {
@ -196,6 +196,7 @@ public final class LevelRenderer {
this.buffer.put(this.chunkDataCache, 0, var6);
this.buffer.flip();
if(this.buffer.remaining() > 0) {
new TextureLocation("/terrain.png").bindTexture();
GL11.glCallLists(this.buffer);
}

View File

@ -3,6 +3,7 @@ package com.mojang.minecraft.render;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.IntBuffer;
import java.util.HashMap;
import org.lwjgl.opengl.GL11;
@ -15,7 +16,6 @@ import net.lax1dude.eaglercraft.GLAllocation;
public class RenderEngine {
public RenderEngine() {
// textureMap = new HashMap<String, Integer>();
// textureNameToImageMap = new HashMap<Integer, EaglerImage>();
singleIntBuffer = GLAllocation.createDirectIntBuffer(1);
imageDataB1 = GLAllocation.createDirectByteBuffer(0x100000);
@ -25,11 +25,10 @@ public class RenderEngine {
}
public int getTexture(String s) {
// TextureBase texturepackbase = new TextureBase();
// Integer integer = (Integer) textureMap.get(s);
// if (integer != null) {
// return integer.intValue();
// }
Integer integer = (Integer) textureMap.get(s);
if (integer != null) {
return integer.intValue();
}
try {
singleIntBuffer.clear();
GLAllocation.generateTextureNames(singleIntBuffer);
@ -37,26 +36,15 @@ public class RenderEngine {
if(s.equals("/terrain.png") || s.contains("arrow") || s.contains("default")) {
textureBlending = true;
}
setupTexture(readTextureImage(TextureBase.func_6481_a(s)), i);
setupTexture(readTextureImage(GL11.loadResourceBytes(s)), i);
textureBlending = false;
// textureMap.put(s, Integer.valueOf(i));
textureMap.put(s, Integer.valueOf(i));
return i;
} catch (IOException ioexception) {
throw new RuntimeException("!!");
}
}
public int allocateAndSetupTexture(EaglerImage bufferedimage) {
singleIntBuffer.clear();
GLAllocation.generateTextureNames(singleIntBuffer);
int i = singleIntBuffer.get(0);
textureBlending = true;
setupTexture(bufferedimage, i);
textureBlending = false;
//textureNameToImageMap.put(Integer.valueOf(i), bufferedimage);
return i;
}
public void setupTexture(EaglerImage bufferedimage, int i) {
if(textureBlending) {
GL11.glEnable(GL11.GL_BLEND);
@ -115,6 +103,7 @@ public class RenderEngine {
}
}
public static HashMap<String, Integer> textureMap = new HashMap<String, Integer>();
private IntBuffer singleIntBuffer;
private ByteBuffer imageDataB1;
private GameSettings options;

View File

@ -1,14 +0,0 @@
package com.mojang.minecraft.render;
import org.lwjgl.opengl.GL11;
public class TextureBase {
public TextureBase() {
//This overrides the default Java constructor insuring non-instability
}
public static byte[] func_6481_a(String s) {
return GL11.loadResourceBytes(s);
}
}

View File

@ -73,7 +73,7 @@ public class Tessellator {
private int normal;
/** The static instance of the Tessellator. */
public static final Tessellator instance = new Tessellator(285000);
public static final Tessellator instance = new Tessellator(525000);
/** Whether this tessellator is currently in draw mode. */
private boolean isDrawing = false;
@ -111,11 +111,11 @@ public class Tessellator {
GL11.glEnableVertexAttrib(GL11.GL_COLOR_ARRAY);
}
// if (this.hasNormals) {
// GL11.glEnableVertexAttrib(GL11.GL_NORMAL_ARRAY);
// }
if (this.hasNormals) {
GL11.glEnableVertexAttrib(GL11.GL_NORMAL_ARRAY);
}
GL11.glDrawArrays(7, 0, this.vertexCount, Int32Array.create(intBuffer.getBuffer(), 0, this.vertexCount * 8));
GL11.glDrawArrays(7, 0, this.vertexCount, Int32Array.create(intBuffer.getBuffer(), 0, this.vertexCount * 7));
if (this.hasTexture) {
GL11.glDisableVertexAttrib(GL11.GL_TEXTURE_COORD_ARRAY);
@ -125,9 +125,9 @@ public class Tessellator {
GL11.glDisableVertexAttrib(GL11.GL_COLOR_ARRAY);
}
// if (this.hasNormals) {
// GL11.glDisableVertexAttrib(GL11.GL_NORMAL_ARRAY);
// }
if (this.hasNormals) {
GL11.glDisableVertexAttrib(GL11.GL_NORMAL_ARRAY);
}
}
int var1 = this.rawBufferIndex * 4;
@ -319,9 +319,9 @@ public class Tessellator {
public void setNormal(float par1, float par2, float par3) {
this.hasNormals = true;
float len = (float) Math.sqrt(par1 * par1 + par2 * par2 + par3 * par3);
int var4 = (int)((par1 / len) * 125.0F) + 125;
int var5 = (int)((par2 / len) * 125.0F) + 125;
int var6 = (int)((par3 / len) * 125.0F) + 125;
int var4 = (int)((par1 / len) * 127.0F) + 127;
int var5 = (int)((par2 / len) * 127.0F) + 127;
int var6 = (int)((par3 / len) * 127.0F) + 127;
this.normal = var4 & 255 | (var5 & 255) << 8 | (var6 & 255) << 16;
}