From da6692c8b112b09c7f0f96b3752afac5a2efcfe6 Mon Sep 17 00:00:00 2001 From: fayer3 Date: Mon, 21 Oct 2024 13:04:10 +0200 Subject: [PATCH 1/7] just log the full stacktrace for the render info, fixes #305 --- .../vivecraft/mixin/client/blaze3d/RenderTargetMixin.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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 0eba25c02..0a00f2482 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 @@ -18,8 +18,6 @@ import org.vivecraft.client_vr.settings.VRSettings; import org.vivecraft.client_xr.render_pass.RenderPassType; -import java.util.Arrays; - @Mixin(RenderTarget.class) public abstract class RenderTargetMixin implements RenderTargetExtension { @@ -121,11 +119,11 @@ public String toString() { if (RenderPassType.isWorldOnly()) { if (!this.vivecraft$loggedSizeError && (this.width != Minecraft.getInstance().getMainRenderTarget().width || this.height != Minecraft.getInstance().getMainRenderTarget().height)) { // log a limited StackTrace to find the cause, we don't need to spam the log with full StackTraces - VRSettings.logger.error("Vivecraft: Mismatched RenderTarget size detected, viewport size change was blocked. MainTarget size: {}x{}, RenderTarget size: {}x{}. RenderPass: {}, Stacktrace: {}", + VRSettings.logger.error("Vivecraft: Mismatched RenderTarget size detected, viewport size change was blocked. MainTarget size: {}x{}, RenderTarget size: {}x{}. RenderPass: {}, Stacktrace:", Minecraft.getInstance().getMainRenderTarget().width, Minecraft.getInstance().getMainRenderTarget().height, this.width, this.height, ClientDataHolderVR.getInstance().currentPass, - String.join("\n", Arrays.stream(Thread.currentThread().getStackTrace(), 2, 12).map(Object::toString).toArray(String[]::new))); + new RuntimeException()); this.vivecraft$loggedSizeError = true; } return false; From 2c92bb25a1e08186487d9a62d8af26e9f30fb8f6 Mon Sep 17 00:00:00 2001 From: fayer3 Date: Mon, 21 Oct 2024 13:09:42 +0200 Subject: [PATCH 2/7] fix bow tracker not resetting completely, fixes interact buttons not working, when switching item while the bow is notched --- .../org/vivecraft/client_vr/gameplay/trackers/BowTracker.java | 1 + 1 file changed, 1 insertion(+) diff --git a/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/BowTracker.java b/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/BowTracker.java index bf8201bad..271c70210 100644 --- a/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/BowTracker.java +++ b/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/BowTracker.java @@ -103,6 +103,7 @@ public boolean isCharged() { public void reset(LocalPlayer player) { this.isDrawing = false; + this.canDraw = false; } public EntryPoint getEntryPoint() { From 425e89f5ca6e4c71659d04e5ddea13dbd210b114 Mon Sep 17 00:00:00 2001 From: fayer3 Date: Mon, 21 Oct 2024 13:12:39 +0200 Subject: [PATCH 3/7] fix some mods gui overlays not rendering correctly --- .../org/vivecraft/mixin/client_vr/MinecraftVRMixin.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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 908c37b4d..acbb9ec54 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 @@ -413,14 +413,18 @@ public abstract class MinecraftVRMixin implements MinecraftExtension { return constant; } - @Inject(at = @At("HEAD"), method = "resizeDisplay") + @Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;getMainRenderTarget()Lcom/mojang/blaze3d/pipeline/RenderTarget;"), method = "resizeDisplay") void vivecraft$restoreVanillaState(CallbackInfo ci) { if (VRState.vrInitialized) { // restore vanilla post chains before the resize, or it will resize the wrong ones if (levelRenderer != null) { ((LevelRendererExtension) levelRenderer).vivecraft$restoreVanillaPostChains(); } - RenderPassManager.setVanillaRenderPass(); + if (VRState.vrRunning) { + RenderPassManager.setGUIRenderPass(); + } else { + RenderPassManager.setVanillaRenderPass(); + } } } From aa89e1d92b62cdb1cbc66e65e7fe533adb3c9241 Mon Sep 17 00:00:00 2001 From: fayer3 Date: Mon, 21 Oct 2024 13:17:38 +0200 Subject: [PATCH 4/7] change LaunchPopup dependency to the Vivecraft name, trying to fix jitpack timing out --- common/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/build.gradle b/common/build.gradle index d47d4b937..2e7ecf2a1 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -45,7 +45,7 @@ dependencies { compileOnly('com.electronwill.night-config:toml:3.6.6') //LaunchPopup - implementation 'com.github.fayer3:LaunchPopup:master-SNAPSHOT' + implementation 'com.github.Vivecraft:LaunchPopup:master-SNAPSHOT' } // extract the LaunchPopup classes jar { From a2c273437208179b6b0c6f72335cc79f7c53dbab Mon Sep 17 00:00:00 2001 From: fayer3 Date: Mon, 21 Oct 2024 13:51:05 +0200 Subject: [PATCH 5/7] use raw item position for items with custom model data by default --- .../vivecraft/client/gui/settings/GuiVRControls.java | 6 +++--- .../vivecraft/client/network/ClientNetworking.java | 4 ++++ .../org/vivecraft/client_vr/settings/VRSettings.java | 3 +++ .../client_vr/renderer/ItemInHandRendererVRMixin.java | 11 ++++++++++- .../java/org/vivecraft/server/ServerNetworking.java | 11 +++++++++++ .../org/vivecraft/server/config/ServerConfig.java | 5 +++++ .../main/resources/assets/vivecraft/lang/de_de.json | 2 ++ .../main/resources/assets/vivecraft/lang/en_us.json | 2 ++ 8 files changed, 40 insertions(+), 4 deletions(-) diff --git a/common/src/main/java/org/vivecraft/client/gui/settings/GuiVRControls.java b/common/src/main/java/org/vivecraft/client/gui/settings/GuiVRControls.java index dcfce187a..c4fa55753 100644 --- a/common/src/main/java/org/vivecraft/client/gui/settings/GuiVRControls.java +++ b/common/src/main/java/org/vivecraft/client/gui/settings/GuiVRControls.java @@ -14,11 +14,11 @@ public class GuiVRControls extends GuiVROptionsBase { new VROptionEntry(VRSettings.VrOptions.DUMMY, true), new VROptionEntry(VRSettings.VrOptions.DUMMY, true), new VROptionEntry(VRSettings.VrOptions.DUMMY, true), - new VROptionEntry(VRSettings.VrOptions.DUMMY), - new VROptionEntry(VRSettings.VrOptions.INGAME_BINDINGS_IN_GUI), new VROptionEntry(VRSettings.VrOptions.REVERSE_HANDS), - new VROptionEntry(VRSettings.VrOptions.RIGHT_CLICK_DELAY), + new VROptionEntry(VRSettings.VrOptions.INGAME_BINDINGS_IN_GUI), new VROptionEntry(VRSettings.VrOptions.ALLOW_ADVANCED_BINDINGS), + new VROptionEntry(VRSettings.VrOptions.RIGHT_CLICK_DELAY), + new VROptionEntry(VRSettings.VrOptions.THIRDPERSON_ITEMTRANSFORMS_CUSTOM), new VROptionEntry(VRSettings.VrOptions.THIRDPERSON_ITEMTRANSFORMS) }; diff --git a/common/src/main/java/org/vivecraft/client/network/ClientNetworking.java b/common/src/main/java/org/vivecraft/client/network/ClientNetworking.java index 97f13ebe9..9c3badb51 100644 --- a/common/src/main/java/org/vivecraft/client/network/ClientNetworking.java +++ b/common/src/main/java/org/vivecraft/client/network/ClientNetworking.java @@ -164,6 +164,10 @@ public static boolean isThirdPersonItems() { return ClientDataHolderVR.getInstance().vrSettings.overrides.getSetting(VRSettings.VrOptions.THIRDPERSON_ITEMTRANSFORMS).getBoolean(); } + public static boolean isThirdPersonItemsCustom() { + return ClientDataHolderVR.getInstance().vrSettings.overrides.getSetting(VRSettings.VrOptions.THIRDPERSON_ITEMTRANSFORMS_CUSTOM).getBoolean(); + } + public static boolean isLimitedSurvivalTeleport() { return ClientDataHolderVR.getInstance().vrSettings.overrides.getSetting(VRSettings.VrOptions.LIMIT_TELEPORT).getBoolean(); } 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 6d42e1ccb..141ea6c66 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 @@ -222,6 +222,8 @@ public enum UpdateType implements OptionEnum { public boolean ingameBindingsInGui = false; @SettingField(VrOptions.THIRDPERSON_ITEMTRANSFORMS) public boolean thirdPersonItems = false; + @SettingField(VrOptions.THIRDPERSON_ITEMTRANSFORMS_CUSTOM) + public boolean thirdPersonItemsCustom = true; // //Locomotion @@ -1702,6 +1704,7 @@ String getDisplayString(String prefix, Object value) { AUTO_SPRINT(false, true), // Auto-sprint AUTO_SPRINT_THRESHOLD(true, false, 0.5f, 1f, 0.01f, 2), // Auto-sprint Threshold THIRDPERSON_ITEMTRANSFORMS(false, true), // 3rd person items + THIRDPERSON_ITEMTRANSFORMS_CUSTOM(false, true), // 3rd person items, for items with custom model data BOW_MODE(false, true) { // Roomscale Bow Mode @Override diff --git a/common/src/main/java/org/vivecraft/mixin/client_vr/renderer/ItemInHandRendererVRMixin.java b/common/src/main/java/org/vivecraft/mixin/client_vr/renderer/ItemInHandRendererVRMixin.java index d57add9e8..eff6df4ca 100644 --- a/common/src/main/java/org/vivecraft/mixin/client_vr/renderer/ItemInHandRendererVRMixin.java +++ b/common/src/main/java/org/vivecraft/mixin/client_vr/renderer/ItemInHandRendererVRMixin.java @@ -121,7 +121,16 @@ public abstract class ItemInHandRendererVRMixin implements ItemInHandRendererExt } ItemDisplayContext itemDisplayContext; - if ((ClientNetworking.isThirdPersonItems() && !(BowTracker.isBow(pStack) && dh.bowTracker.isActive((LocalPlayer) pPlayer))) || dh.climbTracker.isClaws(pStack)) { + + // third person transforms for custom model data items, but not spear, shield and crossbow + boolean hasCMD = pStack.hasTag() && pStack.getTag().getInt("CustomModelData") != 0 && + rendertype != VivecraftItemRendering.VivecraftItemTransformType.Crossbow && + rendertype != VivecraftItemRendering.VivecraftItemTransformType.Spear && + rendertype != VivecraftItemRendering.VivecraftItemTransformType.Shield; + + boolean isBow = BowTracker.isBow(pStack) && dh.bowTracker.isActive((LocalPlayer) pPlayer); + + if (((ClientNetworking.isThirdPersonItems() || (hasCMD && ClientNetworking.isThirdPersonItemsCustom())) && !isBow) || dh.climbTracker.isClaws(pStack)) { useLeftHandModelinLeftHand = true; //test VivecraftItemRendering.applyThirdPersonItemTransforms(pMatrixStack, rendertype, mainHand, pPlayer, pEquippedProgress, pPartialTicks, pStack, pHand); itemDisplayContext = mainHand ? ItemDisplayContext.THIRD_PERSON_RIGHT_HAND : (useLeftHandModelinLeftHand ? ItemDisplayContext.THIRD_PERSON_LEFT_HAND : ItemDisplayContext.THIRD_PERSON_RIGHT_HAND); diff --git a/common/src/main/java/org/vivecraft/server/ServerNetworking.java b/common/src/main/java/org/vivecraft/server/ServerNetworking.java index 2b2de5b1c..595927c0f 100644 --- a/common/src/main/java/org/vivecraft/server/ServerNetworking.java +++ b/common/src/main/java/org/vivecraft/server/ServerNetworking.java @@ -143,6 +143,17 @@ public static void handlePacket(CommonNetworkHelper.PacketDiscriminators packetI packetConsumer.accept(getVivecraftServerPacket(CommonNetworkHelper.PacketDiscriminators.SETTING_OVERRIDE, array)); } + if (ServerConfig.forceThirdPersonItemsCustom.get()) { + FriendlyByteBuf byteBuf = new FriendlyByteBuf(Unpooled.buffer()); + byteBuf.writeUtf("thirdPersonItemsCustom"); + byteBuf.writeUtf("" + true); + + byte[] array = new byte[byteBuf.readableBytes()]; + byteBuf.readBytes(array); + byteBuf.release(); + packetConsumer.accept(getVivecraftServerPacket(CommonNetworkHelper.PacketDiscriminators.SETTING_OVERRIDE, array)); + } + if (ServerConfig.crawlingEnabled.get()) { packetConsumer.accept(getVivecraftServerPacket(CommonNetworkHelper.PacketDiscriminators.CRAWL, new byte[0])); } diff --git a/common/src/main/java/org/vivecraft/server/config/ServerConfig.java b/common/src/main/java/org/vivecraft/server/config/ServerConfig.java index a56f7e701..b0fdccf19 100644 --- a/common/src/main/java/org/vivecraft/server/config/ServerConfig.java +++ b/common/src/main/java/org/vivecraft/server/config/ServerConfig.java @@ -71,6 +71,7 @@ public class ServerConfig { public static ConfigBuilder.DoubleValue worldscaleMin; public static ConfigBuilder.BooleanValue forceThirdPersonItems; + public static ConfigBuilder.BooleanValue forceThirdPersonItemsCustom; public static ConfigBuilder.BooleanValue vrSwitchingEnabled; @@ -358,6 +359,10 @@ private static void fixConfig(CommentedConfig config, ConfigSpec.CorrectionListe .push("thirdPersonItems") .comment("Forces players to use the raw item position setting") .define(false); + forceThirdPersonItemsCustom = builder + .push("thirdPersonItemsCustom") + .comment("Forces players to use the raw item position setting, only for items with custom model data") + .define(false); // end settingOverrides builder.pop(); 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 e6ec2e041..6e387431b 100644 --- a/common/src/main/resources/assets/vivecraft/lang/de_de.json +++ b/common/src/main/resources/assets/vivecraft/lang/de_de.json @@ -140,6 +140,7 @@ "vivecraft.options.LIMIT_TELEPORT": "Limitiere im Überlebensmodus", "vivecraft.options.REVERSE_HANDS": "Hände vertauschen", "vivecraft.options.THIRDPERSON_ITEMTRANSFORMS": "Rohe Gegenstand Position", + "vivecraft.options.THIRDPERSON_ITEMTRANSFORMS_CUSTOM": "Rohe Custom Gegenstand Position", "vivecraft.options.STENCIL_ON": "Augenschablone nutzen", "vivecraft.options.BCB_ON": "Körperposition Anzeigen", "vivecraft.options.WORLD_SCALE": "Welt Skalierung", @@ -233,6 +234,7 @@ "vivecraft.options.LIMIT_TELEPORT.tooltip": "Wenn aktiviert, hat der Bogen-Teleporter im Überlebensmodus Einschränkungen. Er wird nicht in der Lage sein, seitlich an Blöcken hochzuspringen, er wird Hunger verbrauchen, und er wird einen Energieriegel haben, der sich mit der Zeit wieder auffüllt.", "vivecraft.options.REVERSE_HANDS.tooltip": "Tauschen Sie die linke/rechte Hand als dominant.\n An: Links dominant\n Aus: Rechts-dominant\n\nUm die Tastenbelegung zu vertauschen, starten Sie das Spiel neu und stellen Sie sicher, dass die Standardbindungen in SteamVR ausgewählt sind.", "vivecraft.options.THIRDPERSON_ITEMTRANSFORMS.tooltip": "Bestimmt wie gehaltene Gegenstände transformiert werden.\n An: Benutzt unveränderte 3. Person transformationen.\n Aus: Benutzt adaptierte 1. Person transformationen\n\n3. Person transformationen können besser für Mod Gegenstände funktionieren.", + "vivecraft.options.THIRDPERSON_ITEMTRANSFORMS_CUSTOM.tooltip": "Bestimmt wie gehaltene Gegenstände mit 'Custom Model Data' transformiert werden.\n An: Benutzt unveränderte 3. Person transformationen.\n Aus: Benutzt adaptierte 1. Person transformationen", "vivecraft.options.STENCIL_ON.tooltip": "Bereiche des Bildschirms außerhalb des FOV ausblenden.\nVerbessert die Leistung.", "vivecraft.options.BCB_ON.tooltip": "Zeigt Ihre Körperposition als quadratischen Schatten auf dem Boden an.\nDies ist Ihr quadratischer Schatten Kumpel™.\nVerlieren Sie Ihren quadratischen Schatten Kumpel nicht.", "vivecraft.options.WORLD_SCALE.tooltip": "Skaliert den Spieler in der Welt.\nÜber eins macht Sie größer\nUnd darunter macht es sie kleiner\nUnd die, die Ihnen Ihre Mutter gibt\nmachen überhaupt nichts.", 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 a0379d34c..eedbb1a78 100644 --- a/common/src/main/resources/assets/vivecraft/lang/en_us.json +++ b/common/src/main/resources/assets/vivecraft/lang/en_us.json @@ -139,6 +139,7 @@ "vivecraft.options.LIMIT_TELEPORT": "Limit in Survival", "vivecraft.options.REVERSE_HANDS": "Reverse Hands", "vivecraft.options.THIRDPERSON_ITEMTRANSFORMS": "Raw Item Positions", + "vivecraft.options.THIRDPERSON_ITEMTRANSFORMS_CUSTOM": "Raw Custom Item Positions", "vivecraft.options.STENCIL_ON": "Use Eye Stencil", "vivecraft.options.BCB_ON": "Show Body Position", "vivecraft.options.WORLD_SCALE": "World Scale", @@ -232,6 +233,7 @@ "vivecraft.options.LIMIT_TELEPORT.tooltip": "If enabled the arc teleporter will be have restrictions in survival mode. It will not be able to jump up the side of blocks, it will consume food, and it will have an energy bar that refills over time.", "vivecraft.options.REVERSE_HANDS.tooltip": "Swap left/right hands as dominant.\n ON: Left dominant\n OFF: Right dominant\n\nTo swap the buttons, restart the game and make sure default bindings are selected in SteamVR.", "vivecraft.options.THIRDPERSON_ITEMTRANSFORMS.tooltip": "Determines how held items are transformed.\n ON: Use thirdperson transforms unmodified\n OFF: Use firstperson transforms customized\n\nthirdperson transforms may be better for modded items.", + "vivecraft.options.THIRDPERSON_ITEMTRANSFORMS_CUSTOM.tooltip": "Determines how held items with 'Custom Model Data' are transformed.\n ON: Use thirdperson transforms unmodified\n OFF: Use firstperson transforms customized", "vivecraft.options.STENCIL_ON.tooltip": "Mask out areas of the screen outside the FOV.\nImproves performance.", "vivecraft.options.BCB_ON.tooltip": "Shows your body position as a square shadow on the ground.\nThis is your Square Shadow Buddy™.\nDo not lose your Square Shadow Buddy.", "vivecraft.options.WORLD_SCALE.tooltip": "Scales the player in the world.\nAbove one makes you larger\nAnd below one makes you small\nAnd the ones that mother gives you\ndon't do anything at all.", From 8c39167b0236f733bc7a71b3e850fb8eeb550510 Mon Sep 17 00:00:00 2001 From: fayer3 Date: Mon, 21 Oct 2024 14:05:41 +0200 Subject: [PATCH 6/7] bump version --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 2d2d77c73..58f06a265 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ minecraft_version=1.20.4 enabled_platforms=fabric,forge,neoforge archives_base_name=vivecraft -mod_version=1.1.12 +mod_version=1.1.14 maven_group=org.vivecraft architectury_version=11.0.5 From 0148d3bd3a5e2dffb6720b1f138818e6807c3968 Mon Sep 17 00:00:00 2001 From: fayer3 Date: Mon, 21 Oct 2024 14:21:36 +0200 Subject: [PATCH 7/7] forgot the register for the item fix --- .../main/java/org/vivecraft/client_vr/settings/VRSettings.java | 1 + 1 file changed, 1 insertion(+) 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 141ea6c66..a81c3bae3 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 @@ -2167,6 +2167,7 @@ private ServerOverrides() { registerSetting(VrOptions.TELEPORT_HORIZ_LIMIT, "teleportLimitHoriz", () -> vrTeleportHorizLimit); registerSetting(VrOptions.WORLD_SCALE, "worldScale", () -> worldScale); registerSetting(VrOptions.THIRDPERSON_ITEMTRANSFORMS, "thirdPersonItems", () -> thirdPersonItems); + registerSetting(VrOptions.THIRDPERSON_ITEMTRANSFORMS_CUSTOM, "thirdPersonItemsCustom", () -> thirdPersonItemsCustom); } private void registerSetting(VrOptions option, String networkName, Supplier originalValue) {