From 6f7c2a36082855ecd0c7e94114a5831d5c8729a2 Mon Sep 17 00:00:00 2001 From: PeytonPlayz595 <106421860+PeytonPlayz595@users.noreply.github.com> Date: Tue, 11 Jul 2023 12:54:57 -0400 Subject: [PATCH] Fixed Texture Loading (I think) --- .../java/com/mojang/minecraft/Minecraft.java | 56 ++----------------- .../mojang/minecraft/render/RenderEngine.java | 13 +++++ .../PeytonPlayz585/main/MinecraftMain.java | 2 + 3 files changed, 21 insertions(+), 50 deletions(-) diff --git a/src/main/java/com/mojang/minecraft/Minecraft.java b/src/main/java/com/mojang/minecraft/Minecraft.java index 9130690..62008d6 100644 --- a/src/main/java/com/mojang/minecraft/Minecraft.java +++ b/src/main/java/com/mojang/minecraft/Minecraft.java @@ -138,7 +138,6 @@ public final class Minecraft implements Runnable { System.out.println("########## GL ERROR ##########"); System.out.println("@ " + var0); System.out.println(var1 + ": " + var2); - System.exit(0); } } @@ -151,7 +150,7 @@ public final class Minecraft implements Runnable { public final void run() { this.running = true; - try { + //try { Minecraft var1 = this; this.width = MinecraftMain.canvas.getWidth(); this.height = MinecraftMain.canvas.getHeight(); @@ -182,59 +181,16 @@ public final class Minecraft implements Runnable { (var85 = new Level()).setData(8, 8, 8, new byte[512]); this.setLevel(var85); } else { - boolean var10 = false; - -// try { -// if(var1.levelName != null) { -// var1.loadOnlineLevel(var1.levelName, var1.levelId); -// } else if(!var1.levelLoaded) { -// Level var11 = null; -// if((var11 = var1.levelIo.load((InputStream)(new FileInputStream(new File("level.dat"))))) != null) { -// var1.setLevel(var11); -// } -// } -// } catch (Exception var54) { -// var54.printStackTrace(); -// } - - //if(this.level == null) { - this.generateLevel(1); - //} + this.generateLevel(1); } this.particleManager = new ParticleManager(this.level); - -// try { -// var1.soundPlayer = new SoundPlayer(var1.settings); -// SoundPlayer var4 = var1.soundPlayer; -// -// try { -// AudioFormat var67 = new AudioFormat(44100.0F, 16, 2, true, true); -// var4.dataLine = AudioSystem.getSourceDataLine(var67); -// var4.dataLine.open(var67, 4410); -// var4.dataLine.start(); -// var4.running = true; -// Thread var72; -// (var72 = new Thread(var4)).setDaemon(true); -// var72.setPriority(10); -// var72.start(); -// } catch (Exception var51) { -// var51.printStackTrace(); -// var4.running = false; -// } -// -// var1.resourceThread = new ResourceDownloadThread(var2, var1); -// var1.resourceThread.start(); -// } catch (Exception var52) { -// ; -// } - checkGLError("Post startup"); this.hud = new HUDScreen(this, this.width, this.height); - } catch (Exception var62) { - var62.printStackTrace(); - throw new RuntimeException("Failed to start Minecraft! :("); - } + //} catch (Exception var62) { + //var62.printStackTrace(); + //throw new RuntimeException("Failed to start Minecraft! :("); + //} long var13 = System.currentTimeMillis(); int var15 = 0; diff --git a/src/main/java/com/mojang/minecraft/render/RenderEngine.java b/src/main/java/com/mojang/minecraft/render/RenderEngine.java index 2c52a23..85ed2f0 100644 --- a/src/main/java/com/mojang/minecraft/render/RenderEngine.java +++ b/src/main/java/com/mojang/minecraft/render/RenderEngine.java @@ -1,13 +1,16 @@ package com.mojang.minecraft.render; +import java.util.ArrayList; import java.io.IOException; import java.nio.ByteBuffer; import java.nio.IntBuffer; import java.util.HashMap; +import org.lwjgl.BufferUtils; import org.lwjgl.opengl.GL11; import com.mojang.minecraft.GameSettings; +import com.mojang.minecraft.Minecraft; import com.mojang.minecraft.render.texture.TextureFX; import net.PeytonPlayz585.lwjgl.LWJGLUtils; @@ -16,6 +19,16 @@ import net.PeytonPlayz585.minecraft.MinecraftImage; public class RenderEngine { + public RenderEngine() { + textureMap = new HashMap(); + textureNameToImageMap = new HashMap(); + singleIntBuffer = BufferUtils.createIntBuffer(1); + imageDataB1 = BufferUtils.createByteBuffer(0x100000); + imageDataB2 = BufferUtils.createByteBuffer(0x100000); + textureList = new ArrayList(); + options = Minecraft.settings; + } + public int getTexture(String s) { TextureBase texturebase = new TextureBase(); Integer integer = (Integer) textureMap.get(s); diff --git a/src/main/java/net/PeytonPlayz585/main/MinecraftMain.java b/src/main/java/net/PeytonPlayz585/main/MinecraftMain.java index 7c65480..745a0ff 100644 --- a/src/main/java/net/PeytonPlayz585/main/MinecraftMain.java +++ b/src/main/java/net/PeytonPlayz585/main/MinecraftMain.java @@ -68,6 +68,8 @@ public class MinecraftMain { canvas.setAttribute("id", "minecraftClassicBrowser"); rootElement.appendChild(canvas); canvasBack = (HTMLCanvasElement)doc.createElement("canvas"); + imageLoadCanvas = (HTMLCanvasElement) doc.createElement("canvas"); + imageLoadContext = (CanvasRenderingContext2D) imageLoadCanvas.getContext("2d"); double r = win.getDevicePixelRatio(); int iw = parent.getClientWidth();