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() {
this.running = true;
//try {
Minecraft var1 = this;
checkGLError("Pre startup");
GL11.glEnable(3553);
@ -177,21 +175,18 @@ public final class Minecraft implements Runnable {
this.particleManager = new ParticleManager(this.level);
checkGLError("Post startup");
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();
int var15 = 0;
try {
while(this.running) {
if(this.waiting) {
Thread.sleep(100L);
} else {
try {
Thread.sleep(100L);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else {
Timer var63 = this.timer;
long var16;
long var18 = (var16 = System.currentTimeMillis()) - var63.lastSysClock;
@ -835,15 +830,20 @@ public final class Minecraft implements Runnable {
}
if(this.settings.limitFramerate) {
Thread.sleep(5L);
try {
Thread.sleep(5L);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
checkGLError("Post render");
++var15;
} catch (Exception var58) {
this.setCurrentScreen(new ErrorScreen("Client error", "The game broke! [" + var58 + "]"));
var58.printStackTrace();
}
//} catch (Exception var58) {
//this.setCurrentScreen(new ErrorScreen("Client error", "The game broke! [" + var58 + "]"));
//var58.printStackTrace();
//}
while(System.currentTimeMillis() >= var13 + 1000L) {
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() {

View File

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

View File

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

View File

@ -1,13 +1,23 @@
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.IntBuffer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.lwjgl.opengl.GL11;
import com.mojang.minecraft.GameSettings;
import com.mojang.minecraft.Minecraft;
import com.mojang.minecraft.render.texture.TextureFX;
import net.lax1dude.eaglercraft.EaglerImage;
import net.lax1dude.eaglercraft.GLAllocation;
@ -16,43 +26,82 @@ public class RenderEngine {
public RenderEngine() {
textureMap = new HashMap<String, Integer>();
textureNameToImageMap = new HashMap();
textureNameToImageMap = new HashMap<Integer, EaglerImage>();
singleIntBuffer = GLAllocation.createDirectIntBuffer(1);
imageDataB1 = GLAllocation.createDirectByteBuffer(0x100000);
imageDataB2 = GLAllocation.createDirectByteBuffer(0x100000);
textureList = new ArrayList<TextureFX>();
//useMipmaps = false;
options = Minecraft.settings;
}
public int getTexture(String s) {
//TextureBase texturepackbase = new TextureBase();
TextureBase texturepackbase = new TextureBase();
Integer integer = (Integer) textureMap.get(s);
if (integer != null) {
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();
GLAllocation.generateTextureNames(singleIntBuffer);
int i = singleIntBuffer.get(0);
if(s.equals("/terrain.png")) {
useMipmaps = true;
}
setupTexture(GL11.loadPNG(GL11.loadResourceBytes(s)), i);
useMipmaps = false;
textureMap.put(s, Integer.valueOf(i));
setupTexture(bufferedimage, i);
textureNameToImageMap.put(Integer.valueOf(i), bufferedimage);
return i;
}
public int allocateAndSetupTexture(byte[] data, int w, int h) {
int i = GL11.glGenTextures();
bindTexture(i);
GL11.glTexParameteri(3553 /* GL_TEXTURE_2D */, 10241 /* GL_TEXTURE_MIN_FILTER */, 9729 /* GL_LINEAR */);
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 */, 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 */, GL11.GL_NEAREST_MIPMAP_LINEAR);
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 */, 10243 /* GL_TEXTURE_WRAP_T */, 10497 /* GL_REPEAT */);
// 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 k = bufferedimage.h;
int ai[] = bufferedimage.data;
@ -80,38 +129,56 @@ public class RenderEngine {
imageDataB1.position(0).limit(abyte0.length);
GL11.glTexImage2D(3553 /* GL_TEXTURE_2D */, 0, 6408 /* GL_RGBA */, j, k, 0, 6408 /* GL_RGBA */,
5121 /* GL_UNSIGNED_BYTE */, imageDataB1);
if (useMipmaps) {
for (int i1 = 1; i1 <= 4; i1++) {
int k1 = j >> i1 - 1;
int i2 = j >> i1;
int k2 = k >> i1;
imageDataB2.clear();
for (int i3 = 0; i3 < i2; i3++) {
for (int k3 = 0; k3 < k2; k3++) {
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 l4 = imageDataB1.getInt((i3 * 2 + 1 + (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));
imageDataB2.putInt((i3 + k3 * i2) * 4, j5);
}
// if (useMipmaps) {
// for (int i1 = 1; i1 <= 4; i1++) {
// int k1 = j >> i1 - 1;
// int i2 = j >> i1;
// int k2 = k >> i1;
// imageDataB2.clear();
// for (int i3 = 0; i3 < i2; i3++) {
// for (int k3 = 0; k3 < k2; k3++) {
// 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 l4 = imageDataB1.getInt((i3 * 2 + 1 + (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));
// 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) {
int k = (i & 0xff000000) >> 24 & 0xff;
int l = (j & 0xff000000) >> 24 & 0xff;
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) {
@ -123,20 +190,12 @@ public class RenderEngine {
}
}
public int allocateAndSetupTexture(EaglerImage bufferedimage) {
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;
//public static boolean useMipmaps = false;
private HashMap<String, Integer> textureMap;
private HashMap<Integer, EaglerImage> textureNameToImageMap;
private IntBuffer singleIntBuffer;
private ByteBuffer imageDataB1;
private ByteBuffer imageDataB2;
private java.util.List<TextureFX> textureList;
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();
EarlyLoadScreen.paintScreen();
//EarlyLoadScreen.paintScreen();
OpenState st = IndexedDBFilesystem.initialize();
if(st != OpenState.OPENED) {
@ -329,17 +329,17 @@ public class EaglerAdapterImpl2 {
e.printStackTrace();
}
if(mouseEvents.isEmpty() && keyEvents.isEmpty() && !hasBeenActive()) {
EarlyLoadScreen.paintEnable();
while(mouseEvents.isEmpty() && keyEvents.isEmpty()) {
try {
Thread.sleep(100l);
} catch (InterruptedException e) {
;
}
}
}
// if(mouseEvents.isEmpty() && keyEvents.isEmpty() && !hasBeenActive()) {
// EarlyLoadScreen.paintEnable();
//
// while(mouseEvents.isEmpty() && keyEvents.isEmpty()) {
// try {
// Thread.sleep(100l);
// } catch (InterruptedException e) {
// ;
// }
// }
// }
audioctx = AudioContext.create();