unbad some code & made the game actually load

This commit is contained in:
PeytonPlayz595 2023-07-12 13:28:57 -04:00
parent 0dd66b6a48
commit ce09f9acf0
6 changed files with 177 additions and 116 deletions

View File

@ -141,8 +141,6 @@ public final class Minecraft implements Runnable {
public final void run() { public final void run() {
this.running = true; this.running = true;
//try {
Minecraft var1 = this; Minecraft var1 = this;
checkGLError("Pre startup"); checkGLError("Pre startup");
GL11.glEnable(3553); GL11.glEnable(3553);
@ -177,21 +175,18 @@ public final class Minecraft implements Runnable {
this.particleManager = new ParticleManager(this.level); this.particleManager = new ParticleManager(this.level);
checkGLError("Post startup"); checkGLError("Post startup");
this.hud = new HUDScreen(this, this.width, this.height); this.hud = new HUDScreen(this, this.width, this.height);
//} catch (Exception var62) {
//var62.printStackTrace();
//JOptionPane.showMessageDialog((Component)null, var62.toString(), "Failed to start Minecraft", 0);
//throw new RuntimeException("Failed to start Minecraft! :(");
//}
long var13 = System.currentTimeMillis(); long var13 = System.currentTimeMillis();
int var15 = 0; int var15 = 0;
try {
while(this.running) { while(this.running) {
if(this.waiting) { if(this.waiting) {
Thread.sleep(100L);
} else {
try { try {
Thread.sleep(100L);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else {
Timer var63 = this.timer; Timer var63 = this.timer;
long var16; long var16;
long var18 = (var16 = System.currentTimeMillis()) - var63.lastSysClock; long var18 = (var16 = System.currentTimeMillis()) - var63.lastSysClock;
@ -835,15 +830,20 @@ public final class Minecraft implements Runnable {
} }
if(this.settings.limitFramerate) { if(this.settings.limitFramerate) {
Thread.sleep(5L); try {
Thread.sleep(5L);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} }
checkGLError("Post render"); checkGLError("Post render");
++var15; ++var15;
} catch (Exception var58) { //} catch (Exception var58) {
this.setCurrentScreen(new ErrorScreen("Client error", "The game broke! [" + var58 + "]")); //this.setCurrentScreen(new ErrorScreen("Client error", "The game broke! [" + var58 + "]"));
var58.printStackTrace(); //var58.printStackTrace();
} //}
while(System.currentTimeMillis() >= var13 + 1000L) { while(System.currentTimeMillis() >= var13 + 1000L) {
this.debug = var15 + " fps, " + Chunk.chunkUpdates + " chunk updates"; this.debug = var15 + " fps, " + Chunk.chunkUpdates + " chunk updates";
@ -853,17 +853,6 @@ public final class Minecraft implements Runnable {
} }
} }
} }
return;
} catch (StopGameException var59) {
;
} catch (Exception var60) {
var60.printStackTrace();
return;
} finally {
this.shutdown();
}
} }
public final void grabMouse() { public final void grabMouse() {

View File

@ -33,7 +33,7 @@ public final class HUDScreen extends Screen {
public final void render(float var1, boolean var2, int var3, int var4) { public final void render(float var1, boolean var2, int var3, int var4) {
FontRenderer var5 = this.mc.fontRenderer; FontRenderer var5 = this.mc.fontRenderer;
this.mc.renderer.enableGuiMode(); this.mc.renderer.enableGuiMode();
new TextureLocation("/gui/gui.png.png").bindTexture(); new TextureLocation("/gui/gui.png").bindTexture();
ShapeRenderer var7 = ShapeRenderer.instance; ShapeRenderer var7 = ShapeRenderer.instance;
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glEnable(3042); GL11.glEnable(3042);

View File

@ -129,28 +129,27 @@ public final class ModelPart {
} }
public void generateList(float var1) { public void generateList(float var1) {
this.list = GL11.glGenLists(1); this.list = GL11.glGenLists(1);
GL11.glNewList(this.list, 4864); GL11.glNewList(this.list, 4864);
GL11.glBeginQuery(7); //GL11.glBegin(7);
for(int var2 = 0; var2 < this.quads.length; ++var2) { for(int var2 = 0; var2 < this.quads.length; ++var2) {
TexturedQuad var10000 = this.quads[var2]; TexturedQuad var10000 = this.quads[var2];
float var3 = var1; float var3 = var1;
TexturedQuad var4 = var10000; TexturedQuad var4 = var10000;
Vec3D var5 = var10000.vertices[1].vector.subtract(var4.vertices[0].vector).normalize(); Vec3D var5 = var10000.vertices[1].vector.subtract(var4.vertices[0].vector).normalize();
Vec3D var6 = var4.vertices[1].vector.subtract(var4.vertices[2].vector).normalize(); Vec3D var6 = var4.vertices[1].vector.subtract(var4.vertices[2].vector).normalize();
GL11.glNormal3f((var5 = (new Vec3D(var5.y * var6.z - var5.z * var6.y, var5.z * var6.x - var5.x * var6.z, var5.x * var6.y - var5.y * var6.x)).normalize()).x, var5.y, var5.z); GL11.glNormal3f((var5 = (new Vec3D(var5.y * var6.z - var5.z * var6.y, var5.z * var6.x - var5.x * var6.z, var5.x * var6.y - var5.y * var6.x)).normalize()).x, var5.y, var5.z);
for(int var7 = 0; var7 < 4; ++var7) { // for(int var7 = 0; var7 < 4; ++var7) {
Vertex var8; // Vertex var8;
final ModeBuffer mb = new ModeBuffer(1024); // GL11.glTexCoord2f((var8 = var4.vertices[var7]).u, var8.v);
mb.glTexCoord2f((var8 = var4.vertices[var7]).u, var8.v); // GL11.glVertex3f(var8.vector.x * var3, var8.vector.y * var3, var8.vector.z * var3);
mb.glVertex3f(var8.vector.x * var3, var8.vector.y * var3, var8.vector.z * var3); // }
} }
}
GL11.glEndQuery(); //GL11.glEnd();
GL11.glEndList(); GL11.glEndList();
this.hasList = true; this.hasList = true;
} }
} }

View File

@ -1,58 +1,107 @@
package com.mojang.minecraft.render; package com.mojang.minecraft.render;
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) braces deadcode
import java.io.IOException;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.IntBuffer; import java.nio.IntBuffer;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import com.mojang.minecraft.GameSettings; import com.mojang.minecraft.GameSettings;
import com.mojang.minecraft.Minecraft; import com.mojang.minecraft.Minecraft;
import com.mojang.minecraft.render.texture.TextureFX;
import net.lax1dude.eaglercraft.EaglerImage; import net.lax1dude.eaglercraft.EaglerImage;
import net.lax1dude.eaglercraft.GLAllocation; import net.lax1dude.eaglercraft.GLAllocation;
public class RenderEngine { public class RenderEngine {
public RenderEngine() { public RenderEngine() {
textureMap = new HashMap<String, Integer>(); textureMap = new HashMap<String, Integer>();
textureNameToImageMap = new HashMap(); textureNameToImageMap = new HashMap<Integer, EaglerImage>();
singleIntBuffer = GLAllocation.createDirectIntBuffer(1); singleIntBuffer = GLAllocation.createDirectIntBuffer(1);
imageDataB1 = GLAllocation.createDirectByteBuffer(0x100000); imageDataB1 = GLAllocation.createDirectByteBuffer(0x100000);
imageDataB2 = GLAllocation.createDirectByteBuffer(0x100000); imageDataB2 = GLAllocation.createDirectByteBuffer(0x100000);
textureList = new ArrayList<TextureFX>();
//useMipmaps = false;
options = Minecraft.settings; options = Minecraft.settings;
} }
public int getTexture(String s) { public int getTexture(String s) {
//TextureBase texturepackbase = new TextureBase(); TextureBase texturepackbase = new TextureBase();
Integer integer = (Integer) textureMap.get(s); Integer integer = (Integer) textureMap.get(s);
if (integer != null) { if (integer != null) {
return integer.intValue(); return integer.intValue();
} }
try {
singleIntBuffer.clear();
GLAllocation.generateTextureNames(singleIntBuffer);
int i = singleIntBuffer.get(0);
//if(s.equals("/terrain.png")) {
//useMipmaps = true;
//}
setupTexture(readTextureImage(texturepackbase.func_6481_a(s)), i);
//useMipmaps = false;
textureMap.put(s, Integer.valueOf(i));
return i;
} catch (IOException ioexception) {
throw new RuntimeException("!!");
}
}
public int allocateAndSetupTexture(EaglerImage bufferedimage) {
singleIntBuffer.clear(); singleIntBuffer.clear();
GLAllocation.generateTextureNames(singleIntBuffer); GLAllocation.generateTextureNames(singleIntBuffer);
int i = singleIntBuffer.get(0); int i = singleIntBuffer.get(0);
if(s.equals("/terrain.png")) { setupTexture(bufferedimage, i);
useMipmaps = true; textureNameToImageMap.put(Integer.valueOf(i), bufferedimage);
}
setupTexture(GL11.loadPNG(GL11.loadResourceBytes(s)), i);
useMipmaps = false;
textureMap.put(s, Integer.valueOf(i));
return i; return i;
} }
public void setupTexture(EaglerImage bufferedimage, int i) { public int allocateAndSetupTexture(byte[] data, int w, int h) {
int i = GL11.glGenTextures();
bindTexture(i); bindTexture(i);
if (useMipmaps) { GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10241 /* GL_TEXTURE_MIN_FILTER */, 9729 /* GL_LINEAR */);
GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10241 /* GL_TEXTURE_MIN_FILTER */, GL11.GL_NEAREST_MIPMAP_LINEAR); GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10240 /* GL_TEXTURE_MAG_FILTER */, 9728 /* GL_NEAREST */);
GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10240 /* GL_TEXTURE_MAG_FILTER */, GL11.GL_NEAREST /* GL_LINEAR */);
GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, GL11.GL_TEXTURE_MAX_LEVEL, 4);
} else {
GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10241 /* GL_TEXTURE_MIN_FILTER */, 9728 /* GL_NEAREST */);
GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10240 /* GL_TEXTURE_MAG_FILTER */, 9728 /* GL_NEAREST */);
}
GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10242 /* GL_TEXTURE_WRAP_S */, 10497 /* GL_REPEAT */); GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10242 /* GL_TEXTURE_WRAP_S */, 10497 /* GL_REPEAT */);
GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10243 /* GL_TEXTURE_WRAP_T */, 10497 /* GL_REPEAT */); GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10243 /* GL_TEXTURE_WRAP_T */, 10497 /* GL_REPEAT */);
imageDataB1.clear();
imageDataB1.put(data);
imageDataB1.position(0).limit(data.length);
GL11.glTexImage2D(3553 /* GL_TEXTURE_2D */, 0, 6408 /* GL_RGBA */, w, h, 0, 6408 /* GL_RGBA */,
5121 /* GL_UNSIGNED_BYTE */, imageDataB1);
return i;
}
public void setupTexture(EaglerImage bufferedimage, int i) {
bindTexture(i);
// if (useMipmaps) {
// GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10241 /* GL_TEXTURE_MIN_FILTER */, EaglerAdapter.GL_NEAREST_MIPMAP_LINEAR);
// GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10240 /* GL_TEXTURE_MAG_FILTER */, EaglerAdapter.GL_NEAREST /* GL_LINEAR */);
// GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, EaglerAdapter.GL_TEXTURE_MAX_LEVEL, 4);
// } else {
GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10241 /* GL_TEXTURE_MIN_FILTER */, 9728 /* GL_NEAREST */);
GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10240 /* GL_TEXTURE_MAG_FILTER */, 9728 /* GL_NEAREST */);
// }
// if (blurTexture) {
// EaglerAdapter.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10241 /* GL_TEXTURE_MIN_FILTER */, 9729 /* GL_LINEAR */);
// EaglerAdapter.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10240 /* GL_TEXTURE_MAG_FILTER */, 9729 /* GL_LINEAR */);
// }
// if (clampTexture) {
// EaglerAdapter.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10242 /* GL_TEXTURE_WRAP_S */, 10496 /* GL_CLAMP */);
// EaglerAdapter.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10243 /* GL_TEXTURE_WRAP_T */, 10496 /* GL_CLAMP */);
// } else {
GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10242 /* GL_TEXTURE_WRAP_S */, 10497 /* GL_REPEAT */);
GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10243 /* GL_TEXTURE_WRAP_T */, 10497 /* GL_REPEAT */);
// }
int j = bufferedimage.w; int j = bufferedimage.w;
int k = bufferedimage.h; int k = bufferedimage.h;
int ai[] = bufferedimage.data; int ai[] = bufferedimage.data;
@ -80,40 +129,58 @@ public class RenderEngine {
imageDataB1.position(0).limit(abyte0.length); imageDataB1.position(0).limit(abyte0.length);
GL11.glTexImage2D(3553 /* GL_TEXTURE_2D */, 0, 6408 /* GL_RGBA */, j, k, 0, 6408 /* GL_RGBA */, GL11.glTexImage2D(3553 /* GL_TEXTURE_2D */, 0, 6408 /* GL_RGBA */, j, k, 0, 6408 /* GL_RGBA */,
5121 /* GL_UNSIGNED_BYTE */, imageDataB1); 5121 /* GL_UNSIGNED_BYTE */, imageDataB1);
if (useMipmaps) { // if (useMipmaps) {
for (int i1 = 1; i1 <= 4; i1++) { // for (int i1 = 1; i1 <= 4; i1++) {
int k1 = j >> i1 - 1; // int k1 = j >> i1 - 1;
int i2 = j >> i1; // int i2 = j >> i1;
int k2 = k >> i1; // int k2 = k >> i1;
imageDataB2.clear(); // imageDataB2.clear();
for (int i3 = 0; i3 < i2; i3++) { // for (int i3 = 0; i3 < i2; i3++) {
for (int k3 = 0; k3 < k2; k3++) { // for (int k3 = 0; k3 < k2; k3++) {
int i4 = imageDataB1.getInt((i3 * 2 + 0 + (k3 * 2 + 0) * k1) * 4); // int i4 = imageDataB1.getInt((i3 * 2 + 0 + (k3 * 2 + 0) * k1) * 4);
int k4 = imageDataB1.getInt((i3 * 2 + 1 + (k3 * 2 + 0) * k1) * 4); // int k4 = imageDataB1.getInt((i3 * 2 + 1 + (k3 * 2 + 0) * k1) * 4);
int l4 = imageDataB1.getInt((i3 * 2 + 1 + (k3 * 2 + 1) * k1) * 4); // int l4 = imageDataB1.getInt((i3 * 2 + 1 + (k3 * 2 + 1) * k1) * 4);
int i5 = imageDataB1.getInt((i3 * 2 + 0 + (k3 * 2 + 1) * k1) * 4); // int i5 = imageDataB1.getInt((i3 * 2 + 0 + (k3 * 2 + 1) * k1) * 4);
int j5 = averageColor(averageColor(i4, k4), averageColor(l4, i5)); // int j5 = averageColor(averageColor(i4, k4), averageColor(l4, i5));
imageDataB2.putInt((i3 + k3 * i2) * 4, j5); // imageDataB2.putInt((i3 + k3 * i2) * 4, j5);
} // }
//
// }
//
// GL11.glTexImage2D(3553 /* GL_TEXTURE_2D */, i1, 6408 /* GL_RGBA */, i2, k2, 0, 6408 /* GL_RGBA */,
// 5121 /* GL_UNSIGNED_BYTE */, imageDataB2);
// ByteBuffer tmp = imageDataB1;
// imageDataB1 = imageDataB2;
// imageDataB2 = tmp;
// }
//
// }
}
} public void deleteTexture(int i) {
GL11.glDeleteTextures(i);
GL11.glTexImage2D(3553 /* GL_TEXTURE_2D */, i1, 6408 /* GL_RGBA */, i2, k2, 0, 6408 /* GL_RGBA */, }
5121 /* GL_UNSIGNED_BYTE */, imageDataB2);
ByteBuffer tmp = imageDataB1;
imageDataB1 = imageDataB2;
imageDataB2 = tmp;
}
} public int getTextureForDownloadableImage(String s, String s1) {
return getTexture("/mob/char.png");
} }
public void registerTextureFX(TextureFX texturefx) {
textureList.add(texturefx);
texturefx.animate();
}
private int averageColor(int i, int j) { private int averageColor(int i, int j) {
int k = (i & 0xff000000) >> 24 & 0xff; int k = (i & 0xff000000) >> 24 & 0xff;
int l = (j & 0xff000000) >> 24 & 0xff; int l = (j & 0xff000000) >> 24 & 0xff;
return ((k + l >> 1) << 24) + ((i & 0xfefefe) + (j & 0xfefefe) >> 1); return ((k + l >> 1) << 24) + ((i & 0xfefefe) + (j & 0xfefefe) >> 1);
} }
private EaglerImage readTextureImage(byte[] inputstream) throws IOException {
return GL11.loadPNG(inputstream);
}
public void bindTexture(int i) { public void bindTexture(int i) {
if (i < 0) { if (i < 0) {
return; return;
@ -122,21 +189,13 @@ public class RenderEngine {
return; return;
} }
} }
public int allocateAndSetupTexture(EaglerImage bufferedimage) { //public static boolean useMipmaps = false;
singleIntBuffer.clear();
GLAllocation.generateTextureNames(singleIntBuffer);
int i = singleIntBuffer.get(0);
setupTexture(bufferedimage, i);
textureNameToImageMap.put(Integer.valueOf(i), bufferedimage);
return i;
}
public static boolean useMipmaps = false;
private HashMap<String, Integer> textureMap; private HashMap<String, Integer> textureMap;
private HashMap<Integer, EaglerImage> textureNameToImageMap;
private IntBuffer singleIntBuffer; private IntBuffer singleIntBuffer;
private ByteBuffer imageDataB1; private ByteBuffer imageDataB1;
private ByteBuffer imageDataB2; private ByteBuffer imageDataB2;
private java.util.List<TextureFX> textureList;
private GameSettings options; private GameSettings options;
private HashMap<Integer, EaglerImage> textureNameToImageMap; }
}

View File

@ -0,0 +1,14 @@
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 byte[] func_6481_a(String s) {
return GL11.loadResourceBytes(s);
}
}

View File

@ -309,7 +309,7 @@ public class EaglerAdapterImpl2 {
}); });
initFileChooser(); initFileChooser();
EarlyLoadScreen.paintScreen(); //EarlyLoadScreen.paintScreen();
OpenState st = IndexedDBFilesystem.initialize(); OpenState st = IndexedDBFilesystem.initialize();
if(st != OpenState.OPENED) { if(st != OpenState.OPENED) {
@ -329,17 +329,17 @@ public class EaglerAdapterImpl2 {
e.printStackTrace(); e.printStackTrace();
} }
if(mouseEvents.isEmpty() && keyEvents.isEmpty() && !hasBeenActive()) { // if(mouseEvents.isEmpty() && keyEvents.isEmpty() && !hasBeenActive()) {
EarlyLoadScreen.paintEnable(); // EarlyLoadScreen.paintEnable();
//
while(mouseEvents.isEmpty() && keyEvents.isEmpty()) { // while(mouseEvents.isEmpty() && keyEvents.isEmpty()) {
try { // try {
Thread.sleep(100l); // Thread.sleep(100l);
} catch (InterruptedException e) { // } catch (InterruptedException e) {
; // ;
} // }
} // }
} // }
audioctx = AudioContext.create(); audioctx = AudioContext.create();