diff --git a/game/client/src/main/java/net/minecraft/client/Minecraft.java b/game/client/src/main/java/net/minecraft/client/Minecraft.java index 9930e1db5..7e1b16e25 100644 --- a/game/client/src/main/java/net/minecraft/client/Minecraft.java +++ b/game/client/src/main/java/net/minecraft/client/Minecraft.java @@ -157,6 +157,7 @@ import org.lwjgl.glfw.GLFW; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL41; +import org.lwjgl.system.APIUtil; import org.lwjgl.system.Configuration; import org.slf4j.Logger; import org.useless.dragonfly.data.entity.mojang.EntityGeometryMojangData; @@ -188,6 +189,7 @@ public class Minecraft public static final boolean isMultiplayerDisabled = false; public static boolean doPartialTick = true; public static EnumGPUVendor GPU_VENDOR = EnumGPUVendor.UNKNOWN; + public static Thread timerHackThread = null; private static @NotNull Minecraft INSTANCE; public @Nullable PlayerController playerController = null; public boolean hasCrashed; @@ -252,7 +254,7 @@ public class Minecraft public final ScreenshotHelper screenshotHelper = new ScreenshotHelper(this); private boolean f3Press = false; public int debugAtlasLayer = 0; - public Thread rpcThread = null; + public @Nullable Thread rpcThread = null; public final @NotNull PostProcessingManager ppm = new PostProcessingManager(this); private long lastFocusTime; public @NotNull GameWindow gameWindow; @@ -314,7 +316,7 @@ public class Minecraft // LOGGER.error("Failed to install certificates!", e); // } - new Thread("Timer hack thread") { + timerHackThread = new Thread("Timer hack thread") { { this.setDaemon(true); this.start(); @@ -862,6 +864,10 @@ public class Minecraft } catch (Throwable throwable) { LOGGER.error("Failed to free window resources!", throwable); } + if (timerHackThread != null) { + timerHackThread.interrupt(); + timerHackThread = null; + } System.gc(); if (!this.hasCrashed) { System.exit(0); @@ -2453,6 +2459,7 @@ public class Minecraft switch (args[pointer]) { case "--debug": { Global.DEBUG_MODE = true; + pointer++; break; } case "--username": { diff --git a/game/client/src/main/java/net/minecraft/client/discord/RichPresenceHandlerThread.java b/game/client/src/main/java/net/minecraft/client/discord/RichPresenceHandlerThread.java index 432b2b662..967e9a027 100644 --- a/game/client/src/main/java/net/minecraft/client/discord/RichPresenceHandlerThread.java +++ b/game/client/src/main/java/net/minecraft/client/discord/RichPresenceHandlerThread.java @@ -88,6 +88,7 @@ public class RichPresenceHandlerThread extends Thread { public RichPresenceHandlerThread(Minecraft mc) { this.minecraft = mc; + this.setDaemon(true); } @Override diff --git a/game/client/src/main/java/net/minecraft/client/gui/hud/component/HudComponentArmorBar.java b/game/client/src/main/java/net/minecraft/client/gui/hud/component/HudComponentArmorBar.java index 5cf479a64..2479e7c2e 100644 --- a/game/client/src/main/java/net/minecraft/client/gui/hud/component/HudComponentArmorBar.java +++ b/game/client/src/main/java/net/minecraft/client/gui/hud/component/HudComponentArmorBar.java @@ -103,7 +103,7 @@ public class HudComponentArmorBar extends HudComponentMovable { private @NotNull IconCoordinate loadArmorIcon(@NotNull IconKey key) { this.queryBuilder.setLength(0); if (key.state() == ArmorState.EMPTY) { - this.queryBuilder.append("minecraft:gui/hud/armor/").append(getShapeName()).append("/").append("/empty"); + this.queryBuilder.append("minecraft:gui/hud/armor/").append(getShapeName()).append("/empty/empty"); } else { boolean applyFlip = key.isFlipped() && key.state() == ArmorState.HALF; this.queryBuilder.append(key.id.namespace()).append(":gui/hud/armor/").append(getShapeName()).append("/").append(key.state().getRegistry()); diff --git a/game/client/src/main/java/net/minecraft/client/net/thread/ThreadDownloadImage.java b/game/client/src/main/java/net/minecraft/client/net/thread/ThreadDownloadImage.java index 66dc0cd80..e41b1fb4e 100644 --- a/game/client/src/main/java/net/minecraft/client/net/thread/ThreadDownloadImage.java +++ b/game/client/src/main/java/net/minecraft/client/net/thread/ThreadDownloadImage.java @@ -25,6 +25,7 @@ public class ThreadDownloadImage extends Thread { this.url = url; this.imageParser = imageParser; setName("DownloadImage " + counter++); + this.setDaemon(true); } @Override diff --git a/game/client/src/main/java/net/minecraft/client/render/window/GameWindowGLFW.java b/game/client/src/main/java/net/minecraft/client/render/window/GameWindowGLFW.java index 9cabce59c..7429408c5 100644 --- a/game/client/src/main/java/net/minecraft/client/render/window/GameWindowGLFW.java +++ b/game/client/src/main/java/net/minecraft/client/render/window/GameWindowGLFW.java @@ -10,18 +10,12 @@ import net.minecraft.client.option.GameSettings; import net.minecraft.client.render.OpenGLHelper; import net.minecraft.client.util.debug.GLFWLoggerCallback; import net.minecraft.client.util.debug.OpenGLLoggerCallback; -import net.minecraft.core.BuildChannel; import net.minecraft.core.Global; -import net.minecraft.core.Version; import net.minecraft.core.enums.EnumOS; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.lwjgl.PointerBuffer; -import org.lwjgl.glfw.Callbacks; -import org.lwjgl.glfw.GLFW; -import org.lwjgl.glfw.GLFWErrorCallback; -import org.lwjgl.glfw.GLFWImage; -import org.lwjgl.glfw.GLFWVidMode; +import org.lwjgl.glfw.*; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.Display; @@ -47,47 +41,7 @@ import java.util.List; import java.util.Map; import java.util.Objects; -import static org.lwjgl.glfw.GLFW.GLFW_ARROW_CURSOR; -import static org.lwjgl.glfw.GLFW.GLFW_AUTO_ICONIFY; -import static org.lwjgl.glfw.GLFW.GLFW_CONTEXT_VERSION_MAJOR; -import static org.lwjgl.glfw.GLFW.GLFW_CONTEXT_VERSION_MINOR; -import static org.lwjgl.glfw.GLFW.GLFW_CROSSHAIR_CURSOR; -import static org.lwjgl.glfw.GLFW.GLFW_DECORATED; -import static org.lwjgl.glfw.GLFW.GLFW_HAND_CURSOR; -import static org.lwjgl.glfw.GLFW.GLFW_HRESIZE_CURSOR; -import static org.lwjgl.glfw.GLFW.GLFW_IBEAM_CURSOR; -import static org.lwjgl.glfw.GLFW.GLFW_OPENGL_FORWARD_COMPAT; -import static org.lwjgl.glfw.GLFW.GLFW_RESIZABLE; -import static org.lwjgl.glfw.GLFW.GLFW_TRUE; -import static org.lwjgl.glfw.GLFW.GLFW_VISIBLE; -import static org.lwjgl.glfw.GLFW.GLFW_VRESIZE_CURSOR; -import static org.lwjgl.glfw.GLFW.glfwCreateWindow; -import static org.lwjgl.glfw.GLFW.glfwGetError; -import static org.lwjgl.glfw.GLFW.glfwGetFramebufferSize; -import static org.lwjgl.glfw.GLFW.glfwGetMonitorPos; -import static org.lwjgl.glfw.GLFW.glfwGetMonitors; -import static org.lwjgl.glfw.GLFW.glfwGetPrimaryMonitor; -import static org.lwjgl.glfw.GLFW.glfwGetVideoMode; -import static org.lwjgl.glfw.GLFW.glfwGetWindowMonitor; -import static org.lwjgl.glfw.GLFW.glfwGetWindowPos; -import static org.lwjgl.glfw.GLFW.glfwGetWindowSize; -import static org.lwjgl.glfw.GLFW.glfwHideWindow; -import static org.lwjgl.glfw.GLFW.glfwInit; -import static org.lwjgl.glfw.GLFW.glfwMakeContextCurrent; -import static org.lwjgl.glfw.GLFW.glfwPollEvents; -import static org.lwjgl.glfw.GLFW.glfwSetFramebufferSizeCallback; -import static org.lwjgl.glfw.GLFW.glfwSetWindowAttrib; -import static org.lwjgl.glfw.GLFW.glfwSetWindowFocusCallback; -import static org.lwjgl.glfw.GLFW.glfwSetWindowIcon; -import static org.lwjgl.glfw.GLFW.glfwSetWindowMonitor; -import static org.lwjgl.glfw.GLFW.glfwSetWindowPos; -import static org.lwjgl.glfw.GLFW.glfwSetWindowSize; -import static org.lwjgl.glfw.GLFW.glfwSetWindowSizeCallback; -import static org.lwjgl.glfw.GLFW.glfwShowWindow; -import static org.lwjgl.glfw.GLFW.glfwSwapBuffers; -import static org.lwjgl.glfw.GLFW.glfwSwapInterval; -import static org.lwjgl.glfw.GLFW.glfwWindowHint; -import static org.lwjgl.glfw.GLFW.glfwWindowShouldClose; +import static org.lwjgl.glfw.GLFW.*; import static org.lwjgl.system.MemoryUtil.NULL; public class GameWindowGLFW implements GameWindow { @@ -124,7 +78,7 @@ public class GameWindowGLFW implements GameWindow { public void init(Minecraft minecraft, int width, int height) { this.mc = minecraft; - boolean debug = (GameSettings.DEVELOPER_MODE.value || Version.BUILD_CHANNEL == BuildChannel.DEVELOPMENT || Global.DEBUG_MODE); + boolean debug = (GameSettings.DEVELOPER_MODE.value || Global.DEBUG_MODE); LOGGER.info("Initializing GLFW..."); if (debug) { @@ -140,6 +94,8 @@ public class GameWindowGLFW implements GameWindow { glfwWindowHint(GLFW_AUTO_ICONIFY, 1); glfwWindowHint(GLFW_DECORATED, 1); glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE); + glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); + glfwWindowHint(GLFW_CONTEXT_DEBUG, debug ? GLFW_TRUE : GLFW_FALSE); // Iterating through GL versions because theres not way to just request "Highest but atleast X.X" and if forward compat is set on then not request a version causes a crash for (int i = 0; i < OpenGLHelper.versionPairs.length; i += 2) { @@ -167,8 +123,8 @@ public class GameWindowGLFW implements GameWindow { if (capabilities.OpenGL43) { if (debug) { - GL41.glEnable(GL43.GL_DEBUG_OUTPUT); - this.glDebugMessageCallback = new OpenGLLoggerCallback(); + GL41.glEnable(GL43.GL_DEBUG_OUTPUT_SYNCHRONOUS); + this.glDebugMessageCallback = GLDebugMessageCallback.create(new OpenGLLoggerCallback()); GL43.glDebugMessageCallback(this.glDebugMessageCallback, NULL); LOGGER.info("GL4.3 supported, enabling GL Error logging"); } @@ -494,10 +450,15 @@ public class GameWindowGLFW implements GameWindow { public void free() { if (this.window != NULL) { Callbacks.glfwFreeCallbacks(this.window); - this.window = NULL; if (this.glfwErrorCallback != null) this.glfwErrorCallback.free(); - if (this.glDebugMessageCallback != null) this.glDebugMessageCallback.free(); + if (this.glDebugMessageCallback != null) { + GL43.glDisable(GL43.GL_DEBUG_OUTPUT_SYNCHRONOUS); + GL43.glDebugMessageCallback(null, NULL); + this.glDebugMessageCallback.free(); + } this.stbiIconImages.forEach(STBImage::stbi_image_free); + GLFW.glfwDestroyWindow(this.window); + this.window = NULL; } GLFW.glfwTerminate(); } diff --git a/game/client/src/main/java/net/minecraft/client/util/debug/OpenGLLoggerCallback.java b/game/client/src/main/java/net/minecraft/client/util/debug/OpenGLLoggerCallback.java index 7c4dbf8f5..305026db1 100644 --- a/game/client/src/main/java/net/minecraft/client/util/debug/OpenGLLoggerCallback.java +++ b/game/client/src/main/java/net/minecraft/client/util/debug/OpenGLLoggerCallback.java @@ -3,15 +3,12 @@ package net.minecraft.client.util.debug; import it.unimi.dsi.fastutil.ints.Int2BooleanMap; import it.unimi.dsi.fastutil.ints.Int2BooleanOpenHashMap; import org.jetbrains.annotations.NotNull; -import org.lwjgl.opengl.ARBFramebufferObject; -import org.lwjgl.opengl.GL41; -import org.lwjgl.opengl.GL43; -import org.lwjgl.opengl.GLDebugMessageCallback; +import org.lwjgl.opengl.*; import org.lwjgl.system.MemoryUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class OpenGLLoggerCallback extends GLDebugMessageCallback { +public class OpenGLLoggerCallback implements GLDebugMessageCallbackI { private static final Logger LOGGER = LoggerFactory.getLogger("OpenGL"); private final Int2BooleanMap didReport = new Int2BooleanOpenHashMap(); @@ -30,7 +27,7 @@ public class OpenGLLoggerCallback extends GLDebugMessageCallback { getSourceName(source), getTypeName(type), getIdName(id), - msg + msg, new RuntimeException() ); break; } @@ -40,7 +37,7 @@ public class OpenGLLoggerCallback extends GLDebugMessageCallback { getSourceName(source), getTypeName(type), getIdName(id), - msg + msg, new RuntimeException() ); break; } @@ -50,7 +47,7 @@ public class OpenGLLoggerCallback extends GLDebugMessageCallback { getSourceName(source), getTypeName(type), getIdName(id), - msg + msg, new RuntimeException() ); break; } diff --git a/game/server/src/main/java/net/minecraft/server/MinecraftServer.java b/game/server/src/main/java/net/minecraft/server/MinecraftServer.java index 22c248128..0c5ac011d 100644 --- a/game/server/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/game/server/src/main/java/net/minecraft/server/MinecraftServer.java @@ -892,6 +892,7 @@ public class MinecraftServer } case "--debug": { Global.DEBUG_MODE = true; + pointer++; break; } case "--offline": {