From 0654cde537770a0bd0b59fbac45e1ac21f0673a2 Mon Sep 17 00:00:00 2001 From: fayer3 Date: Mon, 4 Dec 2023 23:27:05 +0100 Subject: [PATCH 01/20] remove unnecessary debug export of RenderTarget --- .../org/vivecraft/mixin/client/blaze3d/RenderTargetMixin.java | 1 - 1 file changed, 1 deletion(-) diff --git a/common/src/main/java/org/vivecraft/mixin/client/blaze3d/RenderTargetMixin.java b/common/src/main/java/org/vivecraft/mixin/client/blaze3d/RenderTargetMixin.java index ec961bb49..dd820cff4 100644 --- a/common/src/main/java/org/vivecraft/mixin/client/blaze3d/RenderTargetMixin.java +++ b/common/src/main/java/org/vivecraft/mixin/client/blaze3d/RenderTargetMixin.java @@ -16,7 +16,6 @@ import org.spongepowered.asm.mixin.injection.*; import org.vivecraft.client.extensions.RenderTargetExtension; -@Debug(export = true) @Mixin(RenderTarget.class) public abstract class RenderTargetMixin implements RenderTargetExtension { From 3318b499fc53d163d6da2b80f6c92ac3cde1f1f8 Mon Sep 17 00:00:00 2001 From: fayer3 Date: Sat, 23 Dec 2023 01:50:23 +0100 Subject: [PATCH 02/20] press/release simulated key, before calling keyPress. --- .../java/org/vivecraft/client_vr/provider/InputSimulator.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/org/vivecraft/client_vr/provider/InputSimulator.java b/common/src/main/java/org/vivecraft/client_vr/provider/InputSimulator.java index c46c7bfb8..b2f3d1be0 100644 --- a/common/src/main/java/org/vivecraft/client_vr/provider/InputSimulator.java +++ b/common/src/main/java/org/vivecraft/client_vr/provider/InputSimulator.java @@ -17,8 +17,8 @@ public static boolean isKeyDown(int key) { } public static void pressKey(int key, int modifiers) { - Minecraft.getInstance().keyboardHandler.keyPress(Minecraft.getInstance().getWindow().getWindow(), key, 0, 1, modifiers); pressedKeys.add(key); + Minecraft.getInstance().keyboardHandler.keyPress(Minecraft.getInstance().getWindow().getWindow(), key, 0, 1, modifiers); } public static void pressKey(int key) { @@ -26,8 +26,8 @@ public static void pressKey(int key) { } public static void releaseKey(int key, int modifiers) { - Minecraft.getInstance().keyboardHandler.keyPress(Minecraft.getInstance().getWindow().getWindow(), key, 0, 0, modifiers); pressedKeys.remove(key); + Minecraft.getInstance().keyboardHandler.keyPress(Minecraft.getInstance().getWindow().getWindow(), key, 0, 0, modifiers); } public static void releaseKey(int key) { From 5018a8da1aec6822f2f2067ebff55625d6534e51 Mon Sep 17 00:00:00 2001 From: fayer3 Date: Tue, 26 Dec 2023 23:06:41 +0100 Subject: [PATCH 03/20] always check paths of files submitted to steamvr, since it doesn't always throw an error, but fails silently --- .../provider/openvr_lwjgl/MCOpenVR.java | 48 ++++++++++++------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/common/src/main/java/org/vivecraft/client_vr/provider/openvr_lwjgl/MCOpenVR.java b/common/src/main/java/org/vivecraft/client_vr/provider/openvr_lwjgl/MCOpenVR.java index effd8fca4..988f04204 100644 --- a/common/src/main/java/org/vivecraft/client_vr/provider/openvr_lwjgl/MCOpenVR.java +++ b/common/src/main/java/org/vivecraft/client_vr/provider/openvr_lwjgl/MCOpenVR.java @@ -858,6 +858,26 @@ private void initOpenVRCompositor() { System.out.println("OpenVR Compositor initialized OK."); } + private void checkPathValid(String path, String knownError, boolean alwaysThrow) throws RenderConfigException { + String pathFormatted = ""; + boolean hasInvalidChars = false; + for (char c : path.toCharArray()) { + if (c > 127) { + hasInvalidChars = true; + pathFormatted += "§c" + c + "§r"; + } else { + pathFormatted += c; + } + } + + if (hasInvalidChars || alwaysThrow) { + String error = knownError + (hasInvalidChars ? "\nInvalid characters in path: \n" : "\n"); + System.out.println(error + path); + throw new RenderConfigException(knownError, Component.empty().append(error).append(pathFormatted)); + } + } + + private void installApplicationManifest(boolean force) throws RenderConfigException { File file1 = new File("openvr/vivecraft.vrmanifest"); Utils.loadAssetToFile("vivecraft.vrmanifest", file1, true); @@ -881,6 +901,9 @@ private void installApplicationManifest(boolean force) throws RenderConfigExcept System.out.println("Appkey: " + s); + // check if path is valid always, since if the application was already installed, it will not check it again + checkPathValid(file1.getAbsolutePath(), "Failed to install application manifest", false); + if (!force && VRApplications_IsApplicationInstalled(s)) { System.out.println("Application manifest already installed"); } else { @@ -888,21 +911,7 @@ private void installApplicationManifest(boolean force) throws RenderConfigExcept if (i != 0) { // application needs to be installed, so abort - String pathFormatted = ""; - boolean hasInvalidChars = false; - for (char c : file1.getAbsolutePath().toCharArray()) { - if (c > 127) { - hasInvalidChars = true; - pathFormatted += "§c" + c + "§r"; - } else { - pathFormatted += c; - } - } - - String error = VRApplications_GetApplicationsErrorNameFromEnum(i) + (hasInvalidChars ? "\nInvalid characters in path: \n" : "\n"); - System.out.println("Failed to install application manifest: " + error + file1.getAbsolutePath()); - - throw new RenderConfigException("Failed to install application manifest", Component.empty().append(error).append(pathFormatted)); + checkPathValid(file1.getAbsolutePath(), "Failed to install application manifest: " + VRApplications_GetApplicationsErrorNameFromEnum(i), true); } System.out.println("Application manifest installed successfully"); @@ -964,11 +973,14 @@ private void loadActionHandles() { } } - private void loadActionManifest() { - int i = VRInput_SetActionManifestPath((new File("openvr/input/action_manifest.json")).getAbsolutePath()); + private void loadActionManifest() throws RenderConfigException { + String actionsPath = (new File("openvr/input/action_manifest.json")).getAbsolutePath(); + // check if path is valid for steamvr, since it would just silently fail + checkPathValid(actionsPath, "Failed to install action manifest", false); + int i = VRInput_SetActionManifestPath(actionsPath); if (i != 0) { - throw new RuntimeException("Failed to load action manifest: " + getInputErrorName(i)); + throw new RenderConfigException("Failed to load action manifest", Component.literal(getInputErrorName(i))); } } From 6e1bcc4366e4b573db53312e204a9c65e4e8224b Mon Sep 17 00:00:00 2001 From: fayer3 Date: Wed, 27 Dec 2023 00:50:02 +0100 Subject: [PATCH 04/20] disable vsync on vr enable, and reenable it on disable also make NULLVR respect the framelimiter --- .../java/org/vivecraft/client_vr/provider/nullvr/NullVR.java | 5 +++++ .../java/org/vivecraft/mixin/client_vr/MinecraftVRMixin.java | 1 + .../mixin/client_vr/blaze3d/systems/RenderSystemVRMixin.java | 3 ++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/org/vivecraft/client_vr/provider/nullvr/NullVR.java b/common/src/main/java/org/vivecraft/client_vr/provider/nullvr/NullVR.java index 1bd65a126..26f867eec 100644 --- a/common/src/main/java/org/vivecraft/client_vr/provider/nullvr/NullVR.java +++ b/common/src/main/java/org/vivecraft/client_vr/provider/nullvr/NullVR.java @@ -192,4 +192,9 @@ public boolean isActive() { } return vrActive; } + + @Override + public boolean capFPS() { + return true; + } } diff --git a/common/src/main/java/org/vivecraft/mixin/client_vr/MinecraftVRMixin.java b/common/src/main/java/org/vivecraft/mixin/client_vr/MinecraftVRMixin.java index a39c9b909..8e8c0a447 100644 --- a/common/src/main/java/org/vivecraft/mixin/client_vr/MinecraftVRMixin.java +++ b/common/src/main/java/org/vivecraft/mixin/client_vr/MinecraftVRMixin.java @@ -919,6 +919,7 @@ public abstract class MinecraftVRMixin implements MinecraftExtension { Minecraft.getInstance().getSoundManager().reload(); } resizeDisplay(); + window.updateVsync(options.enableVsync().get()); } @Unique diff --git a/common/src/main/java/org/vivecraft/mixin/client_vr/blaze3d/systems/RenderSystemVRMixin.java b/common/src/main/java/org/vivecraft/mixin/client_vr/blaze3d/systems/RenderSystemVRMixin.java index f75ec0862..c2f22e563 100644 --- a/common/src/main/java/org/vivecraft/mixin/client_vr/blaze3d/systems/RenderSystemVRMixin.java +++ b/common/src/main/java/org/vivecraft/mixin/client_vr/blaze3d/systems/RenderSystemVRMixin.java @@ -7,6 +7,7 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.vivecraft.client_vr.VRState; +import org.vivecraft.client_vr.provider.MCVR; import static com.mojang.blaze3d.systems.RenderSystem.blendFuncSeparate; @@ -21,7 +22,7 @@ public class RenderSystemVRMixin { @Inject(at = @At("HEAD"), method = "limitDisplayFPS", cancellable = true, remap = false) private static void vivecraft$noFPSlimit(CallbackInfo ci) { - if (VRState.vrRunning) { + if (VRState.vrRunning && MCVR.get().capFPS()) { ci.cancel(); } } From d76555d4115d44131580daa9433660f087d44e5a Mon Sep 17 00:00:00 2001 From: fayer3 Date: Wed, 27 Dec 2023 00:51:08 +0100 Subject: [PATCH 05/20] forgot MCVR changes --- .../src/main/java/org/vivecraft/client_vr/provider/MCVR.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/common/src/main/java/org/vivecraft/client_vr/provider/MCVR.java b/common/src/main/java/org/vivecraft/client_vr/provider/MCVR.java index 39eb530dd..503e79114 100644 --- a/common/src/main/java/org/vivecraft/client_vr/provider/MCVR.java +++ b/common/src/main/java/org/vivecraft/client_vr/provider/MCVR.java @@ -1173,4 +1173,8 @@ private void addActionParams(Map map, KeyMapping keyBindin public abstract VRRenderer createVRRenderer(); public abstract boolean isActive(); + + public boolean capFPS() { + return false; + } } From d73adf878df3ea90b4fb6fcf4262333149630cac Mon Sep 17 00:00:00 2001 From: fayer3 Date: Wed, 27 Dec 2023 01:14:42 +0100 Subject: [PATCH 06/20] that was the wrong way around --- .../mixin/client_vr/blaze3d/systems/RenderSystemVRMixin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/main/java/org/vivecraft/mixin/client_vr/blaze3d/systems/RenderSystemVRMixin.java b/common/src/main/java/org/vivecraft/mixin/client_vr/blaze3d/systems/RenderSystemVRMixin.java index c2f22e563..085a3196b 100644 --- a/common/src/main/java/org/vivecraft/mixin/client_vr/blaze3d/systems/RenderSystemVRMixin.java +++ b/common/src/main/java/org/vivecraft/mixin/client_vr/blaze3d/systems/RenderSystemVRMixin.java @@ -22,7 +22,7 @@ public class RenderSystemVRMixin { @Inject(at = @At("HEAD"), method = "limitDisplayFPS", cancellable = true, remap = false) private static void vivecraft$noFPSlimit(CallbackInfo ci) { - if (VRState.vrRunning && MCVR.get().capFPS()) { + if (VRState.vrRunning && !MCVR.get().capFPS()) { ci.cancel(); } } From 5cf5aba9b7e767e264ad61930c18c1d6b4295334 Mon Sep 17 00:00:00 2001 From: fayer3 Date: Wed, 27 Dec 2023 01:28:39 +0100 Subject: [PATCH 07/20] fix inertiaFactor chat text mentioning wrong key --- common/src/main/resources/assets/vivecraft/lang/de_de.json | 2 +- common/src/main/resources/assets/vivecraft/lang/en_us.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/common/src/main/resources/assets/vivecraft/lang/de_de.json b/common/src/main/resources/assets/vivecraft/lang/de_de.json index 16746697a..c4931fd04 100644 --- a/common/src/main/resources/assets/vivecraft/lang/de_de.json +++ b/common/src/main/resources/assets/vivecraft/lang/de_de.json @@ -383,7 +383,7 @@ "vivecraft.messages.teleportenabled": "Bewegungseinschränkung deaktiviert (Teleportation erlaubt)", "vivecraft.messages.walkupblocks": "Blöcke hochlaufen (RCTRL+B): %s", "vivecraft.messages.showaim": "Ziel zeigen (RCTRL+RSHIFT): aktiviert", - "vivecraft.messages.playerinertia": "Spieler Bewegungsträgheit (LCTRL+I): %s", + "vivecraft.messages.playerinertia": "Spieler Bewegungsträgheit (RCTRL+I): %s", "vivecraft.messages.movementmodeswitch": "Bewegungsmodus gewechselt zu: %s", "vivecraft.messages.coords": "X: %.2f Y: %.2f Z: %.2f", "vivecraft.messages.angles": "Längsachse: %.1f Querachse: %.1f Vertikalachse: %.1f", diff --git a/common/src/main/resources/assets/vivecraft/lang/en_us.json b/common/src/main/resources/assets/vivecraft/lang/en_us.json index 9d9fe45e8..607334fdf 100644 --- a/common/src/main/resources/assets/vivecraft/lang/en_us.json +++ b/common/src/main/resources/assets/vivecraft/lang/en_us.json @@ -382,7 +382,7 @@ "vivecraft.messages.teleportenabled": "Restricted movement disabled (teleporting allowed)", "vivecraft.messages.walkupblocks": "Walk up blocks (RCTRL+B): %s", "vivecraft.messages.showaim": "Show aim (RCTRL+RSHIFT): enabled", - "vivecraft.messages.playerinertia": "Player movement inertia (LCTRL+I): %s", + "vivecraft.messages.playerinertia": "Player movement inertia (RCTRL+I): %s", "vivecraft.messages.movementmodeswitch": "Movement mode switched to: %s", "vivecraft.messages.coords": "X: %.2f Y: %.2f Z: %.2f", "vivecraft.messages.angles": "Pitch: %.1f Yaw: %.1f Roll: %.1f", From 0521f5730b7c47cab6141acbd792a827b30b4854 Mon Sep 17 00:00:00 2001 From: fayer3 Date: Sun, 21 Jan 2024 23:07:18 +0100 Subject: [PATCH 08/20] fix render screen layout not updating with vr off fix screen not updating when navigating with keyboard fix tooltips not shown when navigating with keyboard --- .../gui/framework/GuiVROptionsBase.java | 31 ++++++++++++++++--- .../gui/settings/GuiRenderOpticsSettings.java | 12 ++++--- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/common/src/main/java/org/vivecraft/client/gui/framework/GuiVROptionsBase.java b/common/src/main/java/org/vivecraft/client/gui/framework/GuiVROptionsBase.java index 9b470e8c1..084c79848 100644 --- a/common/src/main/java/org/vivecraft/client/gui/framework/GuiVROptionsBase.java +++ b/common/src/main/java/org/vivecraft/client/gui/framework/GuiVROptionsBase.java @@ -181,7 +181,14 @@ protected void init(VRSettings.VrOptions[] settings, boolean clear) { public void render(GuiGraphics guiGraphics, int pMouseX, int pMouseY, float pPartialTicks) { if (this.reinit) { this.reinit = false; + VRSettings.VrOptions selected = this.getFocused() instanceof GuiVROptionButton option ? option.getOption() : null; this.init(); + if (selected != null) { + List items = this.children().stream().filter(listener -> listener instanceof GuiVROptionButton o && o.getOption() == selected).toList(); + if (!items.isEmpty()) { + this.setFocused((GuiEventListener) items.get(0)); + } + } } this.renderBackground(guiGraphics); @@ -252,7 +259,14 @@ public boolean keyPressed(int pKeyCode, int pScanCode, int pModifiers) { return true; } else { - return this.visibleList != null && this.visibleList.keyPressed(pKeyCode, pScanCode, pModifiers) || super.keyPressed(pKeyCode, pScanCode, pModifiers); + if (super.keyPressed(pKeyCode, pScanCode, pModifiers)) { + if (this.getFocused() instanceof AbstractWidget widget) { + this.actionPerformed(widget); + } + return true; + } else { + return this.visibleList != null && this.visibleList.keyPressed(pKeyCode, pScanCode, pModifiers); + } } } @@ -261,11 +275,18 @@ public boolean charTyped(char pCodePoint, int pModifiers) { } private void renderTooltip(GuiGraphics guiGraphics, int pMouseX, int pMouseY) { - AbstractWidget hover = null; + GuiEventListener hover = null; + + if (this.minecraft.getLastInputType().isKeyboard()) { + // only show focused tooltip when navigating with keyboard, so a click with the mouse removes it + hover = this.getFocused(); + } // find active button - for (GuiEventListener child : children()) { - if (child instanceof AbstractWidget && child.isMouseOver(pMouseX, pMouseY)) { - hover = (AbstractWidget) child; + if (hover == null) { + for (GuiEventListener child : children()) { + if (child instanceof AbstractWidget && child.isMouseOver(pMouseX, pMouseY)) { + hover = child; + } } } if (hover != null) { diff --git a/common/src/main/java/org/vivecraft/client/gui/settings/GuiRenderOpticsSettings.java b/common/src/main/java/org/vivecraft/client/gui/settings/GuiRenderOpticsSettings.java index 72cec21af..06468fa50 100644 --- a/common/src/main/java/org/vivecraft/client/gui/settings/GuiRenderOpticsSettings.java +++ b/common/src/main/java/org/vivecraft/client/gui/settings/GuiRenderOpticsSettings.java @@ -136,11 +136,13 @@ protected void loadDefaults() { protected void actionPerformed(AbstractWidget widget) { if (widget instanceof GuiVROption guivroption) { - if (VRState.vrRunning && (guivroption.getId() == VRSettings.VrOptions.MIRROR_DISPLAY.ordinal() || guivroption.getId() == VRSettings.VrOptions.FSAA.ordinal() || guivroption.getId() == VRSettings.VrOptions.STENCIL_ON.ordinal())) { - if (guivroption.getId() == VRSettings.VrOptions.STENCIL_ON.ordinal() || (guivroption.getId() == VRSettings.VrOptions.MIRROR_DISPLAY.ordinal() && ShadersHelper.isShaderActive())) { - this.dataholder.vrRenderer.resizeFrameBuffers("Render Setting Changed"); - } else { - this.dataholder.vrRenderer.reinitFrameBuffers("Render Setting Changed"); + if (guivroption.getId() == VRSettings.VrOptions.MIRROR_DISPLAY.ordinal() || VRState.vrRunning && ( guivroption.getId() == VRSettings.VrOptions.FSAA.ordinal() || guivroption.getId() == VRSettings.VrOptions.STENCIL_ON.ordinal())) { + if (VRState.vrRunning) { + if (guivroption.getId() == VRSettings.VrOptions.STENCIL_ON.ordinal() || (guivroption.getId() == VRSettings.VrOptions.MIRROR_DISPLAY.ordinal() && ShadersHelper.isShaderActive())) { + this.dataholder.vrRenderer.resizeFrameBuffers("Render Setting Changed"); + } else { + this.dataholder.vrRenderer.reinitFrameBuffers("Render Setting Changed"); + } } this.reinit = true; } From c1307e1253810e651d28bc4bfc6703c086fb4b48 Mon Sep 17 00:00:00 2001 From: fayer3 Date: Mon, 22 Jan 2024 17:25:58 +0100 Subject: [PATCH 09/20] add option to disable auto closing of keyboard, and make it possible to toggle keyboard in the radial menu --- common/src/main/java/org/vivecraft/client/VivecraftVRMod.java | 2 +- .../vivecraft/client/gui/settings/GuiKeyboardSettings.java | 3 ++- .../client_vr/gameplay/screenhandlers/GuiHandler.java | 2 +- .../java/org/vivecraft/client_vr/settings/VRSettings.java | 3 +++ .../org/vivecraft/mixin/client_vr/KeyboardHandlerVRMixin.java | 4 +++- .../gui/screens/inventory/AbstractSignEditScreenVRMixin.java | 3 ++- .../mod_compat_vr/rei/mixin/reiTextFieldWidgetMixin.java | 2 +- common/src/main/resources/assets/vivecraft/lang/de_de.json | 2 ++ common/src/main/resources/assets/vivecraft/lang/en_us.json | 2 ++ 9 files changed, 17 insertions(+), 6 deletions(-) diff --git a/common/src/main/java/org/vivecraft/client/VivecraftVRMod.java b/common/src/main/java/org/vivecraft/client/VivecraftVRMod.java index 26ab0a657..a8011c78d 100644 --- a/common/src/main/java/org/vivecraft/client/VivecraftVRMod.java +++ b/common/src/main/java/org/vivecraft/client/VivecraftVRMod.java @@ -74,6 +74,7 @@ private void setupKeybindingSets() { this.userKeyBindingSet.add(this.keyTogglePlayerList); this.userKeyBindingSet.add(this.keyToggleHandheldCam); this.userKeyBindingSet.add(this.keyQuickHandheldCam); + this.userKeyBindingSet.add(this.keyToggleKeyboard); this.hiddenKeyBindingSet.add(GuiHandler.keyLeftClick); this.hiddenKeyBindingSet.add(GuiHandler.keyRightClick); @@ -90,7 +91,6 @@ private void setupKeybindingSets() { this.hiddenKeyBindingSet.add(this.keyClimbeyJump); this.hiddenKeyBindingSet.add(this.keyMenuButton); this.hiddenKeyBindingSet.add(this.keyRadialMenu); - this.hiddenKeyBindingSet.add(this.keyToggleKeyboard); this.hiddenKeyBindingSet.add(this.keyHotbarSwipeX); this.hiddenKeyBindingSet.add(this.keyHotbarSwipeY); this.hiddenKeyBindingSet.add(this.keyTrackpadTouch); diff --git a/common/src/main/java/org/vivecraft/client/gui/settings/GuiKeyboardSettings.java b/common/src/main/java/org/vivecraft/client/gui/settings/GuiKeyboardSettings.java index 542e9dbee..a4f2b7740 100644 --- a/common/src/main/java/org/vivecraft/client/gui/settings/GuiKeyboardSettings.java +++ b/common/src/main/java/org/vivecraft/client/gui/settings/GuiKeyboardSettings.java @@ -14,9 +14,10 @@ public class GuiKeyboardSettings extends GuiVROptionsBase { KeyboardHandler.setOverlayShowing(false); return false; }), + new VROptionEntry(VRSettings.VrOptions.KEYBOARD_PRESS_BINDS), new VROptionEntry(VRSettings.VrOptions.AUTO_OPEN_KEYBOARD), + new VROptionEntry(VRSettings.VrOptions.AUTO_CLOSE_KEYBOARD), new VROptionEntry(VRSettings.VrOptions.PHYSICAL_KEYBOARD_SCALE), - new VROptionEntry(VRSettings.VrOptions.KEYBOARD_PRESS_BINDS), new VROptionEntry(VRSettings.VrOptions.PHYSICAL_KEYBOARD_THEME) }; diff --git a/common/src/main/java/org/vivecraft/client_vr/gameplay/screenhandlers/GuiHandler.java b/common/src/main/java/org/vivecraft/client_vr/gameplay/screenhandlers/GuiHandler.java index cfa45db56..b03e1dd1a 100644 --- a/common/src/main/java/org/vivecraft/client_vr/gameplay/screenhandlers/GuiHandler.java +++ b/common/src/main/java/org/vivecraft/client_vr/gameplay/screenhandlers/GuiHandler.java @@ -329,7 +329,7 @@ public static void onScreenChanged(Screen previousGuiScreen, Screen newScreen, b guiRotation_room = null; guiScale = 1.0F; - if (KeyboardHandler.keyboardForGui) { + if (KeyboardHandler.keyboardForGui && dh.vrSettings.autoCloseKeyboard) { KeyboardHandler.setOverlayShowing(false); } } else { diff --git a/common/src/main/java/org/vivecraft/client_vr/settings/VRSettings.java b/common/src/main/java/org/vivecraft/client_vr/settings/VRSettings.java index 78f410765..4d92cbf3c 100644 --- a/common/src/main/java/org/vivecraft/client_vr/settings/VRSettings.java +++ b/common/src/main/java/org/vivecraft/client_vr/settings/VRSettings.java @@ -396,6 +396,8 @@ public enum UpdateType implements OptionEnum { public boolean seatedHudAltMode = true; @SettingField(VrOptions.AUTO_OPEN_KEYBOARD) public boolean autoOpenKeyboard = false; + @SettingField(VrOptions.AUTO_CLOSE_KEYBOARD) + public boolean autoCloseKeyboard = true; @SettingField public int forceHardwareDetection = 0; // 0 = off, 1 = vive, 2 = oculus @SettingField(VrOptions.RADIAL_MODE_HOLD) @@ -1161,6 +1163,7 @@ Object convertOption(String value) { SHOW_PLUGIN_MISSING(false, true, "vivecraft.options.always", "vivecraft.options.once"), CHAT_MESSAGE_STENCIL(false, true), // warning for other mod using stencil AUTO_OPEN_KEYBOARD(false, true), // Always Open Keyboard + AUTO_CLOSE_KEYBOARD(false, true), // Close Keyboard on Screenchange RADIAL_MODE_HOLD(false, true, "vivecraft.options.hold", "vivecraft.options.press"), // Radial Menu Mode PHYSICAL_KEYBOARD(false, true, "vivecraft.options.keyboard.physical", "vivecraft.options.keyboard.pointer"), // Keyboard Type PHYSICAL_KEYBOARD_SCALE(true, false, 0.75f, 1.5f, 0.01f, -1) { // Keyboard Size diff --git a/common/src/main/java/org/vivecraft/mixin/client_vr/KeyboardHandlerVRMixin.java b/common/src/main/java/org/vivecraft/mixin/client_vr/KeyboardHandlerVRMixin.java index 0a1f0fb11..f7b792e8e 100644 --- a/common/src/main/java/org/vivecraft/mixin/client_vr/KeyboardHandlerVRMixin.java +++ b/common/src/main/java/org/vivecraft/mixin/client_vr/KeyboardHandlerVRMixin.java @@ -35,7 +35,9 @@ public class KeyboardHandlerVRMixin { public void vivecraft$screenHandler(long l, int i, int j, int k, int m, CallbackInfo ci) { if (i == 256 && k == 1) { if (org.vivecraft.client_vr.gameplay.screenhandlers.KeyboardHandler.Showing) { - org.vivecraft.client_vr.gameplay.screenhandlers.KeyboardHandler.setOverlayShowing(false); + if (ClientDataHolderVR.getInstance().vrSettings.autoCloseKeyboard) { + org.vivecraft.client_vr.gameplay.screenhandlers.KeyboardHandler.setOverlayShowing(false); + } if (this.minecraft.screen instanceof ChatScreen) { minecraft.screen.onClose(); } diff --git a/common/src/main/java/org/vivecraft/mixin/client_vr/gui/screens/inventory/AbstractSignEditScreenVRMixin.java b/common/src/main/java/org/vivecraft/mixin/client_vr/gui/screens/inventory/AbstractSignEditScreenVRMixin.java index d81cac97a..ee5e2826d 100644 --- a/common/src/main/java/org/vivecraft/mixin/client_vr/gui/screens/inventory/AbstractSignEditScreenVRMixin.java +++ b/common/src/main/java/org/vivecraft/mixin/client_vr/gui/screens/inventory/AbstractSignEditScreenVRMixin.java @@ -5,6 +5,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.vivecraft.client_vr.ClientDataHolderVR; import org.vivecraft.client_vr.VRState; import org.vivecraft.client_vr.gameplay.screenhandlers.KeyboardHandler; @@ -20,7 +21,7 @@ public class AbstractSignEditScreenVRMixin { @Inject(at = @At("HEAD"), method = "removed") public void vivecraft$dontShowOverlay(CallbackInfo ci) { - if (VRState.vrRunning) { + if (VRState.vrRunning && ClientDataHolderVR.getInstance().vrSettings.autoCloseKeyboard) { KeyboardHandler.setOverlayShowing(false); } } diff --git a/common/src/main/java/org/vivecraft/mod_compat_vr/rei/mixin/reiTextFieldWidgetMixin.java b/common/src/main/java/org/vivecraft/mod_compat_vr/rei/mixin/reiTextFieldWidgetMixin.java index fa71b4081..642606df0 100644 --- a/common/src/main/java/org/vivecraft/mod_compat_vr/rei/mixin/reiTextFieldWidgetMixin.java +++ b/common/src/main/java/org/vivecraft/mod_compat_vr/rei/mixin/reiTextFieldWidgetMixin.java @@ -16,7 +16,7 @@ public abstract class reiTextFieldWidgetMixin implements ContainerEventHandler { @Inject(method = "setFocused(Z)V", at = @At("HEAD")) private void vivecraft$openKeyboard(boolean focused, CallbackInfo ci) { - if (VRState.vrRunning && !ClientDataHolderVR.getInstance().vrSettings.seated) { + if (VRState.vrRunning && !ClientDataHolderVR.getInstance().vrSettings.seated&& (focused || ClientDataHolderVR.getInstance().vrSettings.autoCloseKeyboard)) { KeyboardHandler.setOverlayShowing(focused); } } diff --git a/common/src/main/resources/assets/vivecraft/lang/de_de.json b/common/src/main/resources/assets/vivecraft/lang/de_de.json index c4931fd04..541e84393 100644 --- a/common/src/main/resources/assets/vivecraft/lang/de_de.json +++ b/common/src/main/resources/assets/vivecraft/lang/de_de.json @@ -102,6 +102,7 @@ "vivecraft.options.CROSSHAIR_SCALES_WITH_DISTANCE": "Fadenkreuzskalierung", "vivecraft.options.RENDER_BLOCK_OUTLINE_MODE": "Blockumriss anzeigen", "vivecraft.options.AUTO_OPEN_KEYBOARD": "Tastatur immer öffnen", + "vivecraft.options.AUTO_CLOSE_KEYBOARD": "Tastatur auto schließen", "vivecraft.options.RADIAL_MODE_HOLD": "Kreismenü Modus", "vivecraft.options.PHYSICAL_KEYBOARD": "Tastaturtyp", "vivecraft.options.PHYSICAL_KEYBOARD_SCALE": "Tastaturgröße", @@ -190,6 +191,7 @@ "vivecraft.options.CROSSHAIR_SCALES_WITH_DISTANCE.tooltip": "Bestimmt, wie sich das Fadenkreuz mit der Entfernung verändert.\n An: Das Fadenkreuz wird in der Entfernung größer, um aus Ihrer Sicht gleich groß zu bleiben.\n Aus: Das Fadenkreuz wird in der Welt immer gleich groß sein und mit der Entfernung schrumpfen.", "vivecraft.options.RENDER_BLOCK_OUTLINE_MODE.tooltip": "Legt den Anzeigemodus der Blockumrisse im Spiel fest.\n Immer: Der Blockumriss wird immer angezeigt, auch wenn das HUD deaktiviert ist.\n Mit HUD: Der Blockumriss wird nur angezeigt, wenn das HUD aktiviert ist.\n Nie: Der Blockumriss wird nie angezeigt.", "vivecraft.options.AUTO_OPEN_KEYBOARD.tooltip": "Wenn deaktiviert, wird die Tastatur nur geöffnet, wenn Sie auf ein Textfeld klicken oder wenn ein Textfeld den Fokus nicht verlieren kann.\n\nWenn aktiviert, öffnet sich die Tastatur automatisch, sobald ein Textfeld den Fokus erhält. Wenn sie aktiviert ist, wird sie in unerwünschten Situationen mit Mods geöffnet.", + "vivecraft.options.AUTO_CLOSE_KEYBOARD.tooltip": "Wenn aktiviert, wird die Tastatur automatisch geschlossen, wenn das aktive Menü wechselt.", "vivecraft.options.RADIAL_MODE_HOLD.tooltip": "Verhalten des Kreismenüs beim Drücken der Taste.\n Halten: Kreismenü-Taste halten, über Auswahl schweben und loslassen.\n Drücken: Kreismenü-Taste drücken, Knöpfe anklicken, Kreismenü-Taste erneut drücken um zu schließen.", "vivecraft.options.PHYSICAL_KEYBOARD.tooltip": "Welche Art von VR-Tastatur zum Tippen verwendet werden soll.\n Physisch: Eine Tastatur, auf der Sie wie auf einer echten Tastatur tippen können.\n Zeiger: Eine Tastatur, die Sie verwenden können, indem Sie mit dem Fadenkreuz des Controllers von einen der beiden Controller zeigen und drücken.", "vivecraft.options.PHYSICAL_KEYBOARD_SCALE.tooltip": "Wie groß die physische Tastatur im Verhältnis zu ihrer Basisgröße sein sollte.", diff --git a/common/src/main/resources/assets/vivecraft/lang/en_us.json b/common/src/main/resources/assets/vivecraft/lang/en_us.json index 607334fdf..eb559b2a8 100644 --- a/common/src/main/resources/assets/vivecraft/lang/en_us.json +++ b/common/src/main/resources/assets/vivecraft/lang/en_us.json @@ -101,6 +101,7 @@ "vivecraft.options.CROSSHAIR_SCALES_WITH_DISTANCE": "Crosshair Scaling", "vivecraft.options.RENDER_BLOCK_OUTLINE_MODE": "Show Block Outline", "vivecraft.options.AUTO_OPEN_KEYBOARD": "Always Open Keyboard", + "vivecraft.options.AUTO_CLOSE_KEYBOARD": "Auto Close Keyboard", "vivecraft.options.RADIAL_MODE_HOLD": "Radial Menu Mode", "vivecraft.options.PHYSICAL_KEYBOARD": "Keyboard Type", "vivecraft.options.PHYSICAL_KEYBOARD_SCALE": "Keyboard Size", @@ -189,6 +190,7 @@ "vivecraft.options.CROSSHAIR_SCALES_WITH_DISTANCE.tooltip": "Determines how the crosshair changes with distance.\n ON: The crosshair will grow larger in the distance to remain the same apparent size from your viewpoint.\n OFF: The crosshair will always be the same size in the world and appear to shrink with distance.", "vivecraft.options.RENDER_BLOCK_OUTLINE_MODE.tooltip": "Sets the in-game block outline display mode.\n Always: The block outline is always shown even if the HUD is disabled.\n With HUD: The block outline is only shown when the HUD is enabled.\n Never: The block outline is never shown.", "vivecraft.options.AUTO_OPEN_KEYBOARD.tooltip": "If disabled, the keyboard will only open when you click a text field, or if a text field can't lose focus.\n\nIf enabled, the keyboard will open automatically any time a text field comes into focus. Enabling this will cause it to open in unwanted situations with mods.", + "vivecraft.options.AUTO_CLOSE_KEYBOARD.tooltip": "If enabled, the keyboard will automatically close, when the screen changes.", "vivecraft.options.RADIAL_MODE_HOLD.tooltip": "Behavior of the radial menu when pressing the button.\n Hold: Hold radial menu button, hover over selection and release.\n Press: Press radial menu button, click buttons, press radial menu button again to dismiss.", "vivecraft.options.PHYSICAL_KEYBOARD.tooltip": "Which type of VR keyboard to use for typing.\n Physical: A keyboard which you can type on like a real keyboard.\n Pointer: A keyboard which you can use by pointing either controller's crosshair at and pressing buttons.", "vivecraft.options.PHYSICAL_KEYBOARD_SCALE.tooltip": "How large the physical keyboard should be, relative to its base size.", From f6c0a1efae61fcac61cdee57cb2e1edd87ff9635 Mon Sep 17 00:00:00 2001 From: fayer3 Date: Mon, 22 Jan 2024 21:36:45 +0100 Subject: [PATCH 10/20] fix sending of server setting overrides --- .../java/org/vivecraft/server/ServerNetworking.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/org/vivecraft/server/ServerNetworking.java b/common/src/main/java/org/vivecraft/server/ServerNetworking.java index 4cf8ea878..930202ab1 100644 --- a/common/src/main/java/org/vivecraft/server/ServerNetworking.java +++ b/common/src/main/java/org/vivecraft/server/ServerNetworking.java @@ -112,7 +112,10 @@ public static void handlePacket(CommonNetworkHelper.PacketDiscriminators packetI byteBuf.writeUtf("teleportLimitHoriz"); byteBuf.writeUtf("" + ServerConfig.teleportHorizontalLimit.get()); - listener.send(getVivecraftServerPacket(CommonNetworkHelper.PacketDiscriminators.SETTING_OVERRIDE, byteBuf.readByteArray())); + byte[] array = new byte[byteBuf.readableBytes()]; + byteBuf.readBytes(array); + byteBuf.release(); + listener.send(getVivecraftServerPacket(CommonNetworkHelper.PacketDiscriminators.SETTING_OVERRIDE, array)); } if (ServerConfig.worldscaleLimited.get()) { @@ -123,7 +126,10 @@ public static void handlePacket(CommonNetworkHelper.PacketDiscriminators packetI byteBuf.writeUtf("worldScale.max"); byteBuf.writeUtf("" + ServerConfig.worldscaleMax.get()); - listener.send(getVivecraftServerPacket(CommonNetworkHelper.PacketDiscriminators.SETTING_OVERRIDE, byteBuf.readByteArray())); + byte[] array = new byte[byteBuf.readableBytes()]; + byteBuf.readBytes(array); + byteBuf.release(); + listener.send(getVivecraftServerPacket(CommonNetworkHelper.PacketDiscriminators.SETTING_OVERRIDE, array)); } if (ServerConfig.crawlingEnabled.get()) { From 36ba4cd9b0e27ceb6b8788117836ffc613be58ce Mon Sep 17 00:00:00 2001 From: fayer3 Date: Tue, 23 Jan 2024 01:54:52 +0100 Subject: [PATCH 11/20] add tooltip when a setting is overridden/limited by the server fix overridden slider settings not being disabled fix server overrides not being reset on disconnect --- .../gui/framework/GuiVROptionSlider.java | 5 +++++ .../gui/framework/GuiVROptionsBase.java | 20 +++++++++++++++++-- .../ClientPacketListenerVRMixin.java | 11 +++++----- .../assets/vivecraft/lang/de_de.json | 2 ++ .../assets/vivecraft/lang/en_us.json | 2 ++ 5 files changed, 32 insertions(+), 8 deletions(-) diff --git a/common/src/main/java/org/vivecraft/client/gui/framework/GuiVROptionSlider.java b/common/src/main/java/org/vivecraft/client/gui/framework/GuiVROptionSlider.java index 09871d107..4eb9f0446 100644 --- a/common/src/main/java/org/vivecraft/client/gui/framework/GuiVROptionSlider.java +++ b/common/src/main/java/org/vivecraft/client/gui/framework/GuiVROptionSlider.java @@ -21,6 +21,11 @@ public GuiVROptionSlider(int id, int x, int y, int width, int height, VRSettings this.id = id; this.enumOptions = option; + + ClientDataHolderVR dataholder = ClientDataHolderVR.getInstance(); + if (dataholder.vrSettings.overrides.hasSetting(option) && dataholder.vrSettings.overrides.getSetting(option).isValueOverridden()) { + this.active = false; + } } public GuiVROptionSlider(int id, int x, int y, VRSettings.VrOptions option) { diff --git a/common/src/main/java/org/vivecraft/client/gui/framework/GuiVROptionsBase.java b/common/src/main/java/org/vivecraft/client/gui/framework/GuiVROptionsBase.java index 084c79848..ff57242dc 100644 --- a/common/src/main/java/org/vivecraft/client/gui/framework/GuiVROptionsBase.java +++ b/common/src/main/java/org/vivecraft/client/gui/framework/GuiVROptionsBase.java @@ -284,7 +284,7 @@ private void renderTooltip(GuiGraphics guiGraphics, int pMouseX, int pMouseY) { // find active button if (hover == null) { for (GuiEventListener child : children()) { - if (child instanceof AbstractWidget && child.isMouseOver(pMouseX, pMouseY)) { + if (child instanceof AbstractWidget widget && this.isMouseOver(widget, pMouseX, pMouseY)) { hover = child; } } @@ -293,9 +293,21 @@ private void renderTooltip(GuiGraphics guiGraphics, int pMouseX, int pMouseY) { if (hover instanceof GuiVROption guiHover) { if (guiHover.getOption() != null) { String tooltipString = "vivecraft.options." + guiHover.getOption().name() + ".tooltip"; + String tooltip = ""; // check if it has a tooltip if (I18n.exists(tooltipString)) { - String tooltip = I18n.get(tooltipString, (Object) null); + tooltip = I18n.get(tooltipString, (Object) null); + } + + if (dataholder.vrSettings.overrides.hasSetting(guiHover.getOption())) { + VRSettings.ServerOverrides.Setting setting = dataholder.vrSettings.overrides.getSetting(guiHover.getOption()); + if (setting.isValueOverridden()) { + tooltip = I18n.get("vivecraft.message.overriddenbyserver") + tooltip; + } else if (setting.isFloat() && (setting.isValueMinOverridden() || setting.isValueMaxOverridden())) { + tooltip = I18n.get("vivecraft.message.limitedbyserver", setting.getValueMin(), setting.getValueMax()) + tooltip; + } + } + if (!tooltip.isEmpty()) { // add format reset at line ends tooltip = tooltip.replace("\n", "§r\n"); @@ -314,4 +326,8 @@ private void renderTooltip(GuiGraphics guiGraphics, int pMouseX, int pMouseY) { } } } + + private boolean isMouseOver(AbstractWidget widget, double x, double y) { + return widget.visible && x >= widget.getX() && y >= widget.getY() && x < (widget.getX() + widget.getWidth()) && y < (widget.getY() + widget.getHeight()); + } } diff --git a/common/src/main/java/org/vivecraft/mixin/client_vr/multiplayer/ClientPacketListenerVRMixin.java b/common/src/main/java/org/vivecraft/mixin/client_vr/multiplayer/ClientPacketListenerVRMixin.java index 4d4685ec7..16794c3e4 100644 --- a/common/src/main/java/org/vivecraft/mixin/client_vr/multiplayer/ClientPacketListenerVRMixin.java +++ b/common/src/main/java/org/vivecraft/mixin/client_vr/multiplayer/ClientPacketListenerVRMixin.java @@ -65,17 +65,16 @@ public class ClientPacketListenerVRMixin { } } - @Inject(at = @At("TAIL"), method = "onDisconnect") - public void vivecraft$disconnect(Component component, CallbackInfo ci) { + @Inject(at = @At("TAIL"), method = "close") + public void vivecraft$cleanup(CallbackInfo ci) { VRServerPerms.INSTANCE.setTeleportSupported(false); if (VRState.vrInitialized) { ClientDataHolderVR.getInstance().vrPlayer.setTeleportOverride(false); } ClientDataHolderVR.getInstance().vrSettings.overrides.resetAll(); - } - - @Inject(at = @At("TAIL"), method = "close") - public void vivecraft$cleanup(CallbackInfo ci) { + ClientNetworking.resetServerSettings(); + ClientNetworking.displayedChatMessage = false; + ClientNetworking.displayedChatWarning = false; ClientNetworking.needsReset = true; } diff --git a/common/src/main/resources/assets/vivecraft/lang/de_de.json b/common/src/main/resources/assets/vivecraft/lang/de_de.json index 541e84393..8c9189a6e 100644 --- a/common/src/main/resources/assets/vivecraft/lang/de_de.json +++ b/common/src/main/resources/assets/vivecraft/lang/de_de.json @@ -459,6 +459,8 @@ "vivecraft.messages.3options": "%s > %s > %s", "vivecraft.messages.openSettings": "Klicken um die Einstellungen zu öffnen.", "vivecraft.message.kofi": "Unterstütze uns auf Ko-Fi", + "vivecraft.message.overriddenbyserver": "§6Einstellung überschrieben vom Server.§r\n", + "vivecraft.message.limitedbyserver": "§6Einstellungsbereich vom Server limitiert (%s - %s)§r\n", "vivecraft.gui.update": "§aⓘ§r Update", "vivecraft.gui.vr": "VR: %s", diff --git a/common/src/main/resources/assets/vivecraft/lang/en_us.json b/common/src/main/resources/assets/vivecraft/lang/en_us.json index eb559b2a8..9b9093a7d 100644 --- a/common/src/main/resources/assets/vivecraft/lang/en_us.json +++ b/common/src/main/resources/assets/vivecraft/lang/en_us.json @@ -462,6 +462,8 @@ "vivecraft.messages.3options": "%s > %s > %s", "vivecraft.messages.openSettings": "Click to open settings", "vivecraft.message.kofi": "Support us on Ko-Fi", + "vivecraft.message.overriddenbyserver": "§6Setting overridden by server.§r\n", + "vivecraft.message.limitedbyserver": "§6Setting range limited by server (%s - %s)§r\n", "vivecraft.gui.update": "§aⓘ§r Update", "vivecraft.gui.vr": "VR: %s", From 80968fec632003f32988bdd1a1d6d7638c4ebca3 Mon Sep 17 00:00:00 2001 From: fayer3 Date: Tue, 23 Jan 2024 01:55:44 +0100 Subject: [PATCH 12/20] fix jumpboots color in recipe --- common/src/main/resources/data/vivecraft/recipes/jumpboots.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/main/resources/data/vivecraft/recipes/jumpboots.json b/common/src/main/resources/data/vivecraft/recipes/jumpboots.json index 81296f2fc..8999f9953 100644 --- a/common/src/main/resources/data/vivecraft/recipes/jumpboots.json +++ b/common/src/main/resources/data/vivecraft/recipes/jumpboots.json @@ -18,6 +18,6 @@ "name": "vivecraft.item.jumpboots", "hideflags": 4, "unbreakable": true, - "color": "9233775" + "color": 9233775 } } From 09b7c0063630887adf8442622b091d0d4e6d0919 Mon Sep 17 00:00:00 2001 From: fayer3 Date: Tue, 23 Jan 2024 18:40:49 +0100 Subject: [PATCH 13/20] also check for embedium for sodium compatibility --- common/src/main/java/org/vivecraft/MixinConfig.java | 3 ++- .../java/org/vivecraft/mod_compat_vr/sodium/SodiumHelper.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/org/vivecraft/MixinConfig.java b/common/src/main/java/org/vivecraft/MixinConfig.java index 97b46baf3..9cfd0c99f 100644 --- a/common/src/main/java/org/vivecraft/MixinConfig.java +++ b/common/src/main/java/org/vivecraft/MixinConfig.java @@ -8,6 +8,7 @@ import org.vivecraft.client_vr.settings.VRSettings; import org.vivecraft.mod_compat_vr.iris.mixin.IrisChunkProgramOverridesMixinSodium_0_4_11; import org.vivecraft.mod_compat_vr.iris.mixin.IrisChunkProgramOverridesMixinSodium_0_4_9; +import org.vivecraft.mod_compat_vr.sodium.SodiumHelper; import org.vivecraft.mod_compat_vr.sodium.mixin.RenderSectionManagerVRMixin; import java.io.IOException; @@ -96,6 +97,6 @@ public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { } } - return !mixinClassName.contains("NoSodium") || (!Xplat.isModLoaded("sodium") && !Xplat.isModLoaded("rubidium")); + return !mixinClassName.contains("NoSodium") || !SodiumHelper.isLoaded(); } } diff --git a/common/src/main/java/org/vivecraft/mod_compat_vr/sodium/SodiumHelper.java b/common/src/main/java/org/vivecraft/mod_compat_vr/sodium/SodiumHelper.java index 0fc305528..b2bdb19ef 100644 --- a/common/src/main/java/org/vivecraft/mod_compat_vr/sodium/SodiumHelper.java +++ b/common/src/main/java/org/vivecraft/mod_compat_vr/sodium/SodiumHelper.java @@ -12,7 +12,7 @@ public class SodiumHelper { public static boolean isLoaded() { - return Xplat.isModLoaded("sodium") || Xplat.isModLoaded("rubidium"); + return Xplat.isModLoaded("sodium") || Xplat.isModLoaded("rubidium") || Xplat.isModLoaded("embeddium"); } public static boolean hasIssuesWithParallelBlockBuilding() { From 0200fe97f9de9a84216c5d1a9f3f072c18f2c373 Mon Sep 17 00:00:00 2001 From: fayer3 Date: Wed, 24 Jan 2024 01:03:35 +0100 Subject: [PATCH 14/20] manually merge #176 to make open composite not crash --- .../mixin/client_vr/lwjgl/OpenVRMixin.java | 85 +++++++++++++++++++ .../src/main/resources/vivecraft.mixins.json | 1 + 2 files changed, 86 insertions(+) create mode 100644 common/src/main/java/org/vivecraft/mixin/client_vr/lwjgl/OpenVRMixin.java diff --git a/common/src/main/java/org/vivecraft/mixin/client_vr/lwjgl/OpenVRMixin.java b/common/src/main/java/org/vivecraft/mixin/client_vr/lwjgl/OpenVRMixin.java new file mode 100644 index 000000000..601e38119 --- /dev/null +++ b/common/src/main/java/org/vivecraft/mixin/client_vr/lwjgl/OpenVRMixin.java @@ -0,0 +1,85 @@ +package org.vivecraft.mixin.client_vr.lwjgl; + +import org.lwjgl.openvr.OpenVR; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; +import org.spongepowered.asm.mixin.Shadow; + +import javax.annotation.Nullable; +import java.util.function.LongFunction; + +import static org.lwjgl.openvr.VR.*; + +@Mixin(value = OpenVR.class, remap = false) +public abstract class OpenVRMixin { + + @Shadow + @Nullable + public static OpenVR.IVRSystem VRSystem; + @Shadow + @Nullable + public static OpenVR.IVRChaperone VRChaperone; + @Shadow + @Nullable + public static OpenVR.IVRChaperoneSetup VRChaperoneSetup; + @Shadow + @Nullable + public static OpenVR.IVRCompositor VRCompositor; + @Shadow + @Nullable + public static OpenVR.IVROverlay VROverlay; + @Shadow + @Nullable + public static OpenVR.IVRRenderModels VRRenderModels; + @Shadow + @Nullable + public static OpenVR.IVRExtendedDisplay VRExtendedDisplay; + @Shadow + @Nullable + public static OpenVR.IVRSettings VRSettings; + @Shadow + @Nullable + public static OpenVR.IVRApplications VRApplications; + @Shadow + @Nullable + public static OpenVR.IVRScreenshots VRScreenshots; + @Shadow + @Nullable + public static OpenVR.IVRInput VRInput; + @Shadow + private static int token; + + @Shadow + @Nullable + private static T getGenericInterface(String interfaceNameVersion, LongFunction supplier) { + return null; + } + + /** + * @author CADIndie + * @reason Open Composite doesn't implement all function tables, so trying to assign them will make it crash + */ + @Overwrite + public static void create(int tok) { + token = tok; + + VRSystem = getGenericInterface(IVRSystem_Version, OpenVR.IVRSystem::new); + VRChaperone = getGenericInterface(IVRChaperone_Version, OpenVR.IVRChaperone::new); + VRChaperoneSetup = getGenericInterface(IVRChaperoneSetup_Version, OpenVR.IVRChaperoneSetup::new); + VRCompositor = getGenericInterface(IVRCompositor_Version, OpenVR.IVRCompositor::new); + VROverlay = getGenericInterface(IVROverlay_Version, OpenVR.IVROverlay::new); + // VRResources = getGenericInterface(IVRResources_Version, OpenVR.IVRResources::new); + VRRenderModels = getGenericInterface(IVRRenderModels_Version, OpenVR.IVRRenderModels::new); + VRExtendedDisplay = getGenericInterface(IVRExtendedDisplay_Version, OpenVR.IVRExtendedDisplay::new); + VRSettings = getGenericInterface(IVRSettings_Version, OpenVR.IVRSettings::new); + VRApplications = getGenericInterface(IVRApplications_Version, OpenVR.IVRApplications::new); + // VRTrackedCamera = getGenericInterface(IVRTrackedCamera_Version, OpenVR.IVRTrackedCamera::new); + VRScreenshots = getGenericInterface(IVRScreenshots_Version, OpenVR.IVRScreenshots::new); + // VRDriverManager = getGenericInterface(IVRDriverManager_Version, OpenVR.IVRDriverManager::new); + VRInput = getGenericInterface(IVRInput_Version, OpenVR.IVRInput::new); + // VRIOBuffer = getGenericInterface(IVRIOBuffer_Version, OpenVR.IVRIOBuffer::new); + // VRSpatialAnchors = getGenericInterface(IVRSpatialAnchors_Version, OpenVR.IVRSpatialAnchors::new); + // VRDebug = getGenericInterface(IVRDebug_Version, OpenVR.IVRDebug::new); + // VRNotifications = getGenericInterface(IVRNotifications_Version, OpenVR.IVRNotifications::new); + } +} diff --git a/common/src/main/resources/vivecraft.mixins.json b/common/src/main/resources/vivecraft.mixins.json index f6a712cdf..b4520548e 100644 --- a/common/src/main/resources/vivecraft.mixins.json +++ b/common/src/main/resources/vivecraft.mixins.json @@ -45,6 +45,7 @@ "client_vr.gui.screens.inventory.AbstractSignEditScreenVRMixin", "client_vr.gui.screens.inventory.BookEditScreenVRMixin", "client_vr.gui.screens.inventory.CreativeModeInventoryScreenVRMixin", + "client_vr.lwjgl.OpenVRMixin", "client_vr.multiplayer.ClientPacketListenerVRMixin", "client_vr.multiplayer.MultiPlayerGameModeVRMixin", "client_vr.particle.ItemPickupParticleVRMixin", From 246c3ab3b07485142fb0cba2a88f5b8b94d6923e Mon Sep 17 00:00:00 2001 From: fayer3 Date: Wed, 24 Jan 2024 01:37:18 +0100 Subject: [PATCH 15/20] add keybindings for quick commands --- .../org/vivecraft/client/VivecraftVRMod.java | 25 +++++++++++++++++++ .../mixin/client_vr/MinecraftVRMixin.java | 21 +++++++++++++++- .../assets/vivecraft/lang/de_de.json | 13 ++++++++++ .../assets/vivecraft/lang/en_us.json | 13 ++++++++++ 4 files changed, 71 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/org/vivecraft/client/VivecraftVRMod.java b/common/src/main/java/org/vivecraft/client/VivecraftVRMod.java index a8011c78d..42e879a84 100644 --- a/common/src/main/java/org/vivecraft/client/VivecraftVRMod.java +++ b/common/src/main/java/org/vivecraft/client/VivecraftVRMod.java @@ -39,6 +39,19 @@ public class VivecraftVRMod { public final KeyMapping keyMenuButton = new KeyMapping("vivecraft.key.ingameMenuButton", -1, "key.categories.ui"); public final KeyMapping keyMoveThirdPersonCam = new KeyMapping("vivecraft.key.moveThirdPersonCam", -1, "key.categories.misc"); public final KeyMapping keyQuickHandheldCam = new KeyMapping("vivecraft.key.quickHandheldCam", -1, "key.categories.misc"); + public final KeyMapping keyQuickCommand1 = new KeyMapping("vivecraft.key.quickcommand1", -1, "key.categories.misc"); + public final KeyMapping keyQuickCommand2 = new KeyMapping("vivecraft.key.quickcommand2", -1, "key.categories.misc"); + public final KeyMapping keyQuickCommand3 = new KeyMapping("vivecraft.key.quickcommand3", -1, "key.categories.misc"); + public final KeyMapping keyQuickCommand4 = new KeyMapping("vivecraft.key.quickcommand4", -1, "key.categories.misc"); + public final KeyMapping keyQuickCommand5 = new KeyMapping("vivecraft.key.quickcommand5", -1, "key.categories.misc"); + public final KeyMapping keyQuickCommand6 = new KeyMapping("vivecraft.key.quickcommand6", -1, "key.categories.misc"); + public final KeyMapping keyQuickCommand7 = new KeyMapping("vivecraft.key.quickcommand7", -1, "key.categories.misc"); + public final KeyMapping keyQuickCommand8 = new KeyMapping("vivecraft.key.quickcommand8", -1, "key.categories.misc"); + public final KeyMapping keyQuickCommand9 = new KeyMapping("vivecraft.key.quickcommand9", -1, "key.categories.misc"); + public final KeyMapping keyQuickCommand10 = new KeyMapping("vivecraft.key.quickcommand10", -1, "key.categories.misc"); + public final KeyMapping keyQuickCommand11 = new KeyMapping("vivecraft.key.quickcommand11", -1, "key.categories.misc"); + public final KeyMapping keyQuickCommand12 = new KeyMapping("vivecraft.key.quickcommand12", -1, "key.categories.misc"); + public final KeyMapping[] keyQuickCommands = new KeyMapping[]{keyQuickCommand1, keyQuickCommand2, keyQuickCommand3, keyQuickCommand4, keyQuickCommand5, keyQuickCommand6, keyQuickCommand7, keyQuickCommand8, keyQuickCommand9, keyQuickCommand10, keyQuickCommand11, keyQuickCommand12}; public final KeyMapping keyQuickTorch = new KeyMapping("vivecraft.key.quickTorch", -1, "key.categories.gameplay"); public final KeyMapping keyRadialMenu = new KeyMapping("vivecraft.key.radialMenu", -1, "key.categories.ui"); public final KeyMapping keyRotateAxis = new KeyMapping("vivecraft.key.rotateAxis", -1, "key.categories.movement"); @@ -75,6 +88,18 @@ private void setupKeybindingSets() { this.userKeyBindingSet.add(this.keyToggleHandheldCam); this.userKeyBindingSet.add(this.keyQuickHandheldCam); this.userKeyBindingSet.add(this.keyToggleKeyboard); + this.userKeyBindingSet.add(this.keyQuickCommand1); + this.userKeyBindingSet.add(this.keyQuickCommand2); + this.userKeyBindingSet.add(this.keyQuickCommand3); + this.userKeyBindingSet.add(this.keyQuickCommand4); + this.userKeyBindingSet.add(this.keyQuickCommand5); + this.userKeyBindingSet.add(this.keyQuickCommand6); + this.userKeyBindingSet.add(this.keyQuickCommand7); + this.userKeyBindingSet.add(this.keyQuickCommand8); + this.userKeyBindingSet.add(this.keyQuickCommand9); + this.userKeyBindingSet.add(this.keyQuickCommand10); + this.userKeyBindingSet.add(this.keyQuickCommand11); + this.userKeyBindingSet.add(this.keyQuickCommand12); this.hiddenKeyBindingSet.add(GuiHandler.keyLeftClick); this.hiddenKeyBindingSet.add(GuiHandler.keyRightClick); diff --git a/common/src/main/java/org/vivecraft/mixin/client_vr/MinecraftVRMixin.java b/common/src/main/java/org/vivecraft/mixin/client_vr/MinecraftVRMixin.java index 8e8c0a447..6b49bb917 100644 --- a/common/src/main/java/org/vivecraft/mixin/client_vr/MinecraftVRMixin.java +++ b/common/src/main/java/org/vivecraft/mixin/client_vr/MinecraftVRMixin.java @@ -689,6 +689,15 @@ public abstract class MinecraftVRMixin implements MinecraftExtension { VRPlayersClient.getInstance().tick(); + this.profiler.popPush("Vivecraft Keybindings"); + vivecraft$processAlwaysAvailableKeybindings(); + + this.profiler.pop(); + } + + @Unique + private void vivecraft$processAlwaysAvailableKeybindings() { + // menuworld export if (VivecraftVRMod.INSTANCE.keyExportWorld.consumeClick() && level != null && player != null) { Throwable error = null; try { @@ -743,7 +752,17 @@ public abstract class MinecraftVRMixin implements MinecraftExtension { } } - this.profiler.pop(); + // quick commands + for (int i = 0; i < VivecraftVRMod.INSTANCE.keyQuickCommands.length; i++) { + if (VivecraftVRMod.INSTANCE.keyQuickCommands[i].consumeClick()) { + String command = ClientDataHolderVR.getInstance().vrSettings.vrQuickCommands[i]; + if (command.startsWith("/")) { + this.player.connection.sendCommand(command.substring(1)); + } else { + this.player.connection.sendChat(command); + } + } + } } @Redirect(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/GameRenderer;pick(F)V"), method = "tick") diff --git a/common/src/main/resources/assets/vivecraft/lang/de_de.json b/common/src/main/resources/assets/vivecraft/lang/de_de.json index 8c9189a6e..83666bb93 100644 --- a/common/src/main/resources/assets/vivecraft/lang/de_de.json +++ b/common/src/main/resources/assets/vivecraft/lang/de_de.json @@ -41,6 +41,19 @@ "vivecraft.key.keyboardShift": "Umschalt", "vivecraft.key.climbeyGrab": "Kletterausrüstung", "vivecraft.key.climbeyJump": "Sprung-Schuhe", + "_comment_quickcommands": "double spacing is intentional, to get minecraft to sort them right", + "vivecraft.key.quickcommand1": "Schnellbefehl 1", + "vivecraft.key.quickcommand2": "Schnellbefehl 2", + "vivecraft.key.quickcommand3": "Schnellbefehl 3", + "vivecraft.key.quickcommand4": "Schnellbefehl 4", + "vivecraft.key.quickcommand5": "Schnellbefehl 5", + "vivecraft.key.quickcommand6": "Schnellbefehl 6", + "vivecraft.key.quickcommand7": "Schnellbefehl 7", + "vivecraft.key.quickcommand8": "Schnellbefehl 8", + "vivecraft.key.quickcommand9": "Schnellbefehl 9", + "vivecraft.key.quickcommand10": "Schnellbefehl 10", + "vivecraft.key.quickcommand11": "Schnellbefehl 11", + "vivecraft.key.quickcommand12": "Schnellbefehl 12", "_comment2": "Key binding categories", "vivecraft.key.category.gui": "Benutzeroberfläche", "vivecraft.key.category.climbey": "Kletter Bewegung", diff --git a/common/src/main/resources/assets/vivecraft/lang/en_us.json b/common/src/main/resources/assets/vivecraft/lang/en_us.json index 9b9093a7d..b607b2642 100644 --- a/common/src/main/resources/assets/vivecraft/lang/en_us.json +++ b/common/src/main/resources/assets/vivecraft/lang/en_us.json @@ -40,6 +40,19 @@ "vivecraft.key.keyboardShift": "Shift", "vivecraft.key.climbeyGrab": "Climb Claws", "vivecraft.key.climbeyJump": "Jump Boots", + "_comment_quickcommands": "double spacing is intentional, to get minecraft to sort them right", + "vivecraft.key.quickcommand1": "Quick Command 1", + "vivecraft.key.quickcommand2": "Quick Command 2", + "vivecraft.key.quickcommand3": "Quick Command 3", + "vivecraft.key.quickcommand4": "Quick Command 4", + "vivecraft.key.quickcommand5": "Quick Command 5", + "vivecraft.key.quickcommand6": "Quick Command 6", + "vivecraft.key.quickcommand7": "Quick Command 7", + "vivecraft.key.quickcommand8": "Quick Command 8", + "vivecraft.key.quickcommand9": "Quick Command 9", + "vivecraft.key.quickcommand10": "Quick Command 10", + "vivecraft.key.quickcommand11": "Quick Command 11", + "vivecraft.key.quickcommand12": "Quick Command 12", "_comment1": "Key binding categories", "vivecraft.key.category.gui": "GUI", "vivecraft.key.category.climbey": "Climbey Motion", From 6ae11ef03d1d1b83ef32b425d64aa85f0bf46263 Mon Sep 17 00:00:00 2001 From: fayer3 Date: Wed, 24 Jan 2024 01:40:34 +0100 Subject: [PATCH 16/20] fix quick commands being capped at 32 characters --- .../org/vivecraft/client/gui/settings/GuiQuickCommandsList.java | 1 + 1 file changed, 1 insertion(+) diff --git a/common/src/main/java/org/vivecraft/client/gui/settings/GuiQuickCommandsList.java b/common/src/main/java/org/vivecraft/client/gui/settings/GuiQuickCommandsList.java index 9c1a92295..02697d5d4 100644 --- a/common/src/main/java/org/vivecraft/client/gui/settings/GuiQuickCommandsList.java +++ b/common/src/main/java/org/vivecraft/client/gui/settings/GuiQuickCommandsList.java @@ -37,6 +37,7 @@ public class CommandEntry extends Entry { private CommandEntry(String command, GuiQuickCommandsList parent) { this.txt = new EditBox(GuiQuickCommandsList.this.minecraft.font, parent.width / 2 - 100, 60, 200, 20, Component.literal("")); + this.txt.setMaxLength(256); this.txt.setValue(command); this.btnDelete = new Button.Builder(Component.literal("X"), (p) -> { From 7f0ca44c171c53536c07d949612bc13f6892e259 Mon Sep 17 00:00:00 2001 From: fayer3 Date: Wed, 24 Jan 2024 14:11:05 +0100 Subject: [PATCH 17/20] show GC message with 6 threads available --- common/src/main/java/org/vivecraft/client_vr/VRState.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/main/java/org/vivecraft/client_vr/VRState.java b/common/src/main/java/org/vivecraft/client_vr/VRState.java index 7bccc21df..c572a4a07 100644 --- a/common/src/main/java/org/vivecraft/client_vr/VRState.java +++ b/common/src/main/java/org/vivecraft/client_vr/VRState.java @@ -91,7 +91,7 @@ public static void initializeVR() { if (!garbageCollector.equals("ZGC") && !ClientDataHolderVR.getInstance().vrSettings.disableGarbageCollectorMessage) { // At least 12 GiB RAM (minus 256 MiB for possible reserved) and 8 CPU threads - if (os.getTotalMemorySize() >= 1073741824L * 12L - 1048576L * 256L && Runtime.getRuntime().availableProcessors() >= 8) { + if (os.getTotalMemorySize() >= 1073741824L * 12L - 1048576L * 256L && Runtime.getRuntime().availableProcessors() >= 6) { Minecraft.getInstance().setScreen(new GarbageCollectorScreen(garbageCollector)); } } From 8183cee13cc00aed9aaad21b66f7d6f204e3a449 Mon Sep 17 00:00:00 2001 From: fayer3 Date: Wed, 24 Jan 2024 17:17:13 +0100 Subject: [PATCH 18/20] add setting to adjust mirror cropping --- .../java/org/vivecraft/client_vr/settings/VRSettings.java | 3 +++ .../java/org/vivecraft/mixin/client_vr/MinecraftVRMixin.java | 4 ++-- common/src/main/resources/assets/vivecraft/lang/de_de.json | 2 ++ common/src/main/resources/assets/vivecraft/lang/en_us.json | 2 ++ 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/org/vivecraft/client_vr/settings/VRSettings.java b/common/src/main/java/org/vivecraft/client_vr/settings/VRSettings.java index 4d92cbf3c..dff0da62b 100644 --- a/common/src/main/java/org/vivecraft/client_vr/settings/VRSettings.java +++ b/common/src/main/java/org/vivecraft/client_vr/settings/VRSettings.java @@ -307,6 +307,8 @@ public enum UpdateType implements OptionEnum { public float renderScaleFactor = 1.0f; @SettingField(VrOptions.MIRROR_DISPLAY) public MirrorMode displayMirrorMode = MirrorMode.CROPPED; + @SettingField(VrOptions.MIRROR_CROP) + public float mirrorCrop = 0.15F; @SettingField(VrOptions.MIRROR_EYE) public boolean displayMirrorLeftEye = false; @SettingField(VrOptions.MIRROR_CENTER_SMOOTH) @@ -1230,6 +1232,7 @@ void onOptionChange() { } } }, + MIRROR_CROP(true, false, 0.0f, 0.25f, 0.01f, -1), // crop amount for mirror, MIRROR_EYE(false, true, "vivecraft.options.left", "vivecraft.options.right"), // Mirror Eye MIRROR_CENTER_SMOOTH(true, false, 0.0f, 1.0f, 0.1f, 1) { @Override diff --git a/common/src/main/java/org/vivecraft/mixin/client_vr/MinecraftVRMixin.java b/common/src/main/java/org/vivecraft/mixin/client_vr/MinecraftVRMixin.java index 6b49bb917..74cf3b0dd 100644 --- a/common/src/main/java/org/vivecraft/mixin/client_vr/MinecraftVRMixin.java +++ b/common/src/main/java/org/vivecraft/mixin/client_vr/MinecraftVRMixin.java @@ -1008,8 +1008,8 @@ public abstract class MinecraftVRMixin implements MinecraftExtension { source = ClientDataHolderVR.getInstance().vrRenderer.framebufferEye1; } - xcrop = 0.15F; - ycrop = 0.15F; + xcrop = ClientDataHolderVR.getInstance().vrSettings.mirrorCrop; + ycrop = ClientDataHolderVR.getInstance().vrSettings.mirrorCrop; ar = true; } // Debug diff --git a/common/src/main/resources/assets/vivecraft/lang/de_de.json b/common/src/main/resources/assets/vivecraft/lang/de_de.json index 83666bb93..b8acd4e99 100644 --- a/common/src/main/resources/assets/vivecraft/lang/de_de.json +++ b/common/src/main/resources/assets/vivecraft/lang/de_de.json @@ -441,6 +441,7 @@ "vivecraft.options.VR_SETTINGS_BUTTON_POSITION": "VR Einstellungsknopf Position", "vivecraft.options.INGAME_BINDINGS_IN_GUI": "Im-Spiel Tasten im GUI", "vivecraft.options.MENU_WORLD_FALLBACK": "Ersatz Methode", + "vivecraft.options.MIRROR_CROP": "Spiegel Zuschnitt", "_comment_m6": "Option tooltips", "vivecraft.options.LOW_HEALTH_INDICATOR.tooltip": "Pulsiert den Bildschirm Rot bei niedriger Gesundheit, um den derzeitigen Gesundheitszustand anzuzeigen.", "vivecraft.options.SHADER_GUI_RENDER.tooltip": "Bestimmt wie die Benutzeroberfläche mit Shadern dargestellt wird.\n Nach Shader: zeigt die Benutzeroberfläche ohne Shader, beste Kompatibilität. (Probleme mit PTGI HRR)\n Transparent: zeigt die Benutzeroberfläche mit Shadern und transparent. (Probleme mit Sildurs Vibrant)\n Undurchsichtig: zeigt die Benutzeroberfläche mit Shadern, aber Undurchsichtig", @@ -457,6 +458,7 @@ "vivecraft.options.VR_HOTSWITCH.tooltip": "Schnellwechsel wechselt automatisch zu NONVR wenn das Headset abgenommen wird.\nWenn diese Einstellung ausgeschalten ist, befindet sich das Spiel dauerhaft im VR Modus, sobald VR eingeschalten wurde", "vivecraft.options.INGAME_BINDINGS_IN_GUI.tooltip": "Erlaubt es alle Im-Spiel Tasten in Menüs zu verwenden. Dies kann zu nicht gewollten doppel Tastendrücken führen.", "vivecraft.options.MENU_WORLD_FALLBACK.tooltip": "Wenn Menü Welten deaktiviert sind oder noch nicht geladen sind, wird dieser Ersatz stattdessen verwendet", + "vivecraft.options.MIRROR_CROP.tooltip": "Gibt and um wie viel das VR Bild zugeschnitten wird. Der Standardwert von 15%% versteckt die Augenschablone ganz gut. Wenn Sie ohne Augenschablone spielen, können Sie den Wert reduzieren, um ein größeres Sichtfeld im Desktop Spiegel zu bekommen.", "_comment_m10": "Messages", "vivecraft.messages.mode": "Modus:", "vivecraft.messages.novrhotswitchinglegacy": "Veralteten Vivecraft server mod erkannt. Dieser Server unterstützt kein VR Schnellwechsel. Sie können den Modus nur im Hauptmenü wechseln.", diff --git a/common/src/main/resources/assets/vivecraft/lang/en_us.json b/common/src/main/resources/assets/vivecraft/lang/en_us.json index b607b2642..10b70c452 100644 --- a/common/src/main/resources/assets/vivecraft/lang/en_us.json +++ b/common/src/main/resources/assets/vivecraft/lang/en_us.json @@ -444,6 +444,7 @@ "vivecraft.options.VR_SETTINGS_BUTTON_POSITION": "VR Settings Button Position", "vivecraft.options.INGAME_BINDINGS_IN_GUI": "In-Game Bindings In GUI", "vivecraft.options.MENU_WORLD_FALLBACK": "Fallback Method", + "vivecraft.options.MIRROR_CROP": "Mirror Cropping", "_comment_m6": "Option tooltips", "vivecraft.options.LOW_HEALTH_INDICATOR.tooltip": "Pulses the screen red, when at low health, to indicate your current health status", "vivecraft.options.SHADER_GUI_RENDER.tooltip": "Determines how the GUI is rendered with shaders.\n After Shader: renders the GUI without using the shader, best compatibility. (issues with PTGI HRR)\n Translucent: renders the GUI with shader and transparency. (issues with Sildurs Vibrant)\n Opaque: renders the GUI with shader and opaque", @@ -460,6 +461,7 @@ "vivecraft.options.VR_HOTSWITCH.tooltip": "Hotswitching switches to NONVR when the headset is taken off.\nIf this setting is off, the game will always be in VR mode, when VR is enabled", "vivecraft.options.INGAME_BINDINGS_IN_GUI.tooltip": "Allows for all In-Game bindings to be used in menus, this can cause unwanted double presses.", "vivecraft.options.MENU_WORLD_FALLBACK.tooltip": "If Menuworlds are disabled or not loaded yet, this fallback will be shown instead.", + "vivecraft.options.MIRROR_CROP.tooltip": "Specifies how much of the VR image gets cropped. The default 15%% hides the stencil pretty good. If you play without stencil, you can reduce this, to get a bigger FOV for the mirror.", "_comment_m10": "Messages", "vivecraft.messages.mode": "Mode:", "vivecraft.messages.novrhotswitchinglegacy": "Legacy Vivecraft server mod detected. This Server does not support VR hot switching, you can only change it in the main menu.", From f32b01c889ed1d9445b43a7bc437f5d77fdf3439 Mon Sep 17 00:00:00 2001 From: fayer3 Date: Wed, 24 Jan 2024 17:32:39 +0100 Subject: [PATCH 19/20] forgot the renderopticsscreen changes --- .../client/gui/settings/GuiRenderOpticsSettings.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/common/src/main/java/org/vivecraft/client/gui/settings/GuiRenderOpticsSettings.java b/common/src/main/java/org/vivecraft/client/gui/settings/GuiRenderOpticsSettings.java index 06468fa50..b9755342f 100644 --- a/common/src/main/java/org/vivecraft/client/gui/settings/GuiRenderOpticsSettings.java +++ b/common/src/main/java/org/vivecraft/client/gui/settings/GuiRenderOpticsSettings.java @@ -44,6 +44,9 @@ public class GuiRenderOpticsSettings extends GuiVROptionsBase { VRSettings.VrOptions.MIXED_REALITY_FOV, VRSettings.VrOptions.MIXED_REALITY_RENDER_CAMERA_MODEL }; + static VRSettings.VrOptions[] CROPOptions = new VRSettings.VrOptions[]{ + VRSettings.VrOptions.MIRROR_CROP + }; private float prevRenderScaleFactor = this.settings.renderScaleFactor; private float prevHandCameraResScale = this.settings.handCameraResScale; @@ -104,6 +107,8 @@ public void init() { super.init(UDOptions, false); } else if (this.dataholder.vrSettings.displayMirrorMode == VRSettings.MirrorMode.THIRD_PERSON) { super.init(TUDOptions, false); + } else if (this.dataholder.vrSettings.displayMirrorMode == VRSettings.MirrorMode.CROPPED) { + super.init(CROPOptions, false); } super.addDefaultButtons(); From 471f2151e904d629c22b144cbaa4925ea0bad75b Mon Sep 17 00:00:00 2001 From: fayer3 Date: Wed, 24 Jan 2024 17:34:41 +0100 Subject: [PATCH 20/20] move vr init later, to fix bindings issues with Wynntils --- .../client/ResourceLoadStateTrackerMixin.java | 26 ++++++++++++++++++- .../mixin/client_vr/MinecraftVRMixin.java | 10 ------- .../main/resources/vivecraft.accesswidener | 6 ++++- 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/common/src/main/java/org/vivecraft/mixin/client/ResourceLoadStateTrackerMixin.java b/common/src/main/java/org/vivecraft/mixin/client/ResourceLoadStateTrackerMixin.java index b0f39ecde..bc6dcff4b 100644 --- a/common/src/main/java/org/vivecraft/mixin/client/ResourceLoadStateTrackerMixin.java +++ b/common/src/main/java/org/vivecraft/mixin/client/ResourceLoadStateTrackerMixin.java @@ -1,14 +1,38 @@ package org.vivecraft.mixin.client; import net.minecraft.client.ResourceLoadStateTracker; +import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.vivecraft.client_vr.ClientDataHolderVR; +import org.vivecraft.client_vr.VRState; -@Mixin(ResourceLoadStateTracker.class) +// we want to be late here, because some mods initialize keybinds after the first reload +@Mixin(value = ResourceLoadStateTracker.class, priority = 9999) public abstract class ResourceLoadStateTrackerMixin { + + @Shadow + @Nullable + private ResourceLoadStateTracker.ReloadState reloadState; + + @Inject(at = @At("TAIL"), method = "finishReload") + void vivecraft$initializeVR(CallbackInfo ci) { + if (reloadState != null && reloadState.reloadReason == ResourceLoadStateTracker.ReloadReason.INITIAL) { + // init vr after first resource loading + try { + if (ClientDataHolderVR.getInstance().vrSettings.vrEnabled) { + VRState.vrEnabled = true; + VRState.initializeVR(); + } + } catch (Exception exception) { + exception.printStackTrace(); + } + } + } + @Inject(at = @At("HEAD"), method = "startReload") void vivecraft$startReloadMixin(CallbackInfo ci) { if (ClientDataHolderVR.getInstance().menuWorldRenderer != null) { diff --git a/common/src/main/java/org/vivecraft/mixin/client_vr/MinecraftVRMixin.java b/common/src/main/java/org/vivecraft/mixin/client_vr/MinecraftVRMixin.java index 74cf3b0dd..7893a5e8e 100644 --- a/common/src/main/java/org/vivecraft/mixin/client_vr/MinecraftVRMixin.java +++ b/common/src/main/java/org/vivecraft/mixin/client_vr/MinecraftVRMixin.java @@ -254,16 +254,6 @@ public abstract class MinecraftVRMixin implements MinecraftExtension { "lambda$new$4"} // forge , remap = false) public void vivecraft$initVROnLaunch(CallbackInfo ci) { - // init vr after resource loading - try { - if (ClientDataHolderVR.getInstance().vrSettings.vrEnabled) { - VRState.vrEnabled = true; - VRState.initializeVR(); - } - } catch (Exception exception) { - exception.printStackTrace(); - } - // set initial resourcepacks vivecraft$resourcepacks = resourceManager.listPacks().map(PackResources::packId).toList(); diff --git a/common/src/main/resources/vivecraft.accesswidener b/common/src/main/resources/vivecraft.accesswidener index 1d61305e9..c24bf860f 100644 --- a/common/src/main/resources/vivecraft.accesswidener +++ b/common/src/main/resources/vivecraft.accesswidener @@ -28,7 +28,7 @@ accessible field net/minecraft/network/Connection channel Lio/netty/channel/Chan # for quicktorch accessible method net/minecraft/client/Minecraft startUseItem ()V -# to switch rendrtargetrs for VR passes +# to switch rendertargets for VR passes mutable field net/minecraft/client/Minecraft mainRenderTarget Lcom/mojang/blaze3d/pipeline/RenderTarget; accessible field net/minecraft/client/Minecraft mainRenderTarget Lcom/mojang/blaze3d/pipeline/RenderTarget; @@ -91,3 +91,7 @@ accessible class net/minecraft/world/level/biome/Biome$ClimateSettings accessible field net/minecraft/world/level/biome/AmbientParticleSettings probability F extendable class net/minecraft/world/level/material/FluidState accessible field net/minecraft/world/level/block/state/StateHolder propertiesCodec Lcom/mojang/serialization/MapCodec; + +# to init VR +accessible class net/minecraft/client/ResourceLoadStateTracker$ReloadState +accessible field net/minecraft/client/ResourceLoadStateTracker$ReloadState reloadReason Lnet/minecraft/client/ResourceLoadStateTracker$ReloadReason;