From cc7722dec4a2c7429f4c4d6f290232b94fc9daaa Mon Sep 17 00:00:00 2001 From: Frederik van der Els Date: Thu, 26 Feb 2026 21:39:16 +0100 Subject: [PATCH 1/2] Add cwindowsize command --- .../clientcommands/ClientCommands.java | 1 + .../command/WindowSizeCommand.java | 42 +++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 src/main/java/net/earthcomputer/clientcommands/command/WindowSizeCommand.java diff --git a/src/main/java/net/earthcomputer/clientcommands/ClientCommands.java b/src/main/java/net/earthcomputer/clientcommands/ClientCommands.java index d18ebb81..874dc165 100644 --- a/src/main/java/net/earthcomputer/clientcommands/ClientCommands.java +++ b/src/main/java/net/earthcomputer/clientcommands/ClientCommands.java @@ -195,6 +195,7 @@ public static void registerCommands(CommandDispatcher WeatherCommand.register(dispatcher); WhisperEncryptedCommand.register(dispatcher); WikiCommand.register(dispatcher); + WindowSizeCommand.register(dispatcher); Calendar calendar = Calendar.getInstance(); boolean registerChatCommand = calendar.get(Calendar.MONTH) == Calendar.APRIL && calendar.get(Calendar.DAY_OF_MONTH) == 1; diff --git a/src/main/java/net/earthcomputer/clientcommands/command/WindowSizeCommand.java b/src/main/java/net/earthcomputer/clientcommands/command/WindowSizeCommand.java new file mode 100644 index 00000000..7a55c5fa --- /dev/null +++ b/src/main/java/net/earthcomputer/clientcommands/command/WindowSizeCommand.java @@ -0,0 +1,42 @@ +package net.earthcomputer.clientcommands.command; + +import com.mojang.blaze3d.opengl.GlStateManager; +import com.mojang.blaze3d.platform.Window; +import com.mojang.brigadier.Command; +import com.mojang.brigadier.CommandDispatcher; +import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; +import org.lwjgl.glfw.GLFW; + +import static com.mojang.brigadier.arguments.IntegerArgumentType.*; +import static net.fabricmc.fabric.api.client.command.v2.ClientCommandManager.*; + +public class WindowSizeCommand { + public static void register(CommandDispatcher dispatcher) { + dispatcher.register(literal("cwindowsize") + .then(argument("width", integer(0)) + .then(argument("height", integer(0)) + .executes(ctx -> setWindowSize(ctx.getSource(), getInteger(ctx, "width"), getInteger(ctx, "height")))))); + } + + private static int setWindowSize(FabricClientCommandSource source, int width, int height) { + Window window = source.getClient().getWindow(); + long handle = window.handle(); + + int oldX = window.getX(); + int oldY = window.getY(); + int oldWidth = window.getWidth(); + int oldHeight = window.getHeight(); + + int centerX = oldX + oldWidth / 2; + int centerY = oldY + oldHeight / 2; + + GLFW.glfwSetWindowSize(handle, width, height); + + int newX = centerX - width / 2; + int newY = centerY - height / 2; + + GlStateManager._viewport(newX, newY, width, height); + GLFW.glfwSetWindowPos(handle, newX, newY); + return Command.SINGLE_SUCCESS; + } +} From b766f6012b04e2e2641c3696608a61b62072b9fa Mon Sep 17 00:00:00 2001 From: Frederik van der Els Date: Sat, 28 Feb 2026 00:18:37 +0100 Subject: [PATCH 2/2] Remove viewport change --- .../earthcomputer/clientcommands/command/WindowSizeCommand.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/net/earthcomputer/clientcommands/command/WindowSizeCommand.java b/src/main/java/net/earthcomputer/clientcommands/command/WindowSizeCommand.java index 7a55c5fa..a261c93e 100644 --- a/src/main/java/net/earthcomputer/clientcommands/command/WindowSizeCommand.java +++ b/src/main/java/net/earthcomputer/clientcommands/command/WindowSizeCommand.java @@ -35,7 +35,6 @@ private static int setWindowSize(FabricClientCommandSource source, int width, in int newX = centerX - width / 2; int newY = centerY - height / 2; - GlStateManager._viewport(newX, newY, width, height); GLFW.glfwSetWindowPos(handle, newX, newY); return Command.SINGLE_SUCCESS; }