Made the game sorta playable :>

Fixed various crashes, fixed lighting and water, made the world actually render
This commit is contained in:
PeytonPlayz595 2024-05-12 20:55:14 -04:00
parent 363efd4066
commit 1153220af2
12 changed files with 69 additions and 125 deletions

View File

@ -437,12 +437,14 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 {
lightPos1vec.normalise();
Matrix4f.transform(matModelV[matModelPointer], lightPos0vec, lightPos0vec).normalise();
Matrix4f.transform(matModelV[matModelPointer], lightPos1vec, lightPos1vec).normalise();
lightPos0vec.x = -lightPos0vec.x;
lightPos1vec.x = -lightPos1vec.x;
lightPos0vec.y = -lightPos0vec.y;
lightPos1vec.y = -lightPos1vec.y;
lightPos0vec.z = -lightPos0vec.z;
lightPos1vec.z = -lightPos1vec.z;
//Maybe NOT flip light matrix???
lightPos0vec.x = lightPos0vec.x;
lightPos1vec.x = lightPos1vec.x;
lightPos0vec.y = lightPos0vec.y;
lightPos1vec.y = lightPos1vec.y;
lightPos0vec.z = lightPos0vec.z;
lightPos1vec.z = lightPos1vec.z;
}
public static final void revertLightMatrix() {

View File

@ -161,9 +161,6 @@ public class EaglerAdapterImpl2 {
@JSBody(params = { "v", "s" }, script = "window[v] = s;")
public static native void setDebugVar(String v, String s);
@JSBody(params = { }, script = "if(window.navigator.userActivation){return window.navigator.userActivation.hasBeenActive;}else{return false;}")
public static native boolean hasBeenActive();
public static HTMLDocument doc = null;
public static HTMLElement parent = null;

View File

@ -398,10 +398,6 @@ public class Minecraft implements Runnable {
while(this.running) {
try {
if(!GL11.hasBeenActive()) {
break;
}
AxisAlignedBB.clearBoundingBoxPool();
Vec3D.initialize();
@ -450,7 +446,7 @@ public class Minecraft implements Runnable {
this.entityRenderer.updateCameraAndRender(this.timer.renderPartialTicks);
}
if(!GL11.hasBeenActive()) {
if(!GL11.isFocused()) {
Thread.sleep(10L);
}
@ -610,7 +606,7 @@ public class Minecraft implements Runnable {
}
public void setIngameFocus() {
if(GL11.hasBeenActive()) {
if(GL11.isFocused()) {
if(!this.inGameHasFocus) {
this.inGameHasFocus = true;
this.mouseHelper.grabMouseCursor();

View File

@ -5,13 +5,15 @@ import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import org.lwjgl.opengl.GL11;
public class AchievementMap {
public static AchievementMap instance = new AchievementMap();
private Map guidMap = new HashMap();
private AchievementMap() {
try {
BufferedReader var1 = new BufferedReader(new InputStreamReader(AchievementMap.class.getResourceAsStream("/achievement/map.txt")));
BufferedReader var1 = new BufferedReader(new InputStreamReader(GL11.getResourceAsStream("/achievement/map.txt")));
while(true) {
String var2 = var1.readLine();

View File

@ -3,6 +3,8 @@ package net.minecraft.src;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import org.lwjgl.opengl.GL11;
public class ChatAllowedCharacters {
public static final String allowedCharacters = getAllowedCharacters();
public static final char[] allowedCharactersArray = new char[]{'/', '\n', '\r', '\t', '\u0000', '\f', '`', '?', '*', '\\', '<', '>', '|', '\"', ':'};
@ -11,7 +13,7 @@ public class ChatAllowedCharacters {
String var0 = "";
try {
BufferedReader var1 = new BufferedReader(new InputStreamReader(ChatAllowedCharacters.class.getResourceAsStream("/font.txt"), "UTF-8"));
BufferedReader var1 = new BufferedReader(new InputStreamReader(GL11.getResourceAsStream("/font.txt"), "UTF-8"));
String var2 = "";
while(true) {

View File

@ -324,7 +324,7 @@ public class EntityRenderer {
}
public void updateCameraAndRender(float var1) {
if(!GL11.hasBeenActive()) {
if(!GL11.isPointerLocked2()) {
if(System.currentTimeMillis() - this.prevFrameTime > 500L) {
this.mc.displayInGameMenu();
}
@ -510,25 +510,27 @@ public class EntityRenderer {
GL11.glEnable(GL11.GL_BLEND);
GL11.glDisable(GL11.GL_CULL_FACE);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.mc.renderEngine.getTexture("/terrain.png"));
if(this.mc.gameSettings.fancyGraphics) {
GL11.glColorMask(false, false, false, false);
var16 = var5.sortAndRender(var4, 1, (double)var1);
if(this.mc.gameSettings.anaglyph) {
if(anaglyphField == 0) {
GL11.glColorMask(false, true, true, true);
} else {
GL11.glColorMask(true, false, false, true);
}
} else {
GL11.glColorMask(true, true, true, true);
}
if(var16 > 0) {
var5.renderAllRenderLists(1, (double)var1);
}
} else {
//TODO: Find out why water is broken
// if(this.mc.gameSettings.fancyGraphics) {
// GL11.glColorMask(false, false, false, false);
// var16 = var5.sortAndRender(var4, 1, (double)var1);
// if(this.mc.gameSettings.anaglyph) {
// if(anaglyphField == 0) {
// GL11.glColorMask(false, true, true, true);
// } else {
// GL11.glColorMask(true, false, false, true);
// }
// } else {
// GL11.glColorMask(true, true, true, true);
// }
//
// if(var16 > 0) {
// var5.renderAllRenderLists(1, (double)var1);
// }
// } else {
var5.sortAndRender(var4, 1, (double)var1);
}
// }
GL11.glDepthMask(true);
GL11.glEnable(GL11.GL_CULL_FACE);

View File

@ -10,7 +10,6 @@ public class FontRenderer {
private int[] charWidth = new int[256];
public int fontTextureName = 0;
private int fontDisplayLists;
private IntBuffer buffer = GLAllocation.createDirectIntBuffer(1024);
public FontRenderer(GameSettings var1, String var2, RenderEngine var3) {
BufferedImage var4;
@ -76,7 +75,6 @@ public class FontRenderer {
var19.addVertexWithUV((double)(0.0F + var20), 0.0D, 0.0D, (double)(((float)var10 + var20) / 128.0F + var21), (double)((float)var11 / 128.0F + var23));
var19.addVertexWithUV(0.0D, 0.0D, 0.0D, (double)((float)var10 / 128.0F + var21), (double)((float)var11 / 128.0F + var23));
var19.draw();
GL11.glTranslatef((float)this.charWidth[var9], 0.0F, 0.0F);
GL11.glEndList();
}
@ -140,7 +138,6 @@ public class FontRenderer {
}
GL11.glColor4f(var10, var7, var8, var9);
this.buffer.clear();
GL11.glPushMatrix();
GL11.glTranslatef((float)var2, (float)var3, 0.0F);
@ -152,30 +149,19 @@ public class FontRenderer {
var11 = 15;
}
this.buffer.put(this.fontDisplayLists + 256 + var11 + (var5 ? 16 : 0));
if(this.buffer.remaining() == 0) {
this.buffer.flip();
GL11.glCallLists(this.buffer);
this.buffer.clear();
}
GL11.glCallList(fontDisplayLists + 256 + var11 + (var5 ? 16 : 0));
GL11.glTranslatef(charWidth[256 + var11 + (var5 ? 16 : 0)] * 0.5f, 0.0F, 0.0F);
}
if(var6 < var1.length()) {
var11 = ChatAllowedCharacters.allowedCharacters.indexOf(var1.charAt(var6));
if(var11 >= 0) {
this.buffer.put(this.fontDisplayLists + var11 + 32);
GL11.glCallList(fontDisplayLists + var11 + 32);
GL11.glTranslatef(charWidth[var11 + 32], 0.0F, 0.0F);
}
}
if(this.buffer.remaining() == 0) {
this.buffer.flip();
GL11.glCallLists(this.buffer);
this.buffer.clear();
}
}
this.buffer.flip();
GL11.glCallLists(this.buffer);
GL11.glPopMatrix();
}
}

View File

@ -18,7 +18,7 @@ public class GuiMainMenu extends GuiScreen {
public GuiMainMenu() {
try {
ArrayList var1 = new ArrayList();
BufferedReader var2 = new BufferedReader(new InputStreamReader(GuiMainMenu.class.getResourceAsStream("/title/splashes.txt"), Charset.forName("UTF-8")));
BufferedReader var2 = new BufferedReader(new InputStreamReader(GL11.getResourceAsStream("/title/splashes.txt"), Charset.forName("UTF-8")));
String var3 = "";
while(true) {

View File

@ -16,20 +16,6 @@ public class RenderHelper {
GL11.glEnable(GL11.GL_LIGHT1);
GL11.glEnable(GL11.GL_COLOR_MATERIAL);
GL11.glColorMaterial(GL11.GL_FRONT_AND_BACK, GL11.GL_AMBIENT_AND_DIFFUSE);
float var0 = 0.4F;
float var1 = 0.6F;
float var2 = 0.0F;
Vec3D var3 = Vec3D.createVector((double)0.2F, 1.0D, (double)-0.7F).normalize();
GL11.glRotatef((float)var3.xCoord, (float)var3.yCoord, (float)var3.zCoord, 0.0F);
GL11.glRotatef(var1, var1, var1, 1.0F);
GL11.glRotatef(0.0F, 0.0F, 0.0F, 1.0F);
GL11.glRotatef(var2, var2, var2, 1.0F);
GL11.glRotatef(var2, var0, var1, var2);
var3 = Vec3D.createVector((double)-0.2F, 1.0D, (double)0.7F).normalize();
GL11.glRotatef((float)var3.xCoord, (float)var3.yCoord, (float)var3.zCoord, 0.0F);
GL11.glRotatef(var1, var1, var1, 1.0F);
GL11.glRotatef(0.0F, 0.0F, 0.0F, 1.0F);
GL11.glRotatef(var2, var2, var2, 1.0F);
GL11.glPopMatrix();
GL11.copyModelToLightMatrix();
}
}

View File

@ -3,14 +3,16 @@ package net.minecraft.src;
import java.io.IOException;
import java.util.Properties;
import org.lwjgl.opengl.GL11;
public class StringTranslate {
private static StringTranslate instance = new StringTranslate();
private Properties translateTable = new Properties();
private StringTranslate() {
try {
this.translateTable.load(StringTranslate.class.getResourceAsStream("/lang/en_US.lang"));
this.translateTable.load(StringTranslate.class.getResourceAsStream("/lang/stats_US.lang"));
this.translateTable.load(GL11.getResourceAsStream("/lang/en_US.lang"));
this.translateTable.load(GL11.getResourceAsStream("/lang/stats_US.lang"));
} catch (IOException var2) {
var2.printStackTrace();
}

View File

@ -7,11 +7,11 @@ import org.teavm.jso.typedarrays.Float32Array;
import org.teavm.jso.typedarrays.Int32Array;
public class Tessellator {
private static boolean convertQuadsToTriangles = true;
private Int32Array intBuffer;
private Float32Array floatBuffer;
private int vertexCount = 0;
private double textureU;
private double textureV;
private float textureU;
private float textureV;
private int color;
private boolean hasColor = false;
private boolean hasTexture = false;
@ -31,6 +31,7 @@ public class Tessellator {
private Tessellator(int var1) {
this.bufferSize = var1;
ArrayBuffer a = ArrayBuffer.create(var1 * 4);
this.intBuffer = Int32Array.create(a);
this.floatBuffer = Float32Array.create(a);
}
@ -53,11 +54,7 @@ public class Tessellator {
}
GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
if(this.drawMode == 7 && convertQuadsToTriangles) {
GL11.glDrawArrays(GL11.GL_TRIANGLES, GL11.GL_POINTS, this.vertexCount, Int32Array.create(floatBuffer.getBuffer(), 0, this.vertexCount * 7));
} else {
GL11.glDrawArrays(this.drawMode, GL11.GL_POINTS, this.vertexCount, Int32Array.create(floatBuffer.getBuffer(), 0, this.vertexCount * 7));
}
GL11.glDrawArrays(this.drawMode, GL11.GL_POINTS, this.vertexCount, Int32Array.create(intBuffer.getBuffer(), 0, this.vertexCount * 7));
GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
if(this.hasTexture) {
@ -103,8 +100,8 @@ public class Tessellator {
public void setTextureUV(double var1, double var3) {
this.hasTexture = true;
this.textureU = var1;
this.textureV = var3;
this.textureU = (float) var1;
this.textureV = (float) var3;
}
public void setColorOpaque_F(float var1, float var2, float var3) {
@ -169,47 +166,30 @@ public class Tessellator {
}
public void addVertex(double var1, double var3, double var5) {
if(this.addedVertices > 65534) return;
++this.addedVertices;
Int32Array intBuffer0 = intBuffer;
Float32Array floatBuffer0 = floatBuffer;
if(this.drawMode == 7 && convertQuadsToTriangles && this.addedVertices % 4 == 0) {
for(int var7 = 0; var7 < 2; ++var7) {
int var8 = 8 * (3 - var7);
if(this.hasTexture) {
floatBuffer0.set(this.rawBufferIndex + 3, this.rawBufferIndex - var8 + 3);
floatBuffer0.set(this.rawBufferIndex + 4, this.rawBufferIndex - var8 + 4);
}
if(this.hasColor) {
floatBuffer0.set(this.rawBufferIndex + 5, this.rawBufferIndex - var8 + 5);
}
floatBuffer0.set(this.rawBufferIndex + 0, this.rawBufferIndex - var8 + 0);
floatBuffer0.set(this.rawBufferIndex + 1, this.rawBufferIndex - var8 + 1);
floatBuffer0.set(this.rawBufferIndex + 2, this.rawBufferIndex - var8 + 2);
++this.vertexCount;
this.rawBufferIndex += 8;
}
}
floatBuffer0.set(this.rawBufferIndex + 0, (float)(var1 + this.xOffset));
floatBuffer0.set(this.rawBufferIndex + 1, (float)(var3 + this.yOffset));
floatBuffer0.set(this.rawBufferIndex + 2, (float)(var5 + this.zOffset));
if(this.hasTexture) {
floatBuffer0.set(this.rawBufferIndex + 3, Float.floatToRawIntBits((float)this.textureU));
floatBuffer0.set(this.rawBufferIndex + 4, Float.floatToRawIntBits((float)this.textureV));
floatBuffer0.set(this.rawBufferIndex + 3, this.textureU);
floatBuffer0.set(this.rawBufferIndex + 4, this.textureV);
}
if(this.hasColor) {
floatBuffer0.set(this.rawBufferIndex + 5, this.color);
intBuffer0.set(this.rawBufferIndex + 5, this.color);
}
if(this.hasNormals) {
floatBuffer0.set(this.rawBufferIndex + 6, this.normal);
intBuffer0.set(this.rawBufferIndex + 6, this.normal);
}
floatBuffer0.set(this.rawBufferIndex + 0, Float.floatToRawIntBits((float)(var1 + this.xOffset)));
floatBuffer0.set(this.rawBufferIndex + 1, Float.floatToRawIntBits((float)(var3 + this.yOffset)));
floatBuffer0.set(this.rawBufferIndex + 2, Float.floatToRawIntBits((float)(var5 + this.zOffset)));
this.rawBufferIndex += 8;
this.rawBufferIndex += 7;
++this.vertexCount;
if(this.vertexCount % 4 == 0 && this.rawBufferIndex >= this.bufferSize - 32) {
this.draw();

View File

@ -67,17 +67,13 @@ public class WorldRenderer {
this.posZMinus = var3 - this.posZClip;
float var4 = 6.0F;
this.rendererBoundingBox = AxisAlignedBB.getBoundingBox((double)((float)var1 - var4), (double)((float)var2 - var4), (double)((float)var3 - var4), (double)((float)(var1 + this.sizeWidth) + var4), (double)((float)(var2 + this.sizeHeight) + var4), (double)((float)(var3 + this.sizeDepth) + var4));
GL11.glNewList(this.glRenderList + 2, GL11.GL_COMPILE);
RenderItem.renderAABB(AxisAlignedBB.getBoundingBoxFromPool((double)((float)this.posXClip - var4), (double)((float)this.posYClip - var4), (double)((float)this.posZClip - var4), (double)((float)(this.posXClip + this.sizeWidth) + var4), (double)((float)(this.posYClip + this.sizeHeight) + var4), (double)((float)(this.posZClip + this.sizeDepth) + var4)));
GL11.glEndList();
//GL11.glNewList(this.glRenderList + 2, GL11.GL_COMPILE);
//RenderItem.renderAABB(AxisAlignedBB.getBoundingBoxFromPool((double)((float)this.posXClip - var4), (double)((float)this.posYClip - var4), (double)((float)this.posZClip - var4), (double)((float)(this.posXClip + this.sizeWidth) + var4), (double)((float)(this.posYClip + this.sizeHeight) + var4), (double)((float)(this.posZClip + this.sizeDepth) + var4)));
//GL11.glEndList();
this.markDirty();
}
}
private void setupGLTranslation() {
GL11.glTranslatef((float)this.posXClip, (float)this.posYClip, (float)this.posZClip);
}
public void updateRenderer() {
if(this.needsUpdate) {
++chunksUpdated;
@ -113,14 +109,8 @@ public class WorldRenderer {
if(!var14) {
var14 = true;
GL11.glNewList(this.glRenderList + var11, GL11.GL_COMPILE);
GL11.glPushMatrix();
this.setupGLTranslation();
float var19 = 1.000001F;
GL11.glTranslatef((float)(-this.sizeDepth) / 2.0F, (float)(-this.sizeHeight) / 2.0F, (float)(-this.sizeDepth) / 2.0F);
GL11.glScalef(var19, var19, var19);
GL11.glTranslatef((float)this.sizeDepth / 2.0F, (float)this.sizeHeight / 2.0F, (float)this.sizeDepth / 2.0F);
tessellator.startDrawingQuads();
tessellator.setTranslationD((double)(-this.posX), (double)(-this.posY), (double)(-this.posZ));
tessellator.setTranslationD((double) (this.posXClip-this.posX), (double) (this.posYClip-this.posY), (double) (this.posZClip-this.posZ));
}
if(var11 == 0 && Block.isBlockContainer[var18]) {
@ -144,7 +134,6 @@ public class WorldRenderer {
if(var14) {
tessellator.draw();
GL11.glPopMatrix();
GL11.glEndList();
tessellator.setTranslationD(0.0D, 0.0D, 0.0D);
} else {