From 1e68eb6ed6cc9fe7a2ef821b200b12784291aebb Mon Sep 17 00:00:00 2001
From: NicBOMB <19939315+NicBOMB@users.noreply.github.com>
Date: Sat, 23 Sep 2023 17:48:40 -0700
Subject: [PATCH 01/12] removing all custom math classes
there can be only one
---
.gitignore | 11 +-
.idea/codeStyles/Project.xml | 108 +
.idea/codeStyles/codeStyleConfig.xml | 5 +
.idea/compiler.xml | 32 +
.idea/gradle.xml | 20 +
.../VivecraftMod_Default.xml | 96 +
.../inspectionProfiles/profiles_settings.xml | 6 +
.idea/jarRepositories.xml | 170 ++
.idea/misc.xml | 13 +
.idea/modules.xml | 14 +
.idea/scopes/java_awt.xml | 3 +
.idea/scopes/jetbrains_annotations.xml | 3 +
.idea/scopes/scope_settings.xml | 6 +
.idea/scopes/vivecraft.xml | 3 +
.idea/scopes/vivecraft_common_main_mixin.xml | 3 +
build.gradle | 24 +-
common/build.gradle | 3 +
.../main/java/org/vivecraft/MixinConfig.java | 20 +-
.../org/vivecraft/api_beta/VivecraftAPI.java | 4 +-
.../api_beta/client/VivecraftClientAPI.java | 3 +-
.../org/vivecraft/client/ClientAPIImpl.java | 8 +-
.../org/vivecraft/client/VRPlayersClient.java | 155 +-
.../org/vivecraft/client/VivecraftVRMod.java | 246 +--
.../java/org/vivecraft/client/Xevents.java | 14 +-
.../main/java/org/vivecraft/client/Xplat.java | 7 +-
.../extensions/RenderTargetExtension.java | 43 +-
.../client/gui/framework/GuiVROption.java | 9 +-
.../gui/framework/GuiVROptionButton.java | 57 +-
.../gui/framework/GuiVROptionSlider.java | 63 +-
.../gui/framework/GuiVROptionsBase.java | 438 ++--
.../client/gui/framework/TwoHandedScreen.java | 50 +-
.../client/gui/framework/VROptionEntry.java | 61 -
.../client/gui/framework/VROptionLayout.java | 162 --
.../gui/framework/VROptionPosition.java | 8 +
.../client/gui/screens/ErrorScreen.java | 44 +-
.../client/gui/screens/UpdateScreen.java | 48 +-
.../gui/settings/GuiFreeMoveSettings.java | 61 +-
.../client/gui/settings/GuiHUDSettings.java | 96 +-
.../gui/settings/GuiMainVRSettings.java | 171 +-
.../gui/settings/GuiMenuWorldSettings.java | 72 +-
.../gui/settings/GuiOtherHUDSettings.java | 83 +-
.../gui/settings/GuiQuickCommandEditor.java | 16 +-
.../gui/settings/GuiQuickCommandsInGame.java | 49 +-
.../gui/settings/GuiQuickCommandsList.java | 102 +-
.../gui/settings/GuiRadialConfiguration.java | 109 +-
.../gui/settings/GuiRadialItemsList.java | 31 +-
.../gui/settings/GuiRenderOpticsSettings.java | 213 +-
.../gui/settings/GuiRoomscaleSettings.java | 33 +-
.../client/gui/settings/GuiSeatedOptions.java | 50 +-
.../gui/settings/GuiStandingSettings.java | 46 +-
.../gui/settings/GuiTeleportSettings.java | 40 +-
.../gui/settings/GuiTouchHotbarSettings.java | 56 +
.../client/gui/settings/GuiVRControls.java | 60 +-
.../gui/settings/GuiVRFingerDisplays.java | 54 +
.../gui/settings/GuiVRSkeletalInput.java | 56 +
.../client/gui/widgets/TextScrollWidget.java | 65 +-
.../client/network/ClientNetworking.java | 171 +-
.../client/network/PatreonReceiver.java | 18 +-
.../org/vivecraft/client/render/HMDLayer.java | 42 +-
.../client/render/OpenGLdebugging.java | 107 +-
.../client/render/VRPlayerModel.java | 89 +-
.../client/render/VRPlayerModel_WithArms.java | 464 +++--
.../client/render/VRPlayerRenderer.java | 62 +-
.../org/vivecraft/client/utils/Debug.java | 91 +-
.../vivecraft/client/utils/UpdateChecker.java | 25 +-
.../org/vivecraft/client/utils/Utils.java | 502 +----
.../client/utils/math/BezierCurve.java | 127 --
.../client_vr/ClientDataHolderVR.java | 70 +-
.../org/vivecraft/client_vr/ItemTags.java | 32 +-
.../org/vivecraft/client_vr/MethodHolder.java | 35 -
.../org/vivecraft/client_vr/ScreenUtils.java | 23 +-
.../java/org/vivecraft/client_vr/VRData.java | 196 +-
.../java/org/vivecraft/client_vr/VRState.java | 126 +-
.../vivecraft/client_vr/VRTextureTarget.java | 27 +-
.../org/vivecraft/client_vr/Vec3History.java | 138 +-
.../EntityRenderDispatcherVRExtension.java | 3 +-
.../extensions/FrustumExtension.java | 4 +-
.../extensions/GameRendererExtension.java | 13 +-
.../ItemInHandRendererExtension.java | 3 +-
.../extensions/LevelRendererExtension.java | 1 +
.../client_vr/extensions/PlayerExtension.java | 6 +-
.../client_vr/gameplay/VRMovementStyle.java | 235 +--
.../client_vr/gameplay/VRPlayer.java | 589 +++---
.../gameplay/screenhandlers/GuiHandler.java | 376 ++--
.../screenhandlers/KeyboardHandler.java | 108 +-
.../screenhandlers/RadialHandler.java | 84 +-
.../gameplay/trackers/BackpackTracker.java | 68 +-
.../gameplay/trackers/BowTracker.java | 145 +-
.../gameplay/trackers/CameraTracker.java | 66 +-
.../gameplay/trackers/ClimbTracker.java | 245 ++-
.../gameplay/trackers/CrawlTracker.java | 53 +-
.../gameplay/trackers/EatingTracker.java | 67 +-
.../gameplay/trackers/HorseTracker.java | 73 +-
.../gameplay/trackers/InteractTracker.java | 130 +-
.../gameplay/trackers/JumpTracker.java | 120 +-
.../gameplay/trackers/RowTracker.java | 107 +-
.../gameplay/trackers/RunTracker.java | 49 +-
.../gameplay/trackers/SneakTracker.java | 46 +-
.../gameplay/trackers/SwimTracker.java | 48 +-
.../gameplay/trackers/SwingTracker.java | 176 +-
.../gameplay/trackers/TeleportTracker.java | 146 +-
.../gameplay/trackers/TelescopeTracker.java | 39 +-
.../client_vr/gameplay/trackers/Tracker.java | 27 +-
.../gameplay/trackers/VehicleTracker.java | 104 +-
.../vivecraft/client_vr/gui/GuiKeyboard.java | 198 +-
.../vivecraft/client_vr/gui/GuiRadial.java | 121 +-
.../client_vr/gui/PhysicalKeyboard.java | 405 ++--
.../client_vr/menuworlds/FakeBlockAccess.java | 63 +-
.../menuworlds/MenuWorldDownloader.java | 53 +-
.../menuworlds/MenuWorldExporter.java | 246 ++-
.../menuworlds/MenuWorldRenderer.java | 606 +++---
.../client_vr/provider/ControllerType.java | 2 +-
.../client_vr/provider/HandedKeyBinding.java | 7 +-
.../client_vr/provider/HardwareType.java | 7 +-
.../client_vr/provider/InputSimulator.java | 19 +-
.../vivecraft/client_vr/provider/MCVR.java | 1122 +++++-----
.../client_vr/provider/VRRenderer.java | 308 +--
.../client_vr/provider/nullvr/NullVR.java | 91 +-
.../provider/nullvr/NullVRStereoRenderer.java | 75 +-
.../provider/openvr_lwjgl/MCOpenVR.java | 873 ++++----
.../openvr_lwjgl/OpenVRHapticScheduler.java | 22 +-
.../openvr_lwjgl/OpenVRStereoRenderer.java | 181 +-
.../provider/openvr_lwjgl/OpenVRUtil.java | 44 -
.../provider/openvr_lwjgl/VRInputAction.java | 216 +-
.../control/HapticMusicPlayer.java | 26 +-
.../control/TrackpadSwipeSampler.java | 20 +-
.../control/VRInputActionSet.java | 29 +-
.../control/VivecraftMovementInput.java | 12 +-
.../client_vr/provider/ovr_lwjgl/MC_OVR.java | 2 +-
.../ovr_lwjgl/OVR_StereoRenderer.java | 4 +-
.../client_vr/render/RenderPass.java | 3 +-
.../client_vr/render/ShaderHelper.java | 68 +-
.../client_vr/render/VRArmRenderer.java | 15 +-
.../render/VRFirstPersonArmSwing.java | 2 +-
.../vivecraft/client_vr/render/VRShaders.java | 18 +-
.../client_vr/render/VRWidgetHelper.java | 94 +-
.../render/VivecraftItemRendering.java | 435 ++--
.../vivecraft/client_vr/render/XRCamera.java | 41 +-
.../client_vr/settings/AutoCalibration.java | 38 +-
.../client_vr/settings/OptionEnum.java | 23 +-
.../client_vr/settings/SettingField.java | 6 +-
.../client_vr/settings/VRHotkeys.java | 341 +--
.../client_vr/settings/VRSettings.java | 847 +++++---
.../settings/profile/ProfileManager.java | 97 +-
.../settings/profile/ProfileReader.java | 10 +-
.../settings/profile/ProfileWriter.java | 5 +-
.../client_vr/utils/LoaderUtils.java | 38 +-
.../vivecraft/client_vr/utils/RGBAColor.java | 88 -
.../client_vr/utils/external/jinfinadeck.java | 16 +-
.../client_vr/utils/external/jkatvr.java | 12 +-
.../render_pass/RenderPassManager.java | 16 +-
.../render_pass/WorldRenderPass.java | 23 +-
.../java/org/vivecraft/common/APIImpl.java | 5 +-
.../org/vivecraft/common/VRServerPerms.java | 14 +-
.../common/network/CommonNetworkHelper.java | 11 +-
.../org/vivecraft/common/network/Pose.java | 5 +-
.../common/network/VRPlayerState.java | 51 +
.../common/network/VrPlayerState.java | 60 -
.../org/vivecraft/common/utils/Utils.java | 268 ++-
.../vivecraft/common/utils/color/Color.java | 1099 ++++++++++
.../vivecraft/common/utils/lwjgl/Matrix.java | 27 -
.../common/utils/lwjgl/Matrix2f.java | 259 ---
.../common/utils/lwjgl/Matrix3f.java | 346 ----
.../common/utils/lwjgl/Matrix4f.java | 648 ------
.../vivecraft/common/utils/lwjgl/Vector.java | 41 -
.../common/utils/lwjgl/Vector2f.java | 192 --
.../common/utils/lwjgl/Vector3f.java | 229 --
.../common/utils/lwjgl/Vector4f.java | 235 ---
.../vivecraft/common/utils/math/Angle.java | 206 --
.../org/vivecraft/common/utils/math/Axis.java | 21 -
.../vivecraft/common/utils/math/Convert.java | 173 --
.../vivecraft/common/utils/math/Matrix4f.java | 237 ---
.../common/utils/math/Quaternion.java | 403 ----
.../vivecraft/common/utils/math/Vector2.java | 177 --
.../vivecraft/common/utils/math/Vector3.java | 320 ---
.../client/blaze3d/RenderSystemAccessor.java | 4 +-
.../client/blaze3d/RenderTargetMixin.java | 158 +-
.../events/ContainerEventHandlerVRMixin.java | 4 +-
.../mixin/client/gui/screens/ScreenMixin.java | 16 +-
.../client/gui/screens/TitleScreenMixin.java | 65 +-
.../mixin/client/main/MainMixin.java | 38 +-
.../player/AbstractClientPlayerMixin.java | 5 +-
.../block/LiquidBlockRendererMixin.java | 9 +-
.../renderer/culling/FrustumVRMixin.java | 7 +-
.../entity/EntityRenderDispatcherMixin.java | 53 +-
.../renderer/entity/ItemRendererVRMixin.java | 55 +-
.../renderer/entity/PlayerRendererMixin.java | 76 +-
.../entity/layers/RenderLayerMixin.java | 4 +-
.../ClientBrandRetrieverVRMixin.java | 6 +-
.../client_vr/KeyboardHandlerVRMixin.java | 62 +-
.../mixin/client_vr/KeyboardInputVRMixin.java | 93 +-
.../mixin/client_vr/MinecraftVRMixin.java | 1140 +++++-----
.../mixin/client_vr/MouseHandlerVRMixin.java | 49 +-
.../mixin/client_vr/OptionsVRMixin.java | 59 +-
.../blaze3d/audio/LibraryVRMixin.java | 15 +-
.../platform/GlStateManagerVRMixin.java | 17 +-
.../platform/InputConstantsVRMixin.java | 14 +-
.../blaze3d/platform/WindowVRMixin.java | 45 +-
.../blaze3d/systems/RenderSystemVRMixin.java | 13 +-
.../mixin/client_vr/gui/EditBoxVRMixin.java | 24 +-
.../client_vr/gui/GuiComponentVRMixin.java | 21 +-
.../mixin/client_vr/gui/GuiVRMixin.java | 94 +-
.../client_vr/gui/TutorialToastVRMixin.java | 24 +-
.../gui/screens/OptionsScreenVRMixin.java | 28 +-
.../gui/screens/PauseScreenVRMixin.java | 127 +-
.../client_vr/gui/screens/ScreenVRMixin.java | 19 +-
.../screens/SoundOptionsScreenVRMixin.java | 46 +-
.../gui/screens/WinScreenVRMixin.java | 9 +-
.../AbstractContainerScreenVRMixin.java | 1 +
.../AbstractSignEditScreenVRMixin.java | 13 +-
.../inventory/BookEditScreenVRMixin.java | 12 +-
.../CreativeModeInventoryScreenVRMixin.java | 21 +-
.../ClientPacketListenerVRMixin.java | 103 +-
.../MultiPlayerGameModeVRMixin.java | 23 +-
.../particle/ItemPickupParticleVRMixin.java | 51 +-
.../client_vr/player/LocalPlayerVRMixin.java | 309 ++-
.../renderer/GameRendererVRMixin.java | 1845 +++++++++--------
.../renderer/ItemInHandRendererVRMixin.java | 193 +-
.../renderer/ItemPropertiesVRMixin.java | 13 +-
.../renderer/LevelRendererVRMixin.java | 177 +-
.../NoSodiumLevelRendererVRMixin.java | 21 +-
.../client_vr/renderer/PostChainVRMixin.java | 16 +-
.../TheEndGatewayRendererVRMixin.java | 54 +-
.../TheEndPortalRendererVRMixin.java | 51 +-
.../entity/EntityRenderDispatcherVRMixin.java | 85 +-
.../entity/EntityRendererVRMixin.java | 8 +-
.../entity/FishingHookRendererVRMixin.java | 52 +-
.../entity/GuardianRendererVRMixin.java | 15 +-
.../renderer/entity/MobRendererVRMixin.java | 20 +-
.../MovementTutorialStepInstanceVRMixin.java | 88 +-
.../OpenInventoryTutorialStepVRMixin.java | 16 +-
.../PunchTreeTutorialStepInstanceVRMixin.java | 10 +-
.../mixin/client_vr/world/BoatMixin.java | 273 +--
.../client_vr/world/FishingHookVRMixin.java | 49 +-
.../mixin/client_vr/world/ItemVRMixin.java | 9 +-
.../client_vr/world/PotionItemVRMixin.java | 15 +-
.../world/entity/player/PlayerVRMixin.java | 1 +
.../FireworkRocketEntityVRMixin.java | 30 +-
.../world/level/block/DoorBlockVRMixin.java | 13 +-
.../level/block/FenceGateBlockVRMixin.java | 17 +-
.../level/block/TrapDoorBlockVRMixin.java | 13 +-
.../mixin/server/ChunkMapAccessor.java | 2 +
.../mixin/server/MinecraftServerMixin.java | 8 +-
.../ServerGamePacketListenerImplMixin.java | 38 +-
.../ServerLoginPacketListenerImplMixin.java | 4 +-
.../mixin/server/ServerPlayerMixin.java | 82 +-
.../mixin/server/TrackedEntityAccessor.java | 5 +-
.../world/entity/ai/goal/SwellGoalMixin.java | 14 +-
.../EndermanFreezeWhenLookedAtMixin.java | 14 +-
.../world/entity/monster/EndermanMixin.java | 6 +-
.../entity/projectile/AbstractArrowMixin.java | 51 +-
.../AbstractHurtingProjectileMixin.java | 13 +-
.../entity/projectile/FishingHookMixin.java | 51 +-
.../entity/projectile/ProjectileMixin.java | 12 +-
.../projectile/ThrowableProjectileMixin.java | 13 +-
.../entity/projectile/ThrownTridentMixin.java | 15 +-
.../mixin/world/item/CrossbowItemMixin.java | 19 +-
.../item/crafting/ShapedRecipeMixin.java | 8 +-
.../mixin/DynamicFPSModVRMixin.java | 5 +-
.../mixin/DynamicFPSScreenVRMixin.java | 6 +-
.../mod_compat_vr/iris/IrisHelper.java | 3 +-
.../extensions/PipelineManagerExtension.java | 3 +-
.../iris/mixin/IrisBeginFrameHack.java | 8 +-
.../mixin/IrisChunkProgramOverridesMixin.java | 37 +-
...unkProgramOverridesMixinSodium_0_4_11.java | 8 +-
...hunkProgramOverridesMixinSodium_0_4_9.java | 8 +-
.../iris/mixin/IrisHandRendererVRMixin.java | 8 +-
.../IrisNewWorldRenderingPipelineVRMixin.java | 10 +-
.../mixin/IrisPipelineManagerVRMixin.java | 53 +-
.../iris/mixin/IrisProgramUniformsMixin.java | 15 +-
.../iris/mixin/IrisRenderSystemVRMixin.java | 4 +-
.../iris/mixin/IrisShadowMatricesMixin.java | 23 +-
.../iris/mixin/IrisShadowRendererMixin.java | 41 +-
.../optifine/OptifineHelper.java | 33 +-
.../optifine/mixin/ShadersRenderVRMixin.java | 33 +-
.../optifine/mixin/ShadersVRMixin.java | 28 +-
.../mod_compat_vr/pehkui/PehkuiHelper.java | 3 +-
.../physicsmod/mixin/OptionsScreenMixin.java | 1 +
.../rei/mixin/reiTextFieldWidgetMixin.java | 10 +-
.../ResolutionControlHelper.java | 3 +-
.../mixin/ResolutionControlModMixin.java | 19 +-
.../mod_compat_vr/sodium/SodiumHelper.java | 6 +-
.../FabricSodiumGameOptionPagesVRMixin.java | 11 +-
.../ForgeSodiumGameOptionPagesVRMixin.java | 11 +-
.../mixin/RenderSectionManagerVRMixin.java | 1 +
.../mixin/SodiumWorldRendererVRMixin.java | 4 +-
.../org/vivecraft/server/AimFixHandler.java | 18 +-
.../vivecraft/server/ServerNetworking.java | 237 ++-
.../java/org/vivecraft/server/ServerUtil.java | 10 +-
.../org/vivecraft/server/ServerVRPlayers.java | 5 +-
.../vivecraft/server/ServerVivePlayer.java | 52 +-
.../server/config/ConfigBuilder.java | 3 +-
.../vivecraft/server/config/ServerConfig.java | 116 +-
.../vivecraft/input/cosmos_defaults.json | 2 +-
.../input/cosmos_defaults_reversed.json | 2 +-
.../vivecraft/input/knuckles_defaults.json | 12 +-
.../input/knuckles_defaults_reversed.json | 12 +-
.../vivecraft/input/oculus_defaults.json | 2 +-
.../input/oculus_defaults_reversed.json | 2 +-
.../vivecraft/input/tracker_defaults.json | 2 +-
.../assets/vivecraft/input/vive_defaults.json | 2 +-
.../input/vive_defaults_reversed.json | 2 +-
.../assets/vivecraft/input/wmr_defaults.json | 2 +-
.../input/wmr_defaults_reversed.json | 2 +-
.../assets/vivecraft/lang/en_us.json | 74 +-
.../assets/vivecraft/vivecraft.vrmanifest | 2 +-
fabric/build.gradle | 3 +
.../vivecraft/client/fabric/XeventsImpl.java | 1 +
.../vivecraft/client/fabric/XplatImpl.java | 17 +-
.../org/vivecraft/fabric/VivecraftMod.java | 5 +-
.../mixin/FabricGameRendererVRMixin.java | 15 +-
.../model/FabricModelBakeryMixin.java | 17 +-
.../client/FabricClientNetworkingVRMixin.java | 5 +-
.../world/level/biome/BiomeAccessor.java | 4 +-
fabric/src/main/resources/fabric.mod.json | 1 +
forge/build.gradle | 3 +
.../vivecraft/client/forge/XeventsImpl.java | 10 +-
.../org/vivecraft/client/forge/XplatImpl.java | 17 +-
.../java/org/vivecraft/forge/Vivecraft.java | 3 +-
.../vivecraft/forge/event/ClientEvents.java | 21 +-
.../vivecraft/forge/event/CommonEvents.java | 8 +-
.../forge/mixin/ForgeGameRendererVRMixin.java | 21 +-
.../forge/mixin/ForgeIngameGuiVRMixin.java | 11 +-
.../network/ForgeOpenContainerVRMixin.java | 16 +-
forge/src/main/resources/META-INF/mods.toml | 2 +-
gradlew | 0
326 files changed, 13378 insertions(+), 15041 deletions(-)
create mode 100644 .idea/codeStyles/Project.xml
create mode 100644 .idea/codeStyles/codeStyleConfig.xml
create mode 100644 .idea/compiler.xml
create mode 100644 .idea/gradle.xml
create mode 100644 .idea/inspectionProfiles/VivecraftMod_Default.xml
create mode 100644 .idea/inspectionProfiles/profiles_settings.xml
create mode 100644 .idea/jarRepositories.xml
create mode 100644 .idea/misc.xml
create mode 100644 .idea/modules.xml
create mode 100644 .idea/scopes/java_awt.xml
create mode 100644 .idea/scopes/jetbrains_annotations.xml
create mode 100644 .idea/scopes/scope_settings.xml
create mode 100644 .idea/scopes/vivecraft.xml
create mode 100644 .idea/scopes/vivecraft_common_main_mixin.xml
delete mode 100644 common/src/main/java/org/vivecraft/client/gui/framework/VROptionEntry.java
delete mode 100644 common/src/main/java/org/vivecraft/client/gui/framework/VROptionLayout.java
create mode 100644 common/src/main/java/org/vivecraft/client/gui/framework/VROptionPosition.java
create mode 100644 common/src/main/java/org/vivecraft/client/gui/settings/GuiTouchHotbarSettings.java
create mode 100644 common/src/main/java/org/vivecraft/client/gui/settings/GuiVRFingerDisplays.java
create mode 100644 common/src/main/java/org/vivecraft/client/gui/settings/GuiVRSkeletalInput.java
delete mode 100644 common/src/main/java/org/vivecraft/client/utils/math/BezierCurve.java
delete mode 100644 common/src/main/java/org/vivecraft/client_vr/MethodHolder.java
delete mode 100644 common/src/main/java/org/vivecraft/client_vr/provider/openvr_lwjgl/OpenVRUtil.java
delete mode 100644 common/src/main/java/org/vivecraft/client_vr/utils/RGBAColor.java
create mode 100644 common/src/main/java/org/vivecraft/common/network/VRPlayerState.java
delete mode 100644 common/src/main/java/org/vivecraft/common/network/VrPlayerState.java
create mode 100644 common/src/main/java/org/vivecraft/common/utils/color/Color.java
delete mode 100644 common/src/main/java/org/vivecraft/common/utils/lwjgl/Matrix.java
delete mode 100644 common/src/main/java/org/vivecraft/common/utils/lwjgl/Matrix2f.java
delete mode 100644 common/src/main/java/org/vivecraft/common/utils/lwjgl/Matrix3f.java
delete mode 100644 common/src/main/java/org/vivecraft/common/utils/lwjgl/Matrix4f.java
delete mode 100644 common/src/main/java/org/vivecraft/common/utils/lwjgl/Vector.java
delete mode 100644 common/src/main/java/org/vivecraft/common/utils/lwjgl/Vector2f.java
delete mode 100644 common/src/main/java/org/vivecraft/common/utils/lwjgl/Vector3f.java
delete mode 100644 common/src/main/java/org/vivecraft/common/utils/lwjgl/Vector4f.java
delete mode 100644 common/src/main/java/org/vivecraft/common/utils/math/Angle.java
delete mode 100644 common/src/main/java/org/vivecraft/common/utils/math/Axis.java
delete mode 100644 common/src/main/java/org/vivecraft/common/utils/math/Convert.java
delete mode 100644 common/src/main/java/org/vivecraft/common/utils/math/Matrix4f.java
delete mode 100644 common/src/main/java/org/vivecraft/common/utils/math/Quaternion.java
delete mode 100644 common/src/main/java/org/vivecraft/common/utils/math/Vector2.java
delete mode 100644 common/src/main/java/org/vivecraft/common/utils/math/Vector3.java
mode change 100644 => 100755 gradlew
diff --git a/.gitignore b/.gitignore
index aa9842795..5396c1d34 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,7 +11,16 @@ libs/
.classpath
.project
-.idea/
+.idea/*
+!.idea/compiler.xml
+!.idea/gradle.xml
+!.idea/jarRepositories.xml
+!.idea/misc.xml
+!.idea/modules.xml
+!.idea/codeStyles/
+!.idea/inspectionProfiles/
+!.idea/modules/
+!.idea/scopes/
classes/
.metadata
.vscode
diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
new file mode 100644
index 000000000..b189217f7
--- /dev/null
+++ b/.idea/codeStyles/Project.xml
@@ -0,0 +1,108 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml
new file mode 100644
index 000000000..79ee123c2
--- /dev/null
+++ b/.idea/codeStyles/codeStyleConfig.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 000000000..939d937d8
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
new file mode 100644
index 000000000..08d38a44a
--- /dev/null
+++ b/.idea/gradle.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/VivecraftMod_Default.xml b/.idea/inspectionProfiles/VivecraftMod_Default.xml
new file mode 100644
index 000000000..97e77ca9a
--- /dev/null
+++ b/.idea/inspectionProfiles/VivecraftMod_Default.xml
@@ -0,0 +1,96 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml
new file mode 100644
index 000000000..9c0c90608
--- /dev/null
+++ b/.idea/inspectionProfiles/profiles_settings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
new file mode 100644
index 000000000..56cfd71ef
--- /dev/null
+++ b/.idea/jarRepositories.xml
@@ -0,0 +1,170 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 000000000..f62f5df63
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 000000000..636763cd9
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/scopes/java_awt.xml b/.idea/scopes/java_awt.xml
new file mode 100644
index 000000000..a90bc0e02
--- /dev/null
+++ b/.idea/scopes/java_awt.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/.idea/scopes/jetbrains_annotations.xml b/.idea/scopes/jetbrains_annotations.xml
new file mode 100644
index 000000000..bdef76ddb
--- /dev/null
+++ b/.idea/scopes/jetbrains_annotations.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/.idea/scopes/scope_settings.xml b/.idea/scopes/scope_settings.xml
new file mode 100644
index 000000000..ec495b09e
--- /dev/null
+++ b/.idea/scopes/scope_settings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/scopes/vivecraft.xml b/.idea/scopes/vivecraft.xml
new file mode 100644
index 000000000..33a68dd3a
--- /dev/null
+++ b/.idea/scopes/vivecraft.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/.idea/scopes/vivecraft_common_main_mixin.xml b/.idea/scopes/vivecraft_common_main_mixin.xml
new file mode 100644
index 000000000..c440f5df2
--- /dev/null
+++ b/.idea/scopes/vivecraft_common_main_mixin.xml
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index 7cb380fff..ff0e273d8 100644
--- a/build.gradle
+++ b/build.gradle
@@ -23,10 +23,10 @@ subprojects {
dependencies {
minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
- // The following line declares the mojmap mappings, you may use other mappings as well
- mappings loom.officialMojangMappings()
- // The following line declares the yarn mappings you may select this one as well.
- // mappings "net.fabricmc:yarn:1.18.2+build.4:v2"
+ mappings loom.layered() {
+ officialMojangMappings()
+ parchment("org.parchmentmc.data:parchment-1.20.1:2023.08.20@zip")
+ }
implementation("org.lwjgl:lwjgl-openvr:3.3.1")
implementation("org.lwjgl:lwjgl-openvr:3.3.1:natives-linux")
implementation("org.lwjgl:lwjgl-openvr:3.3.1:natives-macos")
@@ -80,6 +80,11 @@ allprojects {
}
}
+ maven {
+ name = 'ParchmentMC'
+ url = 'https://maven.parchmentmc.org'
+ }
+
exclusiveContent {
forRepository {
maven {
@@ -120,7 +125,16 @@ allprojects {
maven { url = "https://maven.terraformersmc.com/" }
maven { url = "https://maven.cafeteria.dev/releases/" }
maven { url = "https://maven.gegy.dev" }
- maven { url = "https://modmaven.dev" }
+ maven {
+ // location of a maven mirror for JEI files, as a fallback
+ name = "ModMaven"
+ url = "https://modmaven.dev"
+ }
+ maven {
+ // location of the maven that hosts JEI files since January 2023
+ name = "Jared's maven"
+ url = "https://maven.blamejared.com/"
+ }
exclusiveContent {
forRepository {
maven {
diff --git a/common/build.gradle b/common/build.gradle
index 12fe263e3..2e1654caf 100644
--- a/common/build.gradle
+++ b/common/build.gradle
@@ -53,6 +53,9 @@ dependencies {
//LaunchPopup
implementation 'com.github.fayer3:LaunchPopup:master-SNAPSHOT'
+ // MixinExtras
+ implementation(annotationProcessor("io.github.llamalad7:mixinextras-common:0.2.0-rc.4"))
+
}
// extract the LaunchPopup classes
jar {
diff --git a/common/src/main/java/org/vivecraft/MixinConfig.java b/common/src/main/java/org/vivecraft/MixinConfig.java
index 9657306e8..51f78ddc7 100644
--- a/common/src/main/java/org/vivecraft/MixinConfig.java
+++ b/common/src/main/java/org/vivecraft/MixinConfig.java
@@ -1,13 +1,6 @@
package org.vivecraft;
-import org.apache.logging.log4j.Level;
-import org.apache.logging.log4j.LogManager;
-import org.objectweb.asm.tree.ClassNode;
-import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
-import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
-import org.spongepowered.asm.service.MixinService;
import org.vivecraft.client.Xplat;
-
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.mixin.RenderSectionManagerVRMixin;
@@ -16,6 +9,13 @@
import java.util.List;
import java.util.Set;
+import static org.vivecraft.common.utils.Utils.logger;
+
+import org.objectweb.asm.tree.ClassNode;
+import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
+import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
+import org.spongepowered.asm.service.MixinService;
+
public class MixinConfig implements IMixinConfigPlugin {
@Override
@@ -51,7 +51,7 @@ public void onLoad(String mixinPackage) {
@Override
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
if (!Xplat.isModLoadedSuccess()) {
- LogManager.getLogger().log(Level.WARN, "not loading '" + mixinClassName + "' because mod failed to load completely");
+ logger.warn("not loading '{}' because mod failed to load completely", mixinClassName);
return false;
}
@@ -68,7 +68,7 @@ else if (mixinClassName.equals(RenderSectionManagerVRMixin.class.getName())) {
try {
MixinService.getService().getBytecodeProvider().getClassNode(neededClass);
ClassNode node = MixinService.getService().getBytecodeProvider().getClassNode(targetClassName);
- return node.fields.stream().anyMatch(field -> field.name.equals("chunkRenderList"));
+ return node.fields.stream().anyMatch(field -> "chunkRenderList".equals(field.name));
} catch (ClassNotFoundException | IOException e) {
return false;
}
@@ -79,7 +79,7 @@ else if (mixinClassName.equals(RenderSectionManagerVRMixin.class.getName())) {
MixinService.getService().getBytecodeProvider().getClassNode(neededClass);
return true;
} catch (ClassNotFoundException | IOException e) {
- LogManager.getLogger().log(Level.INFO, "Vivecraft: skipping mixin '" + mixinClassName + "'");
+ logger.info("skipping mixin '{}'", mixinClassName);
return false;
}
}
diff --git a/common/src/main/java/org/vivecraft/api_beta/VivecraftAPI.java b/common/src/main/java/org/vivecraft/api_beta/VivecraftAPI.java
index a95a3b0b8..873e3769a 100644
--- a/common/src/main/java/org/vivecraft/api_beta/VivecraftAPI.java
+++ b/common/src/main/java/org/vivecraft/api_beta/VivecraftAPI.java
@@ -1,8 +1,10 @@
package org.vivecraft.api_beta;
+import org.vivecraft.common.APIImpl;
+
import com.google.common.annotations.Beta;
+
import net.minecraft.world.entity.player.Player;
-import org.vivecraft.common.APIImpl;
@Beta
public interface VivecraftAPI {
diff --git a/common/src/main/java/org/vivecraft/api_beta/client/VivecraftClientAPI.java b/common/src/main/java/org/vivecraft/api_beta/client/VivecraftClientAPI.java
index ff629beb4..06bdfc4ca 100644
--- a/common/src/main/java/org/vivecraft/api_beta/client/VivecraftClientAPI.java
+++ b/common/src/main/java/org/vivecraft/api_beta/client/VivecraftClientAPI.java
@@ -1,8 +1,9 @@
package org.vivecraft.api_beta.client;
-import com.google.common.annotations.Beta;
import org.vivecraft.client.ClientAPIImpl;
+import com.google.common.annotations.Beta;
+
public interface VivecraftClientAPI {
static VivecraftClientAPI getInstance() {
diff --git a/common/src/main/java/org/vivecraft/client/ClientAPIImpl.java b/common/src/main/java/org/vivecraft/client/ClientAPIImpl.java
index 215c6625d..c6505233b 100644
--- a/common/src/main/java/org/vivecraft/client/ClientAPIImpl.java
+++ b/common/src/main/java/org/vivecraft/client/ClientAPIImpl.java
@@ -1,9 +1,11 @@
package org.vivecraft.client;
import org.vivecraft.api_beta.client.VivecraftClientAPI;
-import org.vivecraft.client_vr.VRState;
import org.vivecraft.client_xr.render_pass.RenderPassType;
+import static org.vivecraft.client_vr.VRState.vrInitialized;
+import static org.vivecraft.client_vr.VRState.vrRunning;
+
public final class ClientAPIImpl implements VivecraftClientAPI {
public static final ClientAPIImpl INSTANCE = new ClientAPIImpl();
@@ -13,12 +15,12 @@ private ClientAPIImpl() {
@Override
public boolean isVrInitialized() {
- return VRState.vrInitialized;
+ return vrInitialized;
}
@Override
public boolean isVrActive() {
- return VRState.vrRunning;
+ return vrRunning;
}
@Override
diff --git a/common/src/main/java/org/vivecraft/client/VRPlayersClient.java b/common/src/main/java/org/vivecraft/client/VRPlayersClient.java
index 0f452f3e2..34bd12af8 100644
--- a/common/src/main/java/org/vivecraft/client/VRPlayersClient.java
+++ b/common/src/main/java/org/vivecraft/client/VRPlayersClient.java
@@ -1,23 +1,27 @@
package org.vivecraft.client;
-import net.minecraft.client.Minecraft;
+import org.vivecraft.client.utils.Utils;
+import org.vivecraft.client_vr.VRData;
+import org.vivecraft.common.network.VRPlayerState;
+
+import org.joml.Quaternionf;
+import org.joml.Vector3d;
+import org.joml.Vector3f;
+
import net.minecraft.client.particle.Particle;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.world.entity.player.Player;
-import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3;
-import org.vivecraft.client_vr.VRData;
-import org.vivecraft.client.utils.Utils;
-import org.vivecraft.client_vr.ClientDataHolderVR;
-import org.vivecraft.common.network.VrPlayerState;
-import org.vivecraft.common.utils.math.Quaternion;
-import org.vivecraft.common.utils.math.Vector3;
import java.util.*;
-import java.util.Map.Entry;
+
+import static org.vivecraft.client_vr.VRState.dh;
+import static org.vivecraft.client_vr.VRState.mc;
+import static org.vivecraft.common.utils.Utils.*;
+
+import static org.joml.Math.*;
public class VRPlayersClient {
- private final Minecraft mc;
private final Map vivePlayers = new HashMap<>();
private final Map vivePlayersLast = new HashMap<>();
private final Map vivePlayersReceived = Collections.synchronizedMap(new HashMap<>());
@@ -38,12 +42,8 @@ public static void clear() {
instance = null;
}
- private VRPlayersClient() {
- this.mc = Minecraft.getInstance();
- }
-
public boolean isVRPlayer(Player player) {
- return vivePlayers.containsKey(player.getUUID());
+ return this.vivePlayers.containsKey(player.getUUID());
}
public void disableVR(UUID player) {
@@ -52,23 +52,19 @@ public void disableVR(UUID player) {
this.vivePlayersReceived.remove(player);
}
- public void Update(UUID uuid, VrPlayerState vrPlayerState, float worldScale, float heightScale, boolean localPlayer) {
- if (localPlayer || !this.mc.player.getUUID().equals(uuid)) {
- Vector3 forward = new Vector3(0.0F, 0.0F, -1.0F);
- Vector3 hmdDir = vrPlayerState.hmd().orientation().multiply(forward);
- Vector3 controller0Dir = vrPlayerState.controller0().orientation().multiply(forward);
- Vector3 controller1Dir = vrPlayerState.controller1().orientation().multiply(forward);
+ public void Update(UUID uuid, VRPlayerState vrPlayerState, float worldScale, float heightScale, boolean localPlayer) {
+ if (localPlayer || !mc.player.getUUID().equals(uuid)) {
var rotInfo = new RotInfo();
- rotInfo.reverse = vrPlayerState.reverseHands();
- rotInfo.seated = vrPlayerState.seated();
if (this.donors.containsKey(uuid)) {
rotInfo.hmd = this.donors.get(uuid);
}
- rotInfo.leftArmRot = new Vec3(controller1Dir.getX(), controller1Dir.getY(), controller1Dir.getZ());
- rotInfo.rightArmRot = new Vec3(controller0Dir.getX(), controller0Dir.getY(), controller0Dir.getZ());
- rotInfo.headRot = new Vec3(hmdDir.getX(), hmdDir.getY(), hmdDir.getZ());
+ rotInfo.reverse = vrPlayerState.reverseHands();
+ rotInfo.seated = vrPlayerState.seated();
+ rotInfo.leftArmRot = convertToVec3(vrPlayerState.controller1().orientation().transformUnit(0.0F, 0.0F, -1.0F, new Vector3f()));
+ rotInfo.rightArmRot = convertToVec3(vrPlayerState.controller0().orientation().transformUnit(0.0F, 0.0F, -1.0F, new Vector3f()));
+ rotInfo.headRot = convertToVec3(vrPlayerState.hmd().orientation().transformUnit(0.0F, 0.0F, -1.0F, new Vector3f()));
rotInfo.Headpos = vrPlayerState.hmd().position();
rotInfo.leftArmPos = vrPlayerState.controller1().position();
rotInfo.rightArmPos = vrPlayerState.controller0().position();
@@ -95,42 +91,36 @@ public void Update(UUID uuid, VrPlayerState vrPlayerState, float worldScale, flo
}
}
- public void Update(UUID uuid, VrPlayerState vrPlayerState, float worldscale, float heightscale) {
+ public void Update(UUID uuid, VRPlayerState vrPlayerState, float worldscale, float heightscale) {
this.Update(uuid, vrPlayerState, worldscale, heightscale, false);
}
public void tick() {
- for (Entry entry : this.vivePlayers.entrySet()) {
- this.vivePlayersLast.put(entry.getKey(), entry.getValue());
- }
-
- for (Entry entry1 : this.vivePlayersReceived.entrySet()) {
- this.vivePlayers.put(entry1.getKey(), entry1.getValue());
- }
+ this.vivePlayersLast.putAll(this.vivePlayers);
- Level level = Minecraft.getInstance().level;
+ this.vivePlayers.putAll(this.vivePlayersReceived);
- if (level != null) {
+ if (mc.level != null) {
Iterator iterator = this.vivePlayers.keySet().iterator();
while (iterator.hasNext()) {
UUID uuid = iterator.next();
- if (level.getPlayerByUUID(uuid) == null) {
+ if (mc.level.getPlayerByUUID(uuid) == null) {
iterator.remove();
this.vivePlayersLast.remove(uuid);
this.vivePlayersReceived.remove(uuid);
}
}
- if (!this.mc.isPaused()) {
- for (Player player : level.players()) {
+ if (!mc.isPaused()) {
+ for (Player player : mc.level.players()) {
if (this.donors.getOrDefault(player.getUUID(), 0) > 3 && this.rand.nextInt(10) < 4) {
RotInfo playermodelcontroller$rotinfo = this.vivePlayers.get(player.getUUID());
Vec3 vec3 = player.getLookAngle();
if (playermodelcontroller$rotinfo != null) {
- vec3 = playermodelcontroller$rotinfo.leftArmPos.subtract(playermodelcontroller$rotinfo.rightArmPos).yRot((-(float) Math.PI / 2F));
+ vec3 = playermodelcontroller$rotinfo.leftArmPos.subtract(playermodelcontroller$rotinfo.rightArmPos).yRot((-(float) PI / 2F));
if (playermodelcontroller$rotinfo.reverse) {
vec3 = vec3.scale(-1.0D);
@@ -144,11 +134,15 @@ public void tick() {
}
vec3 = vec3.scale(0.1F);
- Vec3 vec31 = playermodelcontroller$rotinfo != null && player == this.mc.player ? playermodelcontroller$rotinfo.Headpos.add(player.position()) : player.getEyePosition(1.0F);
- Particle particle = this.mc.particleEngine.createParticle(ParticleTypes.FIREWORK, vec31.x + (player.isShiftKeyDown() ? -vec3.x * 3.0D : 0.0D) + ((double) this.rand.nextFloat() - 0.5D) * (double) 0.02F, vec31.y - (double) (player.isShiftKeyDown() ? 1.0F : 0.8F) + ((double) this.rand.nextFloat() - 0.5D) * (double) 0.02F, vec31.z + (player.isShiftKeyDown() ? -vec3.z * 3.0D : 0.0D) + ((double) this.rand.nextFloat() - 0.5D) * (double) 0.02F, -vec3.x + ((double) this.rand.nextFloat() - 0.5D) * (double) 0.01F, ((double) this.rand.nextFloat() - (double) 0.05F) * (double) 0.05F, -vec3.z + ((double) this.rand.nextFloat() - 0.5D) * (double) 0.01F);
+ Vec3 vec31 = playermodelcontroller$rotinfo != null && player == mc.player ? playermodelcontroller$rotinfo.Headpos.add(player.position()) : player.getEyePosition(1.0F);
+ Particle particle = mc.particleEngine.createParticle(ParticleTypes.FIREWORK, vec31.x + (player.isShiftKeyDown() ? -vec3.x * 3.0D : 0.0D) + ((double) this.rand.nextFloat() - 0.5D) * (double) 0.02F, vec31.y - (double) (player.isShiftKeyDown() ? 1.0F : 0.8F) + ((double) this.rand.nextFloat() - 0.5D) * (double) 0.02F, vec31.z + (player.isShiftKeyDown() ? -vec3.z * 3.0D : 0.0D) + ((double) this.rand.nextFloat() - 0.5D) * (double) 0.02F, -vec3.x + ((double) this.rand.nextFloat() - 0.5D) * (double) 0.01F, ((double) this.rand.nextFloat() - (double) 0.05F) * (double) 0.05F, -vec3.z + ((double) this.rand.nextFloat() - 0.5D) * (double) 0.01F);
if (particle != null) {
- particle.setColor(0.5F + this.rand.nextFloat() / 2.0F, 0.5F + this.rand.nextFloat() / 2.0F, 0.5F + this.rand.nextFloat() / 2.0F);
+ particle.setColor(
+ 0.5F + this.rand.nextFloat() / 2.0F,
+ 0.5F + this.rand.nextFloat() / 2.0F,
+ 0.5F + this.rand.nextFloat() / 2.0F
+ );
}
}
}
@@ -166,7 +160,7 @@ public boolean HMDCHecked(UUID uuid) {
public RotInfo getRotationsForPlayer(UUID uuid) {
if (this.debug) {
- uuid = this.mc.player.getUUID();
+ uuid = mc.player.getUUID();
}
RotInfo playermodelcontroller$rotinfo = this.vivePlayers.get(uuid);
@@ -174,7 +168,7 @@ public RotInfo getRotationsForPlayer(UUID uuid) {
if (playermodelcontroller$rotinfo != null && this.vivePlayersLast.containsKey(uuid)) {
RotInfo playermodelcontroller$rotinfo1 = this.vivePlayersLast.get(uuid);
RotInfo playermodelcontroller$rotinfo2 = new RotInfo();
- float f = Minecraft.getInstance().getFrameTime();
+ float f = mc.getFrameTime();
playermodelcontroller$rotinfo2.reverse = playermodelcontroller$rotinfo.reverse;
playermodelcontroller$rotinfo2.seated = playermodelcontroller$rotinfo.seated;
playermodelcontroller$rotinfo2.hmd = playermodelcontroller$rotinfo.hmd;
@@ -184,10 +178,22 @@ public RotInfo getRotationsForPlayer(UUID uuid) {
playermodelcontroller$rotinfo2.leftArmQuat = playermodelcontroller$rotinfo.leftArmQuat;
playermodelcontroller$rotinfo2.rightArmQuat = playermodelcontroller$rotinfo.rightArmQuat;
playermodelcontroller$rotinfo2.headQuat = playermodelcontroller$rotinfo.headQuat;
- Vector3 vector3 = new Vector3(0.0F, 0.0F, -1.0F);
- playermodelcontroller$rotinfo2.leftArmRot = Utils.vecLerp(playermodelcontroller$rotinfo1.leftArmRot, Utils.convertToVector3d(playermodelcontroller$rotinfo2.leftArmQuat.multiply(vector3)), f);
- playermodelcontroller$rotinfo2.rightArmRot = Utils.vecLerp(playermodelcontroller$rotinfo1.rightArmRot, Utils.convertToVector3d(playermodelcontroller$rotinfo2.rightArmQuat.multiply(vector3)), f);
- playermodelcontroller$rotinfo2.headRot = Utils.vecLerp(playermodelcontroller$rotinfo1.headRot, Utils.convertToVector3d(playermodelcontroller$rotinfo2.headQuat.multiply(vector3)), f);
+ playermodelcontroller$rotinfo2.leftArmRot = Utils.vecLerp(
+ playermodelcontroller$rotinfo1.leftArmRot,
+ convertToVec3(
+ playermodelcontroller$rotinfo2.leftArmQuat.transformUnit(new Vector3f(forward))
+ ), f
+ );
+ playermodelcontroller$rotinfo2.rightArmRot = Utils.vecLerp(
+ playermodelcontroller$rotinfo1.rightArmRot,
+ convertToVec3(playermodelcontroller$rotinfo2.rightArmQuat.transformUnit(new Vector3f(forward))),
+ f
+ );
+ playermodelcontroller$rotinfo2.headRot = Utils.vecLerp(
+ playermodelcontroller$rotinfo1.headRot,
+ convertToVec3(playermodelcontroller$rotinfo2.headQuat.transformUnit(new Vector3f(forward))),
+ f
+ );
playermodelcontroller$rotinfo2.heightScale = playermodelcontroller$rotinfo.heightScale;
playermodelcontroller$rotinfo2.worldScale = playermodelcontroller$rotinfo.worldScale;
return playermodelcontroller$rotinfo2;
@@ -198,13 +204,13 @@ public RotInfo getRotationsForPlayer(UUID uuid) {
public static RotInfo getMainPlayerRotInfo(VRData data) {
RotInfo playermodelcontroller$rotinfo = new RotInfo();
- Quaternion quaternion = new Quaternion(data.getController(1).getMatrix());
- Quaternion quaternion1 = new Quaternion(data.getController(0).getMatrix());
- Quaternion quaternion2 = new Quaternion(data.hmd.getMatrix());
+ Quaternionf quaternion = new Quaternionf().setFromNormalized(data.getController(1).getMatrix());
+ Quaternionf quaternion1 = new Quaternionf().setFromNormalized(data.getController(0).getMatrix());
+ Quaternionf quaternion2 = new Quaternionf().setFromNormalized(data.hmd.getMatrix());
playermodelcontroller$rotinfo.headQuat = quaternion2;
playermodelcontroller$rotinfo.leftArmQuat = quaternion;
playermodelcontroller$rotinfo.rightArmQuat = quaternion1;
- playermodelcontroller$rotinfo.seated = ClientDataHolderVR.getInstance().vrSettings.seated;
+ playermodelcontroller$rotinfo.seated = dh.vrSettings.seated;
playermodelcontroller$rotinfo.leftArmPos = data.getController(1).getPosition();
playermodelcontroller$rotinfo.rightArmPos = data.getController(0).getPosition();
playermodelcontroller$rotinfo.Headpos = data.hmd.getPosition();
@@ -213,26 +219,30 @@ public static RotInfo getMainPlayerRotInfo(VRData data) {
public boolean isTracked(UUID uuid) {
this.debug = false;
- return this.debug ? true : this.vivePlayers.containsKey(uuid);
+ return this.debug || this.vivePlayers.containsKey(uuid);
}
public static float getFacingYaw(RotInfo rotInfo) {
Vec3 vec3 = getOrientVec(rotInfo.headQuat);
- return (float) Math.toDegrees(Math.atan2(vec3.x, vec3.z));
+ return (float) toDegrees(atan2(vec3.x, vec3.z));
}
- public static Vec3 getOrientVec(Quaternion quat) {
- Vec3 vec3 = quat.multiply(new Vec3(0.0D, 0.0D, -1.0D)).cross(quat.multiply(new Vec3(0.0D, 1.0D, 0.0D))).normalize();
- return (new Vec3(0.0D, 1.0D, 0.0D)).cross(vec3).normalize();
+ public static Vec3 getOrientVec(Quaternionf quat) {
+ return convertToVec3(
+ new Vector3f(up).cross(
+ quat.transformUnit(new Vector3f(forward)).cross(
+ quat.transformUnit(new Vector3f(up))).normalize()
+ ).normalize()
+ );
}
public static class RotInfo {
public boolean seated;
public boolean reverse;
public int hmd = 0;
- public Quaternion leftArmQuat;
- public Quaternion rightArmQuat;
- public Quaternion headQuat;
+ public Quaternionf leftArmQuat;
+ public Quaternionf rightArmQuat;
+ public Quaternionf headQuat;
public Vec3 leftArmRot;
public Vec3 rightArmRot;
public Vec3 headRot;
@@ -243,18 +253,25 @@ public static class RotInfo {
public float heightScale;
public double getBodyYawRadians() {
- Vec3 vec3 = this.leftArmPos.subtract(this.rightArmPos).yRot((-(float) Math.PI / 2F));
-
- if (this.reverse) {
- vec3 = vec3.scale(-1.0D);
- }
+ Vector3d vec3;
if (this.seated) {
- vec3 = this.rightArmRot;
+ vec3 = convertToVector3d(this.rightArmRot, new Vector3d());
+ }
+ else
+ {
+ vec3 = convertToVector3d(this.leftArmPos, new Vector3d())
+ .sub(this.rightArmPos.x(), this.rightArmPos.y(), this.rightArmPos.z())
+ .rotateY((-(float)PI / 2.0F));
+
+ if (this.reverse)
+ {
+ vec3.negate();
+ }
}
- Vec3 vec31 = Utils.vecLerp(vec3, this.headRot, 0.5D);
- return Math.atan2(-vec31.x, vec31.z);
+ vec3.lerp(convertToVector3d(this.headRot, new Vector3d()), 0.5D);
+ return atan2(-vec3.x, vec3.z);
}
}
}
diff --git a/common/src/main/java/org/vivecraft/client/VivecraftVRMod.java b/common/src/main/java/org/vivecraft/client/VivecraftVRMod.java
index 9fcdcc08a..75c7a715d 100644
--- a/common/src/main/java/org/vivecraft/client/VivecraftVRMod.java
+++ b/common/src/main/java/org/vivecraft/client/VivecraftVRMod.java
@@ -1,162 +1,118 @@
package org.vivecraft.client;
-import net.minecraft.client.KeyMapping;
-import net.minecraft.client.Minecraft;
-import org.apache.commons.lang3.ArrayUtils;
import org.vivecraft.client_vr.gameplay.screenhandlers.GuiHandler;
import org.vivecraft.client_vr.provider.HandedKeyBinding;
-import java.util.*;
-
-public class VivecraftVRMod {
-
- public static final boolean compiledWithForge = true;
-
- private static final Minecraft mc = Minecraft.getInstance();
-
- public static VivecraftVRMod INSTANCE = new VivecraftVRMod();
-
- Set allKeyBindingSet;
-
- // key binds that are settable by the user
- Set userKeyBindingSet;
-
- // key binds that are needed internally, but are not required to be set by the user
- Set hiddenKeyBindingSet;
-
- protected Set vanillaBindingSet;
-
- public final HandedKeyBinding keyClimbeyGrab = new HandedKeyBinding("vivecraft.key.climbeyGrab", -1, "vivecraft.key.category.climbey");
- public final HandedKeyBinding keyClimbeyJump = new HandedKeyBinding("vivecraft.key.climbeyJump", -1, "vivecraft.key.category.climbey");
- public final KeyMapping keyExportWorld = new KeyMapping("vivecraft.key.exportWorld", -1, "key.categories.misc");
- public final KeyMapping keyFreeMoveRotate = new KeyMapping("vivecraft.key.freeMoveRotate", -1, "key.categories.movement");
- public final KeyMapping keyFreeMoveStrafe = new KeyMapping("vivecraft.key.freeMoveStrafe", -1, "key.categories.movement");
- public final KeyMapping keyHotbarNext = new KeyMapping("vivecraft.key.hotbarNext", -1, "key.categories.inventory");
- public final KeyMapping keyHotbarPrev = new KeyMapping("vivecraft.key.hotbarPrev", -1, "key.categories.inventory");
- public final KeyMapping keyHotbarScroll = new KeyMapping("vivecraft.key.hotbarScroll", -1, "key.categories.inventory");
- public final KeyMapping keyHotbarSwipeX = new KeyMapping("vivecraft.key.hotbarSwipeX", -1, "key.categories.inventory");
- public final KeyMapping keyHotbarSwipeY = new KeyMapping("vivecraft.key.hotbarSwipeY", -1, "key.categories.inventory");
- 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 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");
- public final KeyMapping keyRotateFree = new KeyMapping("vivecraft.key.rotateFree", -1, "key.categories.movement");
- public final KeyMapping keyRotateLeft = new KeyMapping("vivecraft.key.rotateLeft", -1, "key.categories.movement");
- public final KeyMapping keyRotateRight = new KeyMapping("vivecraft.key.rotateRight", -1, "key.categories.movement");
- public final KeyMapping keySwapMirrorView = new KeyMapping("vivecraft.key.swapMirrorView", -1, "key.categories.misc");
- public final KeyMapping keyTeleport = new KeyMapping("vivecraft.key.teleport", -1, "key.categories.movement");
- public final KeyMapping keyTeleportFallback = new KeyMapping("vivecraft.key.teleportFallback", -1, "key.categories.movement");
- public final KeyMapping keyToggleHandheldCam = new KeyMapping("vivecraft.key.toggleHandheldCam", -1, "key.categories.misc");
- public final KeyMapping keyToggleKeyboard = new KeyMapping("vivecraft.key.toggleKeyboard", -1, "key.categories.ui");
- public final KeyMapping keyToggleMovement = new KeyMapping("vivecraft.key.toggleMovement", -1, "key.categories.movement");
- public final KeyMapping keyTogglePlayerList = new KeyMapping("vivecraft.key.togglePlayerList", -1, "key.categories.multiplayer");
- public final HandedKeyBinding keyTrackpadTouch = new HandedKeyBinding("vivecraft.key.trackpadTouch", -1, "key.categories.misc");
- public final HandedKeyBinding keyVRInteract = new HandedKeyBinding("vivecraft.key.vrInteract", -1, "key.categories.gameplay");
- public final KeyMapping keyWalkabout = new KeyMapping("vivecraft.key.walkabout", -1, "key.categories.movement");
-
- private void setupKeybindingSets() {
- if (this.userKeyBindingSet == null || hiddenKeyBindingSet == null)
- {
- this.userKeyBindingSet = new LinkedHashSet<>();
- this.hiddenKeyBindingSet = new LinkedHashSet<>();
- this.allKeyBindingSet = new LinkedHashSet<>();
-
- this.userKeyBindingSet.add(this.keyRotateLeft);
- this.userKeyBindingSet.add(this.keyRotateRight);
- this.userKeyBindingSet.add(this.keyTeleport);
- this.userKeyBindingSet.add(this.keyTeleportFallback);
- this.userKeyBindingSet.add(this.keyToggleMovement);
- this.userKeyBindingSet.add(this.keyQuickTorch);
- this.userKeyBindingSet.add(this.keySwapMirrorView);
- this.userKeyBindingSet.add(this.keyExportWorld);
- this.userKeyBindingSet.add(this.keyMoveThirdPersonCam);
- this.userKeyBindingSet.add(this.keyTogglePlayerList);
- this.userKeyBindingSet.add(this.keyToggleHandheldCam);
- this.userKeyBindingSet.add(this.keyQuickHandheldCam);
-
- this.hiddenKeyBindingSet.add(GuiHandler.keyLeftClick);
- this.hiddenKeyBindingSet.add(GuiHandler.keyRightClick);
- this.hiddenKeyBindingSet.add(GuiHandler.keyMiddleClick);
- this.hiddenKeyBindingSet.add(GuiHandler.keyShift);
- this.hiddenKeyBindingSet.add(GuiHandler.keyCtrl);
- this.hiddenKeyBindingSet.add(GuiHandler.keyAlt);
- this.hiddenKeyBindingSet.add(GuiHandler.keyScrollUp);
- this.hiddenKeyBindingSet.add(GuiHandler.keyScrollDown);
- this.hiddenKeyBindingSet.add(GuiHandler.keyScrollAxis);
- this.hiddenKeyBindingSet.add(GuiHandler.keyKeyboardClick);
- this.hiddenKeyBindingSet.add(GuiHandler.keyKeyboardShift);
- this.hiddenKeyBindingSet.add(this.keyClimbeyGrab);
- 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);
-
- this.hiddenKeyBindingSet.add(this.keyRotateAxis);
- this.hiddenKeyBindingSet.add(this.keyRotateFree);
- this.hiddenKeyBindingSet.add(this.keyFreeMoveRotate);
- this.hiddenKeyBindingSet.add(this.keyFreeMoveStrafe);
- this.hiddenKeyBindingSet.add(this.keyHotbarNext);
- this.hiddenKeyBindingSet.add(this.keyHotbarPrev);
- this.hiddenKeyBindingSet.add(this.keyHotbarScroll);
- this.hiddenKeyBindingSet.add(this.keyVRInteract);
- this.hiddenKeyBindingSet.add(this.keyWalkabout);
-
- allKeyBindingSet.addAll(userKeyBindingSet);
- allKeyBindingSet.addAll(hiddenKeyBindingSet);
- }
- }
-
- public Set getUserKeyBindings()
- {
- setupKeybindingSets();
- return this.userKeyBindingSet;
- }
-
- public Set getHiddenKeyBindings() {
- setupKeybindingSets();
- return hiddenKeyBindingSet;
- }
+import net.minecraft.client.KeyMapping;
- public Set getAllKeyBindings() {
- setupKeybindingSets();
- return allKeyBindingSet;
- }
+import java.util.Arrays;
+import java.util.LinkedHashSet;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
- public KeyMapping[] initializeBindings(KeyMapping[] keyBindings)
- {
- for (KeyMapping keymapping : this.getUserKeyBindings())
- {
- keyBindings = ArrayUtils.add(keyBindings, keymapping);
- }
+import static org.vivecraft.client_vr.VRState.mc;
- this.setVanillaBindings(keyBindings);
- Map map = KeyMapping.CATEGORY_SORT_ORDER;
- map.put("vivecraft.key.category.gui", 8);
- map.put("vivecraft.key.category.climbey", 9);
- map.put("vivecraft.key.category.keyboard", 10);
- return keyBindings;
- }
+import static org.lwjgl.glfw.GLFW.*;
- public void setVanillaBindings(KeyMapping[] bindings)
- {
- this.vanillaBindingSet = new HashSet<>(Arrays.asList(bindings));
- // add hidden keys, since those are not in there
- vanillaBindingSet.addAll(hiddenKeyBindingSet);
- }
+public class VivecraftVRMod {
- public boolean isSafeBinding(KeyMapping kb)
+ public static final HandedKeyBinding keyClimbeyGrab = new HandedKeyBinding("vivecraft.key.climbeyGrab", GLFW_KEY_UNKNOWN, "vivecraft.key.category.climbey");
+ public static final HandedKeyBinding keyClimbeyJump = new HandedKeyBinding("vivecraft.key.climbeyJump", GLFW_KEY_UNKNOWN, "vivecraft.key.category.climbey");
+ public static final KeyMapping keyExportWorld = new KeyMapping("vivecraft.key.exportWorld", GLFW_KEY_UNKNOWN, "key.categories.misc");
+ public static final KeyMapping keyFreeMoveRotate = new KeyMapping("vivecraft.key.freeMoveRotate", GLFW_KEY_UNKNOWN, "key.categories.movement");
+ public static final KeyMapping keyFreeMoveStrafe = new KeyMapping("vivecraft.key.freeMoveStrafe", GLFW_KEY_UNKNOWN, "key.categories.movement");
+ public static final KeyMapping keyHotbarNext = new KeyMapping("vivecraft.key.hotbarNext", GLFW_KEY_UNKNOWN, "key.categories.inventory");
+ public static final KeyMapping keyHotbarPrev = new KeyMapping("vivecraft.key.hotbarPrev", GLFW_KEY_UNKNOWN, "key.categories.inventory");
+ public static final KeyMapping keyHotbarScroll = new KeyMapping("vivecraft.key.hotbarScroll", GLFW_KEY_UNKNOWN, "key.categories.inventory");
+ public static final KeyMapping keyHotbarSwipeX = new KeyMapping("vivecraft.key.hotbarSwipeX", GLFW_KEY_UNKNOWN, "key.categories.inventory");
+ public static final KeyMapping keyHotbarSwipeY = new KeyMapping("vivecraft.key.hotbarSwipeY", GLFW_KEY_UNKNOWN, "key.categories.inventory");
+ public static final KeyMapping keyMenuButton = new KeyMapping("vivecraft.key.ingameMenuButton", GLFW_KEY_UNKNOWN, "key.categories.ui");
+ public static final KeyMapping keyMoveThirdPersonCam = new KeyMapping("vivecraft.key.moveThirdPersonCam", GLFW_KEY_UNKNOWN, "key.categories.misc");
+ public static final KeyMapping keyQuickHandheldCam = new KeyMapping("vivecraft.key.quickHandheldCam", GLFW_KEY_UNKNOWN, "key.categories.misc");
+ public static final KeyMapping keyQuickTorch = new KeyMapping("vivecraft.key.quickTorch", GLFW_KEY_UNKNOWN, "key.categories.gameplay");
+ public static final KeyMapping keyRadialMenu = new KeyMapping("vivecraft.key.radialMenu", GLFW_KEY_UNKNOWN, "key.categories.ui");
+ public static final KeyMapping keyRotateAxis = new KeyMapping("vivecraft.key.rotateAxis", GLFW_KEY_UNKNOWN, "key.categories.movement");
+ public static final KeyMapping keyRotateFree = new KeyMapping("vivecraft.key.rotateFree", GLFW_KEY_UNKNOWN, "key.categories.movement");
+ public static final KeyMapping keyRotateLeft = new KeyMapping("vivecraft.key.rotateLeft", GLFW_KEY_UNKNOWN, "key.categories.movement");
+ public static final KeyMapping keyRotateRight = new KeyMapping("vivecraft.key.rotateRight", GLFW_KEY_UNKNOWN, "key.categories.movement");
+ public static final KeyMapping keySwapMirrorView = new KeyMapping("vivecraft.key.swapMirrorView", GLFW_KEY_UNKNOWN, "key.categories.misc");
+ public static final KeyMapping keyTeleport = new KeyMapping("vivecraft.key.teleport", GLFW_KEY_UNKNOWN, "key.categories.movement");
+ public static final KeyMapping keyTeleportFallback = new KeyMapping("vivecraft.key.teleportFallback", GLFW_KEY_UNKNOWN, "key.categories.movement");
+ public static final KeyMapping keyToggleHandheldCam = new KeyMapping("vivecraft.key.toggleHandheldCam", GLFW_KEY_UNKNOWN, "key.categories.misc");
+ public static final KeyMapping keyToggleKeyboard = new KeyMapping("vivecraft.key.toggleKeyboard", GLFW_KEY_UNKNOWN, "key.categories.ui");
+ public static final KeyMapping keyToggleMovement = new KeyMapping("vivecraft.key.toggleMovement", GLFW_KEY_UNKNOWN, "key.categories.movement");
+ public static final KeyMapping keyTogglePlayerList = new KeyMapping("vivecraft.key.togglePlayerList", GLFW_KEY_UNKNOWN, "key.categories.multiplayer");
+ public static final HandedKeyBinding keyTrackpadTouch = new HandedKeyBinding("vivecraft.key.trackpadTouch", GLFW_KEY_UNKNOWN, "key.categories.misc");
+ public static final HandedKeyBinding keyVRInteract = new HandedKeyBinding("vivecraft.key.vrInteract", GLFW_KEY_UNKNOWN, "key.categories.gameplay");
+ public static final KeyMapping keyWalkabout = new KeyMapping("vivecraft.key.walkabout", GLFW_KEY_UNKNOWN, "key.categories.movement");
+
+ /** Key binds provided by vivecraft, which the player may bind. */
+ public static final Set userKeyBindingSet = new LinkedHashSet<>(Arrays.asList(
+ keyRotateLeft,
+ keyRotateRight,
+ keyTeleport,
+ keyTeleportFallback,
+ keyToggleMovement,
+ keyQuickTorch,
+ keySwapMirrorView,
+ keyExportWorld,
+ keyMoveThirdPersonCam,
+ keyTogglePlayerList,
+ keyToggleHandheldCam,
+ keyQuickHandheldCam
+ ));
+
+ /** Key binds internal to vivecraft, which the player may not bind. */
+ public static final Set hiddenKeyBindingSet = new LinkedHashSet<>(Arrays.asList(
+ GuiHandler.keyLeftClick,
+ GuiHandler.keyRightClick,
+ GuiHandler.keyMiddleClick,
+ GuiHandler.keyShift,
+ GuiHandler.keyCtrl,
+ GuiHandler.keyAlt,
+ GuiHandler.keyScrollUp,
+ GuiHandler.keyScrollDown,
+ GuiHandler.keyScrollAxis,
+ GuiHandler.keyKeyboardClick,
+ GuiHandler.keyKeyboardShift,
+ keyClimbeyGrab,
+ keyClimbeyJump,
+ keyMenuButton,
+ keyRadialMenu,
+ keyToggleKeyboard,
+ keyHotbarSwipeX,
+ keyHotbarSwipeY,
+ keyTrackpadTouch,
+ keyRotateAxis,
+ keyRotateFree,
+ keyFreeMoveRotate,
+ keyFreeMoveStrafe,
+ keyHotbarNext,
+ keyHotbarPrev,
+ keyHotbarScroll,
+ keyVRInteract,
+ keyWalkabout
+ ));
+
+ /** Key binds provided by vanilla. */
+ public static final Set vanillaBindingSet = new LinkedHashSet<>();
+
+ /** Key binds provided to the player. */
+ public static final Set allKeyBindingSet = Stream.concat(
+ userKeyBindingSet.stream(),
+ hiddenKeyBindingSet.stream()
+ ).collect(Collectors.toSet());
+
+ public static boolean isSafeBinding(KeyMapping kb)
{
- return this.getAllKeyBindings().contains(kb) || kb == mc.options.keyChat || kb == mc.options.keyInventory;
+ return allKeyBindingSet.contains(kb) || kb == mc.options.keyChat || kb == mc.options.keyInventory;
}
- public boolean isModBinding(KeyMapping kb)
+ /** checks if a key bind is provided by vanilla or internal to vivecraft */
+ public static boolean isModBinding(final KeyMapping kb)
{
- return !this.vanillaBindingSet.contains(kb);
+ return !hiddenKeyBindingSet.contains(kb) && !vanillaBindingSet.contains(kb);
}
}
diff --git a/common/src/main/java/org/vivecraft/client/Xevents.java b/common/src/main/java/org/vivecraft/client/Xevents.java
index c1fd3640d..0ccdca162 100644
--- a/common/src/main/java/org/vivecraft/client/Xevents.java
+++ b/common/src/main/java/org/vivecraft/client/Xevents.java
@@ -1,7 +1,9 @@
package org.vivecraft.client;
-import com.mojang.blaze3d.vertex.PoseStack;
import dev.architectury.injectables.annotations.ExpectPlatform;
+
+import com.mojang.blaze3d.vertex.PoseStack;
+
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.block.state.BlockState;
@@ -9,27 +11,27 @@
public interface Xevents {
@ExpectPlatform
- public static boolean renderBlockOverlay(Player player, PoseStack mat, BlockState state, BlockPos pos) {
+ static boolean renderBlockOverlay(Player player, PoseStack mat, BlockState state, BlockPos pos) {
return false;
}
@ExpectPlatform
- public static boolean renderWaterOverlay(Player player, PoseStack mat) {
+ static boolean renderWaterOverlay(Player player, PoseStack mat) {
return false;
}
@ExpectPlatform
- public static boolean renderFireOverlay(Player player, PoseStack mat) {
+ static boolean renderFireOverlay(Player player, PoseStack mat) {
return false;
}
@ExpectPlatform
- public static void onRenderTickStart(float f) {
+ static void onRenderTickStart(float f) {
}
@ExpectPlatform
- public static void onRenderTickEnd(float f) {
+ static void onRenderTickEnd(float f) {
}
diff --git a/common/src/main/java/org/vivecraft/client/Xplat.java b/common/src/main/java/org/vivecraft/client/Xplat.java
index 7d56b8189..67743c1e1 100644
--- a/common/src/main/java/org/vivecraft/client/Xplat.java
+++ b/common/src/main/java/org/vivecraft/client/Xplat.java
@@ -1,11 +1,14 @@
package org.vivecraft.client;
-import com.mojang.blaze3d.pipeline.RenderTarget;
import dev.architectury.injectables.annotations.ExpectPlatform;
+
+import com.mojang.blaze3d.pipeline.RenderTarget;
+
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockAndTintGetter;
import net.minecraft.world.level.biome.Biome;
+import net.minecraft.world.level.biome.Biome.ClimateSettings;
import net.minecraft.world.level.biome.BiomeSpecialEffects;
import net.minecraft.world.level.material.FluidState;
@@ -76,7 +79,7 @@ static TextureAtlasSprite[] getFluidTextures(BlockAndTintGetter level, BlockPos
}
@ExpectPlatform
- static Biome.ClimateSettings getBiomeClimateSettings(Biome biome){
+ static ClimateSettings getBiomeClimateSettings(Biome biome){
return null;
}
diff --git a/common/src/main/java/org/vivecraft/client/extensions/RenderTargetExtension.java b/common/src/main/java/org/vivecraft/client/extensions/RenderTargetExtension.java
index 0aa61315d..b894844e7 100644
--- a/common/src/main/java/org/vivecraft/client/extensions/RenderTargetExtension.java
+++ b/common/src/main/java/org/vivecraft/client/extensions/RenderTargetExtension.java
@@ -1,32 +1,43 @@
package org.vivecraft.client.extensions;
+import org.lwjgl.opengl.GL11C;
+import org.lwjgl.opengl.GL30C;
+
import net.minecraft.client.renderer.ShaderInstance;
-import org.lwjgl.opengl.GL30;
-public interface RenderTargetExtension {
+public interface RenderTargetExtension
+{
- String getName();
+ String getName();
- void clearWithColor(float r, float g, float b, float a, boolean isMac);
+ void clearWithColor(float r, float g, float b, float a, boolean isMac);
- default void blitToScreen(int i, int viewWidth, int viewHeight, int j, boolean b, float f, float g, boolean c) {
- blitToScreen(null, i, viewWidth, viewHeight, j, b, f, g, c);
- }
+ default void blitToScreen(
+ int left, int width, int height, int top, boolean disableBlend, float xCropFactor,
+ float yCropFactor, boolean keepAspect
+ )
+ {
+ blitToScreen(null, left, width, height, top, disableBlend, xCropFactor, yCropFactor, keepAspect);
+ }
- void blitToScreen(ShaderInstance instance, int i, int viewWidth, int viewHeight, int j, boolean b, float f, float g, boolean c);
+ void blitToScreen(
+ ShaderInstance instance, int left, int width, int height, int top, boolean disableBlend, float xCropFactor,
+ float yCropFactor, boolean keepAspect
+ );
- default void genMipMaps() {
- GL30.glGenerateMipmap(3553);
- }
+ default void genMipMaps()
+ {
+ GL30C.glGenerateMipmap(GL11C.GL_TEXTURE_2D);
+ }
- void setTextid(int texid);
+ void setTextid(int texid);
- void setUseStencil(boolean useStencil);
+ void setUseStencil(boolean useStencil);
- boolean getUseStencil();
+ boolean getUseStencil();
- void isLinearFilter(boolean linearFilter);
+ void isLinearFilter(boolean linearFilter);
- void blitFovReduction(ShaderInstance instance, int width, int height);
+ void blitFovReduction(ShaderInstance instance, int width, int height);
}
diff --git a/common/src/main/java/org/vivecraft/client/gui/framework/GuiVROption.java b/common/src/main/java/org/vivecraft/client/gui/framework/GuiVROption.java
index f2e24fd45..ed1dd9199 100644
--- a/common/src/main/java/org/vivecraft/client/gui/framework/GuiVROption.java
+++ b/common/src/main/java/org/vivecraft/client/gui/framework/GuiVROption.java
@@ -1,10 +1,13 @@
package org.vivecraft.client.gui.framework;
+import org.vivecraft.client_vr.settings.VRSettings.VrOptions;
+
import net.minecraft.client.gui.layouts.LayoutElement;
-import org.vivecraft.client_vr.settings.VRSettings;
+
+import javax.annotation.Nonnull;
public interface GuiVROption extends LayoutElement {
- int getId();
- VRSettings.VrOptions getOption();
+ @Nonnull
+ VrOptions getOption();
}
diff --git a/common/src/main/java/org/vivecraft/client/gui/framework/GuiVROptionButton.java b/common/src/main/java/org/vivecraft/client/gui/framework/GuiVROptionButton.java
index 52c901d73..719c7362b 100644
--- a/common/src/main/java/org/vivecraft/client/gui/framework/GuiVROptionButton.java
+++ b/common/src/main/java/org/vivecraft/client/gui/framework/GuiVROptionButton.java
@@ -1,50 +1,55 @@
package org.vivecraft.client.gui.framework;
-import javax.annotation.Nullable;
-
-import org.vivecraft.client_vr.ClientDataHolderVR;
-import org.vivecraft.client_vr.settings.VRSettings;
+import org.vivecraft.client_vr.settings.VRSettings.VrOptions;
import net.minecraft.client.gui.components.Button;
+import net.minecraft.client.resources.language.I18n;
import net.minecraft.network.chat.Component;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+import static org.vivecraft.client_vr.VRState.dh;
+
public class GuiVROptionButton extends Button implements GuiVROption
{
- @Nullable
- private final VRSettings.VrOptions enumOptions;
- private int id = -1;
+ @Nonnull
+ private final VrOptions enumOptions;
- public GuiVROptionButton(int id, int x, int y, String text, OnPress action)
+ public GuiVROptionButton(int x, int y, String text, OnPress action)
{
- this(id, x, y, (VRSettings.VrOptions)null, text, action);
+ this(x, y, null, text, action);
}
- public GuiVROptionButton(int id, int x, int y, @Nullable VRSettings.VrOptions option, String text, OnPress action)
+ public GuiVROptionButton(int x, int y, @Nullable VrOptions option, String text, OnPress action)
{
- this(id, x, y, 150, 20, option, text, action);
+ this(x, y, 150, 20, option, text, action);
}
- public GuiVROptionButton(int id, int x, int y, int width, int height, @Nullable VRSettings.VrOptions option, String text, OnPress action)
+ public GuiVROptionButton(int x, int y, int width, int height, @Nullable VrOptions option, String text, OnPress action)
{
- super(x, y, width, height, Component.translatable(text), action, Button.DEFAULT_NARRATION);
- this.id = id;
- this.enumOptions = option;
- ClientDataHolderVR dataholder = ClientDataHolderVR.getInstance();
-
- if (option != null && dataholder.vrSettings.overrides.hasSetting(option) && dataholder.vrSettings.overrides.getSetting(option).isValueOverridden())
+ super(
+ x,
+ y,
+ width,
+ height,
+ I18n.exists(text + ".button") ?
+ Component.translatable(text + ".button") :
+ Component.translatable(text),
+ action,
+ Button.DEFAULT_NARRATION
+ );
+ this.enumOptions = option == null ? VrOptions.DUMMY : option;
+
+ if (option != null && dh.vrSettings.overrides.hasSetting(option) &&
+ dh.vrSettings.overrides.getSetting(option).isValueOverridden()
+ )
{
this.active = false;
}
}
- @Override
- public int getId() {
- return id;
- }
-
- @Override
- @Nullable
- public VRSettings.VrOptions getOption()
+ public @Override @Nonnull VrOptions getOption()
{
return this.enumOptions;
}
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 dbb6ec986..3e51f608d 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
@@ -1,61 +1,62 @@
package org.vivecraft.client.gui.framework;
+import org.vivecraft.client_vr.settings.VRSettings.VrOptions;
+
import net.minecraft.client.InputType;
-import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.components.AbstractSliderButton;
-import org.vivecraft.client_vr.ClientDataHolderVR;
-import org.vivecraft.client_vr.settings.VRSettings;
-
import net.minecraft.network.chat.Component;
+import javax.annotation.Nonnull;
import javax.annotation.Nullable;
+import static org.vivecraft.client_vr.VRState.dh;
+import static org.vivecraft.client_vr.VRState.mc;
+
public class GuiVROptionSlider extends AbstractSliderButton implements GuiVROption
{
- @Nullable
- private final VRSettings.VrOptions enumOptions;
- private int id = -1;
+ @Nonnull
+ private final VrOptions enumOptions;
- public GuiVROptionSlider(int id, int x, int y, int width, int height, VRSettings.VrOptions option)
+ public GuiVROptionSlider(int x, int y, int width, int height, @Nonnull VrOptions option)
{
- super(x, y, width, height,
- Component.literal(ClientDataHolderVR.getInstance().vrSettings.getButtonDisplayString(option)),
- option.normalizeValue(ClientDataHolderVR.getInstance().vrSettings.getOptionFloatValue(option)));
+ super(
+ x,
+ y,
+ width,
+ height,
+ Component.literal(dh.vrSettings.getButtonDisplayString(option)),
+ option.normalizeValue(dh.vrSettings.getOptionFloatValue(option))
+ );
- this.id = id;
this.enumOptions = option;
}
- public GuiVROptionSlider(int id, int x, int y, VRSettings.VrOptions option)
+ public GuiVROptionSlider(int x, int y, @Nullable VrOptions option)
{
- this(id, x, y, 150, 20, option);
+ this(x, y, 150, 20, option == null ? VrOptions.DUMMY : option);
}
@Override
- protected void updateMessage() {
- this.setMessage(Component.literal(ClientDataHolderVR.getInstance().vrSettings.getButtonDisplayString(this.enumOptions)));
+ protected void updateMessage()
+ {
+ this.setMessage(Component.literal(dh.vrSettings.getButtonDisplayString(this.enumOptions)));
}
@Override
- protected void applyValue() {
- ClientDataHolderVR dataholder = ClientDataHolderVR.getInstance();
- double d0 = this.enumOptions.denormalizeValue((float)this.value);
- dataholder.vrSettings.setOptionFloatValue(this.enumOptions, (float)d0);
+ protected void applyValue()
+ {
+ double d0 = this.enumOptions.denormalizeValue((float) this.value);
+ dh.vrSettings.setOptionFloatValue(this.enumOptions, (float) d0);
// with that keyboard changes don't work, if there are fewer options than pixels
- InputType inputType = Minecraft.getInstance().getLastInputType();
- if (inputType == InputType.MOUSE) {
- this.value = this.enumOptions.normalizeValue((float)d0);
+ InputType inputType = mc.getLastInputType();
+ if (inputType == InputType.MOUSE)
+ {
+ this.value = this.enumOptions.normalizeValue((float) d0);
}
}
- @Override
- public int getId() {
- return id;
- }
-
- @Override
- @Nullable
- public VRSettings.VrOptions getOption() {
+ public @Override @Nonnull VrOptions getOption()
+ {
return this.enumOptions;
}
}
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 437e8b1ff..bf0522cee 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
@@ -1,8 +1,14 @@
package org.vivecraft.client.gui.framework;
+import org.vivecraft.client_vr.ScreenUtils;
+import org.vivecraft.client_vr.settings.VRSettings.VrOptions;
+
+import org.joml.RoundingMode;
+
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.AbstractWidget;
import net.minecraft.client.gui.components.Button;
+import net.minecraft.client.gui.components.Button.Builder;
import net.minecraft.client.gui.components.ObjectSelectionList;
import net.minecraft.client.gui.components.events.GuiEventListener;
import net.minecraft.client.gui.screens.Screen;
@@ -11,26 +17,30 @@
import net.minecraft.network.chat.FormattedText;
import net.minecraft.network.chat.Style;
import net.minecraft.world.phys.Vec2;
-import org.vivecraft.client_vr.ClientDataHolderVR;
-import org.vivecraft.client_vr.ScreenUtils;
-import org.vivecraft.client_vr.settings.VRSettings;
-import java.util.ArrayList;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import java.util.List;
+import java.util.function.BiFunction;
+
+import static org.vivecraft.client.gui.framework.VROptionPosition.*;
+import static org.vivecraft.client_vr.VRState.dh;
+import static org.vivecraft.client_vr.VRState.mc;
+
+import static org.joml.Math.*;
+import static org.lwjgl.glfw.GLFW.*;
public abstract class GuiVROptionsBase extends Screen
{
- protected ClientDataHolderVR dataholder = ClientDataHolderVR.getInstance();
public static final int DONE_BUTTON = 200;
public static final int DEFAULTS_BUTTON = 201;
protected final Screen lastScreen;
- protected final VRSettings settings;
//private VRTooltipManager tooltipManager = new VRTooltipManager(this, new TooltipProviderVROptions());
protected boolean reinit;
protected boolean drawDefaultButtons = true;
- protected ObjectSelectionList visibleList = null;
+ protected ObjectSelectionList visibleList;
private int nextButtonIndex = 0;
- public String vrTitle = "Title";
+ public static String vrTitle = "Title";
private Button btnDone;
private Button btnDefaults;
@@ -38,26 +48,25 @@ public GuiVROptionsBase(Screen lastScreen)
{
super(Component.literal(""));
this.lastScreen = lastScreen;
- this.settings = ClientDataHolderVR.getInstance().vrSettings;
}
protected void addDefaultButtons()
{
- this.addRenderableWidget(this.btnDone = new Button.Builder(Component.translatable("gui.back"), (p) ->
+ this.addRenderableWidget(this.btnDone = new Builder(Component.translatable("gui.back"), (p) ->
{
if (!this.onDoneClicked())
{
- this.dataholder.vrSettings.saveOptions();
- this.minecraft.setScreen(this.lastScreen);
+ dh.vrSettings.saveOptions();
+ mc.setScreen(this.lastScreen);
}
})
.pos(this.width / 2 + 5, this.height - 30)
.size(150, 20)
.build());
- this.addRenderableWidget(this.btnDefaults = new Button.Builder(Component.translatable("vivecraft.gui.loaddefaults"), (p) ->
+ this.addRenderableWidget(this.btnDefaults = new Builder(Component.translatable("vivecraft.gui.loaddefaults"), (p) ->
{
this.loadDefaults();
- this.dataholder.vrSettings.saveOptions();
+ dh.vrSettings.saveOptions();
this.reinit = true;
})
.pos(this.width / 2 - 155, this.height - 30)
@@ -65,157 +74,257 @@ protected void addDefaultButtons()
.build());
}
+ @Override
+ protected void clearWidgets(){
+ super.clearWidgets();
+ this.nextButtonIndex = 0;
+ }
+
protected boolean onDoneClicked()
{
return false;
}
- protected void init(VROptionLayout[] settings, boolean clear)
+ protected void init(
+ @Nullable Class extends Screen> subScreen,
+ @Nullable VrOptions option,
+ @Nullable BiFunction customHandler,
+ @Nonnull VROptionPosition pos,
+ float row,
+ @Nonnull String buttonText
+ )
{
- if (clear)
+ if (this.nextButtonIndex < this.children().size())
{
- this.clearWidgets();
+ this.nextButtonIndex = this.children().size();
}
- int i = 0;
-
- for (final VROptionLayout vroptionlayout : settings)
+ int x = switch (pos)
{
- if (vroptionlayout.getOption() != null && vroptionlayout.getOption().getEnumFloat())
+ case POS_LEFT ->
{
- this.addRenderableWidget(new GuiVROptionSlider(vroptionlayout.getOrdinal(), vroptionlayout.getX(this.width), vroptionlayout.getY(this.height), vroptionlayout.getOption())
- {
- public void onClick(double pMouseX, double p_93635_)
- {
- if (vroptionlayout.getCustomHandler() == null || !vroptionlayout.getCustomHandler().apply(this, new Vec2((float)pMouseX, (float)p_93635_)))
- {
- super.onClick(pMouseX, p_93635_);
- }
- }
- });
+ yield this.width / 2 - 155;
}
- else if (vroptionlayout.getOption() != null)
+ case POS_RIGHT ->
{
- this.addRenderableWidget(new GuiVROptionButton(vroptionlayout.getOrdinal(), vroptionlayout.getX(this.width), vroptionlayout.getY(this.height), vroptionlayout.getOption(), vroptionlayout.getButtonText(), (p) ->
- {
- if (vroptionlayout.getCustomHandler() == null || !vroptionlayout.getCustomHandler().apply((GuiVROptionButton)p, new Vec2(0.0F, 0.0F)))
- {
- this.settings.setOptionValue(((GuiVROptionButton)p).getOption());
- p.setMessage(Component.literal(vroptionlayout.getButtonText()));
- }
- }));
+ yield this.width / 2 - 155 + 160;
}
- else if (vroptionlayout.getScreen() != null)
+ default ->
{
- this.addRenderableWidget(new GuiVROptionButton(vroptionlayout.getOrdinal(), vroptionlayout.getX(this.width), vroptionlayout.getY(this.height), vroptionlayout.getButtonText(), (p) ->
- {
- try {
- if (vroptionlayout.getCustomHandler() != null && vroptionlayout.getCustomHandler().apply((GuiVROptionButton)p, new Vec2(0.0F, 0.0F)))
- {
- return;
- }
+ yield this.width / 2 - 155 + 80;
+ }
+ };
- this.settings.saveOptions();
- this.minecraft.setScreen(vroptionlayout.getScreen().getConstructor(Screen.class).newInstance(this));
- }
- catch (ReflectiveOperationException reflectiveoperationexception)
+ int y = roundUsing((float) (this.height / 6) + 21.0F * row - 10.0F, RoundingMode.CEILING);
+
+ if (option != null && option.getEnumFloat())
+ {
+ this.addRenderableWidget(new GuiVROptionSlider(x, y, option)
+ {
+ @Override public void onClick(double mouseX, double mouseY)
+ {
+ if (customHandler == null || !customHandler.apply(this, new Vec2((float)mouseX, (float)mouseY)))
{
- reflectiveoperationexception.printStackTrace();
+ super.onClick(mouseX, mouseY);
}
- }));
- }
- else if (vroptionlayout.getCustomHandler() != null)
+ }
+ });
+ }
+ else if (option != null)
+ {
+ this.addRenderableWidget(new GuiVROptionButton(x, y, option, dh.vrSettings.getButtonDisplayString(option), (p) ->
{
- this.addRenderableWidget(new GuiVROptionButton(vroptionlayout.getOrdinal(), vroptionlayout.getX(this.width), vroptionlayout.getY(this.height), vroptionlayout.getButtonText(), (p) ->
+ if (customHandler == null || !customHandler.apply((GuiVROptionButton)p, new Vec2(0.0F, 0.0F)))
{
- vroptionlayout.getCustomHandler().apply((GuiVROptionButton)p, new Vec2(0.0F, 0.0F));
- }));
- }
- else
+ dh.vrSettings.setOptionValue(((GuiVROptionButton)p).getOption());
+ p.setMessage(Component.literal(dh.vrSettings.getButtonDisplayString(option)));
+ }
+ }));
+ }
+ else if (subScreen != null)
+ {
+ this.addRenderableWidget(new GuiVROptionButton(x, y, buttonText, (p) ->
{
- this.addRenderableWidget(new GuiVROptionButton(vroptionlayout.getOrdinal(), vroptionlayout.getX(this.width), vroptionlayout.getY(this.height), vroptionlayout.getButtonText(), (p) ->
+ try {
+ if (customHandler != null && customHandler.apply((GuiVROptionButton)p, new Vec2(0.0F, 0.0F)))
+ {
+ return;
+ }
+
+ dh.vrSettings.saveOptions();
+ mc.setScreen(subScreen.getConstructor(Screen.class).newInstance(this));
+ }
+ catch (ReflectiveOperationException reflectiveoperationexception)
{
- }));
- }
+ reflectiveoperationexception.printStackTrace();
+ }
+ }));
+ }
+ else if (customHandler != null)
+ {
+ this.addRenderableWidget(new GuiVROptionButton(x, y, buttonText, (p) ->
+ {
+ customHandler.apply((GuiVROptionButton)p, new Vec2(0.0F, 0.0F));
+ }));
+ }
+ else
+ {
+ this.addRenderableWidget(new GuiVROptionButton(x, y, buttonText, (p) -> {}));
}
-
- ++i;
}
protected void loadDefaults()
{
for (GuiEventListener child : this.children()) {
- if (!(child instanceof GuiVROption))
- continue;
+ if (child instanceof GuiVROption optionButton) {
+ dh.vrSettings.loadDefault(optionButton.getOption());
+ }
+ }
+ }
- GuiVROption optionButton = (GuiVROption)child;
- this.settings.loadDefault(optionButton.getOption());
+ protected final void init(
+ @Nonnull BiFunction customHandler,
+ @Nonnull VROptionPosition pos,
+ float row,
+ @Nonnull String buttonText
+ )
+ {
+ this.init(null, null, customHandler, pos, row, buttonText);
+ }
+
+ @SafeVarargs
+ protected final void init(@Nonnull Class extends GuiVROptionsBase> ...subScreens)
+ {
+ for (Class extends GuiVROptionsBase> subScreen : subScreens)
+ {
+ this.init(subScreen);
}
}
- protected void init(VROptionEntry[] settings, boolean clear)
+ protected void init(@Nonnull Class extends GuiVROptionsBase> subScreen)
+ {
+ this.init(subScreen, null, null);
+ }
+
+ protected void init(@Nonnull Class extends GuiVROptionsBase> subScreen, @Nullable String buttonText)
+ {
+ this.init(subScreen, buttonText, null);
+ }
+
+ protected void init(@Nonnull Class extends GuiVROptionsBase> subScreen, @Nullable VROptionPosition pos)
+ {
+ this.init(subScreen, null, pos);
+ }
+
+ protected void init(@Nonnull Class extends GuiVROptionsBase> subScreen, @Nullable String buttonText, @Nullable VROptionPosition pos)
+ {
+ this.init(subScreen, buttonText, null, null, pos);
+ }
+
+ protected void init(@Nonnull final VrOptions ...options)
{
- if (clear)
+ for (final VrOptions setting : options)
{
- this.clearWidgets();
- this.nextButtonIndex = 0;
+ this.init(setting);
}
+ }
+
+ protected void init(@Nonnull final VrOptions option)
+ {
+ this.init(option, (VROptionPosition)null);
+ }
- ArrayList arraylist = new ArrayList<>();
+ protected void init(@Nonnull final VrOptions option, @Nullable final VROptionPosition pos)
+ {
+ this.init(option, null, pos);
+ }
+ protected void init(@Nonnull final VrOptions option, @Nullable final BiFunction customHandler)
+ {
+ this.init(option, customHandler, null);
+ }
+
+ protected void init(@Nonnull final VrOptions option, @Nullable final BiFunction customHandler, @Nullable final VROptionPosition pos)
+ {
+ this.init(null, option, customHandler, pos);
+ }
+
+ protected void init(@Nullable final String buttonText)
+ {
+ this.init(buttonText, null);
+ }
+
+ protected void init(@Nullable final String buttonText, @Nullable final BiFunction customHandler)
+ {
+ this.init(buttonText, customHandler, null);
+ }
+
+ protected void init(@Nullable final String buttonText, @Nullable final BiFunction customHandler, @Nullable final VROptionPosition pos)
+ {
+ this.init(buttonText, null, customHandler, pos);
+ }
+
+ protected void init(@Nullable final String buttonText, @Nullable final VrOptions option, @Nullable final BiFunction customHandler, @Nullable VROptionPosition pos)
+ {
+ this.init(null, buttonText, option, customHandler, pos);
+ }
+
+ protected void init(@Nullable Class extends GuiVROptionsBase> subScreen, @Nullable String buttonText, @Nullable final VrOptions option, @Nullable final BiFunction customHandler, @Nullable VROptionPosition pos)
+ {
if (this.nextButtonIndex < this.children().size())
{
this.nextButtonIndex = this.children().size();
}
- int i = this.nextButtonIndex;
-
- for (int j = 0; j < settings.length; ++j)
+ if (pos == null)
{
- VROptionLayout.Position vroptionlayout$position = settings[j].center ? VROptionLayout.Position.POS_CENTER : (i % 2 == 0 ? VROptionLayout.Position.POS_LEFT : VROptionLayout.Position.POS_RIGHT);
-
- if (settings[j].center && i % 2 != 0)
+ pos = (this.nextButtonIndex % 2) == 0 ? POS_LEFT : POS_RIGHT;
+ }
+ else
+ {
+ if (pos == POS_CENTER || (this.nextButtonIndex % 2) == (pos == POS_LEFT ? 1 : 0))
{
- ++i;
+ ++this.nextButtonIndex;
}
+ }
- if (settings[j].option != null)
+ if (buttonText == null || buttonText.isEmpty()){
+ try
{
- if (settings[j].option != VRSettings.VrOptions.DUMMY)
- {
- arraylist.add(new VROptionLayout(settings[j].option, settings[j].customHandler, vroptionlayout$position, (float)Math.floor((double)((float)i / 2.0F)), true, settings[j].title));
- }
- }
- else if (settings[j].customHandler != null)
+ buttonText = (String) subScreen.getDeclaredField("vrTitle").get(null);
+ } catch (Exception ignored)
{
- arraylist.add(new VROptionLayout(settings[j].customHandler, vroptionlayout$position, (float)Math.floor((double)((float)i / 2.0F)), true, settings[j].title));
+ buttonText = "";
}
+ }
- if (settings[j].center)
+ if (subScreen != null){
+ this.init(
+ subScreen,
+ option,
+ customHandler,
+ pos,
+ floor(this.nextButtonIndex / 2.0F),
+ buttonText
+ );
+ }
+ else if (option != null)
+ {
+ if (option != VrOptions.DUMMY)
{
- ++i;
+ this.init(subScreen, option, customHandler, pos, floor(this.nextButtonIndex / 2.0F), buttonText);
}
-
- ++i;
}
-
- this.nextButtonIndex = i;
- this.init(arraylist.toArray(new VROptionLayout[0]), false);
- }
-
- protected void init(VRSettings.VrOptions[] settings, boolean clear)
- {
- VROptionEntry[] avroptionentry = new VROptionEntry[settings.length];
-
- for (int i = 0; i < settings.length; ++i)
+ else if (customHandler != null)
{
- avroptionentry[i] = new VROptionEntry(settings[i]);
+ this.init(subScreen, option, customHandler, pos, floor(this.nextButtonIndex / 2.0F), buttonText);
}
- this.init(avroptionentry, clear);
+ ++this.nextButtonIndex;
}
- public void render(GuiGraphics guiGraphics, int pMouseX, int pMouseY, float pPartialTicks)
+ @Override
+ public void render(@Nonnull GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick)
{
if (this.reinit)
{
@@ -227,10 +336,14 @@ public void render(GuiGraphics guiGraphics, int pMouseX, int pMouseY, float pPar
if (this.visibleList != null)
{
- this.visibleList.render(guiGraphics, pMouseX, pMouseY, pPartialTicks);
+ this.visibleList.render(guiGraphics, mouseX, mouseY, partialTick);
}
- guiGraphics.drawCenteredString(this.font, Component.translatable(this.vrTitle), this.width / 2, 15, 16777215);
+ try {
+ guiGraphics.drawCenteredString(this.font, Component.translatable((String) this.getClass().getDeclaredField("vrTitle").get(null)), this.width / 2, 15, 16777215);
+ } catch (Exception ignored){
+ guiGraphics.drawCenteredString(this.font, Component.translatable(vrTitle), this.width / 2, 15, 16777215);
+ }
if (this.btnDefaults != null)
{
@@ -242,8 +355,8 @@ public void render(GuiGraphics guiGraphics, int pMouseX, int pMouseY, float pPar
this.btnDone.visible = this.drawDefaultButtons;
}
- super.render(guiGraphics, pMouseX, pMouseY, pPartialTicks);
- renderTooltip(guiGraphics, pMouseX, pMouseY);
+ super.render(guiGraphics, mouseX, mouseY, partialTick);
+ this.renderTooltip(guiGraphics, mouseX, mouseY);
}
protected void actionPerformed(AbstractWidget button)
@@ -254,101 +367,116 @@ protected void actionPerformedRightClick(AbstractWidget button)
{
}
- public boolean mouseClicked(double pMouseX, double p_94738_, int pMouseY)
+ @Override
+ public boolean mouseClicked(double mouseX, double mouseY, int button)
{
- boolean flag = super.mouseClicked(pMouseX, p_94738_, pMouseY);
- AbstractWidget abstractwidget = ScreenUtils.getSelectedButton((int)pMouseX, (int)p_94738_, ScreenUtils.getButtonList(this));
+ boolean flag = super.mouseClicked(mouseX, mouseY, button);
+ AbstractWidget abstractwidget = ScreenUtils.getSelectedButton((int)mouseX, (int)mouseY, ScreenUtils.getButtonList(this));
if (abstractwidget != null)
{
- if (pMouseY == 0)
+ if (button == GLFW_MOUSE_BUTTON_1)
{
this.actionPerformed(abstractwidget);
}
- else if (pMouseY == 1)
+ else if (button == GLFW_MOUSE_BUTTON_2)
{
this.actionPerformedRightClick(abstractwidget);
}
}
else if (this.visibleList != null)
{
- return this.visibleList.mouseClicked(pMouseX, p_94738_, pMouseY);
+ return this.visibleList.mouseClicked(mouseX, mouseY, button);
}
return flag;
}
- public boolean mouseReleased(double pMouseX, double p_94754_, int pMouseY)
+ @Override
+ public boolean mouseReleased(double mouseX, double mouseY, int button)
{
- return this.visibleList != null ? this.visibleList.mouseReleased(pMouseX, p_94754_, pMouseY) : super.mouseReleased(pMouseX, p_94754_, pMouseY);
+ return this.visibleList != null ? this.visibleList.mouseReleased(mouseX, mouseY, button) : super.mouseReleased(mouseX, mouseY, button);
}
- public boolean mouseDragged(double pMouseX, double p_94741_, int pMouseY, double p_94743_, double pButton)
+ @Override
+ public boolean mouseDragged(double mouseX, double mouseY, int button, double dragX, double dragY)
{
- return this.visibleList != null ? this.visibleList.mouseDragged(pMouseX, p_94741_, pMouseY, p_94743_, pButton) : super.mouseDragged(pMouseX, p_94741_, pMouseY, p_94743_, pButton);
+ return this.visibleList != null ? this.visibleList.mouseDragged(mouseX, mouseY, button, dragX, dragY) : super.mouseDragged(mouseX, mouseY, button, dragX, dragY);
}
- public boolean mouseScrolled(double pMouseX, double p_94735_, double pMouseY)
+ @Override
+ public boolean mouseScrolled(double mouseX, double mouseY, double delta)
{
if (this.visibleList != null)
{
- this.visibleList.mouseScrolled(pMouseX, p_94735_, pMouseY);
+ this.visibleList.mouseScrolled(mouseX, mouseY, delta);
}
- return super.mouseScrolled(pMouseX, p_94735_, pMouseY);
+ return super.mouseScrolled(mouseX, mouseY, delta);
}
- public boolean keyPressed(int pKeyCode, int pScanCode, int pModifiers)
+ @Override
+ public boolean keyPressed(int keyCode, int scanCode, int modifiers)
{
- if (pKeyCode == 256)
+ if (keyCode == GLFW_KEY_ESCAPE)
{
if (!this.onDoneClicked())
{
- this.dataholder.vrSettings.saveOptions();
- this.minecraft.setScreen(this.lastScreen);
+ dh.vrSettings.saveOptions();
+ mc.setScreen(this.lastScreen);
}
return true;
}
else
{
- return this.visibleList != null && this.visibleList.keyPressed(pKeyCode, pScanCode, pModifiers) ? true : super.keyPressed(pKeyCode, pScanCode, pModifiers);
+ return this.visibleList != null && this.visibleList.keyPressed(keyCode, scanCode, modifiers) || super.keyPressed(keyCode, scanCode, modifiers);
}
}
- public boolean charTyped(char pCodePoint, int pModifiers)
+ @Override
+ public boolean charTyped(char codePoint, int modifiers)
{
- return this.visibleList != null && this.visibleList.charTyped(pCodePoint, pModifiers) ? true : super.charTyped(pCodePoint, pModifiers);
+ return this.visibleList != null && this.visibleList.charTyped(codePoint, modifiers) || super.charTyped(codePoint, modifiers);
}
- private void renderTooltip(GuiGraphics guiGraphics, int pMouseX, int pMouseY) {
+ private void renderTooltip(GuiGraphics guiGraphics, int mouseX, int mouseY)
+ {
AbstractWidget hover = null;
// find active button
- for (GuiEventListener child: children()) {
- if (child instanceof AbstractWidget && child.isMouseOver(pMouseX, pMouseY)) {
- hover = (AbstractWidget) child;
+ for (GuiEventListener child: this.children())
+ {
+ if (child instanceof AbstractWidget renderable && renderable.isMouseOver(mouseX, mouseY))
+ {
+ hover = renderable;
}
}
- if (hover != null ) {
- if (hover instanceof GuiVROption guiHover) {
- if (guiHover.getOption() != null) {
- String tooltipString = "vivecraft.options." + guiHover.getOption().name() + ".tooltip";
- // check if it has a tooltip
- if (I18n.exists(tooltipString)) {
- String tooltip = I18n.get(tooltipString, (Object) null);
- // add format reset at line ends
- tooltip = tooltip.replace("\n", "§r\n");
-
- // make last line the roughly 308 wide
- List formattedText = font.getSplitter().splitLines(tooltip, 308, Style.EMPTY);
- tooltip += " ".repeat((308 - (formattedText.size() == 0 ? 0 : font.width(formattedText.get(formattedText.size() - 1)))) / font.width(" "));
-
- // if tooltip is not too low, draw below button, else above
- if (guiHover.getY() + guiHover.getHeight() + formattedText.size() * (font.lineHeight + 1) + 14 < this.height) {
- guiGraphics.renderTooltip(this.font, font.split(Component.literal(tooltip), 308), this.width / 2 - 166, guiHover.getY() + guiHover.getHeight() + 14);
- } else {
- guiGraphics.renderTooltip(this.font, font.split(Component.literal(tooltip), 308), this.width / 2 - 166, guiHover.getY() - formattedText.size() * (font.lineHeight + 1) + 9);
- }
+ if (hover != null)
+ {
+ if (hover instanceof GuiVROption guiHover)
+ {
+ VrOptions option = guiHover.getOption();
+ String tooltipString = "vivecraft.options." + guiHover.getOption().name() + ".tooltip";
+ // check if it has a tooltip
+ String tooltip = option.getTooltipString(tooltipString);
+ if (tooltip == null && I18n.exists(tooltipString))
+ {
+ tooltip = I18n.get(tooltipString, (Object) null);
+ }
+ if (tooltip != null)
+ {
+ // add format reset at line ends
+ tooltip = tooltip.replace("\n", "§r\n");
+
+ // make last line the roughly 308 wide
+ List formattedText = this.font.getSplitter().splitLines(tooltip, 308, Style.EMPTY);
+ tooltip += " ".repeat((308 - (formattedText.size() == 0 ? 0 : this.font.width(formattedText.get(formattedText.size() - 1)))) / this.font.width(" "));
+
+ // if tooltip is not too low, draw below button, else above
+ if (guiHover.getY() + guiHover.getHeight() + formattedText.size() * (font.lineHeight + 1) + 14 < this.height) {
+ guiGraphics.renderTooltip(this.font, this.font.split(Component.literal(tooltip), 308), this.width / 2 - 166, guiHover.getY() + guiHover.getHeight() + 14);
+ } else {
+ guiGraphics.renderTooltip(this.font, this.font.split(Component.literal(tooltip), 308), this.width / 2 - 166, guiHover.getY() - formattedText.size() * (this.font.lineHeight + 1) + 9);
}
}
}
diff --git a/common/src/main/java/org/vivecraft/client/gui/framework/TwoHandedScreen.java b/common/src/main/java/org/vivecraft/client/gui/framework/TwoHandedScreen.java
index 759ece6e1..b365d1c07 100644
--- a/common/src/main/java/org/vivecraft/client/gui/framework/TwoHandedScreen.java
+++ b/common/src/main/java/org/vivecraft/client/gui/framework/TwoHandedScreen.java
@@ -1,19 +1,22 @@
package org.vivecraft.client.gui.framework;
-import net.minecraft.client.gui.GuiGraphics;
-import org.vivecraft.client_vr.ClientDataHolderVR;
import org.vivecraft.client_vr.extensions.GuiExtension;
import org.vivecraft.client_vr.provider.ControllerType;
-import org.vivecraft.client_vr.provider.MCVR;
+import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.AbstractWidget;
import net.minecraft.client.gui.components.Button;
+import net.minecraft.client.gui.components.events.GuiEventListener;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;
+import static org.vivecraft.client_vr.VRState.dh;
+import static org.vivecraft.client_vr.VRState.mc;
+
+import static org.joml.Math.*;
+
public abstract class TwoHandedScreen extends Screen
{
- protected ClientDataHolderVR dataholder = ClientDataHolderVR.getInstance();
public float cursorX1;
public float cursorY1;
public float cursorX2;
@@ -27,11 +30,13 @@ protected TwoHandedScreen()
super(Component.literal(""));
}
+ @Override
public boolean mouseClicked(double pMouseX, double p_94738_, int pMouseY)
{
if (super.mouseClicked(pMouseX, p_94738_, pMouseY))
{
- double d0 = (double)Math.min(Math.max((int)this.cursorX2, 0), this.minecraft.getWindow().getScreenWidth()) * (double)this.minecraft.getWindow().getGuiScaledWidth() / (double)this.minecraft.getWindow().getScreenWidth();
+ double d0 = (double) min(max((int) this.cursorX2, 0), mc.getWindow().getScreenWidth()) *
+ (double) mc.getWindow().getGuiScaledWidth() / (double) mc.getWindow().getScreenWidth();
return true;
}
else
@@ -40,6 +45,7 @@ public boolean mouseClicked(double pMouseX, double p_94738_, int pMouseY)
}
}
+ @Override
public void render(GuiGraphics guiGraphics, int pMouseX, int pMouseY, float pPartialTicks)
{
if (this.reinit)
@@ -48,26 +54,32 @@ public void render(GuiGraphics guiGraphics, int pMouseX, int pMouseY, float pPar
this.reinit = false;
}
- double d0 = (double)(this.cursorX1 * (float)this.width / (float)this.minecraft.getWindow().getGuiScaledWidth()) * (double)this.minecraft.getWindow().getGuiScaledWidth() / (double)this.minecraft.getWindow().getScreenWidth();
- double d1 = (double)(this.cursorY1 * (float)this.height / (float)this.minecraft.getWindow().getGuiScaledHeight()) * (double)this.minecraft.getWindow().getGuiScaledWidth() / (double)this.minecraft.getWindow().getScreenWidth();
- double d2 = (double)(this.cursorX2 * (float)this.width / (float)this.minecraft.getWindow().getGuiScaledWidth()) * (double)this.minecraft.getWindow().getGuiScaledWidth() / (double)this.minecraft.getWindow().getScreenWidth();
- double d3 = (double)(this.cursorY2 * (float)this.height / (float)this.minecraft.getWindow().getGuiScaledHeight()) * (double)this.minecraft.getWindow().getGuiScaledWidth() / (double)this.minecraft.getWindow().getScreenWidth();
+ int i0 = ((int) this.cursorX1 * this.width / mc.getWindow().getGuiScaledWidth())
+ * mc.getWindow().getGuiScaledWidth() / mc.getWindow().getScreenWidth();
+ int i1 = ((int) this.cursorY1 * this.height / mc.getWindow().getGuiScaledHeight())
+ * mc.getWindow().getGuiScaledWidth() / mc.getWindow().getScreenWidth();
+ int i2 = ((int) this.cursorX2 * this.width / mc.getWindow().getGuiScaledWidth())
+ * mc.getWindow().getGuiScaledWidth() / mc.getWindow().getScreenWidth();
+ int i3 = ((int) this.cursorY2 * this.height / mc.getWindow().getGuiScaledHeight())
+ * mc.getWindow().getGuiScaledWidth() / mc.getWindow().getScreenWidth();
AbstractWidget abstractwidget = null;
AbstractWidget abstractwidget1 = null;
- for (int i = 0; i < this.children().size(); ++i)
+ for (GuiEventListener child : this.children())
{
- AbstractWidget abstractwidget2 = (AbstractWidget) this.children().get(i);
- boolean flag = d0 >= (double)abstractwidget2.getX() && d1 >= (double)abstractwidget2.getY() && d0 < (double)(abstractwidget2.getX() + abstractwidget2.getWidth()) && d1 < (double)(abstractwidget2.getY() + 20);
- boolean flag1 = d2 >= (double)abstractwidget2.getX() && d3 >= (double)abstractwidget2.getY() && d2 < (double)(abstractwidget2.getX() + abstractwidget2.getWidth()) && d3 < (double)(abstractwidget2.getY() + 20);
+ AbstractWidget abstractwidget2 = (AbstractWidget) child;
+ boolean flag = i0 >= abstractwidget2.getX() && i1 >= abstractwidget2.getY() &&
+ i0 < (abstractwidget2.getX() + abstractwidget2.getWidth()) && i1 < (abstractwidget2.getY() + 20);
+ boolean flag1 = i2 >= abstractwidget2.getX() && i3 >= abstractwidget2.getY() &&
+ i2 < (abstractwidget2.getX() + abstractwidget2.getWidth()) && i3 < (abstractwidget2.getY() + 20);
if (flag)
{
- abstractwidget2.render(guiGraphics, (int)d0, (int)d1, pPartialTicks);
+ abstractwidget2.render(guiGraphics, i0, i1, pPartialTicks);
}
else
{
- abstractwidget2.render(guiGraphics, (int)d2, (int)d3, pPartialTicks);
+ abstractwidget2.render(guiGraphics, i2, i3, pPartialTicks);
}
if (flag)
@@ -87,7 +99,7 @@ public void render(GuiGraphics guiGraphics, int pMouseX, int pMouseY, float pPar
}
else if (abstractwidget instanceof Button && this.lastHoveredButtonId1 != abstractwidget)
{
- MCVR.get().triggerHapticPulse(ControllerType.LEFT, 300);
+ dh.vr.triggerHapticPulse(ControllerType.LEFT, 300);
this.lastHoveredButtonId1 = abstractwidget;
}
@@ -97,11 +109,11 @@ else if (abstractwidget instanceof Button && this.lastHoveredButtonId1 != abstra
}
else if (abstractwidget1 instanceof Button && this.lastHoveredButtonId2 != abstractwidget1)
{
- MCVR.get().triggerHapticPulse(ControllerType.RIGHT, 300);
+ dh.vr.triggerHapticPulse(ControllerType.RIGHT, 300);
this.lastHoveredButtonId2 = abstractwidget1;
}
- ((GuiExtension) this.minecraft.gui).drawMouseMenuQuad((int)d0, (int)d1);
- ((GuiExtension) this.minecraft.gui).drawMouseMenuQuad((int)d2, (int)d3);
+ ((GuiExtension) mc.gui).drawMouseMenuQuad(i0, i1);
+ ((GuiExtension) mc.gui).drawMouseMenuQuad(i2, i3);
}
}
diff --git a/common/src/main/java/org/vivecraft/client/gui/framework/VROptionEntry.java b/common/src/main/java/org/vivecraft/client/gui/framework/VROptionEntry.java
deleted file mode 100644
index 32257b26f..000000000
--- a/common/src/main/java/org/vivecraft/client/gui/framework/VROptionEntry.java
+++ /dev/null
@@ -1,61 +0,0 @@
-package org.vivecraft.client.gui.framework;
-
-import java.util.function.BiFunction;
-import net.minecraft.world.phys.Vec2;
-import org.vivecraft.client_vr.settings.VRSettings;
-
-public class VROptionEntry
-{
- public final VRSettings.VrOptions option;
- public final String title;
- public final BiFunction customHandler;
- public final boolean center;
-
- public VROptionEntry(String label, BiFunction customHandler, boolean center)
- {
- this.option = null;
- this.title = label;
- this.customHandler = customHandler;
- this.center = center;
- }
-
- public VROptionEntry(String label, BiFunction customHandler)
- {
- this.option = null;
- this.title = label;
- this.customHandler = customHandler;
- this.center = false;
- }
-
- public VROptionEntry(VRSettings.VrOptions option, BiFunction customHandler, boolean center)
- {
- this.option = option;
- this.title = null;
- this.customHandler = customHandler;
- this.center = center;
- }
-
- public VROptionEntry(VRSettings.VrOptions option, BiFunction customHandler)
- {
- this.option = option;
- this.title = null;
- this.customHandler = customHandler;
- this.center = false;
- }
-
- public VROptionEntry(VRSettings.VrOptions option, boolean center)
- {
- this.option = option;
- this.title = null;
- this.customHandler = null;
- this.center = center;
- }
-
- public VROptionEntry(VRSettings.VrOptions option)
- {
- this.option = option;
- this.title = null;
- this.customHandler = null;
- this.center = false;
- }
-}
diff --git a/common/src/main/java/org/vivecraft/client/gui/framework/VROptionLayout.java b/common/src/main/java/org/vivecraft/client/gui/framework/VROptionLayout.java
deleted file mode 100644
index b643c36d3..000000000
--- a/common/src/main/java/org/vivecraft/client/gui/framework/VROptionLayout.java
+++ /dev/null
@@ -1,162 +0,0 @@
-package org.vivecraft.client.gui.framework;
-
-import java.util.function.BiFunction;
-
-import org.vivecraft.client_vr.ClientDataHolderVR;
-import org.vivecraft.client_vr.settings.VRSettings;
-
-import net.minecraft.client.gui.screens.Screen;
-import net.minecraft.world.phys.Vec2;
-
-public class VROptionLayout
-{
- public static final boolean ENABLED = true;
- public static final boolean DISABLED = false;
- private VRSettings.VrOptions _e;
- Position _pos;
- float _row;
- public boolean _enabled;
- String _title = "";
- int _ordinal;
- boolean _defaultb;
- float _defaultf;
- float _maxf;
- float _minf;
- float _incrementf;
- int _defaulti;
- int _maxi;
- int _mini;
- int _incrementi;
- Class extends Screen > screen;
- BiFunction customHandler;
-
- public VROptionLayout(VRSettings.VrOptions e, BiFunction handler, Position pos, float row, boolean enabled, String title)
- {
- this._e = e;
- this._pos = pos;
- this._row = row;
-
- if (title != null)
- {
- this._title = title;
- }
-
- this._enabled = enabled;
- this.customHandler = handler;
- }
-
- public VROptionLayout(VRSettings.VrOptions e, Position pos, float row, boolean enabled, String title)
- {
- this._e = e;
- this._pos = pos;
- this._row = row;
-
- if (title != null)
- {
- this._title = title;
- }
-
- this._enabled = enabled;
- }
-
- public VROptionLayout(Class extends Screen > screen, BiFunction handler, Position pos, float row, boolean enabled, String title)
- {
- this._pos = pos;
- this._row = row;
-
- if (title != null)
- {
- this._title = title;
- }
-
- this._enabled = enabled;
- this.screen = screen;
- this.customHandler = handler;
- }
-
- public VROptionLayout(Class extends Screen > screen, Position pos, float row, boolean enabled, String title)
- {
- this._pos = pos;
- this._row = row;
-
- if (title != null)
- {
- this._title = title;
- }
-
- this._enabled = enabled;
- this.screen = screen;
- }
-
- public VROptionLayout(BiFunction handler, Position pos, float row, boolean enabled, String title)
- {
- this._pos = pos;
- this._row = row;
-
- if (title != null)
- {
- this._title = title;
- }
-
- this._enabled = enabled;
- this.customHandler = handler;
- }
-
- public VROptionLayout(int ordinal, Position pos, float row, boolean enabled, String title)
- {
- this._ordinal = ordinal;
- this._pos = pos;
- this._row = row;
- this._title = title;
- this._enabled = enabled;
- }
-
- public int getX(int screenWidth)
- {
- if (this._pos == Position.POS_LEFT)
- {
- return screenWidth / 2 - 155 + 0;
- }
- else
- {
- return this._pos == Position.POS_RIGHT ? screenWidth / 2 - 155 + 160 : screenWidth / 2 - 155 + 80;
- }
- }
-
- public int getY(int screenHeight)
- {
- return (int)Math.ceil((double)((float)(screenHeight / 6) + 21.0F * this._row - 10.0F));
- }
-
- public String getButtonText()
- {
- return this._title.isEmpty() && this._e != null ? ClientDataHolderVR.getInstance().vrSettings.getButtonDisplayString(this._e) : this._title;
- }
-
- public VRSettings.VrOptions getOption()
- {
- return this._e;
- }
-
- public Class extends Screen > getScreen()
- {
- return this.screen;
- }
-
- public BiFunction getCustomHandler()
- {
- return this.customHandler;
- }
-
- public int getOrdinal()
- {
- return this._e == null ? this._ordinal : this._e.returnEnumOrdinal();
- }
-
- public static enum Position
- {
- POS_LEFT,
- POS_CENTER,
- POS_RIGHT;
- }
-}
diff --git a/common/src/main/java/org/vivecraft/client/gui/framework/VROptionPosition.java b/common/src/main/java/org/vivecraft/client/gui/framework/VROptionPosition.java
new file mode 100644
index 000000000..a5e756846
--- /dev/null
+++ b/common/src/main/java/org/vivecraft/client/gui/framework/VROptionPosition.java
@@ -0,0 +1,8 @@
+package org.vivecraft.client.gui.framework;
+
+public enum VROptionPosition
+{
+ POS_LEFT,
+ POS_CENTER,
+ POS_RIGHT
+}
diff --git a/common/src/main/java/org/vivecraft/client/gui/screens/ErrorScreen.java b/common/src/main/java/org/vivecraft/client/gui/screens/ErrorScreen.java
index 958347782..6ae0577f8 100644
--- a/common/src/main/java/org/vivecraft/client/gui/screens/ErrorScreen.java
+++ b/common/src/main/java/org/vivecraft/client/gui/screens/ErrorScreen.java
@@ -1,43 +1,49 @@
package org.vivecraft.client.gui.screens;
-import net.minecraft.client.Minecraft;
+import org.vivecraft.client.gui.widgets.TextScrollWidget;
+
import net.minecraft.client.gui.GuiGraphics;
-import net.minecraft.client.gui.components.Button;
+import net.minecraft.client.gui.components.Button.Builder;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;
-import org.jetbrains.annotations.NotNull;
-import org.vivecraft.client.gui.widgets.TextScrollWidget;
+import javax.annotation.Nonnull;
-public class ErrorScreen extends Screen {
+import static org.vivecraft.client_vr.VRState.mc;
+
+
+public class ErrorScreen extends Screen
+{
private final Screen lastScreen;
private final Component error;
- public ErrorScreen(String title, Component error) {
+ public ErrorScreen(String title, Component error)
+ {
super(Component.literal(title));
- lastScreen = Minecraft.getInstance().screen;
+ lastScreen = mc.screen;
this.error = error;
}
- protected void init() {
+ @Override
+ protected void init()
+ {
this.addRenderableWidget(new TextScrollWidget(this.width / 2 - 155, 30, 310, this.height - 30 - 36, error));
- this.addRenderableWidget(new Button.Builder(Component.translatable("gui.back"), (p) ->
- Minecraft.getInstance().setScreen(this.lastScreen))
- .pos(this.width / 2 + 5, this.height - 32)
- .size(150, 20)
- .build());
- this.addRenderableWidget(new Button.Builder(Component.translatable("chat.copy"), (p) ->
- Minecraft.getInstance().keyboardHandler.setClipboard(error.getString()))
- .pos(this.width / 2 - 155, this.height - 32)
- .size(150, 20)
- .build());
+ this.addRenderableWidget(new Builder(Component.translatable("gui.back"), (p) ->
+ mc.setScreen(this.lastScreen)).pos(this.width / 2 + 5, this.height - 32).size(150, 20).build()
+ );
+ this.addRenderableWidget(new Builder(Component.translatable("chat.copy"), (p) ->
+ mc.keyboardHandler.setClipboard(error.getString())).pos(this.width / 2 - 155, this.height - 32)
+ .size(150, 20)
+ .build()
+ );
}
@Override
- public void render(@NotNull GuiGraphics guiGraphics, int i, int j, float f) {
+ public void render(@Nonnull GuiGraphics guiGraphics, int i, int j, float f)
+ {
this.renderBackground(guiGraphics);
guiGraphics.drawCenteredString(this.font, this.title, this.width / 2, 15, 16777215);
diff --git a/common/src/main/java/org/vivecraft/client/gui/screens/UpdateScreen.java b/common/src/main/java/org/vivecraft/client/gui/screens/UpdateScreen.java
index 4e6f536c3..b4e04fe82 100644
--- a/common/src/main/java/org/vivecraft/client/gui/screens/UpdateScreen.java
+++ b/common/src/main/java/org/vivecraft/client/gui/screens/UpdateScreen.java
@@ -1,33 +1,45 @@
package org.vivecraft.client.gui.screens;
+import org.vivecraft.client.gui.widgets.TextScrollWidget;
+import org.vivecraft.client.utils.UpdateChecker;
+
import net.minecraft.Util;
-import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
-import net.minecraft.client.gui.components.Button;
+import net.minecraft.client.gui.components.Button.Builder;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;
-import org.jetbrains.annotations.NotNull;
-import org.vivecraft.client.gui.widgets.TextScrollWidget;
-import org.vivecraft.client.utils.UpdateChecker;
+import javax.annotation.Nonnull;
import java.net.URI;
import java.net.URISyntaxException;
+import static org.vivecraft.client_vr.VRState.mc;
+
-public class UpdateScreen extends Screen {
+public class UpdateScreen extends Screen
+{
private final Screen lastScreen;
- public UpdateScreen() {
+ public UpdateScreen()
+ {
super(Component.literal("New Update Available"));
- lastScreen = Minecraft.getInstance().screen;
+ lastScreen = mc.screen;
}
- protected void init() {
+ @Override
+ protected void init()
+ {
- this.addRenderableWidget(new TextScrollWidget(this.width / 2 - 155, 30, 310, this.height - 30 - 60, UpdateChecker.changelog));
+ this.addRenderableWidget(new TextScrollWidget(
+ this.width / 2 - 155,
+ 30,
+ 310,
+ this.height - 30 - 60,
+ UpdateChecker.changelog
+ ));
- this.addRenderableWidget(new Button.Builder(Component.literal("Download from Modrinth"), (p) -> {
+ this.addRenderableWidget(new Builder(Component.literal("Download from Modrinth"), (p) -> {
try {
Util.getPlatform().openUri(new URI("https://modrinth.com/mod/vivecraft"));
} catch (URISyntaxException ignored) {
@@ -37,7 +49,7 @@ protected void init() {
.size(150, 20)
.build());
- this.addRenderableWidget(new Button.Builder(Component.literal("Download from Curseforge"), (p) -> {
+ this.addRenderableWidget(new Builder(Component.literal("Download from Curseforge"), (p) -> {
try {
Util.getPlatform().openUri(new URI("https://www.curseforge.com/minecraft/mc-mods/vivecraft"));
} catch (URISyntaxException ignored) {
@@ -47,22 +59,24 @@ protected void init() {
.size(150, 20)
.build());
- this.addRenderableWidget(new Button.Builder(Component.translatable("gui.back"), (p) ->
- Minecraft.getInstance().setScreen(this.lastScreen))
+ this.addRenderableWidget(new Builder(Component.translatable("gui.back"), (p) ->
+ mc.setScreen(this.lastScreen))
.pos(this.width / 2 - 75, this.height - 32)
.size(150, 20)
.build());
}
@Override
- public void render(@NotNull GuiGraphics guiGraphics, int i, int j, float f) {
+ public void render(@Nonnull GuiGraphics guiGraphics, int i, int j, float f)
+ {
this.renderBackground(guiGraphics);
guiGraphics.drawCenteredString(this.font, this.title, this.width / 2, 15, 16777215);
super.render(guiGraphics, i, j, f);
}
@Override
- public void onClose() {
- this.minecraft.setScreen(lastScreen);
+ public void onClose()
+ {
+ mc.setScreen(lastScreen);
}
}
diff --git a/common/src/main/java/org/vivecraft/client/gui/settings/GuiFreeMoveSettings.java b/common/src/main/java/org/vivecraft/client/gui/settings/GuiFreeMoveSettings.java
index 86458d09c..833edf94f 100644
--- a/common/src/main/java/org/vivecraft/client/gui/settings/GuiFreeMoveSettings.java
+++ b/common/src/main/java/org/vivecraft/client/gui/settings/GuiFreeMoveSettings.java
@@ -1,64 +1,67 @@
package org.vivecraft.client.gui.settings;
-import net.minecraft.client.gui.components.AbstractWidget;
-import net.minecraft.client.gui.screens.Screen;
import org.vivecraft.client.gui.framework.GuiVROption;
import org.vivecraft.client.gui.framework.GuiVROptionsBase;
-import org.vivecraft.client_vr.settings.VRSettings;
+import org.vivecraft.client_vr.settings.VRSettings.VrOptions;
+
+import net.minecraft.client.gui.components.AbstractWidget;
+import net.minecraft.client.gui.screens.Screen;
+
+import static org.vivecraft.client_vr.VRState.dh;
public class GuiFreeMoveSettings extends GuiVROptionsBase
{
- private static VRSettings.VrOptions[] standingSettings = new VRSettings.VrOptions[] {
- VRSettings.VrOptions.FREEMOVE_MODE,
- VRSettings.VrOptions.FREEMOVE_FLY_MODE,
- VRSettings.VrOptions.FOV_REDUCTION,
- VRSettings.VrOptions.INERTIA_FACTOR,
- VRSettings.VrOptions.MOVEMENT_MULTIPLIER,
- VRSettings.VrOptions.AUTO_SPRINT,
- VRSettings.VrOptions.AUTO_SPRINT_THRESHOLD,
- VRSettings.VrOptions.ANALOG_MOVEMENT
- };
- private static VRSettings.VrOptions[] seatedSettings = new VRSettings.VrOptions[] {
- VRSettings.VrOptions.SEATED_HMD,
- VRSettings.VrOptions.FOV_REDUCTION,
- VRSettings.VrOptions.INERTIA_FACTOR
- };
- private static VRSettings.VrOptions[] fovRed = new VRSettings.VrOptions[] {
- VRSettings.VrOptions.FOV_REDUCTION_MIN,
- VRSettings.VrOptions.FOV_REDUCTION_OFFSET
- };
+ public static String vrTitle = "vivecraft.options.screen.freemove";
public GuiFreeMoveSettings(Screen guiScreen)
{
super(guiScreen);
}
+ @Override
public void init()
{
- this.vrTitle = "vivecraft.options.screen.freemove";
+ super.clearWidgets();
- if (this.dataholder.vrSettings.seated)
+ if (dh.vrSettings.seated)
{
- super.init(seatedSettings, true);
+ super.init(
+ VrOptions.SEATED_HMD,
+ VrOptions.FOV_REDUCTION,
+ VrOptions.INERTIA_FACTOR
+ );
}
else
{
- super.init(standingSettings, true);
+ super.init(
+ VrOptions.FREEMOVE_MODE,
+ VrOptions.FREEMOVE_FLY_MODE,
+ VrOptions.FOV_REDUCTION,
+ VrOptions.INERTIA_FACTOR,
+ VrOptions.MOVEMENT_MULTIPLIER,
+ VrOptions.AUTO_SPRINT,
+ VrOptions.AUTO_SPRINT_THRESHOLD,
+ VrOptions.ANALOG_MOVEMENT
+ );
}
- if (this.dataholder.vrSettings.useFOVReduction)
+ if (dh.vrSettings.useFOVReduction)
{
- super.init(fovRed, false);
+ super.init(
+ VrOptions.FOV_REDUCTION_MIN,
+ VrOptions.FOV_REDUCTION_OFFSET
+ );
}
super.addDefaultButtons();
}
+ @Override
protected void actionPerformed(AbstractWidget widget)
{
if (widget instanceof GuiVROption guivroption)
{
- if (guivroption.getId() == VRSettings.VrOptions.FOV_REDUCTION.ordinal())
+ if (guivroption.getOption() == VrOptions.FOV_REDUCTION)
{
this.reinit = true;
}
diff --git a/common/src/main/java/org/vivecraft/client/gui/settings/GuiHUDSettings.java b/common/src/main/java/org/vivecraft/client/gui/settings/GuiHUDSettings.java
index 31fe0decb..b752598df 100644
--- a/common/src/main/java/org/vivecraft/client/gui/settings/GuiHUDSettings.java
+++ b/common/src/main/java/org/vivecraft/client/gui/settings/GuiHUDSettings.java
@@ -1,67 +1,79 @@
package org.vivecraft.client.gui.settings;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.components.AbstractWidget;
-import net.minecraft.client.gui.screens.Screen;
-import org.vivecraft.client.gui.framework.VROptionEntry;
+import org.vivecraft.client.gui.framework.GuiVROption;
import org.vivecraft.client_vr.gameplay.screenhandlers.GuiHandler;
import org.vivecraft.client_vr.gameplay.screenhandlers.KeyboardHandler;
-import org.vivecraft.client.gui.framework.GuiVROption;
-import org.vivecraft.client.gui.framework.GuiVROptionsBase;
-import org.vivecraft.client_vr.settings.VRSettings;
+import org.vivecraft.client_vr.settings.VRSettings.VrOptions;
+
+import net.minecraft.client.gui.components.AbstractWidget;
+import net.minecraft.client.gui.screens.Screen;
+
+import static org.vivecraft.client_vr.VRState.dh;
+import static org.vivecraft.client_vr.VRState.mc;
-public class GuiHUDSettings extends GuiVROptionsBase
+public class GuiHUDSettings extends org.vivecraft.client.gui.framework.GuiVROptionsBase
{
- private VROptionEntry[] hudOptions = new VROptionEntry[] {
- new VROptionEntry(VRSettings.VrOptions.HUD_HIDE),
- new VROptionEntry(VRSettings.VrOptions.HUD_LOCK_TO),
- new VROptionEntry(VRSettings.VrOptions.HUD_SCALE),
- new VROptionEntry(VRSettings.VrOptions.HUD_DISTANCE),
- new VROptionEntry(VRSettings.VrOptions.HUD_OCCLUSION),
- new VROptionEntry(VRSettings.VrOptions.HUD_OPACITY),
- new VROptionEntry(VRSettings.VrOptions.RENDER_MENU_BACKGROUND),
- new VROptionEntry(VRSettings.VrOptions.TOUCH_HOTBAR),
- new VROptionEntry(VRSettings.VrOptions.AUTO_OPEN_KEYBOARD),
- new VROptionEntry(VRSettings.VrOptions.MENU_ALWAYS_FOLLOW_FACE),
- new VROptionEntry(VRSettings.VrOptions.PHYSICAL_KEYBOARD, (button, mousePos) -> {
- KeyboardHandler.setOverlayShowing(false);
- return false;
- }),
- new VROptionEntry(VRSettings.VrOptions.GUI_APPEAR_OVER_BLOCK),
- new VROptionEntry(VRSettings.VrOptions.PHYSICAL_KEYBOARD_SCALE),
- new VROptionEntry("vivecraft.options.screen.menuworld.button", (button, mousePos) -> {
- Minecraft.getInstance().setScreen(new GuiMenuWorldSettings(this));
- return true;
- }),
- new VROptionEntry(VRSettings.VrOptions.PHYSICAL_KEYBOARD_THEME),
- new VROptionEntry(VRSettings.VrOptions.SHADER_GUI_RENDER)
- };
+ public static String vrTitle = "vivecraft.options.screen.gui";
public GuiHUDSettings(Screen guiScreen)
{
super(guiScreen);
}
+ @Override
public void init()
{
- this.vrTitle = "vivecraft.options.screen.gui";
- super.init(this.hudOptions, true);
+ super.clearWidgets();
+ super.init(
+ VrOptions.HUD_HIDE,
+ VrOptions.HUD_LOCK_TO,
+ VrOptions.HUD_SCALE,
+ VrOptions.HUD_DISTANCE,
+ VrOptions.HUD_OCCLUSION,
+ VrOptions.HUD_OPACITY,
+ VrOptions.RENDER_MENU_BACKGROUND);
+ super.init(GuiTouchHotbarSettings.class);
+ super.init(
+ VrOptions.DUMMY,
+ VrOptions.MENU_ALWAYS_FOLLOW_FACE,
+ VrOptions.PLAYER_STATUS,
+ VrOptions.GUI_APPEAR_OVER_BLOCK,
+ switch (dh.vrSettings.playerStatus){
+ case BOTH, ENTITY -> { yield true; }
+ default -> { yield false; }
+ } ? VrOptions.ENTITY_STATUS : VrOptions.DUMMY
+ );
+ super.init(GuiMenuWorldSettings.class);
+ super.init(
+ VrOptions.DUMMY,
+ VrOptions.SHADER_GUI_RENDER
+ );
super.addDefaultButtons();
}
+ @Override
protected void loadDefaults()
{
super.loadDefaults();
- this.minecraft.options.hideGui = false;
+ mc.options.hideGui = false;
}
- protected void actionPerformed(AbstractWidget widget) {
- if (widget instanceof GuiVROption button) {
- if (button.getId() == VRSettings.VrOptions.PHYSICAL_KEYBOARD_THEME.ordinal()) {
- KeyboardHandler.physicalKeyboard.init();
- }
- if (button.getId() == VRSettings.VrOptions.MENU_ALWAYS_FOLLOW_FACE.ordinal()) {
- GuiHandler.onScreenChanged(Minecraft.getInstance().screen, Minecraft.getInstance().screen, false);
+ @Override
+ protected void actionPerformed(AbstractWidget widget)
+ {
+ if (widget instanceof GuiVROption guivroption)
+ {
+ switch(guivroption.getOption()){
+ case PLAYER_STATUS -> { this.reinit = true; }
+ case PHYSICAL_KEYBOARD_THEME -> { KeyboardHandler.physicalKeyboard.init(); }
+ case MENU_ALWAYS_FOLLOW_FACE ->
+ {
+ GuiHandler.onScreenChanged(
+ mc.screen,
+ mc.screen,
+ false
+ );
+ }
}
}
}
diff --git a/common/src/main/java/org/vivecraft/client/gui/settings/GuiMainVRSettings.java b/common/src/main/java/org/vivecraft/client/gui/settings/GuiMainVRSettings.java
index 4dad5599f..3b77d3183 100644
--- a/common/src/main/java/org/vivecraft/client/gui/settings/GuiMainVRSettings.java
+++ b/common/src/main/java/org/vivecraft/client/gui/settings/GuiMainVRSettings.java
@@ -1,117 +1,134 @@
package org.vivecraft.client.gui.settings;
+import org.vivecraft.client.gui.framework.GuiVROption;
+import org.vivecraft.client_vr.settings.VRSettings.VrOptions;
+
+import net.minecraft.client.gui.components.AbstractWidget;
import net.minecraft.client.gui.screens.Screen;
-import org.vivecraft.client.gui.framework.GuiVROptionsBase;
-import org.vivecraft.client.gui.framework.VROptionLayout;
-import org.vivecraft.client_vr.VRState;
-import org.vivecraft.client_vr.provider.MCVR;
-import org.vivecraft.client_vr.settings.VRSettings;
-public class GuiMainVRSettings extends GuiVROptionsBase
-{
- private VROptionLayout[] vrAlwaysOptions = new VROptionLayout[] {
- new VROptionLayout(GuiHUDSettings.class, VROptionLayout.Position.POS_LEFT, 2.0F, true, "vivecraft.options.screen.gui.button"),
- new VROptionLayout(GuiRenderOpticsSettings.class, VROptionLayout.Position.POS_LEFT, 1.0F, true, "vivecraft.options.screen.stereorendering.button"),
- new VROptionLayout(GuiQuickCommandEditor.class, VROptionLayout.Position.POS_RIGHT, 1.0F, true, "vivecraft.options.screen.quickcommands.button"),
- new VROptionLayout(GuiOtherHUDSettings.class, VROptionLayout.Position.POS_RIGHT, 2.0F, true, "vivecraft.options.screen.guiother.button"),
- new VROptionLayout(VRSettings.VrOptions.WORLD_SCALE, VROptionLayout.Position.POS_LEFT, 6.0F, true, (String)null),
- new VROptionLayout(VRSettings.VrOptions.WORLD_ROTATION, VROptionLayout.Position.POS_RIGHT, 6.0F, true, (String)null),
- new VROptionLayout(VRSettings.VrOptions.PLAY_MODE_SEATED, (button, mousePos) -> {
- this.reinit = true;
+import static org.vivecraft.client.gui.framework.VROptionPosition.*;
+import static org.vivecraft.client_vr.VRState.*;
- if (!this.dataholder.vrSettings.seated)
- {
- this.isConfirm = true;
- return true;
- }
- else {
- return false;
- }
- }, VROptionLayout.Position.POS_LEFT, 0.0F, true, (String)null),
- new VROptionLayout(VRSettings.VrOptions.VR_HOTSWITCH, VROptionLayout.Position.POS_RIGHT, 0.0F, true, (String)null),
- new VROptionLayout(VRSettings.VrOptions.LOW_HEALTH_INDICATOR, VROptionLayout.Position.POS_RIGHT, 7.0F, true, (String)null)
- };
- private VROptionLayout[] vrStandingOptions = new VROptionLayout[] {
- new VROptionLayout(GuiStandingSettings.class, VROptionLayout.Position.POS_LEFT, 4.0F, true, "vivecraft.options.screen.standing.button"),
- new VROptionLayout(GuiRoomscaleSettings.class, VROptionLayout.Position.POS_RIGHT, 4.0F, true, "vivecraft.options.screen.roomscale.button"),
- new VROptionLayout(GuiVRControls.class, VROptionLayout.Position.POS_LEFT, 5.0F, true, "vivecraft.options.screen.controls.button"),
- new VROptionLayout(GuiRadialConfiguration.class, VROptionLayout.Position.POS_RIGHT, 5.0F, true, "vivecraft.options.screen.radialmenu.button")
- };
- private VROptionLayout[] vrSeatedOptions = new VROptionLayout[] {
- new VROptionLayout(GuiSeatedOptions.class, VROptionLayout.Position.POS_LEFT, 4.0F, true, "vivecraft.options.screen.seated.button"),
- new VROptionLayout(VRSettings.VrOptions.RESET_ORIGIN, (button, mousePos) -> {
- this.resetOrigin();
- return true;
- }, VROptionLayout.Position.POS_RIGHT, 4.0F, true, (String)null)
- };
- private VROptionLayout[] vrConfirm = new VROptionLayout[] {
- new VROptionLayout((button, mousePos) -> {
- this.reinit = true;
- this.isConfirm = false;
- return false;
- }, VROptionLayout.Position.POS_RIGHT, 2.0F, true, "gui.cancel"),
- new VROptionLayout((button, mousePos) -> {
- this.dataholder.vrSettings.seated = true;
- this.settings.saveOptions();
- this.reinit = true;
- this.isConfirm = false;
- return false;
- }, VROptionLayout.Position.POS_LEFT, 2.0F, true, "vivecraft.gui.ok")
- };
+public class GuiMainVRSettings extends org.vivecraft.client.gui.framework.GuiVROptionsBase
+{
private boolean isConfirm = false;
+ public static String vrTitle = "vivecraft.options.screen.main";
public GuiMainVRSettings(Screen lastScreen)
{
super(lastScreen);
}
+ @Override
protected void init()
{
+ super.clearWidgets();
if (!this.isConfirm)
{
- this.vrTitle = "vivecraft.options.screen.main";
+ vrTitle = "vivecraft.options.screen.main";
+ super.init(
+ VrOptions.PLAY_MODE_SEATED,
+ (button, mousePos) -> {
+ if (dh.vrSettings.seated)
+ {
+ return false;
+ }
+ else
+ {
+ return this.isConfirm = true;
+ }
+ }
+ );
+ super.init(VrOptions.VR_HOTSWITCH);
+ super.init(
+ GuiRenderOpticsSettings.class,
+ GuiQuickCommandEditor.class,
+ GuiHUDSettings.class,
+ GuiOtherHUDSettings.class
+ );
+
+ super.init(VrOptions.DUMMY, POS_CENTER);
- if (this.dataholder.vrSettings.seated)
+ if (dh.vrSettings.seated)
{
- super.init(this.vrSeatedOptions, true);
+ super.init(GuiSeatedOptions.class);
+ super.init(VrOptions.RESET_ORIGIN);
+ super.init(VrOptions.DUMMY, POS_CENTER);
}
else
{
- super.init(this.vrStandingOptions, true);
-
- if (this.dataholder.vrSettings.allowStandingOriginOffset)
- {
- super.init(new VROptionLayout[] {new VROptionLayout(VRSettings.VrOptions.RESET_ORIGIN, (button, mousePos) -> {
- this.resetOrigin();
- return true;
- }, VROptionLayout.Position.POS_LEFT, 7.0F, true, (String)null)
- }, false);
- }
+ super.init(
+ GuiStandingSettings.class,
+ GuiRoomscaleSettings.class,
+ GuiVRControls.class,
+ GuiRadialConfiguration.class
+ );
}
- super.init(this.vrAlwaysOptions, false);
+ super.init(
+ VrOptions.WORLD_SCALE,
+ VrOptions.WORLD_ROTATION,
+ !dh.vrSettings.seated && dh.vrSettings.allowStandingOriginOffset ? VrOptions.RESET_ORIGIN : VrOptions.DUMMY,
+ VrOptions.LOW_HEALTH_INDICATOR
+ );
super.addDefaultButtons();
}
else
{
- this.vrTitle = "vivecraft.messages.seatedmode";
- super.init(this.vrConfirm, true);
+ vrTitle = "vivecraft.messages.seatedmode";
+ super.init(
+ (button, mousePos) -> {
+ dh.vrSettings.seated = true;
+ dh.vrSettings.saveOptions();
+ this.reinit = true;
+ this.isConfirm = false;
+ return false;
+ },
+ POS_LEFT,
+ 2.0F,
+ "gui.ok"
+ );
+ super.init(
+ (button, mousePos) -> {
+ this.reinit = true;
+ this.isConfirm = false;
+ return false;
+ },
+ POS_RIGHT,
+ 2.0F,
+ "gui.cancel"
+ );
}
}
+ @Override
protected void loadDefaults()
{
super.loadDefaults();
- if (VRState.vrInitialized) {
- MCVR.get().seatedRot = 0.0F;
- MCVR.get().clearOffset();
+ if (vrInitialized) {
+ dh.vr.seatedRot = 0.0F;
+ dh.vr.clearOffset();
}
}
protected void resetOrigin()
{
- MCVR.get().resetPosition();
- this.settings.saveOptions();
- this.minecraft.setScreen((Screen)null);
+ if (dh.vr != null) {
+ dh.vr.resetPosition();
+ }
+ dh.vrSettings.saveOptions();
+ mc.setScreen(null);
+ }
+
+ @Override
+ protected void actionPerformed(AbstractWidget widget)
+ {
+ if (widget instanceof GuiVROption guivroption)
+ {
+ switch(guivroption.getOption()){
+ case PLAY_MODE_SEATED -> { this.reinit = true; }
+ case RESET_ORIGIN -> { this.resetOrigin(); }
+ }
+ }
}
}
diff --git a/common/src/main/java/org/vivecraft/client/gui/settings/GuiMenuWorldSettings.java b/common/src/main/java/org/vivecraft/client/gui/settings/GuiMenuWorldSettings.java
index 0abb1a373..7022a0831 100644
--- a/common/src/main/java/org/vivecraft/client/gui/settings/GuiMenuWorldSettings.java
+++ b/common/src/main/java/org/vivecraft/client/gui/settings/GuiMenuWorldSettings.java
@@ -1,57 +1,69 @@
package org.vivecraft.client.gui.settings;
-import org.vivecraft.client.gui.framework.VROptionEntry;
import org.vivecraft.client.gui.framework.GuiVROptionsBase;
-import org.vivecraft.client_vr.settings.VRSettings;
+import org.vivecraft.client_vr.settings.VRSettings.VrOptions;
import net.minecraft.client.gui.screens.Screen;
+import static org.vivecraft.client_vr.VRState.dh;
+
public class GuiMenuWorldSettings extends GuiVROptionsBase
{
- private VROptionEntry[] miscSettings = new VROptionEntry[] {
- new VROptionEntry(VRSettings.VrOptions.MENU_WORLD_SELECTION),
- new VROptionEntry("vivecraft.gui.menuworld.refresh", (button, mousePos) -> {
- if (this.dataholder.menuWorldRenderer != null && this.dataholder.menuWorldRenderer.getLevel() != null)
+ public static String vrTitle = "vivecraft.options.screen.menuworld";
+
+ public GuiMenuWorldSettings(Screen guiScreen)
+ {
+ super(guiScreen);
+ }
+
+ @Override
+ public void init()
+ {
+ super.clearWidgets();
+ super.init(VrOptions.MENU_WORLD_SELECTION);
+ super.init(
+ "vivecraft.gui.menuworld.refresh",
+ (button, mousePos) ->
+ {
+ if (dh.menuWorldRenderer != null && dh.menuWorldRenderer.getLevel() != null)
{
try
{
- this.dataholder.menuWorldRenderer.destroy();
- this.dataholder.menuWorldRenderer.prepare();
- }
- catch (Exception exception)
+ dh.menuWorldRenderer.destroy();
+ dh.menuWorldRenderer.prepare();
+ } catch (Exception exception)
{
exception.printStackTrace();
}
}
return true;
- }),
- new VROptionEntry(VRSettings.VrOptions.DUMMY), new VROptionEntry("vivecraft.gui.menuworld.loadnew", (button, mousePos) -> {
- if (this.dataholder.menuWorldRenderer != null) {
- try {
- if (this.dataholder.menuWorldRenderer.isReady()) {
- this.dataholder.menuWorldRenderer.destroy();
+ }
+ );
+ super.init(VrOptions.DUMMY);
+ super.init(
+ "vivecraft.gui.menuworld.loadnew",
+ (button, mousePos) ->
+ {
+ if (dh.menuWorldRenderer != null)
+ {
+ try
+ {
+ if (dh.menuWorldRenderer.isReady())
+ {
+ dh.menuWorldRenderer.destroy();
}
- this.dataholder.menuWorldRenderer.init();
- } catch (Exception exception) {
+ dh.menuWorldRenderer.init();
+ } catch (Exception exception)
+ {
exception.printStackTrace();
}
}
return true;
- })
- };
-
- public GuiMenuWorldSettings(Screen guiScreen)
- {
- super(guiScreen);
- }
-
- public void init()
- {
- this.vrTitle = "vivecraft.options.screen.menuworld";
- super.init(this.miscSettings, true);
+ }
+ );
super.addDefaultButtons();
}
}
diff --git a/common/src/main/java/org/vivecraft/client/gui/settings/GuiOtherHUDSettings.java b/common/src/main/java/org/vivecraft/client/gui/settings/GuiOtherHUDSettings.java
index a92919e77..d03fd5ce8 100644
--- a/common/src/main/java/org/vivecraft/client/gui/settings/GuiOtherHUDSettings.java
+++ b/common/src/main/java/org/vivecraft/client/gui/settings/GuiOtherHUDSettings.java
@@ -1,60 +1,71 @@
package org.vivecraft.client.gui.settings;
-import net.minecraft.client.gui.components.AbstractWidget;
-import net.minecraft.client.gui.screens.Screen;
-import org.vivecraft.client.gui.framework.GuiVROptionsBase;
import org.vivecraft.client.gui.framework.GuiVROption;
-import org.vivecraft.client_vr.settings.VRSettings;
+import org.vivecraft.client_vr.gameplay.screenhandlers.GuiHandler;
+import org.vivecraft.client_vr.gameplay.screenhandlers.KeyboardHandler;
+import org.vivecraft.client_vr.settings.VRSettings.ChatNotifications;
+import org.vivecraft.client_vr.settings.VRSettings.VrOptions;
-public class GuiOtherHUDSettings extends GuiVROptionsBase
-{
- static VRSettings.VrOptions[] hudOptions = new VRSettings.VrOptions[] {
- VRSettings.VrOptions.CROSSHAIR_SCALE,
- VRSettings.VrOptions.RENDER_CROSSHAIR_MODE,
- VRSettings.VrOptions.RENDER_BLOCK_OUTLINE_MODE,
- VRSettings.VrOptions.MENU_CROSSHAIR_SCALE,
- VRSettings.VrOptions.CROSSHAIR_OCCLUSION,
- VRSettings.VrOptions.CROSSHAIR_SCALES_WITH_DISTANCE,
- VRSettings.VrOptions.CHAT_NOTIFICATIONS
- };
- static VRSettings.VrOptions[] chat = new VRSettings.VrOptions[] {
- VRSettings.VrOptions.CHAT_NOTIFICATION_SOUND
- };
+import net.minecraft.client.gui.components.AbstractWidget;
+import net.minecraft.client.gui.screens.Screen;
- static VRSettings.VrOptions[] messages = new VRSettings.VrOptions[] {
- VRSettings.VrOptions.SHOW_UPDATES,
- VRSettings.VrOptions.SHOW_PLUGIN,
- VRSettings.VrOptions.SHOW_PLUGIN_MISSING
- };
+import static org.vivecraft.client_vr.VRState.dh;
+import static org.vivecraft.client_vr.VRState.mc;
+public class GuiOtherHUDSettings extends org.vivecraft.client.gui.framework.GuiVROptionsBase
+{
+ public static String vrTitle = "vivecraft.options.screen.guiother";
public GuiOtherHUDSettings(Screen guiScreen)
{
super(guiScreen);
}
+ @Override
public void init()
{
- this.vrTitle = "vivecraft.options.screen.guiother";
- super.init(hudOptions, true);
-
- if (this.dataholder.vrSettings.chatNotifications == VRSettings.ChatNotifications.SOUND || this.dataholder.vrSettings.chatNotifications == VRSettings.ChatNotifications.BOTH)
- {
- super.init(chat, false);
- } else {
- super.init(new VRSettings.VrOptions[]{VRSettings.VrOptions.DUMMY}, false);
- }
- super.init(messages, false);
+ super.clearWidgets();
+ super.init(
+ VrOptions.CROSSHAIR_SCALE,
+ VrOptions.RENDER_CROSSHAIR_MODE,
+ VrOptions.RENDER_BLOCK_OUTLINE_MODE,
+ VrOptions.MENU_CROSSHAIR_SCALE,
+ VrOptions.CROSSHAIR_OCCLUSION,
+ VrOptions.CROSSHAIR_SCALES_WITH_DISTANCE,
+ VrOptions.CHAT_NOTIFICATIONS,
+ dh.vrSettings.chatNotifications == ChatNotifications.SOUND || dh.vrSettings.chatNotifications == ChatNotifications.BOTH ? VrOptions.CHAT_NOTIFICATION_SOUND : VrOptions.DUMMY,
+ VrOptions.SHOW_UPDATES,
+ VrOptions.SHOW_PLUGIN,
+ VrOptions.SHOW_PLUGIN_MISSING,
+ VrOptions.AUTO_OPEN_KEYBOARD
+ );
+ super.init(VrOptions.PHYSICAL_KEYBOARD, (button, mousePos) -> {
+ KeyboardHandler.setOverlayShowing(false);
+ return false;
+ });
+ super.init(
+ VrOptions.PHYSICAL_KEYBOARD_SCALE,
+ VrOptions.PHYSICAL_KEYBOARD_THEME
+ );
super.addDefaultButtons();
}
+ @Override
protected void actionPerformed(AbstractWidget widget)
{
if (widget instanceof GuiVROption guivroption)
{
- if (guivroption.getId() == VRSettings.VrOptions.CHAT_NOTIFICATIONS.ordinal())
- {
- this.reinit = true;
+ switch(guivroption.getOption()){
+ case CHAT_NOTIFICATIONS -> { this.reinit = true; }
+ case PHYSICAL_KEYBOARD_THEME -> { KeyboardHandler.physicalKeyboard.init(); }
+ case MENU_ALWAYS_FOLLOW_FACE ->
+ {
+ GuiHandler.onScreenChanged(
+ mc.screen,
+ mc.screen,
+ false
+ );
+ }
}
}
}
diff --git a/common/src/main/java/org/vivecraft/client/gui/settings/GuiQuickCommandEditor.java b/common/src/main/java/org/vivecraft/client/gui/settings/GuiQuickCommandEditor.java
index 03ebd68a8..e8930ef18 100644
--- a/common/src/main/java/org/vivecraft/client/gui/settings/GuiQuickCommandEditor.java
+++ b/common/src/main/java/org/vivecraft/client/gui/settings/GuiQuickCommandEditor.java
@@ -1,10 +1,14 @@
package org.vivecraft.client.gui.settings;
-import net.minecraft.client.gui.screens.Screen;
import org.vivecraft.client.gui.framework.GuiVROptionsBase;
+import net.minecraft.client.gui.screens.Screen;
+
+import static org.vivecraft.client_vr.VRState.dh;
+
public class GuiQuickCommandEditor extends GuiVROptionsBase
{
+ public static String vrTitle = "vivecraft.options.screen.quickcommands";
private GuiQuickCommandsList guiList;
public GuiQuickCommandEditor(Screen par1Screen)
@@ -12,27 +16,29 @@ public GuiQuickCommandEditor(Screen par1Screen)
super(par1Screen);
}
+ @Override
public void init()
{
- this.vrTitle = "vivecraft.options.screen.quickcommands";
- this.guiList = new GuiQuickCommandsList(this, this.minecraft);
+ this.guiList = new GuiQuickCommandsList(this);
super.init();
super.addDefaultButtons();
this.visibleList = this.guiList;
}
+ @Override
protected void loadDefaults()
{
super.loadDefaults();
- this.dataholder.vrSettings.vrQuickCommands = this.dataholder.vrSettings.getQuickCommandsDefaults();
+ dh.vrSettings.vrQuickCommands = dh.vrSettings.getQuickCommandsDefaults();
}
+ @Override
protected boolean onDoneClicked()
{
for (int i = 0; i < 12; ++i)
{
String s = (this.guiList.children().get(i)).txt.getValue();
- this.dataholder.vrSettings.vrQuickCommands[i] = s;
+ dh.vrSettings.vrQuickCommands[i] = s;
}
return super.onDoneClicked();
diff --git a/common/src/main/java/org/vivecraft/client/gui/settings/GuiQuickCommandsInGame.java b/common/src/main/java/org/vivecraft/client/gui/settings/GuiQuickCommandsInGame.java
index a06e2d7dc..4025132cb 100644
--- a/common/src/main/java/org/vivecraft/client/gui/settings/GuiQuickCommandsInGame.java
+++ b/common/src/main/java/org/vivecraft/client/gui/settings/GuiQuickCommandsInGame.java
@@ -1,19 +1,16 @@
package org.vivecraft.client.gui.settings;
-import net.minecraft.client.gui.GuiGraphics;
-import org.vivecraft.client_vr.ClientDataHolderVR;
-
import net.minecraft.client.KeyMapping;
-import net.minecraft.client.gui.components.Button;
+import net.minecraft.client.gui.GuiGraphics;
+import net.minecraft.client.gui.components.Button.Builder;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;
+import static org.vivecraft.client_vr.VRState.dh;
+import static org.vivecraft.client_vr.VRState.mc;
+
public class GuiQuickCommandsInGame extends Screen
{
- protected ClientDataHolderVR dataholder = ClientDataHolderVR.getInstance();
- private int field_146445_a;
- private int field_146444_f;
- private static final String __OBFID = "CL_00000703";
protected final Screen parentScreen;
public GuiQuickCommandsInGame(Screen parent)
@@ -22,43 +19,41 @@ public GuiQuickCommandsInGame(Screen parent)
this.parentScreen = parent;
}
+ @Override
public void init()
{
KeyMapping.releaseAll();
- this.field_146445_a = 0;
this.clearWidgets();
- byte b0 = -16;
- boolean flag = true;
- String[] astring = this.dataholder.vrSettings.vrQuickCommands;
- int i = 0;
+ String[] astring = dh.vrSettings.vrQuickCommands;
+ int i;
for (int j = 0; j < astring.length; ++j)
{
i = j > 5 ? 1 : 0;
String s = astring[j];
- this.addRenderableWidget(new Button.Builder( Component.translatable(s.toString()), (p) ->
+ this.addRenderableWidget(new Builder(Component.translatable(s), (p) ->
{
- this.minecraft.setScreen((Screen)null);
+ mc.setScreen(null);
if (p.getMessage().getString().startsWith("/")) {
- this.minecraft.player.connection.sendCommand(p.getMessage().getString().substring(1));
+ mc.player.connection.sendCommand(p.getMessage().getString().substring(1));
} else {
- this.minecraft.player.connection.sendChat(p.getMessage().getString());
+ mc.player.connection.sendChat(p.getMessage().getString());
}
})
- .size( 125, 20)
- .pos(this.width / 2 - 125 + 127 * i, 36 + (j - 6 * i) * 24)
- .build());
+ .size(125, 20)
+ .pos(this.width / 2 - 125 + 127 * i, 36 + (j - 6 * i) * 24)
+ .build()
+ );
}
- this.addRenderableWidget(new Button.Builder( Component.translatable("Cancel"), (p) ->
- {
- this.minecraft.setScreen(this.parentScreen);
- })
- .size( 100, 20)
- .pos(this.width / 2 - 50, this.height - 30 + b0)
- .build());
+ this.addRenderableWidget(new Builder(Component.translatable("gui.cancel"), (p) -> mc.setScreen(this.parentScreen))
+ .size(100, 20)
+ .pos(this.width / 2 - 50, this.height - 46)
+ .build()
+ );
}
+ @Override
public void render(GuiGraphics guiGraphics, int pMouseX, int pMouseY, float pPartialTicks)
{
this.renderBackground(guiGraphics);
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 ea7e4e673..f5211e375 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
@@ -1,31 +1,27 @@
package org.vivecraft.client.gui.settings;
-import net.minecraft.client.gui.GuiGraphics;
-import net.minecraft.client.gui.components.*;
-import org.vivecraft.client_vr.ClientDataHolderVR;
+import org.vivecraft.client.gui.settings.GuiQuickCommandsList.CommandEntry;
-import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.GuiGraphics;
+import net.minecraft.client.gui.components.Button;
+import net.minecraft.client.gui.components.Button.Builder;
+import net.minecraft.client.gui.components.EditBox;
+import net.minecraft.client.gui.components.ObjectSelectionList;
import net.minecraft.network.chat.Component;
-public class GuiQuickCommandsList extends ObjectSelectionList
-{
- protected ClientDataHolderVR dataholder = ClientDataHolderVR.getInstance();
- private final GuiQuickCommandEditor parent;
- private final Minecraft mc;
+import static org.vivecraft.client_vr.VRState.dh;
+import static org.vivecraft.client_vr.VRState.mc;
- public GuiQuickCommandsList(GuiQuickCommandEditor parent, Minecraft mc)
+public class GuiQuickCommandsList extends ObjectSelectionList
+{
+ public GuiQuickCommandsList(GuiQuickCommandEditor parent)
{
super(mc, parent.width, parent.height, 32, parent.height - 32, 20);
- this.parent = parent;
- this.mc = mc;
- String[] astring = this.dataholder.vrSettings.vrQuickCommands;
- String s = null;
- int i = 0;
- for (String s1 : astring)
+ for (String command : dh.vrSettings.vrQuickCommands)
{
- this.minecraft.font.width(s1);
- this.addEntry(new CommandEntry(s1, this));
+ mc.font.width(command);
+ this.addEntry(new CommandEntry(command, this));
}
}
@@ -33,16 +29,16 @@ public GuiQuickCommandsList(GuiQuickCommandEditor parent, Minecraft mc)
protected void renderSelection(GuiGraphics guiGraphics, int i, int j, int k, int l, int m) {
}
- public class CommandEntry extends Entry
+ public static class CommandEntry extends Entry
{
private final Button btnDelete;
public final EditBox txt;
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 = new EditBox(mc.font, parent.width / 2 - 100, 60, 200, 20, Component.literal(""));
this.txt.setValue(command);
- this.btnDelete = new Button.Builder( Component.literal("X"), (p) ->
+ this.btnDelete = new Builder(Component.literal("X"), (p) ->
{
this.txt.setValue("");
this.txt.setFocused(true);
@@ -57,64 +53,60 @@ public void setFocused(boolean bl) {
txt.setFocused(bl);
}
+ @Override
public boolean mouseClicked(double pMouseX, double p_94738_, int pMouseY)
{
- if (this.btnDelete.mouseClicked(pMouseX, p_94738_, pMouseY))
- {
- return true;
- }
- else
- {
- return this.txt.mouseClicked(pMouseX, p_94738_, pMouseY) ? true : super.mouseClicked(pMouseX, p_94738_, pMouseY);
- }
+ return (this.btnDelete.mouseClicked(pMouseX, p_94738_, pMouseY) ||
+ this.txt.mouseClicked(pMouseX, p_94738_, pMouseY) ||
+ super.mouseClicked(pMouseX, p_94738_, pMouseY)
+ );
}
+ @Override
public boolean mouseDragged(double pMouseX, double p_94741_, int pMouseY, double p_94743_, double pButton)
{
- if (this.btnDelete.isMouseOver(pMouseX, p_94741_) && this.btnDelete.mouseDragged(pMouseX, p_94741_, pMouseY, p_94743_, pButton))
- {
- return true;
- }
- else
- {
- return (this.txt.isMouseOver(pMouseX, p_94741_) && this.txt.mouseDragged(pMouseX, p_94741_, pMouseY, p_94743_, pButton)) || super.mouseDragged(pMouseX, p_94741_, pMouseY, p_94743_, pButton);
- }
+ return (this.btnDelete.isMouseOver(pMouseX, p_94741_) && this.btnDelete.mouseDragged(pMouseX, p_94741_, pMouseY, p_94743_, pButton)) || (this.txt.isMouseOver(pMouseX, p_94741_) && this.txt.mouseDragged(pMouseX, p_94741_, pMouseY, p_94743_, pButton)) || super.mouseDragged(pMouseX, p_94741_, pMouseY, p_94743_, pButton);
}
+ @Override
public boolean mouseReleased(double pMouseX, double p_94754_, int pMouseY)
{
- if (this.btnDelete.mouseReleased(pMouseX, p_94754_, pMouseY))
- {
- return true;
- }
- else
- {
- return this.txt.mouseReleased(pMouseX, p_94754_, pMouseY) ? true : super.mouseReleased(pMouseX, p_94754_, pMouseY);
- }
+ return (
+ this.btnDelete.mouseReleased(pMouseX, p_94754_, pMouseY) ||
+ this.txt.mouseReleased(pMouseX, p_94754_, pMouseY) ||
+ super.mouseReleased(pMouseX, p_94754_, pMouseY)
+ );
}
+ @Override
public boolean mouseScrolled(double pMouseX, double p_94735_, double pMouseY)
{
- if (this.btnDelete.mouseScrolled(pMouseX, p_94735_, pMouseY))
- {
- return true;
- }
- else
- {
- return this.txt.mouseScrolled(pMouseX, p_94735_, pMouseY) ? true : super.mouseScrolled(pMouseX, p_94735_, pMouseY);
- }
+ return (
+ this.btnDelete.mouseScrolled(pMouseX, p_94735_, pMouseY) ||
+ this.txt.mouseScrolled(pMouseX, p_94735_, pMouseY) ||
+ super.mouseScrolled(pMouseX, p_94735_, pMouseY)
+ );
}
+ @Override
public boolean charTyped(char pCodePoint, int pModifiers)
{
- return this.txt.isFocused() ? this.txt.charTyped(pCodePoint, pModifiers) : super.charTyped(pCodePoint, pModifiers);
+ return (
+ this.txt.isFocused() ? this.txt.charTyped(pCodePoint, pModifiers) : super.charTyped(pCodePoint, pModifiers)
+ );
}
+ @Override
public boolean keyPressed(int pKeyCode, int pScanCode, int pModifiers)
{
- return this.txt.isFocused() ? this.txt.keyPressed(pKeyCode, pScanCode, pModifiers) : super.keyPressed(pKeyCode, pScanCode, pModifiers);
+ return (
+ this.txt.isFocused() ?
+ this.txt.keyPressed(pKeyCode, pScanCode, pModifiers) :
+ super.keyPressed(pKeyCode, pScanCode, pModifiers)
+ );
}
+ @Override
public void render(GuiGraphics guiGraphics, int pIndex, int pTop, int pLeft, int pWidth, int pHeight, int pMouseX, int pMouseY, boolean pIsMouseOver, float pPartialTicks)
{
this.txt.setX(pLeft);
diff --git a/common/src/main/java/org/vivecraft/client/gui/settings/GuiRadialConfiguration.java b/common/src/main/java/org/vivecraft/client/gui/settings/GuiRadialConfiguration.java
index 00760cf28..ef4ab85a8 100644
--- a/common/src/main/java/org/vivecraft/client/gui/settings/GuiRadialConfiguration.java
+++ b/common/src/main/java/org/vivecraft/client/gui/settings/GuiRadialConfiguration.java
@@ -1,22 +1,26 @@
package org.vivecraft.client.gui.settings;
-import net.minecraft.client.gui.GuiGraphics;
+import org.vivecraft.client_vr.settings.VRSettings.VrOptions;
+
import org.apache.commons.lang3.ArrayUtils;
-import org.vivecraft.client.gui.framework.GuiVROptionsBase;
-import org.vivecraft.client.gui.framework.VROptionLayout;
-import org.vivecraft.client_vr.settings.VRSettings;
import net.minecraft.client.KeyMapping;
-import net.minecraft.client.gui.components.Button;
+import net.minecraft.client.gui.GuiGraphics;
+import net.minecraft.client.gui.components.Button.Builder;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.resources.language.I18n;
import net.minecraft.network.chat.Component;
-public class GuiRadialConfiguration extends GuiVROptionsBase
+import javax.annotation.Nonnull;
+
+import static org.vivecraft.client_vr.VRState.dh;
+import static org.vivecraft.client_vr.VRState.mc;
+
+import static org.joml.Math.*;
+
+public class GuiRadialConfiguration extends org.vivecraft.client.gui.framework.GuiVROptionsBase
{
- static VROptionLayout[] options = new VROptionLayout[] {
- new VROptionLayout(VRSettings.VrOptions.RADIAL_MODE_HOLD, VROptionLayout.Position.POS_LEFT, 0.0F, true, "")
- };
+ public static String vrTitle = "vivecraft.options.screen.radialmenu";
private String[] arr;
private boolean isShift = false;
private int selectedIndex = -1;
@@ -46,75 +50,79 @@ public void setKey(KeyMapping key)
if (!this.isShift)
{
- this.dataholder.vrSettings.vrRadialItems = ArrayUtils.clone(this.arr);
+ dh.vrSettings.vrRadialItems = ArrayUtils.clone(this.arr);
}
else
{
- this.dataholder.vrSettings.vrRadialItemsAlt = ArrayUtils.clone(this.arr);
+ dh.vrSettings.vrRadialItemsAlt = ArrayUtils.clone(this.arr);
}
- this.dataholder.vrSettings.saveOptions();
+ dh.vrSettings.saveOptions();
}
+ @Override
public void init()
{
- this.vrTitle = "vivecraft.options.screen.radialmenu";
- this.list = new GuiRadialItemsList(this, this.minecraft);
+ this.list = new GuiRadialItemsList(this);
this.clearWidgets();
if (this.isselectmode)
{
- this.addRenderableWidget(new Button.Builder( Component.translatable("gui.cancel"), (p) ->
+ this.addRenderableWidget(new Builder(Component.translatable("gui.cancel"), (p) ->
{
this.isselectmode = false;
this.reinit = true;
this.visibleList = null;
})
- .size( 150, 20)
- .pos(this.width / 2 - 155, this.height - 25)
- .build());
- this.addRenderableWidget(new Button.Builder( Component.translatable("vivecraft.gui.clear"), (p) ->
+ .size(150, 20)
+ .pos(this.width / 2 - 155, this.height - 25)
+ .build()
+ );
+ this.addRenderableWidget(new Builder(Component.translatable("vivecraft.gui.clear"), (p) ->
{
- this.setKey((KeyMapping)null);
+ this.setKey(null);
})
- .size( 150, 20)
- .pos(this.width / 2 - 155, 25)
- .build());
+ .size(150, 20)
+ .pos(this.width / 2 - 155, 25)
+ .build()
+ );
}
else
{
+ super.init(VrOptions.RADIAL_MODE_HOLD);
if (this.isShift)
{
- this.addRenderableWidget(new Button.Builder( Component.translatable("vivecraft.gui.radialmenu.mainset"), (p) ->
+ this.addRenderableWidget(new Builder(Component.translatable("vivecraft.gui.radialmenu.mainset"), (p) ->
{
this.isShift = !this.isShift;
this.reinit = true;
})
- .size( 150, 20)
- .pos(this.width / 2 + 2, 30)
- .build());
+ .size(150, 20)
+ .pos(this.width / 2 + 2, 30)
+ .build()
+ );
}
else
{
- this.addRenderableWidget(new Button.Builder( Component.translatable("vivecraft.gui.radialmenu.alternateset"), (p) ->
+ this.addRenderableWidget(new Builder(Component.translatable("vivecraft.gui.radialmenu.alternateset"), (p) ->
{
this.isShift = !this.isShift;
this.reinit = true;
})
- .size( 150, 20)
- .pos(this.width / 2 + 2, 30)
- .build());
+ .size(150, 20)
+ .pos(this.width / 2 + 2, 30)
+ .build()
+ );
}
- super.init(options, false);
int i = 8;
int j = 120;
int k = 360 / i;
int l = 48;
int i1 = this.width / 2;
int j1 = this.height / 2;
- this.arr = ArrayUtils.clone(this.dataholder.vrSettings.vrRadialItems);
- String[] astring = ArrayUtils.clone(this.dataholder.vrSettings.vrRadialItemsAlt);
+ this.arr = ArrayUtils.clone(dh.vrSettings.vrRadialItems);
+ String[] astring = ArrayUtils.clone(dh.vrSettings.vrRadialItemsAlt);
if (this.isShift)
{
@@ -125,7 +133,7 @@ public void init()
{
KeyMapping keymapping = null;
- for (KeyMapping keymapping1 : this.minecraft.options.keyMappings)
+ for (KeyMapping keymapping1 : mc.options.keyMappings)
{
if (keymapping1.getName().equalsIgnoreCase(this.arr[k1]))
{
@@ -140,7 +148,7 @@ public void init()
s = I18n.get(keymapping.getName());
}
- int i2 = Math.max(j, this.font.width(s));
+ int i2 = max(j, this.font.width(s));
int j2 = 0;
int k2 = 0;
@@ -186,36 +194,38 @@ else if (k1 == 7)
}
int l1 = k1;
- this.addRenderableWidget(new Button.Builder( Component.translatable(s), (p) ->
+ this.addRenderableWidget(new Builder(Component.translatable(s), (p) ->
{
this.selectedIndex = l1;
this.isselectmode = true;
this.reinit = true;
this.visibleList = this.list;
})
- .size( i2, 20)
- .pos(i1 + j2 - i2 / 2, j1 + k2)
- .build());
- super.addDefaultButtons();
+ .size(i2, 20)
+ .pos(i1 + j2 - i2 / 2, j1 + k2)
+ .build()
+ );
}
+ super.addDefaultButtons();
}
}
+ @Override
protected void loadDefaults()
{
super.loadDefaults();
- this.settings.vrRadialItems = this.settings.getRadialItemsDefault();
- this.settings.vrRadialItemsAlt = this.settings.getRadialItemsAltDefault();
+ dh.vrSettings.vrRadialItems = dh.vrSettings.getRadialItemsDefault();
+ dh.vrSettings.vrRadialItemsAlt = dh.vrSettings.getRadialItemsAltDefault();
}
+ @Override
protected boolean onDoneClicked()
{
if (this.isselectmode)
{
this.isselectmode = false;
- this.reinit = true;
this.visibleList = null;
- return true;
+ return this.reinit = true;
}
else
{
@@ -223,18 +233,19 @@ protected boolean onDoneClicked()
}
}
- public void render(GuiGraphics guiGraphics, int pMouseX, int pMouseY, float pPartialTicks)
+ @Override
+ public void render(@Nonnull GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick)
{
- super.render(guiGraphics, pMouseX, pMouseY, pPartialTicks);
+ super.render(guiGraphics, mouseX, mouseY, partialTick);
if (this.visibleList == null)
{
- guiGraphics.drawCenteredString(this.minecraft.font, Component.translatable("vivecraft.messages.radialmenubind.1"), this.width / 2, this.height - 50, 5635925);
+ guiGraphics.drawCenteredString(mc.font, Component.translatable("vivecraft.messages.radialmenubind.1"), this.width / 2, this.height - 50, 5635925);
}
if (this.isShift)
{
- guiGraphics.drawCenteredString(this.minecraft.font, Component.translatable("vivecraft.messages.radialmenubind.2"), this.width / 2, this.height - 36, 13777015);
+ guiGraphics.drawCenteredString(mc.font, Component.translatable("vivecraft.messages.radialmenubind.2"), this.width / 2, this.height - 36, 13777015);
}
}
}
diff --git a/common/src/main/java/org/vivecraft/client/gui/settings/GuiRadialItemsList.java b/common/src/main/java/org/vivecraft/client/gui/settings/GuiRadialItemsList.java
index 33e32f915..f2a33e247 100644
--- a/common/src/main/java/org/vivecraft/client/gui/settings/GuiRadialItemsList.java
+++ b/common/src/main/java/org/vivecraft/client/gui/settings/GuiRadialItemsList.java
@@ -1,37 +1,33 @@
package org.vivecraft.client.gui.settings;
-import java.util.Arrays;
-
-import net.minecraft.client.gui.GuiGraphics;
import org.apache.commons.lang3.ArrayUtils;
import net.minecraft.ChatFormatting;
import net.minecraft.client.KeyMapping;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.components.ObjectSelectionList;
+import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.resources.language.I18n;
import net.minecraft.network.chat.Component;
-public class GuiRadialItemsList extends ObjectSelectionList
+import java.util.Arrays;
+
+import static org.vivecraft.client_vr.VRState.mc;
+
+public class GuiRadialItemsList extends net.minecraft.client.gui.components.ObjectSelectionList
{
private final GuiRadialConfiguration parent;
- private final Minecraft mc;
- private Entry[] listEntries;
- private int maxListLabelWidth = 0;
+ private final int maxListLabelWidth = 90;
- public GuiRadialItemsList(GuiRadialConfiguration parent, Minecraft mc)
+ public GuiRadialItemsList(GuiRadialConfiguration parent)
{
super(mc, parent.width, parent.height, 63, parent.height - 32, 20);
this.parent = parent;
- this.mc = mc;
- this.maxListLabelWidth = 90;
this.buildList();
}
public void buildList()
{
- KeyMapping[] akeymapping = ArrayUtils.clone(this.mc.options.keyMappings);
- Arrays.sort((Object[])akeymapping);
+ KeyMapping[] akeymapping = ArrayUtils.clone(mc.options.keyMappings);
+ Arrays.sort(akeymapping);
String s = null;
for (KeyMapping keymapping : akeymapping)
@@ -51,7 +47,7 @@ public void buildList()
}
}
- public class CategoryEntry extends Entry
+ public static class CategoryEntry extends Entry
{
private final String labelText;
private final int labelWidth;
@@ -59,9 +55,10 @@ public class CategoryEntry extends Entry
public CategoryEntry(String name)
{
this.labelText = I18n.get(name);
- this.labelWidth = GuiRadialItemsList.this.mc.font.width(this.labelText);
+ this.labelWidth = mc.font.width(this.labelText);
}
+ @Override
public void render(GuiGraphics guiGraphics, int pIndex, int pTop, int pLeft, int pWidth, int pHeight, int pMouseX, int pMouseY, boolean pIsMouseOver, float pPartialTicks)
{
guiGraphics.drawString(mc.font, this.labelText, (mc.screen.width / 2 - this.labelWidth / 2), (pTop + pHeight - 9 - 1), 6777215);
@@ -85,6 +82,7 @@ private MappingEntry(KeyMapping key, GuiRadialConfiguration parent)
this.parentScreen = parent;
}
+ @Override
public void render(GuiGraphics guiGraphics, int pIndex, int pTop, int pLeft, int pWidth, int pHeight, int pMouseX, int pMouseY, boolean pIsMouseOver, float pPartialTicks)
{
ChatFormatting chatformatting = ChatFormatting.WHITE;
@@ -97,6 +95,7 @@ public void render(GuiGraphics guiGraphics, int pIndex, int pTop, int pLeft, int
guiGraphics.drawString(mc.font, chatformatting + I18n.get(this.myKey.getName()), (mc.screen.width / 2 - GuiRadialItemsList.this.maxListLabelWidth / 2), (pTop + pHeight / 2 - 9 / 2), 16777215);
}
+ @Override
public boolean mouseClicked(double pMouseX, double p_94738_, int pMouseY)
{
this.parentScreen.setKey(this.myKey);
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 80ace6787..f974091de 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
@@ -1,182 +1,145 @@
package org.vivecraft.client.gui.settings;
-import net.minecraft.client.gui.GuiGraphics;
-import org.vivecraft.mod_compat_vr.ShadersHelper;
-import org.vivecraft.client_vr.VRState;
import org.vivecraft.client.gui.framework.GuiVROption;
-import org.vivecraft.client.gui.framework.GuiVROptionsBase;
import org.vivecraft.client_vr.settings.VRHotkeys;
-import org.vivecraft.client_vr.settings.VRSettings;
+import org.vivecraft.client_vr.settings.VRSettings.VrOptions;
+import org.vivecraft.mod_compat_vr.ShadersHelper;
+import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.AbstractWidget;
import net.minecraft.client.gui.screens.Screen;
-public class GuiRenderOpticsSettings extends GuiVROptionsBase
+import javax.annotation.Nonnull;
+
+import static org.vivecraft.client_vr.VRState.*;
+
+public class GuiRenderOpticsSettings extends org.vivecraft.client.gui.framework.GuiVROptionsBase
{
- static VRSettings.VrOptions[] monoDisplayOptions = new VRSettings.VrOptions[] {
- VRSettings.VrOptions.MONO_FOV,
- VRSettings.VrOptions.DUMMY,
- VRSettings.VrOptions.FSAA
- };
- static VRSettings.VrOptions[] openVRDisplayOptions = new VRSettings.VrOptions[] {
- VRSettings.VrOptions.RENDER_SCALEFACTOR,
- VRSettings.VrOptions.MIRROR_DISPLAY,
- VRSettings.VrOptions.FSAA,
- VRSettings.VrOptions.STENCIL_ON,
- VRSettings.VrOptions.HANDHELD_CAMERA_RENDER_SCALE,
- VRSettings.VrOptions.HANDHELD_CAMERA_FOV,
- VRSettings.VrOptions.RELOAD_EXTERNAL_CAMERA,
- VRSettings.VrOptions.MIRROR_EYE
- };
- static VRSettings.VrOptions[] MROptions = new VRSettings.VrOptions[] {
- VRSettings.VrOptions.MIXED_REALITY_UNITY_LIKE,
- VRSettings.VrOptions.MIXED_REALITY_RENDER_HANDS,
- VRSettings.VrOptions.MIXED_REALITY_KEY_COLOR,
- VRSettings.VrOptions.MIXED_REALITY_FOV,
- VRSettings.VrOptions.MIXED_REALITY_UNDISTORTED,
- VRSettings.VrOptions.MONO_FOV,
- VRSettings.VrOptions.MIXED_REALITY_ALPHA_MASK,
- VRSettings.VrOptions.MIXED_REALITY_RENDER_CAMERA_MODEL
- };
- static VRSettings.VrOptions[] UDOptions = new VRSettings.VrOptions[] {
- VRSettings.VrOptions.MONO_FOV
- };
- static VRSettings.VrOptions[] TUDOptions = new VRSettings.VrOptions[] {
- VRSettings.VrOptions.MIXED_REALITY_FOV,
- VRSettings.VrOptions.MIXED_REALITY_RENDER_CAMERA_MODEL
- };
- private float prevRenderScaleFactor = this.settings.renderScaleFactor;
- private float prevHandCameraResScale = this.settings.handCameraResScale;
+ public static String vrTitle = "vivecraft.options.screen.stereorendering";
+ private float prevRenderScaleFactor = dh.vrSettings.renderScaleFactor;
+ private float prevHandCameraResScale = dh.vrSettings.handCameraResScale;
public GuiRenderOpticsSettings(Screen par1Screen)
{
super(par1Screen);
}
+ @Override
public void init()
{
- this.vrTitle = "vivecraft.options.screen.stereorendering";
- VRSettings.VrOptions[] avrsettings$vroptions = new VRSettings.VrOptions[openVRDisplayOptions.length];
- System.arraycopy(openVRDisplayOptions, 0, avrsettings$vroptions, 0, openVRDisplayOptions.length);
-
- for (int i = 0; i < avrsettings$vroptions.length; ++i)
- {
- VRSettings.VrOptions vrsettings$vroptions = avrsettings$vroptions[i];
-
- if (vrsettings$vroptions == VRSettings.VrOptions.RELOAD_EXTERNAL_CAMERA && (!VRHotkeys.hasExternalCameraConfig() || this.dataholder.vrSettings.displayMirrorMode != VRSettings.MirrorMode.MIXED_REALITY && this.dataholder.vrSettings.displayMirrorMode != VRSettings.MirrorMode.THIRD_PERSON))
+ super.clearWidgets();
+ super.init(
+ VrOptions.RENDER_SCALEFACTOR,
+ VrOptions.MIRROR_DISPLAY,
+ VrOptions.FSAA,
+ VrOptions.STENCIL_ON,
+ VrOptions.HANDHELD_CAMERA_RENDER_SCALE,
+ VrOptions.HANDHELD_CAMERA_FOV,
+ switch(dh.vrSettings.displayMirrorMode){
+ case MIXED_REALITY, THIRD_PERSON -> { yield VRHotkeys.hasExternalCameraConfig(); }
+ default -> { yield false; }
+ } ? VrOptions.RELOAD_EXTERNAL_CAMERA : VrOptions.DUMMY,
+ switch(dh.vrSettings.displayMirrorMode){
+ case CROPPED, SINGLE -> { yield true; }
+ default -> { yield false; }
+ } ? VrOptions.MIRROR_EYE : VrOptions.DUMMY
+ );
+
+ switch(dh.vrSettings.displayMirrorMode){
+ case MIXED_REALITY ->
{
- avrsettings$vroptions[i] = VRSettings.VrOptions.DUMMY;
+ super.init(
+ VrOptions.MIXED_REALITY_UNITY_LIKE,
+ VrOptions.MIXED_REALITY_RENDER_HANDS,
+ dh.vrSettings.mixedRealityAlphaMask && dh.vrSettings.mixedRealityUnityLike ?
+ VrOptions.DUMMY : VrOptions.MIXED_REALITY_KEY_COLOR,
+ VrOptions.MIXED_REALITY_FOV,
+ !dh.vrSettings.mixedRealityUnityLike ? VrOptions.DUMMY : VrOptions.MIXED_REALITY_UNDISTORTED,
+ !dh.vrSettings.mixedRealityUndistorted || !dh.vrSettings.mixedRealityUnityLike ?
+ VrOptions.DUMMY : VrOptions.MONO_FOV,
+ !dh.vrSettings.mixedRealityUnityLike ? VrOptions.DUMMY : VrOptions.MIXED_REALITY_ALPHA_MASK,
+ VrOptions.MIXED_REALITY_RENDER_CAMERA_MODEL
+ );
}
-
- if (vrsettings$vroptions == VRSettings.VrOptions.MIRROR_EYE && this.dataholder.vrSettings.displayMirrorMode != VRSettings.MirrorMode.CROPPED && this.dataholder.vrSettings.displayMirrorMode != VRSettings.MirrorMode.SINGLE)
+ case FIRST_PERSON ->
{
- avrsettings$vroptions[i] = VRSettings.VrOptions.DUMMY;
+ super.init(VrOptions.MONO_FOV);
}
- }
-
- super.init(avrsettings$vroptions, true);
-
- if (this.dataholder.vrSettings.displayMirrorMode == VRSettings.MirrorMode.MIXED_REALITY)
- {
- avrsettings$vroptions = new VRSettings.VrOptions[MROptions.length];
- System.arraycopy(MROptions, 0, avrsettings$vroptions, 0, MROptions.length);
-
- for (int j = 0; j < avrsettings$vroptions.length; ++j)
+ case THIRD_PERSON ->
{
- VRSettings.VrOptions vrsettings$vroptions1 = avrsettings$vroptions[j];
-
- if (vrsettings$vroptions1 == VRSettings.VrOptions.MONO_FOV && (!this.dataholder.vrSettings.mixedRealityUndistorted || !this.dataholder.vrSettings.mixedRealityUnityLike))
- {
- avrsettings$vroptions[j] = VRSettings.VrOptions.DUMMY;
- }
-
- if (vrsettings$vroptions1 == VRSettings.VrOptions.MIXED_REALITY_ALPHA_MASK && !this.dataholder.vrSettings.mixedRealityUnityLike)
- {
- avrsettings$vroptions[j] = VRSettings.VrOptions.DUMMY;
- }
-
- if (vrsettings$vroptions1 == VRSettings.VrOptions.MIXED_REALITY_UNDISTORTED && !this.dataholder.vrSettings.mixedRealityUnityLike)
- {
- avrsettings$vroptions[j] = VRSettings.VrOptions.DUMMY;
- }
-
- if (vrsettings$vroptions1 == VRSettings.VrOptions.MIXED_REALITY_KEY_COLOR && this.dataholder.vrSettings.mixedRealityAlphaMask && this.dataholder.vrSettings.mixedRealityUnityLike)
- {
- avrsettings$vroptions[j] = VRSettings.VrOptions.DUMMY;
- }
+ super.init(
+ VrOptions.MIXED_REALITY_FOV,
+ VrOptions.MIXED_REALITY_RENDER_CAMERA_MODEL
+ );
}
-
- super.init(avrsettings$vroptions, false);
- }
- else if (this.dataholder.vrSettings.displayMirrorMode == VRSettings.MirrorMode.FIRST_PERSON)
- {
- super.init(UDOptions, false);
- }
- else if (this.dataholder.vrSettings.displayMirrorMode == VRSettings.MirrorMode.THIRD_PERSON)
- {
- super.init(TUDOptions, false);
}
super.addDefaultButtons();
- this.children().stream().filter((w) ->
- {
- return w instanceof GuiVROption;
- }).forEach((w) ->
- {
- GuiVROption guivroption = (GuiVROption)w;
+// this.children().stream().filter((w) -> w instanceof GuiVROption).forEach((w) ->
+// {
+// GuiVROption guivroption = (GuiVROption)w;
-// if (guivroption.getOption() == VRSettings.VrOptions.HANDHELD_CAMERA_RENDER_SCALE && Config.isShaders()) //Optifine
+// if (guivroption.getOption() == VrOptions.HANDHELD_CAMERA_RENDER_SCALE && Config.isShaders()) //Optifine
// {
// guivroption.active = false;
// }
- });
+// });
}
- public void render(GuiGraphics guiGraphics, int pMouseX, int pMouseY, float pPartialTicks)
+ @Override
+ public void render(@Nonnull GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick)
{
- super.render(guiGraphics, pMouseX, pMouseY, pPartialTicks);
+ super.render(guiGraphics, mouseX, mouseY, partialTick);
}
+ @Override
protected void loadDefaults()
{
super.loadDefaults();
- this.minecraft.options.fov().set(70);
- if (VRState.vrInitialized) {
- this.dataholder.vrRenderer.reinitFrameBuffers("Defaults Loaded");
+ mc.options.fov().set(70);
+ if (vrInitialized) {
+ dh.vrRenderer.reinitFrameBuffers("Defaults Loaded");
}
}
+ @Override
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");
+ VrOptions option = guivroption.getOption();
+ switch(option){
+ case MIRROR_DISPLAY, FSAA, STENCIL_ON ->
+ {
+ if (vrRunning)
+ {
+ if (option == VrOptions.STENCIL_ON || option == VrOptions.MIRROR_DISPLAY && ShadersHelper.isShaderActive())
+ {
+ dh.vrRenderer.resizeFrameBuffers("Render Setting Changed");
+ }
+ else
+ {
+ dh.vrRenderer.reinitFrameBuffers("Render Setting Changed");
+ }
+ }
}
- }
- if (guivroption.getId() == VRSettings.VrOptions.RELOAD_EXTERNAL_CAMERA.ordinal())
- {
- VRHotkeys.loadExternalCameraConfig();
+ case RELOAD_EXTERNAL_CAMERA -> { VRHotkeys.loadExternalCameraConfig(); }
}
}
}
- public boolean mouseReleased(double pMouseX, double p_94754_, int pMouseY)
+ @Override
+ public boolean mouseReleased(double mouseX, double mouseY, int button)
{
- if (this.settings.renderScaleFactor != this.prevRenderScaleFactor || this.settings.handCameraResScale != this.prevHandCameraResScale)
+ if (dh.vrSettings.renderScaleFactor != this.prevRenderScaleFactor || dh.vrSettings.handCameraResScale != this.prevHandCameraResScale)
{
- this.prevRenderScaleFactor = this.settings.renderScaleFactor;
- this.prevHandCameraResScale = this.settings.handCameraResScale;
- if (VRState.vrRunning) {
- this.dataholder.vrRenderer.resizeFrameBuffers("Render Setting Changed");
+ this.prevRenderScaleFactor = dh.vrSettings.renderScaleFactor;
+ this.prevHandCameraResScale = dh.vrSettings.handCameraResScale;
+ if (vrRunning) {
+ dh.vrRenderer.resizeFrameBuffers("Render Setting Changed");
}
}
- return super.mouseReleased(pMouseX, p_94754_, pMouseY);
+ return super.mouseReleased(mouseX, mouseY, button);
}
}
diff --git a/common/src/main/java/org/vivecraft/client/gui/settings/GuiRoomscaleSettings.java b/common/src/main/java/org/vivecraft/client/gui/settings/GuiRoomscaleSettings.java
index ad7ce4246..d90de11f6 100644
--- a/common/src/main/java/org/vivecraft/client/gui/settings/GuiRoomscaleSettings.java
+++ b/common/src/main/java/org/vivecraft/client/gui/settings/GuiRoomscaleSettings.java
@@ -1,32 +1,33 @@
package org.vivecraft.client.gui.settings;
-import net.minecraft.client.gui.screens.Screen;
import org.vivecraft.client.gui.framework.GuiVROptionsBase;
-import org.vivecraft.client_vr.settings.VRSettings;
+import org.vivecraft.client_vr.settings.VRSettings.VrOptions;
+
+import net.minecraft.client.gui.screens.Screen;
public class GuiRoomscaleSettings extends GuiVROptionsBase
{
- static VRSettings.VrOptions[] roomscaleSettings = new VRSettings.VrOptions[] {
- VRSettings.VrOptions.WEAPON_COLLISION,
- VRSettings.VrOptions.REALISTIC_JUMP,
- VRSettings.VrOptions.REALISTIC_SNEAK,
- VRSettings.VrOptions.REALISTIC_CLIMB,
- VRSettings.VrOptions.REALISTIC_ROW,
- VRSettings.VrOptions.REALISTIC_SWIM,
- VRSettings.VrOptions.BOW_MODE,
- VRSettings.VrOptions.BACKPACK_SWITCH,
- VRSettings.VrOptions.ALLOW_CRAWLING
- };
-
+ public static String vrTitle = "vivecraft.options.screen.roomscale";
public GuiRoomscaleSettings(Screen guiScreen)
{
super(guiScreen);
}
+ @Override
public void init()
{
- this.vrTitle = "vivecraft.options.screen.roomscale";
- super.init(roomscaleSettings, true);
+ super.clearWidgets();
+ super.init(
+ VrOptions.WEAPON_COLLISION,
+ VrOptions.REALISTIC_JUMP,
+ VrOptions.REALISTIC_SNEAK,
+ VrOptions.REALISTIC_CLIMB,
+ VrOptions.REALISTIC_ROW,
+ VrOptions.REALISTIC_SWIM,
+ VrOptions.BOW_MODE,
+ VrOptions.BACKPACK_SWITCH,
+ VrOptions.ALLOW_CRAWLING
+ );
super.addDefaultButtons();
}
}
diff --git a/common/src/main/java/org/vivecraft/client/gui/settings/GuiSeatedOptions.java b/common/src/main/java/org/vivecraft/client/gui/settings/GuiSeatedOptions.java
index d2544ac8a..b9616a9ba 100644
--- a/common/src/main/java/org/vivecraft/client/gui/settings/GuiSeatedOptions.java
+++ b/common/src/main/java/org/vivecraft/client/gui/settings/GuiSeatedOptions.java
@@ -1,42 +1,40 @@
package org.vivecraft.client.gui.settings;
-import net.minecraft.client.gui.screens.Screen;
-import org.vivecraft.client.gui.framework.VROptionEntry;
import org.vivecraft.client.gui.framework.GuiVROptionsBase;
-import org.vivecraft.client_vr.settings.VRSettings;
+import org.vivecraft.client_vr.settings.VRSettings.VrOptions;
+
+import net.minecraft.client.gui.screens.Screen;
+
+import static org.vivecraft.client.gui.framework.VROptionPosition.POS_CENTER;
public class GuiSeatedOptions extends GuiVROptionsBase
{
- private VROptionEntry[] seatedOptions = new VROptionEntry[] {
- new VROptionEntry(VRSettings.VrOptions.X_SENSITIVITY),
- new VROptionEntry(VRSettings.VrOptions.Y_SENSITIVITY),
- new VROptionEntry(VRSettings.VrOptions.KEYHOLE),
- new VROptionEntry(VRSettings.VrOptions.SEATED_HUD_XHAIR),
- new VROptionEntry(VRSettings.VrOptions.WALK_UP_BLOCKS),
- new VROptionEntry(VRSettings.VrOptions.WORLD_ROTATION_INCREMENT),
- new VROptionEntry(VRSettings.VrOptions.VEHICLE_ROTATION),
- new VROptionEntry(VRSettings.VrOptions.DUMMY),
- new VROptionEntry(VRSettings.VrOptions.SEATED_FREE_MOVE, true),
- new VROptionEntry(VRSettings.VrOptions.RIGHT_CLICK_DELAY, false),
- new VROptionEntry("vivecraft.options.screen.teleport.button", (button, mousePos) -> {
- this.minecraft.setScreen(new GuiTeleportSettings(this));
- return true;
- }),
- new VROptionEntry("vivecraft.options.screen.freemove.button", (button, mousePos) -> {
- this.minecraft.setScreen(new GuiFreeMoveSettings(this));
- return true;
- })
- };
-
+ public static String vrTitle = "vivecraft.options.screen.seated";
public GuiSeatedOptions(Screen guiScreen)
{
super(guiScreen);
}
+ @Override
public void init()
{
- this.vrTitle = "vivecraft.options.screen.seated";
- super.init(this.seatedOptions, true);
+ super.clearWidgets();
+ super.init(
+ VrOptions.X_SENSITIVITY,
+ VrOptions.Y_SENSITIVITY,
+ VrOptions.KEYHOLE,
+ VrOptions.SEATED_HUD_XHAIR,
+ VrOptions.WALK_UP_BLOCKS,
+ VrOptions.WORLD_ROTATION_INCREMENT,
+ VrOptions.VEHICLE_ROTATION,
+ VrOptions.DUMMY
+ );
+ super.init(VrOptions.SEATED_FREE_MOVE, POS_CENTER);
+ super.init(VrOptions.RIGHT_CLICK_DELAY);
+ super.init(
+ GuiTeleportSettings.class,
+ GuiFreeMoveSettings.class
+ );
super.addDefaultButtons();
}
}
diff --git a/common/src/main/java/org/vivecraft/client/gui/settings/GuiStandingSettings.java b/common/src/main/java/org/vivecraft/client/gui/settings/GuiStandingSettings.java
index 1d1691478..2d0c02bc0 100644
--- a/common/src/main/java/org/vivecraft/client/gui/settings/GuiStandingSettings.java
+++ b/common/src/main/java/org/vivecraft/client/gui/settings/GuiStandingSettings.java
@@ -1,40 +1,38 @@
package org.vivecraft.client.gui.settings;
-import net.minecraft.client.gui.screens.Screen;
import org.vivecraft.client.gui.framework.GuiVROptionsBase;
-import org.vivecraft.client.gui.framework.VROptionEntry;
-import org.vivecraft.client_vr.settings.VRSettings;
+import org.vivecraft.client_vr.settings.VRSettings.VrOptions;
+
+import net.minecraft.client.gui.screens.Screen;
+
+import static org.vivecraft.client.gui.framework.VROptionPosition.POS_CENTER;
public class GuiStandingSettings extends GuiVROptionsBase
{
- private VROptionEntry[] locomotionSettings = new VROptionEntry[] {
- new VROptionEntry(VRSettings.VrOptions.WALK_UP_BLOCKS),
- new VROptionEntry(VRSettings.VrOptions.VEHICLE_ROTATION),
- new VROptionEntry(VRSettings.VrOptions.WALK_MULTIPLIER),
- new VROptionEntry(VRSettings.VrOptions.WORLD_ROTATION_INCREMENT),
- new VROptionEntry(VRSettings.VrOptions.BCB_ON),
- new VROptionEntry(VRSettings.VrOptions.ALLOW_STANDING_ORIGIN_OFFSET),
- new VROptionEntry(VRSettings.VrOptions.FORCE_STANDING_FREE_MOVE, true),
- new VROptionEntry(VRSettings.VrOptions.DUMMY, true),
- new VROptionEntry("vivecraft.options.screen.teleport.button", (button, mousePos) -> {
- this.minecraft.setScreen(new GuiTeleportSettings(this));
- return true;
- }),
- new VROptionEntry("vivecraft.options.screen.freemove.button", (button, mousePos) -> {
- this.minecraft.setScreen(new GuiFreeMoveSettings(this));
- return true;
- })
- };
-
+ public static String vrTitle = "vivecraft.options.screen.standing";
public GuiStandingSettings(Screen guiScreen)
{
super(guiScreen);
}
+ @Override
public void init()
{
- this.vrTitle = "vivecraft.options.screen.standing";
- super.init(this.locomotionSettings, true);
+ super.clearWidgets();
+ super.init(
+ VrOptions.WALK_UP_BLOCKS,
+ VrOptions.VEHICLE_ROTATION,
+ VrOptions.WALK_MULTIPLIER,
+ VrOptions.WORLD_ROTATION_INCREMENT,
+ VrOptions.BCB_ON,
+ VrOptions.ALLOW_STANDING_ORIGIN_OFFSET
+ );
+ super.init(VrOptions.FORCE_STANDING_FREE_MOVE, POS_CENTER);
+ super.init(VrOptions.DUMMY, POS_CENTER);
+ super.init(
+ GuiTeleportSettings.class,
+ GuiFreeMoveSettings.class
+ );
super.addDefaultButtons();
}
}
diff --git a/common/src/main/java/org/vivecraft/client/gui/settings/GuiTeleportSettings.java b/common/src/main/java/org/vivecraft/client/gui/settings/GuiTeleportSettings.java
index d429926bc..1e253bd56 100644
--- a/common/src/main/java/org/vivecraft/client/gui/settings/GuiTeleportSettings.java
+++ b/common/src/main/java/org/vivecraft/client/gui/settings/GuiTeleportSettings.java
@@ -1,46 +1,48 @@
package org.vivecraft.client.gui.settings;
+import org.vivecraft.client.gui.framework.GuiVROption;
+import org.vivecraft.client_vr.settings.VRSettings.VrOptions;
+
import net.minecraft.client.gui.components.AbstractWidget;
import net.minecraft.client.gui.screens.Screen;
-import org.vivecraft.client.gui.framework.GuiVROption;
-import org.vivecraft.client.gui.framework.GuiVROptionsBase;
-import org.vivecraft.client_vr.settings.VRSettings;
-public class GuiTeleportSettings extends GuiVROptionsBase
-{
- private static VRSettings.VrOptions[] teleportSettings = new VRSettings.VrOptions[] {
- VRSettings.VrOptions.SIMULATE_FALLING,
- VRSettings.VrOptions.LIMIT_TELEPORT
- };
- private static VRSettings.VrOptions[] limitedTeleportSettings = new VRSettings.VrOptions[] {
- VRSettings.VrOptions.TELEPORT_UP_LIMIT,
- VRSettings.VrOptions.TELEPORT_DOWN_LIMIT,
- VRSettings.VrOptions.TELEPORT_HORIZ_LIMIT
- };
+import static org.vivecraft.client_vr.VRState.dh;
+public class GuiTeleportSettings extends org.vivecraft.client.gui.framework.GuiVROptionsBase
+{
+ public static String vrTitle = "vivecraft.options.screen.teleport";
public GuiTeleportSettings(Screen guiScreen)
{
super(guiScreen);
}
+ @Override
public void init()
{
- this.vrTitle = "vivecraft.options.screen.teleport";
- super.init(teleportSettings, true);
+ super.clearWidgets();
+ super.init(
+ VrOptions.SIMULATE_FALLING,
+ VrOptions.LIMIT_TELEPORT
+ );
- if (this.settings.vrLimitedSurvivalTeleport)
+ if (dh.vrSettings.vrLimitedSurvivalTeleport)
{
- super.init(limitedTeleportSettings, false);
+ super.init(
+ VrOptions.TELEPORT_UP_LIMIT,
+ VrOptions.TELEPORT_DOWN_LIMIT,
+ VrOptions.TELEPORT_HORIZ_LIMIT
+ );
}
super.addDefaultButtons();
}
+ @Override
protected void actionPerformed(AbstractWidget widget)
{
if (widget instanceof GuiVROption guivroption)
{
- if (guivroption.getId() == VRSettings.VrOptions.LIMIT_TELEPORT.ordinal())
+ if (guivroption.getOption() == VrOptions.LIMIT_TELEPORT)
{
this.reinit = true;
}
diff --git a/common/src/main/java/org/vivecraft/client/gui/settings/GuiTouchHotbarSettings.java b/common/src/main/java/org/vivecraft/client/gui/settings/GuiTouchHotbarSettings.java
new file mode 100644
index 000000000..8f6d22e31
--- /dev/null
+++ b/common/src/main/java/org/vivecraft/client/gui/settings/GuiTouchHotbarSettings.java
@@ -0,0 +1,56 @@
+package org.vivecraft.client.gui.settings;
+
+import org.vivecraft.client.gui.framework.GuiVROption;
+import org.vivecraft.client.gui.framework.GuiVROptionsBase;
+import org.vivecraft.client_vr.settings.VRSettings.VrOptions;
+
+import net.minecraft.client.gui.components.AbstractWidget;
+import net.minecraft.client.gui.screens.Screen;
+
+import static org.vivecraft.client.gui.framework.VROptionPosition.POS_CENTER;
+import static org.vivecraft.client_vr.VRState.dh;
+
+public class GuiTouchHotbarSettings extends GuiVROptionsBase
+{
+
+ public static String vrTitle = "vivecraft.options.screen.touch_hotbar";
+ public GuiTouchHotbarSettings(final Screen guiScreen)
+ {
+ super(guiScreen);
+ }
+
+ @Override
+ public void init()
+ {
+ super.clearWidgets();
+ super.init(VrOptions.TOUCH_HOTBAR, POS_CENTER);
+ super.init(VrOptions.DUMMY, POS_CENTER);
+ if (dh.vrSettings.vrTouchHotbar) {
+ super.init(
+ VrOptions.TOUCH_HOTBAR_COLOR_R,
+ VrOptions.TOUCH_HOTBAR_COLOR_G,
+ VrOptions.TOUCH_HOTBAR_COLOR_B,
+ VrOptions.TOUCH_HOTBAR_COLOR_A
+ );
+ super.init(VrOptions.DUMMY, POS_CENTER);
+ super.init(
+ VrOptions.TOUCH_OFFBAR_COLOR_R,
+ VrOptions.TOUCH_OFFBAR_COLOR_G,
+ VrOptions.TOUCH_OFFBAR_COLOR_B,
+ VrOptions.TOUCH_OFFBAR_COLOR_A
+ );
+ }
+ super.addDefaultButtons();
+ }
+
+ @Override
+ protected void actionPerformed(final AbstractWidget widget)
+ {
+ if (widget instanceof final GuiVROption guivroption)
+ {
+ if(guivroption.getOption() == VrOptions.TOUCH_HOTBAR){
+ this.reinit = true;
+ }
+ }
+ }
+}
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 1a060ae41..6a57b27a8 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
@@ -1,50 +1,54 @@
package org.vivecraft.client.gui.settings;
-import net.minecraft.client.gui.GuiGraphics;
-import org.vivecraft.client.gui.framework.VROptionEntry;
-import org.vivecraft.client.gui.framework.GuiVROptionsBase;
-import org.vivecraft.client_vr.settings.VRSettings;
+import org.vivecraft.client_vr.settings.VRSettings.VrOptions;
+import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;
-public class GuiVRControls extends GuiVROptionsBase
-{
- private static VROptionEntry[] controlsSettings = new VROptionEntry[] {
- new VROptionEntry(VRSettings.VrOptions.DUMMY, true),
- new VROptionEntry(VRSettings.VrOptions.DUMMY, true),
- 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.ALLOW_ADVANCED_BINDINGS),
- new VROptionEntry(VRSettings.VrOptions.THIRDPERSON_ITEMTRANSFORMS)
- };
+import javax.annotation.Nonnull;
+import static org.vivecraft.client.gui.framework.VROptionPosition.POS_CENTER;
+import static org.vivecraft.client_vr.VRState.mc;
+
+public class GuiVRControls extends org.vivecraft.client.gui.framework.GuiVROptionsBase
+{
+ public static String vrTitle = "vivecraft.options.screen.controls";
public GuiVRControls(Screen par1GuiScreen)
{
super(par1GuiScreen);
}
+ @Override
public void init()
{
- this.vrTitle = "vivecraft.options.screen.controls";
- super.init(controlsSettings, true);
+ super.clearWidgets();
+ super.init(VrOptions.DUMMY, POS_CENTER);
+ super.init(VrOptions.DUMMY, POS_CENTER);
+ super.init(VrOptions.DUMMY, POS_CENTER);
+ super.init(VrOptions.DUMMY, POS_CENTER);
+ super.init(VrOptions.DUMMY, POS_CENTER);
+ super.init(VrOptions.DUMMY);
+ super.init(GuiVRSkeletalInput.class);
+ super.init(
+ VrOptions.REVERSE_HANDS,
+ VrOptions.RIGHT_CLICK_DELAY,
+ VrOptions.ALLOW_ADVANCED_BINDINGS,
+ VrOptions.THIRDPERSON_ITEMTRANSFORMS
+ );
super.addDefaultButtons();
}
- public void render(GuiGraphics guiGraphics, int pMouseX, int pMouseY, float pPartialTicks)
+ @Override
+ public void render(@Nonnull GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTick)
{
- super.render(guiGraphics, pMouseX, pMouseY, pPartialTicks);
+ super.render(guiGraphics, mouseX, mouseY, partialTick);
- int middle = 240 / 2 - this.minecraft.font.lineHeight / 2 - 24;
- int lineHeight = this.minecraft.font.lineHeight + 3;
+ int middle = 240 / 2 - mc.font.lineHeight;
+ int lineHeight = mc.font.lineHeight + 3;
- guiGraphics.drawCenteredString(this.minecraft.font, Component.translatable("vivecraft.messages.controls.1"), this.width / 2, middle - lineHeight, 16777215);
- guiGraphics.drawCenteredString(this.minecraft.font, Component.translatable("vivecraft.messages.controls.2"), this.width / 2, middle, 16777215);
- guiGraphics.drawCenteredString(this.minecraft.font, Component.translatable("vivecraft.messages.controls.3"), this.width / 2, middle + lineHeight, 16777215);
+ guiGraphics.drawCenteredString(mc.font, Component.translatable("vivecraft.messages.controls.1"), this.width / 2, middle - lineHeight, 16777215);
+ guiGraphics.drawCenteredString(mc.font, Component.translatable("vivecraft.messages.controls.2"), this.width / 2, middle, 16777215);
+ guiGraphics.drawCenteredString(mc.font, Component.translatable("vivecraft.messages.controls.3"), this.width / 2, middle + lineHeight, 16777215);
}
}
diff --git a/common/src/main/java/org/vivecraft/client/gui/settings/GuiVRFingerDisplays.java b/common/src/main/java/org/vivecraft/client/gui/settings/GuiVRFingerDisplays.java
new file mode 100644
index 000000000..cb6c653f3
--- /dev/null
+++ b/common/src/main/java/org/vivecraft/client/gui/settings/GuiVRFingerDisplays.java
@@ -0,0 +1,54 @@
+package org.vivecraft.client.gui.settings;
+
+import org.vivecraft.client.gui.framework.GuiVROptionsBase;
+import org.vivecraft.client_vr.settings.VRSettings.VrOptions;
+
+import net.minecraft.client.gui.screens.Screen;
+
+import static org.vivecraft.client_vr.VRState.dh;
+
+public class GuiVRFingerDisplays extends GuiVROptionsBase {
+
+ public static String vrTitle = "vivecraft.options.screen.controls.skeletal_input.finger_displays";
+
+ public GuiVRFingerDisplays(final Screen par1GuiScreen)
+ {
+ super(par1GuiScreen);
+ }
+
+ @Override
+ public void init()
+ {
+ super.clearWidgets();
+ if (dh.vrSettings.reverseHands){
+ super.init(
+ VrOptions.MAIN_THUMB_DISPLAY,
+ VrOptions.OFF_THUMB_DISPLAY,
+ VrOptions.MAIN_INDEX_DISPLAY,
+ VrOptions.OFF_INDEX_DISPLAY,
+ VrOptions.MAIN_MIDDLE_DISPLAY,
+ VrOptions.OFF_MIDDLE_DISPLAY,
+ VrOptions.MAIN_RING_DISPLAY,
+ VrOptions.OFF_RING_DISPLAY,
+ VrOptions.MAIN_LITTLE_DISPLAY,
+ VrOptions.OFF_LITTLE_DISPLAY
+ );
+ }
+ else
+ {
+ super.init(
+ VrOptions.OFF_THUMB_DISPLAY,
+ VrOptions.MAIN_THUMB_DISPLAY,
+ VrOptions.OFF_INDEX_DISPLAY,
+ VrOptions.MAIN_INDEX_DISPLAY,
+ VrOptions.OFF_MIDDLE_DISPLAY,
+ VrOptions.MAIN_MIDDLE_DISPLAY,
+ VrOptions.OFF_RING_DISPLAY,
+ VrOptions.MAIN_RING_DISPLAY,
+ VrOptions.OFF_LITTLE_DISPLAY,
+ VrOptions.MAIN_LITTLE_DISPLAY
+ );
+ }
+ super.addDefaultButtons();
+ }
+}
diff --git a/common/src/main/java/org/vivecraft/client/gui/settings/GuiVRSkeletalInput.java b/common/src/main/java/org/vivecraft/client/gui/settings/GuiVRSkeletalInput.java
new file mode 100644
index 000000000..0e9e001db
--- /dev/null
+++ b/common/src/main/java/org/vivecraft/client/gui/settings/GuiVRSkeletalInput.java
@@ -0,0 +1,56 @@
+package org.vivecraft.client.gui.settings;
+
+import org.vivecraft.client.gui.framework.GuiVROptionsBase;
+import org.vivecraft.client_vr.settings.VRSettings.VrOptions;
+
+import net.minecraft.client.gui.screens.Screen;
+
+import static org.vivecraft.client.gui.framework.VROptionPosition.POS_CENTER;
+import static org.vivecraft.client_vr.VRState.dh;
+
+public class GuiVRSkeletalInput extends GuiVROptionsBase {
+
+ public static String vrTitle = "vivecraft.options.screen.controls.skeletal_input";
+
+ public GuiVRSkeletalInput(final Screen par1GuiScreen)
+ {
+ super(par1GuiScreen);
+ }
+
+ public void init()
+ {
+ super.clearWidgets();
+ if (dh.vrSettings.reverseHands){
+ super.init(
+ VrOptions.MAIN_THUMB_THRESHOLD,
+ VrOptions.OFF_THUMB_THRESHOLD,
+ VrOptions.MAIN_INDEX_THRESHOLD,
+ VrOptions.OFF_INDEX_THRESHOLD,
+ VrOptions.MAIN_MIDDLE_THRESHOLD,
+ VrOptions.OFF_MIDDLE_THRESHOLD,
+ VrOptions.MAIN_RING_THRESHOLD,
+ VrOptions.OFF_RING_THRESHOLD,
+ VrOptions.MAIN_LITTLE_THRESHOLD,
+ VrOptions.OFF_LITTLE_THRESHOLD
+ );
+ } else {
+ super.init(
+ VrOptions.OFF_THUMB_THRESHOLD,
+ VrOptions.MAIN_THUMB_THRESHOLD,
+ VrOptions.OFF_INDEX_THRESHOLD,
+ VrOptions.MAIN_INDEX_THRESHOLD,
+ VrOptions.OFF_MIDDLE_THRESHOLD,
+ VrOptions.MAIN_MIDDLE_THRESHOLD,
+ VrOptions.OFF_RING_THRESHOLD,
+ VrOptions.MAIN_RING_THRESHOLD,
+ VrOptions.OFF_LITTLE_THRESHOLD,
+ VrOptions.MAIN_LITTLE_THRESHOLD
+ );
+ }
+ super.init(VrOptions.FINGER_COUNT);
+ super.init(GuiVRFingerDisplays.class);
+ super.init(VrOptions.FINGER_VIEW);
+ super.init(VrOptions.SKELETAL_INPUT, POS_CENTER);
+ super.addDefaultButtons();
+ }
+}
diff --git a/common/src/main/java/org/vivecraft/client/gui/widgets/TextScrollWidget.java b/common/src/main/java/org/vivecraft/client/gui/widgets/TextScrollWidget.java
index 5b2dbf2e1..614aed931 100644
--- a/common/src/main/java/org/vivecraft/client/gui/widgets/TextScrollWidget.java
+++ b/common/src/main/java/org/vivecraft/client/gui/widgets/TextScrollWidget.java
@@ -1,16 +1,19 @@
package org.vivecraft.client.gui.widgets;
-import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.AbstractWidget;
import net.minecraft.client.gui.narration.NarrationElementOutput;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.FormattedText;
import net.minecraft.network.chat.Style;
-import org.lwjgl.glfw.GLFW;
import java.util.List;
+import static org.vivecraft.client_vr.VRState.mc;
+
+import static org.joml.Math.*;
+import static org.lwjgl.glfw.GLFW.*;
+
public class TextScrollWidget extends AbstractWidget {
private int maxLines = 0;
@@ -28,7 +31,7 @@ public class TextScrollWidget extends AbstractWidget {
public TextScrollWidget(int x, int y, int width, int height, String text) {
super(x, y, width, height, Component.literal(""));
- formattedText = Minecraft.getInstance().font.getSplitter().splitLines(text, width - scrollBarWidth*2, Style.EMPTY);
+ formattedText = mc.font.getSplitter().splitLines(text, width - scrollBarWidth * 2, Style.EMPTY);
initScroll();
}
@@ -36,7 +39,7 @@ public TextScrollWidget(int x, int y, int width, int height, String text) {
public TextScrollWidget(int x, int y, int width, int height, Component text) {
super(x, y, width, height, Component.literal(""));
- formattedText = Minecraft.getInstance().font.getSplitter().splitLines(text, width - scrollBarWidth*2, Style.EMPTY);
+ formattedText = mc.font.getSplitter().splitLines(text, width - scrollBarWidth * 2, Style.EMPTY);
initScroll();
}
@@ -45,8 +48,8 @@ private void initScroll() {
maxLines = (height - 2 - padding + 3) / 12;
currentLine = 0;
scrollSteps = formattedText.size() - maxLines;
- scrollSteps = Math.max(scrollSteps, 0);
- scrollBarSize = scrollSteps == 0 ? height - 2 : (int)(Math.max(formattedText.size(), maxLines) / (float)(scrollSteps) * 12);
+ scrollSteps = max(scrollSteps, 0);
+ scrollBarSize = scrollSteps == 0 ? height - 2 : max(formattedText.size(), maxLines) / scrollSteps * 12;
scrollBarOffset = height - scrollBarSize - 2;
}
@@ -55,22 +58,24 @@ private void initScroll() {
public void renderWidget(GuiGraphics guiGraphics, int i, int j, float f) {
// draw box outline
guiGraphics.fill(
- getX(),
- getY(),
- getX() + width,
- getY() + this.height,
- -6250336);
+ getX(),
+ getY(),
+ getX() + width,
+ getY() + this.height,
+ -6250336
+ );
// draw box inside
guiGraphics.fill(
- getX() + 1,
- getY() + 1,
- getX() + width - 1,
- getY() + this.height - 1,
- -16777216);
+ getX() + 1,
+ getY() + 1,
+ getX() + width - 1,
+ getY() + this.height - 1,
+ -16777216
+ );
// draw text
for (int line = 0; line + currentLine < formattedText.size() && line < maxLines; line++) {
- guiGraphics.drawString(Minecraft.getInstance().font, formattedText.get(line + currentLine).getString(), getX() + padding, getY() + padding + line * 12, 16777215);
+ guiGraphics.drawString(mc.font, formattedText.get(line + currentLine).getString(), getX() + padding, getY() + padding + line * 12, 16777215);
}
float scrollbarStart = scrollSteps == 0 ? 0 : currentLine/(float)scrollSteps * scrollBarOffset;
@@ -78,20 +83,22 @@ public void renderWidget(GuiGraphics guiGraphics, int i, int j, float f) {
if (isFocused() || isHovered) {
// draw scroll bar outline
guiGraphics.fill(
- getX() + width - scrollBarWidth - 2,
- (int) (getY() + 1 + scrollbarStart),
- getX() + width - 1,
- (int) (getY() + 1 + scrollbarStart + scrollBarSize),
- -1);
+ getX() + width - scrollBarWidth - 2,
+ (int) (getY() + 1 + scrollbarStart),
+ getX() + width - 1,
+ (int) (getY() + 1 + scrollbarStart + scrollBarSize),
+ -1
+ );
}
// draw scroll bar
guiGraphics.fill(
- getX() + width - scrollBarWidth - (isFocused() || isHovered ? 1 : 2),
- (int)(getY() + (isFocused() || isHovered ? 2 : 1) + scrollbarStart),
- getX() + width - (isFocused() || isHovered ? 2 : 1),
- (int)(getY() + (isFocused() || isHovered ? 0 : 1) + scrollbarStart + scrollBarSize),
- -6250336);
+ getX() + width - scrollBarWidth - (isFocused() || isHovered ? 1 : 2),
+ (int)(getY() + (isFocused() || isHovered ? 2 : 1) + scrollbarStart),
+ getX() + width - (isFocused() || isHovered ? 2 : 1),
+ (int)(getY() + (isFocused() || isHovered ? 0 : 1) + scrollbarStart + scrollBarSize),
+ -6250336
+ );
}
@Override
@@ -148,8 +155,8 @@ public boolean mouseScrolled(double x, double y, double scrollAmount) {
@Override
public boolean keyPressed(int key, int scancode, int mods) {
- if (key == GLFW.GLFW_KEY_UP || key == GLFW.GLFW_KEY_DOWN) {
- if (mouseScrolled(0, 0, key == GLFW.GLFW_KEY_UP ? 1 : -1)) {
+ if (key == GLFW_KEY_UP || key == GLFW_KEY_DOWN) {
+ if (mouseScrolled(0, 0, key == GLFW_KEY_UP ? 1 : -1)) {
return true;
}
}
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 f5554c0fa..656deee08 100644
--- a/common/src/main/java/org/vivecraft/client/network/ClientNetworking.java
+++ b/common/src/main/java/org/vivecraft/client/network/ClientNetworking.java
@@ -1,35 +1,42 @@
package org.vivecraft.client.network;
-import com.google.common.base.Charsets;
+import org.vivecraft.client.VRPlayersClient;
+import org.vivecraft.client_vr.gameplay.VRPlayer;
+import org.vivecraft.client_vr.settings.AutoCalibration;
+import org.vivecraft.client_vr.settings.VRSettings.ChatServerPluginMessage;
+import org.vivecraft.client_vr.settings.VRSettings.ServerOverrides.Setting;
+import org.vivecraft.client_vr.settings.VRSettings.VrOptions;
+import org.vivecraft.common.CommonDataHolder;
+import org.vivecraft.common.VRServerPerms;
+import org.vivecraft.common.network.CommonNetworkHelper;
+import org.vivecraft.common.network.CommonNetworkHelper.PacketDiscriminators;
+import org.vivecraft.common.network.VRPlayerState;
+
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-import net.minecraft.client.Minecraft;
+
import net.minecraft.client.multiplayer.ClientPacketListener;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.chat.Component;
import net.minecraft.network.protocol.game.ServerboundCustomPayloadPacket;
-import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket;
+import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket.Rot;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.Pose;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.phys.Vec3;
-import org.vivecraft.client.VRPlayersClient;
-import org.vivecraft.common.network.CommonNetworkHelper;
-import org.vivecraft.client_vr.ClientDataHolderVR;
-import org.vivecraft.client_vr.VRState;
-import org.vivecraft.client_vr.gameplay.VRPlayer;
-import org.vivecraft.client_vr.settings.AutoCalibration;
-import org.vivecraft.client_vr.settings.VRSettings;
-import org.vivecraft.common.CommonDataHolder;
-import org.vivecraft.common.VRServerPerms;
-import org.vivecraft.common.network.VrPlayerState;
import java.util.UUID;
+import static org.vivecraft.client.utils.Utils.message;
+import static org.vivecraft.client_vr.VRState.*;
+import static org.vivecraft.common.utils.Utils.logger;
+
+import static org.joml.Math.*;
+
public class ClientNetworking {
public static boolean displayedChatMessage = false;
@@ -50,7 +57,7 @@ public class ClientNetworking {
public static boolean needsReset = true;
- public static ServerboundCustomPayloadPacket getVivecraftClientPacket(CommonNetworkHelper.PacketDiscriminators command, byte[] payload) {
+ public static ServerboundCustomPayloadPacket getVivecraftClientPacket(PacketDiscriminators command, byte[] payload) {
FriendlyByteBuf friendlybytebuf = new FriendlyByteBuf(Unpooled.buffer());
friendlybytebuf.writeByte(command.ordinal());
friendlybytebuf.writeBytes(payload);
@@ -58,8 +65,8 @@ public static ServerboundCustomPayloadPacket getVivecraftClientPacket(CommonNetw
}
public static ServerboundCustomPayloadPacket createVRActivePacket(boolean vrActive) {
- var buffer = new FriendlyByteBuf(Unpooled.buffer());
- buffer.writeByte(CommonNetworkHelper.PacketDiscriminators.IS_VR_ACTIVE.ordinal());
+ FriendlyByteBuf buffer = new FriendlyByteBuf(Unpooled.buffer());
+ buffer.writeByte(PacketDiscriminators.IS_VR_ACTIVE.ordinal());
buffer.writeBoolean(vrActive);
return new ServerboundCustomPayloadPacket(CommonNetworkHelper.CHANNEL, buffer);
}
@@ -73,37 +80,37 @@ public static void resetServerSettings() {
serverAllowsCrawling = false;
serverAllowsVrSwitching = false;
usedNetworkVersion = -1;
- //DataHolder.getInstance().vrSettings.overrides.resetAll(); move to mixin
+ //dh.vrSettings.overrides.resetAll(); move to mixin
}
public static void sendVersionInfo() {
String s = CommonNetworkHelper.CHANNEL.toString();
FriendlyByteBuf friendlybytebuf = new FriendlyByteBuf(Unpooled.buffer());
friendlybytebuf.writeBytes(s.getBytes());
- Minecraft.getInstance().getConnection().send(new ServerboundCustomPayloadPacket(new ResourceLocation("minecraft:register"), friendlybytebuf));
+ mc.getConnection().send(new ServerboundCustomPayloadPacket(new ResourceLocation("minecraft:register"), friendlybytebuf));
// send version string, with currently running
- Minecraft.getInstance().getConnection().send(getVivecraftClientPacket(CommonNetworkHelper.PacketDiscriminators.VERSION,
- (CommonDataHolder.getInstance().versionIdentifier + (VRState.vrRunning ? " VR" : " NONVR")
+ mc.getConnection().send(getVivecraftClientPacket(PacketDiscriminators.VERSION,
+ (CommonDataHolder.getInstance().versionIdentifier + (vrRunning ? " VR" : " NONVR")
+ "\n" + CommonNetworkHelper.MAX_SUPPORTED_NETWORK_VERSION
+ "\n" + CommonNetworkHelper.MIN_SUPPORTED_NETWORK_VERSION
- ).getBytes(Charsets.UTF_8)));
+ ).getBytes(java.nio.charset.StandardCharsets.UTF_8)));
}
public static void sendVRPlayerPositions(VRPlayer vrPlayer) {
- var connection = Minecraft.getInstance().getConnection();
+ var connection = mc.getConnection();
if (!serverWantsData || connection == null) {
return;
}
- float worldScale = ClientDataHolderVR.getInstance().vrPlayer.vrdata_world_post.worldScale;
+ float worldScale = dh.vrPlayer.vrdata_world_post.worldScale;
if (worldScale != worldScallast) {
ByteBuf bytebuf = Unpooled.buffer();
bytebuf.writeFloat(worldScale);
byte[] abyte = new byte[bytebuf.readableBytes()];
bytebuf.readBytes(abyte);
- ServerboundCustomPayloadPacket serverboundcustompayloadpacket = getVivecraftClientPacket(CommonNetworkHelper.PacketDiscriminators.WORLDSCALE, abyte);
- Minecraft.getInstance().getConnection().send(serverboundcustompayloadpacket);
+ ServerboundCustomPayloadPacket serverboundcustompayloadpacket = getVivecraftClientPacket(PacketDiscriminators.WORLDSCALE, abyte);
+ mc.getConnection().send(serverboundcustompayloadpacket);
worldScallast = worldScale;
}
@@ -114,79 +121,79 @@ public static void sendVRPlayerPositions(VRPlayer vrPlayer) {
bytebuf2.writeFloat(f1 / 1.52F);
byte[] abyte3 = new byte[bytebuf2.readableBytes()];
bytebuf2.readBytes(abyte3);
- ServerboundCustomPayloadPacket serverboundcustompayloadpacket1 = getVivecraftClientPacket(CommonNetworkHelper.PacketDiscriminators.HEIGHT, abyte3);
- Minecraft.getInstance().getConnection().send(serverboundcustompayloadpacket1);
+ ServerboundCustomPayloadPacket serverboundcustompayloadpacket1 = getVivecraftClientPacket(PacketDiscriminators.HEIGHT, abyte3);
+ mc.getConnection().send(serverboundcustompayloadpacket1);
heightlast = f1;
}
- var vrPlayerState = VrPlayerState.create(vrPlayer);
+ VRPlayerState vrPlayerState = VRPlayerState.create(vrPlayer);
if (usedNetworkVersion >= 0) {
connection.send(createVrPlayerStatePacket(vrPlayerState));
} else {
sendLegacyPackets(connection, vrPlayerState);
}
- VRPlayersClient.getInstance().Update(Minecraft.getInstance().player.getGameProfile().getId(), vrPlayerState, worldScale, f1 / 1.52F, true);
+ VRPlayersClient.getInstance().Update(mc.player.getGameProfile().getId(), vrPlayerState, worldScale, f1 / 1.52F, true);
}
- public static ServerboundCustomPayloadPacket createVrPlayerStatePacket(VrPlayerState vrPlayerState) {
- var buffer = new FriendlyByteBuf(Unpooled.buffer());
- buffer.writeByte(CommonNetworkHelper.PacketDiscriminators.VR_PLAYER_STATE.ordinal());
+ public static ServerboundCustomPayloadPacket createVrPlayerStatePacket(VRPlayerState vrPlayerState) {
+ FriendlyByteBuf buffer = new FriendlyByteBuf(Unpooled.buffer());
+ buffer.writeByte(PacketDiscriminators.VR_PLAYER_STATE.ordinal());
vrPlayerState.serialize(buffer);
return new ServerboundCustomPayloadPacket(CommonNetworkHelper.CHANNEL, buffer);
}
- public static void sendLegacyPackets(ClientPacketListener connection, VrPlayerState vrPlayerState) {
+ public static void sendLegacyPackets(ClientPacketListener connection, VRPlayerState vrPlayerState) {
// left controller packet
FriendlyByteBuf controller0Buffer = new FriendlyByteBuf(Unpooled.buffer());
- controller0Buffer.writeByte(CommonNetworkHelper.PacketDiscriminators.CONTROLLER0DATA.ordinal());
- controller0Buffer.writeBoolean(ClientDataHolderVR.getInstance().vrSettings.reverseHands);
+ controller0Buffer.writeByte(PacketDiscriminators.CONTROLLER0DATA.ordinal());
+ controller0Buffer.writeBoolean(dh.vrSettings.reverseHands);
vrPlayerState.controller0().serialize(controller0Buffer);
connection.send(new ServerboundCustomPayloadPacket(CommonNetworkHelper.CHANNEL, controller0Buffer));
// right controller packet
FriendlyByteBuf controller1Buffer = new FriendlyByteBuf(Unpooled.buffer());
- controller1Buffer.writeByte(CommonNetworkHelper.PacketDiscriminators.CONTROLLER1DATA.ordinal());
- controller1Buffer.writeBoolean(ClientDataHolderVR.getInstance().vrSettings.reverseHands);
+ controller1Buffer.writeByte(PacketDiscriminators.CONTROLLER1DATA.ordinal());
+ controller1Buffer.writeBoolean(dh.vrSettings.reverseHands);
vrPlayerState.controller1().serialize(controller1Buffer);
connection.send(new ServerboundCustomPayloadPacket(CommonNetworkHelper.CHANNEL, controller1Buffer));
// hmd packet
FriendlyByteBuf headBuffer = new FriendlyByteBuf(Unpooled.buffer());
- headBuffer.writeByte(CommonNetworkHelper.PacketDiscriminators.HEADDATA.ordinal());
- headBuffer.writeBoolean(ClientDataHolderVR.getInstance().vrSettings.seated);
+ headBuffer.writeByte(PacketDiscriminators.HEADDATA.ordinal());
+ headBuffer.writeBoolean(dh.vrSettings.seated);
vrPlayerState.hmd().serialize(headBuffer);
connection.send(new ServerboundCustomPayloadPacket(CommonNetworkHelper.CHANNEL, headBuffer));
}
public static boolean isLimitedSurvivalTeleport() {
- return ClientDataHolderVR.getInstance().vrSettings.overrides.getSetting(VRSettings.VrOptions.LIMIT_TELEPORT).getBoolean();
+ return dh.vrSettings.overrides.getSetting(VrOptions.LIMIT_TELEPORT).getBoolean();
}
public static int getTeleportUpLimit() {
- return ClientDataHolderVR.getInstance().vrSettings.overrides.getSetting(VRSettings.VrOptions.TELEPORT_UP_LIMIT).getInt();
+ return dh.vrSettings.overrides.getSetting(VrOptions.TELEPORT_UP_LIMIT).getInt();
}
public static int getTeleportDownLimit() {
- return ClientDataHolderVR.getInstance().vrSettings.overrides.getSetting(VRSettings.VrOptions.TELEPORT_DOWN_LIMIT).getInt();
+ return dh.vrSettings.overrides.getSetting(VrOptions.TELEPORT_DOWN_LIMIT).getInt();
}
public static int getTeleportHorizLimit() {
- return ClientDataHolderVR.getInstance().vrSettings.overrides.getSetting(VRSettings.VrOptions.TELEPORT_HORIZ_LIMIT).getInt();
+ return dh.vrSettings.overrides.getSetting(VrOptions.TELEPORT_HORIZ_LIMIT).getInt();
}
public static void sendActiveHand(byte c) {
if (serverWantsData) {
- ServerboundCustomPayloadPacket serverboundcustompayloadpacket = getVivecraftClientPacket(CommonNetworkHelper.PacketDiscriminators.ACTIVEHAND, new byte[]{c});
+ ServerboundCustomPayloadPacket serverboundcustompayloadpacket = getVivecraftClientPacket(PacketDiscriminators.ACTIVEHAND, new byte[]{c});
- if (Minecraft.getInstance().getConnection() != null) {
- Minecraft.getInstance().getConnection().send(serverboundcustompayloadpacket);
+ if (mc.getConnection() != null) {
+ mc.getConnection().send(serverboundcustompayloadpacket);
}
}
}
public static void overridePose(LocalPlayer player) {
- if (ClientDataHolderVR.getInstance().crawlTracker.crawling) {
+ if (dh.crawlTracker.crawling) {
player.setPose(Pose.SWIMMING);
}
}
@@ -195,9 +202,9 @@ public static void overrideLook(Player player, Vec3 view) {
if (!serverWantsData) {
capturedPitch = player.getXRot();
capturedYaw = player.getYRot();
- float f = (float) Math.toDegrees(Math.asin(-view.y / view.length()));
- float f1 = (float) Math.toDegrees(Math.atan2(-view.x, view.z));
- ((LocalPlayer) player).connection.send(new ServerboundMovePlayerPacket.Rot(f1, f, player.onGround()));
+ float f = (float) toDegrees(asin(-view.y / view.length()));
+ float f1 = (float) toDegrees(atan2(-view.x, view.z));
+ ((LocalPlayer) player).connection.send(new Rot(f1, f, player.onGround()));
overrideActive = true;
}
}
@@ -205,31 +212,29 @@ public static void overrideLook(Player player, Vec3 view) {
public static void restoreLook(Player player) {
if (!serverWantsData) {
if (overrideActive) {
- ((LocalPlayer) player).connection.send(new ServerboundMovePlayerPacket.Rot(capturedYaw, capturedPitch, player.onGround()));
+ ((LocalPlayer) player).connection.send(new Rot(capturedYaw, capturedPitch, player.onGround()));
overrideActive = false;
}
}
}
- public static void handlePacket(CommonNetworkHelper.PacketDiscriminators packetID, FriendlyByteBuf buffer) {
- ClientDataHolderVR dataholder = ClientDataHolderVR.getInstance();
- Minecraft mc = Minecraft.getInstance();
+ public static void handlePacket(PacketDiscriminators packetID, FriendlyByteBuf buffer) {
switch (packetID) {
case VERSION -> {
String s11 = buffer.readUtf(1024);
- VRServerPerms.INSTANCE.setTeleportSupported(true);
- if (VRState.vrInitialized) {
- dataholder.vrPlayer.teleportWarning = false;
- dataholder.vrPlayer.vrSwitchWarning = true;
+ VRServerPerms.setTeleportSupported(true);
+ if (vrInitialized) {
+ dh.vrPlayer.teleportWarning = false;
+ dh.vrPlayer.vrSwitchWarning = true;
}
- if (!ClientNetworking.displayedChatMessage
- && (dataholder.vrSettings.showServerPluginMessage == VRSettings.ChatServerPluginMessage.ALWAYS
- || (dataholder.vrSettings.showServerPluginMessage == VRSettings.ChatServerPluginMessage.SERVER_ONLY && !Minecraft.getInstance().isLocalServer()))) {
- ClientNetworking.displayedChatMessage = true;
- mc.gui.getChat().addMessage(Component.translatable("vivecraft.messages.serverplugin", s11));
+ if (!displayedChatMessage
+ && (dh.vrSettings.showServerPluginMessage == ChatServerPluginMessage.ALWAYS
+ || (dh.vrSettings.showServerPluginMessage == ChatServerPluginMessage.SERVER_ONLY && !mc.isLocalServer()))) {
+ displayedChatMessage = true;
+ message(Component.translatable("vivecraft.messages.serverplugin", s11));
}
- if (VRState.vrEnabled && dataholder.vrSettings.manualCalibration == -1.0F && !dataholder.vrSettings.seated) {
- mc.gui.getChat().addMessage(Component.translatable("vivecraft.messages.calibrateheight"));
+ if (vrEnabled && dh.vrSettings.manualCalibration == -1.0F && !dh.vrSettings.seated) {
+ message(Component.translatable("vivecraft.messages.calibrateheight"));
}
}
case IS_VR_ACTIVE -> {
@@ -237,12 +242,12 @@ public static void handlePacket(CommonNetworkHelper.PacketDiscriminators packetI
VRPlayersClient.getInstance().disableVR(buffer.readUUID());
}
}
- case REQUESTDATA -> ClientNetworking.serverWantsData = true;
+ case REQUESTDATA -> serverWantsData = true;
case CLIMBING -> {
- ClientNetworking.serverAllowsClimbey = buffer.readBoolean();
+ serverAllowsClimbey = buffer.readBoolean();
if (buffer.readableBytes() > 0) {
- dataholder.climbTracker.serverblockmode = buffer.readByte();
- dataholder.climbTracker.blocklist.clear();
+ dh.climbTracker.serverblockmode = buffer.readByte();
+ dh.climbTracker.blocklist.clear();
while (buffer.readableBytes() > 0) {
String s12 = buffer.readUtf(16384);
@@ -250,15 +255,15 @@ public static void handlePacket(CommonNetworkHelper.PacketDiscriminators packetI
// if the block is not there AIR is returned
if (block != Blocks.AIR) {
- dataholder.climbTracker.blocklist.add(block);
+ dh.climbTracker.blocklist.add(block);
}
}
}
}
- case TELEPORT -> ClientNetworking.serverSupportsDirectTeleport = true;
+ case TELEPORT -> serverSupportsDirectTeleport = true;
case UBERPACKET -> {
UUID uuid = buffer.readUUID();
- var vrPlayerState = VrPlayerState.deserialize(buffer);
+ VRPlayerState vrPlayerState = VRPlayerState.deserialize(buffer);
float worldScale = buffer.readFloat();
float heightScale = buffer.readFloat();
VRPlayersClient.getInstance().Update(uuid, vrPlayerState, worldScale, heightScale);
@@ -269,8 +274,8 @@ public static void handlePacket(CommonNetworkHelper.PacketDiscriminators packetI
String s14 = buffer.readUtf(16384);
String[] astring = s13.split("\\.", 2);
- if (dataholder.vrSettings.overrides.hasSetting(astring[0])) {
- VRSettings.ServerOverrides.Setting vrsettings$serveroverrides$setting = dataholder.vrSettings.overrides.getSetting(astring[0]);
+ if (dh.vrSettings.overrides.hasSetting(astring[0])) {
+ Setting vrsettings$serveroverrides$setting = dh.vrSettings.overrides.getSetting(astring[0]);
try {
if (astring.length > 1) {
@@ -287,7 +292,7 @@ public static void handlePacket(CommonNetworkHelper.PacketDiscriminators packetI
Object object = vrsettings$serveroverrides$setting.getOriginalValue();
if (object instanceof Boolean) {
- vrsettings$serveroverrides$setting.setValue(s14.equals("true"));
+ vrsettings$serveroverrides$setting.setValue("true".equals(s14));
} else if (!(object instanceof Integer) && !(object instanceof Byte) && !(object instanceof Short)) {
if (!(object instanceof Float) && !(object instanceof Double)) {
vrsettings$serveroverrides$setting.setValue(s14);
@@ -299,23 +304,23 @@ public static void handlePacket(CommonNetworkHelper.PacketDiscriminators packetI
}
}
- System.out.println("Server setting override: " + s13 + " = " + s14);
+ logger.info("Server setting override: {} = {}", s13, s14);
} catch (Exception exception) {
exception.printStackTrace();
}
}
}
}
- case CRAWL -> ClientNetworking.serverAllowsCrawling = true;
+ case CRAWL -> serverAllowsCrawling = true;
case NETWORK_VERSION -> // cast to unsigned byte
- ClientNetworking.usedNetworkVersion = buffer.readByte() & 0xFF;
+ usedNetworkVersion = buffer.readByte() & 0xFF;
case VR_SWITCHING -> {
- ClientNetworking.serverAllowsVrSwitching = buffer.readBoolean();
- if (VRState.vrInitialized) {
- if (!ClientNetworking.serverAllowsVrSwitching) {
- Minecraft.getInstance().gui.getChat().addMessage(Component.translatable("vivecraft.messages.novrhotswitching"));
+ serverAllowsVrSwitching = buffer.readBoolean();
+ if (vrInitialized) {
+ if (!serverAllowsVrSwitching) {
+ message(Component.translatable("vivecraft.messages.novrhotswitching"));
}
- dataholder.vrPlayer.vrSwitchWarning = false;
+ dh.vrPlayer.vrSwitchWarning = false;
}
}
}
diff --git a/common/src/main/java/org/vivecraft/client/network/PatreonReceiver.java b/common/src/main/java/org/vivecraft/client/network/PatreonReceiver.java
index 4da27c86a..d2d91c275 100644
--- a/common/src/main/java/org/vivecraft/client/network/PatreonReceiver.java
+++ b/common/src/main/java/org/vivecraft/client/network/PatreonReceiver.java
@@ -1,21 +1,25 @@
package org.vivecraft.client.network;
+import org.vivecraft.client.VRPlayersClient;
+
+import org.apache.commons.io.IOUtils;
+
+import net.minecraft.world.entity.player.Player;
+
import java.io.IOException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
import java.util.HashMap;
-import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-import net.minecraft.world.entity.player.Player;
-import org.apache.commons.io.IOUtils;
-import org.vivecraft.client.VRPlayersClient;
+import static org.vivecraft.common.utils.Utils.logger;
public class PatreonReceiver
{
private static final Object lock = new Object();
- private static List queuedPlayers = new LinkedList<>();
+ private static final List queuedPlayers = new ArrayList<>();
private static Map cache;
private static boolean downloadStarted;
private static boolean downloadFailed;
@@ -49,7 +53,7 @@ private static void fileDownloadFinished(String url, String data)
}
catch (Exception exception1)
{
- System.out.println("error with donors txt " + exception1.getMessage());
+ logger.error("error with donors txt {}", exception1.getMessage());
}
}
@@ -57,7 +61,7 @@ private static void fileDownloadFinished(String url, String data)
}
catch (Exception exception1)
{
- System.out.println("Error parsing data: " + url + ", " + exception1.getClass().getName() + ": " + exception1.getMessage());
+ logger.error("Error parsing data: {}, {}: {}", url, exception1.getClass().getName(), exception1.getMessage());
downloadFailed = true;
}
}
diff --git a/common/src/main/java/org/vivecraft/client/render/HMDLayer.java b/common/src/main/java/org/vivecraft/client/render/HMDLayer.java
index b12cc961e..ff6a4946d 100644
--- a/common/src/main/java/org/vivecraft/client/render/HMDLayer.java
+++ b/common/src/main/java/org/vivecraft/client/render/HMDLayer.java
@@ -1,7 +1,10 @@
package org.vivecraft.client.render;
+import org.vivecraft.client.VRPlayersClient;
+
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
+
import net.minecraft.client.model.PlayerModel;
import net.minecraft.client.player.AbstractClientPlayer;
import net.minecraft.client.renderer.MultiBufferSource;
@@ -11,7 +14,6 @@
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Player;
-import org.vivecraft.client.VRPlayersClient;
public class HMDLayer extends RenderLayer> {
@@ -24,33 +26,17 @@ public HMDLayer(RenderLayerParent this.BLACK_HMD;
+ case 2 -> this.GOLD_HMD;
+ case 3, 4 -> this.DIAMOND_HMD;
+ default -> null;
+ };
+ if (hmd != null) {
+ poseStack.pushPose();
+ VertexConsumer vertexConsumer = multiBufferSource.getBuffer(RenderType.entitySolid(hmd));
+ ((VRPlayerModel)this.getParentModel()).renderHMDR(poseStack, vertexConsumer, i, OverlayTexture.NO_OVERLAY);
+ poseStack.popPose();
}
- poseStack.pushPose();
- VertexConsumer vertexConsumer = multiBufferSource.getBuffer(RenderType.entitySolid(hmd));
- ((VRPlayerModel)this.getParentModel()).renderHMDR(poseStack, vertexConsumer, i, OverlayTexture.NO_OVERLAY);
- poseStack.popPose();
}
}
diff --git a/common/src/main/java/org/vivecraft/client/render/OpenGLdebugging.java b/common/src/main/java/org/vivecraft/client/render/OpenGLdebugging.java
index 8c0b5bf0b..7546057e0 100644
--- a/common/src/main/java/org/vivecraft/client/render/OpenGLdebugging.java
+++ b/common/src/main/java/org/vivecraft/client/render/OpenGLdebugging.java
@@ -1,5 +1,9 @@
package org.vivecraft.client.render;
+import org.apache.commons.io.IOUtils;
+import org.lwjgl.BufferUtils;
+import org.lwjgl.opengl.GL11C;
+
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -8,17 +12,14 @@
import java.nio.IntBuffer;
import java.util.HashMap;
import java.util.Map;
-import org.apache.commons.io.IOUtils;
-import org.lwjgl.BufferUtils;
-import org.lwjgl.opengl.GL11;
public class OpenGLdebugging
{
- private static Map dumpedComplete = new HashMap<>();
- private static Map dumped = new HashMap<>();
- private static Map dumpedType = new HashMap<>();
+ private static final Map dumpedComplete = new HashMap<>();
+ private static final Map dumped = new HashMap<>();
+ private static final Map dumpedType = new HashMap<>();
public static OpenGLdebugging instance = new OpenGLdebugging();
- public GLproperty[] propertyList = new GLproperty[] {new GLproperty(2816, "GL_CURRENT_COLOR", "Current color", "current", "glGetFloatv()"), new GLproperty(2817, "GL_CURRENT_INDEX", "Current color index", "current", "glGetFloatv()"), new GLproperty(2819, "GL_CURRENT_TEXTURE_COORDS", "Current texture coordinates", "current", "glGetFloatv()"), new GLproperty(2818, "GL_CURRENT_NORMAL", "Current normal", "current", "glGetFloatv()"), new GLproperty(2823, "GL_CURRENT_RASTER_POSITION", "Current raster position", "current", "glGetFloatv()"), new GLproperty(2825, "GL_CURRENT_RASTER_DISTANCE", "Current raster distance", "current", "glGetFloatv()"), new GLproperty(2820, "GL_CURRENT_RASTER_COLOR", "Color associated with raster position", "current", "glGetFloatv()"), new GLproperty(2821, "GL_CURRENT_RASTER_INDEX", "Color index associated with raster position", "current", "glGetFloatv()"), new GLproperty(2822, "GL_CURRENT_RASTER_TEXTURE_COORDS", "Texture coordinates associated with raster position", "current", "glGetFloatv()"), new GLproperty(2824, "GL_CURRENT_RASTER_POSITION_VALID", "Raster position valid bit", "current", "glGetBooleanv()"), new GLproperty(2883, "GL_EDGE_FLAG", "Edge flag", "current", "glGetBooleanv()"), new GLproperty(32884, "GL_VERTEX_ARRAY", "Vertex array enable", "vertex-array", "glIsEnabled()"), new GLproperty(32890, "GL_VERTEX_ARRAY_SIZE", "Coordinates per vertex", "vertex-array", "glGetIntegerv()"), new GLproperty(32891, "GL_VERTEX_ARRAY_TYPE", "Type of vertex coordinates", "vertex-array", "glGetIntegerv()"), new GLproperty(32892, "GL_VERTEX_ARRAY_STRIDE", "Stride between vertices", "vertex-array", "glGetIntegerv()"), new GLproperty(32910, "GL_VERTEX_ARRAY_POINTER", "Pointer to the vertex array", "vertex-array", "glGetPointerv()"), new GLproperty(32885, "GL_NORMAL_ARRAY", "Normal array enable", "vertex-array", "glIsEnabled()"), new GLproperty(32894, "GL_NORMAL_ARRAY_TYPE", "Type of normal coordinates", "vertex-array", "glGetIntegerv()"), new GLproperty(32895, "GL_NORMAL_ARRAY_STRIDE", "Stride between normals", "vertex-array", "glGetIntegerv()"), new GLproperty(32911, "GL_NORMAL_ARRAY_POINTER", "Pointer to the normal array", "vertex-array", "glGetPointerv()"), new GLproperty(32886, "GL_COLOR_ARRAY", "RGBA color array enable", "vertex-array", "glIsEnabled()"), new GLproperty(32897, "GL_COLOR_ARRAY_SIZE", "Colors per vertex", "vertex-array", "glGetIntegerv()"), new GLproperty(32898, "GL_COLOR_ARRAY_TYPE", "Type of color components", "vertex-array", "glGetIntegerv()"), new GLproperty(32899, "GL_COLOR_ARRAY_STRIDE", "Stride between colors", "vertex-array", "glGetIntegerv()"), new GLproperty(32912, "GL_COLOR_ARRAY_POINTER", "Pointer to the color array", "vertex-array", "glGetPointerv()"), new GLproperty(32887, "GL_INDEX_ARRAY", "Color-index array enable", "vertex-array", "glIsEnabled()"), new GLproperty(32901, "GL_INDEX_ARRAY_TYPE", "Type of color indices", "vertex-array", "glGetIntegerv()"), new GLproperty(32902, "GL_INDEX_ARRAY_STRIDE", "Stride between color indices", "vertex-array", "glGetIntegerv()"), new GLproperty(32913, "GL_INDEX_ARRAY_POINTER", "Pointer to the index array", "vertex-array", "glGetPointerv()"), new GLproperty(32888, "GL_TEXTURE_COORD_ARRAY", "Texture coordinate array enable", "vertex-array", "glIsEnabled()"), new GLproperty(32904, "GL_TEXTURE_COORD_ARRAY_SIZE", "Texture coordinates per element", "vertex-array", "glGetIntegerv()"), new GLproperty(32905, "GL_TEXTURE_COORD_ARRAY_TYPE", "Type of texture coordinates", "vertex-array", "glGetIntegerv()"), new GLproperty(32906, "GL_TEXTURE_COORD_ARRAY_STRIDE", "Stride between texture coordinates", "vertex-array", "glGetIntegerv()"), new GLproperty(32914, "GL_TEXTURE_COORD_ARRAY_POINTER", "Pointer to the texture coordinate array", "vertex-array", "glGetPointerv()"), new GLproperty(32889, "GL_EDGE_FLAG_ARRAY", "Edge flag array enable", "vertex-array", "glIsEnabled()"), new GLproperty(32908, "GL_EDGE_FLAG_ARRAY_STRIDE", "Stride between edge flags", "vertex-array", "glGetIntegerv()"), new GLproperty(32915, "GL_EDGE_FLAG_ARRAY_POINTER", "Pointer to the edge flag array", "vertex-array", "glGetPointerv()"), new GLproperty(2982, "GL_MODELVIEW_MATRIX", "Modelview matrix stack", "matrix", "glGetFloatv()"), new GLproperty(2983, "GL_PROJECTION_MATRIX", "Projection matrix stack", "matrix", "glGetFloatv()"), new GLproperty(2984, "GL_TEXTURE_MATRIX", "Texture matrix stack", "matrix", "glGetFloatv()"), new GLproperty(2978, "GL_VIEWPORT", "Viewport origin and extent", "viewport", "glGetIntegerv()"), new GLproperty(2928, "GL_DEPTH_RANGE", "Depth range near and far", "viewport", "glGetFloatv()"), new GLproperty(2979, "GL_MODELVIEW_STACK_DEPTH", "Modelview matrix stack pointer", "matrix", "glGetIntegerv()"), new GLproperty(2980, "GL_PROJECTION_STACK_DEPTH", "Projection matrix stack pointer", "matrix", "glGetIntegerv()"), new GLproperty(2981, "GL_TEXTURE_STACK_DEPTH", "Texture matrix stack pointer", "matrix", "glGetIntegerv()"), new GLproperty(2976, "GL_MATRIX_MODE", "Current matrix mode", "transform", "glGetIntegerv()"), new GLproperty(2977, "GL_NORMALIZE", "Current normal normalization on/off", "transform/ enable", "glIsEnabled()"), new GLproperty(2918, "GL_FOG_COLOR", "Fog color", "fog", "glGetFloatv()"), new GLproperty(2913, "GL_FOG_INDEX", "Fog index", "fog", "glGetFloatv()"), new GLproperty(2914, "GL_FOG_DENSITY", "Exponential fog density", "fog", "glGetFloatv()"), new GLproperty(2915, "GL_FOG_START", "Linear fog start", "fog", "glGetFloatv()"), new GLproperty(2916, "GL_FOG_END", "Linear fog end", "fog", "glGetFloatv()"), new GLproperty(2917, "GL_FOG_MODE", "Fog mode", "fog", "glGetIntegerv()"), new GLproperty(2912, "GL_FOG", "True if fog enabled", "fog/enable", "glIsEnabled()"), new GLproperty(2900, "GL_SHADE_MODEL", "glShadeModel() setting", "lighting", "glGetIntegerv()"), new GLproperty(2896, "GL_LIGHTING", "True if lighting is enabled", "lighting/e nable", "glIsEnabled()"), new GLproperty(2903, "GL_COLOR_MATERIAL", "True if color tracking is enabled", "lighting", "glIsEnabled()"), new GLproperty(2902, "GL_COLOR_MATERIAL_PARAMETER", "Material properties tracking current color", "lighting", "glGetIntegerv()"), new GLproperty(2901, "GL_COLOR_MATERIAL_FACE", "Face(s) affected by color tracking", "lighting", "glGetIntegerv()"), new GLproperty(4608, "GL_AMBIENT", "Ambient material color", "lighting", "glGetMaterialfv()"), new GLproperty(4609, "GL_DIFFUSE", "Diffuse material color", "lighting", "glGetMaterialfv()"), new GLproperty(4610, "GL_SPECULAR", "Specular material color", "lighting", "glGetMaterialfv()"), new GLproperty(5632, "GL_EMISSION", "Emissive material color", "lighting", "glGetMaterialfv()"), new GLproperty(5633, "GL_SHININESS", "Specular exponent of material", "lighting", "glGetMaterialfv()"), new GLproperty(2899, "GL_LIGHT_MODEL_AMBIENT", "Ambient scene color", "lighting", "glGetFloatv()"), new GLproperty(2897, "GL_LIGHT_MODEL_LOCAL_VIEWER", "Viewer is local", "lighting", "glGetBooleanv()"), new GLproperty(2898, "GL_LIGHT_MODEL_TWO_SIDE", "Use two-sided lighting", "lighting", "glGetBooleanv()"), new GLproperty(4608, "GL_AMBIENT", "Ambient intensity of light i", "lighting", "glGetLightfv()"), new GLproperty(4609, "GL_DIFFUSE", "Diffuse intensity of light i", "lighting", "glGetLightfv()"), new GLproperty(4610, "GL_SPECULAR", "Specular intensity of light i", "lighting", "glGetLightfv()"), new GLproperty(4611, "GL_POSITION", "Position of light i", "lighting", "glGetLightfv()"), new GLproperty(4615, "GL_CONSTANT_ATTENUATION", "Constant attenuation factor", "lighting", "glGetLightfv()"), new GLproperty(4616, "GL_LINEAR_ATTENUATION", "Linear attenuation factor", "lighting", "glGetLightfv()"), new GLproperty(4617, "GL_QUADRATIC_ATTENUATION", "Quadratic attenuation factor", "lighting", "glGetLightfv()"), new GLproperty(4612, "GL_SPOT_DIRECTION", "Spotlight direction of light i", "lighting", "glGetLightfv()"), new GLproperty(4613, "GL_SPOT_EXPONENT", "Spotlight exponent of light i", "lighting", "glGetLightfv()"), new GLproperty(4614, "GL_SPOT_CUTOFF", "Spotlight angle of light i", "lighting", "glGetLightfv()"), new GLproperty(16384, "GL_LIGHT0", "True if light 0 enabled", "lighting/enable", "glIsEnabled()"), new GLproperty(16385, "GL_LIGHT1", "True if light 1 enabled", "lighting/enable", "glIsEnabled()"), new GLproperty(16386, "GL_LIGHT2", "True if light 2 enabled", "lighting/enable", "glIsEnabled()"), new GLproperty(16387, "GL_LIGHT3", "True if light 3 enabled", "lighting/enable", "glIsEnabled()"), new GLproperty(16388, "GL_LIGHT4", "True if light 4 enabled", "lighting/enable", "glIsEnabled()"), new GLproperty(16389, "GL_LIGHT5", "True if light 5 enabled", "lighting/enable", "glIsEnabled()"), new GLproperty(16390, "GL_LIGHT6", "True if light 6 enabled", "lighting/enable", "glIsEnabled()"), new GLproperty(16391, "GL_LIGHT7", "True if light 7 enabled", "lighting/enable", "glIsEnabled()"), new GLproperty(5635, "GL_COLOR_INDEXES", "ca, cd, and cs for color-index lighting", "lighting/e nable", "glGetMaterialfv()"), new GLproperty(2833, "GL_POINT_SIZE", "Point size", "point", "glGetFloatv()"), new GLproperty(2832, "GL_POINT_SMOOTH", "Point antialiasing on", "point/enable", "glIsEnabled()"), new GLproperty(2849, "GL_LINE_WIDTH", "Line width", "line", "glGetFloatv()"), new GLproperty(2848, "GL_LINE_SMOOTH", "Line antialiasing on", "line/enable", "glIsEnabled()"), new GLproperty(2853, "GL_LINE_STIPPLE_PATTERN", "Line stipple", "line", "glGetIntegerv()"), new GLproperty(2854, "GL_LINE_STIPPLE_REPEAT", "Line stipple repeat", "line", "glGetIntegerv()"), new GLproperty(2852, "GL_LINE_STIPPLE", "Line stipple enable", "line/enable", "glIsEnabled()"), new GLproperty(2884, "GL_CULL_FACE", "Polygon culling enabled", "polygon/enable", "glIsEnabled()"), new GLproperty(2885, "GL_CULL_FACE_MODE", "Cull front-/back-facing polygons", "polygon", "glGetIntegerv()"), new GLproperty(2886, "GL_FRONT_FACE", "Polygon front-face CW/CCW indicator", "polygon", "glGetIntegerv()"), new GLproperty(2881, "GL_POLYGON_SMOOTH", "Polygon antialiasing on", "polygon/enable", "glIsEnabled()"), new GLproperty(2880, "GL_POLYGON_MODE", "Polygon rasterization mode (front and back)", "polygon", "glGetIntegerv()"), new GLproperty(32824, "GL_POLYGON_OFFSET_FACTOR", "Polygon offset factor", "polygon", "glGetFloatv()"), new GLproperty(10753, "GL_POLYGON_OFFSET_POINT", "Polygon offset enable for GL_POINT mode rasterization", "polygon/enable", "glIsEnabled()"), new GLproperty(10754, "GL_POLYGON_OFFSET_LINE", "Polygon offset enable for GL_LINE mode rasterization", "polygon/enable", "glIsEnabled()"), new GLproperty(32823, "GL_POLYGON_OFFSET_FILL", "Polygon offset enable for GL_FILL mode rasterization", "polygon/enable", "glIsEnabled()"), new GLproperty(2882, "GL_POLYGON_STIPPLE", "Polygon stipple enable", "polygon/enable", "glIsEnabled()"), new GLproperty(3552, "GL_TEXTURE_1D", "True if 1-D texturing enabled ", "texture/enable", "glIsEnabled()"), new GLproperty(3553, "GL_TEXTURE_2D", "True if 2-D texturing enabled ", "texture/enable", "glIsEnabled()"), new GLproperty(32872, "GL_TEXTURE_BINDING_1D", "Texture object bound to GL_TEXTURE_1D", "texture", "glGetIntegerv()"), new GLproperty(32873, "GL_TEXTURE_BINDING_2D", "Texture object bound to GL_TEXTURE_2D", "texture", "glGetIntegerv()"), new GLproperty(5890, "GL_TEXTURE", "x-D texture image at level of detail i", "UNUSED", "glGetTexImage()"), new GLproperty(4096, "GL_TEXTURE_WIDTH", "x-D texture image i's width", "UNUSED", "glGetTexLevelParameter*()"), new GLproperty(4097, "GL_TEXTURE_HEIGHT", "x-D texture image i's height", "UNUSED", "glGetTexLevelParameter*()"), new GLproperty(4101, "GL_TEXTURE_BORDER", "x-D texture image i's border width", "UNUSED", "glGetTexLevelParameter*()"), new GLproperty(32860, "GL_TEXTURE_RED_SIZE", "x-D texture image i's red resolution", "UNUSED", "glGetTexLevelParameter*()"), new GLproperty(32861, "GL_TEXTURE_GREEN_SIZE", "x-D texture image i's green resolution", "UNUSED", "glGetTexLevelParameter*()"), new GLproperty(32862, "GL_TEXTURE_BLUE_SIZE", "x-D texture image i's blue resolution", "UNUSED", "glGetTexLevelParameter*()"), new GLproperty(32863, "GL_TEXTURE_ALPHA_SIZE", "x-D texture image i's alpha resolution", "UNUSED", "glGetTexLevelParameter*()"), new GLproperty(32864, "GL_TEXTURE_LUMINANCE_SIZE", "x-D texture image i's luminance resolution", "UNUSED", "glGetTexLevelParameter*()"), new GLproperty(32865, "GL_TEXTURE_INTENSITY_SIZE", "x-D texture image i's intensity resolution", "UNUSED", "glGetTexLevelParameter*()"), new GLproperty(4100, "GL_TEXTURE_BORDER_COLOR", "Texture border color", "texture", "glGetTexParameter*()"), new GLproperty(10241, "GL_TEXTURE_MIN_FILTER", "Texture minification function", "texture", "glGetTexParameter*()"), new GLproperty(10240, "GL_TEXTURE_MAG_FILTER", "Texture magnification function", "texture", "glGetTexParameter*()"), new GLproperty(10242, "GL_TEXTURE_WRAP_S", "Texture wrap mode (x is S or T)", "texture", "glGetTexParameter*()"), new GLproperty(10243, "GL_TEXTURE_WRAP_T", "Texture wrap mode (x is S or T)", "texture", "glGetTexParameter*()"), new GLproperty(32870, "GL_TEXTURE_PRIORITY", "Texture object priority", "texture", "glGetTexParameter*()"), new GLproperty(8704, "GL_TEXTURE_ENV_MODE", "Texture application function", "texture", "glGetTexEnviv()"), new GLproperty(8705, "GL_TEXTURE_ENV_COLOR", "Texture environment color", "texture", "glGetTexEnvfv()"), new GLproperty(3168, "GL_TEXTURE_GEN_S", "Texgen enabled (x is S, T, R, or Q)", "texture/enable", "glIsEnabled()"), new GLproperty(3169, "GL_TEXTURE_GEN_T", "Texgen enabled (x is S, T, R, or Q)", "texture/enable", "glIsEnabled()"), new GLproperty(3170, "GL_TEXTURE_GEN_R", "Texgen enabled (x is S, T, R, or Q)", "texture/enable", "glIsEnabled()"), new GLproperty(3171, "GL_TEXTURE_GEN_Q", "Texgen enabled (x is S, T, R, or Q)", "texture/enable", "glIsEnabled()"), new GLproperty(9474, "GL_EYE_PLANE", "Texgen plane equation coefficients", "texture", "glGetTexGenfv()"), new GLproperty(9473, "GL_OBJECT_PLANE", "Texgen object linear coefficients", "texture", "glGetTexGenfv()"), new GLproperty(9472, "GL_TEXTURE_GEN_MODE", "Function used for texgen", "texture", "glGetTexGeniv()"), new GLproperty(3089, "GL_SCISSOR_TEST", "Scissoring enabled", "scissor/enable", "glIsEnabled()"), new GLproperty(3088, "GL_SCISSOR_BOX", "Scissor box", "scissor", "glGetIntegerv()"), new GLproperty(3008, "GL_ALPHA_TEST", "Alpha test enabled", "color-buffer/enable", "glIsEnabled()"), new GLproperty(3009, "GL_ALPHA_TEST_FUNC", "Alpha test function", "color-buffer", "glGetIntegerv()"), new GLproperty(3010, "GL_ALPHA_TEST_REF", "Alpha test reference value", "color-buffer", "glGetIntegerv()"), new GLproperty(2960, "GL_STENCIL_TEST", "Stenciling enabled", "stencil-buffer/enable", "glIsEnabled()"), new GLproperty(2962, "GL_STENCIL_FUNC", "Stencil function", "stencil-buffer", "glGetIntegerv()"), new GLproperty(2963, "GL_STENCIL_VALUE_MASK", "Stencil mask", "stencil-buffer", "glGetIntegerv()"), new GLproperty(2967, "GL_STENCIL_REF", "Stencil reference value", "stencil-buffer", "glGetIntegerv()"), new GLproperty(2964, "GL_STENCIL_FAIL", "Stencil fail action", "stencil-buffer", "glGetIntegerv()"), new GLproperty(2965, "GL_STENCIL_PASS_DEPTH_FAIL", "Stencil depth buffer fail action", "stencil-buffer", "glGetIntegerv()"), new GLproperty(2966, "GL_STENCIL_PASS_DEPTH_PASS", "Stencil depth buffer pass action", "stencil-buffer", "glGetIntegerv()"), new GLproperty(2929, "GL_DEPTH_TEST", "Depth buffer enabled", "depth-buffer/ena ble", "glIsEnabled()"), new GLproperty(2932, "GL_DEPTH_FUNC", "Depth buffer test function", "depth-buffer", "glGetIntegerv()"), new GLproperty(3042, "GL_BLEND", "Blending enabled", "color-buffer/enable", "glIsEnabled()"), new GLproperty(3041, "GL_BLEND_SRC", "Blending source function", "color-buffer", "glGetIntegerv()"), new GLproperty(3040, "GL_BLEND_DST", "Blending destination function", "color-buffer", "glGetIntegerv()"), new GLproperty(3024, "GL_DITHER", "Dithering enabled", "color-buffer/enable", "glIsEnabled()"), new GLproperty(3057, "GL_INDEX_LOGIC_OP", "Color index logical operation enabled", "color-buffer/enable", "glIsEnabled()"), new GLproperty(3058, "GL_COLOR_LOGIC_OP", "RGBA color logical operation enabled", "color-buffer/enable", "glIsEnabled()"), new GLproperty(3056, "GL_LOGIC_OP_MODE", "Logical operation function", "color-buffer", "glGetIntegerv()"), new GLproperty(3073, "GL_DRAW_BUFFER", "Buffers selected for drawing", "color-buffer", "glGetIntegerv()"), new GLproperty(3105, "GL_INDEX_WRITEMASK", "Color-index writemask", "color-buffer", "glGetIntegerv()"), new GLproperty(3107, "GL_COLOR_WRITEMASK", "Color write enables; R, G, B, or A", "color-buffer", "glGetBooleanv()"), new GLproperty(2930, "GL_DEPTH_WRITEMASK", "Depth buffer enabled for writing", "depth-buffer", "glGetBooleanv()"), new GLproperty(2968, "GL_STENCIL_WRITEMASK", "Stencil-buffer writemask", "stencil-buffer", "glGetIntegerv()"), new GLproperty(3106, "GL_COLOR_CLEAR_VALUE", "Color-buffer clear value (RGBA mode)", "color-buffer", "glGetFloatv()"), new GLproperty(3104, "GL_INDEX_CLEAR_VALUE", "Color-buffer clear value (color-index mode)", "color-buffer", "glGetFloatv()"), new GLproperty(2931, "GL_DEPTH_CLEAR_VALUE", "Depth-buffer clear value", "depth-buffer", "glGetIntegerv()"), new GLproperty(2961, "GL_STENCIL_CLEAR_VALUE", "Stencil-buffer clear value", "stencil-buffer", "glGetIntegerv()"), new GLproperty(2944, "GL_ACCUM_CLEAR_VALUE", "Accumulation-buffer clear value", "accum-buffer", "glGetFloatv()"), new GLproperty(3312, "GL_UNPACK_SWAP_BYTES", "Value of GL_UNPACK_SWAP_BYTES", "pixel-store", "glGetBooleanv()"), new GLproperty(3313, "GL_UNPACK_LSB_FIRST", "Value of GL_UNPACK_LSB_FIRST", "pixel-store", "glGetBooleanv()"), new GLproperty(3314, "GL_UNPACK_ROW_LENGTH", "Value of GL_UNPACK_ROW_LENGTH", "pixel-store", "glGetIntegerv()"), new GLproperty(3315, "GL_UNPACK_SKIP_ROWS", "Value of GL_UNPACK_SKIP_ROWS", "pixel-store", "glGetIntegerv()"), new GLproperty(3316, "GL_UNPACK_SKIP_PIXELS", "Value of GL_UNPACK_SKIP_PIXELS", "pixel-store", "glGetIntegerv()"), new GLproperty(3317, "GL_UNPACK_ALIGNMENT", "Value of GL_UNPACK_ALIGNMENT", "pixel-store", "glGetIntegerv()"), new GLproperty(3328, "GL_PACK_SWAP_BYTES", "Value of GL_PACK_SWAP_BYTES", "pixel-store", "glGetBooleanv()"), new GLproperty(3329, "GL_PACK_LSB_FIRST", "Value of GL_PACK_LSB_FIRST", "pixel-store", "glGetBooleanv()"), new GLproperty(3330, "GL_PACK_ROW_LENGTH", "Value of GL_PACK_ROW_LENGTH", "pixel-store", "glGetIntegerv()"), new GLproperty(3331, "GL_PACK_SKIP_ROWS", "Value of GL_PACK_SKIP_ROWS", "pixel-store", "glGetIntegerv()"), new GLproperty(3332, "GL_PACK_SKIP_PIXELS", "Value of GL_PACK_SKIP_PIXELS", "pixel-store", "glGetIntegerv()"), new GLproperty(3333, "GL_PACK_ALIGNMENT", "Value of GL_PACK_ALIGNMENT", "pixel-store", "glGetIntegerv()"), new GLproperty(3344, "GL_MAP_COLOR", "True if colors are mapped", "pixel", "glGetBooleanv()"), new GLproperty(3345, "GL_MAP_STENCIL", "True if stencil values are mapped", "pixel", "glGetBooleanv()"), new GLproperty(3346, "GL_INDEX_SHIFT", "Value of GL_INDEX_SHIFT", "pixel", "glGetIntegerv()"), new GLproperty(3347, "GL_INDEX_OFFSET", "Value of GL_INDEX_OFFSET", "pixel", "glGetIntegerv()"), new GLproperty(3350, "GL_ZOOM_X", "x zoom factor", "pixel", "glGetFloatv()"), new GLproperty(3351, "GL_ZOOM_Y", "y zoom factor", "pixel", "glGetFloatv()"), new GLproperty(3074, "GL_READ_BUFFER", "Read source buffer", "pixel", "glGetIntegerv()"), new GLproperty(2561, "GL_ORDER", "1D map order", "capability", "glGetMapiv()"), new GLproperty(2561, "GL_ORDER", "2D map orders", "capability", "glGetMapiv()"), new GLproperty(2560, "GL_COEFF", "1D control points", "capability", "glGetMapfv()"), new GLproperty(2560, "GL_COEFF", "2D control points", "capability", "glGetMapfv()"), new GLproperty(2562, "GL_DOMAIN", "1D domain endpoints", "capability", "glGetMapfv()"), new GLproperty(2562, "GL_DOMAIN", "2D domain endpoints", "capability", "glGetMapfv()"), new GLproperty(3536, "GL_MAP1_GRID_DOMAIN", "1D grid endpoints", "eval", "glGetFloatv()"), new GLproperty(3538, "GL_MAP2_GRID_DOMAIN", "2D grid endpoints", "eval", "glGetFloatv()"), new GLproperty(3537, "GL_MAP1_GRID_SEGMENTS", "1D grid divisions", "eval", "glGetFloatv()"), new GLproperty(3539, "GL_MAP2_GRID_SEGMENTS", "2D grid divisions", "eval", "glGetFloatv()"), new GLproperty(3456, "GL_AUTO_NORMAL", "True if automatic normal generation enabled", "eval", "glIsEnabled()"), new GLproperty(3152, "GL_PERSPECTIVE_CORRECTION_HINT", "Perspective correction hint", "hint", "glGetIntegerv()"), new GLproperty(3153, "GL_POINT_SMOOTH_HINT", "Point smooth hint", "hint", "glGetIntegerv()"), new GLproperty(3154, "GL_LINE_SMOOTH_HINT", "Line smooth hint", "hint", "glGetIntegerv()"), new GLproperty(3155, "GL_POLYGON_SMOOTH_HINT", "Polygon smooth hint", "hint", "glGetIntegerv()"), new GLproperty(3156, "GL_FOG_HINT", "Fog hint", "hint", "glGetIntegerv()"), new GLproperty(3377, "GL_MAX_LIGHTS", "Maximum number of lights", "capability", "glGetIntegerv()"), new GLproperty(3378, "GL_MAX_CLIP_PLANES", "Maximum number of user clipping planes", "capability", "glGetIntegerv()"), new GLproperty(3382, "GL_MAX_MODELVIEW_STACK_DEPTH", "Maximum modelview-matrix stack depth", "capability", "glGetIntegerv()"), new GLproperty(3384, "GL_MAX_PROJECTION_STACK_DEPTH", "Maximum projection-matrix stack depth", "capability", "glGetIntegerv()"), new GLproperty(3385, "GL_MAX_TEXTURE_STACK_DEPTH", "Maximum depth of texture matrix stack", "capability", "glGetIntegerv()"), new GLproperty(3408, "GL_SUBPIXEL_BITS", "Number of bits of subpixel precision in x and y", "capability", "glGetIntegerv()"), new GLproperty(3379, "GL_MAX_TEXTURE_SIZE", "See discussion in Texture Proxy in Chapter 9", "capability", "glGetIntegerv()"), new GLproperty(3380, "GL_MAX_PIXEL_MAP_TABLE", "Maximum size of a glPixelMap() translation table", "capability", "glGetIntegerv()"), new GLproperty(3383, "GL_MAX_NAME_STACK_DEPTH", "Maximum selection-name stack depth", "capability", "glGetIntegerv()"), new GLproperty(2865, "GL_MAX_LIST_NESTING", "Maximum display-list call nesting", "capability", "glGetIntegerv()"), new GLproperty(3376, "GL_MAX_EVAL_ORDER", "Maximum evaluator polynomial order", "capability", "glGetIntegerv()"), new GLproperty(3386, "GL_MAX_VIEWPORT_DIMS", "Maximum viewport dimensions", "capability", "glGetIntegerv()"), new GLproperty(3381, "GL_MAX_ATTRIB_STACK_DEPTH", "Maximum depth of the attribute stack", "capability", "glGetIntegerv()"), new GLproperty(3387, "GL_MAX_CLIENT_ATTRIB_STACK_DEPTH", "Maximum depth of the client attribute stack", "capability", "glGetIntegerv()"), new GLproperty(3072, "GL_AUX_BUFFERS", "Number of auxiliary buffers", "capability", "glGetBooleanv()"), new GLproperty(3121, "GL_RGBA_MODE", "True if color buffers store RGBA", "capability", "glGetBooleanv()"), new GLproperty(3120, "GL_INDEX_MODE", "True if color buffers store indices", "capability", "glGetBooleanv()"), new GLproperty(3122, "GL_DOUBLEBUFFER", "True if front and back buffers exist", "capability", "glGetBooleanv()"), new GLproperty(3123, "GL_STEREO", "True if left and right buffers exist", "capability", "glGetBooleanv()"), new GLproperty(2834, "GL_POINT_SIZE_RANGE", "Range (low to high) of antialiased point sizes", "capability", "glGetFloatv()"), new GLproperty(2835, "GL_POINT_SIZE_GRANULARITY", "Antialiased point-size granularity", "capability", "glGetFloatv()"), new GLproperty(2850, "GL_LINE_WIDTH_RANGE", "Range (low to high) of antialiased line widths", "capability", "glGetFloatv()"), new GLproperty(2851, "GL_LINE_WIDTH_GRANULARITY", "Antialiased line-width granularity", "capability", "glGetFloatv()"), new GLproperty(3410, "GL_RED_BITS", "Number of bits per red component in color buffers", "capability", "glGetIntegerv()"), new GLproperty(3411, "GL_GREEN_BITS", "Number of bits per green component in color buffers", "capability", "glGetIntegerv()"), new GLproperty(3412, "GL_BLUE_BITS", "Number of bits per blue component in color buffers", "capability", "glGetIntegerv()"), new GLproperty(3413, "GL_ALPHA_BITS", "Number of bits per alpha component in color buffers", "capability", "glGetIntegerv()"), new GLproperty(3409, "GL_INDEX_BITS", "Number of bits per index in color buffers", "capability", "glGetIntegerv()"), new GLproperty(3414, "GL_DEPTH_BITS", "Number of depth-buffer bitplanes", "capability", "glGetIntegerv()"), new GLproperty(3415, "GL_STENCIL_BITS", "Number of stencil bitplanes", "capability", "glGetIntegerv()"), new GLproperty(3416, "GL_ACCUM_RED_BITS", "Number of bits per red component in the accumulation buffer", "capability", "glGetIntegerv()"), new GLproperty(3417, "GL_ACCUM_GREEN_BITS", "Number of bits per green component in the accumulation buffer", "capability", "glGetIntegerv()"), new GLproperty(3418, "GL_ACCUM_BLUE_BITS", "Number of bits per blue component in the accumulation buffer", "capability", "glGetIntegerv()"), new GLproperty(3419, "GL_ACCUM_ALPHA_BITS", "Number of bits per alpha component in the accumulation buffer", "capability", "glGetIntegerv()"), new GLproperty(2866, "GL_LIST_BASE", "Setting of glListBase()", "list", "glGetIntegerv()"), new GLproperty(2867, "GL_LIST_INDEX", "Number of display list under construction; 0 if none", "current", "glGetIntegerv()"), new GLproperty(2864, "GL_LIST_MODE", "Mode of display list under construction; undefined if none", "current", "glGetIntegerv()"), new GLproperty(2992, "GL_ATTRIB_STACK_DEPTH", "Attribute stack pointer", "current", "glGetIntegerv()"), new GLproperty(2993, "GL_CLIENT_ATTRIB_STACK_DEPTH", "Client attribute stack pointer", "current", "glGetIntegerv()"), new GLproperty(3440, "GL_NAME_STACK_DEPTH", "Name stack depth", "current", "glGetIntegerv()"), new GLproperty(3136, "GL_RENDER_MODE", "glRenderMode() setting", "current", "glGetIntegerv()"), new GLproperty(3571, "GL_SELECTION_BUFFER_POINTER", "Pointer to selection buffer", "select", "glGetPointerv()"), new GLproperty(3572, "GL_SELECTION_BUFFER_SIZE", "Size of selection buffer", "select", "glGetIntegerv()"), new GLproperty(3568, "GL_FEEDBACK_BUFFER_POINTER", "Pointer to feedback buffer", "feedback", "glGetPointerv()"), new GLproperty(3569, "GL_FEEDBACK_BUFFER_SIZE", "Size of feedback buffer", "feedback", "glGetIntegerv()"), new GLproperty(3570, "GL_FEEDBACK_BUFFER_TYPE", "Type of feedback buffer", "feedback", "glGetIntegerv()")};
+ public GLproperty[] propertyList = {new GLproperty(2816, "GL_CURRENT_COLOR", "Current color", "current", "glGetFloatv()"), new GLproperty(2817, "GL_CURRENT_INDEX", "Current color index", "current", "glGetFloatv()"), new GLproperty(2819, "GL_CURRENT_TEXTURE_COORDS", "Current texture coordinates", "current", "glGetFloatv()"), new GLproperty(2818, "GL_CURRENT_NORMAL", "Current normal", "current", "glGetFloatv()"), new GLproperty(2823, "GL_CURRENT_RASTER_POSITION", "Current raster position", "current", "glGetFloatv()"), new GLproperty(2825, "GL_CURRENT_RASTER_DISTANCE", "Current raster distance", "current", "glGetFloatv()"), new GLproperty(2820, "GL_CURRENT_RASTER_COLOR", "Color associated with raster position", "current", "glGetFloatv()"), new GLproperty(2821, "GL_CURRENT_RASTER_INDEX", "Color index associated with raster position", "current", "glGetFloatv()"), new GLproperty(2822, "GL_CURRENT_RASTER_TEXTURE_COORDS", "Texture coordinates associated with raster position", "current", "glGetFloatv()"), new GLproperty(2824, "GL_CURRENT_RASTER_POSITION_VALID", "Raster position valid bit", "current", "glGetBooleanv()"), new GLproperty(2883, "GL_EDGE_FLAG", "Edge flag", "current", "glGetBooleanv()"), new GLproperty(32884, "GL_VERTEX_ARRAY", "Vertex array enable", "vertex-array", "glIsEnabled()"), new GLproperty(32890, "GL_VERTEX_ARRAY_SIZE", "Coordinates per vertex", "vertex-array", "glGetIntegerv()"), new GLproperty(32891, "GL_VERTEX_ARRAY_TYPE", "Type of vertex coordinates", "vertex-array", "glGetIntegerv()"), new GLproperty(32892, "GL_VERTEX_ARRAY_STRIDE", "Stride between vertices", "vertex-array", "glGetIntegerv()"), new GLproperty(32910, "GL_VERTEX_ARRAY_POINTER", "Pointer to the vertex array", "vertex-array", "glGetPointerv()"), new GLproperty(32885, "GL_NORMAL_ARRAY", "Normal array enable", "vertex-array", "glIsEnabled()"), new GLproperty(32894, "GL_NORMAL_ARRAY_TYPE", "Type of normal coordinates", "vertex-array", "glGetIntegerv()"), new GLproperty(32895, "GL_NORMAL_ARRAY_STRIDE", "Stride between normals", "vertex-array", "glGetIntegerv()"), new GLproperty(32911, "GL_NORMAL_ARRAY_POINTER", "Pointer to the normal array", "vertex-array", "glGetPointerv()"), new GLproperty(32886, "GL_COLOR_ARRAY", "RGBA color array enable", "vertex-array", "glIsEnabled()"), new GLproperty(32897, "GL_COLOR_ARRAY_SIZE", "Colors per vertex", "vertex-array", "glGetIntegerv()"), new GLproperty(32898, "GL_COLOR_ARRAY_TYPE", "Type of color components", "vertex-array", "glGetIntegerv()"), new GLproperty(32899, "GL_COLOR_ARRAY_STRIDE", "Stride between colors", "vertex-array", "glGetIntegerv()"), new GLproperty(32912, "GL_COLOR_ARRAY_POINTER", "Pointer to the color array", "vertex-array", "glGetPointerv()"), new GLproperty(32887, "GL_INDEX_ARRAY", "Color-index array enable", "vertex-array", "glIsEnabled()"), new GLproperty(32901, "GL_INDEX_ARRAY_TYPE", "Type of color indices", "vertex-array", "glGetIntegerv()"), new GLproperty(32902, "GL_INDEX_ARRAY_STRIDE", "Stride between color indices", "vertex-array", "glGetIntegerv()"), new GLproperty(32913, "GL_INDEX_ARRAY_POINTER", "Pointer to the index array", "vertex-array", "glGetPointerv()"), new GLproperty(32888, "GL_TEXTURE_COORD_ARRAY", "Texture coordinate array enable", "vertex-array", "glIsEnabled()"), new GLproperty(32904, "GL_TEXTURE_COORD_ARRAY_SIZE", "Texture coordinates per element", "vertex-array", "glGetIntegerv()"), new GLproperty(32905, "GL_TEXTURE_COORD_ARRAY_TYPE", "Type of texture coordinates", "vertex-array", "glGetIntegerv()"), new GLproperty(32906, "GL_TEXTURE_COORD_ARRAY_STRIDE", "Stride between texture coordinates", "vertex-array", "glGetIntegerv()"), new GLproperty(32914, "GL_TEXTURE_COORD_ARRAY_POINTER", "Pointer to the texture coordinate array", "vertex-array", "glGetPointerv()"), new GLproperty(32889, "GL_EDGE_FLAG_ARRAY", "Edge flag array enable", "vertex-array", "glIsEnabled()"), new GLproperty(32908, "GL_EDGE_FLAG_ARRAY_STRIDE", "Stride between edge flags", "vertex-array", "glGetIntegerv()"), new GLproperty(32915, "GL_EDGE_FLAG_ARRAY_POINTER", "Pointer to the edge flag array", "vertex-array", "glGetPointerv()"), new GLproperty(2982, "GL_MODELVIEW_MATRIX", "Modelview matrix stack", "matrix", "glGetFloatv()"), new GLproperty(2983, "GL_PROJECTION_MATRIX", "Projection matrix stack", "matrix", "glGetFloatv()"), new GLproperty(2984, "GL_TEXTURE_MATRIX", "Texture matrix stack", "matrix", "glGetFloatv()"), new GLproperty(2978, "GL_VIEWPORT", "Viewport origin and extent", "viewport", "glGetIntegerv()"), new GLproperty(2928, "GL_DEPTH_RANGE", "Depth range near and far", "viewport", "glGetFloatv()"), new GLproperty(2979, "GL_MODELVIEW_STACK_DEPTH", "Modelview matrix stack pointer", "matrix", "glGetIntegerv()"), new GLproperty(2980, "GL_PROJECTION_STACK_DEPTH", "Projection matrix stack pointer", "matrix", "glGetIntegerv()"), new GLproperty(2981, "GL_TEXTURE_STACK_DEPTH", "Texture matrix stack pointer", "matrix", "glGetIntegerv()"), new GLproperty(2976, "GL_MATRIX_MODE", "Current matrix mode", "transform", "glGetIntegerv()"), new GLproperty(2977, "GL_NORMALIZE", "Current normal normalization on/off", "transform/ enable", "glIsEnabled()"), new GLproperty(2918, "GL_FOG_COLOR", "Fog color", "fog", "glGetFloatv()"), new GLproperty(2913, "GL_FOG_INDEX", "Fog index", "fog", "glGetFloatv()"), new GLproperty(2914, "GL_FOG_DENSITY", "Exponential fog density", "fog", "glGetFloatv()"), new GLproperty(2915, "GL_FOG_START", "Linear fog start", "fog", "glGetFloatv()"), new GLproperty(2916, "GL_FOG_END", "Linear fog end", "fog", "glGetFloatv()"), new GLproperty(2917, "GL_FOG_MODE", "Fog mode", "fog", "glGetIntegerv()"), new GLproperty(2912, "GL_FOG", "True if fog enabled", "fog/enable", "glIsEnabled()"), new GLproperty(2900, "GL_SHADE_MODEL", "glShadeModel() setting", "lighting", "glGetIntegerv()"), new GLproperty(2896, "GL_LIGHTING", "True if lighting is enabled", "lighting/e nable", "glIsEnabled()"), new GLproperty(2903, "GL_COLOR_MATERIAL", "True if color tracking is enabled", "lighting", "glIsEnabled()"), new GLproperty(2902, "GL_COLOR_MATERIAL_PARAMETER", "Material properties tracking current color", "lighting", "glGetIntegerv()"), new GLproperty(2901, "GL_COLOR_MATERIAL_FACE", "Face(s) affected by color tracking", "lighting", "glGetIntegerv()"), new GLproperty(4608, "GL_AMBIENT", "Ambient material color", "lighting", "glGetMaterialfv()"), new GLproperty(4609, "GL_DIFFUSE", "Diffuse material color", "lighting", "glGetMaterialfv()"), new GLproperty(4610, "GL_SPECULAR", "Specular material color", "lighting", "glGetMaterialfv()"), new GLproperty(5632, "GL_EMISSION", "Emissive material color", "lighting", "glGetMaterialfv()"), new GLproperty(5633, "GL_SHININESS", "Specular exponent of material", "lighting", "glGetMaterialfv()"), new GLproperty(2899, "GL_LIGHT_MODEL_AMBIENT", "Ambient scene color", "lighting", "glGetFloatv()"), new GLproperty(2897, "GL_LIGHT_MODEL_LOCAL_VIEWER", "Viewer is local", "lighting", "glGetBooleanv()"), new GLproperty(2898, "GL_LIGHT_MODEL_TWO_SIDE", "Use two-sided lighting", "lighting", "glGetBooleanv()"), new GLproperty(4608, "GL_AMBIENT", "Ambient intensity of light i", "lighting", "glGetLightfv()"), new GLproperty(4609, "GL_DIFFUSE", "Diffuse intensity of light i", "lighting", "glGetLightfv()"), new GLproperty(4610, "GL_SPECULAR", "Specular intensity of light i", "lighting", "glGetLightfv()"), new GLproperty(4611, "GL_POSITION", "Position of light i", "lighting", "glGetLightfv()"), new GLproperty(4615, "GL_CONSTANT_ATTENUATION", "Constant attenuation factor", "lighting", "glGetLightfv()"), new GLproperty(4616, "GL_LINEAR_ATTENUATION", "Linear attenuation factor", "lighting", "glGetLightfv()"), new GLproperty(4617, "GL_QUADRATIC_ATTENUATION", "Quadratic attenuation factor", "lighting", "glGetLightfv()"), new GLproperty(4612, "GL_SPOT_DIRECTION", "Spotlight direction of light i", "lighting", "glGetLightfv()"), new GLproperty(4613, "GL_SPOT_EXPONENT", "Spotlight exponent of light i", "lighting", "glGetLightfv()"), new GLproperty(4614, "GL_SPOT_CUTOFF", "Spotlight angle of light i", "lighting", "glGetLightfv()"), new GLproperty(16384, "GL_LIGHT0", "True if light 0 enabled", "lighting/enable", "glIsEnabled()"), new GLproperty(16385, "GL_LIGHT1", "True if light 1 enabled", "lighting/enable", "glIsEnabled()"), new GLproperty(16386, "GL_LIGHT2", "True if light 2 enabled", "lighting/enable", "glIsEnabled()"), new GLproperty(16387, "GL_LIGHT3", "True if light 3 enabled", "lighting/enable", "glIsEnabled()"), new GLproperty(16388, "GL_LIGHT4", "True if light 4 enabled", "lighting/enable", "glIsEnabled()"), new GLproperty(16389, "GL_LIGHT5", "True if light 5 enabled", "lighting/enable", "glIsEnabled()"), new GLproperty(16390, "GL_LIGHT6", "True if light 6 enabled", "lighting/enable", "glIsEnabled()"), new GLproperty(16391, "GL_LIGHT7", "True if light 7 enabled", "lighting/enable", "glIsEnabled()"), new GLproperty(5635, "GL_COLOR_INDEXES", "ca, cd, and cs for color-index lighting", "lighting/e nable", "glGetMaterialfv()"), new GLproperty(2833, "GL_POINT_SIZE", "Point size", "point", "glGetFloatv()"), new GLproperty(2832, "GL_POINT_SMOOTH", "Point antialiasing on", "point/enable", "glIsEnabled()"), new GLproperty(2849, "GL_LINE_WIDTH", "Line width", "line", "glGetFloatv()"), new GLproperty(2848, "GL_LINE_SMOOTH", "Line antialiasing on", "line/enable", "glIsEnabled()"), new GLproperty(2853, "GL_LINE_STIPPLE_PATTERN", "Line stipple", "line", "glGetIntegerv()"), new GLproperty(2854, "GL_LINE_STIPPLE_REPEAT", "Line stipple repeat", "line", "glGetIntegerv()"), new GLproperty(2852, "GL_LINE_STIPPLE", "Line stipple enable", "line/enable", "glIsEnabled()"), new GLproperty(2884, "GL_CULL_FACE", "Polygon culling enabled", "polygon/enable", "glIsEnabled()"), new GLproperty(2885, "GL_CULL_FACE_MODE", "Cull front-/back-facing polygons", "polygon", "glGetIntegerv()"), new GLproperty(2886, "GL_FRONT_FACE", "Polygon front-face CW/CCW indicator", "polygon", "glGetIntegerv()"), new GLproperty(2881, "GL_POLYGON_SMOOTH", "Polygon antialiasing on", "polygon/enable", "glIsEnabled()"), new GLproperty(2880, "GL_POLYGON_MODE", "Polygon rasterization mode (front and back)", "polygon", "glGetIntegerv()"), new GLproperty(32824, "GL_POLYGON_OFFSET_FACTOR", "Polygon offset factor", "polygon", "glGetFloatv()"), new GLproperty(10753, "GL_POLYGON_OFFSET_POINT", "Polygon offset enable for GL_POINT mode rasterization", "polygon/enable", "glIsEnabled()"), new GLproperty(10754, "GL_POLYGON_OFFSET_LINE", "Polygon offset enable for GL_LINE mode rasterization", "polygon/enable", "glIsEnabled()"), new GLproperty(32823, "GL_POLYGON_OFFSET_FILL", "Polygon offset enable for GL_FILL mode rasterization", "polygon/enable", "glIsEnabled()"), new GLproperty(2882, "GL_POLYGON_STIPPLE", "Polygon stipple enable", "polygon/enable", "glIsEnabled()"), new GLproperty(3552, "GL_TEXTURE_1D", "True if 1-D texturing enabled ", "texture/enable", "glIsEnabled()"), new GLproperty(3553, "GL_TEXTURE_2D", "True if 2-D texturing enabled ", "texture/enable", "glIsEnabled()"), new GLproperty(32872, "GL_TEXTURE_BINDING_1D", "Texture object bound to GL_TEXTURE_1D", "texture", "glGetIntegerv()"), new GLproperty(32873, "GL_TEXTURE_BINDING_2D", "Texture object bound to GL_TEXTURE_2D", "texture", "glGetIntegerv()"), new GLproperty(5890, "GL_TEXTURE", "x-D texture image at level of detail i", "UNUSED", "glGetTexImage()"), new GLproperty(4096, "GL_TEXTURE_WIDTH", "x-D texture image i's width", "UNUSED", "glGetTexLevelParameter*()"), new GLproperty(4097, "GL_TEXTURE_HEIGHT", "x-D texture image i's height", "UNUSED", "glGetTexLevelParameter*()"), new GLproperty(4101, "GL_TEXTURE_BORDER", "x-D texture image i's border width", "UNUSED", "glGetTexLevelParameter*()"), new GLproperty(32860, "GL_TEXTURE_RED_SIZE", "x-D texture image i's red resolution", "UNUSED", "glGetTexLevelParameter*()"), new GLproperty(32861, "GL_TEXTURE_GREEN_SIZE", "x-D texture image i's green resolution", "UNUSED", "glGetTexLevelParameter*()"), new GLproperty(32862, "GL_TEXTURE_BLUE_SIZE", "x-D texture image i's blue resolution", "UNUSED", "glGetTexLevelParameter*()"), new GLproperty(32863, "GL_TEXTURE_ALPHA_SIZE", "x-D texture image i's alpha resolution", "UNUSED", "glGetTexLevelParameter*()"), new GLproperty(32864, "GL_TEXTURE_LUMINANCE_SIZE", "x-D texture image i's luminance resolution", "UNUSED", "glGetTexLevelParameter*()"), new GLproperty(32865, "GL_TEXTURE_INTENSITY_SIZE", "x-D texture image i's intensity resolution", "UNUSED", "glGetTexLevelParameter*()"), new GLproperty(4100, "GL_TEXTURE_BORDER_COLOR", "Texture border color", "texture", "glGetTexParameter*()"), new GLproperty(10241, "GL_TEXTURE_MIN_FILTER", "Texture minification function", "texture", "glGetTexParameter*()"), new GLproperty(10240, "GL_TEXTURE_MAG_FILTER", "Texture magnification function", "texture", "glGetTexParameter*()"), new GLproperty(10242, "GL_TEXTURE_WRAP_S", "Texture wrap mode (x is S or T)", "texture", "glGetTexParameter*()"), new GLproperty(10243, "GL_TEXTURE_WRAP_T", "Texture wrap mode (x is S or T)", "texture", "glGetTexParameter*()"), new GLproperty(32870, "GL_TEXTURE_PRIORITY", "Texture object priority", "texture", "glGetTexParameter*()"), new GLproperty(8704, "GL_TEXTURE_ENV_MODE", "Texture application function", "texture", "glGetTexEnviv()"), new GLproperty(8705, "GL_TEXTURE_ENV_COLOR", "Texture environment color", "texture", "glGetTexEnvfv()"), new GLproperty(3168, "GL_TEXTURE_GEN_S", "Texgen enabled (x is S, T, R, or Q)", "texture/enable", "glIsEnabled()"), new GLproperty(3169, "GL_TEXTURE_GEN_T", "Texgen enabled (x is S, T, R, or Q)", "texture/enable", "glIsEnabled()"), new GLproperty(3170, "GL_TEXTURE_GEN_R", "Texgen enabled (x is S, T, R, or Q)", "texture/enable", "glIsEnabled()"), new GLproperty(3171, "GL_TEXTURE_GEN_Q", "Texgen enabled (x is S, T, R, or Q)", "texture/enable", "glIsEnabled()"), new GLproperty(9474, "GL_EYE_PLANE", "Texgen plane equation coefficients", "texture", "glGetTexGenfv()"), new GLproperty(9473, "GL_OBJECT_PLANE", "Texgen object linear coefficients", "texture", "glGetTexGenfv()"), new GLproperty(9472, "GL_TEXTURE_GEN_MODE", "Function used for texgen", "texture", "glGetTexGeniv()"), new GLproperty(3089, "GL_SCISSOR_TEST", "Scissoring enabled", "scissor/enable", "glIsEnabled()"), new GLproperty(3088, "GL_SCISSOR_BOX", "Scissor box", "scissor", "glGetIntegerv()"), new GLproperty(3008, "GL_ALPHA_TEST", "Alpha test enabled", "color-buffer/enable", "glIsEnabled()"), new GLproperty(3009, "GL_ALPHA_TEST_FUNC", "Alpha test function", "color-buffer", "glGetIntegerv()"), new GLproperty(3010, "GL_ALPHA_TEST_REF", "Alpha test reference value", "color-buffer", "glGetIntegerv()"), new GLproperty(2960, "GL_STENCIL_TEST", "Stenciling enabled", "stencil-buffer/enable", "glIsEnabled()"), new GLproperty(2962, "GL_STENCIL_FUNC", "Stencil function", "stencil-buffer", "glGetIntegerv()"), new GLproperty(2963, "GL_STENCIL_VALUE_MASK", "Stencil mask", "stencil-buffer", "glGetIntegerv()"), new GLproperty(2967, "GL_STENCIL_REF", "Stencil reference value", "stencil-buffer", "glGetIntegerv()"), new GLproperty(2964, "GL_STENCIL_FAIL", "Stencil fail action", "stencil-buffer", "glGetIntegerv()"), new GLproperty(2965, "GL_STENCIL_PASS_DEPTH_FAIL", "Stencil depth buffer fail action", "stencil-buffer", "glGetIntegerv()"), new GLproperty(2966, "GL_STENCIL_PASS_DEPTH_PASS", "Stencil depth buffer pass action", "stencil-buffer", "glGetIntegerv()"), new GLproperty(2929, "GL_DEPTH_TEST", "Depth buffer enabled", "depth-buffer/ena ble", "glIsEnabled()"), new GLproperty(2932, "GL_DEPTH_FUNC", "Depth buffer test function", "depth-buffer", "glGetIntegerv()"), new GLproperty(3042, "GL_BLEND", "Blending enabled", "color-buffer/enable", "glIsEnabled()"), new GLproperty(3041, "GL_BLEND_SRC", "Blending source function", "color-buffer", "glGetIntegerv()"), new GLproperty(3040, "GL_BLEND_DST", "Blending destination function", "color-buffer", "glGetIntegerv()"), new GLproperty(3024, "GL_DITHER", "Dithering enabled", "color-buffer/enable", "glIsEnabled()"), new GLproperty(3057, "GL_INDEX_LOGIC_OP", "Color index logical operation enabled", "color-buffer/enable", "glIsEnabled()"), new GLproperty(3058, "GL_COLOR_LOGIC_OP", "RGBA color logical operation enabled", "color-buffer/enable", "glIsEnabled()"), new GLproperty(3056, "GL_LOGIC_OP_MODE", "Logical operation function", "color-buffer", "glGetIntegerv()"), new GLproperty(3073, "GL_DRAW_BUFFER", "Buffers selected for drawing", "color-buffer", "glGetIntegerv()"), new GLproperty(3105, "GL_INDEX_WRITEMASK", "Color-index writemask", "color-buffer", "glGetIntegerv()"), new GLproperty(3107, "GL_COLOR_WRITEMASK", "Color write enables; R, G, B, or A", "color-buffer", "glGetBooleanv()"), new GLproperty(2930, "GL_DEPTH_WRITEMASK", "Depth buffer enabled for writing", "depth-buffer", "glGetBooleanv()"), new GLproperty(2968, "GL_STENCIL_WRITEMASK", "Stencil-buffer writemask", "stencil-buffer", "glGetIntegerv()"), new GLproperty(3106, "GL_COLOR_CLEAR_VALUE", "Color-buffer clear value (RGBA mode)", "color-buffer", "glGetFloatv()"), new GLproperty(3104, "GL_INDEX_CLEAR_VALUE", "Color-buffer clear value (color-index mode)", "color-buffer", "glGetFloatv()"), new GLproperty(2931, "GL_DEPTH_CLEAR_VALUE", "Depth-buffer clear value", "depth-buffer", "glGetIntegerv()"), new GLproperty(2961, "GL_STENCIL_CLEAR_VALUE", "Stencil-buffer clear value", "stencil-buffer", "glGetIntegerv()"), new GLproperty(2944, "GL_ACCUM_CLEAR_VALUE", "Accumulation-buffer clear value", "accum-buffer", "glGetFloatv()"), new GLproperty(3312, "GL_UNPACK_SWAP_BYTES", "Value of GL_UNPACK_SWAP_BYTES", "pixel-store", "glGetBooleanv()"), new GLproperty(3313, "GL_UNPACK_LSB_FIRST", "Value of GL_UNPACK_LSB_FIRST", "pixel-store", "glGetBooleanv()"), new GLproperty(3314, "GL_UNPACK_ROW_LENGTH", "Value of GL_UNPACK_ROW_LENGTH", "pixel-store", "glGetIntegerv()"), new GLproperty(3315, "GL_UNPACK_SKIP_ROWS", "Value of GL_UNPACK_SKIP_ROWS", "pixel-store", "glGetIntegerv()"), new GLproperty(3316, "GL_UNPACK_SKIP_PIXELS", "Value of GL_UNPACK_SKIP_PIXELS", "pixel-store", "glGetIntegerv()"), new GLproperty(3317, "GL_UNPACK_ALIGNMENT", "Value of GL_UNPACK_ALIGNMENT", "pixel-store", "glGetIntegerv()"), new GLproperty(3328, "GL_PACK_SWAP_BYTES", "Value of GL_PACK_SWAP_BYTES", "pixel-store", "glGetBooleanv()"), new GLproperty(3329, "GL_PACK_LSB_FIRST", "Value of GL_PACK_LSB_FIRST", "pixel-store", "glGetBooleanv()"), new GLproperty(3330, "GL_PACK_ROW_LENGTH", "Value of GL_PACK_ROW_LENGTH", "pixel-store", "glGetIntegerv()"), new GLproperty(3331, "GL_PACK_SKIP_ROWS", "Value of GL_PACK_SKIP_ROWS", "pixel-store", "glGetIntegerv()"), new GLproperty(3332, "GL_PACK_SKIP_PIXELS", "Value of GL_PACK_SKIP_PIXELS", "pixel-store", "glGetIntegerv()"), new GLproperty(3333, "GL_PACK_ALIGNMENT", "Value of GL_PACK_ALIGNMENT", "pixel-store", "glGetIntegerv()"), new GLproperty(3344, "GL_MAP_COLOR", "True if colors are mapped", "pixel", "glGetBooleanv()"), new GLproperty(3345, "GL_MAP_STENCIL", "True if stencil values are mapped", "pixel", "glGetBooleanv()"), new GLproperty(3346, "GL_INDEX_SHIFT", "Value of GL_INDEX_SHIFT", "pixel", "glGetIntegerv()"), new GLproperty(3347, "GL_INDEX_OFFSET", "Value of GL_INDEX_OFFSET", "pixel", "glGetIntegerv()"), new GLproperty(3350, "GL_ZOOM_X", "x zoom factor", "pixel", "glGetFloatv()"), new GLproperty(3351, "GL_ZOOM_Y", "y zoom factor", "pixel", "glGetFloatv()"), new GLproperty(3074, "GL_READ_BUFFER", "Read source buffer", "pixel", "glGetIntegerv()"), new GLproperty(2561, "GL_ORDER", "1D map order", "capability", "glGetMapiv()"), new GLproperty(2561, "GL_ORDER", "2D map orders", "capability", "glGetMapiv()"), new GLproperty(2560, "GL_COEFF", "1D control points", "capability", "glGetMapfv()"), new GLproperty(2560, "GL_COEFF", "2D control points", "capability", "glGetMapfv()"), new GLproperty(2562, "GL_DOMAIN", "1D domain endpoints", "capability", "glGetMapfv()"), new GLproperty(2562, "GL_DOMAIN", "2D domain endpoints", "capability", "glGetMapfv()"), new GLproperty(3536, "GL_MAP1_GRID_DOMAIN", "1D grid endpoints", "eval", "glGetFloatv()"), new GLproperty(3538, "GL_MAP2_GRID_DOMAIN", "2D grid endpoints", "eval", "glGetFloatv()"), new GLproperty(3537, "GL_MAP1_GRID_SEGMENTS", "1D grid divisions", "eval", "glGetFloatv()"), new GLproperty(3539, "GL_MAP2_GRID_SEGMENTS", "2D grid divisions", "eval", "glGetFloatv()"), new GLproperty(3456, "GL_AUTO_NORMAL", "True if automatic normal generation enabled", "eval", "glIsEnabled()"), new GLproperty(3152, "GL_PERSPECTIVE_CORRECTION_HINT", "Perspective correction hint", "hint", "glGetIntegerv()"), new GLproperty(3153, "GL_POINT_SMOOTH_HINT", "Point smooth hint", "hint", "glGetIntegerv()"), new GLproperty(3154, "GL_LINE_SMOOTH_HINT", "Line smooth hint", "hint", "glGetIntegerv()"), new GLproperty(3155, "GL_POLYGON_SMOOTH_HINT", "Polygon smooth hint", "hint", "glGetIntegerv()"), new GLproperty(3156, "GL_FOG_HINT", "Fog hint", "hint", "glGetIntegerv()"), new GLproperty(3377, "GL_MAX_LIGHTS", "Maximum number of lights", "capability", "glGetIntegerv()"), new GLproperty(3378, "GL_MAX_CLIP_PLANES", "Maximum number of user clipping planes", "capability", "glGetIntegerv()"), new GLproperty(3382, "GL_MAX_MODELVIEW_STACK_DEPTH", "Maximum modelview-matrix stack depth", "capability", "glGetIntegerv()"), new GLproperty(3384, "GL_MAX_PROJECTION_STACK_DEPTH", "Maximum projection-matrix stack depth", "capability", "glGetIntegerv()"), new GLproperty(3385, "GL_MAX_TEXTURE_STACK_DEPTH", "Maximum depth of texture matrix stack", "capability", "glGetIntegerv()"), new GLproperty(3408, "GL_SUBPIXEL_BITS", "Number of bits of subpixel precision in x and y", "capability", "glGetIntegerv()"), new GLproperty(3379, "GL_MAX_TEXTURE_SIZE", "See discussion in Texture Proxy in Chapter 9", "capability", "glGetIntegerv()"), new GLproperty(3380, "GL_MAX_PIXEL_MAP_TABLE", "Maximum size of a glPixelMap() translation table", "capability", "glGetIntegerv()"), new GLproperty(3383, "GL_MAX_NAME_STACK_DEPTH", "Maximum selection-name stack depth", "capability", "glGetIntegerv()"), new GLproperty(2865, "GL_MAX_LIST_NESTING", "Maximum display-list call nesting", "capability", "glGetIntegerv()"), new GLproperty(3376, "GL_MAX_EVAL_ORDER", "Maximum evaluator polynomial order", "capability", "glGetIntegerv()"), new GLproperty(3386, "GL_MAX_VIEWPORT_DIMS", "Maximum viewport dimensions", "capability", "glGetIntegerv()"), new GLproperty(3381, "GL_MAX_ATTRIB_STACK_DEPTH", "Maximum depth of the attribute stack", "capability", "glGetIntegerv()"), new GLproperty(3387, "GL_MAX_CLIENT_ATTRIB_STACK_DEPTH", "Maximum depth of the client attribute stack", "capability", "glGetIntegerv()"), new GLproperty(3072, "GL_AUX_BUFFERS", "Number of auxiliary buffers", "capability", "glGetBooleanv()"), new GLproperty(3121, "GL_RGBA_MODE", "True if color buffers store RGBA", "capability", "glGetBooleanv()"), new GLproperty(3120, "GL_INDEX_MODE", "True if color buffers store indices", "capability", "glGetBooleanv()"), new GLproperty(3122, "GL_DOUBLEBUFFER", "True if front and back buffers exist", "capability", "glGetBooleanv()"), new GLproperty(3123, "GL_STEREO", "True if left and right buffers exist", "capability", "glGetBooleanv()"), new GLproperty(2834, "GL_POINT_SIZE_RANGE", "Range (low to high) of antialiased point sizes", "capability", "glGetFloatv()"), new GLproperty(2835, "GL_POINT_SIZE_GRANULARITY", "Antialiased point-size granularity", "capability", "glGetFloatv()"), new GLproperty(2850, "GL_LINE_WIDTH_RANGE", "Range (low to high) of antialiased line widths", "capability", "glGetFloatv()"), new GLproperty(2851, "GL_LINE_WIDTH_GRANULARITY", "Antialiased line-width granularity", "capability", "glGetFloatv()"), new GLproperty(3410, "GL_RED_BITS", "Number of bits per red component in color buffers", "capability", "glGetIntegerv()"), new GLproperty(3411, "GL_GREEN_BITS", "Number of bits per green component in color buffers", "capability", "glGetIntegerv()"), new GLproperty(3412, "GL_BLUE_BITS", "Number of bits per blue component in color buffers", "capability", "glGetIntegerv()"), new GLproperty(3413, "GL_ALPHA_BITS", "Number of bits per alpha component in color buffers", "capability", "glGetIntegerv()"), new GLproperty(3409, "GL_INDEX_BITS", "Number of bits per index in color buffers", "capability", "glGetIntegerv()"), new GLproperty(3414, "GL_DEPTH_BITS", "Number of depth-buffer bitplanes", "capability", "glGetIntegerv()"), new GLproperty(3415, "GL_STENCIL_BITS", "Number of stencil bitplanes", "capability", "glGetIntegerv()"), new GLproperty(3416, "GL_ACCUM_RED_BITS", "Number of bits per red component in the accumulation buffer", "capability", "glGetIntegerv()"), new GLproperty(3417, "GL_ACCUM_GREEN_BITS", "Number of bits per green component in the accumulation buffer", "capability", "glGetIntegerv()"), new GLproperty(3418, "GL_ACCUM_BLUE_BITS", "Number of bits per blue component in the accumulation buffer", "capability", "glGetIntegerv()"), new GLproperty(3419, "GL_ACCUM_ALPHA_BITS", "Number of bits per alpha component in the accumulation buffer", "capability", "glGetIntegerv()"), new GLproperty(2866, "GL_LIST_BASE", "Setting of glListBase()", "list", "glGetIntegerv()"), new GLproperty(2867, "GL_LIST_INDEX", "Number of display list under construction; 0 if none", "current", "glGetIntegerv()"), new GLproperty(2864, "GL_LIST_MODE", "Mode of display list under construction; undefined if none", "current", "glGetIntegerv()"), new GLproperty(2992, "GL_ATTRIB_STACK_DEPTH", "Attribute stack pointer", "current", "glGetIntegerv()"), new GLproperty(2993, "GL_CLIENT_ATTRIB_STACK_DEPTH", "Client attribute stack pointer", "current", "glGetIntegerv()"), new GLproperty(3440, "GL_NAME_STACK_DEPTH", "Name stack depth", "current", "glGetIntegerv()"), new GLproperty(3136, "GL_RENDER_MODE", "glRenderMode() setting", "current", "glGetIntegerv()"), new GLproperty(3571, "GL_SELECTION_BUFFER_POINTER", "Pointer to selection buffer", "select", "glGetPointerv()"), new GLproperty(3572, "GL_SELECTION_BUFFER_SIZE", "Size of selection buffer", "select", "glGetIntegerv()"), new GLproperty(3568, "GL_FEEDBACK_BUFFER_POINTER", "Pointer to feedback buffer", "feedback", "glGetPointerv()"), new GLproperty(3569, "GL_FEEDBACK_BUFFER_SIZE", "Size of feedback buffer", "feedback", "glGetIntegerv()"), new GLproperty(3570, "GL_FEEDBACK_BUFFER_TYPE", "Type of feedback buffer", "feedback", "glGetIntegerv()")};
public static String dumpOpenGLstate()
{
@@ -26,10 +27,10 @@ public static String dumpOpenGLstate()
for (int i = 0; i < instance.propertyList.length; ++i)
{
- stringbuilder.append(instance.propertyList[i].name + ":");
- stringbuilder.append(GL11.glIsEnabled(instance.propertyList[i].gLconstant) + ":");
+ stringbuilder.append(instance.propertyList[i].name).append(":");
+ stringbuilder.append(GL11C.glIsEnabled(instance.propertyList[i].gLconstant)).append(":");
stringbuilder.append(getPropertyAsString(i));
- stringbuilder.append(" (" + instance.propertyList[i].description + ")\n");
+ stringbuilder.append(" (").append(instance.propertyList[i].description).append(")\n");
}
return stringbuilder.toString();
@@ -65,11 +66,11 @@ public static String dumpAllIsEnabled()
for (int i = 0; i < instance.propertyList.length; ++i)
{
- if (instance.propertyList[i].fetchCommand == "glIsEnabled()")
+ if ("glIsEnabled()".equals(instance.propertyList[i].fetchCommand))
{
- stringbuilder.append(instance.propertyList[i].name + ":");
- stringbuilder.append(GL11.glIsEnabled(instance.propertyList[i].gLconstant));
- stringbuilder.append(" (" + instance.propertyList[i].description + ")\n");
+ stringbuilder.append(instance.propertyList[i].name).append(":");
+ stringbuilder.append(GL11C.glIsEnabled(instance.propertyList[i].gLconstant));
+ stringbuilder.append(" (").append(instance.propertyList[i].description).append(")\n");
}
}
@@ -108,9 +109,9 @@ public static String dumpAllType(String type)
{
if (instance.propertyList[i].category.equals(type))
{
- stringbuilder.append(instance.propertyList[i].name + ":");
+ stringbuilder.append(instance.propertyList[i].name).append(":");
stringbuilder.append(getPropertyAsString(i));
- stringbuilder.append(" (" + instance.propertyList[i].description + ")\n");
+ stringbuilder.append(" (").append(instance.propertyList[i].description).append(")\n");
}
}
@@ -145,56 +146,40 @@ private static String getPropertyAsString(int propertyListIndex)
{
int i = instance.propertyList[propertyListIndex].gLconstant;
- if (instance.propertyList[propertyListIndex].fetchCommand.equals("glIsEnabled()"))
- {
- return "" + GL11.glIsEnabled(i);
- }
- else if (instance.propertyList[propertyListIndex].fetchCommand == "glGetBooleanv()")
- {
- ByteBuffer bytebuffer = BufferUtils.createByteBuffer(16);
- GL11.glGetBooleanv(i, bytebuffer);
- String s2 = "";
-
- for (int l = 0; l < bytebuffer.capacity(); ++l)
- {
- s2 = s2 + (l == 0 ? "" : ", ") + bytebuffer.get(l);
+ return switch (instance.propertyList[propertyListIndex].fetchCommand) {
+ case "glIsEnabled()" -> String.valueOf(GL11C.glIsEnabled(i));
+ case "glGetBooleanv()" -> {
+ ByteBuffer bytebuffer = BufferUtils.createByteBuffer(16);
+ GL11C.glGetBooleanv(i, bytebuffer);
+ String s2 = "";
+ for (int l = 0; l < bytebuffer.capacity(); ++l) {
+ s2 = s2 + (l == 0 ? "" : ", ") + bytebuffer.get(l);
+ }
+ yield s2;
}
-
- return s2;
- }
- else if (instance.propertyList[propertyListIndex].fetchCommand == "glGetIntegerv()")
- {
- IntBuffer intbuffer = BufferUtils.createIntBuffer(16);
- GL11.glGetIntegerv(i, intbuffer);
- String s1 = "";
-
- for (int k = 0; k < intbuffer.capacity(); ++k)
- {
- s1 = s1 + (k == 0 ? "" : ", ") + intbuffer.get(k);
+ case "glGetIntegerv()" -> {
+ IntBuffer intbuffer = BufferUtils.createIntBuffer(16);
+ GL11C.glGetIntegerv(i, intbuffer);
+ String s1 = "";
+ for (int k = 0; k < intbuffer.capacity(); ++k) {
+ s1 = s1 + (k == 0 ? "" : ", ") + intbuffer.get(k);
+ }
+ yield s1;
}
-
- return s1;
- }
- else if (instance.propertyList[propertyListIndex].fetchCommand == "glGetFloatv()")
- {
- FloatBuffer floatbuffer = BufferUtils.createFloatBuffer(16);
- GL11.glGetFloatv(i, floatbuffer);
- String s = "";
-
- for (int j = 0; j < floatbuffer.capacity(); ++j)
- {
- s = s + (j == 0 ? "" : ", ") + floatbuffer.get(j);
+ case "glGetFloatv()" -> {
+ FloatBuffer floatbuffer = BufferUtils.createFloatBuffer(16);
+ GL11C.glGetFloatv(i, floatbuffer);
+ String s = "";
+ for (int j = 0; j < floatbuffer.capacity(); ++j) {
+ s = s + (j == 0 ? "" : ", ") + floatbuffer.get(j);
+ }
+ yield s;
}
-
- return s;
- }
- else
- {
- return "";
- }
+ default -> "";
+ };
}
- public class GLproperty
+ public static class GLproperty
{
public int gLconstant;
public String name;
diff --git a/common/src/main/java/org/vivecraft/client/render/VRPlayerModel.java b/common/src/main/java/org/vivecraft/client/render/VRPlayerModel.java
index c89b7e935..c78555ba9 100644
--- a/common/src/main/java/org/vivecraft/client/render/VRPlayerModel.java
+++ b/common/src/main/java/org/vivecraft/client/render/VRPlayerModel.java
@@ -1,7 +1,11 @@
package org.vivecraft.client.render;
+import org.vivecraft.client.VRPlayersClient;
+import org.vivecraft.client.VRPlayersClient.RotInfo;
+
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
+
import net.minecraft.client.model.PlayerModel;
import net.minecraft.client.model.geom.ModelPart;
import net.minecraft.client.model.geom.PartPose;
@@ -11,13 +15,14 @@
import net.minecraft.client.model.geom.builders.PartDefinition;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
-import org.vivecraft.client.VRPlayersClient;
+
+import static org.joml.Math.*;
public class VRPlayerModel extends PlayerModel
{
private final boolean slim;
public ModelPart vrHMD;
- VRPlayersClient.RotInfo rotInfo;
+ RotInfo rotInfo;
private boolean laying;
public VRPlayerModel(ModelPart modelPart, boolean isSlim)
@@ -27,58 +32,58 @@ public VRPlayerModel(ModelPart modelPart, boolean isSlim)
this.vrHMD = modelPart.getChild("vrHMD");
}
- public static MeshDefinition createMesh(CubeDeformation p_170826_, boolean p_170827_)
+ public static MeshDefinition createMesh(CubeDeformation cubeDeformation, boolean slim)
{
- MeshDefinition meshdefinition = PlayerModel.createMesh(p_170826_, p_170827_);
- PartDefinition partdefinition = meshdefinition.getRoot();
- partdefinition.addOrReplaceChild("vrHMD", CubeListBuilder.create().texOffs(0, 0).addBox(-3.5F, -6.0F, -7.5F, 7.0F, 4.0F, 5.0F, p_170826_), PartPose.ZERO);
- return meshdefinition;
+ MeshDefinition meshdefinition = PlayerModel.createMesh(cubeDeformation, slim);
+ PartDefinition partdefinition = meshdefinition.getRoot();
+ partdefinition.addOrReplaceChild("vrHMD", CubeListBuilder.create().texOffs(0, 0).addBox(-3.5F, -6.0F, -7.5F, 7.0F, 4.0F, 5.0F, cubeDeformation), PartPose.ZERO);
+ return meshdefinition;
}
public void setupAnim(T pEntity, float pLimbSwing, float pLimbSwingAmount, float pAgeInTicks, float pNetHeadYaw, float pHeadPitch)
{
- super.setupAnim(pEntity, pLimbSwing, pLimbSwingAmount, pAgeInTicks, pNetHeadYaw, pHeadPitch);
- this.rotInfo = VRPlayersClient.getInstance().getRotationsForPlayer(((Player)pEntity).getUUID());
- VRPlayersClient.RotInfo rotinfo = VRPlayersClient.getInstance().getRotationsForPlayer(((Player)pEntity).getUUID());
+ super.setupAnim(pEntity, pLimbSwing, pLimbSwingAmount, pAgeInTicks, pNetHeadYaw, pHeadPitch);
+ this.rotInfo = VRPlayersClient.getInstance().getRotationsForPlayer(((Player)pEntity).getUUID());
+ RotInfo rotinfo = VRPlayersClient.getInstance().getRotationsForPlayer(((Player)pEntity).getUUID());
- if (rotinfo == null) return; //how
+ if (rotinfo == null) return; //how
- double d0 = (double)(-1.501F * rotinfo.heightScale);
- float f = (float)Math.toRadians((double)pEntity.getYRot());
- float f1 = (float)Math.atan2(-rotinfo.headRot.x, -rotinfo.headRot.z);
- float f2 = (float)Math.asin(rotinfo.headRot.y / rotinfo.headRot.length());
- double d1 = rotinfo.getBodyYawRadians();
- this.head.xRot = -f2;
- this.head.yRot = (float)(Math.PI - (double)f1 - d1);
- this.laying = this.swimAmount > 0.0F || pEntity.isFallFlying() && !pEntity.isAutoSpinAttack();
+ double d0 = -1.501F * rotinfo.heightScale;
+ float f = toRadians(pEntity.getYRot());
+ float f1 = (float)atan2(-rotinfo.headRot.x, -rotinfo.headRot.z);
+ float f2 = (float)asin(rotinfo.headRot.y / rotinfo.headRot.length());
+ double d1 = rotinfo.getBodyYawRadians();
+ this.head.xRot = -f2;
+ this.head.yRot = (float)(PI - (double)f1 - d1);
+ this.laying = this.swimAmount > 0.0F || pEntity.isFallFlying() && !pEntity.isAutoSpinAttack();
- if (this.laying)
- {
- this.head.z = 0.0F;
- this.head.x = 0.0F;
- this.head.y = -4.0F;
- this.head.xRot = (float)((double)this.head.xRot - (Math.PI / 2D));
- } else if (this.crouching) {
- // move head down when crouching
- this.head.z = 0.0F;
- this.head.x = 0.0F;
- this.head.y = 4.2f;
- }
- else
- {
- this.head.z = 0.0F;
- this.head.x = 0.0F;
- this.head.y = 0.0F;
- }
+ if (this.laying)
+ {
+ this.head.z = 0.0F;
+ this.head.x = 0.0F;
+ this.head.y = -4.0F;
+ this.head.xRot = (float)(this.head.xRot - (PI / 2.0D));
+ } else if (this.crouching) {
+ // move head down when crouching
+ this.head.z = 0.0F;
+ this.head.x = 0.0F;
+ this.head.y = 4.2F;
+ }
+ else
+ {
+ this.head.z = 0.0F;
+ this.head.x = 0.0F;
+ this.head.y = 0.0F;
+ }
- this.vrHMD.visible = true;
+ this.vrHMD.visible = true;
- this.vrHMD.copyFrom(this.head);
+ this.vrHMD.copyFrom(this.head);
this.hat.copyFrom(this.head);
}
- public void renderHMDR(PoseStack poseStack, VertexConsumer vertexConsumer, int i, int noOverlay) {
- this.vrHMD.render(poseStack, vertexConsumer, i, noOverlay);
- }
+ public void renderHMDR(PoseStack poseStack, VertexConsumer vertexConsumer, int i, int noOverlay) {
+ this.vrHMD.render(poseStack, vertexConsumer, i, noOverlay);
+ }
}
diff --git a/common/src/main/java/org/vivecraft/client/render/VRPlayerModel_WithArms.java b/common/src/main/java/org/vivecraft/client/render/VRPlayerModel_WithArms.java
index 2a1d91176..de180cb9b 100644
--- a/common/src/main/java/org/vivecraft/client/render/VRPlayerModel_WithArms.java
+++ b/common/src/main/java/org/vivecraft/client/render/VRPlayerModel_WithArms.java
@@ -1,10 +1,15 @@
package org.vivecraft.client.render;
+import org.vivecraft.client.VRPlayersClient;
+import org.vivecraft.client.VRPlayersClient.RotInfo;
+import org.vivecraft.client.Xplat;
+import org.vivecraft.mod_compat_vr.optifine.OptifineHelper;
+import org.vivecraft.mod_compat_vr.pehkui.PehkuiHelper;
+
import com.google.common.collect.ImmutableList;
+
import com.mojang.blaze3d.vertex.PoseStack;
-import com.mojang.math.Axis;
-import net.minecraft.client.Minecraft;
import net.minecraft.client.model.geom.ModelPart;
import net.minecraft.client.model.geom.ModelPart.Polygon;
import net.minecraft.client.model.geom.ModelPart.Vertex;
@@ -13,249 +18,246 @@
import net.minecraft.client.model.geom.builders.CubeListBuilder;
import net.minecraft.client.model.geom.builders.MeshDefinition;
import net.minecraft.client.model.geom.builders.PartDefinition;
-import net.minecraft.util.Mth;
import net.minecraft.world.entity.HumanoidArm;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.phys.Vec3;
-import org.vivecraft.client.VRPlayersClient;
-import org.vivecraft.mod_compat_vr.optifine.OptifineHelper;
-import org.vivecraft.mod_compat_vr.pehkui.PehkuiHelper;
-import org.vivecraft.client.Xplat;
+
+import static org.vivecraft.client_vr.VRState.mc;
+
+import static org.joml.Math.*;
public class VRPlayerModel_WithArms extends VRPlayerModel
{
- private final boolean slim;
- public ModelPart leftShoulder;
- public ModelPart rightShoulder;
- public ModelPart leftShoulder_sleeve;
- public ModelPart rightShoulder_sleeve;
- public ModelPart leftHand;
- public ModelPart rightHand;
- VRPlayersClient.RotInfo rotInfo;
- private boolean laying;
-
- public VRPlayerModel_WithArms(ModelPart modelPart, boolean isSlim)
- {
- super(modelPart, isSlim);
- this.slim = isSlim;
- // use left/right arm as shoulders
- this.leftShoulder = modelPart.getChild("left_arm");
- this.rightShoulder = modelPart.getChild("right_arm");
- this.leftShoulder_sleeve = modelPart.getChild("leftShoulder_sleeve");
- this.rightShoulder_sleeve = modelPart.getChild("rightShoulder_sleeve");
- this.rightHand = modelPart.getChild("rightHand");
- this.leftHand = modelPart.getChild("leftHand");
-
-
- //finger hax
- // some mods remove the base parts
- if (!leftShoulder.cubes.isEmpty()) {
- copyUV(leftShoulder.cubes.get(0).polygons[1], leftHand.cubes.get(0).polygons[1]);
- copyUV(leftShoulder.cubes.get(0).polygons[1], leftHand.cubes.get(0).polygons[0]);
- }
- if (!rightShoulder.cubes.isEmpty()) {
- copyUV(rightShoulder.cubes.get(0).polygons[1], this.rightHand.cubes.get(0).polygons[1]);
- copyUV(rightShoulder.cubes.get(0).polygons[1], this.rightHand.cubes.get(0).polygons[0]);
- }
-
- if (!rightSleeve.cubes.isEmpty()) {
- copyUV(rightShoulder_sleeve.cubes.get(0).polygons[1], this.rightSleeve.cubes.get(0).polygons[1]);
- copyUV(rightShoulder_sleeve.cubes.get(0).polygons[1], this.rightSleeve.cubes.get(0).polygons[0]);
- }
- if (!leftSleeve.cubes.isEmpty()) {
- copyUV(leftShoulder_sleeve.cubes.get(0).polygons[1], leftSleeve.cubes.get(0).polygons[1]);
- copyUV(leftShoulder_sleeve.cubes.get(0).polygons[1], leftSleeve.cubes.get(0).polygons[0]);
- }
- }
-
- private void copyUV(Polygon source, Polygon dest) {
- for (int i = 0; i < source.vertices.length; i++) {
- dest.vertices[i] = new Vertex(dest.vertices[i].pos, source.vertices[i].u, source.vertices[i].v);
- if (OptifineHelper.isOptifineLoaded()) {
- OptifineHelper.copyRenderPositions(source.vertices[i], dest.vertices[i]);
- }
- }
- }
-
- public static MeshDefinition createMesh(CubeDeformation p_170826_, boolean p_170827_)
- {
- MeshDefinition meshdefinition = VRPlayerModel.createMesh(p_170826_, p_170827_);
- PartDefinition partdefinition = meshdefinition.getRoot();
-
- if(p_170827_) {
- partdefinition.addOrReplaceChild("leftHand", CubeListBuilder.create().texOffs(32, 55).addBox(-1.0F, -2.0F, -2.0F, 3.0F, 5.0F, 4.0F, p_170826_), PartPose.offset(5.0F, 2.5F, 0.0F));
- partdefinition.addOrReplaceChild("left_sleeve", CubeListBuilder.create().texOffs(48, 55).addBox(-1.0F, -2.0F, -2.0F, 3.0F, 5.0F, 4.0F, p_170826_.extend(0.25f)), PartPose.offset(5.0F, 2.5F, 0.0F));
- partdefinition.addOrReplaceChild("rightHand", CubeListBuilder.create().texOffs(40, 23).addBox(-2.0F, -2.0F, -2.0F, 3.0F, 5.0F, 4.0F, p_170826_), PartPose.offset(-5.0F, 2.5F, 0.0F));
- partdefinition.addOrReplaceChild("right_sleeve", CubeListBuilder.create().texOffs(40, 39).addBox(-2.0F, -2.0F, -2.0F, 3.0F, 5.0F, 4.0F, p_170826_.extend(0.25f)), PartPose.offset(-5.0F, 2.5F, 0.0F));
- partdefinition.addOrReplaceChild("left_arm", CubeListBuilder.create().texOffs(32, 48).addBox(-1.0F, -2.0F, -2.0F, 3.0F, 5.0F, 4.0F, p_170826_), PartPose.offset(5.0F, 2.5F, 0.0F));
- partdefinition.addOrReplaceChild("right_arm", CubeListBuilder.create().texOffs(40, 16).addBox(-2.0F, -2.0F, -2.0F, 3.0F, 5.0F, 4.0F, p_170826_), PartPose.offset(-5.0F, 2.5F, 0.0F));
- partdefinition.addOrReplaceChild("leftShoulder_sleeve", CubeListBuilder.create().texOffs(48, 48).addBox(-1.0F, -2.0F, -2.0F, 3.0F, 5.0F, 4.0F, p_170826_.extend(0.25f)), PartPose.offset(5.0F, 2.5F, 0.0F));
- partdefinition.addOrReplaceChild("rightShoulder_sleeve", CubeListBuilder.create().texOffs(40, 32).addBox(-2.0F, -2.0F, -2.0F, 3.0F, 5.0F, 4.0F, p_170826_.extend(0.25f)), PartPose.offset(-5.0F, 2.5F, 0.0F));
- }else {
- partdefinition.addOrReplaceChild("leftHand", CubeListBuilder.create().texOffs(32, 55).addBox(-1.0F, -2.0F, -2.0F, 4.0F, 5.0F, 4.0F, p_170826_), PartPose.offset(5.0F, 2.5F, 0.0F));
- partdefinition.addOrReplaceChild("left_sleeve", CubeListBuilder.create().texOffs(48, 55).addBox(-1.0F, -2.0F, -2.0F, 4.0F, 5.0F, 4.0F, p_170826_.extend(0.25f)), PartPose.offset(5.0F, 2.5F, 0.0F));
- partdefinition.addOrReplaceChild("rightHand", CubeListBuilder.create().texOffs(40, 23).addBox(-2.0F, -2.0F, -2.0F, 4.0F, 5.0F, 4.0F, p_170826_), PartPose.offset(-5.0F, 2.5F, 0.0F));
- partdefinition.addOrReplaceChild("right_sleeve", CubeListBuilder.create().texOffs(40, 39).addBox(-2.0F, -2.0F, -2.0F, 4.0F, 5.0F, 4.0F, p_170826_.extend(0.25f)), PartPose.offset(-5.0F, 2.5F, 0.0F));
- partdefinition.addOrReplaceChild("left_arm", CubeListBuilder.create().texOffs(32, 48).addBox(-1.0F, -2.0F, -2.0F, 4.0F, 5.0F, 4.0F, p_170826_), PartPose.offset(5.0F, 2.5F, 0.0F));
- partdefinition.addOrReplaceChild("right_arm", CubeListBuilder.create().texOffs(40, 16).addBox(-2.0F, -2.0F, -2.0F, 4.0F, 5.0F, 4.0F, p_170826_), PartPose.offset(-5.0F, 2.5F, 0.0F));
- partdefinition.addOrReplaceChild("leftShoulder_sleeve", CubeListBuilder.create().texOffs(48, 48).addBox(-1.0F, -2.0F, -2.0F, 4.0F, 5.0F, 4.0F, p_170826_.extend(0.25f)), PartPose.offset(5.0F, 2.5F, 0.0F));
- partdefinition.addOrReplaceChild("rightShoulder_sleeve", CubeListBuilder.create().texOffs(40, 32).addBox(-2.0F, -2.0F, -2.0F, 4.0F, 5.0F, 4.0F, p_170826_.extend(0.25f)), PartPose.offset(-5.0F, 2.5F, 0.0F));
-
- }
- return meshdefinition;
- }
-
-
- protected Iterable bodyParts()
- {
+ private final boolean slim;
+ public ModelPart leftShoulder;
+ public ModelPart rightShoulder;
+ public ModelPart leftShoulder_sleeve;
+ public ModelPart rightShoulder_sleeve;
+ public ModelPart leftHand;
+ public ModelPart rightHand;
+ RotInfo rotInfo;
+ private boolean laying;
+
+ public VRPlayerModel_WithArms(ModelPart modelPart, boolean isSlim)
+ {
+ super(modelPart, isSlim);
+ this.slim = isSlim;
+ // use left/right arm as shoulders
+ this.leftShoulder = modelPart.getChild("left_arm");
+ this.rightShoulder = modelPart.getChild("right_arm");
+ this.leftShoulder_sleeve = modelPart.getChild("leftShoulder_sleeve");
+ this.rightShoulder_sleeve = modelPart.getChild("rightShoulder_sleeve");
+ this.rightHand = modelPart.getChild("rightHand");
+ this.leftHand = modelPart.getChild("leftHand");
+
+
+ //finger hax
+ // some mods remove the base parts
+ if (!leftShoulder.cubes.isEmpty()) {
+ copyUV(leftShoulder.cubes.get(0).polygons[1], leftHand.cubes.get(0).polygons[1]);
+ copyUV(leftShoulder.cubes.get(0).polygons[1], leftHand.cubes.get(0).polygons[0]);
+ }
+ if (!rightShoulder.cubes.isEmpty()) {
+ copyUV(rightShoulder.cubes.get(0).polygons[1], this.rightHand.cubes.get(0).polygons[1]);
+ copyUV(rightShoulder.cubes.get(0).polygons[1], this.rightHand.cubes.get(0).polygons[0]);
+ }
+
+ if (!rightSleeve.cubes.isEmpty()) {
+ copyUV(rightShoulder_sleeve.cubes.get(0).polygons[1], this.rightSleeve.cubes.get(0).polygons[1]);
+ copyUV(rightShoulder_sleeve.cubes.get(0).polygons[1], this.rightSleeve.cubes.get(0).polygons[0]);
+ }
+ if (!leftSleeve.cubes.isEmpty()) {
+ copyUV(leftShoulder_sleeve.cubes.get(0).polygons[1], leftSleeve.cubes.get(0).polygons[1]);
+ copyUV(leftShoulder_sleeve.cubes.get(0).polygons[1], leftSleeve.cubes.get(0).polygons[0]);
+ }
+ }
+
+ private void copyUV(Polygon source, Polygon dest) {
+ for (int i = 0; i < source.vertices.length; i++) {
+ dest.vertices[i] = new Vertex(dest.vertices[i].pos, source.vertices[i].u, source.vertices[i].v);
+ if (OptifineHelper.isOptifineLoaded()) {
+ OptifineHelper.copyRenderPositions(source.vertices[i], dest.vertices[i]);
+ }
+ }
+ }
+
+ public static MeshDefinition createMesh(CubeDeformation p_170826_, boolean p_170827_)
+ {
+ MeshDefinition meshdefinition = VRPlayerModel.createMesh(p_170826_, p_170827_);
+ PartDefinition partdefinition = meshdefinition.getRoot();
+
+ if(p_170827_) {
+ partdefinition.addOrReplaceChild("leftHand", CubeListBuilder.create().texOffs(32, 55).addBox(-1.0F, -2.0F, -2.0F, 3.0F, 5.0F, 4.0F, p_170826_), PartPose.offset(5.0F, 2.5F, 0.0F));
+ partdefinition.addOrReplaceChild("left_sleeve", CubeListBuilder.create().texOffs(48, 55).addBox(-1.0F, -2.0F, -2.0F, 3.0F, 5.0F, 4.0F, p_170826_.extend(0.25F)), PartPose.offset(5.0F, 2.5F, 0.0F));
+ partdefinition.addOrReplaceChild("rightHand", CubeListBuilder.create().texOffs(40, 23).addBox(-2.0F, -2.0F, -2.0F, 3.0F, 5.0F, 4.0F, p_170826_), PartPose.offset(-5.0F, 2.5F, 0.0F));
+ partdefinition.addOrReplaceChild("right_sleeve", CubeListBuilder.create().texOffs(40, 39).addBox(-2.0F, -2.0F, -2.0F, 3.0F, 5.0F, 4.0F, p_170826_.extend(0.25F)), PartPose.offset(-5.0F, 2.5F, 0.0F));
+ partdefinition.addOrReplaceChild("left_arm", CubeListBuilder.create().texOffs(32, 48).addBox(-1.0F, -2.0F, -2.0F, 3.0F, 5.0F, 4.0F, p_170826_), PartPose.offset(5.0F, 2.5F, 0.0F));
+ partdefinition.addOrReplaceChild("right_arm", CubeListBuilder.create().texOffs(40, 16).addBox(-2.0F, -2.0F, -2.0F, 3.0F, 5.0F, 4.0F, p_170826_), PartPose.offset(-5.0F, 2.5F, 0.0F));
+ partdefinition.addOrReplaceChild("leftShoulder_sleeve", CubeListBuilder.create().texOffs(48, 48).addBox(-1.0F, -2.0F, -2.0F, 3.0F, 5.0F, 4.0F, p_170826_.extend(0.25F)), PartPose.offset(5.0F, 2.5F, 0.0F));
+ partdefinition.addOrReplaceChild("rightShoulder_sleeve", CubeListBuilder.create().texOffs(40, 32).addBox(-2.0F, -2.0F, -2.0F, 3.0F, 5.0F, 4.0F, p_170826_.extend(0.25F)), PartPose.offset(-5.0F, 2.5F, 0.0F));
+ }else {
+ partdefinition.addOrReplaceChild("leftHand", CubeListBuilder.create().texOffs(32, 55).addBox(-1.0F, -2.0F, -2.0F, 4.0F, 5.0F, 4.0F, p_170826_), PartPose.offset(5.0F, 2.5F, 0.0F));
+ partdefinition.addOrReplaceChild("left_sleeve", CubeListBuilder.create().texOffs(48, 55).addBox(-1.0F, -2.0F, -2.0F, 4.0F, 5.0F, 4.0F, p_170826_.extend(0.25F)), PartPose.offset(5.0F, 2.5F, 0.0F));
+ partdefinition.addOrReplaceChild("rightHand", CubeListBuilder.create().texOffs(40, 23).addBox(-2.0F, -2.0F, -2.0F, 4.0F, 5.0F, 4.0F, p_170826_), PartPose.offset(-5.0F, 2.5F, 0.0F));
+ partdefinition.addOrReplaceChild("right_sleeve", CubeListBuilder.create().texOffs(40, 39).addBox(-2.0F, -2.0F, -2.0F, 4.0F, 5.0F, 4.0F, p_170826_.extend(0.25F)), PartPose.offset(-5.0F, 2.5F, 0.0F));
+ partdefinition.addOrReplaceChild("left_arm", CubeListBuilder.create().texOffs(32, 48).addBox(-1.0F, -2.0F, -2.0F, 4.0F, 5.0F, 4.0F, p_170826_), PartPose.offset(5.0F, 2.5F, 0.0F));
+ partdefinition.addOrReplaceChild("right_arm", CubeListBuilder.create().texOffs(40, 16).addBox(-2.0F, -2.0F, -2.0F, 4.0F, 5.0F, 4.0F, p_170826_), PartPose.offset(-5.0F, 2.5F, 0.0F));
+ partdefinition.addOrReplaceChild("leftShoulder_sleeve", CubeListBuilder.create().texOffs(48, 48).addBox(-1.0F, -2.0F, -2.0F, 4.0F, 5.0F, 4.0F, p_170826_.extend(0.25F)), PartPose.offset(5.0F, 2.5F, 0.0F));
+ partdefinition.addOrReplaceChild("rightShoulder_sleeve", CubeListBuilder.create().texOffs(40, 32).addBox(-2.0F, -2.0F, -2.0F, 4.0F, 5.0F, 4.0F, p_170826_.extend(0.25F)), PartPose.offset(-5.0F, 2.5F, 0.0F));
+
+ }
+ return meshdefinition;
+ }
+
+
+ protected Iterable bodyParts()
+ {
return ImmutableList.of(this.body, this.leftHand, this.rightHand,this.leftShoulder, this.rightShoulder,this.leftShoulder_sleeve, this.rightShoulder_sleeve, this.rightLeg, this.leftLeg, this.hat, this.leftPants, this.rightPants, this.leftSleeve, this.rightSleeve, this.jacket);
- }
-
- public void setupAnim(T pEntity, float pLimbSwing, float pLimbSwingAmount, float pAgeInTicks, float pNetHeadYaw, float pHeadPitch)
- {
- super.setupAnim(pEntity, pLimbSwing, pLimbSwingAmount, pAgeInTicks, pNetHeadYaw, pHeadPitch);
- this.rotInfo = VRPlayersClient.getInstance().getRotationsForPlayer(((Player)pEntity).getUUID());
- VRPlayersClient.RotInfo rotinfo = VRPlayersClient.getInstance().getRotationsForPlayer(((Player)pEntity).getUUID());
-
- if (rotinfo == null) return;
-
- double d0 = (double)(-1.501F * rotinfo.heightScale);
- float f = (float)Math.toRadians((double)pEntity.getYRot());
- float f1 = (float)Math.atan2(-rotinfo.headRot.x, -rotinfo.headRot.z);
- float f2 = (float)Math.asin(rotinfo.headRot.y / rotinfo.headRot.length());
- float f3 = (float)Math.atan2(-rotinfo.leftArmRot.x, -rotinfo.leftArmRot.z);
- float f4 = (float)Math.asin(rotinfo.leftArmRot.y / rotinfo.leftArmRot.length());
- float f5 = (float)Math.atan2(-rotinfo.rightArmRot.x, -rotinfo.rightArmRot.z);
- float f6 = (float)Math.asin(rotinfo.rightArmRot.y / rotinfo.rightArmRot.length());
- double d1 = rotinfo.getBodyYawRadians();
-
- this.laying = this.swimAmount > 0.0F || pEntity.isFallFlying() && !pEntity.isAutoSpinAttack();
-
- if (!rotinfo.reverse)
- {
- this.rightShoulder.setPos(-Mth.cos(this.body.yRot) * 5.0F, this.slim ? 2.5F : 2.0F, Mth.sin(this.body.yRot) * 5.0F);
- this.leftShoulder.setPos(Mth.cos(this.body.yRot) * 5.0F, this.slim ? 2.5F : 2.0F, -Mth.sin(this.body.yRot) * 5.0F);
- }
- else
- {
- this.leftShoulder.setPos(-Mth.cos(this.body.yRot) * 5.0F, this.slim ? 2.5F : 2.0F, Mth.sin(this.body.yRot) * 5.0F);
- this.rightShoulder.setPos(Mth.cos(this.body.yRot) * 5.0F, this.slim ? 2.5F : 2.0F, -Mth.sin(this.body.yRot) * 5.0F);
- }
-
- if (this.crouching)
- {
- this.rightShoulder.y += 3.2F;
- this.leftShoulder.y += 3.2F;
- }
-
- Vec3 vec3 = rotinfo.leftArmPos;
- Vec3 vec32 = rotinfo.rightArmPos;
- if (Xplat.isModLoaded("pehkui")){
- // remove pehkui scale from that, since the whole entity is scaled
- vec3 = vec3.scale(1.0F / PehkuiHelper.getPlayerScale(pEntity, Minecraft.getInstance().getFrameTime()));
- vec32 = vec32.scale(1.0F / PehkuiHelper.getPlayerScale(pEntity, Minecraft.getInstance().getFrameTime()));
- }
+ }
+
+ public void setupAnim(T pEntity, float pLimbSwing, float pLimbSwingAmount, float pAgeInTicks, float pNetHeadYaw, float pHeadPitch)
+ {
+ super.setupAnim(pEntity, pLimbSwing, pLimbSwingAmount, pAgeInTicks, pNetHeadYaw, pHeadPitch);
+ this.rotInfo = VRPlayersClient.getInstance().getRotationsForPlayer(((Player)pEntity).getUUID());
+ RotInfo rotinfo = VRPlayersClient.getInstance().getRotationsForPlayer(((Player)pEntity).getUUID());
+
+ if (rotinfo == null) return;
+
+ double d0 = -1.501F * rotinfo.heightScale;
+ float f = toRadians(pEntity.getYRot());
+ float f1 = (float)atan2(-rotinfo.headRot.x, -rotinfo.headRot.z);
+ float f2 = (float)asin(rotinfo.headRot.y / rotinfo.headRot.length());
+ float f3 = (float)atan2(-rotinfo.leftArmRot.x, -rotinfo.leftArmRot.z);
+ float f4 = (float)asin(rotinfo.leftArmRot.y / rotinfo.leftArmRot.length());
+ float f5 = (float)atan2(-rotinfo.rightArmRot.x, -rotinfo.rightArmRot.z);
+ float f6 = (float)asin(rotinfo.rightArmRot.y / rotinfo.rightArmRot.length());
+ double d1 = rotinfo.getBodyYawRadians();
+
+ this.laying = this.swimAmount > 0.0F || pEntity.isFallFlying() && !pEntity.isAutoSpinAttack();
+
+ if (!rotinfo.reverse)
+ {
+ this.rightShoulder.setPos(-cos(this.body.yRot) * 5.0F, this.slim ? 2.5F : 2.0F, sin(this.body.yRot) * 5.0F);
+ this.leftShoulder.setPos(cos(this.body.yRot) * 5.0F, this.slim ? 2.5F : 2.0F, -sin(this.body.yRot) * 5.0F);
+ }
+ else
+ {
+ this.leftShoulder.setPos(-cos(this.body.yRot) * 5.0F, this.slim ? 2.5F : 2.0F, sin(this.body.yRot) * 5.0F);
+ this.rightShoulder.setPos(cos(this.body.yRot) * 5.0F, this.slim ? 2.5F : 2.0F, -sin(this.body.yRot) * 5.0F);
+ }
+
+ if (this.crouching)
+ {
+ this.rightShoulder.y += 3.2F;
+ this.leftShoulder.y += 3.2F;
+ }
+
+ Vec3 vec3 = rotinfo.leftArmPos;
+ Vec3 vec32 = rotinfo.rightArmPos;
+ if (Xplat.isModLoaded("pehkui")){
+ // remove pehkui scale from that, since the whole entity is scaled
+ vec3 = vec3.scale(1.0F / PehkuiHelper.getPlayerScale(pEntity, mc.getFrameTime()));
+ vec32 = vec32.scale(1.0F / PehkuiHelper.getPlayerScale(pEntity, mc.getFrameTime()));
+ }
vec3 = vec3.add(0.0D, d0, 0.0D);
- vec3 = vec3.yRot((float)(-Math.PI + d1));
+ vec3 = vec3.yRot((float)(-PI + d1));
vec3 = vec3.scale((double)(16.0F / rotinfo.heightScale));
- this.leftHand.setPos((float)(-vec3.x), (float)(-vec3.y), (float)vec3.z);
- this.leftHand.xRot = (float)((double)(-f4) + (Math.PI * 1.5D));
- this.leftHand.yRot = (float)(Math.PI - (double)f3 - d1);
- this.leftHand.zRot = 0.0F;
+ this.leftHand.setPos((float)(-vec3.x), (float)(-vec3.y), (float)vec3.z);
+ this.leftHand.xRot = (float)((-f4) + (PI * 1.5D));
+ this.leftHand.yRot = (float)(PI - f3 - d1);
+ this.leftHand.zRot = 0.0F;
Vec3 vec31 = new Vec3((double)this.leftShoulder.x + vec3.x, (double)this.leftShoulder.y + vec3.y, (double)this.leftShoulder.z - vec3.z);
- float f7 = (float)Math.atan2(vec31.x, vec31.z);
- float f8 = (float)((Math.PI * 1.5D) - Math.asin(vec31.y / vec31.length()));
- this.leftShoulder.zRot = 0.0F;
- this.leftShoulder.xRot = f8;
- this.leftShoulder.yRot = f7;
-
- if (this.leftShoulder.yRot > 0.0F)
- {
- this.leftShoulder.yRot = 0.0F;
- }
-
- switch (this.leftArmPose)
- {
- case THROW_SPEAR:
- this.leftHand.xRot = (float)((double)this.leftHand.xRot - (Math.PI / 2D));
- default:
- }
-
- vec32 = vec32.add(0.0D, d0, 0.0D);
- vec32 = vec32.yRot((float)(-Math.PI + d1));
+ float f7 = (float)atan2(vec31.x, vec31.z);
+ float f8 = (float)((PI * 1.5D) - asin(vec31.y / vec31.length()));
+ this.leftShoulder.zRot = 0.0F;
+ this.leftShoulder.xRot = f8;
+ this.leftShoulder.yRot = f7;
+
+ if (this.leftShoulder.yRot > 0.0F)
+ {
+ this.leftShoulder.yRot = 0.0F;
+ }
+
+ if (this.leftArmPose == ArmPose.THROW_SPEAR)
+ {
+ this.leftHand.xRot = (float) (this.leftHand.xRot - (PI / 2.0D));
+ }
+
+ vec32 = vec32.add(0.0D, d0, 0.0D);
+ vec32 = vec32.yRot((float)(-PI + d1));
vec32 = vec32.scale((double)(16.0F / rotinfo.heightScale));
- this.rightHand.setPos((float)(-vec32.x), -((float)vec32.y), (float)vec32.z);
- this.rightHand.xRot = (float)((double)(-f6) + (Math.PI * 1.5D));
- this.rightHand.yRot = (float)(Math.PI - (double)f5 - d1);
- this.rightHand.zRot = 0.0F;
+ this.rightHand.setPos((float)(-vec32.x), -((float)vec32.y), (float)vec32.z);
+ this.rightHand.xRot = (float)((-f6) + (PI * 1.5D));
+ this.rightHand.yRot = (float)(PI - f5 - d1);
+ this.rightHand.zRot = 0.0F;
Vec3 vec33 = new Vec3((double)this.rightShoulder.x + vec32.x, (double)this.rightShoulder.y + vec32.y, (double)this.rightShoulder.z - vec32.z);
- float f9 = (float)Math.atan2(vec33.x, vec33.z);
- float f10 = (float)((Math.PI * 1.5D) - Math.asin(vec33.y / vec33.length()));
- this.rightShoulder.zRot = 0.0F;
- this.rightShoulder.xRot = f10;
- this.rightShoulder.yRot = f9;
-
- if (this.rightShoulder.yRot < 0.0F)
- {
- this.rightShoulder.yRot = 0.0F;
- }
-
- switch (this.rightArmPose)
- {
- case THROW_SPEAR:
- this.rightHand.xRot = (float)((double)this.rightHand.xRot - (Math.PI / 2D));
- default:
- }
-
- if (this.laying)
- {
- this.rightShoulder.xRot = (float)((double)this.rightShoulder.xRot - (Math.PI / 2D));
- this.leftShoulder.xRot = (float)((double)this.leftShoulder.xRot - (Math.PI / 2D));
- }
-
- this.leftSleeve.copyFrom(this.leftHand);
- this.rightSleeve.copyFrom(this.rightHand);
- this.leftShoulder_sleeve.copyFrom(this.leftShoulder);
- this.rightShoulder_sleeve.copyFrom(this.rightShoulder);
- this.leftShoulder_sleeve.visible = this.leftSleeve.visible;
- this.rightShoulder_sleeve.visible = this.rightSleeve.visible;
- }
-
- public void setAllVisible(boolean pVisible)
- {
- super.setAllVisible(pVisible);
-
- this.rightShoulder.visible = pVisible;
- this.leftShoulder.visible = pVisible;
- this.rightShoulder_sleeve.visible = pVisible;
- this.leftShoulder_sleeve.visible = pVisible;
- this.rightHand.visible = pVisible;
- this.leftHand.visible = pVisible;
-
- }
-
- protected ModelPart getArm(HumanoidArm pSide)
- {
- return pSide == HumanoidArm.LEFT ? this.leftHand : this.rightHand;
- }
-
- public void translateToHand(HumanoidArm pSide, PoseStack pMatrixStack)
- {
- ModelPart modelpart = this.getArm(pSide);
-
- if (this.laying)
- {
- pMatrixStack.mulPose(Axis.XP.rotationDegrees(-90.0F));
- }
-
- modelpart.translateAndRotate(pMatrixStack);
- pMatrixStack.mulPose(Axis.XP.rotation((float)Math.sin((double)this.attackTime * Math.PI)));
- pMatrixStack.translate(0.0D, -0.5D, 0.0D);
- }
+ float f9 = (float)atan2(vec33.x, vec33.z);
+ float f10 = (float)((PI * 1.5D) - asin(vec33.y / vec33.length()));
+ this.rightShoulder.zRot = 0.0F;
+ this.rightShoulder.xRot = f10;
+ this.rightShoulder.yRot = f9;
+
+ if (this.rightShoulder.yRot < 0.0F)
+ {
+ this.rightShoulder.yRot = 0.0F;
+ }
+
+ if (this.rightArmPose == ArmPose.THROW_SPEAR) {
+ this.rightHand.xRot = (float) (this.rightHand.xRot - (PI / 2.0D));
+ }
+
+ if (this.laying)
+ {
+ this.rightShoulder.xRot = (float)(this.rightShoulder.xRot - (PI / 2.0D));
+ this.leftShoulder.xRot = (float)(this.leftShoulder.xRot - (PI / 2.0D));
+ }
+
+ this.leftSleeve.copyFrom(this.leftHand);
+ this.rightSleeve.copyFrom(this.rightHand);
+ this.leftShoulder_sleeve.copyFrom(this.leftShoulder);
+ this.rightShoulder_sleeve.copyFrom(this.rightShoulder);
+ this.leftShoulder_sleeve.visible = this.leftSleeve.visible;
+ this.rightShoulder_sleeve.visible = this.rightSleeve.visible;
+ }
+
+ public void setAllVisible(boolean pVisible)
+ {
+ super.setAllVisible(pVisible);
+
+ this.rightShoulder.visible = pVisible;
+ this.leftShoulder.visible = pVisible;
+ this.rightShoulder_sleeve.visible = pVisible;
+ this.leftShoulder_sleeve.visible = pVisible;
+ this.rightHand.visible = pVisible;
+ this.leftHand.visible = pVisible;
+
+ }
+
+ protected ModelPart getArm(HumanoidArm pSide)
+ {
+ return pSide == HumanoidArm.LEFT ? this.leftHand : this.rightHand;
+ }
+
+ public void translateToHand(HumanoidArm pSide, PoseStack pMatrixStack)
+ {
+ ModelPart modelpart = this.getArm(pSide);
+
+ if (this.laying)
+ {
+ float ang = toRadians(-90.0F);
+ pMatrixStack.last().pose().rotateX(ang);
+ pMatrixStack.last().normal().rotateX(ang);
+ }
+
+ modelpart.translateAndRotate(pMatrixStack);
+ float ang = sin((float) PI * this.attackTime);
+ pMatrixStack.last().normal().rotateX(ang);
+ pMatrixStack.last().pose().rotateX(ang).translate(0.0F, -0.5F, 0.0F);
+ }
// public void renderToBuffer(PoseStack pMatrixStack, VertexConsumer pBuffer, int pPackedLight, int pPackedOverlay, float pRed, float pGreen, float pBlue, float pAlpha)
// {
@@ -282,7 +284,9 @@ public void translateToHand(HumanoidArm pSide, PoseStack pMatrixStack)
//
// if (this.laying)
// {
-// pMatrixStack.mulPose(Axis.XP.rotationDegrees(-90.0F));
+// float ang = toRadians(-90.0F);
+// pMatrixStack.last().pose().rotateX(ang);
+// pMatrixStack.last().normal().rotateX(ang);
// }
//
// this.rightHand.render(pMatrixStack, pBuffer, pPackedLight, pPackedOverlay, pRed, pGreen, pBlue, pAlpha);
diff --git a/common/src/main/java/org/vivecraft/client/render/VRPlayerRenderer.java b/common/src/main/java/org/vivecraft/client/render/VRPlayerRenderer.java
index 0e227038c..c01d9c290 100644
--- a/common/src/main/java/org/vivecraft/client/render/VRPlayerRenderer.java
+++ b/common/src/main/java/org/vivecraft/client/render/VRPlayerRenderer.java
@@ -1,37 +1,39 @@
package org.vivecraft.client.render;
-import java.util.UUID;
-
-import net.minecraft.client.Minecraft;
import org.vivecraft.client.VRPlayersClient;
-import org.vivecraft.client_vr.ClientDataHolderVR;
+import org.vivecraft.client.VRPlayersClient.RotInfo;
+import org.vivecraft.client_vr.render.RenderPass;
+
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.model.geom.builders.CubeDeformation;
import net.minecraft.client.model.geom.builders.LayerDefinition;
import net.minecraft.client.player.AbstractClientPlayer;
import net.minecraft.client.renderer.MultiBufferSource;
-import net.minecraft.client.renderer.entity.EntityRendererProvider;
-import net.minecraft.client.renderer.entity.player.PlayerRenderer;
import net.minecraft.world.phys.Vec3;
-import org.vivecraft.client_vr.render.RenderPass;
-public class VRPlayerRenderer extends PlayerRenderer
+import java.util.UUID;
+
+import static org.vivecraft.client_vr.VRState.dh;
+import static org.vivecraft.client_vr.VRState.mc;
+
+import static org.joml.Math.*;
+
+import static net.minecraft.client.renderer.entity.EntityRendererProvider.Context;
+
+public class VRPlayerRenderer extends net.minecraft.client.renderer.entity.player.PlayerRenderer
{
- static LayerDefinition VRLayerDef = LayerDefinition.create(VRPlayerModel.createMesh(CubeDeformation.NONE, false), 64, 64);
- static LayerDefinition VRLayerDef_arms = LayerDefinition.create(VRPlayerModel_WithArms.createMesh(CubeDeformation.NONE, false), 64, 64);
+ static LayerDefinition VRLayerDef = LayerDefinition.create(VRPlayerModel.createMesh(CubeDeformation.NONE, false), 64, 64);
+ static LayerDefinition VRLayerDef_arms = LayerDefinition.create(VRPlayerModel_WithArms.createMesh(CubeDeformation.NONE, false), 64, 64);
static LayerDefinition VRLayerDef_slim = LayerDefinition.create(VRPlayerModel.createMesh(CubeDeformation.NONE, true), 64, 64);
- static LayerDefinition VRLayerDef_arms_slim = LayerDefinition.create(VRPlayerModel_WithArms.createMesh(CubeDeformation.NONE, true), 64, 64);
-
- public VRPlayerRenderer(EntityRendererProvider.Context context, boolean slim, boolean seated) {
- super(context, slim);
- model = !slim ?
- (seated ?
- new VRPlayerModel<>(VRLayerDef.bakeRoot(), slim) :
- new VRPlayerModel_WithArms<>(VRLayerDef_arms.bakeRoot(), slim)) :
- (seated ?
- new VRPlayerModel<>(VRLayerDef_slim.bakeRoot(), slim) :
- new VRPlayerModel_WithArms<>(VRLayerDef_arms_slim.bakeRoot(), slim));
+ static LayerDefinition VRLayerDef_arms_slim = LayerDefinition.create(VRPlayerModel_WithArms.createMesh(CubeDeformation.NONE, true), 64, 64);
+
+ public VRPlayerRenderer(Context context, boolean slim, boolean seated) {
+ super(context, slim);
+ this.model = (seated ?
+ new VRPlayerModel<>(slim ? VRLayerDef_slim.bakeRoot() : VRLayerDef.bakeRoot(), slim) :
+ new VRPlayerModel_WithArms<>(slim ? VRLayerDef_arms_slim.bakeRoot() : VRLayerDef_arms.bakeRoot(), slim)
+ );
this.addLayer(new HMDLayer(this));
}
@@ -40,7 +42,7 @@ public VRPlayerRenderer(EntityRendererProvider.Context context, boolean slim, bo
public void render(AbstractClientPlayer entityIn, float pEntityYaw, float pPartialTicks, PoseStack matrixStackIn, MultiBufferSource pBuffer, int pPackedLight)
{
- VRPlayersClient.RotInfo playermodelcontroller$rotinfo = VRPlayersClient.getInstance().getRotationsForPlayer(entityIn.getUUID());
+ RotInfo playermodelcontroller$rotinfo = VRPlayersClient.getInstance().getRotationsForPlayer(entityIn.getUUID());
if (playermodelcontroller$rotinfo != null)
{
@@ -53,7 +55,7 @@ public void render(AbstractClientPlayer entityIn, float pEntityYaw, float pParti
@Override
public Vec3 getRenderOffset(AbstractClientPlayer pEntity, float pPartialTicks)
{
- //idk why we do this anymore
+ //idk why we do this anymore
return pEntity.isVisuallySwimming() ? new Vec3(0.0D, -0.125D, 0.0D) : Vec3.ZERO;
// return pEntity.isCrouching() ? new Vec3(0.0D, -0.125D, 0.0D) : super.getRenderOffset(pEntity, pPartialTicks);
}
@@ -65,7 +67,7 @@ public void setModelProperties(AbstractClientPlayer pClientPlayer)
this.getModel().crouching &= !pClientPlayer.isVisuallySwimming();
- if (pClientPlayer == Minecraft.getInstance().player && this.getModel() instanceof VRPlayerModel_WithArms> armsModel && ClientDataHolderVR.getInstance().currentPass == RenderPass.CAMERA && ClientDataHolderVR.getInstance().cameraTracker.isQuickMode() && ClientDataHolderVR.getInstance().grabScreenShot) {
+ if (pClientPlayer == mc.player && this.getModel() instanceof VRPlayerModel_WithArms> armsModel && dh.currentPass == RenderPass.CAMERA && dh.cameraTracker.isQuickMode() && dh.grabScreenShot) {
// player hands block the camera, so disable them for the screenshot
armsModel.leftHand.visible = false;
armsModel.rightHand.visible = false;
@@ -77,12 +79,12 @@ public void setModelProperties(AbstractClientPlayer pClientPlayer)
@Override
protected void setupRotations(AbstractClientPlayer pEntityLiving, PoseStack pMatrixStack, float pAgeInTicks, float pRotationYaw, float pPartialTicks)
{
- UUID uuid = pEntityLiving.getUUID();
- if (ClientDataHolderVR.getInstance().currentPass != RenderPass.GUI && VRPlayersClient.getInstance().isTracked(uuid))
- {
- VRPlayersClient.RotInfo playermodelcontroller$rotinfo = VRPlayersClient.getInstance().getRotationsForPlayer(uuid);
- pRotationYaw = (float)Math.toDegrees(playermodelcontroller$rotinfo.getBodyYawRadians());
- }
+ UUID uuid = pEntityLiving.getUUID();
+ if (dh.currentPass != RenderPass.GUI && VRPlayersClient.getInstance().isTracked(uuid))
+ {
+ RotInfo playermodelcontroller$rotinfo = VRPlayersClient.getInstance().getRotationsForPlayer(uuid);
+ pRotationYaw = (float)toDegrees(playermodelcontroller$rotinfo.getBodyYawRadians());
+ }
//vanilla below here
super.setupRotations(pEntityLiving, pMatrixStack, pAgeInTicks, pRotationYaw, pPartialTicks);
diff --git a/common/src/main/java/org/vivecraft/client/utils/Debug.java b/common/src/main/java/org/vivecraft/client/utils/Debug.java
index 4953b1a45..961eb44c3 100644
--- a/common/src/main/java/org/vivecraft/client/utils/Debug.java
+++ b/common/src/main/java/org/vivecraft/client/utils/Debug.java
@@ -1,37 +1,44 @@
package org.vivecraft.client.utils;
+import org.vivecraft.common.utils.color.Color;
+
+import org.joml.Quaternionf;
+import org.joml.Vector3f;
+
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.BufferBuilder;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.Tesselator;
-import java.awt.Color;
-import java.util.ArrayList;
-import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.MultiBufferSource;
-import net.minecraft.client.renderer.debug.DebugRenderer;
-import net.minecraft.world.entity.player.Player;
+import net.minecraft.client.renderer.debug.DebugRenderer.SimpleDebugRenderer;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
-import org.vivecraft.common.utils.math.Quaternion;
-import org.vivecraft.common.utils.math.Vector3;
+
+import java.util.ArrayList;
+
+import static org.vivecraft.client_vr.VRState.mc;
+import static org.vivecraft.common.utils.Utils.*;
+
+import static java.lang.Math.pow;
+import static org.joml.Math.*;
public class Debug
{
Vec3 root;
- Quaternion rotation;
+ Quaternionf rotation;
public static boolean isEnabled = true;
static Polygon cross = new Polygon(6);
static Polygon arrowHead = new Polygon(8);
- private static DebugRendererManual renderer = new DebugRendererManual();
+ private static final DebugRendererManual renderer = new DebugRendererManual();
public Debug(Vec3 root)
{
this.root = root;
- this.rotation = new Quaternion();
+ this.rotation = new Quaternionf();
}
- public Debug(Vec3 root, Quaternion rotation)
+ public Debug(Vec3 root, Quaternionf rotation)
{
this.root = root;
this.rotation = rotation;
@@ -39,7 +46,7 @@ public Debug(Vec3 root, Quaternion rotation)
public void drawPoint(Vec3 point, Color color)
{
- point = this.rotation.multiply(point);
+ point = convertToVec3(this.rotation.transformUnit(convertToVector3f(point), new Vector3f()));
Vec3 vec3 = this.root.add(point);
Polygon debug$polygon = cross.offset(vec3);
@@ -57,13 +64,19 @@ public void drawPoint(Vec3 point, Color color)
public void drawVector(Vec3 start, Vec3 direction, Color color)
{
Polygon debug$polygon = new Polygon(2);
- start = this.rotation.multiply(start);
- direction = this.rotation.multiply(direction);
+ start = convertToVec3(this.rotation.transformUnit(convertToVector3f(start), new Vector3f()));
+ direction = convertToVec3(this.rotation.transformUnit(convertToVector3f(direction), new Vector3f()));
debug$polygon.vertices[0] = this.root.add(start);
debug$polygon.colors[0] = new Color(0, 0, 0, 0);
debug$polygon.vertices[1] = this.root.add(start).add(direction);
debug$polygon.colors[1] = color;
- Quaternion quaternion = Quaternion.createFromToVector(new Vector3(0.0F, 1.0F, 0.0F), new Vector3(direction.normalize()));
+ // TODO JOML probably has functions for this
+ Vec3 from = convertToVec3(up);
+ Vec3 to = direction.normalize();
+ float f = (float)(sqrt(pow(from.length(), 2.0D) * pow(to.length(), 2.0D)) + from.dot(to));
+ Vec3 vector3 = from.cross(to);
+ Quaternionf quaternion = new Quaternionf((float)vector3.x, (float)vector3.y, (float)vector3.z, f).normalize(new Quaternionf());
+ //
Polygon debug$polygon1 = arrowHead.rotated(quaternion).offset(this.root.add(start).add(direction));
for (int i = 0; i < debug$polygon1.colors.length; ++i)
@@ -80,8 +93,8 @@ public void drawVector(Vec3 start, Vec3 direction, Color color)
public void drawLine(Vec3 start, Vec3 end, Color color)
{
- start = this.rotation.multiply(start);
- end = this.rotation.multiply(end);
+ start = convertToVec3(this.rotation.transformUnit(convertToVector3f(start), new Vector3f()));
+ end = convertToVec3(this.rotation.transformUnit(convertToVector3f(end), new Vector3f()));
Polygon debug$polygon = new Polygon(2);
debug$polygon.vertices[0] = this.root.add(start);
debug$polygon.colors[0] = new Color(0, 0, 0, 0);
@@ -107,15 +120,15 @@ public void drawBoundingBox(AABB box, Color color)
for (int j = 0; j < 4; ++j)
{
- avec3[j] = this.root.add(this.rotation.multiply(avec3[j]));
- avec31[j] = this.root.add(this.rotation.multiply(avec31[j]));
+ avec3[j] = this.root.add(convertToVec3(this.rotation.transformUnit(convertToVector3f(avec3[j]), new Vector3f())));
+ avec31[j] = this.root.add(convertToVec3(this.rotation.transformUnit(convertToVector3f(avec31[j]), new Vector3f())));
}
for (int k = 0; k < 5; ++k)
{
if (k == 0)
{
- debug$polygon.colors[i] = new Color(0, 0, 0, 0);
+ debug$polygon.colors[i] = new Color(Color.OFF);
}
else
{
@@ -136,7 +149,7 @@ public void drawBoundingBox(AABB box, Color color)
for (int i1 = 1; i1 < 4; ++i1)
{
debug$polygon.vertices[i] = avec3[i1];
- debug$polygon.colors[i] = new Color(0, 0, 0, 0);
+ debug$polygon.colors[i] = new Color(Color.OFF);
++i;
debug$polygon.vertices[i] = avec31[i1];
debug$polygon.colors[i] = color;
@@ -153,40 +166,39 @@ public static DebugRendererManual getRenderer()
static
{
- cross.colors[0] = new Color(0, 0, 0, 0);
+ cross.colors[0] = new Color(Color.OFF);
cross.vertices[0] = new Vec3(0.0D, -0.1D, 0.0D);
cross.vertices[1] = new Vec3(0.0D, 0.1D, 0.0D);
- cross.colors[2] = new Color(0, 0, 0, 0);
+ cross.colors[2] = new Color(Color.OFF);
cross.vertices[2] = new Vec3(0.0D, 0.0D, -0.1D);
cross.vertices[3] = new Vec3(0.0D, 0.0D, 0.1D);
- cross.colors[4] = new Color(0, 0, 0, 0);
+ cross.colors[4] = new Color(Color.OFF);
cross.vertices[4] = new Vec3(-0.1D, 0.0D, 0.0D);
cross.vertices[5] = new Vec3(0.1D, 0.0D, 0.0D);
- arrowHead.colors[0] = new Color(0, 0, 0, 0);
+ arrowHead.colors[0] = new Color(Color.OFF);
arrowHead.vertices[0] = new Vec3(0.0D, 0.0D, 0.0D);
arrowHead.vertices[1] = new Vec3(-0.05D, -0.05D, 0.0D);
- arrowHead.colors[2] = new Color(0, 0, 0, 0);
+ arrowHead.colors[2] = new Color(Color.OFF);
arrowHead.vertices[2] = new Vec3(0.0D, 0.0D, 0.0D);
arrowHead.vertices[3] = new Vec3(0.05D, -0.05D, 0.0D);
- arrowHead.colors[4] = new Color(0, 0, 0, 0);
+ arrowHead.colors[4] = new Color(Color.OFF);
arrowHead.vertices[4] = new Vec3(0.0D, 0.0D, 0.0D);
arrowHead.vertices[5] = new Vec3(0.0D, -0.05D, -0.05D);
- arrowHead.colors[6] = new Color(0, 0, 0, 0);
+ arrowHead.colors[6] = new Color(Color.OFF);
arrowHead.vertices[6] = new Vec3(0.0D, 0.0D, 0.0D);
arrowHead.vertices[7] = new Vec3(0.0D, -0.05D, 0.05D);
}
- public static class DebugRendererManual implements DebugRenderer.SimpleDebugRenderer
+ public static class DebugRendererManual implements SimpleDebugRenderer
{
public boolean manualClearing = false;
ArrayList toDraw = new ArrayList<>();
public void render(float partialTicks, long finishTimeNano)
{
- Player player = Minecraft.getInstance().player;
- double d0 = player.xOld + (player.getX() - player.xOld) * (double)partialTicks;
- double d1 = player.yOld + (player.getY() - player.yOld) * (double)partialTicks;
- double d2 = player.zOld + (player.getZ() - player.zOld) * (double)partialTicks;
+ double d0 = mc.player.xOld + (mc.player.getX() - mc.player.xOld) * (double)partialTicks;
+ double d1 = mc.player.yOld + (mc.player.getY() - mc.player.yOld) * (double)partialTicks;
+ double d2 = mc.player.zOld + (mc.player.getZ() - mc.player.zOld) * (double)partialTicks;
// GlStateManager.lineWidth(5.0F);
//GlStateManager._disableLighting();
RenderSystem.depthMask(false);
@@ -221,10 +233,10 @@ public void clear()
void renderVertex(BufferBuilder buffer, Vec3 vert, Color color, double offX, double offY, double offZ)
{
- buffer.vertex(vert.x - offX, vert.y - offY, vert.z - offZ).color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()).endVertex();
+ buffer.vertex(vert.x - offX, vert.y - offY, vert.z - offZ).color(color.R(), color.G(), color.B(), color.A()).endVertex();
}
- public void render(PoseStack pMatrixStack, MultiBufferSource pBuffer, double pCamX, double p_113510_, double pCamY)
+ public void render(PoseStack pMatrixStack, MultiBufferSource pBuffer, double camX, double camY, double camZ)
{
}
}
@@ -253,13 +265,18 @@ public Polygon offset(Vec3 offset)
return debug$polygon;
}
- public Polygon rotated(Quaternion quat)
+ public Polygon rotated(Quaternionf quat)
{
Polygon debug$polygon = new Polygon(this.vertices.length);
for (int i = 0; i < this.vertices.length; ++i)
{
- debug$polygon.vertices[i] = quat.multiply(new Vector3(this.vertices[i])).toVector3d();
+ debug$polygon.vertices[i] = convertToVec3(
+ quat.transformUnit(
+ new Vector3f().set(this.vertices[i].x, this.vertices[i].y, this.vertices[i].z),
+ new Vector3f()
+ )
+ );
debug$polygon.colors[i] = this.colors[i];
}
diff --git a/common/src/main/java/org/vivecraft/client/utils/UpdateChecker.java b/common/src/main/java/org/vivecraft/client/utils/UpdateChecker.java
index 57c3113c1..7c7d4758f 100644
--- a/common/src/main/java/org/vivecraft/client/utils/UpdateChecker.java
+++ b/common/src/main/java/org/vivecraft/client/utils/UpdateChecker.java
@@ -1,11 +1,12 @@
package org.vivecraft.client.utils;
+import org.vivecraft.client.Xplat;
+
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
-import com.mojang.logging.LogUtils;
+
import net.minecraft.SharedConstants;
-import org.vivecraft.client.Xplat;
import java.io.BufferedReader;
import java.io.IOException;
@@ -13,9 +14,13 @@
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
-import java.util.*;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
import java.util.stream.Collectors;
+import static org.vivecraft.common.utils.Utils.logger;
+
public class UpdateChecker {
public static boolean hasUpdate = false;
@@ -25,7 +30,7 @@ public class UpdateChecker {
public static String newestVersion = "";
public static boolean checkForUpdates() {
- System.out.println("Checking for Vivecraft Updates");
+ logger.info("Checking for Updates...");
try {
String apiURL = "https://api.modrinth.com/v2/project/vivecraft/version?loaders=[%22" + Xplat.getModloader() + "%22]&game_versions=[%22" + SharedConstants.VERSION_STRING + "%22]";
HttpURLConnection conn = (HttpURLConnection) new URL(apiURL).openConnection();
@@ -36,7 +41,7 @@ public static boolean checkForUpdates() {
conn.connect();
if (conn.getResponseCode() != HttpURLConnection.HTTP_OK) {
- LogUtils.getLogger().error("Error " + conn.getResponseCode() + " fetching Vivecraft updates");
+ logger.error("Error {} fetching updates", conn.getResponseCode());
return false;
}
@@ -60,10 +65,12 @@ public static boolean checkForUpdates() {
String currentVersionNumber = Xplat.getModVersion() + "-" +Xplat.getModloader();
Version current = new Version(currentVersionNumber,currentVersionNumber,"");
+ StringBuilder changelogBuilder = new StringBuilder(changelog);
for (Version v : versions) {
if (current.compareTo(v) > 0) {
- changelog += "§a"+v.fullVersion+"§r" + ": \n" + v.changelog + "\n\n";
+ changelogBuilder.append("§a").append(v.fullVersion).append("§r: \n")
+ .append(v.changelog).append("\n\n");
if (newestVersion.isEmpty()) {
newestVersion = v.fullVersion;
}
@@ -71,9 +78,9 @@ public static boolean checkForUpdates() {
}
}
// no carriage returns please
- changelog = changelog.replaceAll("\\r", "");
+ changelog = changelogBuilder.toString().replaceAll("\\r", "");
if (hasUpdate) {
- LogUtils.getLogger().info("Vivecraft update found: " + newestVersion);
+ logger.info("Update Found: {}", newestVersion);
}
} catch (IOException e) {
e.printStackTrace();
@@ -123,7 +130,7 @@ public Version(String version, String version_number, String changelog) {
}
@Override
- public int compareTo(UpdateChecker.Version o) {
+ public int compareTo(Version o) {
long result = this.compareNumber() - o.compareNumber();
if (result < 0) {
return 1;
diff --git a/common/src/main/java/org/vivecraft/client/utils/Utils.java b/common/src/main/java/org/vivecraft/client/utils/Utils.java
index d29b5628a..a2468028a 100644
--- a/common/src/main/java/org/vivecraft/client/utils/Utils.java
+++ b/common/src/main/java/org/vivecraft/client/utils/Utils.java
@@ -1,65 +1,23 @@
package org.vivecraft.client.utils;
-import java.io.BufferedReader;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.net.HttpURLConnection;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Enumeration;
-import java.util.Formatter;
-import java.util.List;
-import java.util.Optional;
-import java.util.Random;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
-
-import javax.annotation.Nullable;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.logging.log4j.LogManager;
-import org.lwjgl.openvr.HmdMatrix44;
import org.vivecraft.client.Xplat;
import org.vivecraft.client_vr.render.VRShaders;
import org.vivecraft.client_vr.utils.LoaderUtils;
-import org.vivecraft.common.utils.math.Quaternion;
-import org.vivecraft.common.utils.math.Vector2;
-import org.vivecraft.common.utils.math.Vector3;
-import org.vivecraft.common.utils.lwjgl.Matrix3f;
-import org.vivecraft.common.utils.lwjgl.Matrix4f;
-import org.vivecraft.common.utils.lwjgl.Vector2f;
-import org.vivecraft.common.utils.lwjgl.Vector3f;
-import org.vivecraft.common.utils.lwjgl.Vector4f;
-
-import com.google.common.base.Charsets;
+
import com.google.common.collect.Lists;
import com.google.common.io.Files;
+import org.apache.commons.io.IOUtils;
+
import com.mojang.blaze3d.pipeline.RenderTarget;
import net.minecraft.ChatFormatting;
import net.minecraft.client.ComponentCollector;
-import net.minecraft.client.Minecraft;
import net.minecraft.client.Screenshot;
import net.minecraft.client.gui.Font;
import net.minecraft.client.renderer.LevelRenderer;
import net.minecraft.core.BlockPos;
import net.minecraft.core.particles.ParticleOptions;
+import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.FormattedText;
import net.minecraft.network.chat.Style;
import net.minecraft.resources.ResourceLocation;
@@ -67,13 +25,40 @@
import net.minecraft.world.level.BlockAndTintGetter;
import net.minecraft.world.phys.Vec3;
+import javax.annotation.Nullable;
+import java.io.*;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.*;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+
+import static org.vivecraft.client_vr.VRState.mc;
+import static org.vivecraft.common.utils.Utils.logger;
+
+import static org.joml.Math.*;
+
public class Utils
{
- private static final char[] illegalChars = new char[] {'"', '<', '>', '|', '\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007', '\b', '\t', '\n', '\u000b', '\f', '\r', '\u000e', '\u000f', '\u0010', '\u0011', '\u0012', '\u0013', '\u0014', '\u0015', '\u0016', '\u0017', '\u0018', '\u0019', '\u001a', '\u001b', '\u001c', '\u001d', '\u001e', '\u001f', ':', '*', '?', '\\', '/'};
+ private static final char[] illegalChars = {'"', '<', '>', '|', '\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005', '\u0006', '\u0007', '\b', '\t', '\n', '\u000b', '\f', '\r', '\u000e', '\u000f', '\u0010', '\u0011', '\u0012', '\u0013', '\u0014', '\u0015', '\u0016', '\u0017', '\u0018', '\u0019', '\u001a', '\u001b', '\u001c', '\u001d', '\u001e', '\u001f', ':', '*', '?', '\\', '/'};
private static final int CONNECT_TIMEOUT = 5000;
private static final int READ_TIMEOUT = 20000;
private static final Random avRandomizer = new Random();
+ public static void message(final Component literal)
+ {
+ if (mc.level != null) {
+ mc.gui.getChat().addMessage(literal);
+ }
+ }
+
public static String sanitizeFileName(String fileName)
{
StringBuilder stringbuilder = new StringBuilder();
@@ -95,90 +80,9 @@ public static String sanitizeFileName(String fileName)
return stringbuilder.toString();
}
- public static Vector3 convertToOVRVector(Vector3f vector)
- {
- return new Vector3(vector.x, vector.y, vector.z);
- }
-
- public static Vector3 convertToOVRVector(Vec3 vector)
- {
- return new Vector3((float)vector.x, (float)vector.y, (float)vector.z);
- }
-
- public static Matrix4f convertOVRMatrix(org.vivecraft.common.utils.math.Matrix4f matrix)
- {
- Matrix4f matrix4f = new Matrix4f();
- matrix4f.m00 = matrix.M[0][0];
- matrix4f.m01 = matrix.M[0][1];
- matrix4f.m02 = matrix.M[0][2];
- matrix4f.m03 = matrix.M[0][3];
- matrix4f.m10 = matrix.M[1][0];
- matrix4f.m11 = matrix.M[1][1];
- matrix4f.m12 = matrix.M[1][2];
- matrix4f.m13 = matrix.M[1][3];
- matrix4f.m20 = matrix.M[2][0];
- matrix4f.m21 = matrix.M[2][1];
- matrix4f.m22 = matrix.M[2][2];
- matrix4f.m23 = matrix.M[2][3];
- matrix4f.m30 = matrix.M[3][0];
- matrix4f.m31 = matrix.M[3][1];
- matrix4f.m32 = matrix.M[3][2];
- matrix4f.m33 = matrix.M[3][3];
- matrix4f.transpose(matrix4f);
- return matrix4f;
- }
-
- public static org.vivecraft.common.utils.math.Matrix4f convertToOVRMatrix(Matrix4f matrixIn)
- {
- Matrix4f matrix4f = new Matrix4f();
- matrixIn.transpose(matrix4f);
- org.vivecraft.common.utils.math.Matrix4f matrix4f1 = new org.vivecraft.common.utils.math.Matrix4f();
- matrix4f1.M[0][0] = matrix4f.m00;
- matrix4f1.M[0][1] = matrix4f.m01;
- matrix4f1.M[0][2] = matrix4f.m02;
- matrix4f1.M[0][3] = matrix4f.m03;
- matrix4f1.M[1][0] = matrix4f.m10;
- matrix4f1.M[1][1] = matrix4f.m11;
- matrix4f1.M[1][2] = matrix4f.m12;
- matrix4f1.M[1][3] = matrix4f.m13;
- matrix4f1.M[2][0] = matrix4f.m20;
- matrix4f1.M[2][1] = matrix4f.m21;
- matrix4f1.M[2][2] = matrix4f.m22;
- matrix4f1.M[2][3] = matrix4f.m23;
- matrix4f1.M[3][0] = matrix4f.m30;
- matrix4f1.M[3][1] = matrix4f.m31;
- matrix4f1.M[3][2] = matrix4f.m32;
- matrix4f1.M[3][3] = matrix4f.m33;
- return matrix4f1;
- }
-
- public static double lerp(double from, double to, double percent)
- {
- return from + (to - from) * percent;
- }
-
- public static double lerpMod(double from, double to, double percent, double mod)
- {
- return Math.abs(to - from) < mod / 2.0D ? from + (to - from) * percent : from + (to - from - Math.signum(to - from) * mod) * percent;
- }
-
- public static double absLerp(double value, double target, double stepSize)
- {
- double d0 = Math.abs(stepSize);
-
- if (target - value > d0)
- {
- return value + d0;
- }
- else
- {
- return target - value < -d0 ? value - d0 : target;
- }
- }
-
public static float angleDiff(float a, float b)
{
- float f = Math.abs(a - b) % 360.0F;
+ float f = abs(a - b) % 360.0F;
float f1 = f > 180.0F ? 360.0F - f : f;
int i = (!(a - b >= 0.0F) || !(a - b <= 180.0F)) && (!(a - b <= -180.0F) || !(a - b >= -360.0F)) ? -1 : 1;
return f1 * (float)i;
@@ -196,14 +100,6 @@ public static float angleNormalize(float angle)
return angle;
}
- public static Vector3f directionFromMatrix(Matrix4f matrix, float x, float y, float z)
- {
- Vector4f vector4f = new Vector4f(x, y, z, 0.0F);
- Matrix4f.transform(matrix, vector4f, vector4f);
- vector4f.normalise(vector4f);
- return new Vector3f(vector4f.x, vector4f.y, vector4f.z);
- }
-
public static void wordWrap(String in, int length, ArrayList wrapped)
{
// can't wrap with length 0, so return the original string
@@ -233,7 +129,7 @@ else if (flag)
}
else
{
- int i = Math.max(Math.max(in.lastIndexOf(" ", length), in.lastIndexOf("\t", length)), in.lastIndexOf("-", length));
+ int i = max(max(in.lastIndexOf(' ', length), in.lastIndexOf('\t', length)), in.lastIndexOf('-', length));
if (i == -1)
{
@@ -246,77 +142,6 @@ else if (flag)
}
}
- public static Vector2f convertVector(Vector2 vector)
- {
- return new Vector2f(vector.getX(), vector.getY());
- }
-
- public static Vector2 convertVector(Vector2f vector)
- {
- return new Vector2(vector.getX(), vector.getY());
- }
-
- public static Vector3f convertVector(Vector3 vector)
- {
- return new Vector3f(vector.getX(), vector.getY(), vector.getZ());
- }
-
- public static Vector3 convertVector(Vector3f vector)
- {
- return new Vector3(vector.getX(), vector.getY(), vector.getZ());
- }
-
- public static Vector3 convertVector(Vec3 vector)
- {
- return new Vector3((float)vector.x, (float)vector.y, (float)vector.z);
- }
-
- public static Vector3f convertToVector3f(Vec3 vector)
- {
- return new Vector3f((float)vector.x, (float)vector.y, (float)vector.z);
- }
-
- public static Vec3 convertToVector3d(Vector3 vector)
- {
- return new Vec3((double)vector.getX(), (double)vector.getY(), (double)vector.getZ());
- }
-
- public static Vec3 convertToVector3d(Vector3f vector)
- {
- return new Vec3((double)vector.x, (double)vector.y, (double)vector.z);
- }
-
- public static Vector3f transformVector(Matrix4f matrix, Vector3f vector, boolean point)
- {
- Vector4f vector4f = Matrix4f.transform(matrix, new Vector4f(vector.x, vector.y, vector.z, point ? 1.0F : 0.0F), (Vector4f)null);
- return new Vector3f(vector4f.x, vector4f.y, vector4f.z);
- }
-
- public static Quaternion quatLerp(Quaternion start, Quaternion end, float fraction)
- {
- Quaternion quaternion = new Quaternion();
- quaternion.w = start.w + (end.w - start.w) * fraction;
- quaternion.x = start.x + (end.x - start.x) * fraction;
- quaternion.y = start.y + (end.y - start.y) * fraction;
- quaternion.z = start.z + (end.z - start.z) * fraction;
- return quaternion;
- }
-
- public static Matrix4f matrix3to4(Matrix3f matrix)
- {
- Matrix4f matrix4f = new Matrix4f();
- matrix4f.m00 = matrix.m00;
- matrix4f.m01 = matrix.m01;
- matrix4f.m02 = matrix.m02;
- matrix4f.m10 = matrix.m10;
- matrix4f.m11 = matrix.m11;
- matrix4f.m12 = matrix.m12;
- matrix4f.m20 = matrix.m20;
- matrix4f.m21 = matrix.m21;
- matrix4f.m22 = matrix.m22;
- return matrix4f;
- }
-
public static InputStream getAssetAsStream(String name, boolean required)
{
InputStream inputstream = null;
@@ -325,7 +150,7 @@ public static InputStream getAssetAsStream(String name, boolean required)
{
try
{
- Optional resource = Minecraft.getInstance().getResourceManager().getResource(new ResourceLocation("vivecraft", name));
+ Optional resource = mc.getResourceManager().getResource(new ResourceLocation("vivecraft", name));
if (resource.isPresent()) {
inputstream = resource.get().open();
}
@@ -396,7 +221,7 @@ public static byte[] loadAsset(String name, boolean required)
public static String loadAssetAsString(String name, boolean required)
{
byte[] abyte = loadAsset(name, required);
- return abyte == null ? null : new String(abyte, Charsets.UTF_8);
+ return abyte == null ? null : new String(abyte, StandardCharsets.UTF_8);
}
public static void loadAssetToFile(String name, File file, boolean required)
@@ -425,7 +250,7 @@ private static void handleAssetException(Throwable e, String name, boolean requi
}
else
{
- System.out.println("Failed to load asset: " + name);
+ logger.error("Failed to load asset: {}", name);
e.printStackTrace();
}
}
@@ -448,22 +273,22 @@ public static void unpackNatives(String directory)
if (path1.toFile().exists())
{
- System.out.println("Copying " + directory + " natives...");
+ logger.info("Copying {} natives...", directory);
for (File file1 : path1.toFile().listFiles())
{
- System.out.println(file1.getName());
+ logger.info(file1.getName());
Files.copy(file1, new File("openvr/" + directory + "/" + file1.getName()));
}
return;
}
}
- catch (Exception exception)
+ catch (Exception ignored)
{
}
- System.out.println("Unpacking " + directory + " natives...");
+ logger.info("Unpacking {} natives...", directory);
Path jarPath = Xplat.getJarPath();
boolean didExtractSomething = false;
@@ -472,12 +297,12 @@ public static void unpackNatives(String directory)
for (Path file : natives.collect(Collectors.toCollection(ArrayList::new)))
{
didExtractSomething = true;
- System.out.println(file);
+ logger.info(file.toString());
java.nio.file.Files.copy(file, new File("openvr/" + directory + "/" + file.getFileName()).toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING);
}
} catch (IOException e)
{
- System.out.println("Failed to unpack natives from jar");
+ logger.info("Failed to unpack natives from jar");
}
if (!didExtractSomething) {
ZipFile zipfile = LoaderUtils.getVivecraftZip();
@@ -490,7 +315,7 @@ public static void unpackNatives(String directory)
if (zipentry.getName().startsWith("natives/" + directory))
{
String s = Paths.get(zipentry.getName()).getFileName().toString();
- System.out.println(s);
+ logger.info(s);
writeStreamToFile(zipfile.getInputStream(zipentry), new File("openvr/" + directory + "/" + s));
}
}
@@ -500,7 +325,7 @@ public static void unpackNatives(String directory)
}
catch (Exception exception1)
{
- System.out.println("Failed to unpack natives");
+ logger.error("Failed to unpack natives");
exception1.printStackTrace();
}
}
@@ -584,7 +409,7 @@ public static String httpReadAllString(String url) throws IOException
return new String(httpReadAll(url), StandardCharsets.UTF_8);
}
- public static void httpReadToFile(String url, File file, boolean writeWhenComplete) throws MalformedURLException, IOException
+ public static void httpReadToFile(String url, File file, boolean writeWhenComplete) throws IOException
{
HttpURLConnection httpurlconnection = (HttpURLConnection)(new URL(url)).openConnection();
httpurlconnection.setConnectTimeout(5000);
@@ -654,7 +479,7 @@ public static List httpReadList(String url) throws IOException
return list;
}
- public static String getFileChecksum(File file, String algorithm) throws FileNotFoundException, IOException, NoSuchAlgorithmException
+ public static String getFileChecksum(File file, String algorithm) throws IOException, NoSuchAlgorithmException
{
InputStream inputstream = new FileInputStream(file);
byte[] abyte = new byte[(int)file.length()];
@@ -674,15 +499,15 @@ public static String getFileChecksum(File file, String algorithm) throws FileNot
return s;
}
- public static byte[] readFile(File file) throws FileNotFoundException, IOException
+ public static byte[] readFile(File file) throws IOException
{
FileInputStream fileinputstream = new FileInputStream(file);
return readFully(fileinputstream);
}
- public static String readFileString(File file) throws FileNotFoundException, IOException
+ public static String readFileString(File file) throws IOException
{
- return new String(readFile(file), "UTF-8");
+ return new String(readFile(file), StandardCharsets.UTF_8);
}
public static byte[] readFully(InputStream in) throws IOException
@@ -700,33 +525,6 @@ public static byte[] readFully(InputStream in) throws IOException
return bytearrayoutputstream.toByteArray();
}
- public static Quaternion slerp(Quaternion start, Quaternion end, float alpha)
- {
- float f = start.x * end.x + start.y * end.y + start.z * end.z + start.w * end.w;
- float f1 = f < 0.0F ? -f : f;
- float f2 = 1.0F - alpha;
- float f3 = alpha;
-
- if ((double)(1.0F - f1) > 0.1D)
- {
- float f4 = (float)Math.acos((double)f1);
- float f5 = 1.0F / (float)Math.sin((double)f4);
- f2 = (float)Math.sin((double)((1.0F - alpha) * f4)) * f5;
- f3 = (float)Math.sin((double)(alpha * f4)) * f5;
- }
-
- if (f < 0.0F)
- {
- f3 = -f3;
- }
-
- float f8 = f2 * start.x + f3 * end.x;
- float f9 = f2 * start.y + f3 * end.y;
- float f6 = f2 * start.z + f3 * end.z;
- float f7 = f2 * start.w + f3 * end.w;
- return new Quaternion(f7, f8, f9, f6);
- }
-
public static Vec3 vecLerp(Vec3 start, Vec3 end, double fraction)
{
double d0 = start.x + (end.x - start.x) * fraction;
@@ -740,9 +538,9 @@ public static float applyDeadzone(float axis, float deadzone)
float f = 1.0F / (1.0F - deadzone);
float f1 = 0.0F;
- if (Math.abs(axis) > deadzone)
+ if (abs(axis) > deadzone)
{
- f1 = (Math.abs(axis) - deadzone) * f * Math.signum(axis);
+ f1 = (abs(axis) - deadzone) * f * signum(axis);
}
return f1;
@@ -750,8 +548,6 @@ public static float applyDeadzone(float axis, float deadzone)
public static void spawnParticles(ParticleOptions type, int count, Vec3 position, Vec3 size, double speed)
{
- Minecraft minecraft = Minecraft.getInstance();
-
for (int i = 0; i < count; ++i)
{
double d0 = avRandomizer.nextGaussian() * size.x;
@@ -763,11 +559,11 @@ public static void spawnParticles(ParticleOptions type, int count, Vec3 position
try
{
- minecraft.level.addParticle(type, position.x + d0, position.y + d1, position.z + d2, d3, d4, d5);
+ mc.level.addParticle(type, position.x + d0, position.y + d1, position.z + d2, d3, d4, d5);
}
catch (Throwable throwable)
{
- LogManager.getLogger().warn("Could not spawn particle effect {}", (Object)type);
+ logger.warn("Could not spawn particle effect {}", type);
return;
}
}
@@ -789,11 +585,10 @@ public static int getCombinedLightWithMin(BlockAndTintGetter lightReader, BlockP
public static void takeScreenshot(RenderTarget fb)
{
- Minecraft minecraft = Minecraft.getInstance();
- Screenshot.grab(minecraft.gameDirectory, fb, (text) ->
+ Screenshot.grab(mc.gameDirectory, fb, (text) ->
{
- minecraft.execute(() -> {
- minecraft.gui.getChat().addMessage(text);
+ mc.execute(() -> {
+ mc.gui.getChat().addMessage(text);
});
});
}
@@ -811,7 +606,7 @@ public static List wrapText(FormattedText text, int width, Font f
{
list.add(sameLine && linePrefix != null ? FormattedText.composite(linePrefix, lineText) : lineText);
});
- return (List)(list.isEmpty() ? Lists.newArrayList(FormattedText.EMPTY) : list);
+ return list.isEmpty() ? Lists.newArrayList(FormattedText.EMPTY) : list;
}
public static List styleToFormats(Style style)
@@ -877,187 +672,6 @@ public static String styleToFormatString(Style style)
return formatsToString(styleToFormats(style));
}
- public static long microTime()
- {
- return System.nanoTime() / 1000L;
- }
-
- public static long milliTime()
- {
- return System.nanoTime() / 1000000L;
- }
-
- public static void printStackIfContainsClass(String className)
- {
- StackTraceElement[] astacktraceelement = Thread.currentThread().getStackTrace();
- boolean flag = false;
-
- for (StackTraceElement stacktraceelement : astacktraceelement)
- {
- if (stacktraceelement.getClassName().equals(className))
- {
- flag = true;
- break;
- }
- }
-
- if (flag)
- {
- Thread.dumpStack();
- }
- }
-
- public static org.joml.Matrix4f Matrix4fFromOpenVR(HmdMatrix44 in)
- {
- return new org.joml.Matrix4f(in.m(0), in.m(4), in.m(8), in.m(12),
- in.m(1), in.m(5), in.m(9), in.m(13),
- in.m(2), in.m(6), in.m(10), in.m(14),
- in.m(3), in.m(7), in.m(11), in.m(15));
- }
-
- public static Quaternion convertMatrix4ftoRotationQuat(float m00, float m01, float m02, float m10, float m11, float m12, float m20, float m21, float m22)
- {
- double d0 = (double)(m00 * m00 + m10 * m10 + m20 * m20);
-
- if (d0 != 1.0D && d0 != 0.0D)
- {
- d0 = 1.0D / Math.sqrt(d0);
- m00 = (float)((double)m00 * d0);
- m10 = (float)((double)m10 * d0);
- m20 = (float)((double)m20 * d0);
- }
-
- d0 = (double)(m01 * m01 + m11 * m11 + m21 * m21);
-
- if (d0 != 1.0D && d0 != 0.0D)
- {
- d0 = 1.0D / Math.sqrt(d0);
- m01 = (float)((double)m01 * d0);
- m11 = (float)((double)m11 * d0);
- m21 = (float)((double)m21 * d0);
- }
-
- d0 = (double)(m02 * m02 + m12 * m12 + m22 * m22);
-
- if (d0 != 1.0D && d0 != 0.0D)
- {
- d0 = 1.0D / Math.sqrt(d0);
- m02 = (float)((double)m02 * d0);
- m12 = (float)((double)m12 * d0);
- m22 = (float)((double)m22 * d0);
- }
-
- float f = m00 + m11 + m22;
- Quaternion quaternion = new Quaternion();
-
- if (f >= 0.0F)
- {
- double d1 = Math.sqrt((double)(f + 1.0F));
- quaternion.w = (float)(0.5D * d1);
- d1 = 0.5D / d1;
- quaternion.x = (float)((double)(m21 - m12) * d1);
- quaternion.y = (float)((double)(m02 - m20) * d1);
- quaternion.z = (float)((double)(m10 - m01) * d1);
- }
- else if (m00 > m11 && m00 > m22)
- {
- double d4 = Math.sqrt(1.0D + (double)m00 - (double)m11 - (double)m22);
- quaternion.x = (float)(d4 * 0.5D);
- d4 = 0.5D / d4;
- quaternion.y = (float)((double)(m10 + m01) * d4);
- quaternion.z = (float)((double)(m02 + m20) * d4);
- quaternion.w = (float)((double)(m21 - m12) * d4);
- }
- else if (m11 > m22)
- {
- double d2 = Math.sqrt(1.0D + (double)m11 - (double)m00 - (double)m22);
- quaternion.y = (float)(d2 * 0.5D);
- d2 = 0.5D / d2;
- quaternion.x = (float)((double)(m10 + m01) * d2);
- quaternion.z = (float)((double)(m21 + m12) * d2);
- quaternion.w = (float)((double)(m02 - m20) * d2);
- }
- else
- {
- double d3 = Math.sqrt(1.0D + (double)m22 - (double)m00 - (double)m11);
- quaternion.z = (float)(d3 * 0.5D);
- d3 = 0.5D / d3;
- quaternion.x = (float)((double)(m02 + m20) * d3);
- quaternion.y = (float)((double)(m21 + m12) * d3);
- quaternion.w = (float)((double)(m10 - m01) * d3);
- }
-
- return quaternion;
- }
-
- public static org.vivecraft.common.utils.math.Matrix4f rotationXMatrix(float angle)
- {
- float f = (float)Math.sin((double)angle);
- float f1 = (float)Math.cos((double)angle);
- return new org.vivecraft.common.utils.math.Matrix4f(1.0F, 0.0F, 0.0F, 0.0F, f1, -f, 0.0F, f, f1);
- }
-
- public static org.vivecraft.common.utils.math.Matrix4f rotationZMatrix(float angle)
- {
- float f = (float)Math.sin((double)angle);
- float f1 = (float)Math.cos((double)angle);
- return new org.vivecraft.common.utils.math.Matrix4f(f1, -f, 0.0F, f, f1, 0.0F, 0.0F, 0.0F, 1.0F);
- }
-
- public static Vector3 convertMatrix4ftoTranslationVector(org.vivecraft.common.utils.math.Matrix4f mat)
- {
- return new Vector3(mat.M[0][3], mat.M[1][3], mat.M[2][3]);
- }
-
- public static void Matrix4fSet(org.vivecraft.common.utils.math.Matrix4f mat, float m11, float m12, float m13, float m14, float m21, float m22, float m23, float m24, float m31, float m32, float m33, float m34, float m41, float m42, float m43, float m44)
- {
- mat.M[0][0] = m11;
- mat.M[0][1] = m12;
- mat.M[0][2] = m13;
- mat.M[0][3] = m14;
- mat.M[1][0] = m21;
- mat.M[1][1] = m22;
- mat.M[1][2] = m23;
- mat.M[1][3] = m24;
- mat.M[2][0] = m31;
- mat.M[2][1] = m32;
- mat.M[2][2] = m33;
- mat.M[2][3] = m34;
- mat.M[3][0] = m41;
- mat.M[3][1] = m42;
- mat.M[3][2] = m43;
- mat.M[3][3] = m44;
- }
-
- public static void Matrix4fCopy(org.vivecraft.common.utils.math.Matrix4f source, org.vivecraft.common.utils.math.Matrix4f dest)
- {
- dest.M[0][0] = source.M[0][0];
- dest.M[0][1] = source.M[0][1];
- dest.M[0][2] = source.M[0][2];
- dest.M[0][3] = source.M[0][3];
- dest.M[1][0] = source.M[1][0];
- dest.M[1][1] = source.M[1][1];
- dest.M[1][2] = source.M[1][2];
- dest.M[1][3] = source.M[1][3];
- dest.M[2][0] = source.M[2][0];
- dest.M[2][1] = source.M[2][1];
- dest.M[2][2] = source.M[2][2];
- dest.M[2][3] = source.M[2][3];
- dest.M[3][0] = source.M[3][0];
- dest.M[3][1] = source.M[3][1];
- dest.M[3][2] = source.M[3][2];
- dest.M[3][3] = source.M[3][3];
- }
-
- public static org.vivecraft.common.utils.math.Matrix4f Matrix4fSetIdentity(org.vivecraft.common.utils.math.Matrix4f mat)
- {
- mat.M[0][0] = mat.M[1][1] = mat.M[2][2] = mat.M[3][3] = 1.0F;
- mat.M[0][1] = mat.M[1][0] = mat.M[2][3] = mat.M[3][1] = 0.0F;
- mat.M[0][2] = mat.M[1][2] = mat.M[2][0] = mat.M[3][2] = 0.0F;
- mat.M[0][3] = mat.M[1][3] = mat.M[2][1] = mat.M[3][0] = 0.0F;
- return mat;
- }
-
static
{
Arrays.sort(illegalChars);
diff --git a/common/src/main/java/org/vivecraft/client/utils/math/BezierCurve.java b/common/src/main/java/org/vivecraft/client/utils/math/BezierCurve.java
deleted file mode 100644
index 338aeb87f..000000000
--- a/common/src/main/java/org/vivecraft/client/utils/math/BezierCurve.java
+++ /dev/null
@@ -1,127 +0,0 @@
-package org.vivecraft.client.utils.math;
-
-import com.mojang.blaze3d.systems.RenderSystem;
-import com.mojang.blaze3d.vertex.BufferBuilder;
-import com.mojang.blaze3d.vertex.DefaultVertexFormat;
-import com.mojang.blaze3d.vertex.Tesselator;
-import com.mojang.blaze3d.vertex.VertexFormat.Mode;
-
-import java.awt.Color;
-import java.util.ArrayList;
-import java.util.Arrays;
-import net.minecraft.client.Minecraft;
-import net.minecraft.world.entity.player.Player;
-import net.minecraft.world.phys.Vec3;
-
-public class BezierCurve
-{
- public ArrayList nodes = new ArrayList<>();
- boolean circular;
-
- public BezierCurve(Node[] nodes, boolean circular)
- {
- this.nodes.addAll(Arrays.asList(nodes));
- this.circular = circular;
- }
-
- public BezierCurve(boolean circular)
- {
- this.circular = circular;
- }
-
- Vec3 getIntermediate(Node n1, Node n2, double perc)
- {
- Vec3 vec3 = n1.vertex;
- Vec3 vec31 = n1.controlOut;
- Vec3 vec32 = n2.controlIn;
- Vec3 vec33 = n2.vertex;
- return vec3.scale(Math.pow(1.0D - perc, 3.0D)).add(vec31.scale(3.0D * Math.pow(1.0D - perc, 2.0D) * perc)).add(vec32.scale(3.0D * (1.0D - perc) * Math.pow(perc, 2.0D))).add(vec33.scale(Math.pow(perc, 3.0D)));
- }
-
- public Vec3 getPointOnPath(double perc)
- {
- int i = this.circular ? this.nodes.size() : this.nodes.size() - 1;
- double d0 = perc * (double)i;
- int j = (int)Math.floor(d0) % this.nodes.size();
- int k = (int)Math.ceil(d0) % this.nodes.size();
-
- if (j == k)
- {
- return (this.nodes.get(j)).vertex;
- }
- else
- {
- Node beziercurve$node = this.nodes.get(j);
- Node beziercurve$node1 = this.nodes.get(k);
- return this.getIntermediate(beziercurve$node, beziercurve$node1, d0 - (double)j);
- }
- }
-
- public Vec3[] getLinearInterpolation(int verticesPerNode)
- {
- if (this.nodes.size() == 0)
- {
- return new Vec3[0];
- }
- else
- {
- int i = verticesPerNode * (this.circular ? this.nodes.size() : this.nodes.size() - 1) + 1;
- Vec3[] avec3 = new Vec3[i];
-
- for (int j = 0; j < i; ++j)
- {
- double d0 = (double)j / (double)Math.max(1, i - 1);
- avec3[j] = this.getPointOnPath(d0);
- }
-
- return avec3;
- }
- }
-
- public void render(int vertexCount, Color c, float partialTicks)
- {
- Player player = Minecraft.getInstance().player;
- double d0 = player.xOld + (player.getX() - player.xOld) * (double)partialTicks;
- double d1 = player.yOld + (player.getY() - player.yOld) * (double)partialTicks;
- double d2 = player.zOld + (player.getZ() - player.zOld) * (double)partialTicks;
- //GlStateManager._disableLighting();
- RenderSystem.depthMask(false);
- Tesselator tesselator = Tesselator.getInstance();
- BufferBuilder bufferbuilder = tesselator.getBuilder();
- bufferbuilder.begin(Mode.LINES, DefaultVertexFormat.POSITION_COLOR);
- Vec3[] avec3 = this.getLinearInterpolation(vertexCount / this.nodes.size());
-
- for (int i = 0; i < avec3.length; ++i)
- {
- this.renderVertex(bufferbuilder, avec3[i], c, d0, d1, d2);
- }
-
- tesselator.end();
- //GlStateManager._enableLighting();
- RenderSystem.depthMask(true);
- }
-
- void renderVertex(BufferBuilder buffer, Vec3 vert, Color color, double offX, double offY, double offZ)
- {
- buffer.vertex(vert.x - offX, vert.y - offY, vert.z - offZ).color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()).endVertex();
- }
-
- public static class Node
- {
- Vec3 vertex;
- Vec3 controlIn;
- Vec3 controlOut;
-
- public Node(Vec3 vertex, Vec3 controlIn, Vec3 controlOut)
- {
- this.vertex = vertex;
- this.controlIn = controlIn;
- this.controlOut = controlOut;
- }
-
- public Node(Vec3 vertex, Vec3 controlDir, double controlLenIn, double controlLenOut)
- {
- this(vertex, vertex.add(controlDir.normalize().scale(-controlLenIn)), vertex.add(controlDir.normalize().scale(controlLenOut)));
- }
- }
-}
diff --git a/common/src/main/java/org/vivecraft/client_vr/ClientDataHolderVR.java b/common/src/main/java/org/vivecraft/client_vr/ClientDataHolderVR.java
index 0f69f1e8a..1d300165b 100644
--- a/common/src/main/java/org/vivecraft/client_vr/ClientDataHolderVR.java
+++ b/common/src/main/java/org/vivecraft/client_vr/ClientDataHolderVR.java
@@ -1,7 +1,5 @@
package org.vivecraft.client_vr;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.resources.model.ModelResourceLocation;
import org.vivecraft.client_vr.gameplay.VRPlayer;
import org.vivecraft.client_vr.gameplay.trackers.*;
import org.vivecraft.client_vr.menuworlds.MenuWorldRenderer;
@@ -10,6 +8,10 @@
import org.vivecraft.client_vr.render.RenderPass;
import org.vivecraft.client_vr.settings.VRSettings;
+import net.minecraft.client.resources.model.ModelResourceLocation;
+
+import javax.annotation.Nonnull;
+
public class ClientDataHolderVR {
public static boolean kiosk;
@@ -17,66 +19,44 @@ public class ClientDataHolderVR {
public static boolean katvr;
public static boolean infinadeck;
public static boolean viewonly;
- public static ModelResourceLocation thirdPersonCameraModel = new ModelResourceLocation("vivecraft", "camcorder", "");
- public static ModelResourceLocation thirdPersonCameraDisplayModel = new ModelResourceLocation("vivecraft", "camcorder_display", "");
- private static ClientDataHolderVR INSTANCE;
+ public static final ModelResourceLocation thirdPersonCameraModel = new ModelResourceLocation("vivecraft", "camcorder", "");
+ public static final ModelResourceLocation thirdPersonCameraDisplayModel = new ModelResourceLocation("vivecraft", "camcorder_display", "");
public VRPlayer vrPlayer;
public MCVR vr;
public VRRenderer vrRenderer;
- public MenuWorldRenderer menuWorldRenderer;
- public BackpackTracker backpackTracker = new BackpackTracker(Minecraft.getInstance(), this);
- public BowTracker bowTracker = new BowTracker(Minecraft.getInstance(), this);
- public SwimTracker swimTracker = new SwimTracker(Minecraft.getInstance(), this);
- public EatingTracker autoFood = new EatingTracker(Minecraft.getInstance(), this);
- public JumpTracker jumpTracker = new JumpTracker(Minecraft.getInstance(), this);
- public SneakTracker sneakTracker = new SneakTracker(Minecraft.getInstance(), this);
- public ClimbTracker climbTracker = new ClimbTracker(Minecraft.getInstance(), this);
- public RunTracker runTracker = new RunTracker(Minecraft.getInstance(), this);
- public RowTracker rowTracker = new RowTracker(Minecraft.getInstance(), this);
- public TeleportTracker teleportTracker = new TeleportTracker(Minecraft.getInstance(), this);
- public SwingTracker swingTracker = new SwingTracker(Minecraft.getInstance(), this);
- public HorseTracker horseTracker = new HorseTracker(Minecraft.getInstance(), this);
- public VehicleTracker vehicleTracker = new VehicleTracker(Minecraft.getInstance(), this);
- public InteractTracker interactTracker = new InteractTracker(Minecraft.getInstance(), this);
- public CrawlTracker crawlTracker = new CrawlTracker(Minecraft.getInstance(), this);
- public CameraTracker cameraTracker = new CameraTracker(Minecraft.getInstance(), this);
public VRSettings vrSettings;
+ public MenuWorldRenderer menuWorldRenderer;
+ public final BackpackTracker backpackTracker = new BackpackTracker();
+ public final BowTracker bowTracker = new BowTracker();
+ public final CameraTracker cameraTracker = new CameraTracker();
+ public final ClimbTracker climbTracker = new ClimbTracker();
+ public final CrawlTracker crawlTracker = new CrawlTracker();
+ public final EatingTracker eatingTracker = new EatingTracker();
+ public final HorseTracker horseTracker = new HorseTracker();
+ public final InteractTracker interactTracker = new InteractTracker();
+ public final JumpTracker jumpTracker = new JumpTracker();
+ public final RowTracker rowTracker = new RowTracker();
+ public final RunTracker runTracker = new RunTracker();
+ public final SneakTracker sneakTracker = new SneakTracker();
+ public final SwimTracker swimTracker = new SwimTracker();
+ public final SwingTracker swingTracker = new SwingTracker();
+ public final TeleportTracker teleportTracker = new TeleportTracker();
+ public final TelescopeTracker telescopeTracker = new TelescopeTracker();
+ public final VehicleTracker vehicleTracker = new VehicleTracker();
public boolean integratedServerLaunchInProgress = false;
public boolean grabScreenShot = false;
public long frameIndex = 0L;
- public RenderPass currentPass;
+ @Nonnull public RenderPass currentPass = RenderPass.VANILLA;
public int tickCounter;
public float watereffect;
public float portaleffect;
public float pumpkineffect;
public static boolean isfphand;
public boolean isFirstPass;
- long mirroNotifyStart;
- String mirrorNotifyText;
- boolean mirrorNotifyClear;
- long mirroNotifyLen;
// showed chat notifications
public boolean showedUpdateNotification;
public boolean skipStupidGoddamnChunkBoundaryClipping;
-
-
- public static ClientDataHolderVR getInstance() {
- if (INSTANCE == null) {
- INSTANCE = new ClientDataHolderVR();
- }
- return INSTANCE;
- }
-
- public void printChatMessage(String string) {
- // TODO Auto-generated method stub
-
- }
-
- public void print(String string) {
- string = string.replace("\n", "\n[Minecrift] ");
- System.out.println("[Minecrift] " + string);
- }
}
diff --git a/common/src/main/java/org/vivecraft/client_vr/ItemTags.java b/common/src/main/java/org/vivecraft/client_vr/ItemTags.java
index db3ce568f..3a5d5f396 100644
--- a/common/src/main/java/org/vivecraft/client_vr/ItemTags.java
+++ b/common/src/main/java/org/vivecraft/client_vr/ItemTags.java
@@ -6,37 +6,37 @@
import net.minecraft.world.item.Item;
public class ItemTags {
- public final static TagKey- VIVECRAFT_ARROWS = tag("arrows");
+ public static final TagKey
- VIVECRAFT_ARROWS = tag("arrows");
- public final static TagKey
- VIVECRAFT_BRUSHES = tag("brushes");
+ public static final TagKey
- VIVECRAFT_BRUSHES = tag("brushes");
- public final static TagKey
- VIVECRAFT_COMPASSES = tag("compasses");
+ public static final TagKey
- VIVECRAFT_COMPASSES = tag("compasses");
- public final static TagKey
- VIVECRAFT_CROSSBOWS = tag("crossbows");
+ public static final TagKey
- VIVECRAFT_CROSSBOWS = tag("crossbows");
- public final static TagKey
- VIVECRAFT_FISHING_RODS = tag("fishing_rods");
+ public static final TagKey
- VIVECRAFT_FISHING_RODS = tag("fishing_rods");
- public final static TagKey
- VIVECRAFT_FOOD_STICKS = tag("food_sticks");
+ public static final TagKey
- VIVECRAFT_FOOD_STICKS = tag("food_sticks");
- public final static TagKey
- VIVECRAFT_HOES = tag("hoes");
+ public static final TagKey
- VIVECRAFT_HOES = tag("hoes");
- public final static TagKey
- VIVECRAFT_MAPS = tag("maps");
+ public static final TagKey
- VIVECRAFT_MAPS = tag("maps");
- public final static TagKey
- VIVECRAFT_SCYTHES = tag("scythes");
+ public static final TagKey
- VIVECRAFT_SCYTHES = tag("scythes");
- public final static TagKey
- VIVECRAFT_SHIELDS = tag("shields");
+ public static final TagKey
- VIVECRAFT_SHIELDS = tag("shields");
- public final static TagKey
- VIVECRAFT_SPEARS = tag("spears");
+ public static final TagKey
- VIVECRAFT_SPEARS = tag("spears");
- public final static TagKey
- VIVECRAFT_SWORDS = tag("swords");
+ public static final TagKey
- VIVECRAFT_SWORDS = tag("swords");
- public final static TagKey
- VIVECRAFT_TELESCOPE = tag("telescope");
+ public static final TagKey
- VIVECRAFT_TELESCOPE = tag("telescope");
- public final static TagKey
- VIVECRAFT_THROW_ITEMS = tag("throw_items");
+ public static final TagKey
- VIVECRAFT_THROW_ITEMS = tag("throw_items");
- public final static TagKey
- VIVECRAFT_TOOLS = tag("tools");
+ public static final TagKey
- VIVECRAFT_TOOLS = tag("tools");
- private static TagKey
- tag(String name){
+ private static TagKey
- tag(final String name){
return TagKey.create(Registries.ITEM, new ResourceLocation("vivecraft", name));
}
}
diff --git a/common/src/main/java/org/vivecraft/client_vr/MethodHolder.java b/common/src/main/java/org/vivecraft/client_vr/MethodHolder.java
deleted file mode 100644
index 045a235a6..000000000
--- a/common/src/main/java/org/vivecraft/client_vr/MethodHolder.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package org.vivecraft.client_vr;
-
-import com.mojang.math.Axis;
-import org.joml.AxisAngle4f;
-import org.lwjgl.glfw.GLFW;
-import org.vivecraft.client_vr.provider.InputSimulator;
-
-import com.mojang.blaze3d.vertex.PoseStack;
-import org.joml.Quaternionf;
-
-import net.minecraft.client.Minecraft;
-
-public abstract class MethodHolder {
-
- public static boolean isKeyDown(int i) {
- return GLFW.glfwGetKey(Minecraft.getInstance().getWindow().getWindow(), i) == 1 || InputSimulator.isKeyDown(i);
- }
-
- public static void notifyMirror(String text, boolean clear, int lengthMs)
- {
- ClientDataHolderVR clientDataHolderVR = ClientDataHolderVR.getInstance();
- clientDataHolderVR.mirroNotifyStart = System.currentTimeMillis();
- clientDataHolderVR.mirroNotifyLen = (long)lengthMs;
- clientDataHolderVR.mirrorNotifyText = text;
- clientDataHolderVR.mirrorNotifyClear = clear;
- }
-
- public static void rotateDeg(PoseStack pose, float angle, float x, float y, float z) {
- pose.mulPose(new Quaternionf(new AxisAngle4f(angle * 0.017453292F, x, y, z)));
- }
-
- public static void rotateDegXp(PoseStack matrix, int i) {
- matrix.mulPose(Axis.XP.rotationDegrees(i));
- }
-}
diff --git a/common/src/main/java/org/vivecraft/client_vr/ScreenUtils.java b/common/src/main/java/org/vivecraft/client_vr/ScreenUtils.java
index 3021889e5..49b9e8785 100644
--- a/common/src/main/java/org/vivecraft/client_vr/ScreenUtils.java
+++ b/common/src/main/java/org/vivecraft/client_vr/ScreenUtils.java
@@ -1,12 +1,13 @@
package org.vivecraft.client_vr;
-import java.util.ArrayList;
-import java.util.List;
-
import net.minecraft.client.gui.components.AbstractWidget;
import net.minecraft.client.gui.components.events.GuiEventListener;
import net.minecraft.client.gui.screens.Screen;
-import org.vivecraft.client_vr.ClientDataHolderVR;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.vivecraft.client_vr.VRState.dh;
public class ScreenUtils {
@@ -40,25 +41,21 @@ public static AbstractWidget getSelectedButton(Screen screen, int x, int y)
}
public static int getBGFrom(){
- if(ClientDataHolderVR.getInstance().vrSettings==null || ClientDataHolderVR.getInstance().vrSettings.menuBackground)
+ if(dh.vrSettings == null || dh.vrSettings.menuBackground)
return -1072689136;
return 0;
}
public static int getBGTo(){
- if(ClientDataHolderVR.getInstance().vrSettings==null || ClientDataHolderVR.getInstance().vrSettings.menuBackground)
+ if(dh.vrSettings == null || dh.vrSettings.menuBackground)
return -804253680;
return 0;
}
public static AbstractWidget getSelectedButton(int x, int y, List listButtons)
{
- for (int i = 0; i < listButtons.size(); ++i)
- {
- AbstractWidget abstractwidget = listButtons.get(i);
-
- if (abstractwidget.visible)
- {
+ for (AbstractWidget abstractwidget : listButtons) {
+ if (abstractwidget.visible) {
int j = abstractwidget.getWidth();
int k = abstractwidget.getHeight();
@@ -72,4 +69,4 @@ public static AbstractWidget getSelectedButton(int x, int y, List this.eye0;
+ case RIGHT -> this.eye1;
+ case THIRD -> this.c2;
+ case SCOPER -> this.t0;
+ case SCOPEL -> this.t1;
+ case CAMERA -> this.cam;
+ default -> this.hmd;
+ };
}
public String toString()
@@ -176,11 +190,7 @@ public String toString()
return "data:\r\n \t\t origin: " + this.origin + "\r\n \t\t rotation: " + String.format("%.2f", this.rotation_radians) + "\r\n \t\t scale: " + String.format("%.2f", this.worldScale) + "\r\n \t\t hmd " + this.hmd + "\r\n \t\t c0 " + this.c0 + "\r\n \t\t c1 " + this.c1 + "\r\n \t\t c2 " + this.c2;
}
- protected Vec3 vecMult(Vec3 in, float factor)
- {
- return new Vec3(in.x * (double)factor, in.y * (double)factor, in.z * (double)factor);
- }
-
+ @ParametersAreNonnullByDefault
public class VRDevicePose
{
final VRData data;
@@ -191,50 +201,48 @@ public class VRDevicePose
public VRDevicePose(VRData data, Matrix4f matrix, Vec3 pos, Vec3 dir)
{
this.data = data;
- this.matrix = matrix.transposed().transposed();
+ this.matrix = new Matrix4f(matrix);
this.pos = new Vec3(pos.x, pos.y, pos.z);
this.dir = new Vec3(dir.x, dir.y, dir.z);
}
public Vec3 getPosition()
{
- Vec3 vec3 = this.pos.scale((double)VRData.this.worldScale);
- vec3 = vec3.yRot(this.data.rotation_radians);
- return vec3.add(this.data.origin.x, this.data.origin.y, this.data.origin.z);
+ return this.pos.scale(this.data.worldScale).yRot(this.data.rotation_radians).add(this.data.origin);
}
public Vec3 getDirection()
{
- return (new Vec3(this.dir.x, this.dir.y, this.dir.z)).yRot(this.data.rotation_radians);
+ return this.dir.yRot(this.data.rotation_radians);
}
public Vec3 getCustomVector(Vec3 axis)
{
- Vector3 vector3 = this.matrix.transform(new Vector3((float)axis.x, (float)axis.y, (float)axis.z));
- return vector3.toVector3d().yRot(this.data.rotation_radians);
+ return convertToVec3(
+ new Vector3f((float)axis.x, (float)axis.y, (float)axis.z).mulProject(this.matrix).rotateY(this.data.rotation_radians)
+ );
}
public float getYaw()
{
Vec3 vec3 = this.getDirection();
- return (float)Math.toDegrees(Math.atan2(-vec3.x, vec3.z));
+ return (float)toDegrees(atan2(-vec3.x, vec3.z));
}
public float getPitch()
{
Vec3 vec3 = this.getDirection();
- return (float)Math.toDegrees(Math.asin(vec3.y / vec3.length()));
+ return (float)toDegrees(asin(vec3.y / vec3.length()));
}
public float getRoll()
{
- return (float)(-Math.toDegrees(Math.atan2((double)this.matrix.M[1][0], (double)this.matrix.M[1][1])));
+ return (float)(-toDegrees(atan2(this.matrix.m10(), this.matrix.m11())));
}
public Matrix4f getMatrix()
{
- Matrix4f matrix4f = Matrix4f.rotationY(VRData.this.rotation_radians);
- return Matrix4f.multiply(matrix4f, this.matrix);
+ return new Matrix4f(this.matrix).rotateY(this.data.rotation_radians);
}
public String toString()
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 145a5f82a..d636c0139 100644
--- a/common/src/main/java/org/vivecraft/client_vr/VRState.java
+++ b/common/src/main/java/org/vivecraft/client_vr/VRState.java
@@ -1,23 +1,41 @@
package org.vivecraft.client_vr;
-import net.minecraft.client.Minecraft;
-import net.minecraft.network.chat.Component;
-import org.lwjgl.glfw.GLFW;
-import org.vivecraft.client_vr.gameplay.VRPlayer;
import org.vivecraft.client.gui.screens.ErrorScreen;
+import org.vivecraft.client_vr.gameplay.VRPlayer;
import org.vivecraft.client_vr.menuworlds.MenuWorldRenderer;
import org.vivecraft.client_vr.provider.nullvr.NullVR;
import org.vivecraft.client_vr.provider.openvr_lwjgl.MCOpenVR;
import org.vivecraft.client_vr.render.RenderConfigException;
-import org.vivecraft.client_vr.settings.VRSettings;
import org.vivecraft.client_xr.render_pass.RenderPassManager;
import org.vivecraft.mod_compat_vr.optifine.OptifineHelper;
+import net.minecraft.network.chat.Component;
+
+import javax.annotation.Nonnull;
+
+/**
+ * The VR State Controller.
+ *
+ * Holds global toggles and other data holders.
+ */
public class VRState {
public static boolean vrRunning = false;
public static boolean vrEnabled = false;
public static boolean vrInitialized = false;
+ /**
+ * The MC Data Holder.
+ * @apiNote Intended for use internal to Vivecraft.
+ *
+ * Other mods should {@link net.minecraft.client.Minecraft#getInstance()} instead.
+ * @see org.vivecraft.mixin.client_vr.MinecraftVRMixin#initVivecraft(net.minecraft.client.gui.screens.Overlay)
+ */
+ @Nonnull public static net.minecraft.client.Minecraft mc = net.minecraft.client.Minecraft.getInstance();
+ /**
+ * The VR Data Holder.
+ * @see org.vivecraft.mixin.client_vr.MinecraftVRMixin#initVivecraft(net.minecraft.client.gui.screens.Overlay)
+ */
+ @Nonnull public static final ClientDataHolderVR dh = new ClientDataHolderVR();
public static void initializeVR() {
if (vrInitialized) {
@@ -29,63 +47,61 @@ public static void initializeVR() {
}
vrInitialized = true;
- ClientDataHolderVR dh = ClientDataHolderVR.getInstance();
- if (dh.vrSettings.stereoProviderPluginID == VRSettings.VRProvider.OPENVR) {
- dh.vr = new MCOpenVR(Minecraft.getInstance(), dh);
- } else {
- dh.vr = new NullVR(Minecraft.getInstance(), dh);
- }
- if (!dh.vr.init()) {
- throw new RenderConfigException("VR init Error", Component.translatable("vivecraft.messages.rendersetupfailed", dh.vr.initStatus + "\nVR provider: " + dh.vr.getName()));
- }
+ dh.vr = switch (dh.vrSettings.stereoProviderPluginID) {
+ case OPENVR -> new MCOpenVR();
+ default -> new NullVR();
+ };
+ if (dh.vr.init()) {
+ dh.vrRenderer = dh.vr.createVRRenderer();
+ dh.vrRenderer.lastGuiScale = mc.options.guiScale().get();
+ try
+ {
+ dh.vrRenderer.setupRenderConfiguration();
+ RenderPassManager.setVanillaRenderPass();
+ } catch (RenderConfigException renderConfigException)
+ {
+ throw new RenderConfigException("VR Render Error", Component.translatable("vivecraft.messages.rendersetupfailed", renderConfigException.error.getString() + "\nVR provider: " + dh.vr.getName()));
+ } catch (Exception e)
+ {
+ e.printStackTrace();
+ }
- dh.vrRenderer = dh.vr.createVRRenderer();
- dh.vrRenderer.lastGuiScale = Minecraft.getInstance().options.guiScale().get();
- try {
- dh.vrRenderer.setupRenderConfiguration();
- RenderPassManager.setVanillaRenderPass();
- } catch(RenderConfigException renderConfigException) {
- throw new RenderConfigException("VR Render Error", Component.translatable("vivecraft.messages.rendersetupfailed", renderConfigException.error.getString() + "\nVR provider: " + dh.vr.getName()));
- } catch(Exception e) {
- e.printStackTrace();
- }
-
- dh.vrPlayer = new VRPlayer();
- dh.vrPlayer.registerTracker(dh.backpackTracker);
- dh.vrPlayer.registerTracker(dh.bowTracker);
- dh.vrPlayer.registerTracker(dh.climbTracker);
- dh.vrPlayer.registerTracker(dh.autoFood);
- dh.vrPlayer.registerTracker(dh.jumpTracker);
- dh.vrPlayer.registerTracker(dh.rowTracker);
- dh.vrPlayer.registerTracker(dh.runTracker);
- dh.vrPlayer.registerTracker(dh.sneakTracker);
- dh.vrPlayer.registerTracker(dh.swimTracker);
- dh.vrPlayer.registerTracker(dh.swingTracker);
- dh.vrPlayer.registerTracker(dh.interactTracker);
- dh.vrPlayer.registerTracker(dh.teleportTracker);
- dh.vrPlayer.registerTracker(dh.horseTracker);
- dh.vrPlayer.registerTracker(dh.vehicleTracker);
- dh.vrPlayer.registerTracker(dh.crawlTracker);
- dh.vrPlayer.registerTracker(dh.cameraTracker);
+ dh.vrPlayer = new VRPlayer();
+ dh.vrPlayer.registerTracker(dh.backpackTracker);
+ dh.vrPlayer.registerTracker(dh.bowTracker);
+ dh.vrPlayer.registerTracker(dh.climbTracker);
+ dh.vrPlayer.registerTracker(dh.eatingTracker);
+ dh.vrPlayer.registerTracker(dh.jumpTracker);
+ dh.vrPlayer.registerTracker(dh.rowTracker);
+ dh.vrPlayer.registerTracker(dh.runTracker);
+ dh.vrPlayer.registerTracker(dh.sneakTracker);
+ dh.vrPlayer.registerTracker(dh.swimTracker);
+ dh.vrPlayer.registerTracker(dh.swingTracker);
+ dh.vrPlayer.registerTracker(dh.interactTracker);
+ dh.vrPlayer.registerTracker(dh.teleportTracker);
+ dh.vrPlayer.registerTracker(dh.horseTracker);
+ dh.vrPlayer.registerTracker(dh.vehicleTracker);
+ dh.vrPlayer.registerTracker(dh.crawlTracker);
+ dh.vrPlayer.registerTracker(dh.cameraTracker);
- dh.vr.postinit();
+ dh.vr.postinit();
- dh.menuWorldRenderer = new MenuWorldRenderer();
+ dh.menuWorldRenderer = new MenuWorldRenderer();
- dh.menuWorldRenderer.init();
+ dh.menuWorldRenderer.init();
+ }
+ else
+ {
+ throw new RenderConfigException("VR init Error", Component.translatable("vivecraft.messages.rendersetupfailed", dh.vr.initStatus + "\nVR provider: " + dh.vr.getName()));
+ }
} catch (RenderConfigException renderConfigException) {
vrEnabled = false;
destroyVR(true);
- Minecraft.getInstance().setScreen(new ErrorScreen(renderConfigException.title, renderConfigException.error));
+ mc.setScreen(new ErrorScreen(renderConfigException.title, renderConfigException.error));
}
}
- public static void startVR() {
- GLFW.glfwSwapInterval(0);
- }
-
public static void destroyVR(boolean disableVRSetting) {
- ClientDataHolderVR dh = ClientDataHolderVR.getInstance();
if (dh.vr != null) {
dh.vr.destroy();
}
@@ -103,12 +119,8 @@ public static void destroyVR(boolean disableVRSetting) {
vrInitialized = false;
vrRunning = false;
if (disableVRSetting) {
- ClientDataHolderVR.getInstance().vrSettings.vrEnabled = false;
- ClientDataHolderVR.getInstance().vrSettings.saveOptions();
+ dh.vrSettings.vrEnabled = false;
+ dh.vrSettings.saveOptions();
}
}
-
- public static void pauseVR() {
- // GLFW.glfwSwapInterval(bl ? 1 : 0);
- }
}
diff --git a/common/src/main/java/org/vivecraft/client_vr/VRTextureTarget.java b/common/src/main/java/org/vivecraft/client_vr/VRTextureTarget.java
index 50e095fdf..36ba4a012 100644
--- a/common/src/main/java/org/vivecraft/client_vr/VRTextureTarget.java
+++ b/common/src/main/java/org/vivecraft/client_vr/VRTextureTarget.java
@@ -1,10 +1,11 @@
package org.vivecraft.client_vr;
-import com.mojang.blaze3d.pipeline.RenderTarget;
-import com.mojang.blaze3d.systems.RenderSystem;
import org.vivecraft.client.Xplat;
import org.vivecraft.client.extensions.RenderTargetExtension;
+import com.mojang.blaze3d.pipeline.RenderTarget;
+import com.mojang.blaze3d.systems.RenderSystem;
+
public class VRTextureTarget extends RenderTarget {
private final String name;
@@ -24,15 +25,19 @@ public VRTextureTarget(String name, int width, int height, boolean usedepth, boo
@Override
public String toString() {
- StringBuilder stringbuilder = new StringBuilder();
- stringbuilder.append("\n");
- if (this.name != null) {
- stringbuilder.append("Name: " + this.name).append("\n");
- }
- stringbuilder.append("Size: " + this.viewWidth + " x " + this.viewHeight).append("\n");
- stringbuilder.append("FB ID: " + this.frameBufferId).append("\n");
- stringbuilder.append("Tex ID: " + this.colorTextureId).append("\n");
- return stringbuilder.toString();
+ return """
+ Texture Target:
+ Name: %s
+ Size: %d x %d
+ FB ID: %d
+ Tex ID: %d
+ """.formatted(
+ this.name,
+ this.viewWidth,
+ this.viewHeight,
+ this.frameBufferId,
+ this.colorTextureId
+ );
}
}
diff --git a/common/src/main/java/org/vivecraft/client_vr/Vec3History.java b/common/src/main/java/org/vivecraft/client_vr/Vec3History.java
index a7505fe8a..e9dde6f9c 100644
--- a/common/src/main/java/org/vivecraft/client_vr/Vec3History.java
+++ b/common/src/main/java/org/vivecraft/client_vr/Vec3History.java
@@ -1,48 +1,58 @@
package org.vivecraft.client_vr;
-import java.util.LinkedList;
-import java.util.ListIterator;
+import org.joml.Vector3d;
+import org.joml.Vector3dc;
+import org.joml.Vector3f;
+
import net.minecraft.Util;
import net.minecraft.world.phys.Vec3;
+import java.util.ArrayDeque;
+import java.util.Deque;
+
+import static java.util.stream.Stream.generate;
+
public class Vec3History
{
- private int _capacity = 450;
- private LinkedList _data = new LinkedList<>();
+ private final int _capacity = 450;
+ private final Deque _data = new ArrayDeque<>(_capacity);
+ {
+ _data.addAll(generate(entry::new).limit(_capacity).toList());
+ }
- public void add(Vec3 in)
+ public void add(double x, double y, double z)
+ {
+ this._data.addFirst(this._data.removeLast().set(x, y, z));
+ }
+
+ public void add(Vector3dc in)
{
- this._data.add(new entry(in));
+ this.add(in.x(), in.y(), in.z());
+ }
- if (this._data.size() > this._capacity)
- {
- this._data.removeFirst();
- }
+ public void add(Vec3 in)
+ {
+ this.add(in.x(), in.y(), in.z());
}
- public void clear()
+ public Vector3d latest(Vector3d dest)
{
- this._data.clear();
+ return dest.set((this._data.getFirst()).data);
}
- public Vec3 latest()
+ public Vector3f latest(Vector3f dest)
{
- return (this._data.getLast()).data;
+ return dest.set((this._data.getFirst()).data);
}
public double totalMovement(double seconds)
{
long i = Util.getMillis();
- ListIterator listiterator = this._data.listIterator(this._data.size());
entry vec3history$entry = null;
double d0 = 0.0D;
- int j = 0;
- while (listiterator.hasPrevious())
+ for (entry vec3history$entry1: this._data)
{
- entry vec3history$entry1 = listiterator.previous();
- ++j;
-
if ((double)(i - vec3history$entry1.ts) > seconds * 1000.0D)
{
break;
@@ -54,25 +64,47 @@ public double totalMovement(double seconds)
}
else
{
- d0 += vec3history$entry.data.distanceTo(vec3history$entry1.data);
+ d0 += vec3history$entry.data.distance(vec3history$entry1.data);
}
}
return d0;
}
- public Vec3 netMovement(double seconds)
+ public Vector3d netMovement(double seconds, Vector3d dest)
{
long i = Util.getMillis();
- ListIterator listiterator = this._data.listIterator(this._data.size());
entry vec3history$entry = null;
entry vec3history$entry1 = null;
- double d0 = 0.0D;
- while (listiterator.hasPrevious())
+ for (entry vec3history$entry2 : this._data)
{
- entry vec3history$entry2 = listiterator.previous();
+ if ((double)(i - vec3history$entry2.ts) > seconds * 1000.0D)
+ {
+ break;
+ }
+
+ if (vec3history$entry == null)
+ {
+ vec3history$entry = vec3history$entry2;
+ }
+ else
+ {
+ vec3history$entry1 = vec3history$entry2;
+ }
+ }
+
+ return vec3history$entry != null && vec3history$entry1 != null ? vec3history$entry.data.sub(vec3history$entry1.data, dest) : dest.set(0);
+ }
+
+ public Vector3f netMovement(double seconds, Vector3f dest)
+ {
+ long i = Util.getMillis();
+ entry vec3history$entry = null;
+ entry vec3history$entry1 = null;
+ for (entry vec3history$entry2 : this._data)
+ {
if ((double)(i - vec3history$entry2.ts) > seconds * 1000.0D)
{
break;
@@ -88,21 +120,18 @@ public Vec3 netMovement(double seconds)
}
}
- return vec3history$entry != null && vec3history$entry1 != null ? vec3history$entry.data.subtract(vec3history$entry1.data) : new Vec3(0.0D, 0.0D, 0.0D);
+ return vec3history$entry != null && vec3history$entry1 != null ? dest.set(vec3history$entry.data).sub((float)vec3history$entry1.data.x, (float)vec3history$entry1.data.y, (float)vec3history$entry1.data.z) : dest.set(0);
}
public double averageSpeed(double seconds)
{
long i = Util.getMillis();
- ListIterator listiterator = this._data.listIterator(this._data.size());
double d0 = 0.0D;
entry vec3history$entry = null;
int j = 0;
- while (listiterator.hasPrevious())
+ for (entry vec3history$entry1 : this._data)
{
- entry vec3history$entry1 = listiterator.previous();
-
if ((double)(i - vec3history$entry1.ts) > seconds * 1000.0D)
{
break;
@@ -115,46 +144,63 @@ public double averageSpeed(double seconds)
else
{
++j;
- double d1 = 0.001D * (double)(vec3history$entry.ts - vec3history$entry1.ts);
- double d2 = vec3history$entry.data.subtract(vec3history$entry1.data).length();
+ double d1 = 0.001D * (vec3history$entry.ts - vec3history$entry1.ts);
+ double d2 = vec3history$entry.data.distance(vec3history$entry1.data);
d0 += d2 / d1;
}
}
- return j == 0 ? d0 : d0 / (double)j;
+ return j == 0 ? d0 : d0 / j;
}
- public Vec3 averagePosition(double seconds)
+ public Vector3d averagePosition(double seconds, Vector3d dest)
{
long i = Util.getMillis();
- ListIterator listiterator = this._data.listIterator(this._data.size());
- Vec3 vec3 = new Vec3(0.0D, 0.0D, 0.0D);
- int j;
- entry vec3history$entry;
+ int j = 0;
- for (j = 0; listiterator.hasPrevious(); vec3 = vec3.add(vec3history$entry.data))
+ for (entry vec3history$entry: this._data)
{
- vec3history$entry = listiterator.previous();
+ if ((double)(i - vec3history$entry.ts) > seconds * 1000.0D)
+ {
+ break;
+ }
+
+ dest.add(vec3history$entry.data);
+ ++j;
+ }
+ return j == 0 ? dest : dest.mul(1.0D / j);
+ }
+
+ public Vector3f averagePosition(double seconds, Vector3f dest)
+ {
+ long i = Util.getMillis();
+ int j = 0;
+
+ for (entry vec3history$entry: this._data)
+ {
if ((double)(i - vec3history$entry.ts) > seconds * 1000.0D)
{
break;
}
+ dest.add((float) vec3history$entry.data.x, (float) vec3history$entry.data.y, (float)vec3history$entry.data.z);
++j;
}
- return j == 0 ? vec3 : vec3.scale(1.0D / (double)j);
+ return j == 0 ? dest : dest.mul(1.0F / j);
}
- private class entry
+ private static class entry
{
public long ts = Util.getMillis();
- public Vec3 data;
+ public Vector3d data = new Vector3d();
- public entry(Vec3 in)
+ public entry set(double x, double y, double z)
{
- this.data = in;
+ this.ts = Util.getMillis();
+ this.data.set(x, y, z);
+ return this;
}
}
}
diff --git a/common/src/main/java/org/vivecraft/client_vr/extensions/EntityRenderDispatcherVRExtension.java b/common/src/main/java/org/vivecraft/client_vr/extensions/EntityRenderDispatcherVRExtension.java
index 1f14500b7..044a7be74 100644
--- a/common/src/main/java/org/vivecraft/client_vr/extensions/EntityRenderDispatcherVRExtension.java
+++ b/common/src/main/java/org/vivecraft/client_vr/extensions/EntityRenderDispatcherVRExtension.java
@@ -1,8 +1,9 @@
package org.vivecraft.client_vr.extensions;
-import org.joml.Quaternionf;
import org.vivecraft.client_vr.render.VRArmRenderer;
+import org.joml.Quaternionf;
+
import java.util.Map;
public interface EntityRenderDispatcherVRExtension {
diff --git a/common/src/main/java/org/vivecraft/client_vr/extensions/FrustumExtension.java b/common/src/main/java/org/vivecraft/client_vr/extensions/FrustumExtension.java
index f0c206b32..b0cc57f13 100644
--- a/common/src/main/java/org/vivecraft/client_vr/extensions/FrustumExtension.java
+++ b/common/src/main/java/org/vivecraft/client_vr/extensions/FrustumExtension.java
@@ -4,7 +4,7 @@
public interface FrustumExtension {
- public void setCameraPosition(double var1, double var3, double var5);
+ void setCameraPosition(double var1, double var3, double var5);
- public boolean isBoundingBoxInFrustum(AABB var1);
+ boolean isBoundingBoxInFrustum(AABB var1);
}
diff --git a/common/src/main/java/org/vivecraft/client_vr/extensions/GameRendererExtension.java b/common/src/main/java/org/vivecraft/client_vr/extensions/GameRendererExtension.java
index a72548d73..6fcc73b7e 100644
--- a/common/src/main/java/org/vivecraft/client_vr/extensions/GameRendererExtension.java
+++ b/common/src/main/java/org/vivecraft/client_vr/extensions/GameRendererExtension.java
@@ -1,14 +1,15 @@
package org.vivecraft.client_vr.extensions;
-import net.minecraft.client.gui.GuiGraphics;
-import net.minecraft.client.renderer.LevelRenderer;
-import net.minecraft.world.entity.LivingEntity;
-import org.joml.Matrix4f;
import org.vivecraft.client_vr.render.RenderPass;
+import org.joml.Matrix4f;
+
import com.mojang.blaze3d.vertex.PoseStack;
+import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.Screen;
+import net.minecraft.client.renderer.LevelRenderer;
+import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.phys.Vec3;
public interface GameRendererExtension {
@@ -51,10 +52,10 @@ public interface GameRendererExtension {
double getRveY();
- void renderVrFast(float partialTicks, boolean secondpass, boolean menuhandright, boolean menuHandleft,
+ void renderVrFast(float partialTicks, boolean secondpass, boolean menuHandRight, boolean menuHandLeft,
PoseStack poseStack);
- void renderVRFabulous(float f, LevelRenderer levelRenderer, boolean menuhandright, boolean menuHandleft, PoseStack poseStack);
+ void renderVRFabulous(float f, LevelRenderer levelRenderer, boolean menuHandRight, boolean menuHandLeft, PoseStack poseStack);
void restoreRVEPos(LivingEntity e);
diff --git a/common/src/main/java/org/vivecraft/client_vr/extensions/ItemInHandRendererExtension.java b/common/src/main/java/org/vivecraft/client_vr/extensions/ItemInHandRendererExtension.java
index 4a514b905..c3a371bbf 100644
--- a/common/src/main/java/org/vivecraft/client_vr/extensions/ItemInHandRendererExtension.java
+++ b/common/src/main/java/org/vivecraft/client_vr/extensions/ItemInHandRendererExtension.java
@@ -1,11 +1,12 @@
package org.vivecraft.client_vr.extensions;
+import org.vivecraft.client_vr.render.VRFirstPersonArmSwing;
+
import org.apache.commons.lang3.tuple.Triple;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.Vec3;
-import org.vivecraft.client_vr.render.VRFirstPersonArmSwing;
public interface ItemInHandRendererExtension {
diff --git a/common/src/main/java/org/vivecraft/client_vr/extensions/LevelRendererExtension.java b/common/src/main/java/org/vivecraft/client_vr/extensions/LevelRendererExtension.java
index 3c55dfab7..9501632ad 100644
--- a/common/src/main/java/org/vivecraft/client_vr/extensions/LevelRendererExtension.java
+++ b/common/src/main/java/org/vivecraft/client_vr/extensions/LevelRendererExtension.java
@@ -1,6 +1,7 @@
package org.vivecraft.client_vr.extensions;
import com.mojang.blaze3d.pipeline.RenderTarget;
+
import net.minecraft.world.entity.Entity;
public interface LevelRendererExtension {
diff --git a/common/src/main/java/org/vivecraft/client_vr/extensions/PlayerExtension.java b/common/src/main/java/org/vivecraft/client_vr/extensions/PlayerExtension.java
index f95794bed..8c8790ada 100644
--- a/common/src/main/java/org/vivecraft/client_vr/extensions/PlayerExtension.java
+++ b/common/src/main/java/org/vivecraft/client_vr/extensions/PlayerExtension.java
@@ -1,18 +1,15 @@
package org.vivecraft.client_vr.extensions;
-import net.minecraft.client.player.LocalPlayer;
import org.vivecraft.client_vr.render.VRFirstPersonArmSwing;
import net.minecraft.core.BlockPos;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.item.ItemStack;
-import net.minecraft.world.phys.Vec3;
public interface PlayerExtension {
int getMovementTeleportTimer();
void setMovementTeleportTimer(int value);
- void addMovementTeleportTimer(int value);
boolean hasTeleported();
void setTeleported(boolean teleported);
@@ -23,7 +20,7 @@ public interface PlayerExtension {
boolean isClimbeyClimbEquipped();
- void stepSound(BlockPos blockpos, Vec3 vec3);
+ void stepSound(BlockPos blockpos, double soundPosX, double soundPosY, double soundPosZ);
void swingArm(InteractionHand interactionhand, VRFirstPersonArmSwing interact);
@@ -32,5 +29,4 @@ public interface PlayerExtension {
float getMuhSpeedFactor();
double getRoomYOffsetFromPose();
boolean getInitFromServer();
- void updateSyncFields(LocalPlayer old);
}
diff --git a/common/src/main/java/org/vivecraft/client_vr/gameplay/VRMovementStyle.java b/common/src/main/java/org/vivecraft/client_vr/gameplay/VRMovementStyle.java
index ca94b4f96..6a4792b49 100644
--- a/common/src/main/java/org/vivecraft/client_vr/gameplay/VRMovementStyle.java
+++ b/common/src/main/java/org/vivecraft/client_vr/gameplay/VRMovementStyle.java
@@ -1,10 +1,12 @@
package org.vivecraft.client_vr.gameplay;
-import org.vivecraft.client_vr.ClientDataHolderVR;
-
-import net.minecraft.client.Minecraft;
+import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
+import static org.vivecraft.client.utils.Utils.message;
+import static org.vivecraft.client_vr.VRState.dh;
+import static org.vivecraft.client_vr.VRState.mc;
+
public class VRMovementStyle
{
public String name;
@@ -29,12 +31,10 @@ public class VRMovementStyle
public float endTeleportingSoundVolume;
public boolean teleportOnRelease;
public boolean arcAiming;
- public ClientDataHolderVR dataholder;
private static final ResourceLocation beamPng = new ResourceLocation("textures/entity/endercrystal/endercrystal_beam.png");
- public VRMovementStyle(ClientDataHolderVR dataholder)
+ public VRMovementStyle()
{
- this.dataholder = dataholder;
this.setStyle("Arc");
}
@@ -42,120 +42,123 @@ public void setStyle(String requestedStyle)
{
boolean flag = true;
- if (requestedStyle == "Minimal")
- {
- this.name = requestedStyle;
- this.cameraSlide = false;
- this.airSparkles = true;
- this.destinationSparkles = true;
- this.showBeam = false;
- this.startTeleportingSound = null;
- this.endTeleportingSoundVolume = 0.8F;
- this.endTeleportingSound = "mob.endermen.portal";
- this.teleportOnRelease = false;
- this.arcAiming = false;
- }
- else if (requestedStyle == "Beam")
- {
- this.name = requestedStyle;
- this.cameraSlide = false;
- this.airSparkles = true;
- this.destinationSparkles = true;
- this.showBeam = true;
- this.beamWave = false;
- this.beamArc = false;
- this.beamSpiral = false;
- this.beamGrow = true;
- this.beamHalfWidth = 0.1F;
- this.beamSegmentLength = 0.1F;
- this.beamVStrips = 16;
- this.renderVerticalStrip = true;
- this.textureScrollSpeed = 3.0F;
- this.texture = beamPng;
- this.startTeleportingSound = null;
- this.endTeleportingSoundVolume = 0.8F;
- this.endTeleportingSound = "mob.endermen.portal";
- this.teleportOnRelease = false;
- this.arcAiming = false;
- }
- else if (requestedStyle == "Tunnel")
- {
- this.name = requestedStyle;
- this.cameraSlide = false;
- this.airSparkles = true;
- this.destinationSparkles = true;
- this.showBeam = true;
- this.beamWave = false;
- this.beamArc = false;
- this.beamSpiral = true;
- this.beamGrow = true;
- this.beamHalfWidth = 0.1F;
- this.beamSpiralRadius = 1.6F;
- this.renderVerticalStrip = true;
- this.beamVStrips = 16;
- this.textureScrollSpeed = 3.0F;
- this.texture = beamPng;
- this.startTeleportingSound = null;
- this.endTeleportingSoundVolume = 0.8F;
- this.endTeleportingSound = "mob.endermen.portal";
- this.teleportOnRelease = false;
- this.arcAiming = false;
- }
- else if (requestedStyle == "Grapple")
- {
- this.name = requestedStyle;
- this.cameraSlide = true;
- this.airSparkles = false;
- this.destinationSparkles = true;
- this.showBeam = true;
- this.beamWave = true;
- this.beamArc = false;
- this.beamSpiral = false;
- this.beamGrow = true;
- this.beamHalfWidth = 0.05F;
- this.beamSegmentLength = 0.05F;
- this.renderVerticalStrip = false;
- this.beamVStrips = 2;
- this.textureScrollSpeed = 7.0F;
- this.texture = beamPng;
- this.startTeleportingSoundVolume = 0.5F;
- this.endTeleportingSoundVolume = 0.5F;
- this.startTeleportingSound = null;
- this.endTeleportingSound = "mob.endermen.portal";
- this.teleportOnRelease = false;
- this.arcAiming = false;
- }
- else if (requestedStyle == "Arc")
- {
- this.name = requestedStyle;
- this.cameraSlide = false;
- this.airSparkles = false;
- this.destinationSparkles = false;
- this.showBeam = true;
- this.beamWave = false;
- this.beamArc = false;
- this.beamSpiral = false;
- this.beamGrow = false;
- this.beamHalfWidth = 0.1F;
- this.beamVStrips = 1;
- this.renderVerticalStrip = true;
- this.textureScrollSpeed = 3.0F;
- this.texture = beamPng;
- this.startTeleportingSound = null;
- this.endTeleportingSoundVolume = 0.7F;
- this.endTeleportingSound = null;
- this.teleportOnRelease = true;
- this.arcAiming = true;
- }
- else
+ switch (requestedStyle)
{
- flag = false;
- ClientDataHolderVR.getInstance().printChatMessage("Unknown teleport style requested: " + requestedStyle);
+ case "Minimal" ->
+ {
+ this.name = requestedStyle;
+ this.cameraSlide = false;
+ this.airSparkles = true;
+ this.destinationSparkles = true;
+ this.showBeam = false;
+ this.startTeleportingSound = null;
+ this.endTeleportingSoundVolume = 0.8F;
+ this.endTeleportingSound = "mob.endermen.portal";
+ this.teleportOnRelease = false;
+ this.arcAiming = false;
+ }
+ case "Beam" ->
+ {
+ this.name = requestedStyle;
+ this.cameraSlide = false;
+ this.airSparkles = true;
+ this.destinationSparkles = true;
+ this.showBeam = true;
+ this.beamWave = false;
+ this.beamArc = false;
+ this.beamSpiral = false;
+ this.beamGrow = true;
+ this.beamHalfWidth = 0.1F;
+ this.beamSegmentLength = 0.1F;
+ this.beamVStrips = 16;
+ this.renderVerticalStrip = true;
+ this.textureScrollSpeed = 3.0F;
+ this.texture = beamPng;
+ this.startTeleportingSound = null;
+ this.endTeleportingSoundVolume = 0.8F;
+ this.endTeleportingSound = "mob.endermen.portal";
+ this.teleportOnRelease = false;
+ this.arcAiming = false;
+ }
+ case "Tunnel" ->
+ {
+ this.name = requestedStyle;
+ this.cameraSlide = false;
+ this.airSparkles = true;
+ this.destinationSparkles = true;
+ this.showBeam = true;
+ this.beamWave = false;
+ this.beamArc = false;
+ this.beamSpiral = true;
+ this.beamGrow = true;
+ this.beamHalfWidth = 0.1F;
+ this.beamSpiralRadius = 1.6F;
+ this.renderVerticalStrip = true;
+ this.beamVStrips = 16;
+ this.textureScrollSpeed = 3.0F;
+ this.texture = beamPng;
+ this.startTeleportingSound = null;
+ this.endTeleportingSoundVolume = 0.8F;
+ this.endTeleportingSound = "mob.endermen.portal";
+ this.teleportOnRelease = false;
+ this.arcAiming = false;
+ }
+ case "Grapple" ->
+ {
+ this.name = requestedStyle;
+ this.cameraSlide = true;
+ this.airSparkles = false;
+ this.destinationSparkles = true;
+ this.showBeam = true;
+ this.beamWave = true;
+ this.beamArc = false;
+ this.beamSpiral = false;
+ this.beamGrow = true;
+ this.beamHalfWidth = 0.05F;
+ this.beamSegmentLength = 0.05F;
+ this.renderVerticalStrip = false;
+ this.beamVStrips = 2;
+ this.textureScrollSpeed = 7.0F;
+ this.texture = beamPng;
+ this.startTeleportingSoundVolume = 0.5F;
+ this.endTeleportingSoundVolume = 0.5F;
+ this.startTeleportingSound = null;
+ this.endTeleportingSound = "mob.endermen.portal";
+ this.teleportOnRelease = false;
+ this.arcAiming = false;
+ }
+ case "Arc" ->
+ {
+ this.name = requestedStyle;
+ this.cameraSlide = false;
+ this.airSparkles = false;
+ this.destinationSparkles = false;
+ this.showBeam = true;
+ this.beamWave = false;
+ this.beamArc = false;
+ this.beamSpiral = false;
+ this.beamGrow = false;
+ this.beamHalfWidth = 0.1F;
+ this.beamVStrips = 1;
+ this.renderVerticalStrip = true;
+ this.textureScrollSpeed = 3.0F;
+ this.texture = beamPng;
+ this.startTeleportingSound = null;
+ this.endTeleportingSoundVolume = 0.7F;
+ this.endTeleportingSound = null;
+ this.teleportOnRelease = true;
+ this.arcAiming = true;
+ }
+ default ->
+ {
+ flag = false;
+ message(Component.translatableWithFallback("vivecraft.options.teleport.style", "Unknown teleport style requested: " + requestedStyle, requestedStyle));
+ }
}
- if (flag && Minecraft.getInstance() != null && dataholder != null)
+ if (flag && mc != null && dh != null)
{
- dataholder.printChatMessage("Teleport style (RCTRL-M): " + this.name);
+ message(Component.translatableWithFallback("vivecraft.options.teleport.style", "Teleport style (RCTRL-M): " + this.name, this.name));
}
}
}
diff --git a/common/src/main/java/org/vivecraft/client_vr/gameplay/VRPlayer.java b/common/src/main/java/org/vivecraft/client_vr/gameplay/VRPlayer.java
index 80e69c1b3..d40b57ec7 100644
--- a/common/src/main/java/org/vivecraft/client_vr/gameplay/VRPlayer.java
+++ b/common/src/main/java/org/vivecraft/client_vr/gameplay/VRPlayer.java
@@ -1,5 +1,23 @@
package org.vivecraft.client_vr.gameplay;
+import org.vivecraft.client.VivecraftVRMod;
+import org.vivecraft.client.Xplat;
+import org.vivecraft.client.network.ClientNetworking;
+import org.vivecraft.client_vr.ItemTags;
+import org.vivecraft.client_vr.VRData;
+import org.vivecraft.client_vr.extensions.GameRendererExtension;
+import org.vivecraft.client_vr.extensions.PlayerExtension;
+import org.vivecraft.client_vr.gameplay.screenhandlers.GuiHandler;
+import org.vivecraft.client_vr.gameplay.screenhandlers.KeyboardHandler;
+import org.vivecraft.client_vr.gameplay.screenhandlers.RadialHandler;
+import org.vivecraft.client_vr.gameplay.trackers.Tracker;
+import org.vivecraft.client_vr.gameplay.trackers.Tracker.EntryPoint;
+import org.vivecraft.client_vr.gameplay.trackers.VehicleTracker;
+import org.vivecraft.client_vr.settings.VRSettings.FreeMove;
+import org.vivecraft.client_vr.settings.VRSettings.VrOptions;
+import org.vivecraft.common.VRServerPerms;
+import org.vivecraft.mod_compat_vr.pehkui.PehkuiHelper;
+
import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.TerrainParticle;
import net.minecraft.client.player.LocalPlayer;
@@ -10,51 +28,38 @@
import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.animal.horse.AbstractHorse;
import net.minecraft.world.entity.player.Player;
-import net.minecraft.world.item.BowItem;
-import net.minecraft.world.item.CrossbowItem;
-import net.minecraft.world.item.EggItem;
-import net.minecraft.world.item.ItemStack;
-import net.minecraft.world.item.Items;
-import net.minecraft.world.item.PotionItem;
-import net.minecraft.world.item.SnowballItem;
-import net.minecraft.world.item.SpawnEggItem;
+import net.minecraft.world.item.*;
import net.minecraft.world.level.ClipContext;
+import net.minecraft.world.level.ClipContext.Block;
+import net.minecraft.world.level.ClipContext.Fluid;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.HitResult;
import net.minecraft.world.phys.Vec3;
-import org.vivecraft.client.VivecraftVRMod;
-import org.vivecraft.client_vr.ClientDataHolderVR;
-import org.vivecraft.common.VRServerPerms;
-import org.vivecraft.client_vr.gameplay.trackers.Tracker;
-import org.vivecraft.mod_compat_vr.pehkui.PehkuiHelper;
-import org.vivecraft.client.Xplat;
-import org.vivecraft.client_vr.ItemTags;
-import org.vivecraft.client_vr.extensions.GameRendererExtension;
-import org.vivecraft.client_vr.extensions.PlayerExtension;
-import org.vivecraft.client.network.ClientNetworking;
-import org.vivecraft.client_vr.VRData;
-import org.vivecraft.client_vr.gameplay.screenhandlers.GuiHandler;
-import org.vivecraft.client_vr.gameplay.screenhandlers.KeyboardHandler;
-import org.vivecraft.client_vr.gameplay.screenhandlers.RadialHandler;
-import org.vivecraft.client_vr.settings.VRSettings;
-import org.vivecraft.client_vr.gameplay.trackers.VehicleTracker;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Random;
+import static org.vivecraft.client_vr.VRState.dh;
+import static org.vivecraft.client_vr.VRState.mc;
+import static org.vivecraft.common.utils.Utils.logger;
+
+import static java.lang.Math.pow;
+import static org.joml.Math.*;
+
public class VRPlayer
{
- Minecraft mc = Minecraft.getInstance();
- ClientDataHolderVR dh = ClientDataHolderVR.getInstance();
public VRData vrdata_room_pre;
public VRData vrdata_world_pre;
public VRData vrdata_room_post;
public VRData vrdata_world_post;
+ @Nullable
public VRData vrdata_world_render;
ArrayList trackers = new ArrayList<>();
- public float worldScale = ClientDataHolderVR.getInstance().vrSettings.overrides.getSetting(VRSettings.VrOptions.WORLD_SCALE).getFloat();
- private float rawWorldScale = ClientDataHolderVR.getInstance().vrSettings.overrides.getSetting(VRSettings.VrOptions.WORLD_SCALE).getFloat();
+ public float worldScale = dh.vrSettings.overrides.getSetting(VrOptions.WORLD_SCALE).getFloat();
+ private float rawWorldScale = dh.vrSettings.overrides.getSetting(VrOptions.WORLD_SCALE).getFloat();
private boolean teleportOverride = false;
public boolean teleportWarning = false;
public boolean vrSwitchWarning = false;
@@ -74,39 +79,31 @@ public void registerTracker(Tracker tracker)
public VRPlayer()
{
- this.vrdata_room_pre = new VRData(new Vec3(0.0D, 0.0D, 0.0D), this.dh.vrSettings.walkMultiplier, 1.0F, 0.0F);
- this.vrdata_room_post = new VRData(new Vec3(0.0D, 0.0D, 0.0D), this.dh.vrSettings.walkMultiplier, 1.0F, 0.0F);
- this.vrdata_world_post = new VRData(new Vec3(0.0D, 0.0D, 0.0D), this.dh.vrSettings.walkMultiplier, 1.0F, 0.0F);
- this.vrdata_world_pre = new VRData(new Vec3(0.0D, 0.0D, 0.0D), this.dh.vrSettings.walkMultiplier, 1.0F, 0.0F);
+ this.vrdata_room_pre = new VRData();
+ this.vrdata_room_post = new VRData();
+ this.vrdata_world_post = new VRData();
+ this.vrdata_world_pre = new VRData();
}
+ @Nonnull
public VRData getVRDataWorld()
{
return this.vrdata_world_render != null ? this.vrdata_world_render : this.vrdata_world_pre;
}
- public static VRPlayer get()
- {
- return ClientDataHolderVR.getInstance().vrPlayer;
- }
-
public static Vec3 room_to_world_pos(Vec3 pos, VRData data)
{
- Vec3 vec3 = new Vec3(pos.x * (double)data.worldScale, pos.y * (double)data.worldScale, pos.z * (double)data.worldScale);
- vec3 = vec3.yRot(data.rotation_radians);
- return vec3.add(data.origin.x, data.origin.y, data.origin.z);
+ return pos.scale(data.worldScale).yRot(data.rotation_radians).add(data.origin);
}
public static Vec3 world_to_room_pos(Vec3 pos, VRData data)
{
- Vec3 vec3 = pos.add(-data.origin.x, -data.origin.y, -data.origin.z);
- vec3 = new Vec3(vec3.x / (double)data.worldScale, vec3.y / (double)data.worldScale, vec3.z / (double)data.worldScale);
- return vec3.yRot(-data.rotation_radians);
+ return pos.subtract(data.origin).scale(pow(data.worldScale, -1)).yRot(-data.rotation_radians);
}
public void postPoll()
{
- this.vrdata_room_pre = new VRData(new Vec3(0.0D, 0.0D, 0.0D), this.dh.vrSettings.walkMultiplier, 1.0F, 0.0F);
+ this.vrdata_room_pre = new VRData();
GuiHandler.processGui();
KeyboardHandler.processGui();
RadialHandler.processGui();
@@ -115,17 +112,17 @@ public void postPoll()
public void preTick()
{
this.onTick = true;
- this.vrdata_world_pre = new VRData(this.roomOrigin, this.dh.vrSettings.walkMultiplier, this.worldScale, (float)Math.toRadians((double)this.dh.vrSettings.worldRotation));
- float f = this.dh.vrSettings.overrides.getSetting(VRSettings.VrOptions.WORLD_SCALE).getFloat();
+ this.vrdata_world_pre = new VRData(this.roomOrigin, this.worldScale, toRadians(dh.vrSettings.worldRotation));
+ float f = dh.vrSettings.overrides.getSetting(VrOptions.WORLD_SCALE).getFloat();
- if (((GameRendererExtension) this.mc.gameRenderer).isInMenuRoom())
+ if (((GameRendererExtension) mc.gameRenderer).isInMenuRoom())
{
this.worldScale = 1.0F;
}
else {
- if (this.wfCount > 0 && !this.mc.isPaused()) {
+ if (this.wfCount > 0 && !mc.isPaused()) {
if (this.wfCount < 40) {
- this.rawWorldScale = (float) ((double) this.rawWorldScale - this.wfMode);
+ this.rawWorldScale = (float) (this.rawWorldScale - this.wfMode);
if (this.wfMode > 0.0D) {
if (this.rawWorldScale < f) {
@@ -135,7 +132,7 @@ public void preTick()
this.rawWorldScale = f;
}
} else {
- this.rawWorldScale = (float) ((double) this.rawWorldScale + this.wfMode);
+ this.rawWorldScale = (float) (this.rawWorldScale + this.wfMode);
if (this.wfMode > 0.0D) {
if (this.rawWorldScale > 20.0F) {
@@ -164,69 +161,68 @@ else if (this.worldScale < 0.025F) //minClip + player position indicator offset
}
}
- if (this.dh.vrSettings.seated && !((GameRendererExtension) this.mc.gameRenderer).isInMenuRoom())
+ if (dh.vrSettings.seated && !((GameRendererExtension) mc.gameRenderer).isInMenuRoom())
{
- this.dh.vrSettings.worldRotation = this.dh.vr.seatedRot;
+ dh.vrSettings.worldRotation = dh.vr.seatedRot;
}
}
public void postTick()
{
- Minecraft minecraft = Minecraft.getInstance();
- ClientDataHolderVR dataholder = ClientDataHolderVR.getInstance();
- VRData vrdata = new VRData(this.vrdata_world_pre.origin, dataholder.vrSettings.walkMultiplier, this.vrdata_world_pre.worldScale, this.vrdata_world_pre.rotation_radians);
- VRData vrdata1 = new VRData(this.vrdata_world_pre.origin, dataholder.vrSettings.walkMultiplier, this.worldScale, this.vrdata_world_pre.rotation_radians);
+ VRData vrdata = new VRData(this.vrdata_world_pre.origin, this.vrdata_world_pre.worldScale, this.vrdata_world_pre.rotation_radians);
+ VRData vrdata1 = new VRData(this.vrdata_world_pre.origin, this.worldScale, this.vrdata_world_pre.rotation_radians);
Vec3 vec3 = vrdata1.hmd.getPosition().subtract(vrdata.hmd.getPosition());
this.roomOrigin = this.roomOrigin.subtract(vec3);
- VRData vrdata2 = new VRData(this.roomOrigin, dataholder.vrSettings.walkMultiplier, this.worldScale, this.vrdata_world_pre.rotation_radians);
- float f = dataholder.vrSettings.worldRotation;
- float f1 = (float)Math.toDegrees((double)this.vrdata_world_pre.rotation_radians);
- this.rotateOriginAround(-f + f1, vrdata2.getHeadPivot());
- this.vrdata_room_post = new VRData(new Vec3(0.0D, 0.0D, 0.0D), dataholder.vrSettings.walkMultiplier, 1.0F, 0.0F);
- this.vrdata_world_post = new VRData(this.roomOrigin, dataholder.vrSettings.walkMultiplier, this.worldScale, (float)Math.toRadians((double)dataholder.vrSettings.worldRotation));
- this.doPermanantLookOverride(minecraft.player, this.vrdata_world_post);
+ VRData vrdata2 = new VRData(this.roomOrigin, this.worldScale, this.vrdata_world_pre.rotation_radians);
+ float rad = this.vrdata_world_pre.rotation_radians - toRadians(dh.vrSettings.worldRotation);
+ Vec3 o = vrdata2.getHeadPivot();
+ if (rad != 0.0F)
+ {
+ this.setRoomOrigin(cos(rad) * (this.roomOrigin.x - o.x) - sin(rad) * (this.roomOrigin.z - o.z) + o.x, this.roomOrigin.y, sin(rad) * (this.roomOrigin.x - o.x) + cos(rad) * (this.roomOrigin.z - o.z) + o.z, false);
+ }
+ this.vrdata_room_post = new VRData();
+ this.vrdata_world_post = new VRData(this.roomOrigin, this.worldScale, toRadians(dh.vrSettings.worldRotation));
+ this.doPermanentLookOverride(mc.player, this.vrdata_world_post);
ClientNetworking.sendVRPlayerPositions(this);
this.onTick = false;
}
public void preRender(float par1)
{
- Minecraft minecraft = Minecraft.getInstance();
- ClientDataHolderVR dataholder = ClientDataHolderVR.getInstance();
float f = this.vrdata_world_post.worldScale * par1 + this.vrdata_world_pre.worldScale * (1.0F - par1);
float f1 = this.vrdata_world_post.rotation_radians;
float f2 = this.vrdata_world_pre.rotation_radians;
- float f3 = Math.abs(f1 - f2);
+ float f3 = abs(f1 - f2);
- if ((double)f3 > Math.PI)
+ if (f3 > (float)PI)
{
if (f1 > f2)
{
- f2 = (float)((double)f2 + (Math.PI * 2D));
+ f2 += (float)PI * 2F;
}
else
{
- f1 = (float)((double)f1 + (Math.PI * 2D));
+ f1 += (float)PI * 2F;
}
}
float f4 = f1 * par1 + f2 * (1.0F - par1);
Vec3 vec3 = new Vec3(this.vrdata_world_pre.origin.x + (this.vrdata_world_post.origin.x - this.vrdata_world_pre.origin.x) * (double)par1, this.vrdata_world_pre.origin.y + (this.vrdata_world_post.origin.y - this.vrdata_world_pre.origin.y) * (double)par1, this.vrdata_world_pre.origin.z + (this.vrdata_world_post.origin.z - this.vrdata_world_pre.origin.z) * (double)par1);
- this.vrdata_world_render = new VRData(vec3, dataholder.vrSettings.walkMultiplier, f, f4);
+ this.vrdata_world_render = new VRData(vec3, f, f4);
for (Tracker tracker : this.trackers)
{
- if (tracker.getEntryPoint() == Tracker.EntryPoint.SPECIAL_ITEMS)
+ if (tracker.getEntryPoint() == EntryPoint.SPECIAL_ITEMS)
{
- tracker.idleTick(minecraft.player);
+ tracker.idleTick();
- if (tracker.isActive(minecraft.player))
+ if (tracker.isActive())
{
- tracker.doProcess(minecraft.player);
+ tracker.doProcess();
}
else
{
- tracker.reset(minecraft.player);
+ tracker.reset();
}
}
}
@@ -246,66 +242,50 @@ public void setRoomOrigin(double x, double y, double z, boolean reset)
this.roomOrigin = new Vec3(x, y, z);
}
- public void snapRoomOriginToPlayerEntity(LocalPlayer player, boolean reset, boolean instant)
+ public void snapRoomOriginToPlayerEntity(boolean reset, boolean instant)
{
- if (!Thread.currentThread().getName().equals("Server thread"))
+ if (!"Server thread".equals(Thread.currentThread().getName()))
{
- if (player != null && player.position() != Vec3.ZERO)
+ if (mc.player != null && mc.player.position() != Vec3.ZERO)
{
- Minecraft minecraft = Minecraft.getInstance();
- ClientDataHolderVR dataholder = ClientDataHolderVR.getInstance();
- if (dataholder.sneakTracker.sneakCounter <= 0)
+ if (dh.sneakTracker.sneakCounter <= 0)
{
VRData vrdata = this.vrdata_world_pre;
if (instant)
{
- vrdata = new VRData(this.roomOrigin, dataholder.vrSettings.walkMultiplier, this.worldScale, (float)Math.toRadians((double)dataholder.vrSettings.worldRotation));
+ vrdata = new VRData(this.roomOrigin, this.worldScale, toRadians(dh.vrSettings.worldRotation));
}
Vec3 vec3 = vrdata.getHeadPivot().subtract(vrdata.origin);
- double d0 = player.getX() - vec3.x;
- double d2 = player.getZ() - vec3.z;
- double d1 = player.getY() + ((PlayerExtension) player).getRoomYOffsetFromPose();
+ double d0 = mc.player.getX() - vec3.x;
+ double d2 = mc.player.getZ() - vec3.z;
+ double d1 = mc.player.getY() + ((PlayerExtension) mc.player).getRoomYOffsetFromPose();
this.setRoomOrigin(d0, d1, d2, reset);
}
}
}
}
- public float rotDiff_Degrees(float start, float end)
- {
- double d0 = Math.toRadians((double)end);
- double d1 = Math.toRadians((double)start);
- return (float)Math.toDegrees(Math.atan2(Math.sin(d0 - d1), Math.cos(d0 - d1)));
- }
-
- public void rotateOriginAround(float degrees, Vec3 o)
- {
- Vec3 vec3 = this.roomOrigin;
- float f = (float)Math.toRadians((double)degrees);
-
- if (f != 0.0F)
- {
- this.setRoomOrigin(Math.cos((double)f) * (vec3.x - o.x) - Math.sin((double)f) * (vec3.z - o.z) + o.x, vec3.y, Math.sin((double)f) * (vec3.x - o.x) + Math.cos((double)f) * (vec3.z - o.z) + o.z, false);
- }
- }
-
public void tick(LocalPlayer player, Minecraft mc, RandomSource rand)
{
if (((PlayerExtension) player).getInitFromServer())
{
if (!this.initdone)
{
- System.out.println("");
- System.out.println("Room object: " + this);
- System.out.println("Room origin: " + this.vrdata_world_pre.origin);
- System.out.println("Hmd position room: " + this.vrdata_room_pre.hmd.getPosition());
- System.out.println("Hmd position world: " + this.vrdata_world_pre.hmd.getPosition());
- System.out.println("Hmd Projection Left: " + dh.vrRenderer.eyeproj[0]);
- System.out.println("Hmd Projection Right: " + dh.vrRenderer.eyeproj[1]);
- System.out.println("");
+ logger.info(
+ """
+ {}
+ Hmd Projection Left:
+ {}
+ Hmd Projection Right:
+ {}
+ """,
+ this,
+ dh.vrRenderer.eyeproj[0],
+ dh.vrRenderer.eyeproj[1]
+ );
this.initdone = true;
}
@@ -313,17 +293,17 @@ public void tick(LocalPlayer player, Minecraft mc, RandomSource rand)
for (Tracker tracker : this.trackers)
{
- if (tracker.getEntryPoint() == Tracker.EntryPoint.LIVING_UPDATE)
+ if (tracker.getEntryPoint() == EntryPoint.LIVING_UPDATE)
{
- tracker.idleTick(mc.player);
+ tracker.idleTick();
- if (tracker.isActive(mc.player))
+ if (tracker.isActive())
{
- tracker.doProcess(mc.player);
+ tracker.doProcess();
}
else
{
- tracker.reset(mc.player);
+ tracker.reset();
}
}
}
@@ -332,19 +312,17 @@ public void tick(LocalPlayer player, Minecraft mc, RandomSource rand)
{
Entity entity = mc.player.getVehicle();
- if (entity instanceof AbstractHorse)
+ if (entity instanceof AbstractHorse abstracthorse)
{
- AbstractHorse abstracthorse = (AbstractHorse)entity;
- if (abstracthorse.isControlledByLocalInstance() && abstracthorse.isSaddled() && !dh.horseTracker.isActive(mc.player))
+ if (abstracthorse.isControlledByLocalInstance() && abstracthorse.isSaddled() && !dh.horseTracker.isActive())
{
abstracthorse.yBodyRot = this.vrdata_world_pre.getBodyYaw();
dh.vehicleTracker.rotationCooldown = 10;
}
}
- else if (entity instanceof Mob)
+ else if (entity instanceof Mob mob)
{
- Mob mob = (Mob)entity;
if (mob.isControlledByLocalInstance())
{
@@ -364,102 +342,129 @@ public void doPlayerMoveInRoom(LocalPlayer player)
}
else
{
- Minecraft minecraft = Minecraft.getInstance();
- ClientDataHolderVR dataholder = ClientDataHolderVR.getInstance();
- if (player != null)
+ if (player != null && !player.isShiftKeyDown() && !player.isSleeping() && !dh.jumpTracker.isjumping() &&
+ !dh.climbTracker.isGrabbingLadder() && player.isAlive()
+ )
{
- if (!player.isShiftKeyDown())
+ VRData vrdata = new VRData(
+ this.roomOrigin,
+ this.worldScale,
+ this.vrdata_world_pre.rotation_radians
+ );
+
+ if (dh.vehicleTracker.canRoomscaleDismount())
{
- if (!player.isSleeping())
+ Vec3 vec35 = mc.player.getVehicle().position();
+ Vec3 vec36 = vrdata.getHeadPivot();
+ double d6 = sqrt(
+ (vec36.x - vec35.x) * (vec36.x - vec35.x) + (vec36.z - vec35.z) * (vec36.z - vec35.z));
+
+ if (d6 > 1.0D)
{
- if (!dataholder.jumpTracker.isjumping())
+ dh.sneakTracker.sneakCounter = 5;
+ }
+ }
+ else
+ {
+ float f = player.getBbWidth() / 2.0F;
+ float f1 = player.getBbHeight();
+ Vec3 vec3 = vrdata.getHeadPivot();
+ double d0 = vec3.x;
+ double d1 = player.getY();
+ double d2 = vec3.z;
+ AABB aabb = new AABB(
+ d0 - (double) f,
+ d1,
+ d2 - (double) f,
+ d0 + (double) f,
+ d1 + (double) f1,
+ d2 + (double) f
+ );
+ Vec3 vec31 = null;
+ float f2 = 0.0625F;
+ boolean flag = mc.level.noCollision(player, aabb);
+
+ if (flag)
+ {
+ player.setPosRaw(d0, !dh.vrSettings.simulateFalling ? d1 : player.getY(), d2);
+ player.setBoundingBox(new AABB(
+ aabb.minX,
+ aabb.minY,
+ aabb.minZ,
+ aabb.maxX,
+ aabb.minY + (double) f1,
+ aabb.maxZ
+ ));
+ player.fallDistance = 0.0F;
+ this.getEstimatedTorsoPosition(d0, d1, d2);
+ }
+ else if (
+ (dh.vrSettings.walkUpBlocks && ((PlayerExtension) player).getMuhJumpFactor() == 1.0F ||
+ dh.climbTracker.isGrabbingLadder() && dh.vrSettings.realisticClimbEnabled
+ ) && player.fallDistance == 0.0F)
+ {
+ if (vec31 == null)
+ {
+ vec31 = this.getEstimatedTorsoPosition(d0, d1, d2);
+ }
+
+ float f3 = player.getDimensions(player.getPose()).width * 0.45F;
+ double d3 = (double) (f - f3);
+ AABB aabb1 = new AABB(
+ vec31.x - d3,
+ aabb.minY,
+ vec31.z - d3,
+ vec31.x + d3,
+ aabb.maxY,
+ vec31.z + d3
+ );
+ boolean flag1 = !mc.level.noCollision(player, aabb1);
+
+ if (flag1)
{
- if (!dataholder.climbTracker.isGrabbingLadder())
+ double d4 = vec31.x - d0;
+ double d5 = vec31.z - d2;
+ aabb = aabb.move(d4, 0.0D, d5);
+ int i = 0;
+
+ if (player.onClimbable() && dh.vrSettings.realisticClimbEnabled)
{
- if (player.isAlive())
+ i = 6;
+ }
+
+ for (int j = 0; j <= 10 + i; ++j)
+ {
+ aabb = aabb.move(0.0D, 0.1D, 0.0D);
+ flag = mc.level.noCollision(player, aabb);
+
+ if (flag)
{
- VRData vrdata = new VRData(this.roomOrigin, dataholder.vrSettings.walkMultiplier, this.worldScale, this.vrdata_world_pre.rotation_radians);
-
- if (dataholder.vehicleTracker.canRoomscaleDismount(minecraft.player))
- {
- Vec3 vec35 = minecraft.player.getVehicle().position();
- Vec3 vec36 = vrdata.getHeadPivot();
- double d6 = Math.sqrt((vec36.x - vec35.x) * (vec36.x - vec35.x) + (vec36.z - vec35.z) * (vec36.z - vec35.z));
-
- if (d6 > 1.0D)
- {
- dataholder.sneakTracker.sneakCounter = 5;
- }
- }
- else
- {
- float f = player.getBbWidth() / 2.0F;
- float f1 = player.getBbHeight();
- Vec3 vec3 = vrdata.getHeadPivot();
- double d0 = vec3.x;
- double d1 = player.getY();
- double d2 = vec3.z;
- AABB aabb = new AABB(d0 - (double)f, d1, d2 - (double)f, d0 + (double)f, d1 + (double)f1, d2 + (double)f);
- Vec3 vec31 = null;
- float f2 = 0.0625F;
- boolean flag = minecraft.level.noCollision(player, aabb);
-
- if (flag)
- {
- player.setPosRaw(d0, !dataholder.vrSettings.simulateFalling ? d1 : player.getY(), d2);
- player.setBoundingBox(new AABB(aabb.minX, aabb.minY, aabb.minZ, aabb.maxX, aabb.minY + (double)f1, aabb.maxZ));
- player.fallDistance = 0.0F;
- this.getEstimatedTorsoPosition(d0, d1, d2);
- }
- else if ((dataholder.vrSettings.walkUpBlocks && ((PlayerExtension) player).getMuhJumpFactor() == 1.0F || dataholder.climbTracker.isGrabbingLadder() && dataholder.vrSettings.realisticClimbEnabled) && player.fallDistance == 0.0F)
- {
- if (vec31 == null)
- {
- vec31 = this.getEstimatedTorsoPosition(d0, d1, d2);
- }
-
- float f3 = player.getDimensions(player.getPose()).width * 0.45F;
- double d3 = (double)(f - f3);
- AABB aabb1 = new AABB(vec31.x - d3, aabb.minY, vec31.z - d3, vec31.x + d3, aabb.maxY, vec31.z + d3);
- boolean flag1 = !minecraft.level.noCollision(player, aabb1);
-
- if (flag1)
- {
- double d4 = vec31.x - d0;
- double d5 = vec31.z - d2;
- aabb = aabb.move(d4, 0.0D, d5);
- int i = 0;
-
- if (player.onClimbable() && dataholder.vrSettings.realisticClimbEnabled)
- {
- i = 6;
- }
-
- for (int j = 0; j <= 10 + i; ++j)
- {
- aabb = aabb.move(0.0D, 0.1D, 0.0D);
- flag = minecraft.level.noCollision(player, aabb);
-
- if (flag)
- {
- d0 = d0 + d4;
- d2 = d2 + d5;
- d1 = d1 + (double)(0.1F * (float)j);
- player.setPosRaw(d0, d1, d2);
- player.setBoundingBox(new AABB(aabb.minX, aabb.minY, aabb.minZ, aabb.maxX, aabb.maxY, aabb.maxZ));
- Vec3 vec32 = this.roomOrigin.add(d4, (double)(0.1F * (float)j), d5);
- this.setRoomOrigin(vec32.x, vec32.y, vec32.z, false);
- Vec3 vec33 = player.getLookAngle();
- Vec3 vec34 = (new Vec3(vec33.x, 0.0D, vec33.z)).normalize();
- player.fallDistance = 0.0F;
- ((PlayerExtension) minecraft.player).stepSound(BlockPos.containing(player.position()), player.position());
- break;
- }
- }
- }
- }
- }
+ d0 = d0 + d4;
+ d2 = d2 + d5;
+ d1 = d1 + (double) (0.1F * (float) j);
+ player.setPosRaw(d0, d1, d2);
+ player.setBoundingBox(new AABB(
+ aabb.minX,
+ aabb.minY,
+ aabb.minZ,
+ aabb.maxX,
+ aabb.maxY,
+ aabb.maxZ
+ ));
+ Vec3 vec32 = this.roomOrigin.add(d4, (double) (0.1F * (float) j), d5);
+ this.setRoomOrigin(vec32.x, vec32.y, vec32.z, false);
+ Vec3 vec33 = player.getLookAngle();
+ Vec3 vec34 = (new Vec3(vec33.x, 0.0D, vec33.z)).normalize();
+ player.fallDistance = 0.0F;
+ Vec3 pos = player.position();
+ ((PlayerExtension) mc.player).stepSound(
+ BlockPos.containing(pos),
+ pos.x(),
+ pos.y(),
+ pos.z()
+ );
+ break;
}
}
}
@@ -471,7 +476,7 @@ else if ((dataholder.vrSettings.walkUpBlocks && ((PlayerExtension) player).getMu
public Vec3 getEstimatedTorsoPosition(double x, double y, double z)
{
- Entity entity = Minecraft.getInstance().player;
+ Entity entity = mc.player;
Vec3 vec3 = entity.getLookAngle();
Vec3 vec31 = (new Vec3(vec3.x, 0.0D, vec3.z)).normalize();
float f = (float)vec3.y * 0.25F;
@@ -481,26 +486,25 @@ public Vec3 getEstimatedTorsoPosition(double x, double y, double z)
public void blockDust(double x, double y, double z, int count, BlockPos bp, BlockState bs, float scale, float velscale)
{
new Random();
- Minecraft minecraft = Minecraft.getInstance();
for (int i = 0; i < count; ++i)
{
- TerrainParticle terrainparticle = new TerrainParticle(minecraft.level, x, y, z, 0.0D, 0.0D, 0.0D, bs);
+ TerrainParticle terrainparticle = new TerrainParticle(mc.level, x, y, z, 0.0D, 0.0D, 0.0D, bs);
terrainparticle.setPower(velscale);
//TODO: check
// minecraft.particleEngine.add(terrainparticle.init(bp).scale(scale));
- minecraft.particleEngine.add(terrainparticle.scale(scale));
+ mc.particleEngine.add(terrainparticle.scale(scale));
}
}
public void updateFreeMove()
{
- if (this.dh.teleportTracker.isAiming())
+ if (dh.teleportTracker.isAiming())
{
this.isFreeMoveCurrent = false;
}
- if (this.mc.player.input.forwardImpulse != 0.0F || this.mc.player.input.leftImpulse != 0.0F)
+ if (mc.player.input.forwardImpulse != 0.0F || mc.player.input.leftImpulse != 0.0F)
{
this.isFreeMoveCurrent = true;
}
@@ -510,28 +514,28 @@ public void updateFreeMove()
public boolean getFreeMove()
{
- if (this.dh.vrSettings.seated)
+ if (dh.vrSettings.seated)
{
- return this.dh.vrSettings.seatedFreeMove || !this.isTeleportEnabled();
+ return dh.vrSettings.seatedFreeMove || !this.isTeleportEnabled();
}
else
{
- return this.isFreeMoveCurrent || this.dh.vrSettings.forceStandingFreeMove;
+ return this.isFreeMoveCurrent || dh.vrSettings.forceStandingFreeMove;
}
}
public String toString()
{
- return "VRPlayer: \r\n \t origin: " + this.roomOrigin + "\r\n \t rotation: " + String.format("%.3f", ClientDataHolderVR.getInstance().vrSettings.worldRotation) + "\r\n \t scale: " + String.format("%.3f", this.worldScale) + "\r\n \t room_pre " + this.vrdata_room_pre + "\r\n \t world_pre " + this.vrdata_world_pre + "\r\n \t world_post " + this.vrdata_world_post + "\r\n \t world_render " + this.vrdata_world_render;
+ return "VRPlayer: \r\n \t origin: " + this.roomOrigin + "\r\n \t rotation: " + String.format("%.3f", dh.vrSettings.worldRotation) + "\r\n \t scale: " + String.format("%.3f", this.worldScale) + "\r\n \t room_pre " + this.vrdata_room_pre + "\r\n \t world_pre " + this.vrdata_world_pre + "\r\n \t world_post " + this.vrdata_world_post + "\r\n \t world_render " + this.vrdata_world_render;
}
public Vec3 getRightClickLookOverride(Player entity, int c)
{
Vec3 vec3 = entity.getLookAngle();
- if (((GameRendererExtension) this.mc.gameRenderer).getCrossVec() != null)
+ if (((GameRendererExtension) mc.gameRenderer).getCrossVec() != null)
{
- vec3 = entity.getEyePosition(1.0F).subtract(((GameRendererExtension) this.mc.gameRenderer).getCrossVec()).normalize().reverse();
+ vec3 = entity.getEyePosition(1.0F).subtract(((GameRendererExtension) mc.gameRenderer).getCrossVec()).normalize().reverse();
}
ItemStack itemstack;
@@ -554,11 +558,11 @@ public Vec3 getRightClickLookOverride(Player entity, int c)
}
}
- VRData vrdata = this.dh.vrPlayer.vrdata_world_pre;
+ VRData vrdata = dh.vrPlayer.vrdata_world_pre;
vec3 = vrdata.getController(c).getDirection();
- Vec3 vec31 = this.dh.bowTracker.getAimVector();
+ Vec3 vec31 = dh.bowTracker.getAimVector();
- if (this.dh.bowTracker.isNotched() && vec31 != null && vec31.lengthSqr() > 0.0D)
+ if (dh.bowTracker.isNotched() && vec31 != null && vec31.lengthSqr() > 0.0D)
{
vec3 = vec31.reverse();
}
@@ -566,78 +570,85 @@ public Vec3 getRightClickLookOverride(Player entity, int c)
return vec3;
}
- if (itemstack.getItem() == Items.BUCKET && this.dh.interactTracker.bukkit[c])
+ if (itemstack.getItem() == Items.BUCKET && dh.interactTracker.bukkit[c])
{
- vec3 = entity.getEyePosition(1.0F).subtract(this.dh.vrPlayer.vrdata_world_pre.getController(c).getPosition()).normalize().reverse();
+ vec3 = entity.getEyePosition(1.0F).subtract(dh.vrPlayer.vrdata_world_pre.getController(c).getPosition()).normalize().reverse();
}
return vec3;
}
- public void doPermanantLookOverride(LocalPlayer entity, VRData data)
+ public void doPermanentLookOverride(LocalPlayer entity, VRData data)
{
- if (entity == null)
- return;
+ if (entity == null)
+ return;
- if (entity.isPassenger())
+ if (entity.isPassenger())
{
- //Server-side movement
- Vec3 vec3 = VehicleTracker.getSteeringDirection(entity);
+ //Server-side movement
+ Vec3 vec3 = VehicleTracker.getSteeringDirection(entity);
- if (vec3 != null)
- {
- entity.setXRot((float)Math.toDegrees(Math.asin(-vec3.y / vec3.length())));
- entity.setYRot((float)Math.toDegrees(Math.atan2(-vec3.x, vec3.z)));
+ if (vec3 != null)
+ {
+ entity.setXRot((float)toDegrees(asin(-vec3.y / vec3.length())));
+ entity.setYRot((float)toDegrees(atan2(-vec3.x, vec3.z)));
entity.setYHeadRot(entity.getYRot());
- }
- } else if(entity.isBlocking()) {
- //block direction
- if (entity.getUsedItemHand() == InteractionHand.MAIN_HAND) {
- entity.setYRot(data.getController(0).getYaw());
- entity.setYHeadRot(entity.getYRot());
- entity.setXRot(-data.getController(0).getPitch());
- } else {
- entity.setYRot(data.getController(1).getYaw());
- entity.setYHeadRot(entity.getYRot());
- entity.setXRot(-data.getController(1).getPitch());
- }
- }
- else if (entity.isSprinting() && (entity.input.jumping || mc.options.keyJump.isDown()) || entity.isFallFlying() || entity.isSwimming() && entity.zza > 0.0F)
+ }
+ }
+ else if(entity.isBlocking())
+ {
+ //block direction
+ if (entity.getUsedItemHand() == InteractionHand.MAIN_HAND)
{
- //Server-side movement
- VRSettings.FreeMove freeMoveType = entity.isFallFlying() && this.dh.vrSettings.vrFreeMoveFlyMode != VRSettings.FreeMove.AUTO ? this.dh.vrSettings.vrFreeMoveFlyMode : this.dh.vrSettings.vrFreeMoveMode;
-
+ entity.setYRot(data.getController(0).getYaw());
+ entity.setYHeadRot(entity.getYRot());
+ entity.setXRot(-data.getController(0).getPitch());
+ }
+ else
+ {
+ entity.setYRot(data.getController(1).getYaw());
+ entity.setYHeadRot(entity.getYRot());
+ entity.setXRot(-data.getController(1).getPitch());
+ }
+ }
+ else if (entity.isSprinting() && (entity.input.jumping || mc.options.keyJump.isDown()) || entity.isFallFlying() || entity.isSwimming() && entity.zza > 0.0F)
+ {
+ //Server-side movement
+ FreeMove freeMoveType = entity.isFallFlying() && dh.vrSettings.vrFreeMoveFlyMode != FreeMove.AUTO ? dh.vrSettings.vrFreeMoveFlyMode : dh.vrSettings.vrFreeMoveMode;
- if (freeMoveType == VRSettings.FreeMove.CONTROLLER)
- {
- entity.setYRot(data.getController(1).getYaw());
- entity.setYHeadRot(entity.getYRot());
- entity.setXRot(-data.getController(1).getPitch());
- }
- else
- {
- entity.setYRot(data.hmd.getYaw());
- entity.setYHeadRot(entity.getYRot());
- entity.setXRot(-data.hmd.getPitch());
- }
+ if (freeMoveType == FreeMove.CONTROLLER)
+ {
+ entity.setYRot(data.getController(1).getYaw());
+ entity.setYHeadRot(entity.getYRot());
+ entity.setXRot(-data.getController(1).getPitch());
+ }
+ else
+ {
+ entity.setYRot(data.hmd.getYaw());
+ entity.setYHeadRot(entity.getYRot());
+ entity.setXRot(-data.hmd.getPitch());
}
- else if (((GameRendererExtension)mc.gameRenderer).getCrossVec() != null){
- //Look AT the crosshair by default, most compatible with mods.
- Vec3 playerToCrosshair = entity.getEyePosition(1).subtract(((GameRendererExtension)mc.gameRenderer).getCrossVec()); //backwards
- double what = playerToCrosshair.y/playerToCrosshair.length();
- if(what > 1) what = 1;
- if(what < -1) what = -1;
- float pitch = (float)Math.toDegrees(Math.asin(what));
- float yaw = (float)Math.toDegrees(Math.atan2(playerToCrosshair.x, -playerToCrosshair.z));
- entity.setXRot(pitch);
- entity.setYRot(yaw);
- entity.setYHeadRot(yaw);
- } else {
- //use HMD only if no crosshair hit.
- entity.setYRot(data.hmd.getYaw());
+ }
+ else if (((GameRendererExtension)mc.gameRenderer).getCrossVec() != null)
+ {
+ //Look AT the crosshair by default, most compatible with mods.
+ Vec3 playerToCrosshair = entity.getEyePosition(1).subtract(((GameRendererExtension)mc.gameRenderer).getCrossVec()); //backwards
+ double what = playerToCrosshair.y/playerToCrosshair.length();
+ if(what > 1) what = 1;
+ if(what < -1) what = -1;
+ float pitch = (float)toDegrees(asin(what));
+ float yaw = (float)toDegrees(atan2(playerToCrosshair.x, -playerToCrosshair.z));
+ entity.setXRot(pitch);
+ entity.setYRot(yaw);
+ entity.setYHeadRot(yaw);
+ }
+ else
+ {
+ //use HMD only if no crosshair hit.
+ entity.setYRot(data.hmd.getYaw());
entity.setYHeadRot(entity.getYRot());
- entity.setXRot(-data.hmd.getPitch());
+ entity.setXRot(-data.hmd.getPitch());
}
}
@@ -648,16 +659,16 @@ public Vec3 AimedPointAtDistance(VRData source, int controller, double distance)
return vec3.add(vec31.x * distance, vec31.y * distance, vec31.z * distance);
}
- public HitResult rayTraceBlocksVR(VRData source, int controller, double blockReachDistance, boolean p_174822_4_)
+ public HitResult rayTraceBlocksVR(VRData source, int controller, double blockReachDistance, boolean fluid)
{
Vec3 vec3 = source.getController(controller).getPosition();
Vec3 vec31 = this.AimedPointAtDistance(source, controller, blockReachDistance);
- return this.mc.level.clip(new ClipContext(vec3, vec31, ClipContext.Block.OUTLINE, p_174822_4_ ? ClipContext.Fluid.ANY : ClipContext.Fluid.NONE, this.mc.player));
+ return mc.level.clip(new ClipContext(vec3, vec31, Block.OUTLINE, fluid ? Fluid.ANY : Fluid.NONE, mc.player));
}
public boolean isTeleportSupported()
{
- return !VRServerPerms.INSTANCE.noTeleportClient;
+ return !VRServerPerms.noTeleportClient;
}
public boolean isTeleportOverridden()
@@ -667,15 +678,15 @@ public boolean isTeleportOverridden()
public boolean isTeleportEnabled()
{
- boolean flag = !VRServerPerms.INSTANCE.noTeleportClient || this.teleportOverride;
+ boolean flag = !VRServerPerms.noTeleportClient || this.teleportOverride;
- if (this.dh.vrSettings.seated)
+ if (dh.vrSettings.seated)
{
return flag;
}
else
{
- return flag && !this.dh.vrSettings.forceStandingFreeMove;
+ return flag && !dh.vrSettings.forceStandingFreeMove;
}
}
@@ -687,7 +698,7 @@ public void setTeleportOverride(boolean override)
public void updateTeleportKeys()
{
- this.dh.vr.getInputAction(VivecraftVRMod.INSTANCE.keyTeleport).setEnabled(this.isTeleportEnabled());
- this.dh.vr.getInputAction(VivecraftVRMod.INSTANCE.keyTeleportFallback).setEnabled(!this.isTeleportEnabled());
+ dh.vr.getInputAction(VivecraftVRMod.keyTeleport).setEnabled(this.isTeleportEnabled());
+ dh.vr.getInputAction(VivecraftVRMod.keyTeleportFallback).setEnabled(!this.isTeleportEnabled());
}
}
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 fc3e95e79..e0bb147d6 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
@@ -1,10 +1,22 @@
package org.vivecraft.client_vr.gameplay.screenhandlers;
+import org.vivecraft.client_vr.VRData.VRDevicePose;
+import org.vivecraft.client_vr.extensions.GameRendererExtension;
+import org.vivecraft.client_vr.gameplay.VRPlayer;
+import org.vivecraft.client_vr.provider.ControllerType;
+import org.vivecraft.client_vr.provider.HandedKeyBinding;
+import org.vivecraft.client_vr.provider.InputSimulator;
+import org.vivecraft.client_vr.render.RenderPass;
+import org.vivecraft.client_vr.settings.VRSettings.HUDLock;
+
+import org.joml.Matrix4f;
+import org.joml.Vector2f;
+import org.joml.Vector3f;
+
import com.mojang.blaze3d.pipeline.RenderTarget;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.KeyMapping;
-import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.ChatScreen;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.WinScreen;
@@ -12,31 +24,20 @@
import net.minecraft.client.gui.screens.inventory.AbstractSignEditScreen;
import net.minecraft.client.gui.screens.inventory.BookEditScreen;
import net.minecraft.world.entity.vehicle.ContainerEntity;
-import net.minecraft.world.phys.*;
+import net.minecraft.world.phys.BlockHitResult;
+import net.minecraft.world.phys.EntityHitResult;
+import net.minecraft.world.phys.HitResult.Type;
+import net.minecraft.world.phys.Vec2;
+import net.minecraft.world.phys.Vec3;
-import org.joml.Vector2f;
+import static org.vivecraft.client_vr.VRState.*;
+import static org.vivecraft.common.utils.Utils.*;
-import org.vivecraft.client_vr.VRData;
-import org.vivecraft.client.utils.Utils;
-import org.vivecraft.client_vr.ClientDataHolderVR;
-import org.vivecraft.client_vr.VRState;
-import org.vivecraft.client_vr.extensions.GameRendererExtension;
-import org.vivecraft.client_vr.gameplay.VRPlayer;
-import org.vivecraft.client_vr.provider.ControllerType;
-import org.vivecraft.client_vr.provider.HandedKeyBinding;
-import org.vivecraft.client_vr.provider.InputSimulator;
-import org.vivecraft.client_vr.provider.MCVR;
-import org.vivecraft.client_vr.provider.openvr_lwjgl.OpenVRUtil;
-import org.vivecraft.client_vr.render.RenderPass;
-import org.vivecraft.client_vr.settings.VRSettings;
-import org.vivecraft.common.utils.math.Matrix4f;
-import org.vivecraft.common.utils.math.Quaternion;
-import org.vivecraft.common.utils.math.Vector3;
+import static org.joml.Math.*;
+import static org.lwjgl.glfw.GLFW.*;
public class GuiHandler
{
- public static Minecraft mc = Minecraft.getInstance();
- public static ClientDataHolderVR dh = ClientDataHolderVR.getInstance();
static boolean lastPressedLeftClick;
static boolean lastPressedRightClick;
static boolean lastPressedMiddleClick;
@@ -50,12 +51,8 @@ public class GuiHandler
public static boolean guiAppearOverBlockActive = false;
public static float guiScale = 1.0F;
public static float guiScaleApplied = 1.0F;
- public static Vec3 IPoint = new Vec3(0.0D, 0.0D, 0.0D);
- public static Vec3 guiPos_room = null;
- public static Matrix4f guiRotation_room = null;
- public static float hudScale = 1.0F;
- public static Vec3 hudPos_room = new Vec3(0.0D, 0.0D, 0.0D);
- public static Matrix4f hudRotation_room = new Matrix4f();
+ public static Vec3 guiPos_room;
+ public static Matrix4f guiRotation_room;
public static final KeyMapping keyLeftClick = new KeyMapping("vivecraft.key.guiLeftClick", -1, "vivecraft.key.category.gui");
public static final KeyMapping keyRightClick = new KeyMapping("vivecraft.key.guiRightClick", -1, "vivecraft.key.category.gui");
public static final KeyMapping keyMiddleClick = new KeyMapping("vivecraft.key.guiMiddleClick", -1, "vivecraft.key.category.gui");
@@ -69,7 +66,7 @@ public class GuiHandler
{
public boolean isPriorityOnController(ControllerType type)
{
- if (KeyboardHandler.Showing && !GuiHandler.dh.vrSettings.physicalKeyboard)
+ if (KeyboardHandler.isShowing() && !dh.vrSettings.physicalKeyboard)
{
return KeyboardHandler.isUsingController(type);
}
@@ -83,9 +80,9 @@ public boolean isPriorityOnController(ControllerType type)
{
public boolean isPriorityOnController(ControllerType type)
{
- if (KeyboardHandler.Showing)
+ if (KeyboardHandler.isShowing())
{
- return GuiHandler.dh.vrSettings.physicalKeyboard ? true : KeyboardHandler.isUsingController(type);
+ return dh.vrSettings.physicalKeyboard || KeyboardHandler.isUsingController(type);
}
else
{
@@ -93,7 +90,7 @@ public boolean isPriorityOnController(ControllerType type)
}
}
};
- public static RenderTarget guiFramebuffer = null;
+ public static RenderTarget guiFramebuffer;
public static int guiWidth = 1280;
public static int guiHeight = 720;
public static int guiScaleFactor = calculateScale(0, false, guiWidth, guiHeight);
@@ -103,11 +100,14 @@ public boolean isPriorityOnController(ControllerType type)
public static int calculateScale(int scaleIn, boolean forceUnicode, int framebufferWidth, int framebufferHeight) {
int j = 1;
- while(j != scaleIn &&
- j < framebufferWidth &&
- j < framebufferHeight &&
- framebufferWidth / (j + 1) >= 320 &&
- framebufferHeight / (j + 1) >= 240) {
+ while(
+ j != scaleIn &&
+ j < framebufferWidth &&
+ j < framebufferHeight &&
+ framebufferWidth / (j + 1) >= 320 &&
+ framebufferHeight / (j + 1) >= 240
+ )
+ {
++j;
}
@@ -126,101 +126,92 @@ public static int calculateScale(int scaleIn, boolean forceUnicode, int framebuf
public static void processGui()
{
- if (mc.screen != null)
+ if (mc.screen != null && !dh.vrSettings.seated && guiRotation_room != null && dh.vr.isControllerTracking(0))
{
- if (!dh.vrSettings.seated)
+ Vec2 vec2 = getTexCoordsForCursor(
+ guiPos_room,
+ guiRotation_room,
+ guiScale,
+ dh.vrPlayer.vrdata_room_pre.getController(0)
+ );
+ float f = vec2.x;
+ float f1 = vec2.y;
+
+ if (!(f < 0.0F) && !(f1 < 0.0F) && !(f > 1.0F) && !(f1 > 1.0F))
{
- if (guiRotation_room != null)
+ if (controllerMouseX == -1.0D)
{
- if (MCVR.get().isControllerTracking(0))
- {
- Vec2 vec2 = getTexCoordsForCursor(guiPos_room, guiRotation_room, mc.screen, guiScale, dh.vrPlayer.vrdata_room_pre.getController(0));
- float f = vec2.x;
- float f1 = vec2.y;
+ controllerMouseX = (int) (f * (float) mc.getWindow().getScreenWidth());
+ controllerMouseY = (int) (f1 * (float) mc.getWindow().getScreenHeight());
+ }
+ else
+ {
+ float f2 = (int) (f * (float) mc.getWindow().getScreenWidth());
+ float f3 = (int) (f1 * (float) mc.getWindow().getScreenHeight());
+ controllerMouseX = controllerMouseX * (double) 0.7F + (double) (f2 * 0.3F);
+ controllerMouseY = controllerMouseY * (double) 0.7F + (double) (f3 * 0.3F);
+ }
+ }
+ else
+ {
+ controllerMouseX = -1.0D;
+ controllerMouseY = -1.0D;
+ }
- if (!(f < 0.0F) && !(f1 < 0.0F) && !(f > 1.0F) && !(f1 > 1.0F))
- {
- if (controllerMouseX == -1.0D)
- {
- controllerMouseX = (double)((int)(f * (float)mc.getWindow().getScreenWidth()));
- controllerMouseY = (double)((int)(f1 * (float)mc.getWindow().getScreenHeight()));
- }
- else
- {
- float f2 = (float)((int)(f * (float)mc.getWindow().getScreenWidth()));
- float f3 = (float)((int)(f1 * (float)mc.getWindow().getScreenHeight()));
- controllerMouseX = controllerMouseX * (double)0.7F + (double)(f2 * 0.3F);
- controllerMouseY = controllerMouseY * (double)0.7F + (double)(f3 * 0.3F);
- }
- }
- else
- {
- controllerMouseX = -1.0D;
- controllerMouseY = -1.0D;
- }
+ if (controllerMouseX >= 0.0D && controllerMouseX < (double) mc.getWindow().getScreenWidth() &&
+ controllerMouseY >= 0.0D && controllerMouseY < (double) mc.getWindow().getScreenHeight())
+ {
+ double d1 = clamp((int) controllerMouseX, 0, mc.getWindow().getScreenWidth());
+ double d0 = clamp((int) controllerMouseY, 0, mc.getWindow().getScreenHeight());
- if (controllerMouseX >= 0.0D && controllerMouseX < (double)mc.getWindow().getScreenWidth() && controllerMouseY >= 0.0D && controllerMouseY < (double)mc.getWindow().getScreenHeight())
- {
- double d1 = (double)Math.min(Math.max((int)controllerMouseX, 0), mc.getWindow().getScreenWidth());
- double d0 = (double)Math.min(Math.max((int)controllerMouseY, 0), mc.getWindow().getScreenHeight());
- int i = 0;
- int j = 0;
-
- if (MCVR.get().isControllerTracking(ControllerType.RIGHT))
- {
- InputSimulator.setMousePos(d1, d0);
- controllerMouseValid = true;
- }
- }
- else
- {
- if (controllerMouseTicks == 0)
- {
- controllerMouseValid = false;
- }
-
- if (controllerMouseTicks > 0)
- {
- --controllerMouseTicks;
- }
- }
- }
+ if (dh.vr.isControllerTracking(ControllerType.RIGHT))
+ {
+ InputSimulator.setMousePos(d1, d0);
+ controllerMouseValid = true;
+ }
+ }
+ else
+ {
+ if (controllerMouseTicks == 0)
+ {
+ controllerMouseValid = false;
+ }
+
+ if (controllerMouseTicks > 0)
+ {
+ --controllerMouseTicks;
}
}
}
}
- public static Vec2 getTexCoordsForCursor(Vec3 guiPos_room, Matrix4f guiRotation_room, Screen screen, float guiScale, VRData.VRDevicePose controller)
+ public static Vec2 getTexCoordsForCursor(Vec3 guiPos_room, Matrix4f guiRotation_room, float guiScale, VRDevicePose controller)
{
Vec3 vec3 = controller.getPosition();
- Vector3 vector3 = new Vector3(vec3);
+ Vector3f vector3 = convertToVector3f(vec3);
Vec3 vec31 = controller.getDirection();
- Vector3 vector31 = new Vector3((float)vec31.x, (float)vec31.y, (float)vec31.z);
- Vector3 vector32 = new Vector3(0.0F, 0.0F, 1.0F);
- Vector3 vector33 = guiRotation_room.transform(vector32);
- Vector3 vector34 = guiRotation_room.transform(new Vector3(1.0F, 0.0F, 0.0F));
- Vector3 vector35 = guiRotation_room.transform(new Vector3(0.0F, 1.0F, 0.0F));
+ Vector3f vector31 = convertToVector3f(vec31);
+ Vector3f vector33 = new Vector3f(backward).mulProject(guiRotation_room);
+ Vector3f vector34 = new Vector3f(right).mulProject(guiRotation_room);
+ Vector3f vector35 = new Vector3f(up).mulProject(guiRotation_room);
float f = vector33.dot(vector31);
- if (Math.abs(f) > 1.0E-5F)
+ if (abs(f) > 1.0E-5F)
{
float f1 = 1.0F;
float f2 = f1 * 0.5F;
float f3 = 1.0F;
float f4 = f3 * 0.5F;
- Vector3 vector36 = new Vector3();
- vector36.setX((float)guiPos_room.x);
- vector36.setY((float)guiPos_room.y);
- vector36.setZ((float)guiPos_room.z);
- Vector3 vector37 = vector36.subtract(vector35.divide(1.0F / f4)).subtract(vector34.divide(1.0F / f2));
- float f5 = -vector33.dot(vector3.subtract(vector37)) / f;
+ Vector3f vector36 = convertToVector3f(guiPos_room);
+ Vector3f vector37 = vector36.sub(vector35.div(1.0F / f4, new Vector3f()), new Vector3f()).sub(vector34.div(1.0F / f2, new Vector3f()), new Vector3f());
+ float f5 = -vector33.dot(vector3.sub(vector37, new Vector3f())) / f;
if (f5 > 0.0F)
{
- Vector3 vector38 = vector3.add(vector31.divide(1.0F / f5));
- Vector3 vector39 = vector38.subtract(vector37);
- float f6 = vector39.dot(vector34.divide(1.0F / f1));
- float f7 = vector39.dot(vector35.divide(1.0F / f1));
+ Vector3f vector38 = vector3.add(vector31.div(1.0F / f5, new Vector3f()), new Vector3f());
+ Vector3f vector39 = vector38.sub(vector37, new Vector3f());
+ float f6 = vector39.dot(vector34.div(1.0F / f1, new Vector3f()));
+ float f7 = vector39.dot(vector35.div(1.0F / f1, new Vector3f()));
float f8 = (float)mc.getWindow().getGuiScaledHeight() / (float)mc.getWindow().getGuiScaledWidth();
f6 = (f6 - 0.5F) / 1.5F / guiScale + 0.5F;
f7 = (f7 - 0.5F) / f8 / 1.5F / guiScale + 0.5F;
@@ -238,73 +229,73 @@ public static void processBindingsGui()
if (keyLeftClick.consumeClick() && mc.screen != null && flag)
{
- InputSimulator.pressMouse(0);
+ InputSimulator.pressMouse(GLFW_MOUSE_BUTTON_LEFT);
lastPressedLeftClick = true;
}
if (!keyLeftClick.isDown() && lastPressedLeftClick)
{
- InputSimulator.releaseMouse(0);
+ InputSimulator.releaseMouse(GLFW_MOUSE_BUTTON_LEFT);
lastPressedLeftClick = false;
}
if (keyRightClick.consumeClick() && mc.screen != null && flag)
{
- InputSimulator.pressMouse(1);
+ InputSimulator.pressMouse(GLFW_MOUSE_BUTTON_RIGHT);
lastPressedRightClick = true;
}
if (!keyRightClick.isDown() && lastPressedRightClick)
{
- InputSimulator.releaseMouse(1);
+ InputSimulator.releaseMouse(GLFW_MOUSE_BUTTON_RIGHT);
lastPressedRightClick = false;
}
if (keyMiddleClick.consumeClick() && mc.screen != null && flag)
{
- InputSimulator.pressMouse(2);
+ InputSimulator.pressMouse(GLFW_MOUSE_BUTTON_MIDDLE);
lastPressedMiddleClick = true;
}
if (!keyMiddleClick.isDown() && lastPressedMiddleClick)
{
- InputSimulator.releaseMouse(2);
+ InputSimulator.releaseMouse(GLFW_MOUSE_BUTTON_MIDDLE);
lastPressedMiddleClick = false;
}
if (keyShift.consumeClick() && mc.screen != null)
{
- InputSimulator.pressKey(340);
+ InputSimulator.pressKey(GLFW_KEY_LEFT_SHIFT);
lastPressedShift = true;
}
if (!keyShift.isDown() && lastPressedShift)
{
- InputSimulator.releaseKey(340);
+ InputSimulator.releaseKey(GLFW_KEY_LEFT_SHIFT);
lastPressedShift = false;
}
if (keyCtrl.consumeClick() && mc.screen != null)
{
- InputSimulator.pressKey(341);
+ InputSimulator.pressKey(GLFW_KEY_LEFT_CONTROL);
lastPressedCtrl = true;
}
if (!keyCtrl.isDown() && lastPressedCtrl)
{
- InputSimulator.releaseKey(341);
+ InputSimulator.releaseKey(GLFW_KEY_LEFT_CONTROL);
lastPressedCtrl = false;
}
if (keyAlt.consumeClick() && mc.screen != null)
{
- InputSimulator.pressKey(342);
+ InputSimulator.pressKey(GLFW_KEY_LEFT_ALT);
lastPressedAlt = true;
}
if (!keyAlt.isDown() && lastPressedAlt)
{
- InputSimulator.releaseKey(342);
+ InputSimulator.releaseKey(GLFW_KEY_LEFT_ALT);
lastPressedAlt = false;
}
@@ -321,7 +312,7 @@ public static void processBindingsGui()
public static void onScreenChanged(Screen previousGuiScreen, Screen newScreen, boolean unpressKeys)
{
- if (!VRState.vrRunning) {
+ if (!vrRunning) {
return;
}
@@ -343,7 +334,7 @@ public static void onScreenChanged(Screen previousGuiScreen, Screen newScreen, b
}
else
{
- RadialHandler.setOverlayShowing(false, (ControllerType)null);
+ RadialHandler.setOverlayShowing(false, null);
}
if (mc.level != null && !(newScreen instanceof WinScreen))
@@ -361,20 +352,16 @@ public static void onScreenChanged(Screen previousGuiScreen, Screen newScreen, b
}
// check if the new screen is meant to show the MenuRoom, instead of the current screen
- boolean staticScreen = mc.gameRenderer == null || (((GameRendererExtension) mc.gameRenderer).willBeInMenuRoom(newScreen));
+ boolean staticScreen = ((GameRendererExtension) mc.gameRenderer).willBeInMenuRoom(newScreen);
staticScreen = staticScreen & (!dh.vrSettings.seated && !dh.vrSettings.menuAlwaysFollowFace);
if (staticScreen)
{
guiScale = 2.0F;
- Vector2f afloat = MCVR.get().getPlayAreaSize();
+ Vector2f afloat = dh.vr.getPlayAreaSize();
// slight offset to center of the room, to prevent z fighting
- guiPos_room = new Vec3(0.02D, (double)1.3F, (double)(-Math.max(afloat != null ? afloat.y / 2.0F : 0.0F, 1.5F)));
+ guiPos_room = new Vec3(0.02D, (double)1.3F, (double)(-max(afloat != null ? afloat.y / 2.0F : 0.0F, 1.5F)));
guiRotation_room = new Matrix4f();
- guiRotation_room.M[0][0] = guiRotation_room.M[1][1] = guiRotation_room.M[2][2] = guiRotation_room.M[3][3] = 1.0F;
- guiRotation_room.M[0][1] = guiRotation_room.M[1][0] = guiRotation_room.M[2][3] = guiRotation_room.M[3][1] = 0.0F;
- guiRotation_room.M[0][2] = guiRotation_room.M[1][2] = guiRotation_room.M[2][0] = guiRotation_room.M[3][2] = 0.0F;
- guiRotation_room.M[0][3] = guiRotation_room.M[1][3] = guiRotation_room.M[2][1] = guiRotation_room.M[3][0] = 0.0F;
}
else
{
@@ -384,7 +371,7 @@ public static void onScreenChanged(Screen previousGuiScreen, Screen newScreen, b
// and if the pointed at block is the same that was last interacted with
boolean isBlockScreen = newScreen instanceof AbstractContainerScreen
&& mc.hitResult != null
- && (mc.hitResult.getType() == HitResult.Type.BLOCK);
+ && (mc.hitResult.getType() == Type.BLOCK);
// check if screen is a container screen
// and if the pointed at entity is the same that was last interacted with
@@ -392,6 +379,8 @@ public static void onScreenChanged(Screen previousGuiScreen, Screen newScreen, b
&& mc.hitResult instanceof EntityHitResult
&& ((EntityHitResult) mc.hitResult).getEntity() instanceof ContainerEntity;
+ Vec3 hmdPos = dh.vrPlayer.vrdata_room_pre.hmd.getPosition();
+
if (guiAppearOverBlockActive && (isBlockScreen || isEntityScreen) && dh.vrSettings.guiAppearOverBlock)
{
Vec3 sourcePos;
@@ -404,9 +393,8 @@ public static void onScreenChanged(Screen previousGuiScreen, Screen newScreen, b
}
Vec3 roomPos = VRPlayer.world_to_room_pos(sourcePos, dh.vrPlayer.vrdata_world_pre);
- Vec3 hmdPos = dh.vrPlayer.vrdata_room_pre.hmd.getPosition();
double distance = roomPos.subtract(hmdPos).length();
- guiScale = (float)Math.sqrt(distance);
+ guiScale = (float)sqrt(distance);
Vec3 sourcePosWorld = new Vec3(sourcePos.x, sourcePos.y + 1.1D + (double)(0.5F * guiScale / 2.0F), sourcePos.z);
guiPos_room = VRPlayer.world_to_room_pos(sourcePosWorld, dh.vrPlayer.vrdata_world_pre);
}
@@ -423,27 +411,20 @@ else if (newScreen instanceof BookEditScreen || newScreen instanceof AbstractSig
vec3 = new Vec3(0.0D, 0.25D, -2.0D);
}
- Vec3 hmdPos = dh.vrPlayer.vrdata_room_pre.hmd.getPosition();
Vec3 vec32 = dh.vrPlayer.vrdata_room_pre.hmd.getCustomVector(vec3);
guiPos_room = new Vec3(vec32.x / 2.0D + hmdPos.x, vec32.y / 2.0D + hmdPos.y, vec32.z / 2.0D + hmdPos.z);
- if (dh.vrSettings.physicalKeyboard && KeyboardHandler.Showing && guiPos_room.y < hmdPos.y + 0.2D)
+ if (dh.vrSettings.physicalKeyboard && KeyboardHandler.isShowing() && guiPos_room.y < hmdPos.y + 0.2D)
{
guiPos_room = new Vec3(guiPos_room.x, hmdPos.y + 0.2D, guiPos_room.z);
}
}
// orient screen
- Vec3 hmdPos = dh.vrPlayer.vrdata_room_pre.hmd.getPosition();
- Vector3 look = new Vector3();
- look.setX((float)(guiPos_room.x - hmdPos.x));
- look.setY((float)(guiPos_room.y - hmdPos.y));
- look.setZ((float)(guiPos_room.z - hmdPos.z));
- float pitch = (float)Math.asin((look.getY() / look.length()));
- float yaw = (float)(Math.PI + Math.atan2(look.getX(), look.getZ()));
- guiRotation_room = Matrix4f.rotationY(yaw);
- Matrix4f tilt = Utils.rotationXMatrix(pitch);
- guiRotation_room = Matrix4f.multiply(guiRotation_room, tilt);
+ Vector3f look = new Vector3f((float)(guiPos_room.x - hmdPos.x), (float)(guiPos_room.y - hmdPos.y), (float)(guiPos_room.z - hmdPos.z));
+ float pitch = asin((look.y / look.length()));
+ float yaw = (float)(PI + atan2(look.x, look.z));
+ guiRotation_room = new Matrix4f().rotationY(yaw).rotateX(pitch);
}
KeyboardHandler.orientOverlay(newScreen != null);
@@ -457,13 +438,14 @@ public static Vec3 applyGUIModelView(RenderPass currentPass, PoseStack pMatrixSt
if (mc.screen != null && guiPos_room == null)
{
- //naughty mods!
- onScreenChanged((Screen)null, mc.screen, false);
- } else if (mc.screen == null && guiPos_room != null)
+ //naughty mods!
+ onScreenChanged(null, mc.screen, false);
+ }
+ else if (mc.screen == null && guiPos_room != null)
{
//even naughtier mods!
// someone canceled the setScreen, so guiPos didn't get reset
- onScreenChanged((Screen)null, null, false);
+ onScreenChanged(null, null, false);
}
Vec3 guipos = guiPos_room;
@@ -473,73 +455,60 @@ public static Vec3 applyGUIModelView(RenderPass currentPass, PoseStack pMatrixSt
if (guipos == null)
{
- guirot = null;
+ guirot = guirot == null ? new Matrix4f() : guirot;
scale = 1.0F;
if (mc.level != null && (mc.screen == null || !dh.vrSettings.floatInventory))
{
- int i = 1;
-
- if (dh.vrSettings.reverseHands)
- {
- i = -1;
- }
-
- if (!dh.vrSettings.seated && dh.vrSettings.vrHudLockMode != VRSettings.HUDLock.HEAD)
+ int hand = dh.vrSettings.reverseHands ? -1 : 1;
+ switch(dh.vrSettings.seated ? HUDLock.HEAD : dh.vrSettings.vrHudLockMode)
{
- if (dh.vrSettings.vrHudLockMode == VRSettings.HUDLock.HAND)
+ case HAND ->
{
- Matrix4f matrix4f5 = dh.vr.getAimRotation(1);
- Matrix4f matrix4f7 = Matrix4f.rotationY(dh.vrPlayer.vrdata_world_render.rotation_radians);
- Matrix4f matrix4f9 = Matrix4f.multiply(matrix4f7, matrix4f5);
- guirot = Matrix4f.multiply(matrix4f9, Utils.rotationXMatrix((-(float)Math.PI / 5F)));
- guirot = Matrix4f.multiply(guirot, Matrix4f.rotationY(((float)Math.PI / 10F) * (float)i));
+ guirot
+ .rotationY(dh.vrPlayer.vrdata_world_render.rotation_radians)
+ .mul0(dh.vr.getAimRotation(1))
+ .rotateX(-(float)PI / 5F)
+ .rotateY(((float)PI * 0.1F) * hand);
scale = 0.58823526F;
- guilocal = new Vec3(guilocal.x, 0.32D * (double)dh.vrPlayer.vrdata_world_render.worldScale, guilocal.z);
+ guilocal = new Vec3(guilocal.x, 0.32F * dh.vrPlayer.vrdata_world_render.worldScale, guilocal.z);
guipos = ((GameRendererExtension) mc.gameRenderer).getControllerRenderPos(1);
dh.vr.hudPopup = true;
}
- else if (dh.vrSettings.vrHudLockMode == VRSettings.HUDLock.WRIST)
+ case WRIST ->
{
- Matrix4f matrix4f6 = dh.vr.getAimRotation(1);
- Matrix4f matrix4f8 = Matrix4f.rotationY(dh.vrPlayer.vrdata_world_render.rotation_radians);
- guirot = Matrix4f.multiply(matrix4f8, matrix4f6);
- guirot = Matrix4f.multiply(guirot, Utils.rotationZMatrix(((float)Math.PI / 2F) * (float)i));
- guirot = Matrix4f.multiply(guirot, Matrix4f.rotationY(0.9424779F * (float)i));
+ guirot.rotationY(dh.vrPlayer.vrdata_world_render.rotation_radians)
+ .mul0(dh.vr.getAimRotation(1))
+ .rotateZ(((float)PI / 2F) * hand)
+ .rotateY(((float)PI * 0.3F) * hand);
guipos = ((GameRendererExtension) mc.gameRenderer).getControllerRenderPos(1);
dh.vr.hudPopup = true;
- boolean flag = mc.player.getModelName().equals("slim");
scale = 0.4F;
- guilocal = new Vec3((double)((float)i * -0.136F * dh.vrPlayer.vrdata_world_render.worldScale), (flag ? 0.13D : 0.12D) * (double)dh.vrPlayer.vrdata_world_render.worldScale, 0.06D * (double)dh.vrPlayer.vrdata_world_render.worldScale);
- guirot = Matrix4f.multiply(guirot, Matrix4f.rotationY(((float)Math.PI / 5F) * (float)i));
+ guilocal = new Vec3(hand * -0.136F * dh.vrPlayer.vrdata_world_render.worldScale, (mc.player.getModelName().equals("slim") ? 0.13F : 0.12F) * dh.vrPlayer.vrdata_world_render.worldScale, 0.06F * dh.vrPlayer.vrdata_world_render.worldScale);
+ guirot.rotateY(((float)PI / 5F) * hand);
}
- }
- else
- {
- Matrix4f matrix4f1 = Matrix4f.rotationY(dh.vrPlayer.vrdata_world_render.rotation_radians);
- Matrix4f matrix4f2 = Matrix4f.multiply(matrix4f1, dh.vr.hmdRotation);
- Vec3 vec33 = dh.vrPlayer.vrdata_world_render.hmd.getPosition();
- Vec3 vec34 = dh.vrPlayer.vrdata_world_render.hmd.getDirection();
-
- if (dh.vrSettings.seated && dh.vrSettings.seatedHudAltMode)
+ default ->
{
- vec34 = dh.vrPlayer.vrdata_world_render.getController(0).getDirection();
- matrix4f2 = Matrix4f.multiply(matrix4f1, dh.vr.getAimRotation(0));
- }
+ guirot.rotationY(dh.vrPlayer.vrdata_world_render.rotation_radians).mul0(dh.vr.hmdRotation);
+ Vec3 vec33 = dh.vrPlayer.vrdata_world_render.hmd.getPosition();
+ Vec3 vec34 = dh.vrPlayer.vrdata_world_render.hmd.getDirection();
- guipos = new Vec3(vec33.x + vec34.x * (double)dh.vrPlayer.vrdata_world_render.worldScale * (double)dh.vrSettings.hudDistance, vec33.y + vec34.y * (double)dh.vrPlayer.vrdata_world_render.worldScale * (double)dh.vrSettings.hudDistance, vec33.z + vec34.z * (double)dh.vrPlayer.vrdata_world_render.worldScale * (double)dh.vrSettings.hudDistance);
- Quaternion quaternion = OpenVRUtil.convertMatrix4ftoRotationQuat(matrix4f2);
- guirot = new Matrix4f(quaternion);
- scale = dh.vrSettings.hudScale;
+ if (dh.vrSettings.seated && dh.vrSettings.seatedHudAltMode)
+ {
+ vec34 = dh.vrPlayer.vrdata_world_render.getController(0).getDirection();
+ guirot.mul0(dh.vr.getAimRotation(0));
+ }
+
+ guipos = new Vec3(vec33.x + vec34.x * dh.vrPlayer.vrdata_world_render.worldScale * dh.vrSettings.hudDistance, vec33.y + vec34.y * dh.vrPlayer.vrdata_world_render.worldScale * dh.vrSettings.hudDistance, vec33.z + vec34.z * dh.vrPlayer.vrdata_world_render.worldScale * dh.vrSettings.hudDistance);
+ scale = dh.vrSettings.hudScale;
+ }
}
}
}
else
{
- VRPlayer vrplayer1 = dh.vrPlayer;
guipos = VRPlayer.room_to_world_pos(guipos, dh.vrPlayer.vrdata_world_render);
- Matrix4f matrix4f4 = Matrix4f.rotationY(dh.vrPlayer.vrdata_world_render.rotation_radians);
- guirot = Matrix4f.multiply(matrix4f4, guirot);
+ guirot = new Matrix4f(guirot).rotateY(dh.vrPlayer.vrdata_world_render.rotation_radians);
}
if ((dh.vrSettings.seated || dh.vrSettings.menuAlwaysFollowFace) && ((GameRendererExtension) mc.gameRenderer).isInMenuRoom())
@@ -560,25 +529,20 @@ else if (dh.vrSettings.vrHudLockMode == VRSettings.HUDLock.WRIST)
f1 += f3;
}
- f1 = f1 / (float)dh.vr.hmdYawSamples.size();
- f1 = (float)Math.toRadians((double)f1);
- Vec3 vec38 = new Vec3(-Math.sin((double)f1), 0.0D, Math.cos((double)f1));
+ f1 /= dh.vr.hmdYawSamples.size();
+ f1 = toRadians(f1);
+ Vec3 vec38 = new Vec3(-sin(f1), 0.0D, cos(f1));
float f4 = ((GameRendererExtension) mc.gameRenderer).isInMenuRoom() ? 2.5F * dh.vrPlayer.vrdata_world_render.worldScale : dh.vrSettings.hudDistance;
Vec3 vec39 = vec35.add(new Vec3(vec38.x * (double)f4, vec38.y * (double)f4, vec38.z * (double)f4));
Vec3 vec310 = new Vec3(vec39.x, vec39.y, vec39.z);
- Matrix4f matrix4f3 = Matrix4f.rotationY((float)Math.PI - f1);
- guirot = Matrix4f.multiply(matrix4f3, Matrix4f.rotationY(dh.vrPlayer.vrdata_world_render.rotation_radians));
- VRPlayer vrplayer = dh.vrPlayer;
guipos = VRPlayer.room_to_world_pos(vec310, dh.vrPlayer.vrdata_world_render);
- guiRotation_room = matrix4f3;
+ guiRotation_room = guirot.rotationY((float)PI - f1).rotateY(dh.vrPlayer.vrdata_world_render.rotation_radians);
guiScale = 2.0F;
guiPos_room = vec310;
}
- //GL11.glMultMatrixf(dh.vrPlayer.vrdata_world_render.getEye(currentPass).getMatrix().toFloatBuffer());
-
if (guipos == null) {
- VRSettings.logger.error("guipos was null, how did that happen. vrRunning: {}", VRState.vrRunning);
+ logger.error("guipos was null, how did that happen. vrRunning: {}", vrRunning);
new RuntimeException().printStackTrace();
guiPos_room = new Vec3(0,0,0);
guipos = VRPlayer.room_to_world_pos(guiPos_room, dh.vrPlayer.vrdata_world_render);
@@ -588,9 +552,11 @@ else if (dh.vrSettings.vrHudLockMode == VRSettings.HUDLock.WRIST)
}
Vec3 vec36 = guipos.subtract(vec3);
- pMatrixStack.translate(vec36.x, vec36.y, vec36.z);
- pMatrixStack.mulPoseMatrix(guirot.toMCMatrix());
- pMatrixStack.translate(guilocal.x, guilocal.y, guilocal.z);
+ pMatrixStack.last().pose()
+ .translate((float) vec36.x, (float) vec36.y, (float) vec36.z)
+ .mul(guirot)
+ .translate((float) guilocal.x, (float) guilocal.y, (float) guilocal.z)
+ ;
float f2 = scale * dh.vrPlayer.vrdata_world_render.worldScale;
pMatrixStack.scale(f2, f2, f2);
guiScaleApplied = f2;
diff --git a/common/src/main/java/org/vivecraft/client_vr/gameplay/screenhandlers/KeyboardHandler.java b/common/src/main/java/org/vivecraft/client_vr/gameplay/screenhandlers/KeyboardHandler.java
index 885c05290..b6258276f 100644
--- a/common/src/main/java/org/vivecraft/client_vr/gameplay/screenhandlers/KeyboardHandler.java
+++ b/common/src/main/java/org/vivecraft/client_vr/gameplay/screenhandlers/KeyboardHandler.java
@@ -1,29 +1,30 @@
package org.vivecraft.client_vr.gameplay.screenhandlers;
-import org.vivecraft.client_vr.ClientDataHolderVR;
-import org.vivecraft.client_vr.provider.ControllerType;
-import org.vivecraft.common.utils.lwjgl.Matrix4f;
import org.vivecraft.client_vr.gui.GuiKeyboard;
import org.vivecraft.client_vr.gui.PhysicalKeyboard;
-import org.vivecraft.client.utils.Utils;
-import org.vivecraft.common.utils.lwjgl.Vector3f;
-import org.vivecraft.common.utils.math.Vector3;
+import org.vivecraft.client_vr.provider.ControllerType;
+
+import org.joml.Matrix4f;
+import org.joml.Vector3f;
import com.mojang.blaze3d.pipeline.RenderTarget;
-import net.minecraft.client.Minecraft;
import net.minecraft.world.phys.Vec2;
import net.minecraft.world.phys.Vec3;
+import static org.vivecraft.client_vr.VRState.dh;
+import static org.vivecraft.client_vr.VRState.mc;
+import static org.vivecraft.common.utils.Utils.convertToVec3;
+
+import static org.joml.Math.*;
+
public class KeyboardHandler
{
- public static Minecraft mc = Minecraft.getInstance();
- public static ClientDataHolderVR dh = ClientDataHolderVR.getInstance();
- public static boolean Showing = false;
+ private static boolean Showing = false;
public static GuiKeyboard UI = new GuiKeyboard();
public static PhysicalKeyboard physicalKeyboard = new PhysicalKeyboard();
public static Vec3 Pos_room = new Vec3(0.0D, 0.0D, 0.0D);
- public static org.vivecraft.common.utils.math.Matrix4f Rotation_room = new org.vivecraft.common.utils.math.Matrix4f();
+ public static Matrix4f Rotation_room = new Matrix4f();
private static boolean lpl;
private static boolean lps;
private static boolean PointedL;
@@ -36,7 +37,7 @@ public class KeyboardHandler
public static boolean setOverlayShowing(boolean showingState)
{
- if (ClientDataHolderVR.kiosk)
+ if (dh.kiosk)
{
return false;
}
@@ -60,7 +61,7 @@ public static boolean setOverlayShowing(boolean showingState)
}
else
{
- UI.init(Minecraft.getInstance(), j, k);
+ UI.init(mc, j, k);
}
Showing = true;
@@ -98,8 +99,8 @@ public static void processGui()
}
else
{
- Vec2 vec2 = GuiHandler.getTexCoordsForCursor(Pos_room, Rotation_room, mc.screen, GuiHandler.guiScale, dh.vrPlayer.vrdata_room_pre.getController(1));
- Vec2 vec21 = GuiHandler.getTexCoordsForCursor(Pos_room, Rotation_room, mc.screen, GuiHandler.guiScale, dh.vrPlayer.vrdata_room_pre.getController(0));
+ Vec2 vec2 = GuiHandler.getTexCoordsForCursor(Pos_room, Rotation_room, GuiHandler.guiScale, dh.vrPlayer.vrdata_room_pre.getController(1));
+ Vec2 vec21 = GuiHandler.getTexCoordsForCursor(Pos_room, Rotation_room, GuiHandler.guiScale, dh.vrPlayer.vrdata_room_pre.getController(0));
float f = vec21.x;
float f1 = vec21.y;
@@ -109,7 +110,6 @@ public static void processGui()
{
UI.cursorX2 = (float)((int)(f * (float)mc.getWindow().getScreenWidth()));
UI.cursorY2 = (float)((int)(f1 * (float)mc.getWindow().getScreenHeight()));
- PointedR = true;
}
else
{
@@ -117,8 +117,8 @@ public static void processGui()
float f3 = (float)((int)(f1 * (float)mc.getWindow().getScreenHeight()));
UI.cursorX2 = UI.cursorX2 * 0.7F + f2 * 0.3F;
UI.cursorY2 = UI.cursorY2 * 0.7F + f3 * 0.3F;
- PointedR = true;
}
+ PointedR = true;
}
else
{
@@ -136,7 +136,6 @@ public static void processGui()
{
UI.cursorX1 = (float)((int)(f * (float)mc.getWindow().getScreenWidth()));
UI.cursorY1 = (float)((int)(f1 * (float)mc.getWindow().getScreenHeight()));
- PointedL = true;
}
else
{
@@ -144,8 +143,8 @@ public static void processGui()
float f5 = (float)((int)(f1 * (float)mc.getWindow().getScreenHeight()));
UI.cursorX1 = UI.cursorX1 * 0.7F + f4 * 0.3F;
UI.cursorY1 = UI.cursorY1 * 0.7F + f5 * 0.3F;
- PointedL = true;
}
+ PointedL = true;
}
else
{
@@ -161,38 +160,30 @@ public static void processGui()
public static void orientOverlay(boolean guiRelative)
{
- keyboardForGui = false;
-
if (Showing)
{
keyboardForGui = guiRelative;
- Matrix4f matrix4f = new Matrix4f();
if (dh.vrSettings.physicalKeyboard)
{
Vec3 vec3 = dh.vrPlayer.vrdata_room_pre.hmd.getPosition();
Vec3 vec31 = new Vec3(0.0D, -0.5D, 0.3D);
- vec31 = vec31.yRot((float)Math.toRadians((double)(-dh.vrPlayer.vrdata_room_pre.hmd.getYaw())));
+ vec31 = vec31.yRot(toRadians(-dh.vrPlayer.vrdata_room_pre.hmd.getYaw()));
Pos_room = new Vec3(vec3.x + vec31.x, vec3.y + vec31.y, vec3.z + vec31.z);
- float f = (float)Math.PI + (float)Math.toRadians((double)(-dh.vrPlayer.vrdata_room_pre.hmd.getYaw()));
- Rotation_room = org.vivecraft.common.utils.math.Matrix4f.rotationY(f);
- Rotation_room = org.vivecraft.common.utils.math.Matrix4f.multiply(Rotation_room, Utils.rotationXMatrix(2.5132742F));
+ float f = (float)PI + toRadians(-dh.vrPlayer.vrdata_room_pre.hmd.getYaw());
+ Rotation_room.rotationY(f).rotateX((float)PI * 0.8F);
}
else if (guiRelative && GuiHandler.guiRotation_room != null)
{
- Matrix4f matrix4f1 = Utils.convertOVRMatrix(GuiHandler.guiRotation_room);
- Vec3 vec35 = new Vec3((double)matrix4f1.m10, (double)matrix4f1.m11, (double)matrix4f1.m12);
- Vec3 vec37 = (new Vec3((double)matrix4f1.m20, (double)matrix4f1.m21, (double)matrix4f1.m22)).scale(0.25D * GuiHandler.guiScale);
- vec35 = vec35.scale((double)0.8F);
- matrix4f.translate(new Vector3f((float)(GuiHandler.guiPos_room.x - vec35.x), (float)(GuiHandler.guiPos_room.y - vec35.y), (float)(GuiHandler.guiPos_room.z - vec35.z)));
- matrix4f.translate(new Vector3f((float)vec37.x, (float)vec37.y, (float)vec37.z));
- Matrix4f.mul(matrix4f, matrix4f1, matrix4f);
- matrix4f.rotate((float)Math.toRadians(30.0D), new Vector3f(-1.0F, 0.0F, 0.0F));
- Rotation_room = Utils.convertToOVRMatrix(matrix4f);
- Pos_room = new Vec3((double)Rotation_room.M[0][3], (double)Rotation_room.M[1][3], (double)Rotation_room.M[2][3]);
- Rotation_room.M[0][3] = 0.0F;
- Rotation_room.M[1][3] = 0.0F;
- Rotation_room.M[2][3] = 0.0F;
+ Vector3f vec35 = GuiHandler.guiRotation_room.getColumn(1, new Vector3f()).mul(0.8F);
+ Vector3f vec37 = GuiHandler.guiRotation_room.getColumn(2, new Vector3f()).mul(0.25F * GuiHandler.guiScale);
+ Matrix4f matrix4f = new Matrix4f()
+ .translate((float)(GuiHandler.guiPos_room.x - vec35.x), (float)(GuiHandler.guiPos_room.y - vec35.y), (float)(GuiHandler.guiPos_room.z - vec35.z))
+ .translate(vec37)
+ .mul(GuiHandler.guiRotation_room)
+ .rotateX(toRadians(-30.0F));
+ Pos_room = convertToVec3(matrix4f.getTranslation(new Vector3f()));
+ Rotation_room.set(matrix4f.setTranslation(new Vector3f(0.0F, 0.0F, 0.0F)));
}
else
{
@@ -201,15 +192,20 @@ else if (guiRelative && GuiHandler.guiRotation_room != null)
Vec3 vec36 = dh.vrPlayer.vrdata_room_pre.hmd.getCustomVector(vec34);
Pos_room = new Vec3(vec36.x / 2.0D + vec33.x, vec36.y / 2.0D + vec33.y, vec36.z / 2.0D + vec33.z);
Vec3 vec32 = dh.vrPlayer.vrdata_room_pre.hmd.getPosition();
- Vector3 vector3 = new Vector3();
- vector3.setX((float)(Pos_room.x - vec32.x));
- vector3.setY((float)(Pos_room.y - vec32.y));
- vector3.setZ((float)(Pos_room.z - vec32.z));
- float f1 = (float)Math.asin((double)(vector3.getY() / vector3.length()));
- float f2 = (float)((double)(float)Math.PI + Math.atan2((double)vector3.getX(), (double)vector3.getZ()));
- Rotation_room = org.vivecraft.common.utils.math.Matrix4f.rotationY(f2);
+ Vector3f vector3 = new Vector3f(
+ (float)(Pos_room.x - vec32.x),
+ (float)(Pos_room.y - vec32.y),
+ (float)(Pos_room.z - vec32.z)
+ );
+ float f1 = asin(vector3.y / vector3.length());
+ float f2 = (float)PI + atan2(vector3.x, vector3.z);
+ Rotation_room.rotationY(f2);
}
}
+ else
+ {
+ keyboardForGui = false;
+ }
}
public static void processBindings()
@@ -222,33 +218,33 @@ public static void processBindings()
return;
}
- double d0 = (double)Math.min(Math.max((int)UI.cursorX1, 0), mc.getWindow().getScreenWidth()) * (double)mc.getWindow().getGuiScaledWidth() / (double)mc.getWindow().getScreenWidth();
- double d1 = (double)Math.min(Math.max((int)UI.cursorY1, 0), mc.getWindow().getScreenWidth()) * (double)mc.getWindow().getGuiScaledHeight() / (double)mc.getWindow().getScreenHeight();
+ double d0 = (double)min(max((int)UI.cursorX1, 0), mc.getWindow().getScreenWidth()) * (double)mc.getWindow().getGuiScaledWidth() / (double)mc.getWindow().getScreenWidth();
+ double d1 = (double)min(max((int)UI.cursorY1, 0), mc.getWindow().getScreenWidth()) * (double)mc.getWindow().getGuiScaledHeight() / (double)mc.getWindow().getScreenHeight();
if (PointedL && GuiHandler.keyKeyboardClick.consumeClick(ControllerType.LEFT))
{
- UI.mouseClicked((double)((int)d0), (double)((int)d1), 0);
+ UI.mouseClicked(d0, d1, 0);
lastPressedClickL = true;
}
if (!GuiHandler.keyKeyboardClick.isDown(ControllerType.LEFT) && lastPressedClickL)
{
- UI.mouseReleased((double)((int)d0), (double)((int)d1), 0);
+ UI.mouseReleased(d0, d1, 0);
lastPressedClickL = false;
}
- d0 = (double)Math.min(Math.max((int)UI.cursorX2, 0), mc.getWindow().getScreenWidth()) * (double)mc.getWindow().getGuiScaledWidth() / (double)mc.getWindow().getScreenWidth();
- d1 = (double)Math.min(Math.max((int)UI.cursorY2, 0), mc.getWindow().getScreenWidth()) * (double)mc.getWindow().getGuiScaledHeight() / (double)mc.getWindow().getScreenHeight();
+ d0 = (double)min(max((int)UI.cursorX2, 0), mc.getWindow().getScreenWidth()) * (double)mc.getWindow().getGuiScaledWidth() / (double)mc.getWindow().getScreenWidth();
+ d1 = (double)min(max((int)UI.cursorY2, 0), mc.getWindow().getScreenWidth()) * (double)mc.getWindow().getGuiScaledHeight() / (double)mc.getWindow().getScreenHeight();
if (PointedR && GuiHandler.keyKeyboardClick.consumeClick(ControllerType.RIGHT))
{
- UI.mouseClicked((double)((int)d0), (double)((int)d1), 0);
+ UI.mouseClicked(d0, d1, 0);
lastPressedClickR = true;
}
if (!GuiHandler.keyKeyboardClick.isDown(ControllerType.RIGHT) && lastPressedClickR)
{
- UI.mouseReleased((double)((int)d0), (double)((int)d1), 0);
+ UI.mouseReleased(d0, d1, 0);
lastPressedClickR = false;
}
@@ -266,6 +262,10 @@ public static void processBindings()
}
}
+ public static boolean isShowing()
+ {
+ return Showing;
+ }
public static boolean isUsingController(ControllerType type)
{
return type == ControllerType.LEFT ? PointedL : PointedR;
diff --git a/common/src/main/java/org/vivecraft/client_vr/gameplay/screenhandlers/RadialHandler.java b/common/src/main/java/org/vivecraft/client_vr/gameplay/screenhandlers/RadialHandler.java
index bc4f7004c..b345340fa 100644
--- a/common/src/main/java/org/vivecraft/client_vr/gameplay/screenhandlers/RadialHandler.java
+++ b/common/src/main/java/org/vivecraft/client_vr/gameplay/screenhandlers/RadialHandler.java
@@ -1,24 +1,25 @@
package org.vivecraft.client_vr.gameplay.screenhandlers;
import org.vivecraft.client.VivecraftVRMod;
-import org.vivecraft.client_vr.ClientDataHolderVR;
-import org.vivecraft.client_vr.VRData;
-import org.vivecraft.client_vr.provider.ControllerType;
+import org.vivecraft.client_vr.VRData.VRDevicePose;
import org.vivecraft.client_vr.gui.GuiRadial;
-import org.vivecraft.client.utils.Utils;
-import org.vivecraft.common.utils.math.Matrix4f;
-import org.vivecraft.common.utils.math.Vector3;
+import org.vivecraft.client_vr.provider.ControllerType;
+
+import org.joml.Matrix4f;
+import org.joml.Vector3f;
import com.mojang.blaze3d.pipeline.RenderTarget;
-import net.minecraft.client.Minecraft;
import net.minecraft.world.phys.Vec2;
import net.minecraft.world.phys.Vec3;
+import static org.vivecraft.client_vr.VRState.dh;
+import static org.vivecraft.client_vr.VRState.mc;
+
+import static org.joml.Math.*;
+
public class RadialHandler
{
- public static Minecraft mc = Minecraft.getInstance();
- public static ClientDataHolderVR dh = ClientDataHolderVR.getInstance();
private static boolean Showing = false;
public static GuiRadial UI = new GuiRadial();
public static Vec3 Pos_room = new Vec3(0.0D, 0.0D, 0.0D);
@@ -27,7 +28,7 @@ public class RadialHandler
private static boolean lps;
private static boolean PointedL;
private static boolean PointedR;
- public static RenderTarget Framebuffer = null;
+ public static RenderTarget Framebuffer;
private static ControllerType activecontroller;
private static boolean lastPressedClickL;
private static boolean lastPressedClickR;
@@ -36,7 +37,7 @@ public class RadialHandler
public static boolean setOverlayShowing(boolean showingState, ControllerType controller)
{
- if (ClientDataHolderVR.kiosk)
+ if (dh.kiosk)
{
return false;
}
@@ -53,7 +54,7 @@ public static boolean setOverlayShowing(boolean showingState, ControllerType con
{
int j = mc.getWindow().getGuiScaledWidth();
int k = mc.getWindow().getGuiScaledHeight();
- UI.init(Minecraft.getInstance(), j, k);
+ UI.init(mc, j, k);
Showing = true;
activecontroller = controller;
orientOverlay(activecontroller);
@@ -79,8 +80,8 @@ public static void processGui()
{
if (Rotation_room != null)
{
- Vec2 vec2 = GuiHandler.getTexCoordsForCursor(Pos_room, Rotation_room, mc.screen, GuiHandler.guiScale, dh.vrPlayer.vrdata_room_pre.getController(1));
- Vec2 vec21 = GuiHandler.getTexCoordsForCursor(Pos_room, Rotation_room, mc.screen, GuiHandler.guiScale, dh.vrPlayer.vrdata_room_pre.getController(0));
+ Vec2 vec2 = GuiHandler.getTexCoordsForCursor(Pos_room, Rotation_room, GuiHandler.guiScale, dh.vrPlayer.vrdata_room_pre.getController(1));
+ Vec2 vec21 = GuiHandler.getTexCoordsForCursor(Pos_room, Rotation_room, GuiHandler.guiScale, dh.vrPlayer.vrdata_room_pre.getController(0));
float f = vec21.x;
float f1 = vec21.y;
@@ -143,35 +144,28 @@ public static void orientOverlay(ControllerType controller)
{
if (isShowing())
{
- VRData.VRDevicePose vrdata$vrdevicepose = dh.vrPlayer.vrdata_room_pre.hmd;
+ VRDevicePose vrdata$vrdevicepose = dh.vrPlayer.vrdata_room_pre.hmd;
float f = 2.0F;
- int i = 0;
-
- if (controller == ControllerType.LEFT)
- {
- i = 1;
- }
+ int con = (controller == ControllerType.LEFT) ? 1 : 0;
if (dh.vrSettings.radialModeHold)
{
- vrdata$vrdevicepose = dh.vrPlayer.vrdata_room_pre.getController(i);
+ vrdata$vrdevicepose = dh.vrPlayer.vrdata_room_pre.getController(con);
f = 1.2F;
}
- new Matrix4f();
Vec3 vec3 = vrdata$vrdevicepose.getPosition();
- Vec3 vec31 = new Vec3(0.0D, 0.0D, (double)(-f));
+ Vec3 vec31 = new Vec3(0.0D, 0.0D, -f);
Vec3 vec32 = vrdata$vrdevicepose.getCustomVector(vec31);
Pos_room = new Vec3(vec32.x / 2.0D + vec3.x, vec32.y / 2.0D + vec3.y, vec32.z / 2.0D + vec3.z);
- Vector3 vector3 = new Vector3();
- vector3.setX((float)(Pos_room.x - vec3.x));
- vector3.setY((float)(Pos_room.y - vec3.y));
- vector3.setZ((float)(Pos_room.z - vec3.z));
- float f1 = (float)Math.asin((double)(vector3.getY() / vector3.length()));
- float f2 = (float)((double)(float)Math.PI + Math.atan2((double)vector3.getX(), (double)vector3.getZ()));
- Rotation_room = Matrix4f.rotationY(f2);
- Matrix4f matrix4f = Utils.rotationXMatrix(f1);
- Rotation_room = Matrix4f.multiply(Rotation_room, matrix4f);
+ Vector3f vector3 = new Vector3f(
+ (float)(Pos_room.x - vec3.x),
+ (float)(Pos_room.y - vec3.y),
+ (float)(Pos_room.z - vec3.z)
+ );
+ float f1 = asin(vector3.y / vector3.length());
+ float f2 = (float)PI + atan2(vector3.x, vector3.z);
+ Rotation_room.rotationY(f2).rotateX(f1);
}
}
@@ -203,10 +197,10 @@ public static void processBindings()
lastPressedShiftR = false;
}
- double d0 = (double)Math.min(Math.max((int)UI.cursorX1, 0), mc.getWindow().getScreenWidth()) * (double)mc.getWindow().getGuiScaledWidth() / (double)mc.getWindow().getScreenWidth();
- double d1 = (double)Math.min(Math.max((int)UI.cursorY1, 0), mc.getWindow().getScreenWidth()) * (double)mc.getWindow().getGuiScaledHeight() / (double)mc.getWindow().getScreenHeight();
- double d2 = (double)Math.min(Math.max((int)UI.cursorX2, 0), mc.getWindow().getScreenWidth()) * (double)mc.getWindow().getGuiScaledWidth() / (double)mc.getWindow().getScreenWidth();
- double d3 = (double)Math.min(Math.max((int)UI.cursorY2, 0), mc.getWindow().getScreenWidth()) * (double)mc.getWindow().getGuiScaledHeight() / (double)mc.getWindow().getScreenHeight();
+ double d0 = (double)min(max((int)UI.cursorX1, 0), mc.getWindow().getScreenWidth()) * (double)mc.getWindow().getGuiScaledWidth() / (double)mc.getWindow().getScreenWidth();
+ double d1 = (double)min(max((int)UI.cursorY1, 0), mc.getWindow().getScreenWidth()) * (double)mc.getWindow().getGuiScaledHeight() / (double)mc.getWindow().getScreenHeight();
+ double d2 = (double)min(max((int)UI.cursorX2, 0), mc.getWindow().getScreenWidth()) * (double)mc.getWindow().getGuiScaledWidth() / (double)mc.getWindow().getScreenWidth();
+ double d3 = (double)min(max((int)UI.cursorY2, 0), mc.getWindow().getScreenWidth()) * (double)mc.getWindow().getGuiScaledHeight() / (double)mc.getWindow().getScreenHeight();
if (dh.vrSettings.radialModeHold)
{
@@ -215,43 +209,43 @@ public static void processBindings()
return;
}
- if (!VivecraftVRMod.INSTANCE.keyRadialMenu.isDown())
+ if (!VivecraftVRMod.keyRadialMenu.isDown())
{
if (activecontroller == ControllerType.LEFT)
{
- UI.mouseClicked((double)((int)d0), (double)((int)d1), 0);
+ UI.mouseClicked(d0, d1, 0);
}
else
{
- UI.mouseClicked((double)((int)d2), (double)((int)d3), 0);
+ UI.mouseClicked(d2, d3, 0);
}
- setOverlayShowing(false, (ControllerType)null);
+ setOverlayShowing(false, null);
}
}
else
{
if (PointedL && GuiHandler.keyKeyboardClick.consumeClick(ControllerType.LEFT))
{
- UI.mouseClicked((double)((int)d0), (double)((int)d1), 0);
+ UI.mouseClicked(d0, d1, 0);
lastPressedClickL = true;
}
if (!GuiHandler.keyKeyboardClick.isDown(ControllerType.LEFT) && lastPressedClickL)
{
- UI.mouseReleased((double)((int)d0), (double)((int)d1), 0);
+ UI.mouseReleased(d0, d1, 0);
lastPressedClickL = false;
}
if (PointedR && GuiHandler.keyKeyboardClick.consumeClick(ControllerType.RIGHT))
{
- UI.mouseClicked((double)((int)d2), (double)((int)d3), 0);
+ UI.mouseClicked(d2, d3, 0);
lastPressedClickR = true;
}
if (!GuiHandler.keyKeyboardClick.isDown(ControllerType.RIGHT) && lastPressedClickR)
{
- UI.mouseReleased((double)((int)d2), (double)((int)d3), 0);
+ UI.mouseReleased(d2, d3, 0);
lastPressedClickR = false;
}
}
diff --git a/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/BackpackTracker.java b/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/BackpackTracker.java
index 0540d73e2..bbdd967af 100644
--- a/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/BackpackTracker.java
+++ b/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/BackpackTracker.java
@@ -1,82 +1,72 @@
package org.vivecraft.client_vr.gameplay.trackers;
-import org.vivecraft.client_vr.ClientDataHolderVR;
-import org.vivecraft.client_vr.gameplay.VRPlayer;
-
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.player.LocalPlayer;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.network.protocol.game.ServerboundPlayerActionPacket;
import net.minecraft.world.phys.Vec3;
+import static org.vivecraft.client_vr.VRState.dh;
+import static org.vivecraft.client_vr.VRState.mc;
+
+import static org.joml.Math.*;
+
public class BackpackTracker extends Tracker
{
public boolean[] wasIn = new boolean[2];
public int previousSlot = 0;
- private Vec3 down = new Vec3(0.0D, -1.0D, 0.0D);
-
- public BackpackTracker(Minecraft mc, ClientDataHolderVR dh)
- {
- super(mc, dh);
- }
+ private final Vec3 down = new Vec3(0.0D, -1.0D, 0.0D);
- public boolean isActive(LocalPlayer p)
+ public boolean isActive()
{
- Minecraft minecraft = Minecraft.getInstance();
- ClientDataHolderVR dataholder = ClientDataHolderVR.getInstance();
- if (dataholder.vrSettings.seated)
+ if (dh.vrSettings.seated)
{
return false;
}
- else if (!dataholder.vrSettings.backpackSwitching)
+ else if (!dh.vrSettings.backpackSwitching)
{
return false;
}
- else if (p == null)
+ else if (mc.player == null)
{
return false;
}
- else if (minecraft.gameMode == null)
+ else if (mc.gameMode == null)
{
return false;
}
- else if (!p.isAlive())
+ else if (!mc.player.isAlive())
{
return false;
}
- else if (p.isSleeping())
+ else if (mc.player.isSleeping())
{
return false;
}
else
{
- return !dataholder.bowTracker.isDrawing;
+ return !dh.bowTracker.isDrawing;
}
}
- public void doProcess(LocalPlayer player)
+ public void doProcess()
{
- VRPlayer vrplayer = this.dh.vrPlayer;
- Vec3 vec3 = vrplayer.vrdata_room_pre.getHeadRear();
+ Vec3 vec3 = dh.vrPlayer.vrdata_room_pre.getHeadRear();
for (int i = 0; i < 2; ++i)
{
- Vec3 vec31 = vrplayer.vrdata_room_pre.getController(i).getPosition();
- Vec3 vec32 = vrplayer.vrdata_room_pre.getHand(i).getDirection();
- Vec3 vec33 = vrplayer.vrdata_room_pre.hmd.getDirection();
+ Vec3 vec31 = dh.vrPlayer.vrdata_room_pre.getController(i).getPosition();
+ Vec3 vec32 = dh.vrPlayer.vrdata_room_pre.getHand(i).getDirection();
+ Vec3 vec33 = dh.vrPlayer.vrdata_room_pre.hmd.getDirection();
Vec3 vec34 = vec3.subtract(vec31);
double d0 = vec32.dot(this.down);
double d1 = vec34.dot(vec33);
- boolean flag = Math.abs(vec3.y - vec31.y) < 0.25D;
+ boolean flag = abs(vec3.y - vec31.y) < 0.25D;
boolean flag1 = d1 > 0.0D && vec34.length() > 0.05D;
boolean flag2 = d0 > 0.6D;
boolean flag3 = d1 < 0.0D && vec34.length() > 0.25D;
boolean flag4 = d0 < 0.0D;
boolean flag5 = flag && flag1 && flag2;
- Minecraft minecraft = Minecraft.getInstance();
- ClientDataHolderVR dataholder = ClientDataHolderVR.getInstance();
if (flag5)
{
@@ -84,33 +74,33 @@ public void doProcess(LocalPlayer player)
{
if (i == 0)
{
- if (!dataholder.climbTracker.isGrabbingLadder() || !dataholder.climbTracker.isClaws(minecraft.player.getMainHandItem()))
+ if (!dh.climbTracker.isGrabbingLadder() || !dh.climbTracker.isClaws(mc.player.getMainHandItem()))
{
- if (player.getInventory().selected != 0)
+ if (mc.player.getInventory().selected != 0)
{
- this.previousSlot = player.getInventory().selected;
- player.getInventory().selected = 0;
+ this.previousSlot = mc.player.getInventory().selected;
+ mc.player.getInventory().selected = 0;
}
else
{
- player.getInventory().selected = this.previousSlot;
+ mc.player.getInventory().selected = this.previousSlot;
this.previousSlot = 0;
}
}
}
- else if (!dataholder.climbTracker.isGrabbingLadder() || !dataholder.climbTracker.isClaws(minecraft.player.getOffhandItem()))
+ else if (!dh.climbTracker.isGrabbingLadder() || !dh.climbTracker.isClaws(mc.player.getOffhandItem()))
{
- if (dataholder.vrSettings.physicalGuiEnabled)
+ if (dh.vrSettings.physicalGuiEnabled)
{
//minecraft.physicalGuiManager.toggleInventoryBag();
}
else
{
- player.connection.send(new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.SWAP_ITEM_WITH_OFFHAND, BlockPos.ZERO, Direction.DOWN));
+ mc.player.connection.send(new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.SWAP_ITEM_WITH_OFFHAND, BlockPos.ZERO, Direction.DOWN));
}
}
- dataholder.vr.triggerHapticPulse(i, 1500);
+ dh.vr.triggerHapticPulse(i, 1500);
this.wasIn[i] = true;
}
}
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 105f62ea6..9c991b3fe 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
@@ -1,30 +1,31 @@
package org.vivecraft.client_vr.gameplay.trackers;
-import java.nio.ByteBuffer;
-
-import org.vivecraft.client_vr.ClientDataHolderVR;
-import org.vivecraft.client_vr.gameplay.VRPlayer;
-import org.vivecraft.mod_compat_vr.pehkui.PehkuiHelper;
import org.vivecraft.client.Xplat;
-import org.vivecraft.common.network.CommonNetworkHelper;
-import org.vivecraft.client_vr.extensions.PlayerExtension;
import org.vivecraft.client.network.ClientNetworking;
import org.vivecraft.client_vr.VRData;
-import org.vivecraft.client_vr.settings.VRSettings;
-import org.vivecraft.common.utils.math.Vector3;
+import org.vivecraft.client_vr.extensions.PlayerExtension;
+import org.vivecraft.client_vr.settings.VRSettings.BowMode;
+import org.vivecraft.common.network.CommonNetworkHelper;
+import org.vivecraft.mod_compat_vr.pehkui.PehkuiHelper;
import net.minecraft.Util;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.player.LocalPlayer;
import net.minecraft.network.protocol.game.ServerboundCustomPayloadPacket;
import net.minecraft.tags.ItemTags;
import net.minecraft.world.InteractionHand;
-import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.UseAnim;
import net.minecraft.world.phys.Vec3;
+import javax.annotation.Nullable;
+import java.nio.ByteBuffer;
+
+import static org.vivecraft.client_vr.VRState.dh;
+import static org.vivecraft.client_vr.VRState.mc;
+import static org.vivecraft.common.utils.Utils.convertToVector3f;
+
+import static org.joml.Math.*;
+
public class BowTracker extends Tracker
{
private double lastcontrollersDist;
@@ -47,11 +48,6 @@ public class BowTracker extends Tracker
int hapcounter = 0;
int lasthapStep = 0;
- public BowTracker(Minecraft mc, ClientDataHolderVR dh)
- {
- super(mc, dh);
- }
-
public Vec3 getAimVector()
{
return this.aim;
@@ -73,11 +69,11 @@ public static boolean isBow(ItemStack itemStack)
{
return false;
}
- else if (ClientDataHolderVR.getInstance().vrSettings.bowMode == VRSettings.BowMode.OFF)
+ else if (dh.vrSettings.bowMode == BowMode.OFF)
{
return false;
}
- else if (ClientDataHolderVR.getInstance().vrSettings.bowMode == VRSettings.BowMode.VANILLA)
+ else if (dh.vrSettings.bowMode == BowMode.VANILLA)
{
return itemStack.getItem() == Items.BOW;
}
@@ -87,37 +83,51 @@ else if (ClientDataHolderVR.getInstance().vrSettings.bowMode == VRSettings.BowMo
}
}
- public static boolean isHoldingBow(LivingEntity e, InteractionHand hand)
+ public static boolean isHoldingBow(InteractionHand hand)
+ {
+ return !dh.vrSettings.seated && isBow(mc.player.getItemInHand(hand));
+ }
+
+ public static boolean isHoldingBowEither()
{
- return ClientDataHolderVR.getInstance().vrSettings.seated ? false : isBow(e.getItemInHand(hand));
+ return isHoldingBow(InteractionHand.MAIN_HAND) || isHoldingBow(InteractionHand.OFF_HAND);
}
- public static boolean isHoldingBowEither(LivingEntity e)
+ @Override public boolean isActive()
{
- return isHoldingBow(e, InteractionHand.MAIN_HAND) || isHoldingBow(e, InteractionHand.OFF_HAND);
+ return this.isActive(null);
}
- public boolean isActive(LocalPlayer p)
+ /**
+ * Test a specific hand isActive.
+ * @param hand the hand to test or either hand (null)
+ * @return bow tracker isActive for the specified hand or either hand
+ */
+ public boolean isActive(@Nullable InteractionHand hand)
{
- if (p == null)
+ if (mc.player == null)
{
return false;
}
- else if (this.mc.gameMode == null)
+ else if (mc.gameMode == null)
{
return false;
}
- else if (!p.isAlive())
+ else if (!mc.player.isAlive())
{
return false;
}
- else if (p.isSleeping())
+ else if (mc.player.isSleeping())
{
return false;
}
+ else if (hand != null)
+ {
+ return isHoldingBow(hand);
+ }
else
{
- return isHoldingBow(p, InteractionHand.MAIN_HAND) || isHoldingBow(p, InteractionHand.OFF_HAND);
+ return isHoldingBowEither();
}
}
@@ -126,28 +136,21 @@ public boolean isCharged()
return Util.getMillis() - this.startDrawTime >= this.maxDrawMillis;
}
- public void reset(LocalPlayer player)
+ @Override public void reset()
{
this.isDrawing = false;
}
- public EntryPoint getEntryPoint()
+ @Override public EntryPoint getEntryPoint()
{
return EntryPoint.SPECIAL_ITEMS;
}
- public void doProcess(LocalPlayer player)
+ @Override public void doProcess()
{
- VRData vrdata = this.dh.vrPlayer.vrdata_world_render;
-
- if (vrdata == null)
- {
- vrdata = this.dh.vrPlayer.vrdata_world_pre;
- }
-
- VRPlayer vrplayer = this.dh.vrPlayer;
+ VRData vrdata = dh.vrPlayer.getVRDataWorld();
- if (this.dh.vrSettings.seated)
+ if (dh.vrSettings.seated)
{
this.aim = vrdata.getController(0).getCustomVector(new Vec3(0.0D, 0.0D, 1.0D));
}
@@ -158,11 +161,11 @@ public void doProcess(LocalPlayer player)
this.lastpressed = this.pressed;
this.lastDraw = this.currentDraw;
this.lastcanDraw = this.canDraw;
- this.maxDraw = (double)this.mc.player.getBbHeight() * 0.22D;
+ this.maxDraw = (double)mc.player.getBbHeight() * 0.22D;
if (Xplat.isModLoaded("pehkui")) {
// this is meant to be relative to the base Bb height, not the scaled one
- this.maxDraw /= PehkuiHelper.getPlayerBbScale(player, mc.getFrameTime());
+ this.maxDraw /= PehkuiHelper.getPlayerBbScale(mc.player, mc.getFrameTime());
}
Vec3 vec3 = vrdata.getController(0).getPosition();
@@ -173,30 +176,28 @@ public void doProcess(LocalPlayer player)
double d0 = vec3.distanceTo(vec33);
this.aim = vec3.subtract(vec31).normalize();
Vec3 vec34 = vrdata.getController(0).getCustomVector(new Vec3(0.0D, 0.0D, -1.0D));
- Vector3 vector3 = new Vector3((float)vec34.x, (float)vec34.y, (float)vec34.z);
Vec3 vec35 = vrdata.getHand(1).getCustomVector(new Vec3(0.0D, -1.0D, 0.0D));
- Vector3 vector31 = new Vector3((float)vec35.x, (float)vec35.y, (float)vec35.z);
- this.controllersDot = (180D / Math.PI) * Math.acos((double)vector31.dot(vector3));
- this.pressed = this.mc.options.keyAttack.isDown();
+ this.controllersDot = (180D / PI) * acos((double) convertToVector3f(vec35).dot(convertToVector3f(vec34)));
+ this.pressed = mc.options.keyAttack.isDown();
float f = 0.15F * vrdata.worldScale;
- boolean flag = isHoldingBow(player, InteractionHand.MAIN_HAND);
+ boolean flag = isHoldingBow(InteractionHand.MAIN_HAND);
InteractionHand interactionhand = flag ? InteractionHand.MAIN_HAND : InteractionHand.OFF_HAND;
ItemStack itemstack = ItemStack.EMPTY;
ItemStack itemstack1 = ItemStack.EMPTY;
if (flag)
{
- itemstack1 = player.getMainHandItem();
- itemstack = player.getProjectile(itemstack1);
+ itemstack1 = mc.player.getMainHandItem();
+ itemstack = mc.player.getProjectile(itemstack1);
}
else
{
- if (player.getMainHandItem().is(ItemTags.ARROWS))
+ if (mc.player.getMainHandItem().is(ItemTags.ARROWS))
{
- itemstack = player.getMainHandItem();
+ itemstack = mc.player.getMainHandItem();
}
- itemstack1 = player.getOffhandItem();
+ itemstack1 = mc.player.getOffhandItem();
}
int i = itemstack1.getUseDuration();
@@ -215,33 +216,33 @@ public void doProcess(LocalPlayer player)
if (!this.isDrawing)
{
- ((PlayerExtension) player).setItemInUseClient(itemstack1, interactionhand);
- ((PlayerExtension) player).setItemInUseCountClient(i);
+ ((PlayerExtension) mc.player).setItemInUseClient(itemstack1, interactionhand);
+ ((PlayerExtension) mc.player).setItemInUseCountClient(i);
//Minecraft.getInstance().physicalGuiManager.preClickAction();
}
}
else if ((float)Util.getMillis() - this.tsNotch > 500.0F)
{
this.canDraw = false;
- ((PlayerExtension) player).setItemInUseClient(ItemStack.EMPTY, interactionhand);
+ ((PlayerExtension) mc.player).setItemInUseClient(ItemStack.EMPTY, interactionhand);
}
if (!this.isDrawing && this.canDraw && this.pressed && !this.lastpressed)
{
this.isDrawing = true;
//Minecraft.getInstance().physicalGuiManager.preClickAction();
- this.mc.gameMode.useItem(player, interactionhand);
+ mc.gameMode.useItem(mc.player, interactionhand);
}
if (this.isDrawing && !this.pressed && this.lastpressed && (double)this.getDrawPercent() > 0.0D)
{
- this.dh.vr.triggerHapticPulse(0, 500);
- this.dh.vr.triggerHapticPulse(1, 3000);
+ dh.vr.triggerHapticPulse(0, 500);
+ dh.vr.triggerHapticPulse(1, 3000);
ServerboundCustomPayloadPacket serverboundcustompayloadpacket = ClientNetworking.getVivecraftClientPacket(CommonNetworkHelper.PacketDiscriminators.DRAW, ByteBuffer.allocate(4).putFloat(this.getDrawPercent()).array());
- Minecraft.getInstance().getConnection().send(serverboundcustompayloadpacket);
- this.mc.gameMode.releaseUsingItem(player);
+ mc.getConnection().send(serverboundcustompayloadpacket);
+ mc.gameMode.releaseUsingItem(mc.player);
serverboundcustompayloadpacket = ClientNetworking.getVivecraftClientPacket(CommonNetworkHelper.PacketDiscriminators.DRAW, ByteBuffer.allocate(4).putFloat(0.0F).array());
- Minecraft.getInstance().getConnection().send(serverboundcustompayloadpacket);
+ mc.getConnection().send(serverboundcustompayloadpacket);
this.isDrawing = false;
}
@@ -252,8 +253,8 @@ else if ((float)Util.getMillis() - this.tsNotch > 500.0F)
if (!this.isDrawing && this.canDraw && !this.lastcanDraw)
{
- this.dh.vr.triggerHapticPulse(1, 800);
- this.dh.vr.triggerHapticPulse(0, 800);
+ dh.vr.triggerHapticPulse(1, 800);
+ dh.vr.triggerHapticPulse(0, 800);
}
if (this.isDrawing)
@@ -273,37 +274,37 @@ else if ((float)Util.getMillis() - this.tsNotch > 500.0F)
}
int l = (int)((float)itemstack1.getUseDuration() - this.getDrawPercent() * (float)this.maxDrawMillis);
- ((PlayerExtension) player).setItemInUseClient(itemstack1, interactionhand);
- double d1 = (double)this.getDrawPercent();
+ ((PlayerExtension) mc.player).setItemInUseClient(itemstack1, interactionhand);
+ double d1 = this.getDrawPercent();
if (d1 >= 1.0D)
{
- ((PlayerExtension) player).setItemInUseCountClient(k);
+ ((PlayerExtension) mc.player).setItemInUseCountClient(k);
}
else if (d1 > 0.4D)
{
- ((PlayerExtension) player).setItemInUseCountClient(j);
+ ((PlayerExtension) mc.player).setItemInUseCountClient(j);
}
else
{
- ((PlayerExtension) player).setItemInUseCountClient(i);
+ ((PlayerExtension) mc.player).setItemInUseCountClient(i);
}
int i1 = (int)(d1 * 4.0D * 4.0D * 3.0D);
if (i1 % 2 == 0 && this.lasthapStep != i1)
{
- this.dh.vr.triggerHapticPulse(0, j1);
+ dh.vr.triggerHapticPulse(0, j1);
if (d1 == 1.0D)
{
- this.dh.vr.triggerHapticPulse(1, j1);
+ dh.vr.triggerHapticPulse(1, j1);
}
}
if (this.isCharged() && this.hapcounter % 4 == 0)
{
- this.dh.vr.triggerHapticPulse(1, 200);
+ dh.vr.triggerHapticPulse(1, 200);
}
this.lasthapStep = i1;
diff --git a/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/CameraTracker.java b/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/CameraTracker.java
index 7c53a8bc8..bbb1aa883 100644
--- a/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/CameraTracker.java
+++ b/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/CameraTracker.java
@@ -1,43 +1,39 @@
package org.vivecraft.client_vr.gameplay.trackers;
-import org.vivecraft.client_vr.ClientDataHolderVR;
-import org.vivecraft.client_vr.VRData;
+import org.vivecraft.client_vr.VRData.VRDevicePose;
import org.vivecraft.client_vr.render.RenderPass;
-import org.vivecraft.client.utils.Utils;
-import org.vivecraft.common.utils.math.Matrix4f;
-import org.vivecraft.common.utils.math.Quaternion;
-import org.vivecraft.common.utils.math.Vector3;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.player.LocalPlayer;
+import org.joml.Matrix4f;
+import org.joml.Quaternionf;
+import org.joml.Vector3f;
+
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.world.phys.Vec3;
+import static org.vivecraft.client_vr.VRState.dh;
+import static org.vivecraft.client_vr.VRState.mc;
+
public class CameraTracker extends Tracker
{
public static final ModelResourceLocation cameraModel = new ModelResourceLocation("vivecraft", "camera", "");
public static final ModelResourceLocation cameraDisplayModel = new ModelResourceLocation("vivecraft", "camera_display", "");
private boolean visible = false;
private Vec3 position = new Vec3(0.0D, 0.0D, 0.0D);
- private Quaternion rotation = new Quaternion();
+ private Quaternionf rotation = new Quaternionf();
private int startController;
- private VRData.VRDevicePose startControllerPose;
+ private VRDevicePose startControllerPose;
private Vec3 startPosition;
- private Quaternion startRotation;
+ private Quaternionf startRotation;
private boolean quickMode;
- public CameraTracker(Minecraft mc, ClientDataHolderVR dh)
- {
- super(mc, dh);
- }
-
- public boolean isActive(LocalPlayer player)
+ @Override
+ public boolean isActive()
{
- if (this.mc.gameMode == null)
+ if (mc.gameMode == null)
{
return false;
}
- else if (this.dh.vrSettings.seated)
+ else if (dh.vrSettings.seated)
{
return false;
}
@@ -47,38 +43,42 @@ else if (this.dh.vrSettings.seated)
}
}
- public void doProcess(LocalPlayer player)
+ @Override
+ public void doProcess()
{
if (this.startControllerPose != null)
{
- VRData.VRDevicePose vrdata$vrdevicepose = this.dh.vrPlayer.vrdata_world_render.getController(this.startController);
+ VRDevicePose vrdata$vrdevicepose = dh.vrPlayer.vrdata_world_render.getController(this.startController);
Vec3 vec3 = this.startControllerPose.getPosition();
Vec3 vec31 = vrdata$vrdevicepose.getPosition().subtract(vec3);
- Matrix4f matrix4f = Matrix4f.multiply(vrdata$vrdevicepose.getMatrix(), this.startControllerPose.getMatrix().inverted());
- Vector3 vector3 = new Vector3((float)this.startPosition.x - (float)vec3.x, (float)this.startPosition.y - (float)vec3.y, (float)this.startPosition.z - (float)vec3.z);
- Vector3 vector31 = matrix4f.transform(vector3);
- this.position = new Vec3(this.startPosition.x + (double)((float)vec31.x) + (double)(vector31.getX() - vector3.getX()), this.startPosition.y + (double)((float)vec31.y) + (double)(vector31.getY() - vector3.getY()), this.startPosition.z + (double)((float)vec31.z) + (double)(vector31.getZ() - vector3.getZ()));
- this.rotation = this.startRotation.multiply(new Quaternion(Utils.convertOVRMatrix(matrix4f)));
+ Matrix4f matrix4f = vrdata$vrdevicepose.getMatrix().mul0(this.startControllerPose.getMatrix().invertAffine(), new Matrix4f());
+ Vector3f vector3 = new Vector3f((float)this.startPosition.x - (float)vec3.x, (float)this.startPosition.y - (float)vec3.y, (float)this.startPosition.z - (float)vec3.z);
+ Vector3f vector31 = vector3.mulProject(matrix4f, new Vector3f());
+ this.position = new Vec3(this.startPosition.x + (double)((float)vec31.x) + (double)(vector31.x - vector3.x), this.startPosition.y + (double)((float)vec31.y) + (double)(vector31.y - vector3.y), this.startPosition.z + (double)((float)vec31.z) + (double)(vector31.z - vector3.z));
+ this.rotation.setFromNormalized(matrix4f);
+ this.startRotation.mul(this.rotation, this.rotation);
}
- if (this.quickMode && !this.isMoving() && !this.dh.grabScreenShot)
+ if (this.quickMode && !this.isMoving() && !dh.grabScreenShot)
{
this.visible = false;
}
- if (this.dh.vrPlayer.vrdata_world_render.getEye(RenderPass.CENTER).getPosition().distanceTo(this.position) > (double)(this.mc.options.getEffectiveRenderDistance() * 12))
+ if (dh.vrPlayer.vrdata_world_render.getEye(RenderPass.CENTER).getPosition().distanceTo(this.position) > (double)(mc.options.getEffectiveRenderDistance() * 12))
{
this.visible = false;
}
}
- public void reset(LocalPlayer player)
+ @Override
+ public void reset()
{
this.visible = false;
this.quickMode = false;
this.stopMoving();
}
+ @Override
public EntryPoint getEntryPoint()
{
return EntryPoint.SPECIAL_ITEMS;
@@ -104,12 +104,12 @@ public void setPosition(Vec3 position)
this.position = position;
}
- public Quaternion getRotation()
+ public Quaternionf getRotation()
{
return this.rotation;
}
- public void setRotation(Quaternion rotation)
+ public void setRotation(Quaternionf rotation)
{
this.rotation = rotation;
}
@@ -132,9 +132,9 @@ public boolean isQuickMode()
public void startMoving(int controller, boolean quickMode)
{
this.startController = controller;
- this.startControllerPose = this.dh.vrPlayer.vrdata_world_pre.getController(controller);
+ this.startControllerPose = dh.vrPlayer.vrdata_world_pre.getController(controller);
this.startPosition = this.position;
- this.startRotation = this.rotation.copy();
+ this.startRotation = new Quaternionf(this.rotation);
this.quickMode = quickMode;
}
diff --git a/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/ClimbTracker.java b/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/ClimbTracker.java
index fbb660252..4fae83d11 100644
--- a/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/ClimbTracker.java
+++ b/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/ClimbTracker.java
@@ -1,25 +1,18 @@
package org.vivecraft.client_vr.gameplay.trackers;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Random;
-import java.util.Set;
-
-import net.minecraft.network.chat.contents.TranslatableContents;
import org.vivecraft.client.VivecraftVRMod;
-import org.vivecraft.client_vr.ClientDataHolderVR;
+import org.vivecraft.client.network.ClientNetworking;
import org.vivecraft.client_vr.BlockTags;
-import org.vivecraft.common.network.CommonNetworkHelper;
import org.vivecraft.client_vr.extensions.PlayerExtension;
-import org.vivecraft.client.network.ClientNetworking;
import org.vivecraft.client_vr.gameplay.VRPlayer;
import org.vivecraft.client_vr.provider.ControllerType;
+import org.vivecraft.common.network.CommonNetworkHelper;
+
+import org.joml.Vector3d;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.player.LocalPlayer;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
+import net.minecraft.network.chat.contents.TranslatableContents;
import net.minecraft.network.protocol.game.ServerboundCustomPayloadPacket;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.effect.MobEffects;
@@ -33,6 +26,14 @@
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.VoxelShape;
+import java.util.*;
+
+import static org.vivecraft.client_vr.VRState.dh;
+import static org.vivecraft.client_vr.VRState.mc;
+import static org.vivecraft.common.utils.Utils.convertToVec3;
+
+import static org.joml.Math.*;
+
public class ClimbTracker extends Tracker
{
private boolean[] latched = new boolean[2];
@@ -61,11 +62,6 @@ public class ClimbTracker extends Tracker
private Random rand = new Random();
boolean unsetflag;
- public ClimbTracker(Minecraft mc, ClientDataHolderVR dh)
- {
- super(mc, dh);
- }
-
public boolean isGrabbingLadder()
{
return this.latched[0] || this.latched[1];
@@ -110,33 +106,33 @@ else if (!i.hasTag() || !i.getTag().getBoolean("Unbreakable"))
}
}
- public boolean isActive(LocalPlayer p)
+ public boolean isActive()
{
- if (this.dh.vrSettings.seated)
+ if (dh.vrSettings.seated)
{
return false;
}
- else if (!this.dh.vrPlayer.getFreeMove() && !ClientDataHolderVR.getInstance().vrSettings.simulateFalling)
+ else if (!dh.vrPlayer.getFreeMove() && !dh.vrSettings.simulateFalling)
{
return false;
}
- else if (!this.dh.vrSettings.realisticClimbEnabled)
+ else if (!dh.vrSettings.realisticClimbEnabled)
{
return false;
}
- else if (p != null && p.isAlive())
+ else if (mc.player != null && mc.player.isAlive())
{
- if (this.mc.gameMode == null)
+ if (mc.gameMode == null)
{
return false;
}
- else if (p.isPassenger())
+ else if (mc.player.isPassenger())
{
return false;
}
else
{
- return this.isClimbeyClimbEquipped() || p.zza == 0.0F && p.xxa == 0.0F;
+ return this.isClimbeyClimbEquipped() || mc.player.zza == 0.0F && mc.player.xxa == 0.0F;
}
}
else
@@ -147,22 +143,22 @@ else if (p.isPassenger())
public boolean isClimbeyClimb()
{
- return !this.isActive(this.mc.player) ? false : this.isClimbeyClimbEquipped();
+ return this.isActive() && this.isClimbeyClimbEquipped();
}
public boolean isClimbeyClimbEquipped()
{
- return ClientNetworking.serverAllowsClimbey && ((PlayerExtension) this.mc.player).isClimbeyClimbEquipped();
+ return ClientNetworking.serverAllowsClimbey && ((PlayerExtension) mc.player).isClimbeyClimbEquipped();
}
- private boolean canstand(BlockPos bp, LocalPlayer p)
+ private boolean canstand(BlockPos bp)
{
- AABB aabb = p.level().getBlockState(bp).getCollisionShape(p.level(), bp).bounds();
+ AABB aabb = mc.player.level().getBlockState(bp).getCollisionShape(mc.player.level(), bp).bounds();
if (aabb != null && aabb.maxY != 0.0D)
{
BlockPos blockpos = bp.above();
- AABB aabb1 = p.level().getBlockState(blockpos).getCollisionShape(p.level(), blockpos).bounds();
+ AABB aabb1 = mc.player.level().getBlockState(blockpos).getCollisionShape(mc.player.level(), blockpos).bounds();
if (aabb1 != null && aabb1.maxY > 0.0D)
{
@@ -171,7 +167,7 @@ private boolean canstand(BlockPos bp, LocalPlayer p)
else
{
BlockPos blockpos1 = blockpos.above();
- AABB aabb2 = p.level().getBlockState(blockpos1).getCollisionShape(p.level(), blockpos1).bounds();
+ AABB aabb2 = mc.player.level().getBlockState(blockpos1).getCollisionShape(mc.player.level(), blockpos1).bounds();
return aabb2 == null || !(aabb2.maxY > 0.0D);
}
}
@@ -181,9 +177,9 @@ private boolean canstand(BlockPos bp, LocalPlayer p)
}
}
- public void idleTick(LocalPlayer player)
+ public void idleTick()
{
- if (!this.isActive(player))
+ if (!this.isActive())
{
this.waslatched[0] = false;
this.waslatched[1] = false;
@@ -193,24 +189,24 @@ public void idleTick(LocalPlayer player)
{
this.forceActivate = true;
}
- else if (this.mc.player.onGround() || this.mc.player.getAbilities().flying)
+ else if (mc.player.onGround() || mc.player.getAbilities().flying)
{
this.forceActivate = false;
}
- this.dh.vr.getInputAction(VivecraftVRMod.INSTANCE.keyClimbeyGrab).setEnabled(ControllerType.RIGHT, this.isClimbeyClimb() && (this.isGrabbingLadder() || this.inblock[0] || this.forceActivate));
- this.dh.vr.getInputAction(VivecraftVRMod.INSTANCE.keyClimbeyGrab).setEnabled(ControllerType.LEFT, this.isClimbeyClimb() && (this.isGrabbingLadder() || this.inblock[1] || this.forceActivate));
+ dh.vr.getInputAction(VivecraftVRMod.keyClimbeyGrab).setEnabled(ControllerType.RIGHT, this.isClimbeyClimb() && (this.isGrabbingLadder() || this.inblock[0] || this.forceActivate));
+ dh.vr.getInputAction(VivecraftVRMod.keyClimbeyGrab).setEnabled(ControllerType.LEFT, this.isClimbeyClimb() && (this.isGrabbingLadder() || this.inblock[1] || this.forceActivate));
}
- public void reset(LocalPlayer player)
+ public void reset()
{
this.latchStartController = -1;
this.latched[0] = false;
this.latched[1] = false;
- player.setNoGravity(false);
+ mc.player.setNoGravity(false);
}
- public void doProcess(LocalPlayer player)
+ public void doProcess()
{
boolean[] aboolean = new boolean[2];
boolean[] aboolean1 = new boolean[2];
@@ -222,13 +218,13 @@ public void doProcess(LocalPlayer player)
for (int i = 0; i < 2; ++i)
{
- avec3[i] = this.dh.vrPlayer.vrdata_world_pre.getController(i).getPosition();
- Vec3 vec3 = this.dh.vrPlayer.vrdata_world_pre.getController(i).getDirection();
+ avec3[i] = dh.vrPlayer.vrdata_world_pre.getController(i).getPosition();
+ Vec3 vec3 = dh.vrPlayer.vrdata_world_pre.getController(i).getDirection();
this.inblock[i] = false;
BlockPos blockpos = BlockPos.containing(avec3[i]);
- BlockState blockstate = this.mc.level.getBlockState(blockpos);
+ BlockState blockstate = mc.level.getBlockState(blockpos);
Block block = blockstate.getBlock();
- VoxelShape voxelshape = blockstate.getCollisionShape(this.mc.level, blockpos);
+ VoxelShape voxelshape = blockstate.getCollisionShape(mc.level, blockpos);
if (voxelshape.isEmpty())
{
@@ -239,9 +235,9 @@ public void doProcess(LocalPlayer player)
this.box[i] = voxelshape.bounds();
}
- if (!this.dh.climbTracker.isClimbeyClimb())
+ if (!dh.climbTracker.isClimbeyClimb())
{
- Vec3 vec31 = this.dh.vrPlayer.vrdata_world_pre.getController(i).getPosition().subtract(vec3.scale(0.2D));
+ Vec3 vec31 = dh.vrPlayer.vrdata_world_pre.getController(i).getPosition().subtract(vec3.scale(0.2D));
AABB aabb = new AABB(avec3[i], vec31);
flag3 = true;
boolean flag4 = block instanceof LadderBlock || block instanceof VineBlock || blockstate.is(BlockTags.VIVECRAFT_CLIMBABLE);
@@ -249,7 +245,7 @@ public void doProcess(LocalPlayer player)
if (!flag4)
{
BlockPos blockpos1 = BlockPos.containing(vec31);
- BlockState blockstate1 = this.mc.level.getBlockState(blockpos1);
+ BlockState blockstate1 = mc.level.getBlockState(blockpos1);
Block block1 = blockstate1.getBlock();
if (block1 instanceof LadderBlock || block1 instanceof VineBlock || blockstate1.is(BlockTags.VIVECRAFT_CLIMBABLE))
@@ -258,7 +254,7 @@ public void doProcess(LocalPlayer player)
blockstate = blockstate1;
block = blockstate1.getBlock();
avec3[i] = vec31;
- VoxelShape voxelshape1 = blockstate1.getCollisionShape(this.mc.level, blockpos1);
+ VoxelShape voxelshape1 = blockstate1.getCollisionShape(mc.level, blockpos1);
if (voxelshape1.isEmpty())
{
@@ -315,22 +311,22 @@ public void doProcess(LocalPlayer player)
flag4 = true;
this.box[i] = new AABB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D);
- if (blockstate.getValue(VineBlock.NORTH) && this.mc.level.getBlockState(blockpos.north()).canOcclude())
+ if (blockstate.getValue(VineBlock.NORTH) && mc.level.getBlockState(blockpos.north()).canOcclude())
{
list.add(this.southBB);
}
- if (blockstate.getValue(VineBlock.EAST) && this.mc.level.getBlockState(blockpos.east()).canOcclude())
+ if (blockstate.getValue(VineBlock.EAST) && mc.level.getBlockState(blockpos.east()).canOcclude())
{
list.add(this.westBB);
}
- if (blockstate.getValue(VineBlock.SOUTH) && this.mc.level.getBlockState(blockpos.south()).canOcclude())
+ if (blockstate.getValue(VineBlock.SOUTH) && mc.level.getBlockState(blockpos.south()).canOcclude())
{
list.add(this.northbb);
}
- if (blockstate.getValue(VineBlock.WEST) && this.mc.level.getBlockState(blockpos.west()).canOcclude())
+ if (blockstate.getValue(VineBlock.WEST) && mc.level.getBlockState(blockpos.west()).canOcclude())
{
list.add(this.eastBB);
}
@@ -380,7 +376,7 @@ else if (aabb2 == this.westBB)
else
{
BlockPos blockpos5 = BlockPos.containing(this.latchStart[i]);
- BlockState blockstate2 = this.mc.level.getBlockState(blockpos5);
+ BlockState blockstate2 = mc.level.getBlockState(blockpos5);
this.inblock[i] = this.wasinblock[i] && blockstate2.getBlock() instanceof LadderBlock || blockstate2.getBlock() instanceof VineBlock || blockstate2.is(BlockTags.VIVECRAFT_CLIMBABLE);
}
}
@@ -390,18 +386,18 @@ else if (aabb2 == this.westBB)
}
else
{
- if (this.mc.player.onGround())
+ if (mc.player.onGround())
{
- this.mc.player.setOnGround(!this.latched[0] && !this.latched[1]);
+ mc.player.setOnGround(!this.latched[0] && !this.latched[1]);
}
if (i == 0)
{
- aboolean[i] = VivecraftVRMod.INSTANCE.keyClimbeyGrab.isDown(ControllerType.RIGHT);
+ aboolean[i] = VivecraftVRMod.keyClimbeyGrab.isDown(ControllerType.RIGHT);
}
else
{
- aboolean[i] = VivecraftVRMod.INSTANCE.keyClimbeyGrab.isDown(ControllerType.LEFT);
+ aboolean[i] = VivecraftVRMod.keyClimbeyGrab.isDown(ControllerType.LEFT);
}
this.inblock[i] = this.box[i] != null && this.box[i].move(blockpos).contains(avec3[i]);
@@ -428,11 +424,11 @@ else if (aabb2 == this.westBB)
if (i == 0)
{
- VivecraftVRMod.INSTANCE.keyClimbeyGrab.unpressKey(ControllerType.RIGHT);
+ VivecraftVRMod.keyClimbeyGrab.unpressKey(ControllerType.RIGHT);
}
else
{
- VivecraftVRMod.INSTANCE.keyClimbeyGrab.unpressKey(ControllerType.LEFT);
+ VivecraftVRMod.keyClimbeyGrab.unpressKey(ControllerType.LEFT);
}
flag2 = true;
@@ -442,7 +438,7 @@ else if (aabb2 == this.westBB)
{
if (!this.wasinblock[i] && this.inblock[i])
{
- this.dh.vr.triggerHapticPulse(i, 750);
+ dh.vr.triggerHapticPulse(i, 750);
}
if (!this.wasinblock[i] && this.inblock[i] && aboolean[i] || !this.wasbutton[i] && aboolean[i] && this.inblock[i])
@@ -450,8 +446,8 @@ else if (aabb2 == this.westBB)
flag1 = true;
this.wantjump = false;
this.latchStart[i] = avec3[i];
- this.latchStart_room[i] = this.dh.vrPlayer.vrdata_room_pre.getController(i).getPosition();
- this.latchStartBody[i] = player.position();
+ this.latchStart_room[i] = dh.vrPlayer.vrdata_room_pre.getController(i).getPosition();
+ this.latchStartBody[i] = mc.player.position();
this.latchStartController = i;
this.latchbox[i] = this.box[i];
this.latched[i] = true;
@@ -466,12 +462,12 @@ else if (aabb2 == this.westBB)
this.latched[0] = false;
}
- this.dh.vr.triggerHapticPulse(i, 2000);
- ((PlayerExtension) this.mc.player).stepSound(blockpos, this.latchStart[i]);
+ dh.vr.triggerHapticPulse(i, 2000);
+ ((PlayerExtension) mc.player).stepSound(blockpos, this.latchStart[i].x(), this.latchStart[i].y(), this.latchStart[i].z());
if (!flag3)
{
- this.dh.vrPlayer.blockDust(this.latchStart[i].x, this.latchStart[i].y, this.latchStart[i].z, 5, blockpos, blockstate, 0.1F, 0.2F);
+ dh.vrPlayer.blockDust(this.latchStart[i].x(), this.latchStart[i].y(), this.latchStart[i].z(), 5, blockpos, blockstate, 0.1F, 0.2F);
}
}
}
@@ -488,19 +484,19 @@ else if (aabb2 == this.westBB)
{
flag1 = true;
this.latchStart[k] = avec3[k];
- this.latchStart_room[k] = this.dh.vrPlayer.vrdata_room_pre.getController(k).getPosition();
- this.latchStartBody[k] = player.position();
+ this.latchStart_room[k] = dh.vrPlayer.vrdata_room_pre.getController(k).getPosition();
+ this.latchStartBody[k] = mc.player.position();
this.latchStartController = k;
this.latched[k] = true;
this.latchbox[k] = this.box[k];
this.wantjump = false;
- this.dh.vr.triggerHapticPulse(k, 2000);
+ dh.vr.triggerHapticPulse(k, 2000);
BlockPos blockpos4 = BlockPos.containing(this.latchStart[k]);
- BlockState blockstate4 = this.mc.level.getBlockState(blockpos4);
+ BlockState blockstate4 = mc.level.getBlockState(blockpos4);
if (!flag3)
{
- this.dh.vrPlayer.blockDust(this.latchStart[k].x, this.latchStart[k].y, this.latchStart[k].z, 5, blockpos4, blockstate4, 0.1F, 0.2F);
+ dh.vrPlayer.blockDust(this.latchStart[k].x, this.latchStart[k].y, this.latchStart[k].z, 5, blockpos4, blockstate4, 0.1F, 0.2F);
}
}
}
@@ -508,7 +504,7 @@ else if (aabb2 == this.westBB)
if (!this.wantjump && !flag3)
{
- this.wantjump = VivecraftVRMod.INSTANCE.keyClimbeyJump.isDown() && this.dh.jumpTracker.isClimbeyJumpEquipped();
+ this.wantjump = VivecraftVRMod.keyClimbeyJump.isDown() && dh.jumpTracker.isClimbeyJumpEquipped();
}
flag2 = flag2 & this.wantjump;
@@ -516,23 +512,23 @@ else if (aabb2 == this.westBB)
if ((this.latched[0] || this.latched[1]) && !this.gravityOverride)
{
this.unsetflag = true;
- player.setNoGravity(true);
+ mc.player.setNoGravity(true);
this.gravityOverride = true;
}
if (!this.latched[0] && !this.latched[1] && this.gravityOverride)
{
- player.setNoGravity(false);
+ mc.player.setNoGravity(false);
this.gravityOverride = false;
}
if (!this.latched[0] && !this.latched[1] && !flag2)
{
- if (player.onGround() && this.unsetflag)
+ if (mc.player.onGround() && this.unsetflag)
{
this.unsetflag = false;
- VivecraftVRMod.INSTANCE.keyClimbeyGrab.unpressKey(ControllerType.RIGHT);
- VivecraftVRMod.INSTANCE.keyClimbeyGrab.unpressKey(ControllerType.LEFT);
+ VivecraftVRMod.keyClimbeyGrab.unpressKey(ControllerType.RIGHT);
+ VivecraftVRMod.keyClimbeyGrab.unpressKey(ControllerType.LEFT);
}
this.latchStartController = -1;
@@ -541,25 +537,24 @@ else if (aabb2 == this.westBB)
{
if ((this.latched[0] || this.latched[1]) && this.rand.nextInt(20) == 10)
{
- this.mc.player.causeFoodExhaustion(0.1F);
+ mc.player.causeFoodExhaustion(0.1F);
BlockPos blockpos3 = BlockPos.containing(this.latchStart[this.latchStartController]);
- BlockState blockstate3 = this.mc.level.getBlockState(blockpos3);
+ BlockState blockstate3 = mc.level.getBlockState(blockpos3);
if (!flag3)
{
- this.dh.vrPlayer.blockDust(this.latchStart[this.latchStartController].x, this.latchStart[this.latchStartController].y, this.latchStart[this.latchStartController].z, 1, blockpos3, blockstate3, 0.1F, 0.2F);
+ dh.vrPlayer.blockDust(this.latchStart[this.latchStartController].x, this.latchStart[this.latchStartController].y, this.latchStart[this.latchStartController].z, 1, blockpos3, blockstate3, 0.1F, 0.2F);
}
}
- Vec3 vec34 = this.dh.vrPlayer.vrdata_world_pre.getController(this.latchStartController).getPosition();
- VRPlayer vrplayer = this.dh.vrPlayer;
- Vec3 vec35 = VRPlayer.room_to_world_pos(this.latchStart_room[this.latchStartController], this.dh.vrPlayer.vrdata_world_pre);
+ Vec3 vec34 = dh.vrPlayer.vrdata_world_pre.getController(this.latchStartController).getPosition();
+ Vec3 vec35 = VRPlayer.room_to_world_pos(this.latchStart_room[this.latchStartController], dh.vrPlayer.vrdata_world_pre);
Vec3 vec36 = vec34.subtract(vec35);
- this.latchStart_room[this.latchStartController] = this.dh.vrPlayer.vrdata_room_pre.getController(this.latchStartController).getPosition();
+ this.latchStart_room[this.latchStartController] = dh.vrPlayer.vrdata_room_pre.getController(this.latchStartController).getPosition();
if (this.wantjump)
{
- this.dh.vr.triggerHapticPulse(this.latchStartController, 200);
+ dh.vr.triggerHapticPulse(this.latchStartController, 200);
}
if (!flag2)
@@ -568,17 +563,17 @@ else if (aabb2 == this.westBB)
if (flag1)
{
- player.setDeltaMovement(0.0D, 0.0D, 0.0D);
+ mc.player.setDeltaMovement(0.0D, 0.0D, 0.0D);
}
else
{
- player.setDeltaMovement(player.getDeltaMovement().x, 0.0D, player.getDeltaMovement().z);
+ mc.player.setDeltaMovement(mc.player.getDeltaMovement().x, 0.0D, mc.player.getDeltaMovement().z);
}
- player.fallDistance = 0.0F;
- double d4 = player.getX();
- double d6 = player.getY();
- double d8 = player.getZ();
+ mc.player.fallDistance = 0.0F;
+ double d4 = mc.player.getX();
+ double d6 = mc.player.getY();
+ double d8 = mc.player.getZ();
double d10 = d4;
double d0 = d8;
double d11 = d6 - vec36.y;
@@ -599,37 +594,37 @@ else if (aabb2 == this.westBB)
{
d0 = d8 - vec36.z;
d10 = (double)((float)blockpos2.getX() + 0.5F);
- d10 += (1.0 - Math.min(ClientDataHolderVR.getInstance().vrPlayer.worldScale, 1.0)) * (j == 4 ? 0.5 : -0.5);
+ d10 += (1.0 - min(dh.vrPlayer.worldScale, 1.0)) * (j == 4 ? 0.5 : -0.5);
}
}
else
{
d10 = d4 - vec36.x;
d0 = (double)((float)blockpos2.getZ() + 0.5F);
- d0 += (1.0 - Math.min(ClientDataHolderVR.getInstance().vrPlayer.worldScale, 1.0)) * (j == 2 ? 0.5 : -0.5);
+ d0 += (1.0 - min(dh.vrPlayer.worldScale, 1.0)) * (j == 2 ? 0.5 : -0.5);
}
}
- double d12 = this.dh.vrPlayer.vrdata_room_pre.getHeadPivot().y;
- double d1 = this.dh.vrPlayer.vrdata_room_pre.getController(this.latchStartController).getPosition().y;
+ double d12 = dh.vrPlayer.vrdata_room_pre.getHeadPivot().y;
+ double d1 = dh.vrPlayer.vrdata_room_pre.getController(this.latchStartController).getPosition().y;
if (!this.wantjump && this.latchbox[this.latchStartController] != null && d1 <= d12 / 2.0D && this.latchStart[this.latchStartController].y > this.latchbox[this.latchStartController].maxY * 0.8D + (double)blockpos2.getY())
{
- Vec3 vec32 = this.dh.vrPlayer.vrdata_world_pre.hmd.getDirection().scale((double)0.1F);
+ Vec3 vec32 = dh.vrPlayer.vrdata_world_pre.hmd.getDirection().scale((double)0.1F);
Vec3 vec33 = (new Vec3(vec32.x, 0.0D, vec32.z)).normalize().scale(0.1D);
- boolean flag5 = this.mc.level.noCollision(player, player.getBoundingBox().move(vec33.x, this.latchbox[this.latchStartController].maxY + (double)blockpos2.getY() - player.getY(), vec33.z));
+ boolean flag5 = mc.level.noCollision(mc.player, mc.player.getBoundingBox().move(vec33.x, this.latchbox[this.latchStartController].maxY + (double)blockpos2.getY() - mc.player.getY(), vec33.z));
if (flag5)
{
- d10 = player.getX() + vec33.x;
+ d10 = mc.player.getX() + vec33.x;
d11 = this.latchbox[this.latchStartController].maxY + (double)blockpos2.getY();
- d0 = player.getZ() + vec33.z;
+ d0 = mc.player.getZ() + vec33.z;
this.latchStartController = -1;
this.latched[0] = false;
this.latched[1] = false;
this.wasinblock[0] = false;
this.wasinblock[1] = false;
- player.setNoGravity(false);
+ mc.player.setNoGravity(false);
}
}
@@ -674,16 +669,16 @@ else if (aabb2 == this.westBB)
d3 = d8;
}
- player.setPos(d13, d2, d3);
- AABB aabb1 = player.getBoundingBox();
- flag6 = this.mc.level.noCollision(player, aabb1);
+ mc.player.setPos(d13, d2, d3);
+ AABB aabb1 = mc.player.getBoundingBox();
+ flag6 = mc.level.noCollision(mc.player, aabb1);
if (flag6)
{
if (l > 1)
{
- this.dh.vr.triggerHapticPulse(0, 100);
- this.dh.vr.triggerHapticPulse(1, 100);
+ dh.vr.triggerHapticPulse(0, 100);
+ dh.vr.triggerHapticPulse(1, 100);
}
break;
@@ -692,16 +687,16 @@ else if (aabb2 == this.westBB)
if (!flag6)
{
- player.setPos(d4, d6, d8);
- this.dh.vr.triggerHapticPulse(0, 100);
- this.dh.vr.triggerHapticPulse(1, 100);
+ mc.player.setPos(d4, d6, d8);
+ dh.vr.triggerHapticPulse(0, 100);
+ dh.vr.triggerHapticPulse(1, 100);
}
- if (this.mc.isLocalServer())
+ if (mc.isLocalServer())
{
- for (ServerPlayer serverplayer : this.mc.getSingleplayerServer().getPlayerList().getPlayers())
+ for (ServerPlayer serverplayer : mc.getSingleplayerServer().getPlayerList().getPlayers())
{
- if (serverplayer.getId() == this.mc.player.getId())
+ if (serverplayer.getId() == mc.player.getId())
{
serverplayer.fallDistance = 0.0F;
}
@@ -711,18 +706,18 @@ else if (aabb2 == this.westBB)
{
ServerboundCustomPayloadPacket serverboundcustompayloadpacket = ClientNetworking.getVivecraftClientPacket(CommonNetworkHelper.PacketDiscriminators.CLIMBING, new byte[0]);
- if (this.mc.getConnection() != null)
+ if (mc.getConnection() != null)
{
- this.mc.getConnection().send(serverboundcustompayloadpacket);
+ mc.getConnection().send(serverboundcustompayloadpacket);
}
}
}
else
{
this.wantjump = false;
- Vec3 vec38 = player.position().subtract(vec36);
- Vec3 vec39 = this.dh.vr.controllerHistory[this.latchStartController].netMovement(0.3D);
- double d5 = this.dh.vr.controllerHistory[this.latchStartController].averageSpeed((double)0.3F);
+ Vec3 vec38 = mc.player.position().subtract(vec36);
+ Vec3 vec39 = convertToVec3(dh.vr.controllerHistory[this.latchStartController].netMovement(0.3D, new Vector3d()));
+ double d5 = dh.vr.controllerHistory[this.latchStartController].averageSpeed(0.3D);
vec39 = vec39.scale(0.66D * d5);
float f = 0.66F;
@@ -731,20 +726,20 @@ else if (aabb2 == this.westBB)
vec39 = vec39.scale((double)f / vec39.length());
}
- if (player.hasEffect(MobEffects.JUMP))
+ if (mc.player.hasEffect(MobEffects.JUMP))
{
- vec39 = vec39.scale((double)player.getEffect(MobEffects.JUMP).getAmplifier() + 1.5D);
+ vec39 = vec39.scale((double)mc.player.getEffect(MobEffects.JUMP).getAmplifier() + 1.5D);
}
- vec39 = vec39.yRot(this.dh.vrPlayer.vrdata_world_pre.rotation_radians);
- player.setDeltaMovement(vec39.multiply(-1.0D, -1.0D, -1.0D));
- player.xOld = vec38.x;
- player.yOld = vec38.y;
- player.zOld = vec38.z;
- vec38 = vec38.add(player.getDeltaMovement().x, player.getDeltaMovement().y, player.getDeltaMovement().z);
- player.setPos(vec38.x, vec38.y, vec38.z);
- this.dh.vrPlayer.snapRoomOriginToPlayerEntity(player, false, false);
- this.mc.player.causeFoodExhaustion(0.3F);
+ vec39 = vec39.yRot(dh.vrPlayer.vrdata_world_pre.rotation_radians);
+ mc.player.setDeltaMovement(vec39.multiply(-1.0D, -1.0D, -1.0D));
+ mc.player.xOld = vec38.x;
+ mc.player.yOld = vec38.y;
+ mc.player.zOld = vec38.z;
+ vec38 = vec38.add(mc.player.getDeltaMovement().x, mc.player.getDeltaMovement().y, mc.player.getDeltaMovement().z);
+ mc.player.setPos(vec38.x, vec38.y, vec38.z);
+ dh.vrPlayer.snapRoomOriginToPlayerEntity(false, false);
+ mc.player.causeFoodExhaustion(0.3F);
}
}
}
diff --git a/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/CrawlTracker.java b/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/CrawlTracker.java
index 27c25393e..8ae9c7962 100644
--- a/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/CrawlTracker.java
+++ b/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/CrawlTracker.java
@@ -1,15 +1,17 @@
package org.vivecraft.client_vr.gameplay.trackers;
import org.vivecraft.client.Xplat;
-import org.vivecraft.client_vr.ClientDataHolderVR;
import org.vivecraft.client.network.ClientNetworking;
+import org.vivecraft.common.network.CommonNetworkHelper;
+import org.vivecraft.mod_compat_vr.pehkui.PehkuiHelper;
+
+import org.joml.Vector3d;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.player.LocalPlayer;
import net.minecraft.network.protocol.game.ServerboundCustomPayloadPacket;
import net.minecraft.world.entity.Pose;
-import org.vivecraft.common.network.CommonNetworkHelper;
-import org.vivecraft.mod_compat_vr.pehkui.PehkuiHelper;
+
+import static org.vivecraft.client_vr.VRState.dh;
+import static org.vivecraft.client_vr.VRState.mc;
public class CrawlTracker extends Tracker
{
@@ -17,18 +19,13 @@ public class CrawlTracker extends Tracker
public boolean crawling;
public boolean crawlsteresis;
- public CrawlTracker(Minecraft mc, ClientDataHolderVR dh)
- {
- super(mc, dh);
- }
-
- public boolean isActive(LocalPlayer player)
+ public boolean isActive()
{
- if (this.dh.vrSettings.seated)
+ if (dh.vrSettings.seated)
{
return false;
}
- else if (!this.dh.vrSettings.allowCrawling)
+ else if (!dh.vrSettings.allowCrawling)
{
return false;
}
@@ -36,48 +33,48 @@ else if (!ClientNetworking.serverAllowsCrawling)
{
return false;
}
- else if (!player.isAlive())
+ else if (!mc.player.isAlive())
{
return false;
}
- else if (player.isSpectator())
+ else if (mc.player.isSpectator())
{
return false;
}
- else if (player.isSleeping())
+ else if (mc.player.isSleeping())
{
return false;
}
else
{
- return !player.isPassenger();
+ return !mc.player.isPassenger();
}
}
- public void reset(LocalPlayer player)
+ public void reset()
{
this.crawling = false;
this.crawlsteresis = false;
- this.updateState(player);
+ this.updateState();
}
- public void doProcess(LocalPlayer player)
+ public void doProcess()
{
double scaleMultiplier = 1.0;
if (Xplat.isModLoaded("pehkui")) {
- scaleMultiplier /= PehkuiHelper.getPlayerScale(player, mc.getFrameTime());
+ scaleMultiplier /= PehkuiHelper.getPlayerScale(mc.player, mc.getFrameTime());
}
- this.crawling = this.dh.vr.hmdPivotHistory.averagePosition((double)0.2F).y * (double)this.dh.vrPlayer.worldScale * scaleMultiplier + (double)0.1F < (double)this.dh.vrSettings.crawlThreshold;
- this.updateState(player);
+ this.crawling = dh.vr.hmdPivotHistory.averagePosition(0.2D, new Vector3d()).y * dh.vrPlayer.worldScale * scaleMultiplier + 0.1D < (double)dh.vrSettings.crawlThreshold;
+ this.updateState();
}
- private void updateState(LocalPlayer player)
+ private void updateState()
{
if (this.crawling != this.wasCrawling)
{
if (this.crawling)
{
- player.setPose(Pose.SWIMMING);
+ mc.player.setPose(Pose.SWIMMING);
this.crawlsteresis = true;
}
@@ -85,16 +82,16 @@ private void updateState(LocalPlayer player)
{
ServerboundCustomPayloadPacket serverboundcustompayloadpacket = ClientNetworking.getVivecraftClientPacket(CommonNetworkHelper.PacketDiscriminators.CRAWL, new byte[] {(byte)(this.crawling ? 1 : 0)});
- if (this.mc.getConnection() != null)
+ if (mc.getConnection() != null)
{
- this.mc.getConnection().send(serverboundcustompayloadpacket);
+ mc.getConnection().send(serverboundcustompayloadpacket);
}
}
this.wasCrawling = this.crawling;
}
- if (!this.crawling && player.getPose() != Pose.SWIMMING)
+ if (!this.crawling && mc.player.getPose() != Pose.SWIMMING)
{
this.crawlsteresis = false;
}
diff --git a/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/EatingTracker.java b/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/EatingTracker.java
index ad46f36be..c46b3fa75 100644
--- a/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/EatingTracker.java
+++ b/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/EatingTracker.java
@@ -1,18 +1,19 @@
package org.vivecraft.client_vr.gameplay.trackers;
-import java.util.Random;
-
-import org.vivecraft.client_vr.ClientDataHolderVR;
-import org.vivecraft.client_vr.gameplay.VRPlayer;
+import org.joml.Vector3d;
import net.minecraft.Util;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.player.LocalPlayer;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.UseAnim;
import net.minecraft.world.phys.Vec3;
+import java.util.Random;
+
+import static org.vivecraft.client_vr.VRState.dh;
+import static org.vivecraft.client_vr.VRState.mc;
+import static org.vivecraft.common.utils.Utils.convertToVec3;
+
public class EatingTracker extends Tracker
{
float mouthtoEyeDistance = 0.0F;
@@ -22,43 +23,38 @@ public class EatingTracker extends Tracker
long eatStart;
private Random r = new Random();
- public EatingTracker(Minecraft mc, ClientDataHolderVR dh)
- {
- super(mc, dh);
- }
-
public boolean isEating()
{
return this.eating[0] || this.eating[1];
}
- public boolean isActive(LocalPlayer p)
+ public boolean isActive()
{
- if (ClientDataHolderVR.getInstance().vrSettings.seated)
+ if (dh.vrSettings.seated)
{
return false;
}
- else if (p == null)
+ else if (mc.player == null)
{
return false;
}
- else if (this.mc.gameMode == null)
+ else if (mc.gameMode == null)
{
return false;
}
- else if (!p.isAlive())
+ else if (!mc.player.isAlive())
{
return false;
}
- else if (p.isSleeping())
+ else if (mc.player.isSleeping())
{
return false;
}
else
{
- if (p.getMainHandItem() != null)
+ if (mc.player.getMainHandItem() != null)
{
- UseAnim useanim = p.getMainHandItem().getUseAnimation();
+ UseAnim useanim = mc.player.getMainHandItem().getUseAnimation();
if (useanim == UseAnim.EAT || useanim == UseAnim.DRINK || useanim == UseAnim.TOOT_HORN)
{
@@ -66,9 +62,9 @@ else if (p.isSleeping())
}
}
- if (p.getOffhandItem() != null)
+ if (mc.player.getOffhandItem() != null)
{
- UseAnim useanim1 = p.getOffhandItem().getUseAnimation();
+ UseAnim useanim1 = mc.player.getOffhandItem().getUseAnimation();
if (useanim1 == UseAnim.EAT || useanim1 == UseAnim.DRINK || useanim1 == UseAnim.TOOT_HORN)
{
@@ -80,30 +76,31 @@ else if (p.isSleeping())
}
}
- public void reset(LocalPlayer player)
+ public void reset()
{
this.eating[0] = false;
this.eating[1] = false;
}
- public void doProcess(LocalPlayer player) {
- VRPlayer vrplayer = this.dh.vrPlayer;
- Vec3 hmdPos = vrplayer.vrdata_room_pre.hmd.getPosition();
- Vec3 mouthPos = vrplayer.vrdata_room_pre.getController(0).getCustomVector(new Vec3(0.0D, (double)(-this.mouthtoEyeDistance), 0.0D)).add(hmdPos);
+ public void doProcess()
+ {
+ Vec3 hmdPos = dh.vrPlayer.vrdata_room_pre.hmd.getPosition();
+ Vec3 mouthPos = dh.vrPlayer.vrdata_room_pre.getController(0).getCustomVector(new Vec3(0.0D, (double)(-this.mouthtoEyeDistance), 0.0D)).add(hmdPos);
for (int c = 0; c < 2; ++c) {
- Vec3 controllerPos = this.dh.vr.controllerHistory[c].averagePosition(0.333D).add(vrplayer.vrdata_room_pre.getController(c).getCustomVector(new Vec3(0.0D, 0.0D, -0.1D)));
- controllerPos = controllerPos.add(this.dh.vrPlayer.vrdata_room_pre.getController(c).getDirection().scale(0.1D));
+ Vec3 controllerPos = convertToVec3(dh.vr.controllerHistory[c].averagePosition(0.333D, new Vector3d())).add(dh.vrPlayer.vrdata_room_pre.getController(c).getCustomVector(new Vec3(0.0D, 0.0D, -0.1D)));
+ controllerPos = controllerPos.add(dh.vrPlayer.vrdata_room_pre.getController(c).getDirection().scale(0.1D));
- if (mouthPos.distanceTo(controllerPos) < (double)this.threshold) {
- ItemStack itemstack = c == 0 ? player.getMainHandItem() : player.getOffhandItem();
+ if (mouthPos.distanceTo(controllerPos) < (double)this.threshold)
+ {
+ ItemStack itemstack = c == 0 ? mc.player.getMainHandItem() : mc.player.getOffhandItem();
if (itemstack == ItemStack.EMPTY) continue;
int crunchiness = 0;
if (itemstack.getUseAnimation() == UseAnim.DRINK){//thats how liquid works.
- if(vrplayer.vrdata_room_pre.getController(c).getCustomVector(new Vec3(0,1,0)).y > 0) continue;
+ if(dh.vrPlayer.vrdata_room_pre.getController(c).getCustomVector(new Vec3(0,1,0)).y > 0) continue;
}
else if (itemstack.getUseAnimation() == UseAnim.EAT) {
crunchiness = 2;
@@ -119,9 +116,9 @@ else if (itemstack.getUseAnimation() == UseAnim.TOOT_HORN) {
{
//Minecraft.getInstance().physicalGuiManager.preClickAction();
- if (this.mc.gameMode.useItem(player, c == 0 ? InteractionHand.MAIN_HAND : InteractionHand.OFF_HAND).consumesAction())
+ if (mc.gameMode.useItem(mc.player, c == 0 ? InteractionHand.MAIN_HAND : InteractionHand.OFF_HAND).consumesAction())
{
- this.mc.gameRenderer.itemInHandRenderer.itemUsed(c == 0 ? InteractionHand.MAIN_HAND : InteractionHand.OFF_HAND);
+ mc.gameRenderer.itemInHandRenderer.itemUsed(c == 0 ? InteractionHand.MAIN_HAND : InteractionHand.OFF_HAND);
this.eating[c] = true;
this.eatStart = Util.getMillis();
}
@@ -129,11 +126,11 @@ else if (itemstack.getUseAnimation() == UseAnim.TOOT_HORN) {
if (this.eating[c])
{
- long k = (long)player.getUseItemRemainingTicks();
+ long k = (long)mc.player.getUseItemRemainingTicks();
if (k > 0L && k % 5L <= (long)crunchiness)
{
- this.dh.vr.triggerHapticPulse(c, 700);
+ dh.vr.triggerHapticPulse(c, 700);
}
}
diff --git a/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/HorseTracker.java b/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/HorseTracker.java
index 31ddc5027..97806387e 100644
--- a/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/HorseTracker.java
+++ b/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/HorseTracker.java
@@ -1,16 +1,18 @@
package org.vivecraft.client_vr.gameplay.trackers;
-import org.vivecraft.client_vr.ClientDataHolderVR;
-import org.vivecraft.client_vr.gameplay.VRPlayer;
-import org.vivecraft.client_vr.settings.VRSettings;
-import org.vivecraft.client.utils.Utils;
-import org.vivecraft.common.utils.math.Quaternion;
-
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.player.LocalPlayer;
+import org.joml.Quaternionf;
+import org.joml.Vector3d;
+import org.joml.Vector3f;
+
import net.minecraft.world.entity.animal.horse.Horse;
import net.minecraft.world.phys.Vec3;
+import static org.vivecraft.client_vr.VRState.dh;
+import static org.vivecraft.client_vr.VRState.mc;
+import static org.vivecraft.common.utils.Utils.*;
+
+import static org.joml.Math.*;
+
public class HorseTracker extends Tracker
{
double boostTrigger = 1.4D;
@@ -21,52 +23,44 @@ public class HorseTracker extends Tracker
long lastBoostMillis = -1L;
double turnspeed = 6.0D;
double bodyturnspeed = 0.2D;
- double baseSpeed = 0.2D;
+ float baseSpeed = 0.2F;
Horse horse = null;
ModelInfo info = new ModelInfo();
- public HorseTracker(Minecraft mc, ClientDataHolderVR dh)
- {
- super(mc, dh);
- }
-
- public boolean isActive(LocalPlayer p)
+ public void reset()
{
- return false;
- }
-
- public void reset(LocalPlayer player)
- {
- super.reset(player);
-
if (this.horse != null)
{
this.horse.setNoAi(false);
}
}
- public void doProcess(LocalPlayer player)
+ public void doProcess()
{
- this.horse = (Horse)player.getVehicle();
+ this.horse = (Horse)mc.player.getVehicle();
this.horse.setNoAi(true);
float f = (this.horse.getYRot() + 360.0F) % 360.0F;
float f1 = (this.horse.yBodyRot + 360.0F) % 360.0F;
- Vec3 vec3 = this.dh.vr.controllerHistory[1].netMovement(0.1D).scale(10.0D);
- Vec3 vec31 = this.dh.vr.controllerHistory[0].netMovement(0.1D).scale(10.0D);
- double d0 = Math.min(-vec3.y, -vec31.y);
+ Vec3 vec3 = convertToVec3(dh.vr.controllerHistory[1].netMovement(0.1D, new Vector3d())).scale(10.0D);
+ Vec3 vec31 = convertToVec3(dh.vr.controllerHistory[0].netMovement(0.1D, new Vector3d())).scale(10.0D);
+ double d0 = min(-vec3.y, -vec31.y);
if (d0 > this.boostTrigger)
{
this.boost();
}
- Quaternion quaternion = new Quaternion(0.0F, -this.horse.yBodyRot, 0.0F);
- Vec3 vec32 = quaternion.multiply(new Vec3(0.0D, 0.0D, -1.0D));
- Vec3 vec33 = quaternion.multiply(new Vec3(1.0D, 0.0D, 0.0D));
- Vec3 vec34 = quaternion.multiply(new Vec3(-1.0D, 0.0D, 0.0D));
- Quaternion quaternion1 = new Quaternion(0.0F, VRSettings.inst.worldRotation, 0.0F);
- Vec3 vec35 = VRPlayer.get().roomOrigin.add(quaternion1.multiply(this.dh.vr.controllerHistory[1].latest()));
- Vec3 vec36 = VRPlayer.get().roomOrigin.add(quaternion1.multiply(this.dh.vr.controllerHistory[0].latest()));
+ Quaternionf quaternion = new Quaternionf().setAngleAxis(-this.horse.yBodyRot, 0.0F, 1.0F, 0.0F)
+ .mul(new Quaternionf().setAngleAxis(0.0F, 1.0F, 0.0F, 0.0F), new Quaternionf())
+ .mul(new Quaternionf().setAngleAxis(0.0F, 0.0F, 0.0F, 1.0F), new Quaternionf());
+ Vec3 vec32 = convertToVec3(quaternion.transformUnit(forward, new Vector3f()));
+ Vec3 vec33 = convertToVec3(quaternion.transformUnit(right, new Vector3f()));
+ Vec3 vec34 = convertToVec3(quaternion.transformUnit(left, new Vector3f()));
+ Quaternionf quaternion1 = new Quaternionf().setAngleAxis(toRadians(dh.vrSettings.worldRotation), 0.0F, 1.0F, 0.0F)
+ .mul(new Quaternionf().setAngleAxis(0.0F, 1.0F, 0.0F, 0.0F), new Quaternionf())
+ .mul(new Quaternionf().setAngleAxis(0.0F, 0.0F, 0.0F, 1.0F), new Quaternionf());
+ Vec3 vec35 = dh.vrPlayer.roomOrigin.add(convertToVec3(quaternion1.transformUnit(dh.vr.controllerHistory[1].latest(new Vector3f()), new Vector3f())));
+ Vec3 vec36 = dh.vrPlayer.roomOrigin.add(convertToVec3(quaternion1.transformUnit(dh.vr.controllerHistory[0].latest(new Vector3f()), new Vector3f())));
double d1 = vec35.subtract(this.info.leftReinPos).dot(vec32) + vec35.subtract(this.info.leftReinPos).dot(vec33);
double d2 = vec36.subtract(this.info.rightReinPos).dot(vec32) + vec36.subtract(this.info.rightReinPos).dot(vec34);
@@ -75,7 +69,7 @@ public void doProcess(LocalPlayer player)
this.speedLevel = 0;
}
- if (d1 > this.pullTrigger + 0.3D && d2 > this.pullTrigger + 0.3D && Math.abs(d2 - d1) < 0.1D)
+ if (d1 > this.pullTrigger + 0.3D && d2 > this.pullTrigger + 0.3D && abs(d2 - d1) < 0.1D)
{
if (this.speedLevel <= 0 && System.currentTimeMillis() > this.lastBoostMillis + (long)this.coolDownMillis)
{
@@ -104,9 +98,12 @@ public void doProcess(LocalPlayer player)
this.horse.setYRot((float)((double)f + (d4 - d3) * this.turnspeed));
}
- this.horse.yBodyRot = (float)Utils.lerpMod((double)f1, (double)f, this.bodyturnspeed, 360.0D);
+ this.horse.yBodyRot = (float)(abs(f - f1) < 360.0D / 2.0D ?
+ f1 + (f - f1) * this.bodyturnspeed :
+ f1 + (f - f1 - signum(f - f1) * 360.0D) * this.bodyturnspeed
+ );
this.horse.yHeadRot = f;
- Vec3 vec37 = quaternion.multiply(new Vec3(0.0D, 0.0D, (double)this.speedLevel * this.baseSpeed));
+ Vector3f vec37 = quaternion.transformUnit(new Vector3f(0.0F, 0.0F, this.speedLevel * this.baseSpeed), new Vector3f());
this.horse.setDeltaMovement(vec37.x, this.horse.getDeltaMovement().y, vec37.z);
}
@@ -140,7 +137,7 @@ else if (System.currentTimeMillis() < this.lastBoostMillis + (long)this.coolDown
}
else
{
- System.out.println("Breaking");
+ logger.info("Breaking");
--this.speedLevel;
this.lastBoostMillis = System.currentTimeMillis();
return true;
diff --git a/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/InteractTracker.java b/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/InteractTracker.java
index 98bb9c39d..680474dfa 100644
--- a/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/InteractTracker.java
+++ b/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/InteractTracker.java
@@ -1,25 +1,19 @@
package org.vivecraft.client_vr.gameplay.trackers;
-import java.util.HashSet;
-
import org.vivecraft.client.VivecraftVRMod;
-import org.vivecraft.client_vr.ClientDataHolderVR;
import org.vivecraft.client.Xplat;
-import org.vivecraft.client_vr.extensions.PlayerExtension;
import org.vivecraft.client_vr.VRData;
+import org.vivecraft.client_vr.extensions.PlayerExtension;
import org.vivecraft.client_vr.provider.ControllerType;
-import org.vivecraft.client_vr.settings.VRHotkeys;
-import org.vivecraft.client_vr.settings.VRSettings;
import org.vivecraft.client_vr.render.RenderPass;
import org.vivecraft.client_vr.render.VRFirstPersonArmSwing;
+import org.vivecraft.client_vr.settings.VRHotkeys;
+import org.vivecraft.client_vr.settings.VRSettings;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.player.LocalPlayer;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.network.protocol.game.ServerboundPlayerActionPacket;
-import net.minecraft.util.Mth;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.projectile.ProjectileUtil;
@@ -34,6 +28,14 @@
import net.minecraft.world.phys.EntityHitResult;
import net.minecraft.world.phys.Vec3;
+import java.util.HashSet;
+
+import static org.vivecraft.client_vr.VRState.dh;
+import static org.vivecraft.client_vr.VRState.mc;
+
+import static org.joml.Math.*;
+import static org.joml.RoundingMode.FLOOR;
+
public class InteractTracker extends Tracker
{
public boolean[] bukkit = new boolean[2];
@@ -48,67 +50,59 @@ public class InteractTracker extends Tracker
boolean[] wasactive = new boolean[2];
private HashSet rightClickable = null;
- public InteractTracker(Minecraft mc, ClientDataHolderVR dh)
+ public boolean isActive()
{
- super(mc, dh);
- }
-
- public boolean isActive(LocalPlayer p)
- {
- if (this.mc.gameMode == null)
+ if (mc.gameMode == null)
{
return false;
}
- else if (p == null)
+ else if (mc.player == null)
{
return false;
}
- else if (!p.isAlive())
+ else if (!mc.player.isAlive())
{
return false;
}
- else if (p.isSleeping())
+ else if (mc.player.isSleeping())
{
return false;
}
else
{
- Minecraft minecraft = Minecraft.getInstance();
- ClientDataHolderVR dataholder = ClientDataHolderVR.getInstance();
-
- if (dataholder.vrSettings.seated)
+ if (dh.vrSettings.seated)
{
return false;
}
- else if (p.isBlocking() && this.hotbar < 0)
+ else if (mc.player.isBlocking() && this.hotbar < 0)
{
return false;
}
else
{
- return !dataholder.bowTracker.isNotched();
+ return !dh.bowTracker.isNotched();
}
}
}
- public void reset(LocalPlayer player)
+ public void reset()
{
for (int i = 0; i < 2; ++i)
{
- this.reset(player, i);
+ this.reset(i);
}
}
- private void reset(LocalPlayer player, int c)
+ private void reset(int c)
{
if (this.inCamera[c] && VRHotkeys.isMovingThirdPersonCam() && VRHotkeys.getMovingThirdPersonCamTriggerer() == VRHotkeys.Triggerer.INTERACTION && VRHotkeys.getMovingThirdPersonCamController() == c)
{
VRHotkeys.stopMovingThirdPersonCam();
}
- if (this.inHandheldCamera[c] && this.dh.cameraTracker.isMoving() && this.dh.cameraTracker.getMovingController() == c && !this.dh.cameraTracker.isQuickMode())
+ if (this.inHandheldCamera[c] && dh.cameraTracker.isMoving() && dh.cameraTracker.getMovingController() == c && !dh.cameraTracker.isQuickMode())
{
- this.dh.cameraTracker.stopMoving();
+ dh.cameraTracker.stopMoving();
}
this.inBlockPos[c] = null;
@@ -118,10 +112,10 @@ private void reset(LocalPlayer player, int c)
this.inCamera[c] = false;
this.inHandheldCamera[c] = false;
this.active[c] = false;
- this.dh.vr.getInputAction(VivecraftVRMod.INSTANCE.keyVRInteract).setEnabled(ControllerType.values()[c], false);
+ dh.vr.getInputAction(VivecraftVRMod.keyVRInteract).setEnabled(ControllerType.values()[c], false);
}
- public void doProcess(LocalPlayer player)
+ public void doProcess()
{
if (this.rightClickable == null)
{
@@ -144,7 +138,7 @@ public void doProcess(LocalPlayer player)
this.rightClickable.add(oclass);
}
}
- catch (Throwable throwable1)
+ catch (Throwable ignored)
{
}
@@ -162,7 +156,7 @@ public void doProcess(LocalPlayer player)
this.rightClickable.add(oclass);
}
}
- catch (Throwable throwable)
+ catch (Throwable ignored)
{
}
}
@@ -176,42 +170,42 @@ public void doProcess(LocalPlayer player)
for (int j = 0; j < 2; ++j)
{
- if (!this.inCamera[j] && !this.inHandheldCamera[j] || !VivecraftVRMod.INSTANCE.keyVRInteract.isDown(ControllerType.values()[j]))
+ if (!this.inCamera[j] && !this.inHandheldCamera[j] || !VivecraftVRMod.keyVRInteract.isDown(ControllerType.values()[j]))
{
- this.reset(player, j);
+ this.reset(j);
if (j == 0 && this.hotbar >= 0)
{
this.active[j] = true;
}
- Vec3 vec35 = this.dh.vrPlayer.vrdata_world_pre.getHeadPivot();
- Vec3 vec3 = this.dh.vrPlayer.vrdata_world_pre.getController(j).getPosition();
- Vec3 vec31 = this.dh.vrPlayer.vrdata_world_pre.getHand(j).getCustomVector(vec34);
- ItemStack itemstack = player.getItemInHand(j == 0 ? InteractionHand.MAIN_HAND : InteractionHand.OFF_HAND);
+ Vec3 vec35 = dh.vrPlayer.vrdata_world_pre.getHeadPivot();
+ Vec3 vec3 = dh.vrPlayer.vrdata_world_pre.getController(j).getPosition();
+ Vec3 vec31 = dh.vrPlayer.vrdata_world_pre.getHand(j).getCustomVector(vec34);
+ ItemStack itemstack = mc.player.getItemInHand(j == 0 ? InteractionHand.MAIN_HAND : InteractionHand.OFF_HAND);
Item item = null;
- if (!this.active[j] && (this.dh.vrSettings.displayMirrorMode == VRSettings.MirrorMode.MIXED_REALITY || this.dh.vrSettings.displayMirrorMode == VRSettings.MirrorMode.THIRD_PERSON) && this.dh.vrSettings.mixedRealityRenderCameraModel)
+ if (!this.active[j] && (dh.vrSettings.displayMirrorMode == VRSettings.MirrorMode.MIXED_REALITY || dh.vrSettings.displayMirrorMode == VRSettings.MirrorMode.THIRD_PERSON) && dh.vrSettings.mixedRealityRenderCameraModel)
{
- VRData.VRDevicePose vrdata$vrdevicepose = this.dh.vrPlayer.vrdata_world_pre.getEye(RenderPass.THIRD);
+ VRData.VRDevicePose vrdata$vrdevicepose = dh.vrPlayer.vrdata_world_pre.getEye(RenderPass.THIRD);
Vec3 vec32 = vrdata$vrdevicepose.getPosition();
- vec32 = vec32.subtract(vrdata$vrdevicepose.getCustomVector(new Vec3(0.0D, 0.0D, -1.0D)).scale((double)0.15F * this.dh.vrPlayer.vrdata_world_pre.worldScale));
- vec32 = vec32.subtract(vrdata$vrdevicepose.getCustomVector(new Vec3(0.0D, -1.0D, 0.0D)).scale((double)0.05F * this.dh.vrPlayer.vrdata_world_pre.worldScale));
+ vec32 = vec32.subtract(vrdata$vrdevicepose.getCustomVector(new Vec3(0.0D, 0.0D, -1.0D)).scale((double)0.15F * dh.vrPlayer.vrdata_world_pre.worldScale));
+ vec32 = vec32.subtract(vrdata$vrdevicepose.getCustomVector(new Vec3(0.0D, -1.0D, 0.0D)).scale((double)0.05F * dh.vrPlayer.vrdata_world_pre.worldScale));
- if (vec3.distanceTo(vec32) < (double)0.15F * this.dh.vrPlayer.vrdata_world_pre.worldScale)
+ if (vec3.distanceTo(vec32) < (double)0.15F * dh.vrPlayer.vrdata_world_pre.worldScale)
{
this.inCamera[j] = true;
this.active[j] = true;
}
}
- if (!this.active[j] && this.dh.cameraTracker.isVisible() && !this.dh.cameraTracker.isQuickMode())
+ if (!this.active[j] && dh.cameraTracker.isVisible() && !dh.cameraTracker.isQuickMode())
{
- VRData.VRDevicePose vrdata$vrdevicepose1 = this.dh.vrPlayer.vrdata_world_pre.getEye(RenderPass.CAMERA);
+ VRData.VRDevicePose vrdata$vrdevicepose1 = dh.vrPlayer.vrdata_world_pre.getEye(RenderPass.CAMERA);
Vec3 vec36 = vrdata$vrdevicepose1.getPosition();
- vec36 = vec36.subtract(vrdata$vrdevicepose1.getCustomVector(new Vec3(0.0D, 0.0D, -1.0D)).scale((double)0.08F * this.dh.vrPlayer.vrdata_world_pre.worldScale));
+ vec36 = vec36.subtract(vrdata$vrdevicepose1.getCustomVector(new Vec3(0.0D, 0.0D, -1.0D)).scale((double)0.08F * dh.vrPlayer.vrdata_world_pre.worldScale));
- if (vec3.distanceTo(vec36) < (double)0.11F * this.dh.vrPlayer.vrdata_world_pre.worldScale)
+ if (vec3.distanceTo(vec36) < (double)0.11F * dh.vrPlayer.vrdata_world_pre.worldScale)
{
this.inHandheldCamera[j] = true;
this.active[j] = true;
@@ -220,14 +214,14 @@ public void doProcess(LocalPlayer player)
if (!this.active[j])
{
- int k = Mth.floor(vec3.x);
- int l = Mth.floor(vec3.y);
- int i = Mth.floor(vec3.z);
+ int k = roundUsing(vec3.x, FLOOR);
+ int l = roundUsing(vec3.y, FLOOR);
+ int i = roundUsing(vec3.z, FLOOR);
Vec3 vec33 = new Vec3(vec3.x + vec31.x * -0.1D, vec3.y + vec31.y * -0.1D, vec3.z + vec31.z * -0.1D);
AABB aabb = new AABB(vec3, vec33);
- this.inEntityHit[j] = ProjectileUtil.getEntityHitResult(this.mc.getCameraEntity(), vec35, vec3, aabb, (e) ->
+ this.inEntityHit[j] = ProjectileUtil.getEntityHitResult(mc.getCameraEntity(), vec35, vec3, aabb, (e) ->
{
- return !e.isSpectator() && e.isPickable() && e != this.mc.getCameraEntity().getVehicle();
+ return !e.isSpectator() && e.isPickable() && e != mc.getCameraEntity().getVehicle();
}, 0.0D);
if (this.inEntityHit[j] != null)
@@ -242,8 +236,8 @@ public void doProcess(LocalPlayer player)
{
BlockPos blockpos = null;
blockpos = BlockPos.containing(vec3);
- BlockState blockstate = this.mc.level.getBlockState(blockpos);
- BlockHitResult blockhitresult = blockstate.getShape(this.mc.level, blockpos).clip(vec35, vec3, blockpos);
+ BlockState blockstate = mc.level.getBlockState(blockpos);
+ BlockHitResult blockhitresult = blockstate.getShape(mc.level, blockpos).clip(vec35, vec3, blockpos);
this.inBlockPos[j] = blockpos;
this.inBlockHit[j] = blockhitresult;
this.active[j] = blockhitresult != null && (this.rightClickable.contains(blockstate.getBlock().getClass()) || this.rightClickable.contains(blockstate.getBlock().getClass().getSuperclass()));
@@ -259,10 +253,10 @@ public void doProcess(LocalPlayer player)
if (!this.wasactive[j] && this.active[j])
{
- this.dh.vr.triggerHapticPulse(j, 250);
+ dh.vr.triggerHapticPulse(j, 250);
}
- this.dh.vr.getInputAction(VivecraftVRMod.INSTANCE.keyVRInteract).setEnabled(ControllerType.values()[j], this.active[j]);
+ dh.vr.getInputAction(VivecraftVRMod.keyVRInteract).setEnabled(ControllerType.values()[j], this.active[j]);
this.wasactive[j] = this.active[j];
}
}
@@ -287,19 +281,19 @@ public void processBindings()
{
for (int i = 0; i < 2; ++i)
{
- if (VivecraftVRMod.INSTANCE.keyVRInteract.consumeClick(ControllerType.values()[i]) && this.active[i])
+ if (VivecraftVRMod.keyVRInteract.consumeClick(ControllerType.values()[i]) && this.active[i])
{
InteractionHand interactionhand = InteractionHand.values()[i];
boolean flag = false;
- if (this.hotbar >= 0 && this.hotbar < 9 && this.mc.player.getInventory().selected != this.hotbar && interactionhand == InteractionHand.MAIN_HAND)
+ if (this.hotbar >= 0 && this.hotbar < 9 && mc.player.getInventory().selected != this.hotbar && interactionhand == InteractionHand.MAIN_HAND)
{
- this.mc.player.getInventory().selected = this.hotbar;
+ mc.player.getInventory().selected = this.hotbar;
flag = true;
}
else if (this.hotbar == 9 && interactionhand == InteractionHand.MAIN_HAND)
{
- this.mc.player.connection.send(new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.SWAP_ITEM_WITH_OFFHAND, BlockPos.ZERO, Direction.DOWN));
+ mc.player.connection.send(new ServerboundPlayerActionPacket(ServerboundPlayerActionPacket.Action.SWAP_ITEM_WITH_OFFHAND, BlockPos.ZERO, Direction.DOWN));
flag = true;
}
else if (this.inCamera[i])
@@ -309,31 +303,31 @@ else if (this.inCamera[i])
}
else if (this.inHandheldCamera[i])
{
- this.dh.cameraTracker.startMoving(i);
+ dh.cameraTracker.startMoving(i);
flag = true;
}
else if (this.inEntityHit[i] != null)
{
flag = true;
- if (!this.mc.gameMode.interactAt(this.mc.player, this.inEntity[i], this.inEntityHit[i], interactionhand).consumesAction() && !this.mc.gameMode.interact(this.mc.player, this.inEntity[i], interactionhand).consumesAction())
+ if (!mc.gameMode.interactAt(mc.player, this.inEntity[i], this.inEntityHit[i], interactionhand).consumesAction() && !mc.gameMode.interact(mc.player, this.inEntity[i], interactionhand).consumesAction())
{
flag = false;
}
}
else if (this.inBlockHit[i] != null)
{
- flag = this.mc.gameMode.useItemOn(this.mc.player, interactionhand, this.inBlockHit[i]).consumesAction();
+ flag = mc.gameMode.useItemOn(mc.player, interactionhand, this.inBlockHit[i]).consumesAction();
}
else if (this.bukkit[i])
{
- flag = this.mc.gameMode.useItem(this.mc.player, interactionhand).consumesAction();
+ flag = mc.gameMode.useItem(mc.player, interactionhand).consumesAction();
}
if (flag)
{
- ((PlayerExtension) this.mc.player).swingArm(interactionhand, VRFirstPersonArmSwing.Interact);
- this.dh.vr.triggerHapticPulse(i, 750);
+ ((PlayerExtension) mc.player).swingArm(interactionhand, VRFirstPersonArmSwing.Interact);
+ dh.vr.triggerHapticPulse(i, 750);
}
}
}
diff --git a/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/JumpTracker.java b/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/JumpTracker.java
index 171ce453b..303788e77 100644
--- a/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/JumpTracker.java
+++ b/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/JumpTracker.java
@@ -1,20 +1,22 @@
package org.vivecraft.client_vr.gameplay.trackers;
-import net.minecraft.network.chat.contents.TranslatableContents;
import org.vivecraft.client.VivecraftVRMod;
-import org.vivecraft.client_vr.ClientDataHolderVR;
-import org.vivecraft.client_vr.extensions.PlayerExtension;
import org.vivecraft.client.network.ClientNetworking;
-import org.vivecraft.client_vr.gameplay.VRPlayer;
+import org.vivecraft.client_vr.extensions.PlayerExtension;
import org.vivecraft.client_vr.settings.AutoCalibration;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.player.LocalPlayer;
+import org.joml.Vector3d;
+
+import net.minecraft.network.chat.contents.TranslatableContents;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.phys.Vec3;
+import static org.vivecraft.client_vr.VRState.dh;
+import static org.vivecraft.client_vr.VRState.mc;
+import static org.vivecraft.common.utils.Utils.convertToVec3;
+
public class JumpTracker extends Tracker
{
public Vec3[] latchStart = new Vec3[] {new Vec3(0.0D, 0.0D, 0.0D), new Vec3(0.0D, 0.0D, 0.0D)};
@@ -23,44 +25,39 @@ public class JumpTracker extends Tracker
private boolean c0Latched = false;
private boolean c1Latched = false;
- public JumpTracker(Minecraft mc, ClientDataHolderVR dh)
- {
- super(mc, dh);
- }
-
public boolean isClimbeyJump()
{
- return !this.isActive(Minecraft.getInstance().player) ? false : this.isClimbeyJumpEquipped();
+ return !this.isActive() ? false : this.isClimbeyJumpEquipped();
}
public boolean isClimbeyJumpEquipped()
{
- return ClientNetworking.serverAllowsClimbey && ((PlayerExtension) Minecraft.getInstance().player).isClimbeyJumpEquipped();
+ return ClientNetworking.serverAllowsClimbey && ((PlayerExtension) mc.player).isClimbeyJumpEquipped();
}
- public boolean isActive(LocalPlayer p)
+ public boolean isActive()
{
- if (ClientDataHolderVR.getInstance().vrSettings.seated)
+ if (dh.vrSettings.seated)
{
return false;
}
- else if (!ClientDataHolderVR.getInstance().vrPlayer.getFreeMove() && !ClientDataHolderVR.getInstance().vrSettings.simulateFalling)
+ else if (!dh.vrPlayer.getFreeMove() && !dh.vrSettings.simulateFalling)
{
return false;
}
- else if (!ClientDataHolderVR.getInstance().vrSettings.realisticJumpEnabled)
+ else if (!dh.vrSettings.realisticJumpEnabled)
{
return false;
}
- else if (p != null && p.isAlive())
+ else if (mc.player != null && mc.player.isAlive())
{
- if (this.mc.gameMode == null)
+ if (mc.gameMode == null)
{
return false;
}
- else if (!p.isInWater() && !p.isInLava() && p.onGround())
+ else if (!mc.player.isInWater() && !mc.player.isInLava() && mc.player.onGround())
{
- return !p.isShiftKeyDown() && !p.isPassenger();
+ return !mc.player.isShiftKeyDown() && !mc.player.isPassenger();
}
else
{
@@ -78,80 +75,79 @@ public boolean isjumping()
return this.c1Latched || this.c0Latched;
}
- public void idleTick(LocalPlayer player)
+ public void idleTick()
{
- this.dh.vr.getInputAction(VivecraftVRMod.INSTANCE.keyClimbeyJump).setEnabled(this.isClimbeyJumpEquipped() && (this.isActive(player) || this.dh.climbTracker.isClimbeyClimbEquipped() && this.dh.climbTracker.isGrabbingLadder()));
+ dh.vr.getInputAction(VivecraftVRMod.keyClimbeyJump).setEnabled(this.isClimbeyJumpEquipped() && (this.isActive() || dh.climbTracker.isClimbeyClimbEquipped() && dh.climbTracker.isGrabbingLadder()));
}
- public void reset(LocalPlayer player)
+ public void reset()
{
this.c1Latched = false;
this.c0Latched = false;
}
- public void doProcess(LocalPlayer player)
+ public void doProcess()
{
if (this.isClimbeyJumpEquipped())
{
- VRPlayer vrplayer = this.dh.vrPlayer;
boolean[] aboolean = new boolean[2];
for (int i = 0; i < 2; ++i)
{
- aboolean[i] = VivecraftVRMod.INSTANCE.keyClimbeyJump.isDown();
+ aboolean[i] = VivecraftVRMod.keyClimbeyJump.isDown();
}
boolean flag = false;
if (!aboolean[0] && this.c0Latched)
{
- this.dh.vr.triggerHapticPulse(0, 200);
+ dh.vr.triggerHapticPulse(0, 200);
flag = true;
}
- Vec3 vec3 = this.dh.vrPlayer.vrdata_room_pre.getController(0).getPosition();
- Vec3 vec31 = this.dh.vrPlayer.vrdata_room_pre.getController(1).getPosition();
+ Vec3 vec3 = dh.vrPlayer.vrdata_room_pre.getController(0).getPosition();
+ Vec3 vec31 = dh.vrPlayer.vrdata_room_pre.getController(1).getPosition();
Vec3 vec32 = vec3.add(vec31).scale(0.5D);
if (aboolean[0] && !this.c0Latched)
{
this.latchStart[0] = vec32;
- this.latchStartOrigin[0] = this.dh.vrPlayer.vrdata_world_pre.origin;
- this.latchStartPlayer[0] = this.mc.player.position();
- this.dh.vr.triggerHapticPulse(0, 1000);
+ this.latchStartOrigin[0] = dh.vrPlayer.vrdata_world_pre.origin;
+ this.latchStartPlayer[0] = mc.player.position();
+ dh.vr.triggerHapticPulse(0, 1000);
}
if (!aboolean[1] && this.c1Latched)
{
- this.dh.vr.triggerHapticPulse(1, 200);
+ dh.vr.triggerHapticPulse(1, 200);
flag = true;
}
if (aboolean[1] && !this.c1Latched)
{
this.latchStart[1] = vec32;
- this.latchStartOrigin[1] = this.dh.vrPlayer.vrdata_world_pre.origin;
- this.latchStartPlayer[1] = this.mc.player.position();
- this.dh.vr.triggerHapticPulse(1, 1000);
+ this.latchStartOrigin[1] = dh.vrPlayer.vrdata_world_pre.origin;
+ this.latchStartPlayer[1] = mc.player.position();
+ dh.vr.triggerHapticPulse(1, 1000);
}
this.c0Latched = aboolean[0];
this.c1Latched = aboolean[1];
int j = 0;
Vec3 vec33 = vec32.subtract(this.latchStart[j]);
- vec33 = vec33.yRot(this.dh.vrPlayer.vrdata_world_pre.rotation_radians);
+ vec33 = vec33.yRot(dh.vrPlayer.vrdata_world_pre.rotation_radians);
if (!flag && this.isjumping())
{
- this.dh.vr.triggerHapticPulse(0, 200);
- this.dh.vr.triggerHapticPulse(1, 200);
+ dh.vr.triggerHapticPulse(0, 200);
+ dh.vr.triggerHapticPulse(1, 200);
}
if (flag)
{
- this.dh.climbTracker.forceActivate = true;
- Vec3 vec34 = this.dh.vr.controllerHistory[0].netMovement(0.3D).add(this.dh.vr.controllerHistory[1].netMovement(0.3D));
- double d0 = (this.dh.vr.controllerHistory[0].averageSpeed(0.3D) + this.dh.vr.controllerHistory[1].averageSpeed(0.3D)) / 2.0D;
+ dh.climbTracker.forceActivate = true;
+ Vec3 vec34 = convertToVec3(dh.vr.controllerHistory[0].netMovement(0.3D, new Vector3d()).add(dh.vr.controllerHistory[1].netMovement(0.3D, new Vector3d())));
+ double d0 = (dh.vr.controllerHistory[0].averageSpeed(0.3D) + dh.vr.controllerHistory[1].averageSpeed(0.3D)) / 2.0D;
vec34 = vec34.scale((double)0.33F * d0);
float f = 0.66F;
@@ -160,44 +156,44 @@ public void doProcess(LocalPlayer player)
vec34 = vec34.scale((double)f / vec34.length());
}
- if (player.hasEffect(MobEffects.JUMP))
+ if (mc.player.hasEffect(MobEffects.JUMP))
{
- vec34 = vec34.scale((double)player.getEffect(MobEffects.JUMP).getAmplifier() + 1.5D);
+ vec34 = vec34.scale((double)mc.player.getEffect(MobEffects.JUMP).getAmplifier() + 1.5D);
}
- vec34 = vec34.yRot(this.dh.vrPlayer.vrdata_world_pre.rotation_radians);
- Vec3 vec35 = this.mc.player.position().subtract(vec33);
+ vec34 = vec34.yRot(dh.vrPlayer.vrdata_world_pre.rotation_radians);
+ Vec3 vec35 = mc.player.position().subtract(vec33);
if (vec33.y < 0.0D && vec34.y < 0.0D)
{
double d2 = -vec34.x;
- double d1 = player.getDeltaMovement().x + d2 * 1.25D;
+ double d1 = mc.player.getDeltaMovement().x + d2 * 1.25D;
d2 = -vec34.y;
double d3 = -vec34.z;
- player.setDeltaMovement(d1, d2, player.getDeltaMovement().z + d3 * 1.25D);
- player.xOld = vec35.x;
- player.yOld = vec35.y;
- player.zOld = vec35.z;
- vec35 = vec35.add(player.getDeltaMovement());
- player.setPos(vec35.x, vec35.y, vec35.z);
- this.dh.vrPlayer.snapRoomOriginToPlayerEntity(player, false, true);
- this.mc.player.causeFoodExhaustion(0.3F);
- this.mc.player.setOnGround(false);
+ mc.player.setDeltaMovement(d1, d2, mc.player.getDeltaMovement().z + d3 * 1.25D);
+ mc.player.xOld = vec35.x;
+ mc.player.yOld = vec35.y;
+ mc.player.zOld = vec35.z;
+ vec35 = vec35.add(mc.player.getDeltaMovement());
+ mc.player.setPos(vec35.x, vec35.y, vec35.z);
+ dh.vrPlayer.snapRoomOriginToPlayerEntity(false, true);
+ mc.player.causeFoodExhaustion(0.3F);
+ mc.player.setOnGround(false);
}
else
{
- this.dh.vrPlayer.snapRoomOriginToPlayerEntity(player, false, true);
+ dh.vrPlayer.snapRoomOriginToPlayerEntity(false, true);
}
}
else if (this.isjumping())
{
- Vec3 vec36 = this.latchStartOrigin[0].subtract(this.latchStartPlayer[0]).add(this.mc.player.position()).subtract(vec33);
- this.dh.vrPlayer.setRoomOrigin(vec36.x, vec36.y, vec36.z, false);
+ Vec3 vec36 = this.latchStartOrigin[0].subtract(this.latchStartPlayer[0]).add(mc.player.position()).subtract(vec33);
+ dh.vrPlayer.setRoomOrigin(vec36.x, vec36.y, vec36.z, false);
}
}
- else if (this.dh.vr.hmdPivotHistory.netMovement(0.25D).y > 0.1D && this.dh.vr.hmdPivotHistory.latest().y - (double) AutoCalibration.getPlayerHeight() > (double)this.dh.vrSettings.jumpThreshold)
+ else if (dh.vr.hmdPivotHistory.netMovement(0.25D, new Vector3d()).y > 0.1D && dh.vr.hmdPivotHistory.latest(new Vector3d()).y - (double) AutoCalibration.getPlayerHeight() > (double)dh.vrSettings.jumpThreshold)
{
- player.jumpFromGround();
+ mc.player.jumpFromGround();
}
}
diff --git a/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/RowTracker.java b/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/RowTracker.java
index 6a8e31edb..b9b289c2f 100644
--- a/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/RowTracker.java
+++ b/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/RowTracker.java
@@ -1,16 +1,20 @@
package org.vivecraft.client_vr.gameplay.trackers;
-import org.vivecraft.client_vr.ClientDataHolderVR;
-import org.vivecraft.client_vr.gameplay.VRPlayer;
-import org.vivecraft.client_vr.settings.VRSettings;
-import org.vivecraft.common.utils.math.Quaternion;
+import org.joml.Quaternionf;
+import org.joml.Vector3d;
+import org.joml.Vector3f;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.player.LocalPlayer;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.vehicle.Boat;
import net.minecraft.world.phys.Vec3;
+import static org.vivecraft.client_vr.VRState.dh;
+import static org.vivecraft.client_vr.VRState.mc;
+import static org.vivecraft.common.utils.Utils.backward;
+import static org.vivecraft.common.utils.Utils.convertToVec3;
+
+import static org.joml.Math.*;
+
public class RowTracker extends Tracker
{
Vec3[] lastUWPs = new Vec3[2];
@@ -18,40 +22,35 @@ public class RowTracker extends Tracker
double transmissionEfficiency = 0.9D;
public float LOar;
public float ROar;
- public float Foar;
-
- public RowTracker(Minecraft mc, ClientDataHolderVR dh)
- {
- super(mc, dh);
- }
+ public float FOar;
- public boolean isActive(LocalPlayer p)
+ public boolean isActive()
{
- if (ClientDataHolderVR.getInstance().vrSettings.seated)
+ if (dh.vrSettings.seated)
{
return false;
}
- else if (!ClientDataHolderVR.getInstance().vrSettings.realisticRowEnabled)
+ else if (!dh.vrSettings.realisticRowEnabled)
{
return false;
}
- else if (p != null && p.isAlive())
+ else if (mc.player != null && mc.player.isAlive())
{
- if (this.mc.gameMode == null)
+ if (mc.gameMode == null)
{
return false;
}
- else if (Minecraft.getInstance().options.keyUp.isDown())
+ else if (mc.options.keyUp.isDown())
{
return false;
}
- else if (!(p.getVehicle() instanceof Boat))
+ else if (!(mc.player.getVehicle() instanceof Boat))
{
return false;
}
else
{
- return !ClientDataHolderVR.getInstance().bowTracker.isNotched();
+ return !dh.bowTracker.isNotched();
}
}
else
@@ -62,29 +61,29 @@ else if (!(p.getVehicle() instanceof Boat))
public boolean isRowing()
{
- return this.ROar + this.LOar + this.Foar > 0.0F;
+ return this.ROar + this.LOar + this.FOar > 0.0F;
}
- public void reset(LocalPlayer player)
+ public void reset()
{
this.LOar = 0.0F;
this.ROar = 0.0F;
- this.Foar = 0.0F;
+ this.FOar = 0.0F;
}
- public void doProcess(LocalPlayer player)
+ public void doProcess()
{
- double d0 = this.dh.vr.controllerHistory[0].averageSpeed(0.5D);
- double d1 = this.dh.vr.controllerHistory[1].averageSpeed(0.5D);
+ double d0 = dh.vr.controllerHistory[0].averageSpeed(0.5D);
+ double d1 = dh.vr.controllerHistory[1].averageSpeed(0.5D);
float f = 0.5F;
float f1 = 2.0F;
- this.ROar = (float)Math.max(d0 - (double)f, 0.0D);
- this.LOar = (float)Math.max(d1 - (double)f, 0.0D);
- this.Foar = this.ROar > 0.0F && this.LOar > 0.0F ? (this.ROar + this.LOar) / 2.0F : 0.0F;
+ this.ROar = (float) max(d0 - (double) f, 0.0D);
+ this.LOar = (float) max(d1 - (double) f, 0.0D);
+ this.FOar = this.ROar > 0.0F && this.LOar > 0.0F ? (this.ROar + this.LOar) / 2.0F : 0.0F;
- if (this.Foar > f1)
+ if (this.FOar > f1)
{
- this.Foar = f1;
+ this.FOar = f1;
}
if (this.ROar > f1)
@@ -98,10 +97,20 @@ public void doProcess(LocalPlayer player)
}
}
- public void doProcessFinaltransmithastofixthis(LocalPlayer player)
+ public void doProcessFinaltransmithastofixthis()
{
- Boat boat = (Boat)player.getVehicle();
- Quaternion quaternion = (new Quaternion(boat.getXRot(), -(boat.getYRot() % 360.0F), 0.0F)).normalized();
+ Boat boat = (Boat)mc.player.getVehicle();
+ Quaternionf quaternion = new Quaternionf().setAngleAxis(-(boat.getYRot() % 360.0F), 0.0F, 1.0F, 0.0F)
+ .mul(new Quaternionf().setAngleAxis(boat.getXRot(), 1.0F, 0.0F, 0.0F))
+ .mul(new Quaternionf().setAngleAxis(0.0F, 0.0F, 0.0F, 1.0F));
+ if (sqrt(quaternion.lengthSquared()) > 0.0F)
+ {
+ quaternion.normalize();
+ }
+ else
+ {
+ quaternion.identity();
+ }
for (int i = 0; i <= 1; ++i)
{
@@ -120,12 +129,12 @@ public void doProcessFinaltransmithastofixthis(LocalPlayer player)
{
Vec3 vec33 = this.lastUWPs[i].subtract(vec32);
vec33 = vec33.subtract(boat.getDeltaMovement());
- Vec3 vec34 = quaternion.multiply(new Vec3(0.0D, 0.0D, 1.0D));
+ Vec3 vec34 = convertToVec3(quaternion.transformUnit(new Vector3f(backward)));
double d0 = vec33.dot(vec34) * this.transmissionEfficiency / 5.0D;
if ((!(d0 < 0.0D) || !(this.forces[i] > 0.0D)) && (!(d0 > 0.0D) || !(this.forces[i] < 0.0D)))
{
- this.forces[i] = Math.min(Math.max(d0, -0.1D), 0.1D);
+ this.forces[i] = min(max(d0, -0.1D), 0.1D);
}
else
{
@@ -147,16 +156,30 @@ Vec3 getArmToPaddleVector(int paddle, Boat boat)
Vec3 getAttachmentPoint(int paddle, Boat boat)
{
- Vec3 vec3 = new Vec3((double)((paddle == 0 ? 9.0F : -9.0F) / 16.0F), 0.625D, 0.1875D);
- Quaternion quaternion = (new Quaternion(boat.getXRot(), -(boat.getYRot() % 360.0F), 0.0F)).normalized();
- return boat.position().add(quaternion.multiply(vec3));
+ Quaternionf quaternion = new Quaternionf().setAngleAxis(-(boat.getYRot() % 360.0F), 0.0F, 1.0F, 0.0F)
+ .mul(new Quaternionf().setAngleAxis(boat.getXRot(), 1.0F, 0.0F, 0.0F))
+ .mul(new Quaternionf().setAngleAxis(0.0F, 0.0F, 0.0F, 1.0F));
+ if (sqrt(quaternion.lengthSquared()) > 0.0F)
+ {
+ quaternion.normalize();
+ }
+ else
+ {
+ quaternion.identity();
+ }
+ return boat.position().add(convertToVec3(quaternion.transformUnit(new Vector3f(
+ (paddle == 0 ? 9.0F : -9.0F) / 16.0F, 0.625F, 0.1875F)
+ )));
}
Vec3 getAbsArmPos(int side)
{
- Vec3 vec3 = this.dh.vr.controllerHistory[side].averagePosition(0.1D);
- Quaternion quaternion = new Quaternion(0.0F, VRSettings.inst.worldRotation, 0.0F);
- return VRPlayer.get().roomOrigin.add(quaternion.multiply(vec3));
+ return dh.vrPlayer.roomOrigin.add(convertToVec3(
+ new Quaternionf().setAngleAxis(toRadians(dh.vrSettings.worldRotation), 0.0F, 1.0F, 0.0F)
+ .mul(new Quaternionf().setAngleAxis(0.0F, 1.0F, 0.0F, 0.0F))
+ .mul(new Quaternionf().setAngleAxis(0.0F, 0.0F, 0.0F, 1.0F))
+ .transformUnit(new Vector3f().set(dh.vr.controllerHistory[side].averagePosition(0.1D, new Vector3d())))
+ ));
}
boolean isPaddleUnderWater(int paddle, Boat boat)
diff --git a/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/RunTracker.java b/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/RunTracker.java
index f52d394ff..7d24594d5 100644
--- a/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/RunTracker.java
+++ b/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/RunTracker.java
@@ -1,46 +1,43 @@
package org.vivecraft.client_vr.gameplay.trackers;
-import org.vivecraft.client_vr.ClientDataHolderVR;
-import org.vivecraft.client_vr.settings.VRSettings;
+import org.vivecraft.client_vr.settings.VRSettings.FreeMove;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.player.LocalPlayer;
import net.minecraft.world.phys.Vec3;
+import static org.vivecraft.client_vr.VRState.dh;
+import static org.vivecraft.client_vr.VRState.mc;
+
+import static org.joml.Math.*;
+
public class RunTracker extends Tracker
{
private double direction = 0.0D;
private double speed = 0.0D;
private Vec3 movedir;
- public RunTracker(Minecraft mc, ClientDataHolderVR dh)
- {
- super(mc, dh);
- }
-
- public boolean isActive(LocalPlayer p)
+ public boolean isActive()
{
- if (ClientDataHolderVR.getInstance().vrPlayer.getFreeMove() && !ClientDataHolderVR.getInstance().vrSettings.seated)
+ if (dh.vrPlayer.getFreeMove() && !dh.vrSettings.seated)
{
- if (ClientDataHolderVR.getInstance().vrSettings.vrFreeMoveMode != VRSettings.FreeMove.RUN_IN_PLACE)
+ if (dh.vrSettings.vrFreeMoveMode != FreeMove.RUN_IN_PLACE)
{
return false;
}
- else if (p != null && p.isAlive())
+ else if (mc.player != null && mc.player.isAlive())
{
- if (this.mc.gameMode == null)
+ if (mc.gameMode == null)
{
return false;
}
- else if (p.onGround() || !p.isInWater() && !p.isInLava())
+ else if (mc.player.onGround() || !mc.player.isInWater() && !mc.player.isInLava())
{
- if (p.onClimbable())
+ if (mc.player.onClimbable())
{
return false;
}
else
{
- return !ClientDataHolderVR.getInstance().bowTracker.isNotched();
+ return !dh.bowTracker.isNotched();
}
}
else
@@ -69,17 +66,17 @@ public double getSpeed()
return this.speed;
}
- public void reset(LocalPlayer player)
+ public void reset()
{
this.speed = 0.0D;
}
- public void doProcess(LocalPlayer player)
+ public void doProcess()
{
- Vec3 vec3 = this.dh.vrPlayer.vrdata_world_pre.getController(0).getPosition();
- Vec3 vec31 = this.dh.vrPlayer.vrdata_world_pre.getController(1).getPosition();
- double d0 = this.dh.vr.controllerHistory[0].averageSpeed(0.33D);
- double d1 = this.dh.vr.controllerHistory[1].averageSpeed(0.33D);
+ Vec3 vec3 = dh.vrPlayer.vrdata_world_pre.getController(0).getPosition();
+ Vec3 vec31 = dh.vrPlayer.vrdata_world_pre.getController(1).getPosition();
+ double d0 = dh.vr.controllerHistory[0].averageSpeed(0.33D);
+ double d1 = dh.vr.controllerHistory[1].averageSpeed(0.33D);
if (this.speed > 0.0D)
{
@@ -95,14 +92,14 @@ else if (d0 < 0.6D && d1 < 0.6D)
return;
}
- if (Math.abs(d0 - d1) > 0.5D)
+ if (abs(d0 - d1) > 0.5D)
{
this.speed = 0.0D;
}
else
{
- Vec3 vec32 = this.dh.vrPlayer.vrdata_world_pre.getController(0).getDirection().add(this.dh.vrPlayer.vrdata_world_pre.getController(1).getDirection()).scale(0.5D);
- this.direction = (double)((float)Math.toDegrees(Math.atan2(-vec32.x, vec32.z)));
+ Vec3 vec32 = dh.vrPlayer.vrdata_world_pre.getController(0).getDirection().add(dh.vrPlayer.vrdata_world_pre.getController(1).getDirection()).scale(0.5D);
+ this.direction = atan2(-vec32.x, vec32.z);
double d2 = (d0 + d1) / 2.0D;
this.speed = d2 * 1.0D * 1.3D;
diff --git a/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/SneakTracker.java b/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/SneakTracker.java
index fbcf45c4a..b4bba0d28 100644
--- a/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/SneakTracker.java
+++ b/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/SneakTracker.java
@@ -1,42 +1,39 @@
package org.vivecraft.client_vr.gameplay.trackers;
-import org.vivecraft.client_vr.ClientDataHolderVR;
import org.vivecraft.client_vr.settings.AutoCalibration;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.player.LocalPlayer;
+import org.joml.Vector3d;
+
+import static org.vivecraft.client_vr.VRState.dh;
+import static org.vivecraft.client_vr.VRState.mc;
public class SneakTracker extends Tracker
{
public boolean sneakOverride = false;
public int sneakCounter = 0;
- public SneakTracker(Minecraft mc, ClientDataHolderVR dh)
+ @Override
+ public boolean isActive()
{
- super(mc, dh);
- }
-
- public boolean isActive(LocalPlayer p)
- {
- if (ClientDataHolderVR.getInstance().vrSettings.seated)
+ if (dh.vrSettings.seated)
{
return false;
}
- else if (!ClientDataHolderVR.getInstance().vrPlayer.getFreeMove() && !ClientDataHolderVR.getInstance().vrSettings.simulateFalling)
+ else if (!dh.vrPlayer.getFreeMove() && !dh.vrSettings.simulateFalling)
{
return false;
}
- else if (!ClientDataHolderVR.getInstance().vrSettings.realisticSneakEnabled)
+ else if (!dh.vrSettings.realisticSneakEnabled)
{
return false;
}
- else if (this.mc.gameMode == null)
+ else if (mc.gameMode == null)
{
return false;
}
- else if (p != null && p.isAlive() && p.onGround())
+ else if (mc.player != null && mc.player.isAlive() && mc.player.onGround())
{
- return !p.isPassenger();
+ return !mc.player.isPassenger();
}
else
{
@@ -44,25 +41,20 @@ else if (p != null && p.isAlive() && p.onGround())
}
}
- public void reset(LocalPlayer player)
+ @Override
+ public void reset()
{
this.sneakOverride = false;
}
- public void doProcess(LocalPlayer player)
+ @Override
+ public void doProcess()
{
- if (!this.mc.isPaused() && this.dh.sneakTracker.sneakCounter > 0)
+ if (!mc.isPaused() && dh.sneakTracker.sneakCounter > 0)
{
- --this.dh.sneakTracker.sneakCounter;
+ --dh.sneakTracker.sneakCounter;
}
- if ((double) AutoCalibration.getPlayerHeight() - this.dh.vr.hmdPivotHistory.latest().y > (double)this.dh.vrSettings.sneakThreshold)
- {
- this.sneakOverride = true;
- }
- else
- {
- this.sneakOverride = false;
- }
+ this.sneakOverride = (double)AutoCalibration.getPlayerHeight() - dh.vr.hmdPivotHistory.latest(new Vector3d()).y > (double)dh.vrSettings.sneakThreshold;
}
}
diff --git a/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/SwimTracker.java b/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/SwimTracker.java
index b0f6a4227..a528b655a 100644
--- a/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/SwimTracker.java
+++ b/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/SwimTracker.java
@@ -1,11 +1,10 @@
package org.vivecraft.client_vr.gameplay.trackers;
-import org.vivecraft.client_vr.ClientDataHolderVR;
-
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.player.LocalPlayer;
import net.minecraft.world.phys.Vec3;
+import static org.vivecraft.client_vr.VRState.dh;
+import static org.vivecraft.client_vr.VRState.mc;
+
public class SwimTracker extends Tracker
{
Vec3 motion = Vec3.ZERO;
@@ -14,42 +13,37 @@ public class SwimTracker extends Tracker
final double riseSpeed = (double)0.005F;
double swimspeed = (double)1.3F;
- public SwimTracker(Minecraft mc, ClientDataHolderVR dh)
- {
- super(mc, dh);
- }
-
- public boolean isActive(LocalPlayer p)
+ public boolean isActive()
{
- if (this.dh.vrSettings.seated)
+ if (dh.vrSettings.seated)
{
return false;
}
- else if (!this.dh.vrSettings.realisticSwimEnabled)
+ else if (!dh.vrSettings.realisticSwimEnabled)
{
return false;
}
- else if (this.mc.screen != null)
+ else if (mc.screen != null)
{
return false;
}
- else if (p != null && p.isAlive())
+ else if (mc.player != null && mc.player.isAlive())
{
- if (this.mc.gameMode == null)
+ if (mc.gameMode == null)
{
return false;
}
- else if (!p.isInWater() && !p.isInLava())
+ else if (!mc.player.isInWater() && !mc.player.isInLava())
{
return false;
}
- else if (p.zza > 0.0F)
+ else if (mc.player.zza > 0.0F)
{
return false;
}
else
{
- return !(p.xxa > 0.0F);
+ return !(mc.player.xxa > 0.0F);
}
}
else
@@ -58,14 +52,14 @@ else if (p.zza > 0.0F)
}
}
- public void doProcess(LocalPlayer player)
+ public void doProcess()
{
- Vec3 vec3 = this.dh.vrPlayer.vrdata_world_pre.getController(0).getPosition();
- Vec3 vec31 = this.dh.vrPlayer.vrdata_world_pre.getController(1).getPosition();
+ Vec3 vec3 = dh.vrPlayer.vrdata_world_pre.getController(0).getPosition();
+ Vec3 vec31 = dh.vrPlayer.vrdata_world_pre.getController(1).getPosition();
Vec3 vec32 = vec31.subtract(vec3).scale(0.5D).add(vec3);
- Vec3 vec33 = this.dh.vrPlayer.vrdata_world_pre.getHeadPivot().subtract(0.0D, 0.3D, 0.0D);
- Vec3 vec34 = vec32.subtract(vec33).normalize().add(this.dh.vrPlayer.vrdata_world_pre.hmd.getDirection()).scale(0.5D);
- Vec3 vec35 = this.dh.vrPlayer.vrdata_world_pre.getController(0).getCustomVector(new Vec3(0.0D, 0.0D, -1.0D)).add(this.dh.vrPlayer.vrdata_world_pre.getController(1).getCustomVector(new Vec3(0.0D, 0.0D, -1.0D))).scale(0.5D);
+ Vec3 vec33 = dh.vrPlayer.vrdata_world_pre.getHeadPivot().subtract(0.0D, 0.3D, 0.0D);
+ Vec3 vec34 = vec32.subtract(vec33).normalize().add(dh.vrPlayer.vrdata_world_pre.hmd.getDirection()).scale(0.5D);
+ Vec3 vec35 = dh.vrPlayer.vrdata_world_pre.getController(0).getCustomVector(new Vec3(0.0D, 0.0D, -1.0D)).add(dh.vrPlayer.vrdata_world_pre.getController(1).getCustomVector(new Vec3(0.0D, 0.0D, -1.0D))).scale(0.5D);
double d0 = vec35.add(vec34).length() / 2.0D;
double d1 = vec33.distanceTo(vec32);
double d2 = this.lastDist - d1;
@@ -77,9 +71,9 @@ public void doProcess(LocalPlayer player)
}
this.lastDist = d1;
- player.setSwimming(this.motion.length() > (double)0.3F);
- player.setSprinting(this.motion.length() > 1.0D);
- player.push(this.motion.x, this.motion.y, this.motion.z);
+ mc.player.setSwimming(this.motion.length() > (double)0.3F);
+ mc.player.setSprinting(this.motion.length() > 1.0D);
+ mc.player.push(this.motion.x, this.motion.y, this.motion.z);
this.motion = this.motion.scale(this.friction);
}
}
diff --git a/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/SwingTracker.java b/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/SwingTracker.java
index 02c87885b..3a0555c2e 100644
--- a/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/SwingTracker.java
+++ b/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/SwingTracker.java
@@ -1,19 +1,13 @@
package org.vivecraft.client_vr.gameplay.trackers;
-import java.util.List;
-
-import net.minecraft.world.item.context.UseOnContext;
-import net.minecraft.world.level.block.*;
import org.vivecraft.client.VivecraftVRMod;
-import org.vivecraft.client_vr.ClientDataHolderVR;
import org.vivecraft.client_vr.BlockTags;
import org.vivecraft.client_vr.ItemTags;
import org.vivecraft.client_vr.Vec3History;
import org.vivecraft.client_vr.provider.ControllerType;
-import org.vivecraft.client_vr.settings.VRSettings;
+import org.vivecraft.client_vr.settings.VRSettings.FreeMove;
+import org.vivecraft.client_vr.settings.VRSettings.WeaponCollision;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.player.LocalPlayer;
import net.minecraft.core.BlockPos;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
@@ -21,13 +15,24 @@
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.*;
+import net.minecraft.world.item.context.UseOnContext;
import net.minecraft.world.level.ClipContext;
+import net.minecraft.world.level.ClipContext.Block;
+import net.minecraft.world.level.ClipContext.Fluid;
+import net.minecraft.world.level.block.*;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.BlockHitResult;
-import net.minecraft.world.phys.HitResult;
+import net.minecraft.world.phys.HitResult.Type;
import net.minecraft.world.phys.Vec3;
+import java.util.List;
+
+import static org.vivecraft.client_vr.VRState.dh;
+import static org.vivecraft.client_vr.VRState.mc;
+
+import static org.joml.Math.*;
+
public class SwingTracker extends Tracker
{
private Vec3[] lastWeaponEndAir = new Vec3[] {new Vec3(0.0D, 0.0D, 0.0D), new Vec3(0.0D, 0.0D, 0.0D)};
@@ -40,70 +45,60 @@ public class SwingTracker extends Tracker
Vec3 forward = new Vec3(0.0D, 0.0D, -1.0D);
double speedthresh = 3.0D;
- public SwingTracker(Minecraft mc, ClientDataHolderVR dh)
- {
- super(mc, dh);
- }
-
- public boolean isActive(LocalPlayer p)
+ public boolean isActive()
{
if (this.disableSwing > 0)
{
--this.disableSwing;
return false;
}
- else if (this.mc.gameMode == null)
+ else if (mc.gameMode == null)
{
return false;
}
- else if (p == null)
+ else if (mc.player == null)
{
return false;
}
- else if (!p.isAlive())
+ else if (!mc.player.isAlive())
{
return false;
}
- else if (p.isSleeping())
+ else if (mc.player.isSleeping())
{
return false;
}
else
{
- Minecraft minecraft = Minecraft.getInstance();
- ClientDataHolderVR dataholder = ClientDataHolderVR.getInstance();
-
- if (minecraft.screen != null)
+ if (mc.screen != null)
{
return false;
}
- else if (dataholder.vrSettings.weaponCollision == VRSettings.WeaponCollision.OFF)
+ else if (dh.vrSettings.weaponCollision == WeaponCollision.OFF)
{
return false;
}
- else if (dataholder.vrSettings.weaponCollision == VRSettings.WeaponCollision.AUTO)
+ else if (dh.vrSettings.weaponCollision == WeaponCollision.AUTO)
{
- return !p.isCreative();
+ return !mc.player.isCreative();
}
- else if (dataholder.vrSettings.seated)
+ else if (dh.vrSettings.seated)
{
return false;
}
else
{
- VRSettings vrsettings = dataholder.vrSettings;
-
- if (dataholder.vrSettings.vrFreeMoveMode == VRSettings.FreeMove.RUN_IN_PLACE && p.zza > 0.0F)
+ if (dh.vrSettings.vrFreeMoveMode == FreeMove.RUN_IN_PLACE && mc.player.zza > 0.0F)
{
return false;
}
- else if (p.isBlocking())
+ else if (mc.player.isBlocking())
{
return false;
}
else
{
- return !dataholder.jumpTracker.isjumping();
+ return !dh.jumpTracker.isjumping();
}
}
}
@@ -114,24 +109,24 @@ public static boolean isTool(Item item)
return item instanceof DiggerItem || item instanceof ArrowItem || item instanceof FishingRodItem || item instanceof FoodOnAStickItem || item instanceof ShearsItem || item == Items.BONE || item == Items.BLAZE_ROD || item == Items.BAMBOO || item == Items.TORCH || item == Items.REDSTONE_TORCH || item == Items.STICK || item == Items.DEBUG_STICK || item instanceof FlintAndSteelItem || item instanceof BrushItem || item.getDefaultInstance().is(ItemTags.VIVECRAFT_TOOLS);
}
- public void doProcess(LocalPlayer player)
+ public void doProcess()
{
this.speedthresh = 3.0D;
- if (player.isCreative())
+ if (mc.player.isCreative())
{
this.speedthresh *= 1.5D;
}
- this.mc.getProfiler().push("updateSwingAttack");
+ mc.getProfiler().push("updateSwingAttack");
for (int i = 0; i < 2; ++i)
{
- if (!this.dh.climbTracker.isGrabbingLadder(i))
+ if (!dh.climbTracker.isGrabbingLadder(i))
{
- Vec3 vec3 = this.dh.vrPlayer.vrdata_world_pre.getController(i).getPosition();
- Vec3 vec31 = this.dh.vrPlayer.vrdata_world_pre.getHand(i).getCustomVector(this.forward);
- ItemStack itemstack = player.getItemInHand(i == 0 ? InteractionHand.MAIN_HAND : InteractionHand.OFF_HAND);
+ Vec3 vec3 = dh.vrPlayer.vrdata_world_pre.getController(i).getPosition();
+ Vec3 vec31 = dh.vrPlayer.vrdata_world_pre.getHand(i).getCustomVector(this.forward);
+ ItemStack itemstack = mc.player.getItemInHand(i == 0 ? InteractionHand.MAIN_HAND : InteractionHand.OFF_HAND);
Item item = itemstack.getItem();
boolean flag = false;
boolean flag1 = false;
@@ -175,10 +170,13 @@ else if (!itemstack.isEmpty())
f1 = 0.3F;
}
- f = f * this.dh.vrPlayer.vrdata_world_pre.worldScale;
- this.miningPoint[i] = vec3.add(vec31.scale((double)f));
- Vec3 vec32 = this.dh.vrPlayer.vrdata_room_pre.getController(i).getPosition().add(this.dh.vrPlayer.vrdata_room_pre.getHand(i).getCustomVector(this.forward).scale(0.3D));
- this.tipHistory[i].add(vec32);
+ f *= dh.vrPlayer.vrdata_world_pre.worldScale;
+ this.miningPoint[i] = vec3.add(vec31.scale(f));
+ this.tipHistory[i].add(
+ dh.vrPlayer.vrdata_room_pre.getController(i).getPosition().add(
+ dh.vrPlayer.vrdata_room_pre.getHand(i).getCustomVector(this.forward).scale(0.3D)
+ )
+ );
float f2 = (float)this.tipHistory[i].averageSpeed(0.33D);
boolean flag2 = false;
this.canact[i] = (double)f2 > this.speedthresh && !this.lastWeaponSolid[i];
@@ -186,40 +184,34 @@ else if (!itemstack.isEmpty())
if (flag3)
{
- BlockHitResult blockhitresult = this.mc.level.clip(new ClipContext(this.dh.vrPlayer.vrdata_world_pre.hmd.getPosition(), vec3, ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, this.mc.player));
+ BlockHitResult blockhitresult = mc.level.clip(new ClipContext(dh.vrPlayer.vrdata_world_pre.hmd.getPosition(), vec3, Block.OUTLINE, Fluid.NONE, mc.player));
- if (blockhitresult.getType() != HitResult.Type.MISS)
+ if (blockhitresult.getType() != Type.MISS)
{
flag3 = false;
}
}
this.attackingPoint[i] = this.constrain(vec3, this.miningPoint[i]);
- Vec3 vec33 = vec3.add(vec31.scale((double)(f + f1)));
+ Vec3 vec33 = vec3.add(vec31.scale(f + f1));
vec33 = this.constrain(vec3, vec33);
AABB aabb = new AABB(vec3, this.attackingPoint[i]);
AABB aabb1 = new AABB(vec3, vec33);
- List list = this.mc.level.getEntities(this.mc.player, aabb1);
- list.removeIf((e) ->
- {
- return e instanceof Player;
- });
- List list1 = this.mc.level.getEntities(this.mc.player, aabb);
- list1.removeIf((e) ->
- {
- return !(e instanceof Player);
- });
+ List list = mc.level.getEntities(mc.player, aabb1);
+ list.removeIf((e) -> e instanceof Player);
+ List list1 = mc.level.getEntities(mc.player, aabb);
+ list1.removeIf((e) -> !(e instanceof Player));
list.addAll(list1);
for (Entity entity : list)
{
- if (entity.isPickable() && entity != this.mc.getCameraEntity().getVehicle())
+ if (entity.isPickable() && entity != mc.getCameraEntity().getVehicle())
{
if (flag3)
{
//Minecraft.getInstance().physicalGuiManager.preClickAction();
- this.mc.gameMode.attack(player, entity);
- this.dh.vr.triggerHapticPulse(i, 1000);
+ mc.gameMode.attack(mc.player, entity);
+ dh.vr.triggerHapticPulse(i, 1000);
this.lastWeaponSolid[i] = true;
}
@@ -229,19 +221,19 @@ else if (!itemstack.isEmpty())
this.canact[i] = this.canact[i] && !flag1 && !flag2;
- if (!this.dh.climbTracker.isClimbeyClimb() || (i != 0 || !VivecraftVRMod.INSTANCE.keyClimbeyGrab.isDown(ControllerType.RIGHT)) && flag && (i != 1 || !VivecraftVRMod.INSTANCE.keyClimbeyGrab.isDown(ControllerType.LEFT)) && flag)
+ if (!dh.climbTracker.isClimbeyClimb() || (i != 0 || !VivecraftVRMod.keyClimbeyGrab.isDown(ControllerType.RIGHT)) && flag && (i != 1 || !VivecraftVRMod.keyClimbeyGrab.isDown(ControllerType.LEFT)) && flag)
{
BlockPos blockpos = BlockPos.containing(this.miningPoint[i]);
- BlockState blockstate = this.mc.level.getBlockState(blockpos);
- BlockHitResult blockhitresult1 = this.mc.level.clip(new ClipContext(this.lastWeaponEndAir[i], this.miningPoint[i], ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, this.mc.player));
+ BlockState blockstate = mc.level.getBlockState(blockpos);
+ BlockHitResult blockhitresult1 = mc.level.clip(new ClipContext(this.lastWeaponEndAir[i], this.miningPoint[i], Block.OUTLINE, Fluid.NONE, mc.player));
- if (!blockstate.isAir() && blockhitresult1.getType() == HitResult.Type.BLOCK && this.lastWeaponEndAir[i].length() != 0.0D)
+ if (!blockstate.isAir() && blockhitresult1.getType() == Type.BLOCK && this.lastWeaponEndAir[i].length() != 0.0D)
{
this.lastWeaponSolid[i] = true;
boolean flag4 = blockhitresult1.getBlockPos().equals(blockpos);
- boolean flag5 = this.dh.vrSettings.realisticClimbEnabled && (blockstate.getBlock() instanceof LadderBlock || blockstate.getBlock() instanceof VineBlock || blockstate.is(BlockTags.VIVECRAFT_CLIMBABLE));
+ boolean flag5 = dh.vrSettings.realisticClimbEnabled && (blockstate.getBlock() instanceof LadderBlock || blockstate.getBlock() instanceof VineBlock || blockstate.is(BlockTags.VIVECRAFT_CLIMBABLE));
- if (blockhitresult1.getType() == HitResult.Type.BLOCK && flag4 && this.canact[i] && !flag5)
+ if (blockhitresult1.getType() == Type.BLOCK && flag4 && this.canact[i] && !flag5)
{
int j = 3;
@@ -251,39 +243,39 @@ else if (!itemstack.isEmpty())
|| blockstate.getBlock() instanceof AttachedStemBlock
|| blockstate.is(BlockTags.VIVECRAFT_CROPS)
// check if the item can use the block
- || item.useOn(new UseOnContext(player, i == 0 ? InteractionHand.MAIN_HAND : InteractionHand.OFF_HAND, blockhitresult1)).shouldSwing()))
+ || item.useOn(new UseOnContext(mc.player, i == 0 ? InteractionHand.MAIN_HAND : InteractionHand.OFF_HAND, blockhitresult1)).shouldSwing()))
{
// don't try to break crops with hoes
// actually use the item on the block
- boolean useSuccessful = this.mc.gameMode.useItemOn(player, i == 0 ? InteractionHand.MAIN_HAND : InteractionHand.OFF_HAND, blockhitresult1).shouldSwing();
+ boolean useSuccessful = mc.gameMode.useItemOn(mc.player, i == 0 ? InteractionHand.MAIN_HAND : InteractionHand.OFF_HAND, blockhitresult1).shouldSwing();
if (itemstack.is(ItemTags.VIVECRAFT_SCYTHES) && !useSuccessful) {
// some scythes just need to be used
- this.mc.gameMode.useItem(player, i == 0 ? InteractionHand.MAIN_HAND : InteractionHand.OFF_HAND);
+ mc.gameMode.useItem(mc.player, i == 0 ? InteractionHand.MAIN_HAND : InteractionHand.OFF_HAND);
}
}
else if ((item instanceof BrushItem /*|| itemstack.is(ItemTags.VIVECRAFT_BRUSHES*/))
{
- ((BrushItem)item).spawnDustParticles(player.level(), blockhitresult1, blockstate, player.getViewVector(0.0F), i == 0 ? player.getMainArm() : player.getMainArm().getOpposite());
- player.level().playSound(player, blockhitresult1.getBlockPos(), blockstate.getBlock() instanceof BrushableBlock ? ((BrushableBlock)blockstate.getBlock()).getBrushSound() : SoundEvents.BRUSH_GENERIC, SoundSource.BLOCKS);
- this.mc.gameMode.useItemOn(player, i == 0 ? InteractionHand.MAIN_HAND : InteractionHand.OFF_HAND, blockhitresult1);
+ ((BrushItem)item).spawnDustParticles(mc.player.level(), blockhitresult1, blockstate, mc.player.getViewVector(0.0F), i == 0 ? mc.player.getMainArm() : mc.player.getMainArm().getOpposite());
+ mc.player.level().playSound(mc.player, blockhitresult1.getBlockPos(), blockstate.getBlock() instanceof BrushableBlock ? ((BrushableBlock)blockstate.getBlock()).getBrushSound() : SoundEvents.BRUSH_GENERIC, SoundSource.BLOCKS);
+ mc.gameMode.useItemOn(mc.player, i == 0 ? InteractionHand.MAIN_HAND : InteractionHand.OFF_HAND, blockhitresult1);
}
else if (blockstate.getBlock() instanceof NoteBlock || blockstate.is(BlockTags.VIVECRAFT_MUSIC_BLOCKS))
{
- this.mc.gameMode.continueDestroyBlock(blockhitresult1.getBlockPos(), blockhitresult1.getDirection());
+ mc.gameMode.continueDestroyBlock(blockhitresult1.getBlockPos(), blockhitresult1.getDirection());
}
else
{
- j = (int)((double)j + Math.min((double)f2 - this.speedthresh, 4.0D));
- //this.mc.physicalGuiManager.preClickAction();
- this.mc.gameMode.startDestroyBlock(blockhitresult1.getBlockPos(), blockhitresult1.getDirection());
+ j = (int)((double)j + min((double)f2 - this.speedthresh, 4.0D));
+ //Minecraft.getInstance().physicalGuiManager.preClickAction();
+ mc.gameMode.startDestroyBlock(blockhitresult1.getBlockPos(), blockhitresult1.getDirection());
if (this.getIsHittingBlock())
{
for (int k = 0; k < j; ++k)
{
- if (this.mc.gameMode.continueDestroyBlock(blockhitresult1.getBlockPos(), blockhitresult1.getDirection()))
+ if (mc.gameMode.continueDestroyBlock(blockhitresult1.getBlockPos(), blockhitresult1.getDirection()))
{
- this.mc.particleEngine.crack(blockhitresult1.getBlockPos(), blockhitresult1.getDirection());
+ mc.particleEngine.crack(blockhitresult1.getBlockPos(), blockhitresult1.getDirection());
}
this.clearBlockHitDelay();
@@ -294,13 +286,13 @@ else if (blockstate.getBlock() instanceof NoteBlock || blockstate.is(BlockTags.V
}
}
- Minecraft.getInstance().gameMode.destroyDelay = 0;
+ mc.gameMode.destroyDelay = 0;
}
- this.dh.vrPlayer.blockDust(blockhitresult1.getLocation().x, blockhitresult1.getLocation().y, blockhitresult1.getLocation().z, 3 * j, blockpos, blockstate, 0.6F, 1.0F);
+ dh.vrPlayer.blockDust(blockhitresult1.getLocation().x, blockhitresult1.getLocation().y, blockhitresult1.getLocation().z, 3 * j, blockpos, blockstate, 0.6F, 1.0F);
}
- this.dh.vr.triggerHapticPulse(i, 250 * j);
+ dh.vr.triggerHapticPulse(i, 250 * j);
}
}
else
@@ -312,12 +304,12 @@ else if (blockstate.getBlock() instanceof NoteBlock || blockstate.is(BlockTags.V
}
}
- this.mc.getProfiler().pop();
+ mc.getProfiler().pop();
}
private boolean getIsHittingBlock()
{
- return Minecraft.getInstance().gameMode.isDestroying();
+ return mc.gameMode.isDestroying();
}
private void clearBlockHitDelay()
@@ -328,35 +320,35 @@ private void clearBlockHitDelay()
public Vec3 constrain(Vec3 start, Vec3 end)
{
- BlockHitResult blockhitresult = this.mc.level.clip(new ClipContext(start, end, ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, this.mc.player));
- return blockhitresult.getType() == HitResult.Type.BLOCK ? blockhitresult.getLocation() : end;
+ BlockHitResult blockhitresult = mc.level.clip(new ClipContext(start, end, Block.OUTLINE, Fluid.NONE, mc.player));
+ return blockhitresult.getType() == Type.BLOCK ? blockhitresult.getLocation() : end;
}
- public static float getItemFade(LocalPlayer p, ItemStack is)
+ public static float getItemFade(ItemStack is)
{
- float f = p.getAttackStrengthScale(0.0F) * 0.75F + 0.25F;
+ float f = mc.player.getAttackStrengthScale(0.0F) * 0.75F + 0.25F;
- if (p.isShiftKeyDown())
+ if (mc.player.isShiftKeyDown())
{
f = 0.75F;
}
- boolean[] aboolean = ClientDataHolderVR.getInstance().swingTracker.lastWeaponSolid;
- Minecraft.getInstance().getItemRenderer();
+ boolean[] aboolean = dh.swingTracker.lastWeaponSolid;
+ mc.getItemRenderer();
- if (aboolean[ClientDataHolderVR.ismainhand ? 0 : 1])
+ if (aboolean[dh.ismainhand ? 0 : 1])
{
f -= 0.25F;
}
if (is != ItemStack.EMPTY)
{
- if (p.isBlocking() && p.getUseItem() != is)
+ if (mc.player.isBlocking() && mc.player.getUseItem() != is)
{
f -= 0.25F;
}
- if (is.getItem() == Items.SHIELD && !p.isBlocking())
+ if (is.getItem() == Items.SHIELD && !mc.player.isBlocking())
{
f -= 0.25F;
}
diff --git a/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/TeleportTracker.java b/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/TeleportTracker.java
index cebbd9eb7..fbc6eca0c 100644
--- a/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/TeleportTracker.java
+++ b/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/TeleportTracker.java
@@ -1,8 +1,18 @@
package org.vivecraft.client_vr.gameplay.trackers;
+import org.vivecraft.client.VivecraftVRMod;
+import org.vivecraft.client.network.ClientNetworking;
+import org.vivecraft.client_vr.BlockTags;
+import org.vivecraft.client_vr.extensions.GameRendererExtension;
+import org.vivecraft.client_vr.extensions.PlayerExtension;
+import org.vivecraft.client_vr.gameplay.VRMovementStyle;
+
+import org.joml.Matrix4f;
+import org.joml.Quaternionf;
+import org.joml.Vector3f;
+
import net.minecraft.client.Minecraft;
import net.minecraft.client.player.LocalPlayer;
-import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.ClipContext;
@@ -15,22 +25,15 @@
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.HitResult;
import net.minecraft.world.phys.Vec3;
-import org.vivecraft.client.VivecraftVRMod;
-import org.vivecraft.client_vr.ClientDataHolderVR;
-import org.vivecraft.client_vr.BlockTags;
-import org.vivecraft.client_vr.extensions.GameRendererExtension;
-import org.vivecraft.client_vr.extensions.PlayerExtension;
-import org.vivecraft.client.network.ClientNetworking;
-import org.vivecraft.client_vr.provider.openvr_lwjgl.OpenVRUtil;
-import org.vivecraft.client_vr.gameplay.VRMovementStyle;
-import org.vivecraft.client.utils.Utils;
-import org.vivecraft.common.utils.math.Angle;
-import org.vivecraft.common.utils.math.Matrix4f;
-import org.vivecraft.common.utils.math.Quaternion;
-import org.vivecraft.common.utils.math.Vector3;
import java.util.Random;
+import static org.vivecraft.client_vr.VRState.dh;
+import static org.vivecraft.client_vr.VRState.mc;
+import static org.vivecraft.common.utils.Utils.up;
+
+import static org.joml.Math.*;
+
public class TeleportTracker extends Tracker
{
private float teleportEnergy;
@@ -41,13 +44,7 @@ public class TeleportTracker extends Tracker
private Vec3[] movementTeleportArc = new Vec3[50];
public int movementTeleportArcSteps = 0;
public double lastTeleportArcDisplayOffset = 0.0D;
- public VRMovementStyle vrMovementStyle;
-
- public TeleportTracker(Minecraft mc, ClientDataHolderVR dh)
- {
- super(mc, dh);
- this.vrMovementStyle = new VRMovementStyle(dh);
- }
+ public final VRMovementStyle vrMovementStyle = new VRMovementStyle();
public float getTeleportEnergy()
{
@@ -64,34 +61,34 @@ public Vec3 getDestination()
return this.movementTeleportDestination;
}
- public boolean isActive(LocalPlayer p)
+ public boolean isActive()
{
- if (p == null)
+ if (mc.player == null)
{
return false;
}
- else if (this.mc.gameMode == null)
+ else if (mc.gameMode == null)
{
return false;
}
- else if (!p.isAlive())
+ else if (!mc.player.isAlive())
{
return false;
}
else
{
- return !p.isSleeping();
+ return !mc.player.isSleeping();
}
}
- public void reset(LocalPlayer player)
+ public void reset()
{
this.movementTeleportDestination = new Vec3(0.0D, 0.0D, 0.0D);
this.movementTeleportArcSteps = 0;
this.movementTeleportProgress = 0.0D;
}
- public void doProcess(LocalPlayer player)
+ public void doProcess()
{
Random random = new Random();
@@ -102,25 +99,25 @@ public void doProcess(LocalPlayer player)
boolean flag = false;
Vec3 vec3 = null;
- boolean flag1 = VivecraftVRMod.INSTANCE.keyTeleport.isDown() && this.dh.vrPlayer.isTeleportEnabled();
- boolean flag2 = this.dh.vrSettings.seated && !this.dh.vrPlayer.getFreeMove() && (player.input.forwardImpulse != 0.0F || player.input.leftImpulse != 0.0F);
+ boolean flag1 = VivecraftVRMod.keyTeleport.isDown() && dh.vrPlayer.isTeleportEnabled();
+ boolean flag2 = dh.vrSettings.seated && !dh.vrPlayer.getFreeMove() && (mc.player.input.forwardImpulse != 0.0F || mc.player.input.leftImpulse != 0.0F);
- if ((flag1 || flag2) && !player.isPassenger())
+ if ((flag1 || flag2) && !mc.player.isPassenger())
{
vec3 = this.movementTeleportDestination;
if (this.vrMovementStyle.teleportOnRelease)
{
- if (((PlayerExtension) player).getMovementTeleportTimer() == 0)
+ if (((PlayerExtension) mc.player).getMovementTeleportTimer() == 0)
{
String playCustomTeleportSound = this.vrMovementStyle.startTeleportingSound;
}
- ((PlayerExtension) player).setMovementTeleportTimer(((PlayerExtension) player).getMovementTeleportTimer() +1);
+ ((PlayerExtension) mc.player).setMovementTeleportTimer(((PlayerExtension) mc.player).getMovementTeleportTimer() +1);
- if (((PlayerExtension) player).getMovementTeleportTimer() > 0)
+ if (((PlayerExtension) mc.player).getMovementTeleportTimer() > 0)
{
- this.movementTeleportProgress = (double)((float)((PlayerExtension) player).getMovementTeleportTimer() / 1.0F);
+ this.movementTeleportProgress = (double)((float)((PlayerExtension) mc.player).getMovementTeleportTimer() / 1.0F);
if (this.movementTeleportProgress >= 1.0D)
{
@@ -129,9 +126,9 @@ public void doProcess(LocalPlayer player)
if (vec3.x != 0.0D || vec3.y != 0.0D || vec3.z != 0.0D)
{
- Vec3 vec38 = this.dh.vrPlayer.vrdata_world_pre.hmd.getPosition();
+ Vec3 vec38 = dh.vrPlayer.vrdata_world_pre.hmd.getPosition();
Vec3 vec31 = vec3.add(-vec38.x, -vec38.y, -vec38.z).normalize();
- Vec3 vec32 = player.getLookAngle();
+ Vec3 vec32 = mc.player.getLookAngle();
Vec3 vec33 = vec32.cross(new Vec3(0.0D, 1.0D, 0.0D));
Vec3 vec34 = vec33.cross(vec32);
@@ -151,18 +148,18 @@ public void doProcess(LocalPlayer player)
}
}
}
- else if (((PlayerExtension) player).getMovementTeleportTimer() >= 0 && (vec3.x != 0.0D || vec3.y != 0.0D || vec3.z != 0.0D))
+ else if (((PlayerExtension) mc.player).getMovementTeleportTimer() >= 0 && (vec3.x != 0.0D || vec3.y != 0.0D || vec3.z != 0.0D))
{
- if (((PlayerExtension) player).getMovementTeleportTimer() == 0)
+ if (((PlayerExtension) mc.player).getMovementTeleportTimer() == 0)
{
}
- ((PlayerExtension) player).setMovementTeleportTimer(((PlayerExtension) player).getMovementTeleportTimer() + 1);
- Vec3 vec39 = player.position();
+ ((PlayerExtension) mc.player).setMovementTeleportTimer(((PlayerExtension) mc.player).getMovementTeleportTimer() + 1);
+ Vec3 vec39 = mc.player.position();
double d6 = vec3.distanceTo(vec39);
- double d7 = (double)((PlayerExtension) player).getMovementTeleportTimer() * 1.0D / (d6 + 3.0D);
+ double d7 = (double)((PlayerExtension) mc.player).getMovementTeleportTimer() * 1.0D / (d6 + 3.0D);
- if (((PlayerExtension) player).getMovementTeleportTimer() > 0)
+ if (((PlayerExtension) mc.player).getMovementTeleportTimer() > 0)
{
this.movementTeleportProgress = d7;
@@ -170,8 +167,8 @@ else if (((PlayerExtension) player).getMovementTeleportTimer() >= 0 && (vec3.x !
{
}
- Vec3 vec310 = vec3.add(-player.getX(), -player.getY(), -player.getZ()).normalize();
- Vec3 vec311 = player.getLookAngle();
+ Vec3 vec310 = vec3.add(-mc.player.getX(), -mc.player.getY(), -mc.player.getZ()).normalize();
+ Vec3 vec311 = mc.player.getLookAngle();
Vec3 vec35 = vec311.cross(new Vec3(0.0D, 1.0D, 0.0D));
Vec3 vec312 = vec35.cross(vec311);
@@ -182,7 +179,7 @@ else if (((PlayerExtension) player).getMovementTeleportTimer() >= 0 && (vec3.x !
double d8 = random.nextDouble() * 1.0D + 3.5D;
double d9 = random.nextDouble() * 2.5D;
double d4 = random.nextDouble() * 4.0D - 2.0D;
- Vec3 vec37 = new Vec3(player.getX() + vec311.x * d8, player.getY() + vec311.y * d8, player.getZ() + vec311.z * d8);
+ Vec3 vec37 = new Vec3(mc.player.getX() + vec311.x * d8, mc.player.getY() + vec311.y * d8, mc.player.getZ() + vec311.z * d8);
vec37 = vec37.add(vec35.x * d4, vec35.y * d4, vec35.z * d4);
vec37.add(vec312.x * d9, vec312.y * d9, vec312.z * d9);
double d5 = -0.6D;
@@ -208,13 +205,13 @@ else if (((PlayerExtension) player).getMovementTeleportTimer() >= 0 && (vec3.x !
flag = true;
}
- ((PlayerExtension) player).setMovementTeleportTimer(0);
+ ((PlayerExtension) mc.player).setMovementTeleportTimer(0);
this.movementTeleportProgress = 0.0D;
}
if (flag && vec3 != null && (vec3.x != 0.0D || vec3.y != 0.0D || vec3.z != 0.0D))
{
- this.movementTeleportDistance = vec3.distanceTo(player.position());
+ this.movementTeleportDistance = vec3.distanceTo(mc.player.position());
if (this.movementTeleportDistance > 0.0D && this.vrMovementStyle.endTeleportingSound != null)
{
@@ -227,27 +224,27 @@ else if (((PlayerExtension) player).getMovementTeleportTimer() >= 0 && (vec3.x !
Block block = null;
- if (!this.dh.vrPlayer.isTeleportSupported())
+ if (!dh.vrPlayer.isTeleportSupported())
{
String s1 = "tp " + vec3.x + " " + vec3.y + " " + vec3.z;
- this.mc.player.connection.sendCommand(s1);
+ mc.player.connection.sendCommand(s1);
}
else
{
if (ClientNetworking.serverSupportsDirectTeleport)
{
- ((PlayerExtension) player).setTeleported(true);
+ ((PlayerExtension) mc.player).setTeleported(true);
}
- player.moveTo(vec3.x, vec3.y, vec3.z);
+ mc.player.moveTo(vec3.x, vec3.y, vec3.z);
}
this.doTeleportCallback();
- ((PlayerExtension) this.mc.player).stepSound(BlockPos.containing(vec3), vec3);
+ ((PlayerExtension) mc.player).stepSound(BlockPos.containing(vec3), vec3.x(), vec3.y(), vec3.z());
}
}
- public void updateTeleportDestinations(GameRenderer renderer, Minecraft mc, LocalPlayer player)
+ public void updateTeleportDestinations()
{
mc.getProfiler().push("updateTeleportDestinations");
@@ -257,14 +254,14 @@ public void updateTeleportDestinations(GameRenderer renderer, Minecraft mc, Loca
if (this.movementTeleportProgress > 0.0D)
{
- this.updateTeleportArc(mc, player);
+ this.updateTeleportArc();
}
}
mc.getProfiler().pop();
}
- private void updateTeleportArc(Minecraft mc, LocalPlayer player)
+ private void updateTeleportArc()
{
Vec3 vec3 = dh.vrPlayer.vrdata_world_render.getController(1).getPosition();
Vec3 vec31 = dh.vrPlayer.vrdata_world_render.getController(1).getDirection();
@@ -277,20 +274,15 @@ private void updateTeleportArc(Minecraft mc, LocalPlayer player)
matrix4f = dh.vr.getAimRotation(0);
}
- Matrix4f matrix4f1 = Matrix4f.rotationY(dh.vrPlayer.vrdata_world_render.rotation_radians);
- matrix4f = Matrix4f.multiply(matrix4f1, matrix4f);
- Quaternion quaternion = OpenVRUtil.convertMatrix4ftoRotationQuat(matrix4f);
- Angle angle = quaternion.toEuler();
+ matrix4f = matrix4f.rotateY(dh.vrPlayer.vrdata_world_render.rotation_radians, new Matrix4f());
+ Quaternionf quaternion = new Quaternionf().setFromUnnormalized(matrix4f);
int i = 50;
this.movementTeleportArc[0] = new Vec3(vec3.x, vec3.y, vec3.z);
this.movementTeleportArcSteps = 1;
float f = 0.098F;
- Matrix4f matrix4f2 = Utils.rotationZMatrix((float)Math.toRadians((double)(-angle.getRoll())));
- Matrix4f matrix4f3 = Utils.rotationXMatrix(-2.5132742F);
- Matrix4f matrix4f4 = Matrix4f.multiply(matrix4f, matrix4f2);
- Vector3 vector3 = new Vector3(0.0F, 1.0F, 0.0F);
- Vector3 vector31 = matrix4f4.transform(vector3);
- Vec3 vec32 = vector31.negate().toVector3d();
+ Matrix4f matrix4f4 = matrix4f.rotateZ(-atan2((2.0F * (quaternion.x * quaternion.y + quaternion.w * quaternion.z)), (quaternion.w * quaternion.w - quaternion.x * quaternion.x + quaternion.y * quaternion.y - quaternion.z * quaternion.z)));
+ Vector3f vector31 = new Vector3f(up).mulProject(matrix4f4);
+ Vec3 vec32 = new Vec3(-vector31.x, -vector31.y, -vector31.z);
vec32 = vec32.scale((double)f);
float f1 = 0.5F;
Vec3 vec33 = new Vec3(vec31.x * (double)f1, vec31.y * (double)f1, vec31.z * (double)f1);
@@ -318,11 +310,11 @@ private void updateTeleportArc(Minecraft mc, LocalPlayer player)
this.movementTeleportArcSteps = j + 1;
Vec3 vec36 = vec34.subtract(vec35).normalize();
Vec3 vec37 = new Vec3(-vec36.x * 0.02D, -vec36.y * 0.02D, -vec36.z * 0.02D);
- this.checkAndSetTeleportDestination(mc, player, vec3, blockhitresult, vec37);
+ this.checkAndSetTeleportDestination(mc, mc.player, vec3, blockhitresult, vec37);
Vec3 vec38 = mc.player.position().subtract(this.movementTeleportDestination);
double d0 = vec38.y;
this.movementTeleportDistance = vec38.length();
- double d1 = Math.sqrt(vec38.x * vec38.x + vec38.z * vec38.z);
+ double d1 = sqrt(vec38.x * vec38.x + vec38.z * vec38.z);
boolean flag1 = true;
if (mc.player.isShiftKeyDown() && d0 > 0.2D)
@@ -336,11 +328,11 @@ private void updateTeleportArc(Minecraft mc, LocalPlayer player)
{
flag1 = false;
}
- else if (ClientNetworking.getTeleportUpLimit() > 0 && -d0 > (double) ClientNetworking.getTeleportUpLimit() * (double)((PlayerExtension) player).getMuhJumpFactor() + 0.2D)
+ else if (ClientNetworking.getTeleportUpLimit() > 0 && -d0 > (double) ClientNetworking.getTeleportUpLimit() * (double)((PlayerExtension) mc.player).getMuhJumpFactor() + 0.2D)
{
flag1 = false;
}
- else if (ClientNetworking.getTeleportHorizLimit() > 0 && d1 > (double) ClientNetworking.getTeleportHorizLimit() * (double)((PlayerExtension) player).getMuhSpeedFactor() + 0.2D)
+ else if (ClientNetworking.getTeleportHorizLimit() > 0 && d1 > (double) ClientNetworking.getTeleportHorizLimit() * (double)((PlayerExtension) mc.player).getMuhSpeedFactor() + 0.2D)
{
flag1 = false;
}
@@ -364,22 +356,20 @@ else if (ClientNetworking.getTeleportHorizLimit() > 0 && d1 > (double) ClientNet
private void doTeleportCallback()
{
- Minecraft minecraft = Minecraft.getInstance();
- ClientDataHolderVR dataholder = ClientDataHolderVR.getInstance();
- dataholder.swingTracker.disableSwing = 3;
+ dh.swingTracker.disableSwing = 3;
if (ClientNetworking.isLimitedSurvivalTeleport())
{
- minecraft.player.causeFoodExhaustion((float)(this.movementTeleportDistance / 16.0D * (double)1.2F));
+ mc.player.causeFoodExhaustion((float)(this.movementTeleportDistance / 16.0D * (double)1.2F));
- if (minecraft.gameMode.hasMissTime() && this.vrMovementStyle.arcAiming)
+ if (mc.gameMode.hasMissTime() && this.vrMovementStyle.arcAiming)
{
this.teleportEnergy = (float)((double)this.teleportEnergy - this.movementTeleportDistance * 4.0D);
}
}
- minecraft.player.fallDistance = 0.0F;
- ((PlayerExtension) minecraft.player).setMovementTeleportTimer(-1);
+ mc.player.fallDistance = 0.0F;
+ ((PlayerExtension) mc.player).setMovementTeleportTimer(-1);
}
private boolean checkAndSetTeleportDestination(Minecraft mc, LocalPlayer player, Vec3 start, BlockHitResult collision, Vec3 reverseEpsilon)
@@ -498,7 +488,7 @@ public Vec3 getInterpolatedArcPosition(float progress)
else
{
float f = progress * (float)(this.movementTeleportArcSteps - 1);
- int i = (int)Math.floor((double)f);
+ int i = (int)floor(f);
double d0 = this.movementTeleportArc[i + 1].x - this.movementTeleportArc[i].x;
double d1 = this.movementTeleportArc[i + 1].y - this.movementTeleportArc[i].y;
double d2 = this.movementTeleportArc[i + 1].z - this.movementTeleportArc[i].z;
diff --git a/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/TelescopeTracker.java b/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/TelescopeTracker.java
index 2b58719ad..e1368389b 100644
--- a/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/TelescopeTracker.java
+++ b/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/TelescopeTracker.java
@@ -1,18 +1,20 @@
package org.vivecraft.client_vr.gameplay.trackers;
-import net.minecraft.network.chat.contents.TranslatableContents;
-import org.vivecraft.client_vr.ClientDataHolderVR;
import org.vivecraft.client_vr.ItemTags;
import org.vivecraft.client_vr.VRData;
import org.vivecraft.client_vr.render.RenderPass;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.player.LocalPlayer;
import net.minecraft.client.resources.model.ModelResourceLocation;
+import net.minecraft.network.chat.contents.TranslatableContents;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.phys.Vec3;
+import static org.vivecraft.client_vr.VRState.dh;
+import static org.vivecraft.client_vr.VRState.mc;
+
+import static org.joml.Math.*;
+
public class TelescopeTracker extends Tracker
{
//public static final ResourceLocation scopeResource = new ResourceLocation("vivecraft:trashbin");
@@ -22,20 +24,6 @@ public class TelescopeTracker extends Tracker
private static final double lensDotMax = 0.9D;
private static final double lensDotMin = 0.75D;
- public TelescopeTracker(Minecraft mc, ClientDataHolderVR dh)
- {
- super(mc, dh);
- }
-
- public boolean isActive(LocalPlayer player)
- {
- return false;
- }
-
- public void doProcess(LocalPlayer player)
- {
- }
-
public static boolean isTelescope(ItemStack i)
{
return i != null && (i.getItem() == Items.SPYGLASS || isLegacyTelescope(i) || i.is(ItemTags.VIVECRAFT_TELESCOPE));
@@ -67,13 +55,13 @@ else if (!i.hasTag() || !i.getTag().getBoolean("Unbreakable"))
private static Vec3 getLensOrigin(int controller)
{
- VRData.VRDevicePose vrdata$vrdevicepose = ClientDataHolderVR.getInstance().vrPlayer.vrdata_room_pre.getController(controller);
+ VRData.VRDevicePose vrdata$vrdevicepose = dh.vrPlayer.vrdata_room_pre.getController(controller);
return vrdata$vrdevicepose.getPosition().add(getViewVector(controller).scale(-0.2D).add(vrdata$vrdevicepose.getDirection().scale((double)0.05F)));
}
private static Vec3 getViewVector(int controller)
{
- return ClientDataHolderVR.getInstance().vrPlayer.vrdata_room_pre.getController(controller).getCustomVector(new Vec3(0.0D, -1.0D, 0.0D));
+ return dh.vrPlayer.vrdata_room_pre.getController(controller).getCustomVector(new Vec3(0.0D, -1.0D, 0.0D));
}
public static boolean isViewing(int controller)
@@ -83,9 +71,8 @@ public static boolean isViewing(int controller)
public static float viewPercent(int controller)
{
- LocalPlayer p = Minecraft.getInstance().player;
- if(p!= null && ClientDataHolderVR.getInstance().vrSettings.seated) {
- if(isTelescope(p.getUseItem()))
+ if(mc.player!= null && dh.vrSettings.seated) {
+ if(isTelescope(mc.player.getUseItem()))
return 1;
else
return 0;
@@ -114,10 +101,10 @@ private static float viewPercent(int controller, int e)
}
else
{
- VRData.VRDevicePose eye = ClientDataHolderVR.getInstance().vrPlayer.vrdata_room_pre.getEye(RenderPass.values()[e]);
+ VRData.VRDevicePose eye = dh.vrPlayer.vrdata_room_pre.getEye(RenderPass.values()[e]);
double dist = eye.getPosition().subtract(getLensOrigin(controller)).length();
Vec3 look = eye.getDirection();
- double dot = Math.abs(look.dot(getViewVector(controller)));
+ double dot = abs(look.dot(getViewVector(controller)));
double dfact = 0.0D;
double distfact = 0.0D;
@@ -146,7 +133,7 @@ private static float viewPercent(int controller, int e)
}
}
- return (float)Math.min(dfact, distfact);
+ return (float)min(dfact, distfact);
}
}
}
diff --git a/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/Tracker.java b/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/Tracker.java
index e67aed315..7418a984c 100644
--- a/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/Tracker.java
+++ b/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/Tracker.java
@@ -1,30 +1,21 @@
package org.vivecraft.client_vr.gameplay.trackers;
-import org.vivecraft.client_vr.ClientDataHolderVR;
-
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.player.LocalPlayer;
-
public abstract class Tracker
{
- public Minecraft mc;
- public ClientDataHolderVR dh;
-
- public Tracker(Minecraft mc, ClientDataHolderVR dh)
+ public boolean isActive()
{
- this.mc = mc;
- this.dh = dh;
+ return false;
}
- public abstract boolean isActive(LocalPlayer var1);
-
- public abstract void doProcess(LocalPlayer var1);
+ public void doProcess()
+ {
+ }
- public void reset(LocalPlayer player)
+ public void reset()
{
}
- public void idleTick(LocalPlayer player)
+ public void idleTick()
{
}
@@ -33,9 +24,9 @@ public EntryPoint getEntryPoint()
return EntryPoint.LIVING_UPDATE;
}
- public static enum EntryPoint
+ public enum EntryPoint
{
LIVING_UPDATE,
- SPECIAL_ITEMS;
+ SPECIAL_ITEMS
}
}
diff --git a/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/VehicleTracker.java b/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/VehicleTracker.java
index e814cf318..ff0bf1b68 100644
--- a/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/VehicleTracker.java
+++ b/common/src/main/java/org/vivecraft/client_vr/gameplay/trackers/VehicleTracker.java
@@ -1,11 +1,9 @@
package org.vivecraft.client_vr.gameplay.trackers;
-import org.vivecraft.client_vr.ClientDataHolderVR;
import org.vivecraft.client_vr.ItemTags;
-import org.vivecraft.client_vr.VRData;
-import org.vivecraft.client_vr.settings.VRSettings;
+import org.vivecraft.client_vr.VRData.VRDevicePose;
+import org.vivecraft.client_vr.settings.VRSettings.FreeMove;
-import net.minecraft.client.Minecraft;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.Mob;
@@ -15,9 +13,13 @@
import net.minecraft.world.item.FoodOnAStickItem;
import net.minecraft.world.phys.Vec3;
+import static org.vivecraft.client_vr.VRState.dh;
+import static org.vivecraft.client_vr.VRState.mc;
+
+import static org.joml.Math.*;
+
public class VehicleTracker extends Tracker
{
- private float PreMount_World_Rotation;
public Vec3 Premount_Pos_Room = new Vec3(0.0D, 0.0D, 0.0D);
public float vehicleInitialRotation = 0.0F;
public int rotationCooldown = 0;
@@ -25,33 +27,27 @@ public class VehicleTracker extends Tracker
private int minecartStupidityCounter;
public int dismountCooldown = 0;
- public VehicleTracker(Minecraft mc, ClientDataHolderVR dh)
- {
- super(mc, dh);
- }
-
- public boolean isActive(LocalPlayer p)
+ public boolean isActive()
{
- Minecraft minecraft = Minecraft.getInstance();
- if (p == null)
+ if (mc.player == null)
{
return false;
}
- else if (minecraft.gameMode == null)
+ else if (mc.gameMode == null)
{
return false;
}
else
{
- return p.isAlive();
+ return mc.player.isAlive();
}
}
- public void reset(LocalPlayer player)
+ public void reset()
{
this.minecartStupidityCounter = 2;
- super.reset(player);
+ super.reset();
}
public double getVehicleFloor(Entity vehicle, double original)
@@ -63,8 +59,6 @@ public static Vec3 getSteeringDirection(LocalPlayer player)
{
Vec3 vec3 = null;
Entity entity = player.getVehicle();
- Minecraft minecraft = Minecraft.getInstance();
- ClientDataHolderVR dataholder = ClientDataHolderVR.getInstance();
if (!(entity instanceof AbstractHorse) && !(entity instanceof Boat))
{
@@ -75,29 +69,27 @@ public static Vec3 getSteeringDirection(LocalPlayer player)
if (mob.isControlledByLocalInstance())
{
int i = (player.getMainHandItem().getItem() instanceof FoodOnAStickItem || player.getMainHandItem().is(ItemTags.VIVECRAFT_FOOD_STICKS)) ? 0 : 1;
- VRData.VRDevicePose vrdata$vrdevicepose = dataholder.vrPlayer.vrdata_world_pre.getController(i);
+ VRDevicePose vrdata$vrdevicepose = dh.vrPlayer.vrdata_world_pre.getController(i);
return vrdata$vrdevicepose.getPosition().add(vrdata$vrdevicepose.getDirection().scale(0.3D)).subtract(entity.position()).normalize();
}
}
}
else if (player.zza > 0.0F)
{
- VRSettings vrsettings = dataholder.vrSettings;
-
- if (dataholder.vrSettings.vrFreeMoveMode == VRSettings.FreeMove.HMD)
+ if (dh.vrSettings.vrFreeMoveMode == FreeMove.HMD)
{
- return dataholder.vrPlayer.vrdata_world_pre.hmd.getDirection();
+ return dh.vrPlayer.vrdata_world_pre.hmd.getDirection();
}
- return dataholder.vrPlayer.vrdata_world_pre.getController(0).getDirection();
+ return dh.vrPlayer.vrdata_world_pre.getController(0).getDirection();
}
return vec3;
}
- public void doProcess(LocalPlayer player)
+ public void doProcess()
{
- if (!this.mc.isPaused())
+ if (!mc.isPaused())
{
if (this.dismountCooldown > 0)
{
@@ -109,12 +101,12 @@ public void doProcess(LocalPlayer player)
--this.rotationCooldown;
}
- if (this.dh.vrSettings.vehicleRotation && this.mc.player.isPassenger() && this.rotationCooldown == 0)
+ if (dh.vrSettings.vehicleRotation && mc.player.isPassenger() && this.rotationCooldown == 0)
{
- Entity entity = this.mc.player.getVehicle();
+ Entity entity = mc.player.getVehicle();
this.rotationTarget = (double)entity.getYRot();
- if (entity instanceof AbstractHorse && !this.dh.horseTracker.isActive(this.mc.player))
+ if (entity instanceof AbstractHorse && !dh.horseTracker.isActive())
{
AbstractHorse abstracthorse = (AbstractHorse)entity;
@@ -170,7 +162,9 @@ else if (entity instanceof Mob)
}
}
- float f1 = this.dh.vrPlayer.rotDiff_Degrees((float)this.rotationTarget, this.vehicleInitialRotation);
+ float f0 = toRadians(this.vehicleInitialRotation);
+ float f11 = toRadians((float) this.rotationTarget);
+ float f1 = (float) toDegrees(atan2(sin(f0 - f11), cos(f0 - f11)));
if (flag)
{
@@ -185,9 +179,9 @@ else if (entity instanceof Mob)
}
}
- this.dh.vrSettings.worldRotation += f1;
- this.dh.vrSettings.worldRotation %= 360.0F;
- this.dh.vr.seatedRot = this.dh.vrSettings.worldRotation;
+ dh.vrSettings.worldRotation += f1;
+ dh.vrSettings.worldRotation %= 360.0F;
+ dh.vr.seatedRot = dh.vrSettings.worldRotation;
this.vehicleInitialRotation -= f1;
this.vehicleInitialRotation %= 360.0F;
}
@@ -195,9 +189,9 @@ else if (entity instanceof Mob)
{
this.minecartStupidityCounter = 3;
- if (this.mc.player.isPassenger())
+ if (mc.player.isPassenger())
{
- this.vehicleInitialRotation = this.mc.player.getVehicle().getYRot();
+ this.vehicleInitialRotation = mc.player.getVehicle().getYRot();
}
}
}
@@ -205,18 +199,15 @@ else if (entity instanceof Mob)
public void onStartRiding(Entity vehicle, LocalPlayer player)
{
- Minecraft minecraft = Minecraft.getInstance();
- ClientDataHolderVR dataholder = ClientDataHolderVR.getInstance();
- this.PreMount_World_Rotation = dataholder.vrPlayer.vrdata_world_pre.rotation_radians;
- Vec3 vec3 = dataholder.vrPlayer.vrdata_room_pre.getHeadPivot();
+ Vec3 vec3 = dh.vrPlayer.vrdata_room_pre.getHeadPivot();
this.Premount_Pos_Room = new Vec3(vec3.x, 0.0D, vec3.z);
this.dismountCooldown = 5;
- if (dataholder.vrSettings.vehicleRotation)
+ if (dh.vrSettings.vehicleRotation)
{
- float f = dataholder.vrPlayer.vrdata_world_pre.hmd.getYaw();
+ float f = dh.vrPlayer.vrdata_world_pre.hmd.getYaw();
float f1 = vehicle.getYRot() % 360.0F;
- this.vehicleInitialRotation = dataholder.vrSettings.worldRotation;
+ this.vehicleInitialRotation = dh.vrSettings.worldRotation;
this.rotationCooldown = 2;
if (vehicle instanceof Minecart)
@@ -224,27 +215,34 @@ public void onStartRiding(Entity vehicle, LocalPlayer player)
return;
}
- float f2 = dataholder.vrPlayer.rotDiff_Degrees(f1, f);
- dataholder.vrSettings.worldRotation = (float)(Math.toDegrees((double)dataholder.vrPlayer.vrdata_world_pre.rotation_radians) + (double)f2);
- dataholder.vrSettings.worldRotation %= 360.0F;
- dataholder.vr.seatedRot = dataholder.vrSettings.worldRotation;
+ float f0 = toRadians(f);
+ float f11 = toRadians(f1);
+ float f2 = (float) toDegrees(atan2(sin(f0 - f11), cos(f0 - f11)));
+ dh.vrSettings.worldRotation = (float)(toDegrees(dh.vrPlayer.vrdata_world_pre.rotation_radians) + f2);
+ dh.vrSettings.worldRotation %= 360.0F;
+ dh.vr.seatedRot = dh.vrSettings.worldRotation;
}
}
+ // TODO: remove onStopRiding?
public void onStopRiding(LocalPlayer player)
{
- this.dh.swingTracker.disableSwing = 10;
- this.dh.sneakTracker.sneakCounter = 0;
+ dh.swingTracker.disableSwing = 10;
+ dh.sneakTracker.sneakCounter = 0;
- if (this.dh.vrSettings.vehicleRotation)
+ if (dh.vrSettings.vehicleRotation)
{
+ //I dont wanna do this anymore.
+ //I think its more confusing to get off the thing and not know where you're looking
+ // mc.vrSettings.vrWorldRotation = playerRotation_PreMount;
+ // mc.vr.seatedRot = playerRotation_PreMount;
}
}
private float getMinecartRenderYaw(Minecart entity)
{
Vec3 vec3 = new Vec3(entity.getX() - entity.xOld, entity.getY() - entity.yOld, entity.getZ() - entity.zOld);
- float f = (float)Math.toDegrees(Math.atan2(-vec3.x, vec3.z));
+ float f = (float)toDegrees(atan2(-vec3.x, vec3.z));
return this.shouldMinecartTurnView(entity) ? -180.0F + f : this.vehicleInitialRotation;
}
@@ -260,8 +258,8 @@ private boolean shouldMinecartTurnView(Minecart entity)
return vec3.length() > 0.001D;
}
- public boolean canRoomscaleDismount(LocalPlayer player)
+ public boolean canRoomscaleDismount()
{
- return player.zza == 0.0F && player.xxa == 0.0F && player.isPassenger() && player.getVehicle().onGround() && this.dismountCooldown == 0;
+ return mc.player.zza == 0.0F && mc.player.xxa == 0.0F && mc.player.isPassenger() && mc.player.getVehicle().onGround() && this.dismountCooldown == 0;
}
}
diff --git a/common/src/main/java/org/vivecraft/client_vr/gui/GuiKeyboard.java b/common/src/main/java/org/vivecraft/client_vr/gui/GuiKeyboard.java
index bc4146d3a..9f15d8a15 100644
--- a/common/src/main/java/org/vivecraft/client_vr/gui/GuiKeyboard.java
+++ b/common/src/main/java/org/vivecraft/client_vr/gui/GuiKeyboard.java
@@ -1,12 +1,17 @@
package org.vivecraft.client_vr.gui;
-import net.minecraft.client.gui.GuiGraphics;
-import net.minecraft.network.chat.Component;
-import org.lwjgl.glfw.GLFW;
import org.vivecraft.client.gui.framework.TwoHandedScreen;
import org.vivecraft.client_vr.provider.InputSimulator;
+import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.Button;
+import net.minecraft.client.gui.components.Button.Builder;
+import net.minecraft.network.chat.Component;
+
+import static org.vivecraft.client_vr.VRState.dh;
+
+import static org.joml.Math.*;
+import static org.lwjgl.glfw.GLFW.*;
public class GuiKeyboard extends TwoHandedScreen
{
@@ -14,162 +19,153 @@ public class GuiKeyboard extends TwoHandedScreen
public void init()
{
- String s = this.dataholder.vrSettings.keyboardKeys;
- String s1 = this.dataholder.vrSettings.keyboardKeysShift;
+ String arr = dh.vrSettings.keyboardKeys;
+ String alt = dh.vrSettings.keyboardKeysShift;
this.clearWidgets();
if (this.isShift)
{
- s = s1;
+ arr = alt;
}
- int i = 13;
- int j = 4;
- int k = 32;
- int l = 2;
- int i1 = 25;
- double d0 = (double)s.length() / (double)i;
+ int cols = 13;
+ int rows = 4;
+ int margin = 32;
+ int spacing = 2;
+ int bwidth = 25;
+ double tmp = (double)arr.length() / cols;
- if (Math.floor(d0) == d0)
+ if (floor(tmp) == tmp)
{
- j = (int)d0;
+ rows = (int)tmp;
}
else
{
- j = (int)(d0 + 1.0D);
+ rows = (int)(tmp + 1.0D);
}
- for (int j1 = 0; j1 < j; ++j1)
+ for (int r = 0; r < rows; ++r)
{
- for (int k1 = 0; k1 < i; ++k1)
+ for (int i = 0; i < cols; ++i)
{
- int l1 = j1 * i + k1;
- char c0 = ' ';
+ int c = (r * cols) + i;
+ char x = ' ';
- if (l1 < s.length())
+ if (c < arr.length())
{
- c0 = s.charAt(l1);
+ x = arr.charAt(c);
}
- String s2 = String.valueOf(c0);
- Button button = new Button.Builder( Component.literal(s2), (p) ->
- {
- InputSimulator.typeChars(s2);
- })
- .size( i1, 20)
- .pos(k + k1 * (i1 + l), k + j1 * (20 + l))
+ final String c1 = String.valueOf(x);
+ Button button = new Builder(Component.literal(c1), (p) -> InputSimulator.typeChars(c1))
+ .size(bwidth, 20)
+ .pos(margin + i * (bwidth + spacing), margin + r * (20 + spacing))
.build();
this.addRenderableWidget(button);
}
}
- this.addRenderableWidget(new Button.Builder( Component.literal("Shift"), (p) ->
- {
- this.setShift(!this.isShift);
- })
- .size( 30, 20)
- .pos(0, k + 3 * (20 + l))
+ this.addRenderableWidget(new Builder(Component.literal("Shift"), (p) -> this.setShift(!this.isShift))
+ .size(30, 20)
+ .pos(0, margin + 3 * (20 + spacing))
.build());
- this.addRenderableWidget(new Button.Builder( Component.literal(" "), (p) ->
- {
- InputSimulator.typeChars(" ");
- })
- .size( 5 * (i1 + l), 20)
- .pos(k + 4 * (i1 + l), k + j * (20 + l))
+ this.addRenderableWidget(new Builder(Component.literal(" "), (p) -> InputSimulator.typeChars(" "))
+ .size(5 * (bwidth + spacing), 20)
+ .pos(margin + 4 * (bwidth + spacing), margin + rows * (20 + spacing))
.build());
- this.addRenderableWidget(new Button.Builder( Component.literal("BKSP"), (p) ->
+ this.addRenderableWidget(new Builder(Component.literal("BKSP"), (p) ->
{
- InputSimulator.pressKey(GLFW.GLFW_KEY_BACKSPACE);
- InputSimulator.releaseKey(GLFW.GLFW_KEY_BACKSPACE);
+ InputSimulator.pressKey(GLFW_KEY_BACKSPACE);
+ InputSimulator.releaseKey(GLFW_KEY_BACKSPACE);
})
- .size( 35, 20)
- .pos(i * (i1 + l) + k, k)
+ .size(35, 20)
+ .pos(cols * (bwidth + spacing) + margin, margin)
.build());
- this.addRenderableWidget(new Button.Builder( Component.literal("ENTER"), (p) ->
+ this.addRenderableWidget(new Builder(Component.literal("ENTER"), (p) ->
{
- InputSimulator.pressKey(GLFW.GLFW_KEY_ENTER);
- InputSimulator.releaseKey(GLFW.GLFW_KEY_ENTER);
+ InputSimulator.pressKey(GLFW_KEY_ENTER);
+ InputSimulator.releaseKey(GLFW_KEY_ENTER);
})
- .size( 35, 20)
- .pos(i * (i1 + l) + k, k + 2 * (20 + l))
+ .size(35, 20)
+ .pos(cols * (bwidth + spacing) + margin, margin + 2 * (20 + spacing))
.build());
- this.addRenderableWidget(new Button.Builder( Component.literal("TAB"), (p) ->
+ this.addRenderableWidget(new Builder(Component.literal("TAB"), (p) ->
{
- InputSimulator.pressKey(GLFW.GLFW_KEY_TAB);
- InputSimulator.releaseKey(GLFW.GLFW_KEY_TAB);
+ InputSimulator.pressKey(GLFW_KEY_TAB);
+ InputSimulator.releaseKey(GLFW_KEY_TAB);
})
- .size( 30, 20)
- .pos(0, k + 20 + l)
+ .size(30, 20)
+ .pos(0, margin + 20 + spacing)
.build());
- this.addRenderableWidget(new Button.Builder( Component.literal("ESC"), (p) ->
+ this.addRenderableWidget(new Builder(Component.literal("ESC"), (p) ->
{
- InputSimulator.pressKey(GLFW.GLFW_KEY_ESCAPE);
- InputSimulator.releaseKey(GLFW.GLFW_KEY_ESCAPE);
+ InputSimulator.pressKey(GLFW_KEY_ESCAPE);
+ InputSimulator.releaseKey(GLFW_KEY_ESCAPE);
})
- .size( 30, 20)
- .pos(0, k)
+ .size(30, 20)
+ .pos(0, margin)
.build());
- this.addRenderableWidget(new Button.Builder( Component.literal("\u2191"), (p) ->
+ this.addRenderableWidget(new Builder(Component.literal("↑"), (p) ->
{
- InputSimulator.pressKey(GLFW.GLFW_KEY_UP);
- InputSimulator.releaseKey(GLFW.GLFW_KEY_UP);
+ InputSimulator.pressKey(GLFW_KEY_UP);
+ InputSimulator.releaseKey(GLFW_KEY_UP);
})
- .size( i1, 20)
- .pos((i - 1) * (i1 + l) + k, k + j * (20 + l))
+ .size(bwidth, 20)
+ .pos((cols - 1) * (bwidth + spacing) + margin, margin + rows * (20 + spacing))
.build());
- this.addRenderableWidget(new Button.Builder( Component.literal("\u2193"), (p) ->
+ this.addRenderableWidget(new Builder(Component.literal("↓"), (p) ->
{
- InputSimulator.pressKey(GLFW.GLFW_KEY_DOWN);
- InputSimulator.releaseKey(GLFW.GLFW_KEY_DOWN);
+ InputSimulator.pressKey(GLFW_KEY_DOWN);
+ InputSimulator.releaseKey(GLFW_KEY_DOWN);
})
- .size( i1, 20)
- .pos((i - 1) * (i1 + l) + k, k + (j + 1) * (20 + l))
+ .size(bwidth, 20)
+ .pos((cols - 1) * (bwidth + spacing) + margin, margin + (rows + 1) * (20 + spacing))
.build());
- this.addRenderableWidget(new Button.Builder( Component.literal("\u2190"), (p) ->
+ this.addRenderableWidget(new Builder(Component.literal("←"), (p) ->
{
- InputSimulator.pressKey(GLFW.GLFW_KEY_LEFT);
- InputSimulator.releaseKey(GLFW.GLFW_KEY_LEFT);
+ InputSimulator.pressKey(GLFW_KEY_LEFT);
+ InputSimulator.releaseKey(GLFW_KEY_LEFT);
})
- .size( i1, 20)
- .pos((i - 2) * (i1 + l) + k, k + (j + 1) * (20 + l))
+ .size(bwidth, 20)
+ .pos((cols - 2) * (bwidth + spacing) + margin, margin + (rows + 1) * (20 + spacing))
.build());
- this.addRenderableWidget(new Button.Builder( Component.literal("\u2192"), (p) ->
+ this.addRenderableWidget(new Builder(Component.literal("→"), (p) ->
{
- InputSimulator.pressKey(GLFW.GLFW_KEY_RIGHT);
- InputSimulator.releaseKey(GLFW.GLFW_KEY_RIGHT);
+ InputSimulator.pressKey(GLFW_KEY_RIGHT);
+ InputSimulator.releaseKey(GLFW_KEY_RIGHT);
})
- .size( i1, 20)
- .pos(i * (i1 + l) + k, k + (j + 1) * (20 + l))
+ .size(bwidth, 20)
+ .pos(cols * (bwidth + spacing) + margin, margin + (rows + 1) * (20 + spacing))
.build());
- this.addRenderableWidget(new Button.Builder( Component.literal("CUT"), (p) ->
+ this.addRenderableWidget(new Builder(Component.literal("CUT"), (p) ->
{
- InputSimulator.pressKey(GLFW.GLFW_KEY_LEFT_CONTROL);
- InputSimulator.pressKey(GLFW.GLFW_KEY_X);
- InputSimulator.releaseKey(GLFW.GLFW_KEY_X);
- InputSimulator.releaseKey(GLFW.GLFW_KEY_LEFT_CONTROL);
+ InputSimulator.pressKey(GLFW_KEY_LEFT_CONTROL);
+ InputSimulator.pressKey(GLFW_KEY_X);
+ InputSimulator.releaseKey(GLFW_KEY_X);
+ InputSimulator.releaseKey(GLFW_KEY_LEFT_CONTROL);
})
- .size( 35, 20)
- .pos(k, k + -1 * (20 + l))
+ .size(35, 20)
+ .pos(margin, margin + -1 * (20 + spacing))
.build());
- this.addRenderableWidget(new Button.Builder( Component.literal("COPY"), (p) ->
+ this.addRenderableWidget(new Builder(Component.literal("COPY"), (p) ->
{
- InputSimulator.pressKey(GLFW.GLFW_KEY_LEFT_CONTROL);
- InputSimulator.pressKey(GLFW.GLFW_KEY_C);
- InputSimulator.releaseKey(GLFW.GLFW_KEY_C);
- InputSimulator.releaseKey(GLFW.GLFW_KEY_LEFT_CONTROL);
+ InputSimulator.pressKey(GLFW_KEY_LEFT_CONTROL);
+ InputSimulator.pressKey(GLFW_KEY_C);
+ InputSimulator.releaseKey(GLFW_KEY_C);
+ InputSimulator.releaseKey(GLFW_KEY_LEFT_CONTROL);
})
- .size( 35, 20)
- .pos(35 + l + k, k + -1 * (20 + l))
+ .size(35, 20)
+ .pos(35 + spacing + margin, margin + -1 * (20 + spacing))
.build());
- this.addRenderableWidget(new Button.Builder( Component.literal("PASTE"), (p) ->
+ this.addRenderableWidget(new Builder(Component.literal("PASTE"), (p) ->
{
- InputSimulator.pressKey(GLFW.GLFW_KEY_LEFT_CONTROL);
- InputSimulator.pressKey(GLFW.GLFW_KEY_V);
- InputSimulator.releaseKey(GLFW.GLFW_KEY_V);
- InputSimulator.releaseKey(GLFW.GLFW_KEY_LEFT_CONTROL);
+ InputSimulator.pressKey(GLFW_KEY_LEFT_CONTROL);
+ InputSimulator.pressKey(GLFW_KEY_V);
+ InputSimulator.releaseKey(GLFW_KEY_V);
+ InputSimulator.releaseKey(GLFW_KEY_LEFT_CONTROL);
})
- .size( 35, 20)
- .pos(2 * (35 + l) + k, k + -1 * (20 + l))
+ .size(35, 20)
+ .pos(2 * (35 + spacing) + margin, margin + -1 * (20 + spacing))
.build());
}
diff --git a/common/src/main/java/org/vivecraft/client_vr/gui/GuiRadial.java b/common/src/main/java/org/vivecraft/client_vr/gui/GuiRadial.java
index 671b99828..db1369602 100644
--- a/common/src/main/java/org/vivecraft/client_vr/gui/GuiRadial.java
+++ b/common/src/main/java/org/vivecraft/client_vr/gui/GuiRadial.java
@@ -1,125 +1,124 @@
package org.vivecraft.client_vr.gui;
-import net.minecraft.client.gui.GuiGraphics;
-import org.vivecraft.client.gui.framework.TwoHandedScreen;
-import org.vivecraft.client_vr.provider.MCVR;
import org.vivecraft.client_vr.provider.openvr_lwjgl.VRInputAction;
import net.minecraft.client.KeyMapping;
-import net.minecraft.client.gui.components.Button;
+import net.minecraft.client.gui.GuiGraphics;
+import net.minecraft.client.gui.components.Button.Builder;
import net.minecraft.client.resources.language.I18n;
import net.minecraft.network.chat.Component;
-public class GuiRadial extends TwoHandedScreen
+import static org.vivecraft.client_vr.VRState.dh;
+
+import static org.joml.Math.*;
+
+public class GuiRadial extends org.vivecraft.client.gui.framework.TwoHandedScreen
{
private boolean isShift = false;
String[] arr;
public void init()
{
- this.arr = this.dataholder.vrSettings.vrRadialItems;
- String[] astring = this.dataholder.vrSettings.vrRadialItemsAlt;
+ this.arr = dh.vrSettings.vrRadialItems;
+ String[] alt = dh.vrSettings.vrRadialItemsAlt;
this.clearWidgets();
- int i = 8;
- int j = 120;
- int k = 360 / i;
- int l = 48;
- int i1 = this.width / 2;
- int j1 = this.height / 2;
+
+ int numButts = 8;
+ int buttonWidthMin = 120;
+ int degreesPerButt = 360 / numButts;
+ int dist = 48;
+ int centerx = this.width / 2;
+ int centery = this.height / 2;
if (this.isShift)
{
- this.arr = astring;
+ this.arr = alt;
}
- for (int k1 = 0; k1 < i; ++k1)
+ for (int i = 0; i < numButts; ++i)
{
- KeyMapping keymapping = null;
+ KeyMapping b = null;
- for (KeyMapping keymapping1 : this.minecraft.options.keyMappings)
+ for (KeyMapping kb : this.minecraft.options.keyMappings)
{
- if (keymapping1.getName().equalsIgnoreCase(this.arr[k1]))
+ if (kb.getName().equalsIgnoreCase(this.arr[i]))
{
- keymapping = keymapping1;
+ b = kb;
}
}
- String s = "?";
+ String str = "?";
- if (keymapping != null)
+ if (b != null)
{
- s = I18n.get(keymapping.getName());
+ str = I18n.get(b.getName());
}
- int i2 = Math.max(j, this.font.width(s));
- int j2 = 0;
- int k2 = 0;
+ int buttonwidth = max(buttonWidthMin, this.font.width(str));
+ int x = 0, y = 0;
- if (k1 == 0)
+ if (i == 0)
{
- j2 = 0;
- k2 = -l;
+ y = -dist;
}
- else if (k1 == 1)
+ else if (i == 1)
{
- j2 = i2 / 2 + 8;
- k2 = -l / 2;
+ x = buttonwidth / 2 + 8;
+ y = -dist / 2;
}
- else if (k1 == 2)
+ else if (i == 2)
{
- j2 = i2 / 2 + 32;
- k2 = 0;
+ x = buttonwidth / 2 + 32;
}
- else if (k1 == 3)
+ else if (i == 3)
{
- j2 = i2 / 2 + 8;
- k2 = l / 2;
+ x = buttonwidth / 2 + 8;
+ y = dist / 2;
}
- else if (k1 == 4)
+ else if (i == 4)
{
- j2 = 0;
- k2 = l;
+ y = dist;
}
- else if (k1 == 5)
+ else if (i == 5)
{
- j2 = -i2 / 2 - 8;
- k2 = l / 2;
+ x = -buttonwidth / 2 - 8;
+ y = dist / 2;
}
- else if (k1 == 6)
+ else if (i == 6)
{
- j2 = -i2 / 2 - 32;
- k2 = 0;
+ x = -buttonwidth / 2 - 32;
}
- else if (k1 == 7)
+ else if (i == 7)
{
- j2 = -i2 / 2 - 8;
- k2 = -l / 2;
+ x = -buttonwidth / 2 - 8;
+ y = -dist / 2;
}
- int l1 = k1;
+ final int idx = i;
- if (s != "?")
+ if (!"?".equals(str))
{
- this.addRenderableWidget(new Button.Builder( Component.translatable(s), (p) ->
+ this.addRenderableWidget(new Builder(Component.translatable(str), (p) ->
{
- if (l1 < 200)
+ if (idx < 200)
{
- VRInputAction vrinputaction = MCVR.get().getInputAction(this.arr[l1]);
+ VRInputAction vb = dh.vr.getInputAction(this.arr[idx]);
- if (vrinputaction != null)
+ if (vb != null)
{
- vrinputaction.pressBinding();
- vrinputaction.unpressBinding(2);
+ vb.pressBinding();
+ vb.unpressBinding(2);
}
}
- else if (l1 == 201)
+ else if (idx == 201)
{
this.setShift(!this.isShift);
}
})
- .size( i2, 20)
- .pos(i1 + j2 - i2 / 2, j1 + k2 - 10)
- .build());
+ .size(buttonwidth, 20)
+ .pos(centerx + x - buttonwidth / 2, centery + y - 10)
+ .build()
+ );
}
}
}
diff --git a/common/src/main/java/org/vivecraft/client_vr/gui/PhysicalKeyboard.java b/common/src/main/java/org/vivecraft/client_vr/gui/PhysicalKeyboard.java
index 6ac172a38..186b91571 100644
--- a/common/src/main/java/org/vivecraft/client_vr/gui/PhysicalKeyboard.java
+++ b/common/src/main/java/org/vivecraft/client_vr/gui/PhysicalKeyboard.java
@@ -1,34 +1,18 @@
package org.vivecraft.client_vr.gui;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.function.Supplier;
-import java.util.stream.Stream;
-
-import org.lwjgl.glfw.GLFW;
-import org.lwjgl.opengl.GL11;
-import org.vivecraft.client_vr.ClientDataHolderVR;
import org.vivecraft.client_vr.gameplay.screenhandlers.GuiHandler;
import org.vivecraft.client_vr.gameplay.screenhandlers.KeyboardHandler;
import org.vivecraft.client_vr.provider.ControllerType;
import org.vivecraft.client_vr.provider.InputSimulator;
-import org.vivecraft.client_vr.provider.MCVR;
import org.vivecraft.client_vr.settings.OptionEnum;
-import org.vivecraft.client_vr.utils.RGBAColor;
-import org.vivecraft.client.utils.Utils;
-import org.vivecraft.common.utils.lwjgl.Matrix4f;
-import org.vivecraft.common.utils.lwjgl.Vector3f;
+import org.vivecraft.common.utils.color.Color;
+
+import org.joml.Matrix4f;
+import org.joml.Vector3f;
+import org.lwjgl.opengl.GL11C;
-import com.mojang.blaze3d.platform.GlStateManager;
+import com.mojang.blaze3d.platform.GlStateManager.DestFactor;
+import com.mojang.blaze3d.platform.GlStateManager.SourceFactor;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.BufferBuilder;
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
@@ -36,26 +20,44 @@
import com.mojang.blaze3d.vertex.Tesselator;
import com.mojang.blaze3d.vertex.VertexFormat.Mode;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.Font;
+import net.minecraft.client.gui.Font.DisplayMode;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.client.renderer.MultiBufferSource;
+import net.minecraft.client.renderer.MultiBufferSource.BufferSource;
import net.minecraft.client.resources.sounds.SimpleSoundInstance;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvents;
-import net.minecraft.util.Mth;
import net.minecraft.util.Tuple;
import net.minecraft.world.phys.AABB;
-import net.minecraft.world.phys.Vec3;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.function.Supplier;
+import java.util.stream.Stream;
+
+import static org.vivecraft.client_vr.VRState.dh;
+import static org.vivecraft.client_vr.VRState.mc;
+import static org.vivecraft.common.utils.Utils.*;
+
+import static org.joml.Math.*;
+import static org.joml.RoundingMode.CEILING;
+import static org.lwjgl.glfw.GLFW.*;
public class PhysicalKeyboard
{
- private final Minecraft mc = Minecraft.getInstance();
- private ClientDataHolderVR dh = ClientDataHolderVR.getInstance();
private boolean reinit;
private boolean shift;
private boolean shiftSticky;
- private List keys;
+ private final List keys = new ArrayList<>();
private static final int ROWS = 4;
private static final int COLUMNS = 13;
private static final float SPACING = 0.0064F;
@@ -69,9 +71,9 @@ public class PhysicalKeyboard
private float keyHeight;
private float keyWidthSpecial;
private float scale = 1.0F;
- private KeyButton[] pressedKey = new KeyButton[2];
- private long[] pressTime = new long[2];
- private long[] pressRepeatTime = new long[2];
+ private final KeyButton[] pressedKey = new KeyButton[2];
+ private final long[] pressTime = new long[2];
+ private final long[] pressRepeatTime = new long[2];
private long shiftPressTime;
private boolean lastPressedShift;
private Supplier easterEggText = () -> {
@@ -85,12 +87,7 @@ public class PhysicalKeyboard
};
private int easterEggIndex = 0;
private boolean easterEggActive;
- private Map customTheme = new HashMap<>();
-
- public PhysicalKeyboard()
- {
- this.keys = new ArrayList<>();
- }
+ private Map customTheme = new HashMap<>();
public void init()
{
@@ -102,16 +99,12 @@ public void init()
this.keyHeight = KEY_HEIGHT * this.scale;
this.keyWidthSpecial = KEY_WIDTH_SPECIAL * this.scale;
- String chars = this.dh.vrSettings.keyboardKeys;
- if (this.shift)
- {
- chars = this.dh.vrSettings.keyboardKeysShift;
- }
+ String chars = this.shift ? dh.vrSettings.keyboardKeysShift : dh.vrSettings.keyboardKeys;
float calcRows = (float)chars.length() / (float)this.columns;
- if (Math.abs((float)this.rows - calcRows) > 0.01F)
+ if (abs((float)this.rows - calcRows) > 0.01F)
{
- this.rows = Mth.ceil(calcRows);
+ this.rows = roundUsing(calcRows, CEILING);
}
for (int i = 0; i < this.rows; ++i)
@@ -127,7 +120,7 @@ public void init()
}
final char c1 = c0;
- this.addKey(new KeyButton(k, String.valueOf(c0), this.keyWidthSpecial + this.spacing + (float)j * (this.keyWidth + this.spacing), (float)i * (this.keyHeight + this.spacing), this.keyWidth, this.keyHeight)
+ this.addKey(new KeyButton(k, String.valueOf(c0), this.keyWidthSpecial + this.spacing + j * (this.keyWidth + this.spacing), i * (this.keyHeight + this.spacing), this.keyWidth, this.keyHeight)
{
@Override
public void onPressed()
@@ -139,10 +132,10 @@ public void onPressed()
PhysicalKeyboard.this.setShift(false, false);
}
- if (c1 == '/' && PhysicalKeyboard.this.mc.screen == null)
+ if (c1 == '/' && mc.screen == null)
{
- InputSimulator.pressKey(GLFW.GLFW_KEY_SLASH);
- InputSimulator.releaseKey(GLFW.GLFW_KEY_SLASH);
+ InputSimulator.pressKey(GLFW_KEY_SLASH);
+ InputSimulator.releaseKey(GLFW_KEY_SLASH);
}
}
});
@@ -151,12 +144,12 @@ public void onPressed()
for (int l = 0; l < 2; ++l)
{
- this.addKey(new KeyButton(1000 + l, "Shift", l == 1 ? this.keyWidthSpecial + this.spacing + (float)this.columns * (this.keyWidth + this.spacing) : 0.0F, 3.0F * (this.keyHeight + this.spacing), this.keyWidthSpecial, this.keyHeight)
+ this.addKey(new KeyButton(1000 + l, "Shift", l == 1 ? this.keyWidthSpecial + this.spacing + this.columns * (this.keyWidth + this.spacing) : 0.0F, 3.0F * (this.keyHeight + this.spacing), this.keyWidthSpecial, this.keyHeight)
{
@Override
public void onPressed()
{
- if (PhysicalKeyboard.this.shift && !PhysicalKeyboard.this.shiftSticky && Utils.milliTime() - PhysicalKeyboard.this.shiftPressTime < 400L)
+ if (PhysicalKeyboard.this.shift && !PhysicalKeyboard.this.shiftSticky && milliTime() - PhysicalKeyboard.this.shiftPressTime < 400L)
{
PhysicalKeyboard.this.setShift(true, true);
}
@@ -165,21 +158,18 @@ public void onPressed()
PhysicalKeyboard.this.setShift(!PhysicalKeyboard.this.shift, false);
}
- PhysicalKeyboard.this.shiftPressTime = Utils.milliTime();
+ PhysicalKeyboard.this.shiftPressTime = milliTime();
}
@Override
- public RGBAColor getRenderColor() {
- if (shift) {
- RGBAColor color = new RGBAColor(this.pressed ? 1.0F : 0.5F, this.pressed ? 1.0F : 0.5F, 0.0F, 0.5F);
-
- if (!shiftSticky)
- color.r = 0.0F;
-
- return color;
- }
-
- return super.getRenderColor();
+ public Color getRenderColor() {
+ return (PhysicalKeyboard.this.shift ?
+ new Color(
+ (!shiftSticky ? Byte.MIN_VALUE : this.pressed ? Byte.MAX_VALUE : (byte) -1),
+ this.pressed ? Byte.MAX_VALUE : (byte) -1
+ ) :
+ super.getRenderColor()
+ );
}
});
}
@@ -197,8 +187,8 @@ public void onPressed()
@Override
public void onPressed()
{
- InputSimulator.pressKey(GLFW.GLFW_KEY_TAB);
- InputSimulator.releaseKey(GLFW.GLFW_KEY_TAB);
+ InputSimulator.pressKey(GLFW_KEY_TAB);
+ InputSimulator.releaseKey(GLFW_KEY_TAB);
}
});
this.addKey(new KeyButton(1004, "Esc", 0.0F, 0.0F, this.keyWidthSpecial, this.keyHeight)
@@ -206,73 +196,73 @@ public void onPressed()
@Override
public void onPressed()
{
- InputSimulator.pressKey(GLFW.GLFW_KEY_ESCAPE);
- InputSimulator.releaseKey(GLFW.GLFW_KEY_ESCAPE);
+ InputSimulator.pressKey(GLFW_KEY_ESCAPE);
+ InputSimulator.releaseKey(GLFW_KEY_ESCAPE);
}
});
- this.addKey(new KeyButton(1005, "Bksp", this.keyWidthSpecial + this.spacing + (float)this.columns * (this.keyWidth + this.spacing), 0.0F, this.keyWidthSpecial, this.keyHeight)
+ this.addKey(new KeyButton(1005, "Bksp", this.keyWidthSpecial + this.spacing + this.columns * (this.keyWidth + this.spacing), 0.0F, this.keyWidthSpecial, this.keyHeight)
{
@Override
public void onPressed()
{
- InputSimulator.pressKey(GLFW.GLFW_KEY_BACKSPACE);
- InputSimulator.releaseKey(GLFW.GLFW_KEY_BACKSPACE);
+ InputSimulator.pressKey(GLFW_KEY_BACKSPACE);
+ InputSimulator.releaseKey(GLFW_KEY_BACKSPACE);
}
});
- this.addKey(new KeyButton(1006, "Enter", this.keyWidthSpecial + this.spacing + (float)this.columns * (this.keyWidth + this.spacing), 2.0F * (this.keyHeight + this.spacing), this.keyWidthSpecial, this.keyHeight)
+ this.addKey(new KeyButton(1006, "Enter", this.keyWidthSpecial + this.spacing + this.columns * (this.keyWidth + this.spacing), 2.0F * (this.keyHeight + this.spacing), this.keyWidthSpecial, this.keyHeight)
{
@Override
public void onPressed()
{
- InputSimulator.pressKey(GLFW.GLFW_KEY_ENTER);
- InputSimulator.releaseKey(GLFW.GLFW_KEY_ENTER);
+ InputSimulator.pressKey(GLFW_KEY_ENTER);
+ InputSimulator.releaseKey(GLFW_KEY_ENTER);
}
});
- this.addKey(new KeyButton(1007, "\u2191", this.keyWidthSpecial + this.spacing + (float)(this.columns + 1) * (this.keyWidth + this.spacing), 4.0F * (this.keyHeight + this.spacing), this.keyWidth, this.keyHeight)
+ this.addKey(new KeyButton(1007, "↑", this.keyWidthSpecial + this.spacing + (this.columns + 1) * (this.keyWidth + this.spacing), 4.0F * (this.keyHeight + this.spacing), this.keyWidth, this.keyHeight)
{
@Override
public void onPressed()
{
- InputSimulator.pressKey(GLFW.GLFW_KEY_UP);
- InputSimulator.releaseKey(GLFW.GLFW_KEY_UP);
+ InputSimulator.pressKey(GLFW_KEY_UP);
+ InputSimulator.releaseKey(GLFW_KEY_UP);
}
});
- this.addKey(new KeyButton(1008, "\u2193", this.keyWidthSpecial + this.spacing + (float)(this.columns + 1) * (this.keyWidth + this.spacing), 5.0F * (this.keyHeight + this.spacing), this.keyWidth, this.keyHeight)
+ this.addKey(new KeyButton(1008, "↓", this.keyWidthSpecial + this.spacing + (this.columns + 1) * (this.keyWidth + this.spacing), 5.0F * (this.keyHeight + this.spacing), this.keyWidth, this.keyHeight)
{
@Override
public void onPressed()
{
- InputSimulator.pressKey(GLFW.GLFW_KEY_DOWN);
- InputSimulator.releaseKey(GLFW.GLFW_KEY_DOWN);
+ InputSimulator.pressKey(GLFW_KEY_DOWN);
+ InputSimulator.releaseKey(GLFW_KEY_DOWN);
}
});
- this.addKey(new KeyButton(1009, "\u2190", this.keyWidthSpecial + this.spacing + (float)this.columns * (this.keyWidth + this.spacing), 5.0F * (this.keyHeight + this.spacing), this.keyWidth, this.keyHeight)
+ this.addKey(new KeyButton(1009, "←", this.keyWidthSpecial + this.spacing + this.columns * (this.keyWidth + this.spacing), 5.0F * (this.keyHeight + this.spacing), this.keyWidth, this.keyHeight)
{
@Override
public void onPressed()
{
- InputSimulator.pressKey(GLFW.GLFW_KEY_LEFT);
- InputSimulator.releaseKey(GLFW.GLFW_KEY_LEFT);
+ InputSimulator.pressKey(GLFW_KEY_LEFT);
+ InputSimulator.releaseKey(GLFW_KEY_LEFT);
}
});
- this.addKey(new KeyButton(1010, "\u2192", this.keyWidthSpecial + this.spacing + (float)(this.columns + 2) * (this.keyWidth + this.spacing), 5.0F * (this.keyHeight + this.spacing), this.keyWidth, this.keyHeight)
+ this.addKey(new KeyButton(1010, "→", this.keyWidthSpecial + this.spacing + (this.columns + 2) * (this.keyWidth + this.spacing), 5.0F * (this.keyHeight + this.spacing), this.keyWidth, this.keyHeight)
{
@Override
public void onPressed()
{
- InputSimulator.pressKey(GLFW.GLFW_KEY_RIGHT);
- InputSimulator.releaseKey(GLFW.GLFW_KEY_RIGHT);
+ InputSimulator.pressKey(GLFW_KEY_RIGHT);
+ InputSimulator.releaseKey(GLFW_KEY_RIGHT);
}
});
- this.addKey(new KeyButton(1011, "Cut", 1.0F * (this.keyWidthSpecial + this.spacing), -1.0F * (this.keyHeight + this.spacing), this.keyWidthSpecial, this.keyHeight)
+ this.addKey(new KeyButton(1011, "Cut", (this.keyWidthSpecial + this.spacing), -1.0F * (this.keyHeight + this.spacing), this.keyWidthSpecial, this.keyHeight)
{
@Override
public void onPressed()
{
- InputSimulator.pressKey(GLFW.GLFW_KEY_LEFT_CONTROL);
- InputSimulator.pressKey(GLFW.GLFW_KEY_X);
- InputSimulator.releaseKey(GLFW.GLFW_KEY_X);
- InputSimulator.releaseKey(GLFW.GLFW_KEY_LEFT_CONTROL);
+ InputSimulator.pressKey(GLFW_KEY_LEFT_CONTROL);
+ InputSimulator.pressKey(GLFW_KEY_X);
+ InputSimulator.releaseKey(GLFW_KEY_X);
+ InputSimulator.releaseKey(GLFW_KEY_LEFT_CONTROL);
}
});
this.addKey(new KeyButton(1012, "Copy", 2.0F * (this.keyWidthSpecial + this.spacing), -1.0F * (this.keyHeight + this.spacing), this.keyWidthSpecial, this.keyHeight)
@@ -280,10 +270,10 @@ public void onPressed()
@Override
public void onPressed()
{
- InputSimulator.pressKey(GLFW.GLFW_KEY_LEFT_CONTROL);
- InputSimulator.pressKey(GLFW.GLFW_KEY_C);
- InputSimulator.releaseKey(GLFW.GLFW_KEY_C);
- InputSimulator.releaseKey(GLFW.GLFW_KEY_LEFT_CONTROL);
+ InputSimulator.pressKey(GLFW_KEY_LEFT_CONTROL);
+ InputSimulator.pressKey(GLFW_KEY_C);
+ InputSimulator.releaseKey(GLFW_KEY_C);
+ InputSimulator.releaseKey(GLFW_KEY_LEFT_CONTROL);
}
});
this.addKey(new KeyButton(1013, "Paste", 3.0F * (this.keyWidthSpecial + this.spacing), -1.0F * (this.keyHeight + this.spacing), this.keyWidthSpecial, this.keyHeight)
@@ -291,10 +281,10 @@ public void onPressed()
@Override
public void onPressed()
{
- InputSimulator.pressKey(GLFW.GLFW_KEY_LEFT_CONTROL);
- InputSimulator.pressKey(GLFW.GLFW_KEY_V);
- InputSimulator.releaseKey(GLFW.GLFW_KEY_V);
- InputSimulator.releaseKey(GLFW.GLFW_KEY_LEFT_CONTROL);
+ InputSimulator.pressKey(GLFW_KEY_LEFT_CONTROL);
+ InputSimulator.pressKey(GLFW_KEY_V);
+ InputSimulator.releaseKey(GLFW_KEY_V);
+ InputSimulator.releaseKey(GLFW_KEY_LEFT_CONTROL);
}
});
@@ -315,17 +305,17 @@ public void onPressed()
}
if (dh.vrSettings.physicalKeyboardTheme == KeyboardTheme.CUSTOM) {
- customTheme.clear();
+ this.customTheme.clear();
File themeFile = new File(mc.gameDirectory, "keyboardtheme.txt");
if (!themeFile.exists()) {
// Write template theme file
try (PrintWriter pw = new PrintWriter(new FileWriter(themeFile, StandardCharsets.UTF_8))) {
- char[] normalChars = this.dh.vrSettings.keyboardKeys.toCharArray();
+ char[] normalChars = dh.vrSettings.keyboardKeys.toCharArray();
for (int i = 0; i < normalChars.length; i++) {
pw.println("# " + normalChars[i] + " (Normal)");
pw.println(i + "=255,255,255");
}
- char[] shiftChars = this.dh.vrSettings.keyboardKeysShift.toCharArray();
+ char[] shiftChars = dh.vrSettings.keyboardKeysShift.toCharArray();
for (int i = 0; i < shiftChars.length; i++) {
pw.println("# " + shiftChars[i] + " (Shifted)");
pw.println((i + 500) + "=255,255,255");
@@ -348,10 +338,10 @@ public void onPressed()
String[] split = line.split("=", 2);
int id = Integer.parseInt(split[0]);
String[] colorSplit = split[1].split(",");
- RGBAColor color = new RGBAColor(Integer.parseInt(colorSplit[0]), Integer.parseInt(colorSplit[1]), Integer.parseInt(colorSplit[2]), 255);
- customTheme.put(id, color);
+ Color color = new Color(Integer.parseInt(colorSplit[0]), Integer.parseInt(colorSplit[1]), Integer.parseInt(colorSplit[2]));
+ this.customTheme.put(id, color);
} catch (Exception ex) {
- System.out.println("Bad theme line: " + line);
+ logger.error("Bad theme line: {}", line);
ex.printStackTrace();
}
});
@@ -378,7 +368,7 @@ public void process()
if (physicalkeyboard$keybutton != null)
{
- if (physicalkeyboard$keybutton != this.pressedKey[i] && Utils.milliTime() - this.pressTime[i] >= 150L)
+ if (physicalkeyboard$keybutton != this.pressedKey[i] && milliTime() - this.pressTime[i] >= 150L)
{
if (this.pressedKey[i] != null)
{
@@ -388,20 +378,20 @@ public void process()
physicalkeyboard$keybutton.press(controllertype, false);
this.pressedKey[i] = physicalkeyboard$keybutton;
- this.pressTime[i] = Utils.milliTime();
- this.pressRepeatTime[i] = Utils.milliTime();
+ this.pressTime[i] = milliTime();
+ this.pressRepeatTime[i] = milliTime();
}
- else if (physicalkeyboard$keybutton == this.pressedKey[i] && Utils.milliTime() - this.pressTime[i] >= 500L && Utils.milliTime() - this.pressRepeatTime[i] >= 100L)
+ else if (physicalkeyboard$keybutton == this.pressedKey[i] && milliTime() - this.pressTime[i] >= 500L && milliTime() - this.pressRepeatTime[i] >= 100L)
{
physicalkeyboard$keybutton.press(controllertype, true);
- this.pressRepeatTime[i] = Utils.milliTime();
+ this.pressRepeatTime[i] = milliTime();
}
}
else if (this.pressedKey[i] != null)
{
this.pressedKey[i].unpress(controllertype);
this.pressedKey[i] = null;
- this.pressTime[i] = Utils.milliTime();
+ this.pressTime[i] = milliTime();
}
}
}
@@ -428,15 +418,15 @@ private Vector3f getCenterPos()
private KeyButton findTouchedKey(ControllerType controller)
{
- Matrix4f matrix4f = new Matrix4f();
- matrix4f.translate(this.getCenterPos());
- Matrix4f.mul(matrix4f, (Matrix4f)Utils.convertOVRMatrix(KeyboardHandler.Rotation_room).invert(), matrix4f);
- matrix4f.translate((Vector3f)Utils.convertToVector3f(KeyboardHandler.Pos_room).negate());
- Vec3 vec3 = Utils.convertToVector3d(Utils.transformVector(matrix4f, Utils.convertToVector3f(this.dh.vrPlayer.vrdata_room_pre.getController(controller.ordinal()).getPosition()), true));
+ Matrix4f matrix4f = new Matrix4f().translate(this.getCenterPos())
+ .mul(KeyboardHandler.Rotation_room.invertAffine(new Matrix4f()))
+ .translate(convertToVector3f(KeyboardHandler.Pos_room).negate());
+ Vector3f vector = convertToVector3f(dh.vrPlayer.vrdata_room_pre.getController(controller.ordinal()).getPosition());
+ matrix4f.transformPosition(vector, vector);
for (KeyButton physicalkeyboard$keybutton : this.keys)
{
- if (physicalkeyboard$keybutton.getCollisionBoundingBox().contains(vec3))
+ if (physicalkeyboard$keybutton.getCollisionBoundingBox().contains(vector.x(), vector.y(), vector.z()))
{
return physicalkeyboard$keybutton;
}
@@ -459,7 +449,7 @@ private void updateEasterEgg(String label)
this.easterEggIndex = 0;
}
}
- else if (label.equals("Enter"))
+ else if ("Enter".equals(label))
{
this.easterEggActive = !this.easterEggActive;
}
@@ -469,61 +459,60 @@ else if (label.equals("Enter"))
}
}
- private void drawBox(BufferBuilder buf, AABB box, RGBAColor color, PoseStack poseStack)
+ private void drawBox(BufferBuilder buf, AABB box, Color color, PoseStack poseStack)
{
- org.joml.Matrix4f matrix = poseStack.last().pose();
+ Matrix4f matrix = poseStack.last().pose();
float minX = (float)box.minX, minY = (float)box.minY, minZ = (float)box.minZ;
float maxX = (float)box.maxX, maxY = (float)box.maxY, maxZ = (float)box.maxZ;
- buf.vertex(matrix, minX, minY, minZ).uv(0, 0).color(color.r, color.g, color.b, color.a).normal(0.0F, 0.0F, -1.0F).endVertex();
- buf.vertex(matrix, minX, maxY, minZ).uv(0, 0).color(color.r, color.g, color.b, color.a).normal(0.0F, 0.0F, -1.0F).endVertex();
- buf.vertex(matrix, maxX, maxY, minZ).uv(0, 0).color(color.r, color.g, color.b, color.a).normal(0.0F, 0.0F, -1.0F).endVertex();
- buf.vertex(matrix, maxX, minY, minZ).uv(0, 0).color(color.r, color.g, color.b, color.a).normal(0.0F, 0.0F, -1.0F).endVertex();
- buf.vertex(matrix, minX, minY, minZ).uv(0, 0).color(color.r, color.g, color.b, color.a).normal(0.0F, -1.0F, 0.0F).endVertex();
- buf.vertex(matrix, maxX, minY, minZ).uv(0, 0).color(color.r, color.g, color.b, color.a).normal(0.0F, -1.0F, 0.0F).endVertex();
- buf.vertex(matrix, maxX, minY, maxZ).uv(0, 0).color(color.r, color.g, color.b, color.a).normal(0.0F, -1.0F, 0.0F).endVertex();
- buf.vertex(matrix, minX, minY, maxZ).uv(0, 0).color(color.r, color.g, color.b, color.a).normal(0.0F, -1.0F, 0.0F).endVertex();
- buf.vertex(matrix, minX, minY, minZ).uv(0, 0).color(color.r, color.g, color.b, color.a).normal(-1.0F, 0.0F, 0.0F).endVertex();
- buf.vertex(matrix, minX, minY, maxZ).uv(0, 0).color(color.r, color.g, color.b, color.a).normal(-1.0F, 0.0F, 0.0F).endVertex();
- buf.vertex(matrix, minX, maxY, maxZ).uv(0, 0).color(color.r, color.g, color.b, color.a).normal(-1.0F, 0.0F, 0.0F).endVertex();
- buf.vertex(matrix, minX, maxY, minZ).uv(0, 0).color(color.r, color.g, color.b, color.a).normal(-1.0F, 0.0F, 0.0F).endVertex();
- buf.vertex(matrix, maxX, maxY, maxZ).uv(0, 0).color(color.r, color.g, color.b, color.a).normal(0.0F, 0.0F, 1.0F).endVertex();
- buf.vertex(matrix, minX, maxY, maxZ).uv(0, 0).color(color.r, color.g, color.b, color.a).normal(0.0F, 0.0F, 1.0F).endVertex();
- buf.vertex(matrix, minX, minY, maxZ).uv(0, 0).color(color.r, color.g, color.b, color.a).normal(0.0F, 0.0F, 1.0F).endVertex();
- buf.vertex(matrix, maxX, minY, maxZ).uv(0, 0).color(color.r, color.g, color.b, color.a).normal(0.0F, 0.0F, 1.0F).endVertex();
- buf.vertex(matrix, maxX, maxY, maxZ).uv(0, 0).color(color.r, color.g, color.b, color.a).normal(0.0F, 1.0F, 0.0F).endVertex();
- buf.vertex(matrix, maxX, maxY, minZ).uv(0, 0).color(color.r, color.g, color.b, color.a).normal(0.0F, 1.0F, 0.0F).endVertex();
- buf.vertex(matrix, minX, maxY, minZ).uv(0, 0).color(color.r, color.g, color.b, color.a).normal(0.0F, 1.0F, 0.0F).endVertex();
- buf.vertex(matrix, minX, maxY, maxZ).uv(0, 0).color(color.r, color.g, color.b, color.a).normal(0.0F, 1.0F, 0.0F).endVertex();
- buf.vertex(matrix, maxX, maxY, maxZ).uv(0, 0).color(color.r, color.g, color.b, color.a).normal(1.0F, 0.0F, 0.0F).endVertex();
- buf.vertex(matrix, maxX, minY, maxZ).uv(0, 0).color(color.r, color.g, color.b, color.a).normal(1.0F, 0.0F, 0.0F).endVertex();
- buf.vertex(matrix, maxX, minY, minZ).uv(0, 0).color(color.r, color.g, color.b, color.a).normal(1.0F, 0.0F, 0.0F).endVertex();
- buf.vertex(matrix, maxX, maxY, minZ).uv(0, 0).color(color.r, color.g, color.b, color.a).normal(1.0F, 0.0F, 0.0F).endVertex();
+ int r = color.R();
+ int g = color.G();
+ int b = color.B();
+ int a = color.A();
+ buf.vertex(matrix, minX, minY, minZ).uv(0, 0).color(r, g, b, a).normal(0.0F, 0.0F, -1.0F).endVertex();
+ buf.vertex(matrix, minX, maxY, minZ).uv(0, 0).color(r, g, b, a).normal(0.0F, 0.0F, -1.0F).endVertex();
+ buf.vertex(matrix, maxX, maxY, minZ).uv(0, 0).color(r, g, b, a).normal(0.0F, 0.0F, -1.0F).endVertex();
+ buf.vertex(matrix, maxX, minY, minZ).uv(0, 0).color(r, g, b, a).normal(0.0F, 0.0F, -1.0F).endVertex();
+ buf.vertex(matrix, minX, minY, minZ).uv(0, 0).color(r, g, b, a).normal(0.0F, -1.0F, 0.0F).endVertex();
+ buf.vertex(matrix, maxX, minY, minZ).uv(0, 0).color(r, g, b, a).normal(0.0F, -1.0F, 0.0F).endVertex();
+ buf.vertex(matrix, maxX, minY, maxZ).uv(0, 0).color(r, g, b, a).normal(0.0F, -1.0F, 0.0F).endVertex();
+ buf.vertex(matrix, minX, minY, maxZ).uv(0, 0).color(r, g, b, a).normal(0.0F, -1.0F, 0.0F).endVertex();
+ buf.vertex(matrix, minX, minY, minZ).uv(0, 0).color(r, g, b, a).normal(-1.0F, 0.0F, 0.0F).endVertex();
+ buf.vertex(matrix, minX, minY, maxZ).uv(0, 0).color(r, g, b, a).normal(-1.0F, 0.0F, 0.0F).endVertex();
+ buf.vertex(matrix, minX, maxY, maxZ).uv(0, 0).color(r, g, b, a).normal(-1.0F, 0.0F, 0.0F).endVertex();
+ buf.vertex(matrix, minX, maxY, minZ).uv(0, 0).color(r, g, b, a).normal(-1.0F, 0.0F, 0.0F).endVertex();
+ buf.vertex(matrix, maxX, maxY, maxZ).uv(0, 0).color(r, g, b, a).normal(0.0F, 0.0F, 1.0F).endVertex();
+ buf.vertex(matrix, minX, maxY, maxZ).uv(0, 0).color(r, g, b, a).normal(0.0F, 0.0F, 1.0F).endVertex();
+ buf.vertex(matrix, minX, minY, maxZ).uv(0, 0).color(r, g, b, a).normal(0.0F, 0.0F, 1.0F).endVertex();
+ buf.vertex(matrix, maxX, minY, maxZ).uv(0, 0).color(r, g, b, a).normal(0.0F, 0.0F, 1.0F).endVertex();
+ buf.vertex(matrix, maxX, maxY, maxZ).uv(0, 0).color(r, g, b, a).normal(0.0F, 1.0F, 0.0F).endVertex();
+ buf.vertex(matrix, maxX, maxY, minZ).uv(0, 0).color(r, g, b, a).normal(0.0F, 1.0F, 0.0F).endVertex();
+ buf.vertex(matrix, minX, maxY, minZ).uv(0, 0).color(r, g, b, a).normal(0.0F, 1.0F, 0.0F).endVertex();
+ buf.vertex(matrix, minX, maxY, maxZ).uv(0, 0).color(r, g, b, a).normal(0.0F, 1.0F, 0.0F).endVertex();
+ buf.vertex(matrix, maxX, maxY, maxZ).uv(0, 0).color(r, g, b, a).normal(1.0F, 0.0F, 0.0F).endVertex();
+ buf.vertex(matrix, maxX, minY, maxZ).uv(0, 0).color(r, g, b, a).normal(1.0F, 0.0F, 0.0F).endVertex();
+ buf.vertex(matrix, maxX, minY, minZ).uv(0, 0).color(r, g, b, a).normal(1.0F, 0.0F, 0.0F).endVertex();
+ buf.vertex(matrix, maxX, maxY, minZ).uv(0, 0).color(r, g, b, a).normal(1.0F, 0.0F, 0.0F).endVertex();
}
public void render(PoseStack poseStack)
{
poseStack.pushPose();
Vector3f center = this.getCenterPos();
- poseStack.translate(-center.x, -center.y, -center.z);
+ poseStack.last().pose().translate(-center.x, -center.y, -center.z);
RenderSystem.disableCull();
RenderSystem.enableBlend();
if (this.easterEggActive) {
// https://qimg.techjargaming.com/i/UkG1cWAh.png
for (KeyButton button : this.keys) {
- RGBAColor color = RGBAColor.fromHSB(((float)this.dh.tickCounter + this.mc.getFrameTime()) / 100.0F + (float)(button.boundingBox.minX + (button.boundingBox.maxX - button.boundingBox.minX) / 2.0D) / 2.0F, 1.0F, 1.0F);
- button.color.r = color.r;
- button.color.g = color.g;
- button.color.b = color.b;
+ button.color.fromHSB(((float)dh.tickCounter + mc.getFrameTime()) / 100.0F + (float)(button.boundingBox.minX + (button.boundingBox.maxX - button.boundingBox.minX) / 2.0D) / 2.0F, 1.0F, 1.0F);
}
} else {
this.keys.forEach(button -> {
if (dh.vrSettings.physicalKeyboardTheme == KeyboardTheme.CUSTOM) {
- RGBAColor color = customTheme.get(this.shift && button.id < 1000 ? button.id + 500 : button.id);
+ Color color = this.customTheme.get(this.shift && button.id < 1000 ? button.id + 500 : button.id);
if (color != null) {
- button.color.r = color.r;
- button.color.g = color.g;
- button.color.b = color.b;
+ button.color.set(color.r, color.g, color.b);
}
} else {
dh.vrSettings.physicalKeyboardTheme.assignColor(button);
@@ -538,11 +527,10 @@ public void render(PoseStack poseStack)
RenderSystem.setShaderTexture(0, new ResourceLocation("vivecraft:textures/white.png"));
// We need to ignore depth so we can see the back faces and text
- RenderSystem.depthFunc(GL11.GL_ALWAYS);
- RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
+ RenderSystem.depthFunc(GL11C.GL_ALWAYS);
+ RenderSystem.blendFuncSeparate(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA, SourceFactor.ONE, DestFactor.ONE_MINUS_SRC_ALPHA);
// Stuff for drawing labels
- Font font = this.mc.font;
ArrayList> labels = new ArrayList<>();
float textScale = 0.002F * this.scale;
@@ -551,41 +539,41 @@ public void render(PoseStack poseStack)
BufferBuilder bufferbuilder = tesselator.getBuilder();
bufferbuilder.begin(Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR_NORMAL);
- for (KeyButton physicalkeyboard$keybutton1 : this.keys)
+ for (KeyButton button : this.keys)
{
- AABB box = physicalkeyboard$keybutton1.getRenderBoundingBox();
- RGBAColor color = physicalkeyboard$keybutton1.getRenderColor();
+ AABB box = button.getRenderBoundingBox();
// Draw the key itself
- this.drawBox(bufferbuilder, box, color, poseStack);
+ this.drawBox(bufferbuilder, box, button.getRenderColor(), poseStack);
// Calculate text position
- float stringWidth = (float)font.width(physicalkeyboard$keybutton1.label) * textScale;
- float stringHeight = font.lineHeight * textScale;
+ float stringWidth = (float)mc.font.width(button.label) * textScale;
+ float stringHeight = mc.font.lineHeight * textScale;
float textX = (float)box.minX + ((float)box.maxX - (float)box.minX) / 2.0F - stringWidth / 2.0F;
float textY = (float)box.minY + ((float)box.maxY - (float)box.minY) / 2.0F - stringHeight / 2.0F;
float textZ = (float)box.minZ + ((float)box.maxZ - (float)box.minZ) / 2.0F;
// Put label in the list
- labels.add(new Tuple<>(physicalkeyboard$keybutton1.label, new Vector3f(textX, textY, textZ)));
+ labels.add(new Tuple<>(button.label, new Vector3f(textX, textY, textZ)));
}
// Draw all the key boxes
tesselator.end();
- RenderSystem.depthFunc(GL11.GL_LEQUAL);
+ RenderSystem.depthFunc(GL11C.GL_LEQUAL);
//GlStateManager._disableLighting();
// Start building vertices for text
- MultiBufferSource.BufferSource multibuffersource$buffersource = MultiBufferSource.immediate(tesselator.getBuilder());
+ BufferSource multibuffersource$buffersource = MultiBufferSource.immediate(tesselator.getBuilder());
// Build all the text
for (Tuple label : labels)
{
+ Vector3f textPos = label.getB();
poseStack.pushPose();
- poseStack.translate((double)(label.getB()).x, (double)(label.getB()).y, (double)(label.getB()).z);
+ poseStack.last().pose().translate(textPos.x, textPos.y, textPos.z);
poseStack.scale(textScale, textScale, 1.0F);
- font.drawInBatch(label.getA(), 0.0F, 0.0F, 0xFFFFFFFF, false, poseStack.last().pose(), multibuffersource$buffersource, Font.DisplayMode.NORMAL, 0, 15728880, font.isBidirectional());
+ mc.font.drawInBatch(label.getA(), 0.0F, 0.0F, 0xFFFFFFFF, false, poseStack.last().pose(), multibuffersource$buffersource, DisplayMode.NORMAL, 0, 15728880, mc.font.isBidirectional());
poseStack.popPose();
}
@@ -607,7 +595,7 @@ public void show()
this.shift = false;
}
- this.scale = this.dh.vrSettings.physicalKeyboardScale;
+ this.scale = dh.vrSettings.physicalKeyboardScale;
this.reinit = true;
}
@@ -653,14 +641,14 @@ private abstract class KeyButton
public final int id;
public final String label;
public final AABB boundingBox;
- public RGBAColor color = new RGBAColor(1.0F, 1.0F, 1.0F, 0.5F);
+ public Color color = new Color(Color.WHITE, (byte) -1);
public boolean pressed;
public KeyButton(int id, String label, float x, float y, float width, float height)
{
this.id = id;
this.label = label;
- this.boundingBox = new AABB((double)x, (double)y, 0.0D, (double)(x + width), (double)(y + height), 0.028D * (double)PhysicalKeyboard.this.scale);
+ this.boundingBox = new AABB(x, y, 0.0D, x + width, y + height, 0.028D * PhysicalKeyboard.this.scale);
}
public AABB getRenderBoundingBox()
@@ -673,15 +661,15 @@ public AABB getCollisionBoundingBox()
return this.pressed ? this.boundingBox.expandTowards(0.0D, 0.0D, 0.08D) : this.boundingBox;
}
- public RGBAColor getRenderColor()
+ public Color getRenderColor()
{
- RGBAColor color = this.color.copy();
+ Color color = new Color(this.color);
if (!this.pressed)
{
- color.r *= 0.5F;
- color.g *= 0.5F;
- color.b *= 0.5F;
+ color.r >>= 1;
+ color.g >>= 1;
+ color.b >>= 1;
}
return color;
@@ -691,10 +679,10 @@ public final void press(ControllerType controller, boolean isRepeat)
{
if (!isRepeat)
{
- PhysicalKeyboard.this.mc.getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F));
+ mc.getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F));
}
- MCVR.get().triggerHapticPulse(controller, isRepeat ? 300 : 600);
+ dh.vr.triggerHapticPulse(controller, isRepeat ? 300 : 600);
this.pressed = true;
this.onPressed();
PhysicalKeyboard.this.updateEasterEgg(this.label);
@@ -712,86 +700,81 @@ public enum KeyboardTheme implements OptionEnum {
DEFAULT {
@Override
public void assignColor(KeyButton button) {
- button.color.r = 1.0F;
- button.color.g = 1.0F;
- button.color.b = 1.0F;
+ button.color.set(Color.WHITE);
}
},
RED {
@Override
public void assignColor(KeyButton button) {
- button.color.r = 1.0F;
- button.color.g = 0.0F;
- button.color.b = 0.0F;
+ button.color.set(Color.RED);
}
},
GREEN {
@Override
public void assignColor(KeyButton button) {
- button.color.r = 0.0F;
- button.color.g = 1.0F;
- button.color.b = 0.0F;
+ button.color.set(Color.GREEN);
}
},
BLUE {
@Override
public void assignColor(KeyButton button) {
- button.color.r = 0.0F;
- button.color.g = 0.0F;
- button.color.b = 1.0F;
+ button.color.set(Color.BLUE);
}
},
BLACK {
@Override
public void assignColor(KeyButton button) {
- button.color.r = 0.0F;
- button.color.g = 0.0F;
- button.color.b = 0.0F;
+ button.color.set(Color.BLACK);
}
},
GRASS {
@Override
public void assignColor(KeyButton button) {
if (button.boundingBox.maxY < 0.07D) {
- button.color.r = 0.321F;
- button.color.g = 0.584F;
- button.color.b = 0.184F;
+ // button.color.set(0.321F, 0.584F, 0.184F);
+ button.color.set((byte)0xD1, (byte)0x14, (byte)0xAE);
} else {
- button.color.r = 0.607F;
- button.color.g = 0.462F;
- button.color.b = 0.325F;
+ // button.color.set(0.607F, 0.462F, 0.325F);
+ button.color.set((byte)0x1A, (byte)0xF5, (byte)0xD2);
}
}
},
BEES {
@Override
public void assignColor(KeyButton button) {
- float val = button.boundingBox.maxX % 0.2D < 0.1D ? 1.0F : 0.0F;
- button.color.r = val;
- button.color.g = val;
- button.color.b = 0.0F;
+ if (button.boundingBox.maxX % 0.2D < 0.1D){
+ button.color.r(Byte.MAX_VALUE);
+ button.color.g(Byte.MAX_VALUE);
+ }
+ else
+ {
+ button.color.r(Byte.MIN_VALUE);
+ button.color.g(Byte.MIN_VALUE);
+ }
+ button.color.b(Byte.MIN_VALUE);
}
},
AESTHETIC {
@Override
public void assignColor(KeyButton button) {
if (button.id >= 1000) {
- button.color.r = 0.0F;
- button.color.g = 1.0F;
- button.color.b = 1.0F;
+ button.color.set(Color.CYAN);
} else {
- button.color.r = 1.0F;
- button.color.g = 0.0F;
- button.color.b = 1.0F;
+ button.color.set(Color.MAGENTA);
}
}
},
DOSE {
@Override
public void assignColor(KeyButton button) {
- button.color.r = button.id % 2 == 0 ? 0.5F : 0.0F;
- button.color.g = button.id % 2 == 0 ? 0.0F : 1.0F;
- button.color.b = button.id % 2 == 0 ? 1.0F : 0.0F;
+ if (button.id % 2 == 0)
+ {
+ button.color.set((byte) -1, Byte.MIN_VALUE, Byte.MAX_VALUE);
+ }
+ else
+ {
+ button.color.set(Byte.MIN_VALUE, Byte.MAX_VALUE, Byte.MIN_VALUE);
+ }
}
},
CUSTOM {
diff --git a/common/src/main/java/org/vivecraft/client_vr/menuworlds/FakeBlockAccess.java b/common/src/main/java/org/vivecraft/client_vr/menuworlds/FakeBlockAccess.java
index 2ee7c6517..c072287a6 100644
--- a/common/src/main/java/org/vivecraft/client_vr/menuworlds/FakeBlockAccess.java
+++ b/common/src/main/java/org/vivecraft/client_vr/menuworlds/FakeBlockAccess.java
@@ -1,17 +1,12 @@
package org.vivecraft.client_vr.menuworlds;
-import java.util.Collections;
-import java.util.List;
-import javax.annotation.Nullable;
-
-import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.DimensionSpecialEffects;
import net.minecraft.core.*;
-import net.minecraft.util.Mth;
+import net.minecraft.core.BlockPos.MutableBlockPos;
+import net.minecraft.core.Direction.Axis;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.flag.FeatureFlagSet;
import net.minecraft.world.level.ColorResolver;
-import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.LightLayer;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.biome.BiomeManager;
@@ -22,13 +17,21 @@
import net.minecraft.world.level.chunk.ChunkAccess;
import net.minecraft.world.level.chunk.ChunkStatus;
import net.minecraft.world.level.dimension.DimensionType;
-import net.minecraft.world.level.levelgen.Heightmap;
+import net.minecraft.world.level.levelgen.Heightmap.Types;
import net.minecraft.world.level.lighting.LevelLightEngine;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.shapes.VoxelShape;
-public class FakeBlockAccess implements LevelReader {
+import javax.annotation.Nullable;
+import java.util.Collections;
+import java.util.List;
+
+import static org.vivecraft.client_vr.VRState.mc;
+
+import static org.joml.Math.*;
+
+public class FakeBlockAccess implements net.minecraft.world.level.LevelReader {
private int version;
private long seed;
private DimensionType dimensionType;
@@ -79,7 +82,7 @@ public FakeBlockAccess(int version, long seed, BlockState[] blocks, byte[] skyli
// set the ground to the height of the center block
BlockPos pos = new BlockPos(0, (int)this.ground, 0);
BlockState standing = blocks[encodeCoords(pos)];
- this.ground += Math.max(standing.getCollisionShape(this, pos).max(Direction.Axis.Y), 0.0);
+ this.ground += max(standing.getCollisionShape(this, pos).max(Axis.Y), 0.0);
this.effectiveGround = this.ground;
}
@@ -175,7 +178,7 @@ public BlockEntity getBlockEntity(BlockPos pos) {
@Override
public int getBlockTint(BlockPos blockPosIn, ColorResolver colorResolverIn) {
- int i = Minecraft.getInstance().options.biomeBlendRadius().get();
+ int i = mc.options.biomeBlendRadius().get();
if (i == 0)
{
@@ -190,7 +193,7 @@ public int getBlockTint(BlockPos blockPosIn, ColorResolver colorResolverIn) {
Cursor3D cursor3D = new Cursor3D(blockPosIn.getX() - i, blockPosIn.getY(), blockPosIn.getZ() - i, blockPosIn.getX() + i, blockPosIn.getY(), blockPosIn.getZ() + i);
int j1;
- for (BlockPos.MutableBlockPos blockpos$mutable = new BlockPos.MutableBlockPos(); cursor3D.advance(); i1 += j1 & 255)
+ for (MutableBlockPos blockpos$mutable = new MutableBlockPos(); cursor3D.advance(); i1 += j1 & 255)
{
blockpos$mutable.set(cursor3D.nextX(), cursor3D.nextY(), cursor3D.nextZ());
j1 = colorResolverIn.getColor(this.getBiome(blockpos$mutable).value(), (double)blockpos$mutable.getX(), (double)blockpos$mutable.getZ());
@@ -243,24 +246,12 @@ public float getShade(Direction face, boolean shade) {
return flag ? 0.9F : 1.0F;
}
else {
- switch (face) {
- case DOWN:
- return flag ? 0.9F : 0.5F;
-
- case UP:
- return flag ? 0.9F : 1.0F;
-
- case NORTH:
- case SOUTH:
- return 0.8F;
-
- case WEST:
- case EAST:
- return 0.6F;
-
- default:
- return 1.0F;
- }
+ return switch (face) {
+ case DOWN -> flag ? 0.9F : 0.5F;
+ case UP -> flag ? 0.9F : 1.0F;
+ case NORTH, SOUTH -> 0.8F;
+ case WEST, EAST -> 0.6F;
+ };
}
}
@@ -275,8 +266,8 @@ public ChunkAccess getChunk(int x, int z, ChunkStatus requiredStatus, boolean no
}
@Override
- public int getHeight(Heightmap.Types heightmapType, int x, int z) {
- if (heightmapType == Heightmap.Types.MOTION_BLOCKING) {
+ public int getHeight(Types heightmapType, int x, int z) {
+ if (heightmapType == Types.MOTION_BLOCKING) {
return getHeightBlocking(x, z);
}
return 0; // �\_(?)_/�
@@ -287,7 +278,7 @@ public int getHeightBlocking(int x, int z) {
}
@Override
- public BlockPos getHeightmapPos(Heightmap.Types heightmapType, BlockPos pos) {
+ public BlockPos getHeightmapPos(Types heightmapType, BlockPos pos) {
return BlockPos.ZERO; // �\_(?)_/�
}
@@ -322,9 +313,9 @@ public Holder getNoiseBiome(int x, int y, int z) {
int yMoved = y + (int)effectiveGround/4;
int zMoved = z + zSize/8;
if (!checkCoords(x * 4, y * 4, z * 4)) {
- xMoved = Mth.clamp(xMoved, 0, xSize / 4 - 1);
- yMoved = Mth.clamp(yMoved, 0, (ySize-(int)effectiveGround) / 4 - 1);
- zMoved = Mth.clamp(zMoved, 0, zSize / 4 - 1);
+ xMoved = clamp(0, xSize / 4 - 1, xMoved);
+ yMoved = clamp(0, (ySize-(int)effectiveGround) / 4 - 1, yMoved);
+ zMoved = clamp(0, zSize / 4 - 1, zMoved);
}
return Holder.direct(biomemap[(yMoved * (zSize / 4) + zMoved) * (xSize / 4) + xMoved]);
}
diff --git a/common/src/main/java/org/vivecraft/client_vr/menuworlds/MenuWorldDownloader.java b/common/src/main/java/org/vivecraft/client_vr/menuworlds/MenuWorldDownloader.java
index f96b37261..db5c50558 100644
--- a/common/src/main/java/org/vivecraft/client_vr/menuworlds/MenuWorldDownloader.java
+++ b/common/src/main/java/org/vivecraft/client_vr/menuworlds/MenuWorldDownloader.java
@@ -1,16 +1,19 @@
package org.vivecraft.client_vr.menuworlds;
+import net.minecraft.SharedConstants;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.security.NoSuchAlgorithmException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
-import net.minecraft.SharedConstants;
-import org.vivecraft.client.utils.Utils;
-import org.vivecraft.client_vr.ClientDataHolderVR;
-import org.vivecraft.client_vr.settings.VRSettings;
+import static org.vivecraft.client.utils.Utils.*;
+import static org.vivecraft.client_vr.VRState.dh;
+import static org.vivecraft.common.utils.Utils.logger;
public class MenuWorldDownloader {
private static final String baseUrl = "https://cache.techjargaming.com/vivecraft/115/";
@@ -31,31 +34,35 @@ public static void downloadWorld(String path) throws IOException, NoSuchAlgorith
File file = new File(path);
file.getParentFile().mkdirs();
if (file.exists()) {
- String localSha1 = Utils.getFileChecksum(file, "SHA-1");
- String remoteSha1 = Utils.httpReadLine(baseUrl + "checksum.php?file=" + path);
+ String localSha1 = getFileChecksum(file, "SHA-1");
+ String remoteSha1 = httpReadLine(baseUrl + "checksum.php?file=" + path);
if (localSha1.equals(remoteSha1)) {
- VRSettings.logger.info("MenuWorlds: SHA-1 matches for " + path);
+ logger.info("MenuWorlds: SHA-1 matches for {}", path);
return;
}
}
- VRSettings.logger.info("MenuWorlds: Downloading world " + path);
- Utils.httpReadToFile(baseUrl + path, file, true);
+ logger.info("MenuWorlds: Downloading world {}", path);
+ httpReadToFile(baseUrl + path, file, true);
}
public static InputStream getRandomWorld() throws IOException, NoSuchAlgorithmException {
init();
- VRSettings settings = ClientDataHolderVR.getInstance().vrSettings;
-
try {
List worldList = new ArrayList<>();
- if (settings.menuWorldSelection == VRSettings.MenuWorld.BOTH || settings.menuWorldSelection == VRSettings.MenuWorld.CUSTOM)
- worldList.addAll(getCustomWorlds());
- if (settings.menuWorldSelection == VRSettings.MenuWorld.BOTH || settings.menuWorldSelection == VRSettings.MenuWorld.OFFICIAL || worldList.size() == 0)
- worldList.addAll(getOfficialWorlds());
- // don't load the same world twice in a row
- if (worldList.size() > 1)
- worldList.removeIf(world -> lastWorld.equals(world.path) || (world.file != null && lastWorld.equals(world.file.getPath())));
+ if (
+ switch(dh.vrSettings.menuWorldSelection)
+ {
+ case CUSTOM -> worldList.addAll(getCustomWorlds()) || worldList.addAll(getOfficialWorlds());
+ case OFFICIAL -> worldList.addAll(getOfficialWorlds());
+ case BOTH -> worldList.addAll(getCustomWorlds()) && worldList.addAll(getOfficialWorlds());
+ default -> false;
+ }
+ )
+ {
+ // don't load the same world twice in a row
+ worldList.removeIf(world -> lastWorld.equals(world.path) || lastWorld.equals(world.file.getPath()));
+ }
if (worldList.size() == 0)
return getRandomWorldFallback();
@@ -73,11 +80,11 @@ public static InputStream getRandomWorld() throws IOException, NoSuchAlgorithmEx
private static InputStream getStreamForWorld(MenuWorldItem world) throws IOException, NoSuchAlgorithmException {
if (world.file != null) {
- VRSettings.logger.info("MenuWorlds: Using world " + world.file.getName());
+ logger.info("MenuWorlds: Using world {}", world.file.getName());
return new FileInputStream(world.file);
} else if (world.path != null) {
downloadWorld(world.path);
- VRSettings.logger.info("MenuWorlds: Using official world " + world.path);
+ logger.info("MenuWorlds: Using official world {}", world.path);
return new FileInputStream(world.path);
} else {
throw new IllegalArgumentException("File or path must be assigned");
@@ -93,14 +100,14 @@ private static List getCustomWorlds() throws IOException {
private static List getOfficialWorlds() throws IOException {
List list = new ArrayList<>();
- List resultList = Utils.httpReadAllLines(baseUrl + "menuworlds_list.php?minver=" + MenuWorldExporter.MIN_VERSION + "&maxver=" + MenuWorldExporter.VERSION + "&mcver=" + SharedConstants.VERSION_STRING);
+ List resultList = httpReadAllLines(baseUrl + "menuworlds_list.php?minver=" + MenuWorldExporter.MIN_VERSION + "&maxver=" + MenuWorldExporter.VERSION + "&mcver=" + SharedConstants.VERSION_STRING);
for (String str : resultList)
list.add(new MenuWorldItem("menuworlds/" + str, null));
return list;
}
private static InputStream getRandomWorldFallback() throws IOException, NoSuchAlgorithmException {
- VRSettings.logger.info("MenuWorlds: Couldn't find a world, trying random file from directory");
+ logger.info("MenuWorlds: Couldn't find a world, trying random file from directory");
File dir = new File("menuworlds");
if (dir.exists()) {
MenuWorldItem world = getRandomWorldFromList(getWorldsInDirectory(dir));
diff --git a/common/src/main/java/org/vivecraft/client_vr/menuworlds/MenuWorldExporter.java b/common/src/main/java/org/vivecraft/client_vr/menuworlds/MenuWorldExporter.java
index 1fa26f25e..4754783b0 100644
--- a/common/src/main/java/org/vivecraft/client_vr/menuworlds/MenuWorldExporter.java
+++ b/common/src/main/java/org/vivecraft/client_vr/menuworlds/MenuWorldExporter.java
@@ -1,30 +1,13 @@
package org.vivecraft.client_vr.menuworlds;
-import com.google.common.io.Files;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Optional;
-import java.util.OptionalLong;
-import java.util.zip.DataFormatException;
-import java.util.zip.Deflater;
-import java.util.zip.Inflater;
+import org.vivecraft.client.Xplat;
-import org.vivecraft.client_vr.settings.VRSettings;
+import com.google.common.io.Files;
import com.mojang.datafixers.DataFixer;
import com.mojang.serialization.Dynamic;
+
import net.minecraft.SharedConstants;
-import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.core.BlockPos;
import net.minecraft.core.RegistryAccess;
@@ -46,15 +29,26 @@
import net.minecraft.util.valueproviders.ConstantInt;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LightLayer;
-import net.minecraft.world.level.biome.AmbientParticleSettings;
-import net.minecraft.world.level.biome.Biome;
-import net.minecraft.world.level.biome.BiomeGenerationSettings;
-import net.minecraft.world.level.biome.BiomeSpecialEffects;
-import net.minecraft.world.level.biome.MobSpawnSettings;
+import net.minecraft.world.level.biome.*;
+import net.minecraft.world.level.biome.Biome.BiomeBuilder;
+import net.minecraft.world.level.biome.Biome.ClimateSettings;
+import net.minecraft.world.level.biome.Biome.TemperatureModifier;
+import net.minecraft.world.level.biome.BiomeGenerationSettings.PlainBuilder;
+import net.minecraft.world.level.biome.BiomeSpecialEffects.Builder;
+import net.minecraft.world.level.biome.BiomeSpecialEffects.GrassColorModifier;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.dimension.BuiltinDimensionTypes;
import net.minecraft.world.level.dimension.DimensionType;
-import org.vivecraft.client.Xplat;
+import net.minecraft.world.level.dimension.DimensionType.MonsterSettings;
+
+import java.io.*;
+import java.util.*;
+import java.util.zip.DataFormatException;
+import java.util.zip.Deflater;
+import java.util.zip.Inflater;
+
+import static org.vivecraft.client_vr.VRState.mc;
+import static org.vivecraft.common.utils.Utils.logger;
public class MenuWorldExporter {
public static final int VERSION = 5;
@@ -123,15 +117,15 @@ public static byte[] saveArea(Level level, int xMin, int zMin, int xSize, int zS
dos.writeInt(level.dimensionType().minY());
dos.writeFloat(level.dimensionType().ambientLight());
- dos.writeFloat(switch (Minecraft.getInstance().player.getDirection()) {
- case SOUTH -> 180.0f;
- case WEST -> -90.0f;
- case EAST -> 90.0f;
- default -> 0.0f; // also NORTH
+ dos.writeFloat(switch (mc.player.getDirection()) {
+ case SOUTH -> 180.0F;
+ case WEST -> -90.0F;
+ case EAST -> 90.0F;
+ default -> 0.0F; // also NORTH
});
- dos.writeBoolean(level.getRainLevel(1.0f) > 0.0f);
- dos.writeBoolean(level.getThunderLevel(1.0f) > 0.0f);
+ dos.writeBoolean(level.getRainLevel(1.0F) > 0.0F);
+ dos.writeBoolean(level.getThunderLevel(1.0F) > 0.0F);
blockStateMapper.writePalette(dos);
biomeMapper.writePalette(dos, level.registryAccess());
@@ -211,7 +205,7 @@ public static FakeBlockAccess loadWorld(byte[] data) throws IOException, DataFor
boolean isFlat;
if (header.version < 4) // old format
- isFlat = dis.readUTF().equals("flat");
+ isFlat = "flat".equals(dis.readUTF());
else
isFlat = dis.readBoolean();
@@ -232,7 +226,7 @@ else if (header.version == 4)
dataVersion = dis.readInt(); // v5+ stores the real data version
if (dataVersion > SharedConstants.getCurrentVersion().getDataVersion().getVersion())
- VRSettings.logger.warn("Data version is newer than current, this menu world may not load correctly.");
+ logger.warn("Data version is newer than current, this menu world may not load correctly.");
OptionalLong dimFixedTime = OptionalLong.empty();
boolean dimHasCeiling;
@@ -244,16 +238,16 @@ else if (header.version == 4)
dimFixedTime = OptionalLong.of(18000L);
dimHasCeiling = true;
dimMinY = 0;
- dimAmbientLight = 0.1f;
+ dimAmbientLight = 0.1F;
} else if (BuiltinDimensionTypes.END_EFFECTS.equals(dimName)) {
dimFixedTime = OptionalLong.of(6000L);
dimHasCeiling = false;
dimMinY = 0;
- dimAmbientLight = 0.0f;
+ dimAmbientLight = 0.0F;
} else { // overworld/default
dimHasCeiling = false;
dimMinY = 0; // pre-v5 worlds don't have deeper underground
- dimAmbientLight = 0.0f;
+ dimAmbientLight = 0.0F;
}
} else {
if (dis.readBoolean())
@@ -263,9 +257,9 @@ else if (header.version == 4)
dimAmbientLight = dis.readFloat();
}
- DimensionType dimensionType = new DimensionType(dimFixedTime, dimHasSkyLight, dimHasCeiling, false, false, 1.0, true, false, dimMinY, ySize, ySize, BlockTags.INFINIBURN_OVERWORLD, dimName, dimAmbientLight, new DimensionType.MonsterSettings(false, false, ConstantInt.of(0), 0));
+ DimensionType dimensionType = new DimensionType(dimFixedTime, dimHasSkyLight, dimHasCeiling, false, false, 1.0, true, false, dimMinY, ySize, ySize, BlockTags.INFINIBURN_OVERWORLD, dimName, dimAmbientLight, new MonsterSettings(false, false, ConstantInt.of(0), 0));
- float rotation = 0.0f;
+ float rotation = 0.0F;
boolean rain = false;
boolean thunder = false;
@@ -355,7 +349,7 @@ public static int readVersion(File file) throws IOException {
}
private static Optional decodeEnum(Class type, String input) {
- return Arrays.stream(type.getEnumConstants()).filter(e -> input.equals(((StringRepresentable)e).getSerializedName())).findFirst();
+ return Arrays.stream(type.getEnumConstants()).filter(e -> input.equals(e.getSerializedName())).findFirst();
}
public static class Header {
@@ -416,7 +410,7 @@ private interface BiomeMapper {
Biome getBiome(int id);
}
- private static final BiomeGenerationSettings dummyGenerationSettings = new BiomeGenerationSettings.PlainBuilder().build();
+ private static final BiomeGenerationSettings dummyGenerationSettings = new PlainBuilder().build();
private static final MobSpawnSettings dummyMobSpawnSettings = new MobSpawnSettings.Builder().build();
private static class PaletteBiomeMapper implements BiomeMapper {
@@ -441,16 +435,16 @@ void readPalette(DataInputStream dis) throws IOException {
int size = dis.readInt();
for (int i = 0; i < size; i++) {
- Biome.BiomeBuilder builder = new Biome.BiomeBuilder();
+ BiomeBuilder builder = new BiomeBuilder();
dis.readUTF(); // registry key, not actually used though, just for reference
builder.hasPrecipitation(dis.readBoolean());
builder.temperature(dis.readFloat());
- decodeEnum(Biome.TemperatureModifier.class, dis.readUTF()).ifPresent(builder::temperatureAdjustment);
+ decodeEnum(TemperatureModifier.class, dis.readUTF()).ifPresent(builder::temperatureAdjustment);
builder.downfall(dis.readFloat());
- BiomeSpecialEffects.Builder effectsBuilder = new BiomeSpecialEffects.Builder();
+ Builder effectsBuilder = new Builder();
effectsBuilder.fogColor(dis.readInt());
effectsBuilder.waterColor(dis.readInt());
effectsBuilder.waterFogColor(dis.readInt());
@@ -462,7 +456,7 @@ void readPalette(DataInputStream dis) throws IOException {
if (dis.readBoolean())
effectsBuilder.grassColorOverride(dis.readInt());
- decodeEnum(BiomeSpecialEffects.GrassColorModifier.class, dis.readUTF()).ifPresent(effectsBuilder::grassColorModifier);
+ decodeEnum(GrassColorModifier.class, dis.readUTF()).ifPresent(effectsBuilder::grassColorModifier);
if (dis.readBoolean()) {
ParticleType> particleType = BuiltInRegistries.PARTICLE_TYPE.get(new ResourceLocation(dis.readUTF()));
@@ -484,7 +478,7 @@ void writePalette(DataOutputStream dos, RegistryAccess registryAccess) throws IO
dos.writeUTF(registryAccess.registryOrThrow(Registries.BIOME).getKey(biome).toString());
- Biome.ClimateSettings climateSettings = Xplat.getBiomeClimateSettings(biome);
+ ClimateSettings climateSettings = Xplat.getBiomeClimateSettings(biome);
dos.writeBoolean(climateSettings.hasPrecipitation());
dos.writeFloat(climateSettings.temperature());
@@ -526,163 +520,163 @@ private static class LegacyBiomeMapper implements BiomeMapper {
//map.put(0, new Biome.BiomeBuilder().hasPrecipitation(true).temperature(1).temperatureAdjustment(Biome.TemperatureModifier.NONE).downfall(1).specialEffects(new BiomeSpecialEffects.Builder().fogColor(1).waterColor(1).waterFogColor(1).skyColor(1).foliageColorOverride(1).grassColorOverride(1).grassColorModifier(BiomeSpecialEffects.GrassColorModifier.NONE).ambientParticle(new AmbientParticleSettings((ParticleOptions)BuiltInRegistries.PARTICLE_TYPE.get(new ResourceLocation("")), 0)).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// plains
- map.put(1, new Biome.BiomeBuilder().hasPrecipitation(true).temperature(0.800000f).downfall(0.400000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7907327).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(1, new BiomeBuilder().hasPrecipitation(true).temperature(0.800000F).downfall(0.400000F).specialEffects(new Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7907327).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// the_void
- map.put(127, new Biome.BiomeBuilder().hasPrecipitation(false).temperature(0.500000f).downfall(0.500000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(8103167).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(127, new BiomeBuilder().hasPrecipitation(false).temperature(0.500000F).downfall(0.500000F).specialEffects(new Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(8103167).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// ocean
- map.put(0, new Biome.BiomeBuilder().hasPrecipitation(true).temperature(0.500000f).downfall(0.500000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(8103167).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(0, new BiomeBuilder().hasPrecipitation(true).temperature(0.500000F).downfall(0.500000F).specialEffects(new Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(8103167).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// desert
- map.put(2, new Biome.BiomeBuilder().hasPrecipitation(false).temperature(2.000000f).downfall(0.000000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7254527).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(2, new BiomeBuilder().hasPrecipitation(false).temperature(2.000000F).downfall(0.000000F).specialEffects(new Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7254527).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// mountains
- map.put(3, new Biome.BiomeBuilder().hasPrecipitation(true).temperature(0.200000f).downfall(0.300000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(8233727).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(3, new BiomeBuilder().hasPrecipitation(true).temperature(0.200000F).downfall(0.300000F).specialEffects(new Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(8233727).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// forest
- map.put(4, new Biome.BiomeBuilder().hasPrecipitation(true).temperature(0.700000f).downfall(0.800000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7972607).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(4, new BiomeBuilder().hasPrecipitation(true).temperature(0.700000F).downfall(0.800000F).specialEffects(new Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7972607).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// taiga
- map.put(5, new Biome.BiomeBuilder().hasPrecipitation(true).temperature(0.250000f).downfall(0.800000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(8233983).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(5, new BiomeBuilder().hasPrecipitation(true).temperature(0.250000F).downfall(0.800000F).specialEffects(new Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(8233983).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// swamp
- map.put(6, new Biome.BiomeBuilder().hasPrecipitation(true).temperature(0.800000f).downfall(0.900000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(6388580).waterFogColor(2302743).skyColor(7907327).foliageColorOverride(6975545).grassColorModifier(BiomeSpecialEffects.GrassColorModifier.SWAMP).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(6, new BiomeBuilder().hasPrecipitation(true).temperature(0.800000F).downfall(0.900000F).specialEffects(new Builder().fogColor(12638463).waterColor(6388580).waterFogColor(2302743).skyColor(7907327).foliageColorOverride(6975545).grassColorModifier(GrassColorModifier.SWAMP).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// river
- map.put(7, new Biome.BiomeBuilder().hasPrecipitation(true).temperature(0.500000f).downfall(0.500000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(8103167).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(7, new BiomeBuilder().hasPrecipitation(true).temperature(0.500000F).downfall(0.500000F).specialEffects(new Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(8103167).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// nether_wastes
- map.put(8, new Biome.BiomeBuilder().hasPrecipitation(false).temperature(2.000000f).downfall(0.000000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(3344392).waterColor(4159204).waterFogColor(329011).skyColor(7254527).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(8, new BiomeBuilder().hasPrecipitation(false).temperature(2.000000F).downfall(0.000000F).specialEffects(new Builder().fogColor(3344392).waterColor(4159204).waterFogColor(329011).skyColor(7254527).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// the_end
- map.put(9, new Biome.BiomeBuilder().hasPrecipitation(false).temperature(0.500000f).downfall(0.500000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(10518688).waterColor(4159204).waterFogColor(329011).skyColor(0).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(9, new BiomeBuilder().hasPrecipitation(false).temperature(0.500000F).downfall(0.500000F).specialEffects(new Builder().fogColor(10518688).waterColor(4159204).waterFogColor(329011).skyColor(0).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// frozen_ocean
- map.put(10, new Biome.BiomeBuilder().hasPrecipitation(true).temperature(0.000000f).downfall(0.500000f).temperatureAdjustment(Biome.TemperatureModifier.FROZEN).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(3750089).waterFogColor(329011).skyColor(8364543).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(10, new BiomeBuilder().hasPrecipitation(true).temperature(0.000000F).downfall(0.500000F).temperatureAdjustment(TemperatureModifier.FROZEN).specialEffects(new Builder().fogColor(12638463).waterColor(3750089).waterFogColor(329011).skyColor(8364543).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// frozen_river
- map.put(11, new Biome.BiomeBuilder().hasPrecipitation(true).temperature(0.000000f).downfall(0.500000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(3750089).waterFogColor(329011).skyColor(8364543).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(11, new BiomeBuilder().hasPrecipitation(true).temperature(0.000000F).downfall(0.500000F).specialEffects(new Builder().fogColor(12638463).waterColor(3750089).waterFogColor(329011).skyColor(8364543).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// snowy_tundra
- map.put(12, new Biome.BiomeBuilder().hasPrecipitation(true).temperature(0.000000f).downfall(0.500000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(8364543).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(12, new BiomeBuilder().hasPrecipitation(true).temperature(0.000000F).downfall(0.500000F).specialEffects(new Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(8364543).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// snowy_mountains
- map.put(13, new Biome.BiomeBuilder().hasPrecipitation(true).temperature(0.000000f).downfall(0.500000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(8364543).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(13, new BiomeBuilder().hasPrecipitation(true).temperature(0.000000F).downfall(0.500000F).specialEffects(new Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(8364543).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// mushroom_fields
- map.put(14, new Biome.BiomeBuilder().hasPrecipitation(true).temperature(0.900000f).downfall(1.000000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7842047).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(14, new BiomeBuilder().hasPrecipitation(true).temperature(0.900000F).downfall(1.000000F).specialEffects(new Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7842047).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// mushroom_field_shore
- map.put(15, new Biome.BiomeBuilder().hasPrecipitation(true).temperature(0.900000f).downfall(1.000000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7842047).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(15, new BiomeBuilder().hasPrecipitation(true).temperature(0.900000F).downfall(1.000000F).specialEffects(new Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7842047).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// beach
- map.put(16, new Biome.BiomeBuilder().hasPrecipitation(true).temperature(0.800000f).downfall(0.400000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7907327).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(16, new BiomeBuilder().hasPrecipitation(true).temperature(0.800000F).downfall(0.400000F).specialEffects(new Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7907327).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// desert_hills
- map.put(17, new Biome.BiomeBuilder().hasPrecipitation(false).temperature(2.000000f).downfall(0.000000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7254527).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(17, new BiomeBuilder().hasPrecipitation(false).temperature(2.000000F).downfall(0.000000F).specialEffects(new Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7254527).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// wooded_hills
- map.put(18, new Biome.BiomeBuilder().hasPrecipitation(true).temperature(0.700000f).downfall(0.800000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7972607).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(18, new BiomeBuilder().hasPrecipitation(true).temperature(0.700000F).downfall(0.800000F).specialEffects(new Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7972607).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// taiga_hills
- map.put(19, new Biome.BiomeBuilder().hasPrecipitation(true).temperature(0.250000f).downfall(0.800000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(8233983).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(19, new BiomeBuilder().hasPrecipitation(true).temperature(0.250000F).downfall(0.800000F).specialEffects(new Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(8233983).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// mountain_edge
- map.put(20, new Biome.BiomeBuilder().hasPrecipitation(true).temperature(0.200000f).downfall(0.300000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(8233727).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(20, new BiomeBuilder().hasPrecipitation(true).temperature(0.200000F).downfall(0.300000F).specialEffects(new Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(8233727).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// jungle
- map.put(21, new Biome.BiomeBuilder().hasPrecipitation(true).temperature(0.950000f).downfall(0.900000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7842047).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(21, new BiomeBuilder().hasPrecipitation(true).temperature(0.950000F).downfall(0.900000F).specialEffects(new Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7842047).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// jungle_hills
- map.put(22, new Biome.BiomeBuilder().hasPrecipitation(true).temperature(0.950000f).downfall(0.900000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7842047).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(22, new BiomeBuilder().hasPrecipitation(true).temperature(0.950000F).downfall(0.900000F).specialEffects(new Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7842047).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// jungle_edge
- map.put(23, new Biome.BiomeBuilder().hasPrecipitation(true).temperature(0.950000f).downfall(0.800000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7842047).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(23, new BiomeBuilder().hasPrecipitation(true).temperature(0.950000F).downfall(0.800000F).specialEffects(new Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7842047).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// deep_ocean
- map.put(24, new Biome.BiomeBuilder().hasPrecipitation(true).temperature(0.500000f).downfall(0.500000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(8103167).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(24, new BiomeBuilder().hasPrecipitation(true).temperature(0.500000F).downfall(0.500000F).specialEffects(new Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(8103167).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// stone_shore
- map.put(25, new Biome.BiomeBuilder().hasPrecipitation(true).temperature(0.200000f).downfall(0.300000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(8233727).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(25, new BiomeBuilder().hasPrecipitation(true).temperature(0.200000F).downfall(0.300000F).specialEffects(new Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(8233727).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// snowy_beach
- map.put(26, new Biome.BiomeBuilder().hasPrecipitation(true).temperature(0.050000f).downfall(0.300000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4020182).waterFogColor(329011).skyColor(8364543).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(26, new BiomeBuilder().hasPrecipitation(true).temperature(0.050000F).downfall(0.300000F).specialEffects(new Builder().fogColor(12638463).waterColor(4020182).waterFogColor(329011).skyColor(8364543).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// birch_forest
- map.put(27, new Biome.BiomeBuilder().hasPrecipitation(true).temperature(0.600000f).downfall(0.600000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(8037887).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(27, new BiomeBuilder().hasPrecipitation(true).temperature(0.600000F).downfall(0.600000F).specialEffects(new Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(8037887).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// birch_forest_hills
- map.put(28, new Biome.BiomeBuilder().hasPrecipitation(true).temperature(0.600000f).downfall(0.600000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(8037887).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(28, new BiomeBuilder().hasPrecipitation(true).temperature(0.600000F).downfall(0.600000F).specialEffects(new Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(8037887).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// dark_forest
- map.put(29, new Biome.BiomeBuilder().hasPrecipitation(true).temperature(0.700000f).downfall(0.800000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7972607).grassColorModifier(BiomeSpecialEffects.GrassColorModifier.DARK_FOREST).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(29, new BiomeBuilder().hasPrecipitation(true).temperature(0.700000F).downfall(0.800000F).specialEffects(new Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7972607).grassColorModifier(GrassColorModifier.DARK_FOREST).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// snowy_taiga
- map.put(30, new Biome.BiomeBuilder().hasPrecipitation(true).temperature(-0.500000f).downfall(0.400000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4020182).waterFogColor(329011).skyColor(8625919).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(30, new BiomeBuilder().hasPrecipitation(true).temperature(-0.500000F).downfall(0.400000F).specialEffects(new Builder().fogColor(12638463).waterColor(4020182).waterFogColor(329011).skyColor(8625919).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// snowy_taiga_hills
- map.put(31, new Biome.BiomeBuilder().hasPrecipitation(true).temperature(-0.500000f).downfall(0.400000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4020182).waterFogColor(329011).skyColor(8625919).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(31, new BiomeBuilder().hasPrecipitation(true).temperature(-0.500000F).downfall(0.400000F).specialEffects(new Builder().fogColor(12638463).waterColor(4020182).waterFogColor(329011).skyColor(8625919).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// giant_tree_taiga
- map.put(32, new Biome.BiomeBuilder().hasPrecipitation(true).temperature(0.300000f).downfall(0.800000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(8168447).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(32, new BiomeBuilder().hasPrecipitation(true).temperature(0.300000F).downfall(0.800000F).specialEffects(new Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(8168447).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// giant_tree_taiga_hills
- map.put(33, new Biome.BiomeBuilder().hasPrecipitation(true).temperature(0.300000f).downfall(0.800000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(8168447).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(33, new BiomeBuilder().hasPrecipitation(true).temperature(0.300000F).downfall(0.800000F).specialEffects(new Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(8168447).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// wooded_mountains
- map.put(34, new Biome.BiomeBuilder().hasPrecipitation(true).temperature(0.200000f).downfall(0.300000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(8233727).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(34, new BiomeBuilder().hasPrecipitation(true).temperature(0.200000F).downfall(0.300000F).specialEffects(new Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(8233727).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// savanna
- map.put(35, new Biome.BiomeBuilder().hasPrecipitation(false).temperature(1.200000f).downfall(0.000000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7711487).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(35, new BiomeBuilder().hasPrecipitation(false).temperature(1.200000F).downfall(0.000000F).specialEffects(new Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7711487).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// savanna_plateau
- map.put(36, new Biome.BiomeBuilder().hasPrecipitation(false).temperature(1.000000f).downfall(0.000000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7776511).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(36, new BiomeBuilder().hasPrecipitation(false).temperature(1.000000F).downfall(0.000000F).specialEffects(new Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7776511).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// badlands
- map.put(37, new Biome.BiomeBuilder().hasPrecipitation(false).temperature(2.000000f).downfall(0.000000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7254527).foliageColorOverride(10387789).grassColorOverride(9470285).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(37, new BiomeBuilder().hasPrecipitation(false).temperature(2.000000F).downfall(0.000000F).specialEffects(new Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7254527).foliageColorOverride(10387789).grassColorOverride(9470285).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// wooded_badlands_plateau
- map.put(38, new Biome.BiomeBuilder().hasPrecipitation(false).temperature(2.000000f).downfall(0.000000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7254527).foliageColorOverride(10387789).grassColorOverride(9470285).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(38, new BiomeBuilder().hasPrecipitation(false).temperature(2.000000F).downfall(0.000000F).specialEffects(new Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7254527).foliageColorOverride(10387789).grassColorOverride(9470285).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// badlands_plateau
- map.put(39, new Biome.BiomeBuilder().hasPrecipitation(false).temperature(2.000000f).downfall(0.000000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7254527).foliageColorOverride(10387789).grassColorOverride(9470285).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(39, new BiomeBuilder().hasPrecipitation(false).temperature(2.000000F).downfall(0.000000F).specialEffects(new Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7254527).foliageColorOverride(10387789).grassColorOverride(9470285).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// small_end_islands
- map.put(40, new Biome.BiomeBuilder().hasPrecipitation(false).temperature(0.500000f).downfall(0.500000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(10518688).waterColor(4159204).waterFogColor(329011).skyColor(0).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(40, new BiomeBuilder().hasPrecipitation(false).temperature(0.500000F).downfall(0.500000F).specialEffects(new Builder().fogColor(10518688).waterColor(4159204).waterFogColor(329011).skyColor(0).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// end_midlands
- map.put(41, new Biome.BiomeBuilder().hasPrecipitation(false).temperature(0.500000f).downfall(0.500000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(10518688).waterColor(4159204).waterFogColor(329011).skyColor(0).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(41, new BiomeBuilder().hasPrecipitation(false).temperature(0.500000F).downfall(0.500000F).specialEffects(new Builder().fogColor(10518688).waterColor(4159204).waterFogColor(329011).skyColor(0).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// end_highlands
- map.put(42, new Biome.BiomeBuilder().hasPrecipitation(false).temperature(0.500000f).downfall(0.500000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(10518688).waterColor(4159204).waterFogColor(329011).skyColor(0).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(42, new BiomeBuilder().hasPrecipitation(false).temperature(0.500000F).downfall(0.500000F).specialEffects(new Builder().fogColor(10518688).waterColor(4159204).waterFogColor(329011).skyColor(0).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// end_barrens
- map.put(43, new Biome.BiomeBuilder().hasPrecipitation(false).temperature(0.500000f).downfall(0.500000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(10518688).waterColor(4159204).waterFogColor(329011).skyColor(0).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(43, new BiomeBuilder().hasPrecipitation(false).temperature(0.500000F).downfall(0.500000F).specialEffects(new Builder().fogColor(10518688).waterColor(4159204).waterFogColor(329011).skyColor(0).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// warm_ocean
- map.put(44, new Biome.BiomeBuilder().hasPrecipitation(true).temperature(0.500000f).downfall(0.500000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4445678).waterFogColor(270131).skyColor(8103167).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(44, new BiomeBuilder().hasPrecipitation(true).temperature(0.500000F).downfall(0.500000F).specialEffects(new Builder().fogColor(12638463).waterColor(4445678).waterFogColor(270131).skyColor(8103167).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// lukewarm_ocean
- map.put(45, new Biome.BiomeBuilder().hasPrecipitation(true).temperature(0.500000f).downfall(0.500000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4566514).waterFogColor(267827).skyColor(8103167).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(45, new BiomeBuilder().hasPrecipitation(true).temperature(0.500000F).downfall(0.500000F).specialEffects(new Builder().fogColor(12638463).waterColor(4566514).waterFogColor(267827).skyColor(8103167).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// cold_ocean
- map.put(46, new Biome.BiomeBuilder().hasPrecipitation(true).temperature(0.500000f).downfall(0.500000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4020182).waterFogColor(329011).skyColor(8103167).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(46, new BiomeBuilder().hasPrecipitation(true).temperature(0.500000F).downfall(0.500000F).specialEffects(new Builder().fogColor(12638463).waterColor(4020182).waterFogColor(329011).skyColor(8103167).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// deep_warm_ocean
- map.put(47, new Biome.BiomeBuilder().hasPrecipitation(true).temperature(0.500000f).downfall(0.500000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4445678).waterFogColor(270131).skyColor(8103167).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(47, new BiomeBuilder().hasPrecipitation(true).temperature(0.500000F).downfall(0.500000F).specialEffects(new Builder().fogColor(12638463).waterColor(4445678).waterFogColor(270131).skyColor(8103167).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// deep_lukewarm_ocean
- map.put(48, new Biome.BiomeBuilder().hasPrecipitation(true).temperature(0.500000f).downfall(0.500000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4566514).waterFogColor(267827).skyColor(8103167).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(48, new BiomeBuilder().hasPrecipitation(true).temperature(0.500000F).downfall(0.500000F).specialEffects(new Builder().fogColor(12638463).waterColor(4566514).waterFogColor(267827).skyColor(8103167).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// deep_cold_ocean
- map.put(49, new Biome.BiomeBuilder().hasPrecipitation(true).temperature(0.500000f).downfall(0.500000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4020182).waterFogColor(329011).skyColor(8103167).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(49, new BiomeBuilder().hasPrecipitation(true).temperature(0.500000F).downfall(0.500000F).specialEffects(new Builder().fogColor(12638463).waterColor(4020182).waterFogColor(329011).skyColor(8103167).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// deep_frozen_ocean
- map.put(50, new Biome.BiomeBuilder().hasPrecipitation(true).temperature(0.500000f).downfall(0.500000f).temperatureAdjustment(Biome.TemperatureModifier.FROZEN).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(3750089).waterFogColor(329011).skyColor(8103167).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(50, new BiomeBuilder().hasPrecipitation(true).temperature(0.500000F).downfall(0.500000F).temperatureAdjustment(TemperatureModifier.FROZEN).specialEffects(new Builder().fogColor(12638463).waterColor(3750089).waterFogColor(329011).skyColor(8103167).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// sunflower_plains
- map.put(129, new Biome.BiomeBuilder().hasPrecipitation(true).temperature(0.800000f).downfall(0.400000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7907327).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(129, new BiomeBuilder().hasPrecipitation(true).temperature(0.800000F).downfall(0.400000F).specialEffects(new Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7907327).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// desert_lakes
- map.put(130, new Biome.BiomeBuilder().hasPrecipitation(false).temperature(2.000000f).downfall(0.000000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7254527).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(130, new BiomeBuilder().hasPrecipitation(false).temperature(2.000000F).downfall(0.000000F).specialEffects(new Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7254527).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// gravelly_mountains
- map.put(131, new Biome.BiomeBuilder().hasPrecipitation(true).temperature(0.200000f).downfall(0.300000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(8233727).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(131, new BiomeBuilder().hasPrecipitation(true).temperature(0.200000F).downfall(0.300000F).specialEffects(new Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(8233727).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// flower_forest
- map.put(132, new Biome.BiomeBuilder().hasPrecipitation(true).temperature(0.700000f).downfall(0.800000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7972607).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(132, new BiomeBuilder().hasPrecipitation(true).temperature(0.700000F).downfall(0.800000F).specialEffects(new Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7972607).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// taiga_mountains
- map.put(133, new Biome.BiomeBuilder().hasPrecipitation(true).temperature(0.250000f).downfall(0.800000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(8233983).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(133, new BiomeBuilder().hasPrecipitation(true).temperature(0.250000F).downfall(0.800000F).specialEffects(new Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(8233983).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// swamp_hills
- map.put(134, new Biome.BiomeBuilder().hasPrecipitation(true).temperature(0.800000f).downfall(0.900000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(6388580).waterFogColor(2302743).skyColor(7907327).foliageColorOverride(6975545).grassColorModifier(BiomeSpecialEffects.GrassColorModifier.SWAMP).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(134, new BiomeBuilder().hasPrecipitation(true).temperature(0.800000F).downfall(0.900000F).specialEffects(new Builder().fogColor(12638463).waterColor(6388580).waterFogColor(2302743).skyColor(7907327).foliageColorOverride(6975545).grassColorModifier(GrassColorModifier.SWAMP).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// ice_spikes
- map.put(140, new Biome.BiomeBuilder().hasPrecipitation(true).temperature(0.000000f).downfall(0.500000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(8364543).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(140, new BiomeBuilder().hasPrecipitation(true).temperature(0.000000F).downfall(0.500000F).specialEffects(new Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(8364543).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// modified_jungle
- map.put(149, new Biome.BiomeBuilder().hasPrecipitation(true).temperature(0.950000f).downfall(0.900000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7842047).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(149, new BiomeBuilder().hasPrecipitation(true).temperature(0.950000F).downfall(0.900000F).specialEffects(new Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7842047).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// modified_jungle_edge
- map.put(151, new Biome.BiomeBuilder().hasPrecipitation(true).temperature(0.950000f).downfall(0.800000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7842047).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(151, new BiomeBuilder().hasPrecipitation(true).temperature(0.950000F).downfall(0.800000F).specialEffects(new Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7842047).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// tall_birch_forest
- map.put(155, new Biome.BiomeBuilder().hasPrecipitation(true).temperature(0.600000f).downfall(0.600000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(8037887).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(155, new BiomeBuilder().hasPrecipitation(true).temperature(0.600000F).downfall(0.600000F).specialEffects(new Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(8037887).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// tall_birch_hills
- map.put(156, new Biome.BiomeBuilder().hasPrecipitation(true).temperature(0.600000f).downfall(0.600000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(8037887).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(156, new BiomeBuilder().hasPrecipitation(true).temperature(0.600000F).downfall(0.600000F).specialEffects(new Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(8037887).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// dark_forest_hills
- map.put(157, new Biome.BiomeBuilder().hasPrecipitation(true).temperature(0.700000f).downfall(0.800000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7972607).grassColorModifier(BiomeSpecialEffects.GrassColorModifier.DARK_FOREST).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(157, new BiomeBuilder().hasPrecipitation(true).temperature(0.700000F).downfall(0.800000F).specialEffects(new Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7972607).grassColorModifier(GrassColorModifier.DARK_FOREST).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// snowy_taiga_mountains
- map.put(158, new Biome.BiomeBuilder().hasPrecipitation(true).temperature(-0.500000f).downfall(0.400000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4020182).waterFogColor(329011).skyColor(8625919).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(158, new BiomeBuilder().hasPrecipitation(true).temperature(-0.500000F).downfall(0.400000F).specialEffects(new Builder().fogColor(12638463).waterColor(4020182).waterFogColor(329011).skyColor(8625919).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// giant_spruce_taiga
- map.put(160, new Biome.BiomeBuilder().hasPrecipitation(true).temperature(0.250000f).downfall(0.800000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(8233983).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(160, new BiomeBuilder().hasPrecipitation(true).temperature(0.250000F).downfall(0.800000F).specialEffects(new Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(8233983).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// giant_spruce_taiga_hills
- map.put(161, new Biome.BiomeBuilder().hasPrecipitation(true).temperature(0.250000f).downfall(0.800000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(8233983).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(161, new BiomeBuilder().hasPrecipitation(true).temperature(0.250000F).downfall(0.800000F).specialEffects(new Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(8233983).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// modified_gravelly_mountains
- map.put(162, new Biome.BiomeBuilder().hasPrecipitation(true).temperature(0.200000f).downfall(0.300000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(8233727).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(162, new BiomeBuilder().hasPrecipitation(true).temperature(0.200000F).downfall(0.300000F).specialEffects(new Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(8233727).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// shattered_savanna
- map.put(163, new Biome.BiomeBuilder().hasPrecipitation(false).temperature(1.100000f).downfall(0.000000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7776767).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(163, new BiomeBuilder().hasPrecipitation(false).temperature(1.100000F).downfall(0.000000F).specialEffects(new Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7776767).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// shattered_savanna_plateau
- map.put(164, new Biome.BiomeBuilder().hasPrecipitation(false).temperature(1.000000f).downfall(0.000000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7776511).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(164, new BiomeBuilder().hasPrecipitation(false).temperature(1.000000F).downfall(0.000000F).specialEffects(new Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7776511).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// eroded_badlands
- map.put(165, new Biome.BiomeBuilder().hasPrecipitation(false).temperature(2.000000f).downfall(0.000000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7254527).foliageColorOverride(10387789).grassColorOverride(9470285).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(165, new BiomeBuilder().hasPrecipitation(false).temperature(2.000000F).downfall(0.000000F).specialEffects(new Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7254527).foliageColorOverride(10387789).grassColorOverride(9470285).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// modified_wooded_badlands_plateau
- map.put(166, new Biome.BiomeBuilder().hasPrecipitation(false).temperature(2.000000f).downfall(0.000000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7254527).foliageColorOverride(10387789).grassColorOverride(9470285).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(166, new BiomeBuilder().hasPrecipitation(false).temperature(2.000000F).downfall(0.000000F).specialEffects(new Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7254527).foliageColorOverride(10387789).grassColorOverride(9470285).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// modified_badlands_plateau
- map.put(167, new Biome.BiomeBuilder().hasPrecipitation(false).temperature(2.000000f).downfall(0.000000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7254527).foliageColorOverride(10387789).grassColorOverride(9470285).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(167, new BiomeBuilder().hasPrecipitation(false).temperature(2.000000F).downfall(0.000000F).specialEffects(new Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7254527).foliageColorOverride(10387789).grassColorOverride(9470285).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// bamboo_jungle
- map.put(168, new Biome.BiomeBuilder().hasPrecipitation(true).temperature(0.950000f).downfall(0.900000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7842047).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(168, new BiomeBuilder().hasPrecipitation(true).temperature(0.950000F).downfall(0.900000F).specialEffects(new Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7842047).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// bamboo_jungle_hills
- map.put(169, new Biome.BiomeBuilder().hasPrecipitation(true).temperature(0.950000f).downfall(0.900000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7842047).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(169, new BiomeBuilder().hasPrecipitation(true).temperature(0.950000F).downfall(0.900000F).specialEffects(new Builder().fogColor(12638463).waterColor(4159204).waterFogColor(329011).skyColor(7842047).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// soul_sand_valley
- map.put(170, new Biome.BiomeBuilder().hasPrecipitation(false).temperature(2.000000f).downfall(0.000000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(1787717).waterColor(4159204).waterFogColor(329011).skyColor(7254527).ambientParticle(new AmbientParticleSettings((ParticleOptions)BuiltInRegistries.PARTICLE_TYPE.get(new ResourceLocation("minecraft:ash")), 0.006250f)).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(170, new BiomeBuilder().hasPrecipitation(false).temperature(2.000000F).downfall(0.000000F).specialEffects(new Builder().fogColor(1787717).waterColor(4159204).waterFogColor(329011).skyColor(7254527).ambientParticle(new AmbientParticleSettings((ParticleOptions)BuiltInRegistries.PARTICLE_TYPE.get(new ResourceLocation("minecraft:ash")), 0.006250F)).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// crimson_forest
- map.put(171, new Biome.BiomeBuilder().hasPrecipitation(false).temperature(2.000000f).downfall(0.000000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(3343107).waterColor(4159204).waterFogColor(329011).skyColor(7254527).ambientParticle(new AmbientParticleSettings((ParticleOptions)BuiltInRegistries.PARTICLE_TYPE.get(new ResourceLocation("minecraft:crimson_spore")), 0.025000f)).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(171, new BiomeBuilder().hasPrecipitation(false).temperature(2.000000F).downfall(0.000000F).specialEffects(new Builder().fogColor(3343107).waterColor(4159204).waterFogColor(329011).skyColor(7254527).ambientParticle(new AmbientParticleSettings((ParticleOptions)BuiltInRegistries.PARTICLE_TYPE.get(new ResourceLocation("minecraft:crimson_spore")), 0.025000F)).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// warped_forest
- map.put(172, new Biome.BiomeBuilder().hasPrecipitation(false).temperature(2.000000f).downfall(0.000000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(1705242).waterColor(4159204).waterFogColor(329011).skyColor(7254527).ambientParticle(new AmbientParticleSettings((ParticleOptions)BuiltInRegistries.PARTICLE_TYPE.get(new ResourceLocation("minecraft:warped_spore")), 0.014280f)).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(172, new BiomeBuilder().hasPrecipitation(false).temperature(2.000000F).downfall(0.000000F).specialEffects(new Builder().fogColor(1705242).waterColor(4159204).waterFogColor(329011).skyColor(7254527).ambientParticle(new AmbientParticleSettings((ParticleOptions)BuiltInRegistries.PARTICLE_TYPE.get(new ResourceLocation("minecraft:warped_spore")), 0.014280F)).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
// basalt_deltas
- map.put(173, new Biome.BiomeBuilder().hasPrecipitation(false).temperature(2.000000f).downfall(0.000000f).specialEffects(new BiomeSpecialEffects.Builder().fogColor(6840176).waterColor(4159204).waterFogColor(4341314).skyColor(7254527).ambientParticle(new AmbientParticleSettings((ParticleOptions)BuiltInRegistries.PARTICLE_TYPE.get(new ResourceLocation("minecraft:white_ash")), 0.118093f)).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
+ map.put(173, new BiomeBuilder().hasPrecipitation(false).temperature(2.000000F).downfall(0.000000F).specialEffects(new Builder().fogColor(6840176).waterColor(4159204).waterFogColor(4341314).skyColor(7254527).ambientParticle(new AmbientParticleSettings((ParticleOptions)BuiltInRegistries.PARTICLE_TYPE.get(new ResourceLocation("minecraft:white_ash")), 0.118093F)).build()).generationSettings(dummyGenerationSettings).mobSpawnSettings(dummyMobSpawnSettings).build());
}
private LegacyBiomeMapper() {
diff --git a/common/src/main/java/org/vivecraft/client_vr/menuworlds/MenuWorldRenderer.java b/common/src/main/java/org/vivecraft/client_vr/menuworlds/MenuWorldRenderer.java
index 79319a4c0..4c5cdc6a7 100644
--- a/common/src/main/java/org/vivecraft/client_vr/menuworlds/MenuWorldRenderer.java
+++ b/common/src/main/java/org/vivecraft/client_vr/menuworlds/MenuWorldRenderer.java
@@ -1,31 +1,49 @@
package org.vivecraft.client_vr.menuworlds;
-import com.mojang.blaze3d.platform.GlStateManager;
+import org.vivecraft.client.Xplat;
+import org.vivecraft.client_vr.settings.VRSettings.MenuWorld;
+import org.vivecraft.mod_compat_vr.optifine.OptifineHelper;
+import org.vivecraft.mod_compat_vr.sodium.SodiumHelper;
+
+import org.apache.commons.lang3.tuple.Pair;
+import org.joml.Matrix4f;
+import org.joml.Vector2f;
+import org.joml.Vector3f;
+import org.lwjgl.opengl.GL11C;
+
+import com.mojang.blaze3d.platform.GlStateManager.DestFactor;
+import com.mojang.blaze3d.platform.GlStateManager.SourceFactor;
import com.mojang.blaze3d.platform.NativeImage;
import com.mojang.blaze3d.shaders.FogShape;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.*;
-import com.mojang.math.Axis;
+import com.mojang.blaze3d.vertex.BufferBuilder.RenderedBuffer;
+import com.mojang.blaze3d.vertex.VertexBuffer.Usage;
+import com.mojang.blaze3d.vertex.VertexFormat.Mode;
+
import net.minecraft.Util;
import net.minecraft.client.CloudStatus;
import net.minecraft.client.GraphicsStatus;
-import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.*;
+import net.minecraft.client.renderer.DimensionSpecialEffects.SkyType;
+import net.minecraft.client.renderer.FogRenderer.FogMode;
import net.minecraft.client.renderer.block.BlockRenderDispatcher;
-import net.minecraft.client.renderer.texture.*;
+import net.minecraft.client.renderer.texture.DynamicTexture;
+import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.core.BlockPos;
+import net.minecraft.core.BlockPos.MutableBlockPos;
import net.minecraft.core.Holder;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.BiomeTags;
import net.minecraft.tags.FluidTags;
import net.minecraft.tags.TagKey;
import net.minecraft.util.CubicSampler;
-import net.minecraft.util.Mth;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.BlockAndTintGetter;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.LightLayer;
import net.minecraft.world.level.biome.Biome;
+import net.minecraft.world.level.biome.Biome.Precipitation;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.RenderShape;
import net.minecraft.world.level.block.state.BlockState;
@@ -35,15 +53,6 @@
import net.minecraft.world.level.material.Fluids;
import net.minecraft.world.level.material.FogType;
import net.minecraft.world.phys.Vec3;
-import org.apache.commons.lang3.tuple.Pair;
-import org.joml.Matrix4f;
-import org.joml.Vector3f;
-import org.lwjgl.opengl.GL11;
-import org.vivecraft.client.Xplat;
-import org.vivecraft.client_vr.ClientDataHolderVR;
-import org.vivecraft.client_vr.settings.VRSettings;
-import org.vivecraft.mod_compat_vr.optifine.OptifineHelper;
-import org.vivecraft.mod_compat_vr.sodium.SodiumHelper;
import java.io.InputStream;
import java.util.*;
@@ -51,6 +60,17 @@
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
+import static org.vivecraft.client_vr.VRState.dh;
+import static org.vivecraft.client_vr.VRState.mc;
+import static org.vivecraft.common.utils.Utils.logger;
+
+import static java.lang.Math.pow;
+import static org.joml.Math.*;
+import static org.joml.RoundingMode.FLOOR;
+import static org.joml.Vector2i.lengthSquared;
+
+import static net.minecraft.client.Minecraft.useFancyGraphics;
+
public class MenuWorldRenderer {
private static final ResourceLocation MOON_LOCATION = new ResourceLocation("textures/environment/moon_phases.png");
private static final ResourceLocation SUN_LOCATION = new ResourceLocation("textures/environment/sun.png");
@@ -63,11 +83,10 @@ public class MenuWorldRenderer {
private static final ResourceLocation SNOW_LOCATION = new ResourceLocation("textures/environment/snow.png");
- private Minecraft mc;
private DimensionSpecialEffects dimensionInfo;
private FakeBlockAccess blockAccess;
- private final DynamicTexture lightTexture;
- private final NativeImage lightPixels;
+ private final DynamicTexture lightTexture = new DynamicTexture(16, 16, false);
+ private final NativeImage lightPixels = this.lightTexture.getPixels();
private final ResourceLocation lightTextureLocation;
private boolean lightmapUpdateNeeded;
private float blockLightRedFlicker;
@@ -83,9 +102,9 @@ public class MenuWorldRenderer {
private VertexBuffer cloudVBO;
private int renderDistance;
private int renderDistanceChunks;
- public MenuFogRenderer fogRenderer;
+ public MenuFogRenderer fogRenderer = new MenuFogRenderer(this);
public Set visibleTextures = new HashSet<>();
- private Random rand;
+ private Random rand = new Random();
private boolean ready;
private CloudStatus prevCloudsType;
private int prevCloudX;
@@ -102,41 +121,36 @@ public class MenuWorldRenderer {
private final float[] rainSizeX = new float[1024];
private final float[] rainSizeZ = new float[1024];
- private Set animatedSprites = null;
+ private Set animatedSprites;
public MenuWorldRenderer() {
- this.mc = Minecraft.getInstance();
- this.lightTexture = new DynamicTexture(16, 16, false);
this.lightTextureLocation = mc.getTextureManager().register("vivecraft_light_map", this.lightTexture);
- this.lightPixels = this.lightTexture.getPixels();
- this.fogRenderer = new MenuFogRenderer(this);
- this.rand = new Random();
this.rand.nextInt(); // toss some bits in the bin
}
public void init() {
- if (ClientDataHolderVR.getInstance().vrSettings.menuWorldSelection == VRSettings.MenuWorld.NONE) {
- //VRSettings.logger.info("Main menu worlds disabled.");
+ if (dh.vrSettings.menuWorldSelection == MenuWorld.NONE) {
+ //logger.info("Main menu worlds disabled.");
return;
}
try {
InputStream inputStream = MenuWorldDownloader.getRandomWorld();
if (inputStream != null) {
- VRSettings.logger.info("MenuWorlds: Initializing main menu world renderer...");
+ logger.info("MenuWorlds: Initializing main menu world renderer...");
loadRenderers();
- VRSettings.logger.info("MenuWorlds: Loading world data...");
+ logger.info("MenuWorlds: Loading world data...");
setWorld(MenuWorldExporter.loadWorld(inputStream));
prepare();
fastTime = new Random().nextInt(10) == 0;
} else {
- VRSettings.logger.warn("Failed to load any main menu world, falling back to old menu room");
+ logger.warn("Failed to load any main menu world, falling back to old menu room");
}
} catch (Throwable e) { // Only effective way of preventing crash on poop computers with low heap size
if (e instanceof OutOfMemoryError || e.getCause() instanceof OutOfMemoryError) {
- VRSettings.logger.error("OutOfMemoryError while loading main menu world. Low heap size or 32-bit Java?");
+ logger.error("OutOfMemoryError while loading main menu world. Low heap size or 32-bit Java?");
} else {
- VRSettings.logger.error("Exception thrown when loading main menu world, falling back to old menu room. \n {}", e.getMessage());
+ logger.error("Exception thrown when loading main menu world, falling back to old menu room. \n {}", e.getMessage());
}
e.printStackTrace();
destroy();
@@ -155,25 +169,29 @@ public void render(PoseStack poseStack) {
turnOnLightLayer();
- poseStack.pushPose();
-
- //rotate World
- poseStack.mulPose(Axis.YP.rotationDegrees(worldRotation));
+ float worldRotRads = toRadians(worldRotation);
- // small offset to center on source block, and add the partial block offset, this shouldn't be too noticable on the fog
- poseStack.translate(-0.5,-blockAccess.getGround()+(int)blockAccess.getGround(),-0.5);
+ poseStack.pushPose();
+ poseStack.last().normal()
+ //rotate World
+ .rotateY(worldRotRads);
+ poseStack.last().pose()
+ //rotate World
+ .rotateY(worldRotRads)
+ // small offset to center on source block, and add the partial block offset, this shouldn't be too noticable on the fog
+ .translate(-0.5F, -blockAccess.getGround()+(int)blockAccess.getGround(), -0.5F);
// not sure why this needs to be rotated twice, but it works
- Vec3 offset = new Vec3(0.5,-blockAccess.getGround()+(int)blockAccess.getGround(),0.5).yRot(worldRotation*0.0174533f);
- Vec3 eyePosition = getEyePos().add(offset).yRot(-worldRotation*0.0174533f);
+ Vec3 offset = new Vec3(0.5, -blockAccess.getGround()+(int)blockAccess.getGround(), 0.5).yRot(worldRotRads);
+ Vec3 eyePosition = getEyePos().add(offset).yRot(-worldRotRads);
fogRenderer.levelFogColor();
renderSky(poseStack, eyePosition);
- fogRenderer.setupFog(FogRenderer.FogMode.FOG_TERRAIN);
+ fogRenderer.setupFog(FogMode.FOG_TERRAIN);
- RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
+ RenderSystem.blendFunc(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA);
RenderSystem.enableBlend();
Matrix4f modelView = poseStack.last().pose();
@@ -225,7 +243,7 @@ private void renderChunkLayer(RenderType layer, Matrix4f modelView, Matrix4f Pro
public void prepare() {
if (vertexBuffers == null) {
- VRSettings.logger.info("MenuWorlds: Building geometry...");
+ logger.info("MenuWorlds: Building geometry...");
boolean ao = mc.options.ambientOcclusion().get();
mc.options.ambientOcclusion().set(true);
@@ -250,17 +268,17 @@ public void prepare() {
animatedSprites = new HashSet<>();
// disable liquid chunk wrapping
- ClientDataHolderVR.getInstance().skipStupidGoddamnChunkBoundaryClipping = true;
+ dh.skipStupidGoddamnChunkBoundaryClipping = true;
if (!SodiumHelper.isLoaded() || !SodiumHelper.hasIssuesWithParallelBlockBuilding()) {
// generate the data in parallel
- List>> futures = new ArrayList<>();
+ List>> futures = new ArrayList<>();
for (RenderType layer : layers) {
futures.add(CompletableFuture.supplyAsync(() -> buildGeometryLayer(layer), Util.backgroundExecutor()));
}
- for (Future> future : futures) {
+ for (Future> future : futures) {
try {
- Pair pair = future.get();
+ Pair pair = future.get();
uploadGeometry(pair.getLeft(), pair.getRight());
} catch (ExecutionException | InterruptedException e) {
throw new RuntimeException(e);
@@ -269,7 +287,7 @@ public void prepare() {
} else {
// generate the data in series
for (RenderType layer : layers) {
- Pair pair = buildGeometryLayer(layer);
+ Pair pair = buildGeometryLayer(layer);
uploadGeometry(pair.getLeft(), pair.getRight());
}
}
@@ -281,28 +299,28 @@ public void prepare() {
if (OptifineHelper.isOptifineLoaded()) {
OptifineHelper.setRenderRegions(optifineRenderRegions);
}
- ClientDataHolderVR.getInstance().skipStupidGoddamnChunkBoundaryClipping = false;
+ dh.skipStupidGoddamnChunkBoundaryClipping = false;
}
}
}
- private Pair buildGeometryLayer(RenderType layer) {
+ private Pair buildGeometryLayer(RenderType layer) {
PoseStack thisPose = new PoseStack();
int renderDistSquare = (renderDistance + 1) * (renderDistance + 1);
BlockRenderDispatcher blockRenderer = mc.getBlockRenderer();
BufferBuilder vertBuffer = new BufferBuilder(20 * 2097152);
- vertBuffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.BLOCK);
+ vertBuffer.begin(Mode.QUADS, DefaultVertexFormat.BLOCK);
RandomSource randomSource = RandomSource.create();
int c = 0;
for (int x = -blockAccess.getXSize() / 2; x < blockAccess.getXSize() / 2; x++) {
for (int y = (int) -blockAccess.getGround(); y < blockAccess.getYSize() - (int) blockAccess.getGround(); y++) {
// don't build unnecessary blocks in tall worlds
- if (Mth.abs(y) > renderDistance + 1)
+ if (abs(y) > renderDistance + 1)
continue;
for (int z = -blockAccess.getZSize() / 2; z < blockAccess.getZSize() / 2; z++) {
// don't build unnecessary blocks in fog
- if (Mth.lengthSquared(x, z) > renderDistSquare)
+ if (lengthSquared(x, z) > renderDistSquare)
continue;
BlockPos pos = new BlockPos(x, y, z);
@@ -334,15 +352,16 @@ private Pair buildGeometryLayer(Render
}
}
}
- VRSettings.logger.info("Built " + c + " blocks.");
+ logger.info("Built {} blocks.", c);
if (layer == RenderType.translucent()) {
- vertBuffer.setQuadSorting(VertexSorting.byDistance(0, Mth.frac(blockAccess.getGround()), 0));
+ float frac = blockAccess.getGround();
+ vertBuffer.setQuadSorting(VertexSorting.byDistance(0.0F, frac - roundUsing(frac, FLOOR), 0.0F));
}
return Pair.of(layer, vertBuffer.end());
}
- private void uploadGeometry(RenderType layer, BufferBuilder.RenderedBuffer renderedBuffer) {
- VertexBuffer buffer = new VertexBuffer(VertexBuffer.Usage.STATIC);
+ private void uploadGeometry(RenderType layer, RenderedBuffer renderedBuffer) {
+ VertexBuffer buffer = new VertexBuffer(Usage.STATIC);
buffer.bind();
buffer.upload(renderedBuffer);
VertexBuffer.unbind();
@@ -377,12 +396,12 @@ public void tick() {
if (this.areEyesInFluid(FluidTags.WATER))
{
int i = 1; //this.isSpectator() ? 10 : 1;
- this.waterVisionTime = Mth.clamp(this.waterVisionTime + i, 0, 600);
+ this.waterVisionTime = clamp(0, 600, this.waterVisionTime + i);
}
else if (this.waterVisionTime > 0)
{
this.areEyesInFluid(FluidTags.WATER);
- this.waterVisionTime = Mth.clamp(this.waterVisionTime - 10, 0, 600);
+ this.waterVisionTime = clamp(0, 600, this.waterVisionTime - 10);
}
if (SodiumHelper.isLoaded() && animatedSprites != null) {
for (TextureAtlasSprite sprite : animatedSprites) {
@@ -419,7 +438,7 @@ public void loadRenderers() {
for (int j = 0; j < 32; ++j) {
float f = j - 16;
float g = i - 16;
- float h = Mth.sqrt(f * f + g * g);
+ float h = Vector2f.length(f, g);
this.rainSizeX[i << 5 | j] = -g / h;
this.rainSizeZ[i << 5 | j] = f / h;
}
@@ -465,14 +484,14 @@ public void pushVisibleTextures() {
public void renderSky(PoseStack poseStack, Vec3 position)
{
- if (this.dimensionInfo.skyType() == DimensionSpecialEffects.SkyType.END)
+ if (this.dimensionInfo.skyType() == SkyType.END)
{
this.renderEndSky(poseStack);
}
- else if (this.dimensionInfo.skyType() == DimensionSpecialEffects.SkyType.NORMAL)
+ else if (this.dimensionInfo.skyType() == SkyType.NORMAL)
{
RenderSystem.setShader(GameRenderer::getPositionShader);
- fogRenderer.setupFog(FogRenderer.FogMode.FOG_SKY);
+ fogRenderer.setupFog(FogMode.FOG_SKY);
ShaderInstance skyShader = RenderSystem.getShader();
//RenderSystem.disableTexture();
@@ -497,7 +516,7 @@ else if (this.dimensionInfo.skyType() == DimensionSpecialEffects.SkyType.NORMAL)
}
RenderSystem.enableBlend();
- RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
+ RenderSystem.blendFuncSeparate(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA, SourceFactor.ONE, DestFactor.ZERO);
float[] sunriseColor = this.dimensionInfo.getSunriseColor(this.getTimeOfDay(), 0); // calcSunriseSunsetColors
@@ -505,25 +524,33 @@ else if (this.dimensionInfo.skyType() == DimensionSpecialEffects.SkyType.NORMAL)
{
//RenderSystem.disableTexture();
RenderSystem.setShader(GameRenderer::getPositionColorShader);
- RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f);
+ RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
poseStack.pushPose();
- poseStack.mulPose(Axis.XP.rotationDegrees(90.0f));
- poseStack.mulPose(Axis.ZP.rotationDegrees(Mth.sin(this.getSunAngle()) < 0.0f ? 180.0f : 0.0f));
- poseStack.mulPose(Axis.ZP.rotationDegrees(90.0f));
+ float ang0 = toRadians(90.0F);
+ float ang1 = sin(this.getSunAngle()) < 0.0F ? toRadians(180.0F) : 0.0F;
+
+ poseStack.last().pose()
+ .rotateX(ang0)
+ .rotateZ(ang1)
+ .rotateZ(ang0);
+ poseStack.last().normal()
+ .rotateX(ang0)
+ .rotateZ(ang1)
+ .rotateZ(ang0);
Matrix4f modelView = poseStack.last().pose();
- bufferBuilder.begin(VertexFormat.Mode.TRIANGLE_FAN, DefaultVertexFormat.POSITION_COLOR);
+ bufferBuilder.begin(Mode.TRIANGLE_FAN, DefaultVertexFormat.POSITION_COLOR);
bufferBuilder
- .vertex(modelView, 0.0f, 100.0f, 0.0f)
+ .vertex(modelView, 0.0F, 100.0F, 0.0F)
.color(sunriseColor[0], sunriseColor[1], sunriseColor[2], sunriseColor[3])
.endVertex();
for (int j = 0; j <= 16; ++j)
{
- float f6 = (float)j * ((float)Math.PI * 2F) / 16.0F;
- float f7 = Mth.sin(f6);
- float f8 = Mth.cos(f6);
+ float f6 = (float)j * ((float)PI * 2F) / 16.0F;
+ float f7 = sin(f6);
+ float f8 = cos(f6);
bufferBuilder
.vertex(modelView, f7 * 120.0F, f8 * 120.0F, -f8 * 40.0F * sunriseColor[3])
.color(sunriseColor[0], sunriseColor[1], sunriseColor[2], 0.0F)
@@ -536,27 +563,30 @@ else if (this.dimensionInfo.skyType() == DimensionSpecialEffects.SkyType.NORMAL)
//RenderSystem.enableTexture();
- RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
+ RenderSystem.blendFuncSeparate(SourceFactor.SRC_ALPHA, DestFactor.ONE, SourceFactor.ONE, DestFactor.ZERO);
poseStack.pushPose();
float f10 = 1.0F - getRainLevel();
- RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, f10);
- poseStack.mulPose(Axis.YP.rotationDegrees(-90.0f));
- Matrix4f modelView = poseStack.last().pose();
+ RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, f10);
+ float ang1 = toRadians(-90.0F);
+ poseStack.last().normal().rotateY(ang1);
+ Matrix4f modelView = poseStack.last().pose().rotateY(ang1);
//if (OptifineHelper.isOptifineLoaded()) {
// needs a full Level
//CustomSky.renderSky(this.world, poseStack, Minecraft.getInstance().getFrameTime());
//}
- poseStack.mulPose(Axis.XP.rotationDegrees(this.getTimeOfDay() * 360.0f));
+ float ang2 = toRadians(this.getTimeOfDay() * 360.0F);
+ poseStack.last().normal().rotateX(ang2);
+ modelView.rotateX(ang2);
float size = 30.0F;
if (!OptifineHelper.isOptifineLoaded() || OptifineHelper.isSunMoonEnabled())
{
RenderSystem.setShader(GameRenderer::getPositionTexShader);
RenderSystem.setShaderTexture(0, SUN_LOCATION);
- bufferBuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX);
+ bufferBuilder.begin(Mode.QUADS, DefaultVertexFormat.POSITION_TEX);
bufferBuilder.vertex(modelView, -size, 100.0F, -size).uv(0.0F, 0.0F).endVertex();
bufferBuilder.vertex(modelView, size, 100.0F, -size).uv(1.0F, 0.0F).endVertex();
bufferBuilder.vertex(modelView, size, 100.0F, size).uv(1.0F, 1.0F).endVertex();
@@ -571,15 +601,15 @@ else if (this.dimensionInfo.skyType() == DimensionSpecialEffects.SkyType.NORMAL)
int moonPhase = this.getMoonPhase();
int l = moonPhase % 4;
int i1 = moonPhase / 4 % 2;
- float u0 = (float)(l + 0) / 4.0F;
- float v0 = (float)(i1 + 0) / 2.0F;
+ float u0 = (float)l / 4.0F;
+ float v0 = (float)i1 / 2.0F;
float u1 = (float)(l + 1) / 4.0F;
float v1 = (float)(i1 + 1) / 2.0F;
- bufferBuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX);
- bufferBuilder.vertex(modelView, -size, -100.0f, size).uv(u0, v1).endVertex();
- bufferBuilder.vertex(modelView, size, -100.0f, size).uv(u1, v1).endVertex();
- bufferBuilder.vertex(modelView, size, -100.0f, -size).uv(u1, v0).endVertex();
- bufferBuilder.vertex(modelView, -size, -100.0f, -size).uv(u0, v0).endVertex();
+ bufferBuilder.begin(Mode.QUADS, DefaultVertexFormat.POSITION_TEX);
+ bufferBuilder.vertex(modelView, -size, -100.0F, size).uv(u0, v1).endVertex();
+ bufferBuilder.vertex(modelView, size, -100.0F, size).uv(u1, v1).endVertex();
+ bufferBuilder.vertex(modelView, size, -100.0F, -size).uv(u1, v0).endVertex();
+ bufferBuilder.vertex(modelView, -size, -100.0F, -size).uv(u0, v0).endVertex();
BufferUploader.drawWithShader(bufferBuilder.end());
}
@@ -594,10 +624,10 @@ else if (this.dimensionInfo.skyType() == DimensionSpecialEffects.SkyType.NORMAL)
this.starVBO.bind();
this.starVBO.drawWithShader(poseStack.last().pose(), RenderSystem.getProjectionMatrix(), GameRenderer.getPositionShader());
VertexBuffer.unbind();
- fogRenderer.setupFog(FogRenderer.FogMode.FOG_SKY);
+ fogRenderer.setupFog(FogMode.FOG_SKY);
}
- RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f);
+ RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
RenderSystem.disableBlend();
RenderSystem.defaultBlendFunc();
@@ -608,16 +638,16 @@ else if (this.dimensionInfo.skyType() == DimensionSpecialEffects.SkyType.NORMAL)
if (horizonDistance < 0.0D)
{
- RenderSystem.setShaderColor(0.0f, 0.0f, 0.0f, 1.0f);
+ RenderSystem.setShaderColor(0.0F, 0.0F, 0.0F, 1.0F);
poseStack.pushPose();
- poseStack.translate(0.0f, 12.0f, 0.0f);
+ poseStack.translate(0.0F, 12.0F, 0.0F);
this.sky2VBO.bind();
this.sky2VBO.drawWithShader(poseStack.last().pose(), RenderSystem.getProjectionMatrix(), skyShader);
VertexBuffer.unbind();
poseStack.popPose();
}
- RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f);
+ RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
RenderSystem.depthMask(true);
}
}
@@ -627,7 +657,7 @@ private void renderEndSky(PoseStack poseStack)
if (!OptifineHelper.isOptifineLoaded() || OptifineHelper.isSkyEnabled())
{
RenderSystem.enableBlend();
- RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
+ RenderSystem.blendFuncSeparate(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA, SourceFactor.ONE, DestFactor.ZERO);
RenderSystem.depthMask(false);
RenderSystem.setShader(GameRenderer::getPositionTexColorShader);
RenderSystem.setShaderTexture(0, END_SKY_LOCATION);
@@ -637,16 +667,44 @@ private void renderEndSky(PoseStack poseStack)
for (int i = 0; i < 6; ++i)
{
poseStack.pushPose();
- switch (i) {
- case 1 -> poseStack.mulPose(Axis.XP.rotationDegrees(90.0f));
- case 2 -> poseStack.mulPose(Axis.XP.rotationDegrees(-90.0f));
- case 3 -> poseStack.mulPose(Axis.XP.rotationDegrees(180.0f));
- case 4 -> poseStack.mulPose(Axis.ZP.rotationDegrees(90.0f));
- case 5 -> poseStack.mulPose(Axis.ZP.rotationDegrees(-90.0f));
- }
+ Matrix4f modelView = switch (i) {
+ case 1 ->
+ {
+ float ang1 = toRadians(90.0F);
+ poseStack.last().normal().rotateX(ang1);
+ yield poseStack.last().pose().rotateX(ang1);
+ }
+ case 2 ->
+ {
+ float ang2 = toRadians(-90.0F);
+ poseStack.last().normal().rotateX(ang2);
+ yield poseStack.last().pose().rotateX(ang2);
+ }
+ case 3 ->
+ {
+ float ang3 = toRadians(180.0F);
+ poseStack.last().normal().rotateX(ang3);
+ yield poseStack.last().pose().rotateX(ang3);
+ }
+ case 4 ->
+ {
+ float ang4 = toRadians(90.0F);
+ poseStack.last().normal().rotateZ(ang4);
+ yield poseStack.last().pose().rotateZ(ang4);
+ }
+ case 5 ->
+ {
+ float ang5 = toRadians(-90.0F);
+ poseStack.last().normal().rotateZ(ang5);
+ yield poseStack.last().pose().rotateZ(ang5);
+ }
+ default ->
+ {
+ yield poseStack.last().pose();
+ }
+ };
- Matrix4f modelView = poseStack.last().pose();
- bufferBuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR);
+ bufferBuilder.begin(Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR);
int r = 40;
int g = 40;
@@ -677,18 +735,18 @@ public void renderClouds(PoseStack poseStack, double x, double y, double z)
{
float cloudHeight = this.dimensionInfo.getCloudHeight();
- if (!Float.isNaN(cloudHeight) && this.mc.options.getCloudsType() != CloudStatus.OFF) {
+ if (!Float.isNaN(cloudHeight) && mc.options.getCloudsType() != CloudStatus.OFF) {
// setup clouds
RenderSystem.disableCull();
RenderSystem.enableBlend();
RenderSystem.enableDepthTest();
- RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
+ RenderSystem.blendFuncSeparate(SourceFactor.SRC_ALPHA, DestFactor.ONE_MINUS_SRC_ALPHA, SourceFactor.ONE, DestFactor.ONE_MINUS_SRC_ALPHA);
RenderSystem.depthMask(true);
- float cloudSizeXZ = 12.0f;
- float cloudSizeY = 4.0f;
- double cloudOffset = ((float) ticks + mc.getFrameTime()) * 0.03f;
+ float cloudSizeXZ = 12.0F;
+ float cloudSizeY = 4.0F;
+ double cloudOffset = ((float) ticks + mc.getFrameTime()) * 0.03F;
double cloudX = (x + cloudOffset) / 12.0;
double cloudY = cloudHeight - y + 0.33;
if (OptifineHelper.isOptifineLoaded()) {
@@ -696,27 +754,27 @@ public void renderClouds(PoseStack poseStack, double x, double y, double z)
}
double cloudZ = z / 12.0 + 0.33;
- cloudX -= Mth.floor(cloudX / 2048.0) * 2048;
- cloudZ -= Mth.floor(cloudZ / 2048.0) * 2048;
- float cloudXfract = (float) (cloudX - (double) Mth.floor(cloudX));
- float cloudYfract = (float) (cloudY / 4.0 - (double) Mth.floor(cloudY / 4.0)) * 4.0f;
- float cloudZfract = (float) (cloudZ - (double) Mth.floor(cloudZ));
+ cloudX -= roundUsing(cloudX / 2048.0, FLOOR) * 2048;
+ cloudZ -= roundUsing(cloudZ / 2048.0, FLOOR) * 2048;
+ float cloudXfract = (float) (cloudX - (double) roundUsing(cloudX, FLOOR));
+ float cloudYfract = (float) (cloudY / 4.0 - (double) roundUsing(cloudY / 4.0, FLOOR)) * 4.0f;
+ float cloudZfract = (float) (cloudZ - (double) roundUsing(cloudZ, FLOOR));
Vec3 cloudColor = this.getCloudColour();
- int cloudXfloor = (int) Math.floor(cloudX);
- int cloudYfloor = (int) Math.floor(cloudY / 4.0);
- int cloudZfloor = (int) Math.floor(cloudZ);
+ int cloudXfloor = roundUsing(cloudX, FLOOR);
+ int cloudYfloor = roundUsing(cloudY / 4.0, FLOOR);
+ int cloudZfloor = roundUsing(cloudZ, FLOOR);
if (cloudXfloor != this.prevCloudX ||
cloudYfloor != this.prevCloudY ||
cloudZfloor != this.prevCloudZ ||
- this.mc.options.getCloudsType() != this.prevCloudsType ||
+ mc.options.getCloudsType() != this.prevCloudsType ||
this.prevCloudColor.distanceToSqr(cloudColor) > 2.0E-4)
{
this.prevCloudX = cloudXfloor;
this.prevCloudY = cloudYfloor;
this.prevCloudZ = cloudZfloor;
this.prevCloudColor = cloudColor;
- this.prevCloudsType = this.mc.options.getCloudsType();
+ this.prevCloudsType = mc.options.getCloudsType();
this.generateClouds = true;
}
if (this.generateClouds) {
@@ -725,8 +783,8 @@ public void renderClouds(PoseStack poseStack, double x, double y, double z)
if (this.cloudVBO != null) {
this.cloudVBO.close();
}
- this.cloudVBO = new VertexBuffer(VertexBuffer.Usage.STATIC);
- BufferBuilder.RenderedBuffer renderedBuffer = this.buildClouds(bufferBuilder, cloudX, cloudY, cloudZ, cloudColor);
+ this.cloudVBO = new VertexBuffer(Usage.STATIC);
+ RenderedBuffer renderedBuffer = this.buildClouds(bufferBuilder, cloudX, cloudY, cloudZ, cloudColor);
this.cloudVBO.bind();
this.cloudVBO.upload(renderedBuffer);
VertexBuffer.unbind();
@@ -737,7 +795,7 @@ public void renderClouds(PoseStack poseStack, double x, double y, double z)
RenderSystem.setShaderTexture(0, CLOUDS_LOCATION);
fogRenderer.levelFogColor();
poseStack.pushPose();
- poseStack.scale(12.0f, 1.0f, 12.0f);
+ poseStack.scale(12.0F, 1.0F, 12.0F);
poseStack.translate(-cloudXfract, cloudYfract, -cloudZfract);
if (this.cloudVBO != null) {
this.cloudVBO.bind();
@@ -760,71 +818,71 @@ public void renderClouds(PoseStack poseStack, double x, double y, double z)
}
private BufferBuilder.RenderedBuffer buildClouds(BufferBuilder bufferBuilder, double cloudX, double cloudY, double cloudZ, Vec3 cloudColor) {
- float l = (float)Mth.floor(cloudX) * 0.00390625f;
- float m = (float)Mth.floor(cloudZ) * 0.00390625f;
+ float l = (float)floor(cloudX) * 0.00390625f;
+ float m = (float)floor(cloudZ) * 0.00390625f;
float redTop = (float)cloudColor.x;
float greenTop = (float)cloudColor.y;
float blueTop = (float)cloudColor.z;
- float redX = redTop * 0.9f;
- float greenX = greenTop * 0.9f;
- float blueX = blueTop * 0.9f;
- float redBottom = redTop * 0.7f;
- float greenBottom = greenTop * 0.7f;
- float blueBottom = blueTop * 0.7f;
- float redZ = redTop * 0.8f;
- float greenZ = greenTop * 0.8f;
- float blueZ = blueTop * 0.8f;
+ float redX = redTop * 0.9F;
+ float greenX = greenTop * 0.9F;
+ float blueX = blueTop * 0.9F;
+ float redBottom = redTop * 0.7F;
+ float greenBottom = greenTop * 0.7F;
+ float blueBottom = blueTop * 0.7F;
+ float redZ = redTop * 0.8F;
+ float greenZ = greenTop * 0.8F;
+ float blueZ = blueTop * 0.8F;
RenderSystem.setShader(GameRenderer::getPositionTexColorNormalShader);
- bufferBuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR_NORMAL);
- float z = (float)Math.floor(cloudY / 4.0) * 4.0f;
+ bufferBuilder.begin(Mode.QUADS, DefaultVertexFormat.POSITION_TEX_COLOR_NORMAL);
+ float z = (float)floor(cloudY / 4.0) * 4.0F;
if (this.prevCloudsType == CloudStatus.FANCY) {
for (int aa = -3; aa <= 4; ++aa) {
for (int ab = -3; ab <= 4; ++ab) {
int ae;
float ac = aa * 8;
float ad = ab * 8;
- if (z > -5.0f) {
- bufferBuilder.vertex(ac + 0.0f, z + 0.0f, ad + 8.0f).uv((ac + 0.0f) * 0.00390625f + l, (ad + 8.0f) * 0.00390625f + m).color(redBottom, greenBottom, blueBottom, 0.8f).normal(0.0f, -1.0f, 0.0f).endVertex();
- bufferBuilder.vertex(ac + 8.0f, z + 0.0f, ad + 8.0f).uv((ac + 8.0f) * 0.00390625f + l, (ad + 8.0f) * 0.00390625f + m).color(redBottom, greenBottom, blueBottom, 0.8f).normal(0.0f, -1.0f, 0.0f).endVertex();
- bufferBuilder.vertex(ac + 8.0f, z + 0.0f, ad + 0.0f).uv((ac + 8.0f) * 0.00390625f + l, (ad + 0.0f) * 0.00390625f + m).color(redBottom, greenBottom, blueBottom, 0.8f).normal(0.0f, -1.0f, 0.0f).endVertex();
- bufferBuilder.vertex(ac + 0.0f, z + 0.0f, ad + 0.0f).uv((ac + 0.0f) * 0.00390625f + l, (ad + 0.0f) * 0.00390625f + m).color(redBottom, greenBottom, blueBottom, 0.8f).normal(0.0f, -1.0f, 0.0f).endVertex();
+ if (z > -5.0F) {
+ bufferBuilder.vertex(ac + 0.0F, z + 0.0F, ad + 8.0F).uv((ac + 0.0F) * 0.00390625F + l, (ad + 8.0F) * 0.00390625F + m).color(redBottom, greenBottom, blueBottom, 0.8F).normal(0.0F, -1.0F, 0.0F).endVertex();
+ bufferBuilder.vertex(ac + 8.0F, z + 0.0F, ad + 8.0F).uv((ac + 8.0F) * 0.00390625F + l, (ad + 8.0F) * 0.00390625F + m).color(redBottom, greenBottom, blueBottom, 0.8F).normal(0.0F, -1.0F, 0.0F).endVertex();
+ bufferBuilder.vertex(ac + 8.0F, z + 0.0F, ad + 0.0F).uv((ac + 8.0F) * 0.00390625F + l, (ad + 0.0F) * 0.00390625F + m).color(redBottom, greenBottom, blueBottom, 0.8F).normal(0.0F, -1.0F, 0.0F).endVertex();
+ bufferBuilder.vertex(ac + 0.0F, z + 0.0F, ad + 0.0F).uv((ac + 0.0F) * 0.00390625F + l, (ad + 0.0F) * 0.00390625F + m).color(redBottom, greenBottom, blueBottom, 0.8F).normal(0.0F, -1.0F, 0.0F).endVertex();
}
- if (z <= 5.0f) {
- bufferBuilder.vertex(ac + 0.0f, z + 4.0f - 9.765625E-4f, ad + 8.0f).uv((ac + 0.0f) * 0.00390625f + l, (ad + 8.0f) * 0.00390625f + m).color(redTop, greenTop, blueTop, 0.8f).normal(0.0f, 1.0f, 0.0f).endVertex();
- bufferBuilder.vertex(ac + 8.0f, z + 4.0f - 9.765625E-4f, ad + 8.0f).uv((ac + 8.0f) * 0.00390625f + l, (ad + 8.0f) * 0.00390625f + m).color(redTop, greenTop, blueTop, 0.8f).normal(0.0f, 1.0f, 0.0f).endVertex();
- bufferBuilder.vertex(ac + 8.0f, z + 4.0f - 9.765625E-4f, ad + 0.0f).uv((ac + 8.0f) * 0.00390625f + l, (ad + 0.0f) * 0.00390625f + m).color(redTop, greenTop, blueTop, 0.8f).normal(0.0f, 1.0f, 0.0f).endVertex();
- bufferBuilder.vertex(ac + 0.0f, z + 4.0f - 9.765625E-4f, ad + 0.0f).uv((ac + 0.0f) * 0.00390625f + l, (ad + 0.0f) * 0.00390625f + m).color(redTop, greenTop, blueTop, 0.8f).normal(0.0f, 1.0f, 0.0f).endVertex();
+ if (z <= 5.0F) {
+ bufferBuilder.vertex(ac + 0.0F, z + 4.0F - 9.765625E-4f, ad + 8.0F).uv((ac + 0.0F) * 0.00390625F + l, (ad + 8.0F) * 0.00390625F + m).color(redTop, greenTop, blueTop, 0.8F).normal(0.0F, 1.0F, 0.0F).endVertex();
+ bufferBuilder.vertex(ac + 8.0F, z + 4.0F - 9.765625E-4f, ad + 8.0F).uv((ac + 8.0F) * 0.00390625F + l, (ad + 8.0F) * 0.00390625F + m).color(redTop, greenTop, blueTop, 0.8F).normal(0.0F, 1.0F, 0.0F).endVertex();
+ bufferBuilder.vertex(ac + 8.0F, z + 4.0F - 9.765625E-4f, ad + 0.0F).uv((ac + 8.0F) * 0.00390625F + l, (ad + 0.0F) * 0.00390625F + m).color(redTop, greenTop, blueTop, 0.8F).normal(0.0F, 1.0F, 0.0F).endVertex();
+ bufferBuilder.vertex(ac + 0.0F, z + 4.0F - 9.765625E-4f, ad + 0.0F).uv((ac + 0.0F) * 0.00390625F + l, (ad + 0.0F) * 0.00390625F + m).color(redTop, greenTop, blueTop, 0.8F).normal(0.0F, 1.0F, 0.0F).endVertex();
}
if (aa > -1) {
for (ae = 0; ae < 8; ++ae) {
- bufferBuilder.vertex(ac + (float)ae + 0.0f, z + 0.0f, ad + 8.0f).uv((ac + (float)ae + 0.5f) * 0.00390625f + l, (ad + 8.0f) * 0.00390625f + m).color(redX, greenX, blueX, 0.8f).normal(-1.0f, 0.0f, 0.0f).endVertex();
- bufferBuilder.vertex(ac + (float)ae + 0.0f, z + 4.0f, ad + 8.0f).uv((ac + (float)ae + 0.5f) * 0.00390625f + l, (ad + 8.0f) * 0.00390625f + m).color(redX, greenX, blueX, 0.8f).normal(-1.0f, 0.0f, 0.0f).endVertex();
- bufferBuilder.vertex(ac + (float)ae + 0.0f, z + 4.0f, ad + 0.0f).uv((ac + (float)ae + 0.5f) * 0.00390625f + l, (ad + 0.0f) * 0.00390625f + m).color(redX, greenX, blueX, 0.8f).normal(-1.0f, 0.0f, 0.0f).endVertex();
- bufferBuilder.vertex(ac + (float)ae + 0.0f, z + 0.0f, ad + 0.0f).uv((ac + (float)ae + 0.5f) * 0.00390625f + l, (ad + 0.0f) * 0.00390625f + m).color(redX, greenX, blueX, 0.8f).normal(-1.0f, 0.0f, 0.0f).endVertex();
+ bufferBuilder.vertex(ac + (float)ae + 0.0F, z + 0.0F, ad + 8.0F).uv((ac + (float)ae + 0.5F) * 0.00390625F + l, (ad + 8.0F) * 0.00390625F + m).color(redX, greenX, blueX, 0.8F).normal(-1.0F, 0.0F, 0.0F).endVertex();
+ bufferBuilder.vertex(ac + (float)ae + 0.0F, z + 4.0F, ad + 8.0F).uv((ac + (float)ae + 0.5F) * 0.00390625F + l, (ad + 8.0F) * 0.00390625F + m).color(redX, greenX, blueX, 0.8F).normal(-1.0F, 0.0F, 0.0F).endVertex();
+ bufferBuilder.vertex(ac + (float)ae + 0.0F, z + 4.0F, ad + 0.0F).uv((ac + (float)ae + 0.5F) * 0.00390625F + l, (ad + 0.0F) * 0.00390625F + m).color(redX, greenX, blueX, 0.8F).normal(-1.0F, 0.0F, 0.0F).endVertex();
+ bufferBuilder.vertex(ac + (float)ae + 0.0F, z + 0.0F, ad + 0.0F).uv((ac + (float)ae + 0.5F) * 0.00390625F + l, (ad + 0.0F) * 0.00390625F + m).color(redX, greenX, blueX, 0.8F).normal(-1.0F, 0.0F, 0.0F).endVertex();
}
}
if (aa <= 1) {
for (ae = 0; ae < 8; ++ae) {
- bufferBuilder.vertex(ac + (float)ae + 1.0f - 9.765625E-4f, z + 0.0f, ad + 8.0f).uv((ac + (float)ae + 0.5f) * 0.00390625f + l, (ad + 8.0f) * 0.00390625f + m).color(redX, greenX, blueX, 0.8f).normal(1.0f, 0.0f, 0.0f).endVertex();
- bufferBuilder.vertex(ac + (float)ae + 1.0f - 9.765625E-4f, z + 4.0f, ad + 8.0f).uv((ac + (float)ae + 0.5f) * 0.00390625f + l, (ad + 8.0f) * 0.00390625f + m).color(redX, greenX, blueX, 0.8f).normal(1.0f, 0.0f, 0.0f).endVertex();
- bufferBuilder.vertex(ac + (float)ae + 1.0f - 9.765625E-4f, z + 4.0f, ad + 0.0f).uv((ac + (float)ae + 0.5f) * 0.00390625f + l, (ad + 0.0f) * 0.00390625f + m).color(redX, greenX, blueX, 0.8f).normal(1.0f, 0.0f, 0.0f).endVertex();
- bufferBuilder.vertex(ac + (float)ae + 1.0f - 9.765625E-4f, z + 0.0f, ad + 0.0f).uv((ac + (float)ae + 0.5f) * 0.00390625f + l, (ad + 0.0f) * 0.00390625f + m).color(redX, greenX, blueX, 0.8f).normal(1.0f, 0.0f, 0.0f).endVertex();
+ bufferBuilder.vertex(ac + (float)ae + 1.0F - 9.765625E-4f, z + 0.0F, ad + 8.0F).uv((ac + (float)ae + 0.5F) * 0.00390625F + l, (ad + 8.0F) * 0.00390625F + m).color(redX, greenX, blueX, 0.8F).normal(1.0F, 0.0F, 0.0F).endVertex();
+ bufferBuilder.vertex(ac + (float)ae + 1.0F - 9.765625E-4f, z + 4.0F, ad + 8.0F).uv((ac + (float)ae + 0.5F) * 0.00390625F + l, (ad + 8.0F) * 0.00390625F + m).color(redX, greenX, blueX, 0.8F).normal(1.0F, 0.0F, 0.0F).endVertex();
+ bufferBuilder.vertex(ac + (float)ae + 1.0F - 9.765625E-4f, z + 4.0F, ad + 0.0F).uv((ac + (float)ae + 0.5F) * 0.00390625F + l, (ad + 0.0F) * 0.00390625F + m).color(redX, greenX, blueX, 0.8F).normal(1.0F, 0.0F, 0.0F).endVertex();
+ bufferBuilder.vertex(ac + (float)ae + 1.0F - 9.765625E-4f, z + 0.0F, ad + 0.0F).uv((ac + (float)ae + 0.5F) * 0.00390625F + l, (ad + 0.0F) * 0.00390625F + m).color(redX, greenX, blueX, 0.8F).normal(1.0F, 0.0F, 0.0F).endVertex();
}
}
if (ab > -1) {
for (ae = 0; ae < 8; ++ae) {
- bufferBuilder.vertex(ac + 0.0f, z + 4.0f, ad + (float)ae + 0.0f).uv((ac + 0.0f) * 0.00390625f + l, (ad + (float)ae + 0.5f) * 0.00390625f + m).color(redZ, greenZ, blueZ, 0.8f).normal(0.0f, 0.0f, -1.0f).endVertex();
- bufferBuilder.vertex(ac + 8.0f, z + 4.0f, ad + (float)ae + 0.0f).uv((ac + 8.0f) * 0.00390625f + l, (ad + (float)ae + 0.5f) * 0.00390625f + m).color(redZ, greenZ, blueZ, 0.8f).normal(0.0f, 0.0f, -1.0f).endVertex();
- bufferBuilder.vertex(ac + 8.0f, z + 0.0f, ad + (float)ae + 0.0f).uv((ac + 8.0f) * 0.00390625f + l, (ad + (float)ae + 0.5f) * 0.00390625f + m).color(redZ, greenZ, blueZ, 0.8f).normal(0.0f, 0.0f, -1.0f).endVertex();
- bufferBuilder.vertex(ac + 0.0f, z + 0.0f, ad + (float)ae + 0.0f).uv((ac + 0.0f) * 0.00390625f + l, (ad + (float)ae + 0.5f) * 0.00390625f + m).color(redZ, greenZ, blueZ, 0.8f).normal(0.0f, 0.0f, -1.0f).endVertex();
+ bufferBuilder.vertex(ac + 0.0F, z + 4.0F, ad + (float)ae + 0.0F).uv((ac + 0.0F) * 0.00390625F + l, (ad + (float)ae + 0.5F) * 0.00390625F + m).color(redZ, greenZ, blueZ, 0.8F).normal(0.0F, 0.0F, -1.0F).endVertex();
+ bufferBuilder.vertex(ac + 8.0F, z + 4.0F, ad + (float)ae + 0.0F).uv((ac + 8.0F) * 0.00390625F + l, (ad + (float)ae + 0.5F) * 0.00390625F + m).color(redZ, greenZ, blueZ, 0.8F).normal(0.0F, 0.0F, -1.0F).endVertex();
+ bufferBuilder.vertex(ac + 8.0F, z + 0.0F, ad + (float)ae + 0.0F).uv((ac + 8.0F) * 0.00390625F + l, (ad + (float)ae + 0.5F) * 0.00390625F + m).color(redZ, greenZ, blueZ, 0.8F).normal(0.0F, 0.0F, -1.0F).endVertex();
+ bufferBuilder.vertex(ac + 0.0F, z + 0.0F, ad + (float)ae + 0.0F).uv((ac + 0.0F) * 0.00390625F + l, (ad + (float)ae + 0.5F) * 0.00390625F + m).color(redZ, greenZ, blueZ, 0.8F).normal(0.0F, 0.0F, -1.0F).endVertex();
}
}
if (ab > 1) continue;
for (ae = 0; ae < 8; ++ae) {
- bufferBuilder.vertex(ac + 0.0f, z + 4.0f, ad + (float)ae + 1.0f - 9.765625E-4f).uv((ac + 0.0f) * 0.00390625f + l, (ad + (float)ae + 0.5f) * 0.00390625f + m).color(redZ, greenZ, blueZ, 0.8f).normal(0.0f, 0.0f, 1.0f).endVertex();
- bufferBuilder.vertex(ac + 8.0f, z + 4.0f, ad + (float)ae + 1.0f - 9.765625E-4f).uv((ac + 8.0f) * 0.00390625f + l, (ad + (float)ae + 0.5f) * 0.00390625f + m).color(redZ, greenZ, blueZ, 0.8f).normal(0.0f, 0.0f, 1.0f).endVertex();
- bufferBuilder.vertex(ac + 8.0f, z + 0.0f, ad + (float)ae + 1.0f - 9.765625E-4f).uv((ac + 8.0f) * 0.00390625f + l, (ad + (float)ae + 0.5f) * 0.00390625f + m).color(redZ, greenZ, blueZ, 0.8f).normal(0.0f, 0.0f, 1.0f).endVertex();
- bufferBuilder.vertex(ac + 0.0f, z + 0.0f, ad + (float)ae + 1.0f - 9.765625E-4f).uv((ac + 0.0f) * 0.00390625f + l, (ad + (float)ae + 0.5f) * 0.00390625f + m).color(redZ, greenZ, blueZ, 0.8f).normal(0.0f, 0.0f, 1.0f).endVertex();
+ bufferBuilder.vertex(ac + 0.0F, z + 4.0F, ad + (float)ae + 1.0F - 9.765625E-4f).uv((ac + 0.0F) * 0.00390625F + l, (ad + (float)ae + 0.5F) * 0.00390625F + m).color(redZ, greenZ, blueZ, 0.8F).normal(0.0F, 0.0F, 1.0F).endVertex();
+ bufferBuilder.vertex(ac + 8.0F, z + 4.0F, ad + (float)ae + 1.0F - 9.765625E-4f).uv((ac + 8.0F) * 0.00390625F + l, (ad + (float)ae + 0.5F) * 0.00390625F + m).color(redZ, greenZ, blueZ, 0.8F).normal(0.0F, 0.0F, 1.0F).endVertex();
+ bufferBuilder.vertex(ac + 8.0F, z + 0.0F, ad + (float)ae + 1.0F - 9.765625E-4f).uv((ac + 8.0F) * 0.00390625F + l, (ad + (float)ae + 0.5F) * 0.00390625F + m).color(redZ, greenZ, blueZ, 0.8F).normal(0.0F, 0.0F, 1.0F).endVertex();
+ bufferBuilder.vertex(ac + 0.0F, z + 0.0F, ad + (float)ae + 1.0F - 9.765625E-4f).uv((ac + 0.0F) * 0.00390625F + l, (ad + (float)ae + 0.5F) * 0.00390625F + m).color(redZ, greenZ, blueZ, 0.8F).normal(0.0F, 0.0F, 1.0F).endVertex();
}
}
}
@@ -833,10 +891,10 @@ private BufferBuilder.RenderedBuffer buildClouds(BufferBuilder bufferBuilder, do
int ab = 32;
for (int af = -32; af < 32; af += 32) {
for (int ag = -32; ag < 32; ag += 32) {
- bufferBuilder.vertex(af + 0, z, ag + 32).uv((float)(af + 0) * 0.00390625f + l, (float)(ag + 32) * 0.00390625f + m).color(redTop, greenTop, blueTop, 0.8f).normal(0.0f, -1.0f, 0.0f).endVertex();
- bufferBuilder.vertex(af + 32, z, ag + 32).uv((float)(af + 32) * 0.00390625f + l, (float)(ag + 32) * 0.00390625f + m).color(redTop, greenTop, blueTop, 0.8f).normal(0.0f, -1.0f, 0.0f).endVertex();
- bufferBuilder.vertex(af + 32, z, ag + 0).uv((float)(af + 32) * 0.00390625f + l, (float)(ag + 0) * 0.00390625f + m).color(redTop, greenTop, blueTop, 0.8f).normal(0.0f, -1.0f, 0.0f).endVertex();
- bufferBuilder.vertex(af + 0, z, ag + 0).uv((float)(af + 0) * 0.00390625f + l, (float)(ag + 0) * 0.00390625f + m).color(redTop, greenTop, blueTop, 0.8f).normal(0.0f, -1.0f, 0.0f).endVertex();
+ bufferBuilder.vertex(af, z, ag + 32).uv((float)(af) * 0.00390625F + l, (float)(ag + 32) * 0.00390625F + m).color(redTop, greenTop, blueTop, 0.8F).normal(0.0F, -1.0F, 0.0F).endVertex();
+ bufferBuilder.vertex(af + 32, z, ag + 32).uv((float)(af + 32) * 0.00390625F + l, (float)(ag + 32) * 0.00390625F + m).color(redTop, greenTop, blueTop, 0.8F).normal(0.0F, -1.0F, 0.0F).endVertex();
+ bufferBuilder.vertex(af + 32, z, ag).uv((float)(af + 32) * 0.00390625F + l, (float)(ag) * 0.00390625F + m).color(redTop, greenTop, blueTop, 0.8F).normal(0.0F, -1.0F, 0.0F).endVertex();
+ bufferBuilder.vertex(af, z, ag).uv((float)(af) * 0.00390625F + l, (float)(ag) * 0.00390625F + m).color(redTop, greenTop, blueTop, 0.8F).normal(0.0F, -1.0F, 0.0F).endVertex();
}
}
}
@@ -844,32 +902,29 @@ private BufferBuilder.RenderedBuffer buildClouds(BufferBuilder bufferBuilder, do
}
private void renderSnowAndRain(PoseStack poseStack, double inX, double inY, double inZ) {
- if (getRainLevel() <= 0.0f) {
+ if (getRainLevel() <= 0.0F) {
return;
}
RenderSystem.getModelViewStack().pushPose();
- RenderSystem.getModelViewStack().mulPoseMatrix(poseStack.last().pose());
+ RenderSystem.getModelViewStack().last().pose().mul(poseStack.last().pose());
RenderSystem.applyModelViewMatrix();
- int xFloor = Mth.floor(inX);
- int yFloor = Mth.floor(inY);
- int zFloor = Mth.floor(inZ);
+ int xFloor = roundUsing(inX, FLOOR);
+ int yFloor = roundUsing(inY, FLOOR);
+ int zFloor = roundUsing(inZ, FLOOR);
Tesselator tesselator = Tesselator.getInstance();
BufferBuilder bufferBuilder = tesselator.getBuilder();
RenderSystem.disableCull();
RenderSystem.enableBlend();
RenderSystem.enableDepthTest();
- int rainDistance = 5;
- if (Minecraft.useFancyGraphics()) {
- rainDistance = 10;
- }
+ int rainDistance = useFancyGraphics() ? 10 : 5;
RenderSystem.depthMask(true);
int count = -1;
float rainAnimationTime = this.ticks + mc.getFrameTime();
RenderSystem.setShader(GameRenderer::getParticleShader);
turnOnLightLayer();
- BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos();
+ MutableBlockPos mutableBlockPos = new MutableBlockPos();
for (int rainZ = zFloor - rainDistance; rainZ <= zFloor + rainDistance; ++rainZ) {
for (int rainX = xFloor - rainDistance; rainX <= xFloor + rainDistance; ++rainX) {
int q = (rainZ - zFloor + 16) * 32 + rainX - xFloor + 16;
@@ -880,19 +935,19 @@ private void renderSnowAndRain(PoseStack poseStack, double inX, double inY, doub
if (!biome.hasPrecipitation()) continue;
int blockingHeight = blockAccess.getHeightBlocking(rainX, rainZ);
- int lower = Math.max(yFloor - rainDistance, blockingHeight);
- int upper = Math.max(yFloor + rainDistance, blockingHeight);
+ int lower = max(yFloor - rainDistance, blockingHeight);
+ int upper = max(yFloor + rainDistance, blockingHeight);
if (lower == upper) {
// no rain
continue;
}
- int rainY = Math.max(blockingHeight, yFloor);
+ int rainY = max(blockingHeight, yFloor);
RandomSource randomSource = RandomSource.create(rainX * rainX * 3121L + rainX * 45238971L ^ rainZ * rainZ * 418711L + rainZ * 13761L);
mutableBlockPos.setY(lower);
- Biome.Precipitation precipitation = biome.getPrecipitationAt(mutableBlockPos);
- if (precipitation == Biome.Precipitation.NONE) {
+ Precipitation precipitation = biome.getPrecipitationAt(mutableBlockPos);
+ if (precipitation == Precipitation.NONE) {
continue;
}
@@ -900,7 +955,7 @@ private void renderSnowAndRain(PoseStack poseStack, double inX, double inY, doub
double localX = rainX + 0.5;
double localZ = rainZ + 0.5;
- float distance = (float)Math.sqrt(localX * localX + localZ * localZ) / (float)rainDistance;
+ float distance = (float)sqrt(localX * localX + localZ * localZ) / (float)rainDistance;
float blend;
float xOffset = 0;
float yOffset = 0;
@@ -908,30 +963,30 @@ private void renderSnowAndRain(PoseStack poseStack, double inX, double inY, doub
int skyLight = blockAccess.getBrightness(LightLayer.SKY, mutableBlockPos) << 4;
int blockLight = blockAccess.getBrightness(LightLayer.BLOCK, mutableBlockPos) << 4;
- if (precipitation == Biome.Precipitation.RAIN) {
+ if (precipitation == Precipitation.RAIN) {
if (count != 0) {
if (count >= 0) {
tesselator.end();
}
count = 0;
RenderSystem.setShaderTexture(0, RAIN_LOCATION);
- bufferBuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.PARTICLE);
+ bufferBuilder.begin(Mode.QUADS, DefaultVertexFormat.PARTICLE);
}
- blend = ((1.0f - distance * distance) * 0.5f + 0.5f);
+ blend = ((1.0F - distance * distance) * 0.5F + 0.5F);
int x = this.ticks + rainX * rainX * 3121 + rainX * 45238971 + rainZ * rainZ * 418711 + rainZ * 13761 & 0x1F;
yOffset = -((float)x + mc.getFrameTime()) / 32.0f * (3.0f + randomSource.nextFloat());
- } else if (precipitation == Biome.Precipitation.SNOW) {
+ } else if (precipitation == Precipitation.SNOW) {
if (count != 1) {
if (count >= 0) {
tesselator.end();
}
count = 1;
RenderSystem.setShaderTexture(0, SNOW_LOCATION);
- bufferBuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.PARTICLE);
+ bufferBuilder.begin(Mode.QUADS, DefaultVertexFormat.PARTICLE);
}
- blend = ((1.0f - distance * distance) * 0.3f + 0.5f);
+ blend = ((1.0F - distance * distance) * 0.3F + 0.5F);
xOffset = (float)(randomSource.nextDouble() + (double)rainAnimationTime * 0.01 * (double)((float)randomSource.nextGaussian()));
float ae = -((float)(this.ticks & 0x1FF) + mc.getFrameTime()) / 512.0f;
float af = (float)(randomSource.nextDouble() + (double)(rainAnimationTime * (float)randomSource.nextGaussian()) * 0.001);
@@ -946,19 +1001,19 @@ private void renderSnowAndRain(PoseStack poseStack, double inX, double inY, doub
bufferBuilder
.vertex(localX - r, (double)upper - inY, localZ - s)
.uv(0.0f + xOffset, (float)lower * 0.25f + yOffset)
- .color(1.0f, 1.0f, 1.0f, blend).uv2(blockLight, skyLight).endVertex();
+ .color(1.0F, 1.0F, 1.0F, blend).uv2(blockLight, skyLight).endVertex();
bufferBuilder
.vertex(localX + r, (double)upper - inY, localZ + s)
.uv(1.0f + xOffset, (float)lower * 0.25f + yOffset)
- .color(1.0f, 1.0f, 1.0f, blend).uv2(blockLight, skyLight).endVertex();
+ .color(1.0F, 1.0F, 1.0F, blend).uv2(blockLight, skyLight).endVertex();
bufferBuilder
.vertex(localX + r, (double)lower - inY, localZ + s)
.uv(1.0f + xOffset, (float)upper * 0.25f + yOffset)
- .color(1.0f, 1.0f, 1.0f, blend).uv2(blockLight, skyLight).endVertex();
+ .color(1.0F, 1.0F, 1.0F, blend).uv2(blockLight, skyLight).endVertex();
bufferBuilder
.vertex(localX - r, (double)lower - inY, localZ - s)
.uv(0.0f + xOffset, (float)upper * 0.25f + yOffset)
- .color(1.0f, 1.0f, 1.0f, blend).uv2(blockLight, skyLight).endVertex();
+ .color(1.0F, 1.0F, 1.0F, blend).uv2(blockLight, skyLight).endVertex();
}
}
if (count >= 0) {
@@ -984,8 +1039,7 @@ public float getTimeOfDay()
public float getSunAngle()
{
- float dayTime = this.getTimeOfDay();
- return dayTime * ((float)Math.PI * 2F);
+ return this.getTimeOfDay() * ((float)PI * 2F);
}
public int getMoonPhase()
@@ -995,12 +1049,12 @@ public int getMoonPhase()
public float getSkyDarken() {
float dayTime = this.getTimeOfDay();
- float h = 1.0f - (Mth.cos(dayTime * ((float)Math.PI * 2)) * 2.0f + 0.2f);
- h = Mth.clamp(h, 0.0f, 1.0f);
- h = 1.0f - h;
- h *= 1.0f - this.getRainLevel() * 5.0f / 16.0f;
- h *= 1.0f - this.getThunderLevel() * 5.0f / 16.0f;
- return h * 0.8f + 0.2f;
+ float h = 1.0f - (cos(dayTime * ((float)PI * 2)) * 2.0f + 0.2f);
+ h = clamp(0.0f, 1.0f, h);
+ h = 1.0F - h;
+ h *= 1.0F - this.getRainLevel() * 5.0F / 16.0F;
+ h *= 1.0F - this.getThunderLevel() * 5.0F / 16.0F;
+ return h * 0.8F + 0.2F;
}
public float getRainLevel() {
@@ -1014,8 +1068,8 @@ public float getThunderLevel() {
public float getStarBrightness()
{
float f = this.getTimeOfDay();
- float f1 = 1.0F - (Mth.cos(f * ((float)Math.PI * 2F)) * 2.0F + 0.25F);
- f1 = Mth.clamp(f1, 0.0F, 1.0F);
+ float f1 = 1.0F - (cos(f * ((float)PI * 2F)) * 2.0F + 0.25F);
+ f1 = clamp(0.0F, 1.0F, f1);
return f1 * f1 * 0.5F;
}
@@ -1027,8 +1081,8 @@ public Vec3 getSkyColor(Vec3 position)
Vec3 skyColor = CubicSampler.gaussianSampleVec3(samplePosition, (i, j, k) -> Vec3.fromRGB24(blockAccess.getBiomeManager().getNoiseBiomeAtQuart(i, j, k).value().getSkyColor()));
- float h = Mth.cos(dayTime * ((float)Math.PI * 2)) * 2.0f + 0.5f;
- h = Mth.clamp(h, 0.0f, 1.0f);
+ float h = cos(dayTime * ((float)PI * 2)) * 2.0f + 0.5f;
+ h = clamp(0.0f, 1.0f, h);
float skyColorR = (float)skyColor.x * h;
float skyColorG = (float)skyColor.y * h;
float skyColorB = (float)skyColor.z * h;
@@ -1063,7 +1117,7 @@ public Vec3 getSkyColor(Vec3 position)
public Vec3 getFogColor(Vec3 pos)
{
- float f = Mth.clamp(Mth.cos(this.getTimeOfDay() * ((float)Math.PI * 2F)) * 2.0F + 0.5F, 0.0F, 1.0F);
+ float f = clamp(0.0F, 1.0F, cos(this.getTimeOfDay() * ((float)PI * 2F)) * 2.0F + 0.5F);
Vec3 scaledPos = pos.subtract(2.0D, 2.0D, 2.0D).scale(0.25D);
return CubicSampler.gaussianSampleVec3(scaledPos, (x, y, z) -> this.dimensionInfo.getBrightnessDependentFogColor(Vec3.fromRGB24(this.blockAccess.getBiomeManager().getNoiseBiomeAtQuart(x, y, z).value().getFogColor()), f));
}
@@ -1071,8 +1125,8 @@ public Vec3 getFogColor(Vec3 pos)
public Vec3 getCloudColour()
{
float dayTime = this.getTimeOfDay();
- float f1 = Mth.cos(dayTime * ((float)Math.PI * 2F)) * 2.0F + 0.5F;
- f1 = Mth.clamp(f1, 0.0F, 1.0F);
+ float f1 = cos(dayTime * ((float)PI * 2F)) * 2.0F + 0.5F;
+ f1 = clamp(0.0F, 1.0F, f1);
float r = 1.0F;
float g = 1.0F;
float b = 1.0F;
@@ -1111,8 +1165,8 @@ private void generateSky()
if (this.skyVBO != null) {
this.skyVBO.close();
}
- this.skyVBO = new VertexBuffer(VertexBuffer.Usage.STATIC);
- BufferBuilder.RenderedBuffer renderedBuffer = buildSkyDisc(bufferBuilder, 16.0f);
+ this.skyVBO = new VertexBuffer(Usage.STATIC);
+ RenderedBuffer renderedBuffer = buildSkyDisc(bufferBuilder, 16.0F);
this.skyVBO.bind();
this.skyVBO.upload(renderedBuffer);
VertexBuffer.unbind();
@@ -1125,21 +1179,21 @@ private void generateSky2()
if (this.sky2VBO != null) {
this.sky2VBO.close();
}
- this.sky2VBO = new VertexBuffer(VertexBuffer.Usage.STATIC);
- BufferBuilder.RenderedBuffer renderedBuffer = buildSkyDisc(bufferBuilder, -16.0f);
+ this.sky2VBO = new VertexBuffer(Usage.STATIC);
+ RenderedBuffer renderedBuffer = buildSkyDisc(bufferBuilder, -16.0F);
this.sky2VBO.bind();
this.sky2VBO.upload(renderedBuffer);
VertexBuffer.unbind();
}
- private static BufferBuilder.RenderedBuffer buildSkyDisc(BufferBuilder bufferBuilder, float posY) {
- float g = Math.signum(posY) * 512.0f;
- float h = 512.0f;
+ private static RenderedBuffer buildSkyDisc(BufferBuilder bufferBuilder, float posY) {
+ float g = signum(posY) * 512.0F;
+ float h = 512.0F;
RenderSystem.setShader(GameRenderer::getPositionShader);
- bufferBuilder.begin(VertexFormat.Mode.TRIANGLE_FAN, DefaultVertexFormat.POSITION);
+ bufferBuilder.begin(Mode.TRIANGLE_FAN, DefaultVertexFormat.POSITION);
bufferBuilder.vertex(0.0, posY, 0.0).endVertex();
for (int i = -180; i <= 180; i += 45) {
- bufferBuilder.vertex(g * Mth.cos((float)i * ((float)Math.PI / 180)), posY, 512.0f * Mth.sin((float)i * ((float)Math.PI / 180))).endVertex();
+ bufferBuilder.vertex(g * cos((float)i * ((float)PI / 180)), posY, 512.0f * sin((float)i * ((float)PI / 180))).endVertex();
}
return bufferBuilder.end();
}
@@ -1152,17 +1206,17 @@ private void generateStars()
if (this.starVBO != null) {
this.starVBO.close();
}
- this.starVBO = new VertexBuffer(VertexBuffer.Usage.STATIC);
- BufferBuilder.RenderedBuffer renderedBuffer = this.buildStars(bufferBuilder);
+ this.starVBO = new VertexBuffer(Usage.STATIC);
+ RenderedBuffer renderedBuffer = this.buildStars(bufferBuilder);
this.starVBO.bind();
this.starVBO.upload(renderedBuffer);
VertexBuffer.unbind();
}
- private BufferBuilder.RenderedBuffer buildStars(BufferBuilder bufferBuilderIn)
+ private RenderedBuffer buildStars(BufferBuilder bufferBuilderIn)
{
Random random = new Random(10842L);
- bufferBuilderIn.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION);
+ bufferBuilderIn.begin(Mode.QUADS, DefaultVertexFormat.POSITION);
for (int i = 0; i < 1500; ++i)
{
@@ -1174,22 +1228,22 @@ private BufferBuilder.RenderedBuffer buildStars(BufferBuilder bufferBuilderIn)
if (d4 < 1.0D && d4 > 0.01D)
{
- d4 = 1.0D / Math.sqrt(d4);
+ d4 = 1.0D / sqrt(d4);
d0 = d0 * d4;
d1 = d1 * d4;
d2 = d2 * d4;
double d5 = d0 * 100.0D;
double d6 = d1 * 100.0D;
double d7 = d2 * 100.0D;
- double d8 = Math.atan2(d0, d2);
- double d9 = Math.sin(d8);
- double d10 = Math.cos(d8);
- double d11 = Math.atan2(Math.sqrt(d0 * d0 + d2 * d2), d1);
- double d12 = Math.sin(d11);
- double d13 = Math.cos(d11);
- double d14 = random.nextDouble() * Math.PI * 2.0D;
- double d15 = Math.sin(d14);
- double d16 = Math.cos(d14);
+ double d8 = atan2(d0, d2);
+ double d9 = sin(d8);
+ double d10 = cos(d8);
+ double d11 = atan2(sqrt(d0 * d0 + d2 * d2), d1);
+ double d12 = sin(d11);
+ double d13 = cos(d11);
+ double d14 = random.nextDouble() * PI * 2.0D;
+ double d15 = sin(d14);
+ double d16 = cos(d14);
for (int j = 0; j < 4; ++j)
{
@@ -1217,14 +1271,14 @@ public void turnOffLightLayer() {
public void turnOnLightLayer() {
RenderSystem.setShaderTexture(2, this.lightTextureLocation);
mc.getTextureManager().bindForSetup(this.lightTextureLocation);
- RenderSystem.texParameter(GL11.GL_TEXTURE_2D , GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
- RenderSystem.texParameter(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
+ RenderSystem.texParameter(GL11C.GL_TEXTURE_2D , GL11C.GL_TEXTURE_MIN_FILTER, GL11C.GL_LINEAR);
+ RenderSystem.texParameter(GL11C.GL_TEXTURE_2D, GL11C.GL_TEXTURE_MAG_FILTER, GL11C.GL_LINEAR);
}
public void updateTorchFlicker()
{
this.blockLightRedFlicker += (float)((Math.random() - Math.random()) * Math.random() * Math.random() * 0.1);
- this.blockLightRedFlicker *= 0.9f;
+ this.blockLightRedFlicker *= 0.9F;
this.lightmapUpdateNeeded = true;
}
@@ -1247,21 +1301,21 @@ public void updateLightmap()
}*/
float skyLight = getSkyDarken();
- float effectiveSkyLight = skyFlashTime > 0 ? 1.0f : skyLight * 0.95F + 0.05F;
+ float effectiveSkyLight = skyFlashTime > 0 ? 1.0F : skyLight * 0.95F + 0.05F;
/* no darkness effect, we don't have an actual player
- float darknessScale = this.mc.options.darknessEffectScale().get().floatValue();
+ float darknessScale = mc.options.darknessEffectScale().get().floatValue();
float darknessGamma = this.getDarknessGamma(0) * darknessScale;
- float effectiveDarknessScale = this.calculateDarknessScale(this.mc.player, darknessGamma, 0) * darknessScale;
+ float effectiveDarknessScale = this.calculateDarknessScale(mc.player, darknessGamma, 0) * darknessScale;
*/
float waterVision = getWaterVision();
/* no night vision, we don't have a player
- float nightVision = this.mc.player.hasEffect(MobEffects.NIGHT_VISION)
- ? GameRenderer.getNightVisionScale(this.mc.player, 0)
- : (waterVision > 0.0f && this.mc.player.hasEffect(MobEffects.CONDUIT_POWER) ? waterVision : 0.0f);
+ float nightVision = mc.player.hasEffect(MobEffects.NIGHT_VISION)
+ ? GameRenderer.getNightVisionScale(mc.player, 0)
+ : (waterVision > 0.0f && mc.player.hasEffect(MobEffects.CONDUIT_POWER) ? waterVision : 0.0F);
*/
- float nightVision = 0.0f;
+ float nightVision = 0.0F;
Vector3f skylightColor = new Vector3f(skyLight, skyLight, 1.0f).lerp(new Vector3f(1.0f, 1.0f, 1.0f), 0.35f);
@@ -1271,27 +1325,27 @@ public void updateLightmap()
for (int j = 0; j < 16; ++j)
{
float skyBrightness = LightTexture.getBrightness(this.blockAccess.dimensionType(), i) * effectiveSkyLight;
- float blockBrightnessRed = LightTexture.getBrightness(this.blockAccess.dimensionType(), j) * (blockLightRedFlicker + 1.5f);
- float blockBrightnessGreen = blockBrightnessRed * ((blockBrightnessRed * 0.6f + 0.4f) * 0.6f + 0.4f);
- float blockBrightnessBlue = blockBrightnessRed * (blockBrightnessRed * blockBrightnessRed * 0.6f + 0.4f);
+ float blockBrightnessRed = LightTexture.getBrightness(this.blockAccess.dimensionType(), j) * (blockLightRedFlicker + 1.5F);
+ float blockBrightnessGreen = blockBrightnessRed * ((blockBrightnessRed * 0.6F + 0.4F) * 0.6F + 0.4F);
+ float blockBrightnessBlue = blockBrightnessRed * (blockBrightnessRed * blockBrightnessRed * 0.6F + 0.4F);
finalColor.set(blockBrightnessRed, blockBrightnessGreen, blockBrightnessBlue);
if (dimensionInfo.forceBrightLightmap()) {
finalColor.lerp(new Vector3f(0.99f, 1.12f, 1.0f), 0.25f);
- finalColor.set(Mth.clamp(finalColor.x, 0.0f, 1.0f), Mth.clamp(finalColor.y, 0.0f, 1.0f), Mth.clamp(finalColor.z, 0.0f, 1.0f));
+ finalColor.set(clamp(0.0f, 1.0f, finalColor.x), clamp(0.0f, 1.0f, finalColor.y), clamp(0.0f, 1.0f, finalColor.z));
} else {
finalColor.add(new Vector3f(skylightColor).mul(skyBrightness));
finalColor.lerp(new Vector3f(0.75f, 0.75f, 0.75f), 0.04f);
// no darkening from bosses
-// if (getDarkenWorldAmount() > 0.0f) {
-// finalColor.lerp(new Vector3f(finalColor).mul(0.7f, 0.6f, 0.6f), getDarkenWorldAmount());
+// if (getDarkenWorldAmount() > 0.0F) {
+// finalColor.lerp(new Vector3f(finalColor).mul(0.7F, 0.6F, 0.6F), getDarkenWorldAmount());
// }
}
/* no night vision, no player
- if (nightVision > 0.0f && (w = Math.max(finalColor.x(), Math.max(finalColor.y(), finalColor.z()))) < 1.0f) {
- v = 1.0f / w;
+ if (nightVision > 0.0F && (w = max(finalColor.x(), max(finalColor.y(), finalColor.z()))) < 1.0F) {
+ v = 1.0F / w;
vector3f4 = new Vector3f(finalColor).mul(v);
finalColor.lerp(vector3f4, nightVision);
}
@@ -1299,18 +1353,18 @@ public void updateLightmap()
if (!dimensionInfo.forceBrightLightmap()) {
/* no darkness, no player
- if (effectiveDarknessScale > 0.0f) {
+ if (effectiveDarknessScale > 0.0F) {
finalColor.add(-effectiveDarknessScale, -effectiveDarknessScale, -effectiveDarknessScale);
}
*/
- finalColor.set(Mth.clamp(finalColor.x, 0.0f, 1.0f), Mth.clamp(finalColor.y, 0.0f, 1.0f), Mth.clamp(finalColor.z, 0.0f, 1.0f));
+ finalColor.set(clamp(0.0f, 1.0f, finalColor.x), clamp(0.0f, 1.0f, finalColor.y), clamp(0.0f, 1.0f, finalColor.z));
}
- float gamma = this.mc.options.gamma().get().floatValue();
+ float gamma = mc.options.gamma().get().floatValue();
Vector3f vector3f5 = new Vector3f(this.notGamma(finalColor.x), this.notGamma(finalColor.y), this.notGamma(finalColor.z));
- finalColor.lerp(vector3f5, Math.max(0.0f, gamma /*- darknessGamma*/));
+ finalColor.lerp(vector3f5, max(0.0f, gamma /*- darknessGamma*/));
finalColor.lerp(new Vector3f(0.75f, 0.75f, 0.75f), 0.04f);
- finalColor.set(Mth.clamp(finalColor.x, 0.0f, 1.0f), Mth.clamp(finalColor.y, 0.0f, 1.0f), Mth.clamp(finalColor.z, 0.0f, 1.0f));
+ finalColor.set(clamp(0.0f, 1.0f, finalColor.x), clamp(0.0f, 1.0f, finalColor.y), clamp(0.0f, 1.0f, finalColor.z));
finalColor.mul(255.0f);
int r = (int)finalColor.x();
@@ -1326,8 +1380,8 @@ public void updateLightmap()
}
private float notGamma(float f) {
- float g = 1.0f - f;
- return 1.0f - g * g * g * g;
+ float g = 1.0F - f;
+ return 1.0F - g * g * g * g;
}
public float getWaterVision()
@@ -1344,8 +1398,8 @@ public float getWaterVision()
}
else
{
- float f2 = Mth.clamp((float)this.waterVisionTime / 100.0F, 0.0F, 1.0F);
- float f3 = (float)this.waterVisionTime < 100.0F ? 0.0F : Mth.clamp(((float)this.waterVisionTime - 100.0F) / 500.0F, 0.0F, 1.0F);
+ float f2 = clamp(0.0F, 1.0F, (float)this.waterVisionTime / 100.0F);
+ float f3 = (float)this.waterVisionTime < 100.0F ? 0.0F : clamp(0.0F, 1.0F, ((float)this.waterVisionTime - 100.0F) / 500.0F);
return f2 * 0.6F + f3 * 0.39999998F;
}
}
@@ -1363,7 +1417,7 @@ public boolean areEyesInFluid(TagKey tagIn)
}
public Vec3 getEyePos() {
- return ClientDataHolderVR.getInstance().vrPlayer.vrdata_room_post.hmd.getPosition();
+ return dh.vrPlayer.vrdata_room_post.hmd.getPosition();
}
private boolean isFluidTagged(Fluid fluid, TagKey tag) {
@@ -1449,7 +1503,7 @@ public void setupFogColor() {
if (fogType == FogType.WATER && fogRed != 0.0f && fogGreen != 0.0f && fogBlue != 0.0f) {
float f1 = this.menuWorldRenderer.getWaterVision();
- float f3 = Math.min(1.0f / fogRed, Math.min(1.0f / fogGreen, 1.0f / fogBlue));
+ float f3 = min(1.0f / fogRed, min(1.0f / fogGreen, 1.0f / fogBlue));
fogRed = fogRed * (1.0F - f1) + fogRed * f3 * f1;
fogGreen = fogGreen * (1.0F - f1) + fogGreen * f3 * f1;
@@ -1480,7 +1534,7 @@ public void setupFogColor() {
private void updateSurfaceFog() {
float f = 0.25F + 0.75F * (float) this.menuWorldRenderer.renderDistanceChunks / 32.0F;
- f = 1.0F - (float) Math.pow(f, 0.25);
+ f = 1.0F - (float) pow(f, 0.25);
Vec3 eyePos = this.menuWorldRenderer.getEyePos();
Vec3 skyColor = this.menuWorldRenderer.getSkyColor(eyePos);
if (OptifineHelper.isOptifineLoaded()) {
@@ -1508,9 +1562,9 @@ private void updateSurfaceFog() {
fogBlue = (float) fogColor.z;
if (this.menuWorldRenderer.renderDistanceChunks >= 4) {
- float d0 = Mth.sin(this.menuWorldRenderer.getSunAngle()) > 0.0F ? -1.0F : 1.0F;
+ float d0 = sin(this.menuWorldRenderer.getSunAngle()) > 0.0F ? -1.0F : 1.0F;
Vec3 vec3d2 = new Vec3(d0, 0.0F, 0.0F).yRot(0);
- float f5 = (float) ClientDataHolderVR.getInstance().vrPlayer.vrdata_room_post.hmd.getDirection().yRot(menuWorldRenderer.worldRotation).dot(vec3d2);
+ float f5 = (float) dh.vrPlayer.vrdata_room_post.hmd.getDirection().yRot(menuWorldRenderer.worldRotation).dot(vec3d2);
if (f5 < 0.0F) {
f5 = 0.0F;
@@ -1569,55 +1623,55 @@ private void updateWaterFog(LevelReader levelIn) {
int j1 = previousBiomeFog >> 16 & 255;
int k1 = previousBiomeFog >> 8 & 255;
int l1 = previousBiomeFog & 255;
- float f = Mth.clamp((float) (currentTime - this.biomeChangedTime) / 5000.0F, 0.0F, 1.0F);
+ float f = clamp(0.0F, 1.0F, (float) (currentTime - this.biomeChangedTime) / 5000.0F);
- float f1 = Mth.lerp(f, j1, k);
- float f2 = Mth.lerp(f, k1, l);
- float f3 = Mth.lerp(f, l1, i1);
+ float f1 = lerp(j1, k, f);
+ float f2 = lerp(k1, l, f);
+ float f3 = lerp(l1, i1, f);
fogRed = f1 / 255.0F;
fogGreen = f2 / 255.0F;
fogBlue = f3 / 255.0F;
if (targetBiomeFog != waterFogColor) {
targetBiomeFog = waterFogColor;
- previousBiomeFog = Mth.floor(f1) << 16 | Mth.floor(f2) << 8 | Mth.floor(f3);
+ previousBiomeFog = roundUsing(f1, FLOOR) << 16 | roundUsing(f2, FLOOR) << 8 | roundUsing(f3, FLOOR);
this.biomeChangedTime = currentTime;
}
}
- public void setupFog(FogRenderer.FogMode fogMode) {
+ public void setupFog(FogMode fogMode) {
FogType fogType = getEyeFogType();
float fogStart, fogEnd;
FogShape fogShape = FogShape.SPHERE;
if (fogType == FogType.LAVA) {
- fogStart = 0.25f;
- fogEnd = 1.0f;
+ fogStart = 0.25F;
+ fogEnd = 1.0F;
} else if (fogType == FogType.POWDER_SNOW) {
- fogStart = 0.0f;
- fogEnd = 2.0f;
+ fogStart = 0.0F;
+ fogEnd = 2.0F;
} else if (fogType == FogType.WATER) {
- fogStart = -8.0f;
- fogEnd = 96.0f;
+ fogStart = -8.0F;
+ fogEnd = 96.0F;
Holder holder = menuWorldRenderer.blockAccess.getBiome(BlockPos.containing(menuWorldRenderer.getEyePos()));
if (holder.is(BiomeTags.HAS_CLOSER_WATER_FOG)) {
- fogEnd *= 0.85f;
+ fogEnd *= 0.85F;
}
if (fogEnd > menuWorldRenderer.renderDistance) {
fogEnd = menuWorldRenderer.renderDistance;
fogShape = FogShape.CYLINDER;
}
} else if (menuWorldRenderer.blockAccess.getDimensionReaderInfo().isFoggyAt(0,0)) {
- fogStart = menuWorldRenderer.renderDistance * 0.05f;
- fogEnd = Math.min(menuWorldRenderer.renderDistance, 192.0f) * 0.5f;
- } else if (fogMode == FogRenderer.FogMode.FOG_SKY) {
- fogStart = 0.0f;
+ fogStart = menuWorldRenderer.renderDistance * 0.05F;
+ fogEnd = min(menuWorldRenderer.renderDistance, 192.0F) * 0.5F;
+ } else if (fogMode == FogMode.FOG_SKY) {
+ fogStart = 0.0F;
fogEnd = menuWorldRenderer.renderDistance;
fogShape = FogShape.CYLINDER;
} else {
- float h = Mth.clamp(menuWorldRenderer.renderDistance / 10.0f, 4.0f, 64.0f);
+ float h = clamp(4.0f, 64.0f, menuWorldRenderer.renderDistance / 10.0f);
fogStart = menuWorldRenderer.renderDistance - h;
fogEnd = menuWorldRenderer.renderDistance;
fogShape = FogShape.CYLINDER;
diff --git a/common/src/main/java/org/vivecraft/client_vr/provider/ControllerType.java b/common/src/main/java/org/vivecraft/client_vr/provider/ControllerType.java
index 6d38107a7..1571f05be 100644
--- a/common/src/main/java/org/vivecraft/client_vr/provider/ControllerType.java
+++ b/common/src/main/java/org/vivecraft/client_vr/provider/ControllerType.java
@@ -3,5 +3,5 @@
public enum ControllerType
{
RIGHT,
- LEFT;
+ LEFT
}
diff --git a/common/src/main/java/org/vivecraft/client_vr/provider/HandedKeyBinding.java b/common/src/main/java/org/vivecraft/client_vr/provider/HandedKeyBinding.java
index 7d5b5ff80..301ef8fdb 100644
--- a/common/src/main/java/org/vivecraft/client_vr/provider/HandedKeyBinding.java
+++ b/common/src/main/java/org/vivecraft/client_vr/provider/HandedKeyBinding.java
@@ -1,16 +1,17 @@
package org.vivecraft.client_vr.provider;
-import java.util.Arrays;
import net.minecraft.client.KeyMapping;
+import java.util.Arrays;
+
public class HandedKeyBinding extends KeyMapping
{
private boolean[] pressed = new boolean[ControllerType.values().length];
private int[] pressTime = new int[ControllerType.values().length];
- public HandedKeyBinding(String p_90821_, int p_90822_, String p_90823_)
+ public HandedKeyBinding(String string, int i, String string2)
{
- super(p_90821_, p_90822_, p_90823_);
+ super(string, i, string2);
}
@Override
diff --git a/common/src/main/java/org/vivecraft/client_vr/provider/HardwareType.java b/common/src/main/java/org/vivecraft/client_vr/provider/HardwareType.java
index 650bd754a..b27e7c4b6 100644
--- a/common/src/main/java/org/vivecraft/client_vr/provider/HardwareType.java
+++ b/common/src/main/java/org/vivecraft/client_vr/provider/HardwareType.java
@@ -1,6 +1,7 @@
package org.vivecraft.client_vr.provider;
import com.google.common.collect.ImmutableList;
+
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -14,9 +15,9 @@ public enum HardwareType
public final List manufacturers;
public final boolean hasTouchpad;
public final boolean hasStick;
- private static Map map = new HashMap<>();
+ private static final Map map = new HashMap<>();
- private HardwareType(boolean hasTouchpad, boolean hasStick, String... manufacturers)
+ HardwareType(boolean hasTouchpad, boolean hasStick, String... manufacturers)
{
this.hasTouchpad = hasTouchpad;
this.hasStick = hasStick;
@@ -25,7 +26,7 @@ private HardwareType(boolean hasTouchpad, boolean hasStick, String... manufactur
public static HardwareType fromManufacturer(String name)
{
- return map.containsKey(name) ? map.get(name) : VIVE;
+ return map.getOrDefault(name, VIVE);
}
static {
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 70296132c..6bd7ce9d0 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
@@ -2,11 +2,12 @@
import java.util.HashSet;
import java.util.Set;
-import net.minecraft.client.Minecraft;
+
+import static org.vivecraft.client_vr.VRState.mc;
public class InputSimulator
{
- private static Set pressedKeys = new HashSet<>();
+ private static final Set pressedKeys = new HashSet<>();
public static boolean isKeyDown(int key)
{
@@ -15,7 +16,7 @@ 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);
+ mc.keyboardHandler.keyPress(mc.getWindow().getWindow(), key, 0, 1, modifiers);
pressedKeys.add(key);
}
@@ -26,7 +27,7 @@ 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);
+ mc.keyboardHandler.keyPress(mc.getWindow().getWindow(), key, 0, 0, modifiers);
pressedKeys.remove(key);
}
@@ -37,7 +38,7 @@ public static void releaseKey(int key)
public static void typeChar(char character, int modifiers)
{
- Minecraft.getInstance().keyboardHandler.charTyped(Minecraft.getInstance().getWindow().getWindow(), character, modifiers);
+ mc.keyboardHandler.charTyped(mc.getWindow().getWindow(), character, modifiers);
}
public static void typeChar(char character)
@@ -47,7 +48,7 @@ public static void typeChar(char character)
public static void pressMouse(int button, int modifiers)
{
- Minecraft.getInstance().mouseHandler.onPress(Minecraft.getInstance().getWindow().getWindow(), button, 1, modifiers);
+ mc.mouseHandler.onPress(mc.getWindow().getWindow(), button, 1, modifiers);
}
public static void pressMouse(int button)
@@ -57,7 +58,7 @@ public static void pressMouse(int button)
public static void releaseMouse(int button, int modifiers)
{
- Minecraft.getInstance().mouseHandler.onPress(Minecraft.getInstance().getWindow().getWindow(), button, 0, modifiers);
+ mc.mouseHandler.onPress(mc.getWindow().getWindow(), button, 0, modifiers);
}
public static void releaseMouse(int button)
@@ -67,12 +68,12 @@ public static void releaseMouse(int button)
public static void setMousePos(double x, double y)
{
- Minecraft.getInstance().mouseHandler.onMove(Minecraft.getInstance().getWindow().getWindow(), x, y);
+ mc.mouseHandler.onMove(mc.getWindow().getWindow(), x, y);
}
public static void scrollMouse(double xOffset, double yOffset)
{
- Minecraft.getInstance().mouseHandler.onScroll(Minecraft.getInstance().getWindow().getWindow(), xOffset, yOffset);
+ mc.mouseHandler.onScroll(mc.getWindow().getWindow(), xOffset, yOffset);
}
public static void typeChars(CharSequence characters)
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 682961bdb..0cf47bcdc 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
@@ -1,26 +1,10 @@
package org.vivecraft.client_vr.provider;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-import org.joml.Vector2f;
-import org.lwjgl.glfw.GLFW;
import org.vivecraft.client.VivecraftVRMod;
-import org.vivecraft.client_vr.ClientDataHolderVR;
-import org.vivecraft.client_vr.extensions.GuiExtension;
-import org.vivecraft.client_vr.VRData;
+import org.vivecraft.client.utils.Utils;
+import org.vivecraft.client_vr.VRData.VRDevicePose;
import org.vivecraft.client_vr.Vec3History;
+import org.vivecraft.client_vr.extensions.GuiExtension;
import org.vivecraft.client_vr.gameplay.screenhandlers.GuiHandler;
import org.vivecraft.client_vr.gameplay.screenhandlers.KeyboardHandler;
import org.vivecraft.client_vr.gameplay.screenhandlers.RadialHandler;
@@ -28,48 +12,68 @@
import org.vivecraft.client_vr.provider.openvr_lwjgl.control.VRInputActionSet;
import org.vivecraft.client_vr.provider.openvr_lwjgl.control.VivecraftMovementInput;
import org.vivecraft.client_vr.render.RenderConfigException;
+import org.vivecraft.client_vr.render.RenderPass;
import org.vivecraft.client_vr.settings.VRHotkeys;
-import org.vivecraft.client_vr.settings.VRSettings;
+import org.vivecraft.client_vr.settings.VRHotkeys.Triggerer;
+import org.vivecraft.client_vr.settings.VRSettings.HUDLock;
+import org.vivecraft.client_vr.settings.VRSettings.MirrorMode;
import org.vivecraft.client_xr.render_pass.RenderPassManager;
-import org.vivecraft.common.utils.lwjgl.Matrix4f;
-import org.vivecraft.client_vr.render.RenderPass;
-import org.vivecraft.client.utils.Utils;
-import org.vivecraft.common.utils.lwjgl.Vector3f;
-import org.vivecraft.common.utils.math.Quaternion;
-import org.vivecraft.common.utils.math.Vector3;
+import org.vivecraft.mod_compat_vr.ShadersHelper;
+
+import org.joml.*;
import net.minecraft.client.KeyMapping;
-import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.ChatScreen;
-import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.WinScreen;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
import net.minecraft.network.chat.Component;
-import net.minecraft.util.Mth;
+import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.TorchBlock;
import net.minecraft.world.phys.Vec3;
-import org.vivecraft.mod_compat_vr.ShadersHelper;
+import javax.annotation.Nullable;
+import javax.annotation.ParametersAreNonnullByDefault;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.*;
+import java.util.stream.Stream;
+
+import static org.vivecraft.client.utils.Utils.message;
+import static org.vivecraft.client_vr.VRState.dh;
+import static org.vivecraft.client_vr.VRState.mc;
+import static org.vivecraft.common.utils.Utils.*;
+
+import static org.joml.Math.*;
+import static org.lwjgl.glfw.GLFW.*;
+
+@ParametersAreNonnullByDefault
public abstract class MCVR
{
- protected Minecraft mc;
- protected ClientDataHolderVR dh;
protected static MCVR me;
- protected static VivecraftVRMod mod;
- protected org.vivecraft.common.utils.math.Matrix4f hmdPose = new org.vivecraft.common.utils.math.Matrix4f();
- public org.vivecraft.common.utils.math.Matrix4f hmdRotation = new org.vivecraft.common.utils.math.Matrix4f();
+ protected Matrix4f hmdPose = new Matrix4f();
+ public Matrix4f hmdRotation = new Matrix4f();
public HardwareType detectedHardware = HardwareType.VIVE;
- protected org.vivecraft.common.utils.math.Matrix4f hmdPoseLeftEye = new org.vivecraft.common.utils.math.Matrix4f();
- protected org.vivecraft.common.utils.math.Matrix4f hmdPoseRightEye = new org.vivecraft.common.utils.math.Matrix4f();
+ protected Matrix4f hmdPoseLeftEye = new Matrix4f();
+ protected Matrix4f hmdPoseRightEye = new Matrix4f();
public Vec3History hmdHistory = new Vec3History();
public Vec3History hmdPivotHistory = new Vec3History();
protected boolean headIsTracking;
- protected org.vivecraft.common.utils.math.Matrix4f[] controllerPose = new org.vivecraft.common.utils.math.Matrix4f[3];
- protected org.vivecraft.common.utils.math.Matrix4f[] controllerRotation = new org.vivecraft.common.utils.math.Matrix4f[3];
- protected boolean[] controllerTracking = new boolean[3];
- protected org.vivecraft.common.utils.math.Matrix4f[] handRotation = new org.vivecraft.common.utils.math.Matrix4f[3];
+ protected Matrix4f[] controllerPose = new Matrix4f[]{new Matrix4f(), new Matrix4f()};
+ protected Matrix4f[] controllerRotation = new Matrix4f[]{new Matrix4f(), new Matrix4f()};
+ protected boolean[] controllerTracking = new boolean[]{false, false};
+ protected int[] controllerSkeletalInputTrackingLevel = {0, 0};
+ protected ArrayList[] gestureFingerSplay = new ArrayList[]{new ArrayList(), new ArrayList()};
+ protected ArrayList[] gestureFingerCurl = new ArrayList[]{new ArrayList(), new ArrayList()};
+ protected ArrayList[] gestureFingerTransforms = new ArrayList[]{new ArrayList(), new ArrayList()};
+ protected ArrayList[] gestureFingerOrientations = new ArrayList[]{new ArrayList(), new ArrayList()};
+ protected Matrix4f[] gesturePose = new Matrix4f[2];
+ protected Matrix4f[] gestureRotation = new Matrix4f[2];
+ protected Vector3d[] gestureVelocity = new Vector3d[2];
+ protected Matrix4f[] handRotation = new Matrix4f[]{new Matrix4f(), new Matrix4f()};
public Vec3History[] controllerHistory = new Vec3History[] {new Vec3History(), new Vec3History()};
public Vec3History[] controllerForwardHistory = new Vec3History[] {new Vec3History(), new Vec3History()};
public Vec3History[] controllerUpHistory = new Vec3History[] {new Vec3History(), new Vec3History()};
@@ -78,11 +82,8 @@ public abstract class MCVR
public boolean initialized;
public String initStatus;
public boolean initSuccess;
- protected org.vivecraft.common.utils.math.Matrix4f[] poseMatrices;
- protected Vec3[] deviceVelocity;
- protected Vec3[] aimSource = new Vec3[3];
- public Vector3 forward = new Vector3(0.0F, 0.0F, -1.0F);
- public Vector3 up = new Vector3(0.0F, 1.0F, 0.0F);
+ protected Matrix4f[] poseMatrices;
+ protected Vec3[] aimSource = new Vec3[]{new Vec3(0.0D, 0.0D, 0.0D), new Vec3(0.0D, 0.0D, 0.0D)};
public int hmdAvgLength = 90;
public LinkedList hmdPosSamples = new LinkedList<>();
public LinkedList hmdYawSamples = new LinkedList<>();
@@ -97,10 +98,6 @@ public abstract class MCVR
protected HapticScheduler hapticScheduler;
public float seatedRot;
public float aimPitch = 0.0F;
- protected final org.vivecraft.common.utils.math.Matrix4f Neutral_HMD = new org.vivecraft.common.utils.math.Matrix4f(1.0F, 0.0F, 0.0F, 0.0F, 0.0F, 1.0F, 0.0F, 1.62F, 0.0F, 0.0F, 1.0F, 0.0F, 0.0F, 0.0F, 0.0F, 1.0F);
- protected final org.vivecraft.common.utils.math.Matrix4f TPose_Left = new org.vivecraft.common.utils.math.Matrix4f(1.0F, 0.0F, 0.0F, 0.25F, 0.0F, 1.0F, 0.0F, 1.62F, 0.0F, 0.0F, 1.0F, 0.25F, 0.0F, 0.0F, 0.0F, 1.0F);
- protected final org.vivecraft.common.utils.math.Matrix4f TPose_Right = new org.vivecraft.common.utils.math.Matrix4f(1.0F, 0.0F, 0.0F, 0.75F, 0.0F, 1.0F, 0.0F, 1.62F, 0.0F, 0.0F, 1.0F, 0.75F, 0.0F, 0.0F, 0.0F, 1.0F);
- protected boolean TPose = false;
public boolean hudPopup = true;
protected int moveModeSwitchCount = 0;
public boolean isWalkingAbout;
@@ -110,31 +107,9 @@ public abstract class MCVR
protected float walkaboutYawStart;
protected float hmdForwardYaw = 180;
public boolean ignorePressesNextFrame = false;
- protected int quickTorchPreviousSlot;
protected Map inputActions = new HashMap<>();
protected Map inputActionsByKeyBinding = new HashMap<>();
- public MCVR(Minecraft mc, ClientDataHolderVR dh, VivecraftVRMod vrMod)
- {
- this.mc = mc;
- this.dh = dh;
- mod = vrMod;
- me = this;
-
- for (int i = 0; i < 3; ++i)
- {
- this.aimSource[i] = new Vec3(0.0D, 0.0D, 0.0D);
- this.controllerPose[i] = new org.vivecraft.common.utils.math.Matrix4f();
- this.controllerRotation[i] = new org.vivecraft.common.utils.math.Matrix4f();
- this.handRotation[i] = new org.vivecraft.common.utils.math.Matrix4f();
- }
- }
-
- public static MCVR get()
- {
- return me;
- }
-
public abstract String getName();
public abstract String getID();
@@ -148,7 +123,7 @@ public double getGunAngle()
return this.gunAngle;
}
- public org.vivecraft.common.utils.math.Matrix4f getAimRotation(int controller)
+ public Matrix4f getAimRotation(int controller)
{
return this.controllerRotation[controller];
}
@@ -157,10 +132,10 @@ public Vec3 getAimSource(int controller)
{
Vec3 vec3 = new Vec3(this.aimSource[controller].x, this.aimSource[controller].y, this.aimSource[controller].z);
- if (!this.dh.vrSettings.seated && this.dh.vrSettings.allowStandingOriginOffset)
+ if (!dh.vrSettings.seated && dh.vrSettings.allowStandingOriginOffset)
{
- if(this.dh.vr.isHMDTracking())
- vec3 = vec3.add((double)this.dh.vrSettings.originOffset.getX(), (double)this.dh.vrSettings.originOffset.getY(), (double)this.dh.vrSettings.originOffset.getZ());
+ if(dh.vr.isHMDTracking())
+ vec3 = vec3.add((double)dh.vrSettings.originOffset.x, (double)dh.vrSettings.originOffset.y, (double)dh.vrSettings.originOffset.z);
}
return vec3;
@@ -168,8 +143,26 @@ public Vec3 getAimSource(int controller)
public Vec3 getAimVector(int controller)
{
- Vector3 vector3 = this.controllerRotation[controller].transform(this.forward);
- return vector3.toVector3d();
+ return convertToVec3(new Vector3f(forward).mulProject(this.controllerRotation[controller]));
+ }
+
+ public Vector3f getGesturePosition(int controller)
+ {
+ Vector3f vector3_position = this.gesturePose[controller].getTranslation(new Vector3f());
+ return new Vector3f(vector3_position.x, vector3_position.y, vector3_position.z);
+ }
+
+ public Vector3f getGestureVector(int controller)
+ {
+ return this.gesturePose[controller].transformPosition(new Vector3f(up));
+ }
+
+ public ArrayList getGestureFingerTransforms(int controller){
+ return this.gestureFingerTransforms[controller];
+ }
+
+ public ArrayList getGestureFingerOrientations(int controller){
+ return this.gestureFingerOrientations[controller];
}
public void triggerHapticPulse(ControllerType controller, float durationSeconds, float frequency, float amplitude)
@@ -179,9 +172,9 @@ public void triggerHapticPulse(ControllerType controller, float durationSeconds,
public void triggerHapticPulse(ControllerType controller, float durationSeconds, float frequency, float amplitude, float delaySeconds)
{
- if (!this.dh.vrSettings.seated)
+ if (!dh.vrSettings.seated)
{
- if (this.dh.vrSettings.reverseHands)
+ if (dh.vrSettings.reverseHands)
{
if (controller == ControllerType.RIGHT)
{
@@ -215,35 +208,33 @@ public void triggerHapticPulse(int controller, int strength)
}
}
- public org.vivecraft.common.utils.math.Matrix4f getHandRotation(int controller)
+ public Matrix4f getHandRotation(int controller)
{
return this.handRotation[controller];
}
public Vec3 getHandVector(int controller)
{
- Vector3 vector3 = new Vector3(0.0F, 0.0F, -1.0F);
- org.vivecraft.common.utils.math.Matrix4f matrix4f = this.handRotation[controller];
- Vector3 vector31 = matrix4f.transform(vector3);
- return vector31.toVector3d();
+ Vector3f vector31 = new Vector3f().set(forward).mulProject(this.handRotation[controller]);
+ return convertToVec3(vector31);
}
public Vec3 getCenterEyePosition()
{
- Vector3 vector3 = Utils.convertMatrix4ftoTranslationVector(this.hmdPose);
+ Vector3f vector3 = this.hmdPose.getTranslation(new Vector3f());
- if (this.dh.vrSettings.seated || this.dh.vrSettings.allowStandingOriginOffset)
+ if (dh.vrSettings.seated || dh.vrSettings.allowStandingOriginOffset)
{
- if(this.dh.vr.isHMDTracking())
- vector3 = vector3.add(this.dh.vrSettings.originOffset);
+ if(dh.vr.isHMDTracking())
+ vector3 = vector3.add(dh.vrSettings.originOffset, new Vector3f());
}
- return vector3.toVector3d();
+ return convertToVec3(vector3);
}
public Vec3 getEyePosition(RenderPass eye)
{
- org.vivecraft.common.utils.math.Matrix4f matrix4f = this.hmdPoseRightEye;
+ Matrix4f matrix4f = this.hmdPoseRightEye;
if (eye == RenderPass.LEFT)
{
@@ -260,85 +251,54 @@ else if (eye == RenderPass.RIGHT)
if (matrix4f == null)
{
- org.vivecraft.common.utils.math.Matrix4f matrix4f2 = this.hmdPose;
- Vector3 vector31 = Utils.convertMatrix4ftoTranslationVector(matrix4f2);
+ Vector3f vector31 = this.hmdPose.getTranslation(new Vector3f());
- if (this.dh.vrSettings.seated || this.dh.vrSettings.allowStandingOriginOffset)
+ if (dh.vrSettings.seated || dh.vrSettings.allowStandingOriginOffset)
{
- if(this.dh.vr.isHMDTracking())
- vector31 = vector31.add(this.dh.vrSettings.originOffset);
+ if(dh.vr.isHMDTracking())
+ vector31 = vector31.add(dh.vrSettings.originOffset, new Vector3f());
}
- return vector31.toVector3d();
+ return convertToVec3(vector31);
}
else
{
- org.vivecraft.common.utils.math.Matrix4f matrix4f1 = org.vivecraft.common.utils.math.Matrix4f.multiply(this.hmdPose, matrix4f);
- Vector3 vector3 = Utils.convertMatrix4ftoTranslationVector(matrix4f1);
+ Vector3f vector3 = this.hmdPose.mul0(matrix4f, new Matrix4f()).getTranslation(new Vector3f());
- if (this.dh.vrSettings.seated || this.dh.vrSettings.allowStandingOriginOffset)
+ if (dh.vrSettings.seated || dh.vrSettings.allowStandingOriginOffset)
{
- if(this.dh.vr.isHMDTracking())
- vector3 = vector3.add(this.dh.vrSettings.originOffset);
+ if(dh.vr.isHMDTracking())
+ vector3 = vector3.add(dh.vrSettings.originOffset, new Vector3f());
}
- return vector3.toVector3d();
+ return convertToVec3(vector3);
}
}
public HardwareType getHardwareType()
{
- return this.dh.vrSettings.forceHardwareDetection > 0 ? HardwareType.values()[this.dh.vrSettings.forceHardwareDetection - 1] : this.detectedHardware;
+ return dh.vrSettings.forceHardwareDetection > 0 ? HardwareType.values()[dh.vrSettings.forceHardwareDetection - 1] : this.detectedHardware;
}
public Vec3 getHmdVector()
{
- Vector3 vector3 = this.hmdRotation.transform(this.forward);
- return vector3.toVector3d();
+ return convertToVec3(new Vector3f(forward).mulProject(this.hmdRotation));
}
- public org.vivecraft.common.utils.math.Matrix4f getEyeRotation(RenderPass eye)
+ public Matrix4f getEyeRotation(RenderPass eye)
{
- org.vivecraft.common.utils.math.Matrix4f matrix4f;
+ Matrix4f matrix4f = new Matrix4f();
if (eye == RenderPass.LEFT)
{
- matrix4f = this.hmdPoseLeftEye;
- }
- else if (eye == RenderPass.RIGHT)
- {
- matrix4f = this.hmdPoseRightEye;
+ matrix4f.set(this.hmdPoseLeftEye);
}
else
{
- matrix4f = null;
+ matrix4f.set(this.hmdPoseRightEye);
}
- if (matrix4f != null)
- {
- org.vivecraft.common.utils.math.Matrix4f matrix4f1 = new org.vivecraft.common.utils.math.Matrix4f();
- matrix4f1.M[0][0] = matrix4f.M[0][0];
- matrix4f1.M[0][1] = matrix4f.M[0][1];
- matrix4f1.M[0][2] = matrix4f.M[0][2];
- matrix4f1.M[0][3] = 0.0F;
- matrix4f1.M[1][0] = matrix4f.M[1][0];
- matrix4f1.M[1][1] = matrix4f.M[1][1];
- matrix4f1.M[1][2] = matrix4f.M[1][2];
- matrix4f1.M[1][3] = 0.0F;
- matrix4f1.M[2][0] = matrix4f.M[2][0];
- matrix4f1.M[2][1] = matrix4f.M[2][1];
- matrix4f1.M[2][2] = matrix4f.M[2][2];
- matrix4f1.M[2][3] = 0.0F;
- matrix4f1.M[3][0] = 0.0F;
- matrix4f1.M[3][1] = 0.0F;
- matrix4f1.M[3][2] = 0.0F;
- matrix4f1.M[3][3] = 1.0F;
- return org.vivecraft.common.utils.math.Matrix4f.multiply(this.hmdRotation, matrix4f1);
- }
- else
- {
- return this.hmdRotation;
- }
+ return this.hmdRotation.mul0(new Matrix4f().set3x3(matrix4f), matrix4f);
}
public VRInputAction getInputAction(String keyBindingDesc)
@@ -363,10 +323,7 @@ public VRInputAction getInputAction(KeyMapping keyBinding)
public Collection getInputActionsInSet(VRInputActionSet set)
{
- return Collections.unmodifiableCollection(this.inputActions.values().stream().filter((action) ->
- {
- return action.actionSet == set;
- }).collect(Collectors.toList()));
+ return this.inputActions.values().stream().filter((action) -> action.actionSet == set).toList();
}
public boolean isControllerTracking(ControllerType controller)
@@ -379,15 +336,27 @@ public boolean isControllerTracking(int controller)
return this.controllerTracking[controller];
}
+ public int getControllerSkeletalTrackingLevel(int controller) {
+ return this.controllerSkeletalInputTrackingLevel[controller];
+ }
+
+ public ArrayList[] getGestureFingerSplay(){
+ return this.gestureFingerSplay;
+ }
+
+ public ArrayList[] getGestureFingerCurl(){
+ return this.gestureFingerCurl;
+ }
+
public void resetPosition()
{
- Vec3 vec3 = this.getCenterEyePosition().scale(-1.0D).add((double)this.dh.vrSettings.originOffset.getX(), (double)this.dh.vrSettings.originOffset.getY(), (double)this.dh.vrSettings.originOffset.getZ());
- this.dh.vrSettings.originOffset = new Vector3((float)vec3.x, (float)vec3.y + 1.62F, (float)vec3.z);
+ Vec3 vec3 = this.getCenterEyePosition().scale(-1.0D).add((double)dh.vrSettings.originOffset.x, (double)dh.vrSettings.originOffset.y, (double)dh.vrSettings.originOffset.z);
+ dh.vrSettings.originOffset = new Vector3f((float)vec3.x, (float)vec3.y + 1.62F, (float)vec3.z);
}
public void clearOffset()
{
- this.dh.vrSettings.originOffset = new Vector3(0.0F, 0.0F, 0.0F);
+ dh.vrSettings.originOffset = new Vector3f(0.0F, 0.0F, 0.0F);
}
public boolean isHMDTracking()
@@ -397,29 +366,26 @@ public boolean isHMDTracking()
protected void processHotbar()
{
- int previousSlot = this.dh.interactTracker.hotbar;
- this.dh.interactTracker.hotbar = -1;
+ int previousSlot = dh.interactTracker.hotbar;
+ dh.interactTracker.hotbar = -1;
if(mc.player == null) return;
if(mc.player.getInventory() == null) return;
- if(dh.climbTracker.isGrabbingLadder() &&
- dh.climbTracker.isClaws(mc.player.getMainHandItem())) return;
- if(!dh.interactTracker.isActive(mc.player)) return;
+ if(dh.climbTracker.isGrabbingLadder() && dh.climbTracker.isClaws(mc.player.getMainHandItem())) return;
+ if(!dh.interactTracker.isActive()) return;
Vec3 main = this.getAimSource(0);
Vec3 off = this.getAimSource(1);
- Vec3 barStartos = null, barEndos = null;
-
- int i = 1;
- if (this.dh.vrSettings.reverseHands)
- i = -1;
-
- if (this.dh.vrSettings.vrHudLockMode == VRSettings.HUDLock.WRIST) {
- barStartos = this.getAimRotation(1).transform(new Vector3((float)i * 0.02F, 0.05F, 0.26F)).toVector3d();
- barEndos = this.getAimRotation(1).transform(new Vector3((float)i * 0.02F, 0.05F, 0.01F)).toVector3d();
- } else if (this.dh.vrSettings.vrHudLockMode == VRSettings.HUDLock.HAND) {
- barStartos = this.getAimRotation(1).transform(new Vector3((float)i * -0.18F, 0.08F, -0.01F)).toVector3d();
- barEndos = this.getAimRotation(1).transform(new Vector3((float)i * 0.19F, 0.04F, -0.08F)).toVector3d();
+ Vec3 barStartos, barEndos;
+
+ int i = dh.vrSettings.reverseHands ? 0 : 1;
+
+ if (dh.vrSettings.vrHudLockMode == HUDLock.WRIST) {
+ barStartos = convertToVec3(new Vector3f((float)i * 0.02F, 0.05F, 0.26F).mulProject(this.getAimRotation(1)));
+ barEndos = convertToVec3(new Vector3f((float)i * 0.02F, 0.05F, 0.01F).mulProject(this.getAimRotation(1)));
+ } else if (dh.vrSettings.vrHudLockMode == HUDLock.HAND) {
+ barStartos = convertToVec3(new Vector3f((float)i * -0.18F, 0.08F, -0.01F).mulProject(this.getAimRotation(1)));
+ barEndos = convertToVec3(new Vector3f((float)i * 0.19F, 0.04F, -0.08F).mulProject(this.getAimRotation(1)));
} else return; //how did u get here
@@ -446,7 +412,7 @@ protected void processHotbar()
if(dh.vrSettings.reverseHands) pos = 9 - pos;
- int box = (int) Math.floor(pos);
+ int box = (int) floor(pos);
if(box > 8) return;
if(box < 0) {
@@ -464,10 +430,10 @@ protected void processHotbar()
protected KeyMapping findKeyBinding(String name)
{
- return Stream.concat(Arrays.stream(this.mc.options.keyMappings), mod.getHiddenKeyBindings().stream()).filter((kb) ->
+ return Stream.concat(Arrays.stream(mc.options.keyMappings), VivecraftVRMod.hiddenKeyBindingSet.stream()).filter((kb) ->
{
return name.equals(kb.getName());
- }).findFirst().orElse((KeyMapping)null);
+ }).findFirst().orElse(null);
}
protected void hmdSampling()
@@ -482,7 +448,7 @@ protected void hmdSampling()
this.hmdYawSamples.removeFirst();
}
- float f = this.dh.vrPlayer.vrdata_room_pre.hmd.getYaw();
+ float f = dh.vrPlayer.vrdata_room_pre.hmd.getYaw();
if (f < 0.0F)
{
@@ -492,13 +458,13 @@ protected void hmdSampling()
this.hmdYawTotal += Utils.angleDiff(f, this.hmdYawLast);
this.hmdYawLast = f;
- if (Math.abs(Utils.angleNormalize(this.hmdYawTotal) - this.hmdYawLast) > 1.0F || this.hmdYawTotal > 100000.0F)
+ if (abs(Utils.angleNormalize(this.hmdYawTotal) - this.hmdYawLast) > 1.0F || this.hmdYawTotal > 100000.0F)
{
this.hmdYawTotal = this.hmdYawLast;
- System.out.println("HMD yaw desync/overflow corrected");
+ logger.warn("HMD yaw desync/overflow corrected");
}
- this.hmdPosSamples.add(this.dh.vrPlayer.vrdata_room_pre.hmd.getPosition());
+ this.hmdPosSamples.add(dh.vrPlayer.vrdata_room_pre.hmd.getPosition());
float f1 = 0.0F;
if (this.hmdYawSamples.size() > 0)
@@ -511,12 +477,12 @@ protected void hmdSampling()
f1 /= (float)this.hmdYawSamples.size();
}
- if (Math.abs(this.hmdYawTotal - f1) > 20.0F)
+ if (abs(this.hmdYawTotal - f1) > 20.0F)
{
this.trigger = true;
}
- if (Math.abs(this.hmdYawTotal - f1) < 1.0F)
+ if (abs(this.hmdYawTotal - f1) < 1.0F)
{
this.trigger = false;
}
@@ -532,322 +498,216 @@ protected void updateAim()
RenderPassManager.setGUIRenderPass();
- if (this.mc != null)
+ this.hmdRotation.identity();
+ this.hmdRotation.set3x3(this.hmdPose);
+ Vec3 vec3 = this.getCenterEyePosition();
+ this.hmdHistory.add(vec3);
+ Vector3f vector3 = new Vector3f(0.0F, -0.1F, 0.1F).mulProject(this.hmdRotation);
+ this.hmdPivotHistory.add(vector3.x + vec3.x, vector3.y + vec3.y, vector3.z + vec3.z);
+
+ if (dh.vrSettings.seated)
{
- this.hmdRotation.M[0][0] = this.hmdPose.M[0][0];
- this.hmdRotation.M[0][1] = this.hmdPose.M[0][1];
- this.hmdRotation.M[0][2] = this.hmdPose.M[0][2];
- this.hmdRotation.M[0][3] = 0.0F;
- this.hmdRotation.M[1][0] = this.hmdPose.M[1][0];
- this.hmdRotation.M[1][1] = this.hmdPose.M[1][1];
- this.hmdRotation.M[1][2] = this.hmdPose.M[1][2];
- this.hmdRotation.M[1][3] = 0.0F;
- this.hmdRotation.M[2][0] = this.hmdPose.M[2][0];
- this.hmdRotation.M[2][1] = this.hmdPose.M[2][1];
- this.hmdRotation.M[2][2] = this.hmdPose.M[2][2];
- this.hmdRotation.M[2][3] = 0.0F;
- this.hmdRotation.M[3][0] = 0.0F;
- this.hmdRotation.M[3][1] = 0.0F;
- this.hmdRotation.M[3][2] = 0.0F;
- this.hmdRotation.M[3][3] = 1.0F;
- Vec3 vec3 = this.getCenterEyePosition();
- this.hmdHistory.add(vec3);
- Vector3 vector3 = this.hmdRotation.transform(new Vector3(0.0F, -0.1F, 0.1F));
- this.hmdPivotHistory.add(new Vec3((double)vector3.getX() + vec3.x, (double)vector3.getY() + vec3.y, (double)vector3.getZ() + vec3.z));
-
- if (this.dh.vrSettings.seated)
- {
- this.controllerPose[0] = this.hmdPose.inverted().inverted();
- this.controllerPose[1] = this.hmdPose.inverted().inverted();
- }
+ this.controllerPose[0] = this.hmdPose.invert(new Matrix4f()).invert(new Matrix4f());
+ this.controllerPose[1] = this.hmdPose.invert(new Matrix4f()).invert(new Matrix4f());
+ }
- org.vivecraft.common.utils.math.Matrix4f[] amatrix4f = new org.vivecraft.common.utils.math.Matrix4f[] {new org.vivecraft.common.utils.math.Matrix4f(), new org.vivecraft.common.utils.math.Matrix4f()};
- org.vivecraft.common.utils.math.Matrix4f[] amatrix4f1 = new org.vivecraft.common.utils.math.Matrix4f[] {new org.vivecraft.common.utils.math.Matrix4f(), new org.vivecraft.common.utils.math.Matrix4f()};
+ Matrix4f[] amatrix4f = new Matrix4f[] {new Matrix4f(), new Matrix4f()};
+ Matrix4f[] amatrix4f1 = new Matrix4f[] {new Matrix4f(), new Matrix4f()};
- if (this.dh.vrSettings.seated)
- {
- amatrix4f1[0] = this.controllerPose[0];
- }
- else
- {
- amatrix4f1[0] = org.vivecraft.common.utils.math.Matrix4f.multiply(this.controllerPose[0], this.getControllerComponentTransform(0, "handgrip"));
- }
+ if (dh.vrSettings.seated)
+ {
+ amatrix4f1[0].set(this.controllerPose[0]);
+ }
+ else
+ {
+ this.controllerPose[0].mul0(this.getControllerComponentTransform(0, "handgrip"), amatrix4f1[0]);
+ }
- this.handRotation[0].M[0][0] = amatrix4f1[0].M[0][0];
- this.handRotation[0].M[0][1] = amatrix4f1[0].M[0][1];
- this.handRotation[0].M[0][2] = amatrix4f1[0].M[0][2];
- this.handRotation[0].M[0][3] = 0.0F;
- this.handRotation[0].M[1][0] = amatrix4f1[0].M[1][0];
- this.handRotation[0].M[1][1] = amatrix4f1[0].M[1][1];
- this.handRotation[0].M[1][2] = amatrix4f1[0].M[1][2];
- this.handRotation[0].M[1][3] = 0.0F;
- this.handRotation[0].M[2][0] = amatrix4f1[0].M[2][0];
- this.handRotation[0].M[2][1] = amatrix4f1[0].M[2][1];
- this.handRotation[0].M[2][2] = amatrix4f1[0].M[2][2];
- this.handRotation[0].M[2][3] = 0.0F;
- this.handRotation[0].M[3][0] = 0.0F;
- this.handRotation[0].M[3][1] = 0.0F;
- this.handRotation[0].M[3][2] = 0.0F;
- this.handRotation[0].M[3][3] = 1.0F;
-
- if (this.dh.vrSettings.seated)
- {
- amatrix4f[0] = this.controllerPose[0];
- }
- else
+ this.handRotation[0].identity();
+ this.handRotation[0].set3x3(amatrix4f1[0]);
+
+ if (dh.vrSettings.seated)
+ {
+ amatrix4f[0].set(this.controllerPose[0]);
+ }
+ else
+ {
+ this.controllerPose[0].mul0(this.getControllerComponentTransform(0, "tip"), amatrix4f[0]);
+ }
+
+ Vector3f vector31 = amatrix4f[0].getTranslation(new Vector3f());
+ this.aimSource[0] = convertToVec3(vector31);
+ this.controllerHistory[0].add(this.getAimSource(0));
+ this.controllerRotation[0].identity();
+ this.controllerRotation[0].set3x3(amatrix4f[0]);
+ Vec3 vec31 = this.getHmdVector();
+
+ if (dh.vrSettings.seated && mc.screen == null)
+ {
+ Matrix4f matrix4f = new Matrix4f();
+ float f = 110.0F;
+ float f1 = 180.0F;
+ double d0 = mc.mouseHandler.xpos() / (double)mc.getWindow().getScreenWidth() * (double)f - (double)(f / 2.0F);
+ int i = mc.getWindow().getScreenHeight();
+
+ if (i % 2 != 0)
{
- amatrix4f[0] = org.vivecraft.common.utils.math.Matrix4f.multiply(this.controllerPose[0], this.getControllerComponentTransform(0, "tip"));
+ --i;
}
- Vector3 vector31 = Utils.convertMatrix4ftoTranslationVector(amatrix4f[0]);
- this.aimSource[0] = vector31.toVector3d();
- this.controllerHistory[0].add(this.getAimSource(0));
- this.controllerRotation[0].M[0][0] = amatrix4f[0].M[0][0];
- this.controllerRotation[0].M[0][1] = amatrix4f[0].M[0][1];
- this.controllerRotation[0].M[0][2] = amatrix4f[0].M[0][2];
- this.controllerRotation[0].M[0][3] = 0.0F;
- this.controllerRotation[0].M[1][0] = amatrix4f[0].M[1][0];
- this.controllerRotation[0].M[1][1] = amatrix4f[0].M[1][1];
- this.controllerRotation[0].M[1][2] = amatrix4f[0].M[1][2];
- this.controllerRotation[0].M[1][3] = 0.0F;
- this.controllerRotation[0].M[2][0] = amatrix4f[0].M[2][0];
- this.controllerRotation[0].M[2][1] = amatrix4f[0].M[2][1];
- this.controllerRotation[0].M[2][2] = amatrix4f[0].M[2][2];
- this.controllerRotation[0].M[2][3] = 0.0F;
- this.controllerRotation[0].M[3][0] = 0.0F;
- this.controllerRotation[0].M[3][1] = 0.0F;
- this.controllerRotation[0].M[3][2] = 0.0F;
- this.controllerRotation[0].M[3][3] = 1.0F;
- Vec3 vec31 = this.getHmdVector();
-
- if (this.dh.vrSettings.seated && this.mc.screen == null)
- {
- Matrix4f matrix4f = new Matrix4f();
- float f = 110.0F;
- float f1 = 180.0F;
- double d0 = this.mc.mouseHandler.xpos() / (double)this.mc.getWindow().getScreenWidth() * (double)f - (double)(f / 2.0F);
- int i = this.mc.getWindow().getScreenHeight();
+ double d1 = -mc.mouseHandler.ypos() / (double)i * (double)f1 + (double)(f1 / 2.0F);
+ double d2 = -d1;
- if (i % 2 != 0)
+ if (mc.isWindowActive())
+ {
+ float f2 = dh.vrSettings.keyholeX;
+ float f3 = 20.0F * dh.vrSettings.xSensitivity;
+ int j = (int)((double)(-f2 + f / 2.0F) * (double)mc.getWindow().getScreenWidth() / (double)f) + 1;
+ int k = (int)((double)(f2 + f / 2.0F) * (double)mc.getWindow().getScreenWidth() / (double)f) - 1;
+ float f4 = ((float)abs(d0) - f2) / (f / 2.0F - f2);
+ double d3 = mc.mouseHandler.xpos();
+
+ if (d0 < (double)(-f2))
{
- --i;
+ this.seatedRot += f3 * f4;
+ this.seatedRot %= 360.0F;
+ this.hmdForwardYaw = (float)toDegrees(atan2(vec31.x, vec31.z));
+ d3 = (double)j;
+ d0 = (double)(-f2);
}
-
- double d1 = -this.mc.mouseHandler.ypos() / (double)i * (double)f1 + (double)(f1 / 2.0F);
- double d2 = -d1;
-
- if (this.mc.isWindowActive())
+ else if (d0 > (double)f2)
{
- float f2 = this.dh.vrSettings.keyholeX;
- float f3 = 20.0F * this.dh.vrSettings.xSensitivity;
- int j = (int)((double)(-f2 + f / 2.0F) * (double)this.mc.getWindow().getScreenWidth() / (double)f) + 1;
- int k = (int)((double)(f2 + f / 2.0F) * (double)this.mc.getWindow().getScreenWidth() / (double)f) - 1;
- float f4 = ((float)Math.abs(d0) - f2) / (f / 2.0F - f2);
- double d3 = this.mc.mouseHandler.xpos();
-
- if (d0 < (double)(-f2))
- {
- this.seatedRot += f3 * f4;
- this.seatedRot %= 360.0F;
- this.hmdForwardYaw = (float)Math.toDegrees(Math.atan2(vec31.x, vec31.z));
- d3 = (double)j;
- d0 = (double)(-f2);
- }
- else if (d0 > (double)f2)
- {
- this.seatedRot -= f3 * f4;
- this.seatedRot %= 360.0F;
- this.hmdForwardYaw = (float)Math.toDegrees(Math.atan2(vec31.x, vec31.z));
- d3 = (double)k;
- d0 = (double)f2;
- }
-
- double d4 = 0.5D * (double)this.dh.vrSettings.ySensitivity;
- d2 = (double)this.aimPitch + d1 * d4;
- d2 = Mth.clamp(d2, -89.9D, 89.9D);
- InputSimulator.setMousePos(d3, (double)(i / 2));
- GLFW.glfwSetCursorPos(this.mc.getWindow().getWindow(), d3, (double)(i / 2));
- matrix4f.rotate((float)Math.toRadians(-d2), new Vector3f(1.0F, 0.0F, 0.0F));
- matrix4f.rotate((float)Math.toRadians(-180.0D + d0 - (double)this.hmdForwardYaw), new Vector3f(0.0F, 1.0F, 0.0F));
+ this.seatedRot -= f3 * f4;
+ this.seatedRot %= 360.0F;
+ this.hmdForwardYaw = (float)toDegrees(atan2(vec31.x, vec31.z));
+ d3 = (double)k;
+ d0 = (double)f2;
}
- this.controllerRotation[0].M[0][0] = matrix4f.m00;
- this.controllerRotation[0].M[0][1] = matrix4f.m01;
- this.controllerRotation[0].M[0][2] = matrix4f.m02;
- this.controllerRotation[0].M[1][0] = matrix4f.m10;
- this.controllerRotation[0].M[1][1] = matrix4f.m11;
- this.controllerRotation[0].M[1][2] = matrix4f.m12;
- this.controllerRotation[0].M[2][0] = matrix4f.m20;
- this.controllerRotation[0].M[2][1] = matrix4f.m21;
- this.controllerRotation[0].M[2][2] = matrix4f.m22;
-
- this.handRotation[0].M[0][0] = matrix4f.m00;
- this.handRotation[0].M[0][1] = matrix4f.m01;
- this.handRotation[0].M[0][2] = matrix4f.m02;
- this.handRotation[0].M[1][0] = matrix4f.m10;
- this.handRotation[0].M[1][1] = matrix4f.m11;
- this.handRotation[0].M[1][2] = matrix4f.m12;
- this.handRotation[0].M[2][0] = matrix4f.m20;
- this.handRotation[0].M[2][1] = matrix4f.m21;
- this.handRotation[0].M[2][2] = matrix4f.m22;
+ double d4 = 0.5D * (double)dh.vrSettings.ySensitivity;
+ d2 = (double)this.aimPitch + d1 * d4;
+ d2 = clamp(-89.9D, 89.9D, d2);
+ InputSimulator.setMousePos(d3, (double)(i / 2));
+ glfwSetCursorPos(mc.getWindow().getWindow(), d3, (double)(i / 2));
+ matrix4f.rotateX((float)toRadians(-d2));
+ matrix4f.rotateY((float)toRadians(-180.0D + d0 - (double)this.hmdForwardYaw));
}
- Vec3 vec32 = this.getAimVector(0);
- this.aimPitch = (float)Math.toDegrees(Math.asin(vec32.y / vec32.length()));
- this.controllerForwardHistory[0].add(vec32);
- Vec3 vec33 = this.controllerRotation[0].transform(this.up).toVector3d();
- this.controllerUpHistory[0].add(vec33);
+ this.controllerRotation[0].set3x3(new Matrix4f(matrix4f));
- if (this.dh.vrSettings.seated)
- {
- amatrix4f1[1] = this.controllerPose[1];
- }
- else
- {
- amatrix4f1[1] = org.vivecraft.common.utils.math.Matrix4f.multiply(this.controllerPose[1], this.getControllerComponentTransform(1, "handgrip"));
- }
+ this.handRotation[0].set3x3(new Matrix4f(matrix4f));
+ }
- this.handRotation[1].M[0][0] = amatrix4f1[1].M[0][0];
- this.handRotation[1].M[0][1] = amatrix4f1[1].M[0][1];
- this.handRotation[1].M[0][2] = amatrix4f1[1].M[0][2];
- this.handRotation[1].M[0][3] = 0.0F;
- this.handRotation[1].M[1][0] = amatrix4f1[1].M[1][0];
- this.handRotation[1].M[1][1] = amatrix4f1[1].M[1][1];
- this.handRotation[1].M[1][2] = amatrix4f1[1].M[1][2];
- this.handRotation[1].M[1][3] = 0.0F;
- this.handRotation[1].M[2][0] = amatrix4f1[1].M[2][0];
- this.handRotation[1].M[2][1] = amatrix4f1[1].M[2][1];
- this.handRotation[1].M[2][2] = amatrix4f1[1].M[2][2];
- this.handRotation[1].M[2][3] = 0.0F;
- this.handRotation[1].M[3][0] = 0.0F;
- this.handRotation[1].M[3][1] = 0.0F;
- this.handRotation[1].M[3][2] = 0.0F;
- this.handRotation[1].M[3][3] = 1.0F;
-
- if (this.dh.vrSettings.seated)
- {
- amatrix4f[1] = this.controllerPose[1];
- }
- else
- {
- amatrix4f[1] = org.vivecraft.common.utils.math.Matrix4f.multiply(this.controllerPose[1], this.getControllerComponentTransform(1, "tip"));
- }
+ Vec3 vec32 = this.getAimVector(0);
+ this.aimPitch = (float)toDegrees(asin(vec32.y / vec32.length()));
+ this.controllerForwardHistory[0].add(vec32);
+ this.controllerUpHistory[0].add(convertToVec3(new Vector3f(up).mulProject(this.controllerRotation[0])));
- vector31 = Utils.convertMatrix4ftoTranslationVector(amatrix4f[1]);
- this.aimSource[1] = vector31.toVector3d();
- this.controllerHistory[1].add(this.getAimSource(1));
- this.controllerRotation[1].M[0][0] = amatrix4f[1].M[0][0];
- this.controllerRotation[1].M[0][1] = amatrix4f[1].M[0][1];
- this.controllerRotation[1].M[0][2] = amatrix4f[1].M[0][2];
- this.controllerRotation[1].M[0][3] = 0.0F;
- this.controllerRotation[1].M[1][0] = amatrix4f[1].M[1][0];
- this.controllerRotation[1].M[1][1] = amatrix4f[1].M[1][1];
- this.controllerRotation[1].M[1][2] = amatrix4f[1].M[1][2];
- this.controllerRotation[1].M[1][3] = 0.0F;
- this.controllerRotation[1].M[2][0] = amatrix4f[1].M[2][0];
- this.controllerRotation[1].M[2][1] = amatrix4f[1].M[2][1];
- this.controllerRotation[1].M[2][2] = amatrix4f[1].M[2][2];
- this.controllerRotation[1].M[2][3] = 0.0F;
- this.controllerRotation[1].M[3][0] = 0.0F;
- this.controllerRotation[1].M[3][1] = 0.0F;
- this.controllerRotation[1].M[3][2] = 0.0F;
- this.controllerRotation[1].M[3][3] = 1.0F;
- vec31 = this.getAimVector(1);
- this.controllerForwardHistory[1].add(vec31);
- vec32 = this.controllerRotation[1].transform(this.up).toVector3d();
- this.controllerUpHistory[1].add(vec32);
-
- if (this.dh.vrSettings.seated)
- {
- this.aimSource[1] = this.getCenterEyePosition();
- this.aimSource[0] = this.getCenterEyePosition();
- }
+ if (dh.vrSettings.seated)
+ {
+ amatrix4f1[1].set(this.controllerPose[1]);
+ }
+ else
+ {
+ this.controllerPose[1].mul0(this.getControllerComponentTransform(1, "handgrip"), amatrix4f1[1]);
+ }
- boolean flag = false;
+ this.handRotation[1].identity();
+ this.handRotation[1].set3x3(amatrix4f1[1]);
- if (flag)
- {
- this.controllerPose[2] = this.controllerPose[0];
- }
+ if (dh.vrSettings.seated)
+ {
+ amatrix4f[1].set(this.controllerPose[1]);
+ }
+ else
+ {
+ this.controllerPose[1].mul0(this.getControllerComponentTransform(1, "tip"), amatrix4f[1]);
+ }
- this.controllerRotation[2].M[0][0] = this.controllerPose[2].M[0][0];
- this.controllerRotation[2].M[0][1] = this.controllerPose[2].M[0][1];
- this.controllerRotation[2].M[0][2] = this.controllerPose[2].M[0][2];
- this.controllerRotation[2].M[0][3] = 0.0F;
- this.controllerRotation[2].M[1][0] = this.controllerPose[2].M[1][0];
- this.controllerRotation[2].M[1][1] = this.controllerPose[2].M[1][1];
- this.controllerRotation[2].M[1][2] = this.controllerPose[2].M[1][2];
- this.controllerRotation[2].M[1][3] = 0.0F;
- this.controllerRotation[2].M[2][0] = this.controllerPose[2].M[2][0];
- this.controllerRotation[2].M[2][1] = this.controllerPose[2].M[2][1];
- this.controllerRotation[2].M[2][2] = this.controllerPose[2].M[2][2];
- this.controllerRotation[2].M[2][3] = 0.0F;
- this.controllerRotation[2].M[3][0] = 0.0F;
- this.controllerRotation[2].M[3][1] = 0.0F;
- this.controllerRotation[2].M[3][2] = 0.0F;
- this.controllerRotation[2].M[3][3] = 1.0F;
-
- if ((!this.hasThirdController() || this.dh.vrSettings.displayMirrorMode != VRSettings.MirrorMode.MIXED_REALITY && this.dh.vrSettings.displayMirrorMode != VRSettings.MirrorMode.THIRD_PERSON) && !flag)
- {
- this.mrMovingCamActive = false;
- this.aimSource[2] = new Vec3((double)this.dh.vrSettings.vrFixedCamposX, (double)this.dh.vrSettings.vrFixedCamposY, (double)this.dh.vrSettings.vrFixedCamposZ);
- }
- else
- {
- this.mrMovingCamActive = true;
- Vector3 vector32 = Utils.convertMatrix4ftoTranslationVector(this.controllerPose[2]);
- this.aimSource[2] = vector32.toVector3d();
- }
+ vector31 = amatrix4f[1].getTranslation(new Vector3f());
+ this.aimSource[1] = convertToVec3(vector31);
+ this.controllerHistory[1].add(this.getAimSource(1));
+ this.controllerRotation[1].identity();
+ this.controllerRotation[1].set3x3(amatrix4f[1]);
+ this.controllerForwardHistory[1].add(this.getAimVector(1));
+ this.controllerUpHistory[1].add(convertToVec3(new Vector3f(up).mulProject(this.controllerRotation[1])));
+
+ if (dh.vrSettings.seated)
+ {
+ this.aimSource[1] = this.getCenterEyePosition();
+ this.aimSource[0] = this.getCenterEyePosition();
}
+
+// boolean flag = false;
+//
+// if (flag)
+// {
+// this.controllerPose[2] = this.controllerPose[0];
+// }
+//
+// this.controllerRotation[2].identity();
+// this.controllerRotation[2].set3x3(this.controllerPose[2]);
+//
+// if ((!this.hasThirdController() || dh.vrSettings.displayMirrorMode != MirrorMode.MIXED_REALITY && dh.vrSettings.displayMirrorMode != MirrorMode.THIRD_PERSON) && !flag)
+// {
+// this.mrMovingCamActive = false;
+// this.aimSource[2] = new Vec3(dh.vrSettings.vrFixedCamposX, dh.vrSettings.vrFixedCamposY, dh.vrSettings.vrFixedCamposZ);
+// }
+// else
+// {
+// this.mrMovingCamActive = true;
+// Vector3f vector32 = this.controllerPose[2].getTranslation(new Vector3f());
+// this.aimSource[2] = convertToVec3(vector32);
+// }
}
public void processBindings()
{
if (!this.inputActions.isEmpty())
{
- boolean flag = this.mc.level != null && this.mc.player != null && this.mc.player.isSleeping();
- boolean flag1 = this.mc.screen != null;
- boolean flag2 = mod.keyToggleMovement.consumeClick();
+ boolean sleeping = mc.level != null && mc.player != null && mc.player.isSleeping();
+ boolean gui = mc.screen != null;
+ boolean toggleMovementPressed = VivecraftVRMod.keyToggleMovement.consumeClick();
- if (!this.mc.options.keyPickItem.isDown() && !flag2)
+ if (!mc.options.keyPickItem.isDown() && !toggleMovementPressed)
{
this.moveModeSwitchCount = 0;
}
- else if (++this.moveModeSwitchCount == 80 || flag2)
+ else if (++this.moveModeSwitchCount == 80 || toggleMovementPressed)
{
- if (this.dh.vrSettings.seated)
+ if (dh.vrSettings.seated)
{
- this.dh.vrSettings.seatedFreeMove = !this.dh.vrSettings.seatedFreeMove;
- this.mc.gui.getChat().addMessage(Component.translatable("vivecraft.messages.movementmodeswitch", this.dh.vrSettings.seatedFreeMove ? Component.translatable("vivecraft.options.freemove") : Component.translatable("vivecraft.options.teleport")));
+ dh.vrSettings.seatedFreeMove = !dh.vrSettings.seatedFreeMove;
+ message(Component.translatable("vivecraft.messages.movementmodeswitch", dh.vrSettings.seatedFreeMove ? Component.translatable("vivecraft.options.freemove") : Component.translatable("vivecraft.options.teleport")));
}
- else if (this.dh.vrPlayer.isTeleportSupported())
+ else if (dh.vrPlayer.isTeleportSupported())
{
- this.dh.vrSettings.forceStandingFreeMove = !this.dh.vrSettings.forceStandingFreeMove;
- this.mc.gui.getChat().addMessage(Component.translatable("vivecraft.messages.movementmodeswitch", this.dh.vrSettings.seatedFreeMove ? Component.translatable("vivecraft.options.freemove") : Component.translatable("vivecraft.options.teleport")));
+ dh.vrSettings.forceStandingFreeMove = !dh.vrSettings.forceStandingFreeMove;
+ message(Component.translatable("vivecraft.messages.movementmodeswitch", dh.vrSettings.seatedFreeMove ? Component.translatable("vivecraft.options.freemove") : Component.translatable("vivecraft.options.teleport")));
}
- else if (this.dh.vrPlayer.isTeleportOverridden())
+ else if (dh.vrPlayer.isTeleportOverridden())
{
- this.dh.vrPlayer.setTeleportOverride(false);
- this.mc.gui.getChat().addMessage(Component.translatable("vivecraft.messages.teleportdisabled"));
+ dh.vrPlayer.setTeleportOverride(false);
+ message(Component.translatable("vivecraft.messages.teleportdisabled"));
}
else
{
- this.dh.vrPlayer.setTeleportOverride(true);
- this.mc.gui.getChat().addMessage(Component.translatable("vivecraft.messages.teleportenabled"));
+ dh.vrPlayer.setTeleportOverride(true);
+ message(Component.translatable("vivecraft.messages.teleportenabled"));
}
}
Vec3 vec3 = this.getAimVector(0);
Vec3 vec31 = this.getAimVector(1);
- float f = (float)Math.toDegrees(Math.atan2(-vec3.x, vec3.z));
- float f1 = (float)Math.toDegrees(Math.atan2(-vec31.x, vec31.z));
+ float f = (float)toDegrees(atan2(-vec3.x, vec3.z));
+ float f1 = (float)toDegrees(atan2(-vec31.x, vec31.z));
- if (!flag1)
+ if (!gui)
{
- if (mod.keyWalkabout.isDown())
+ if (VivecraftVRMod.keyWalkabout.isDown())
{
float f2 = f;
- ControllerType controllertype = this.findActiveBindingControllerType(mod.keyWalkabout);
+ ControllerType controllertype = this.findActiveBindingControllerType(VivecraftVRMod.keyWalkabout);
if (controllertype != null && controllertype == ControllerType.LEFT)
{
@@ -857,12 +717,12 @@ else if (this.dh.vrPlayer.isTeleportOverridden())
if (!this.isWalkingAbout)
{
this.isWalkingAbout = true;
- this.walkaboutYawStart = this.dh.vrSettings.worldRotation - f2;
+ this.walkaboutYawStart = dh.vrSettings.worldRotation - f2;
}
else
{
- this.dh.vrSettings.worldRotation = this.walkaboutYawStart + f2;
- this.dh.vrSettings.worldRotation %= 360.0F;
+ dh.vrSettings.worldRotation = this.walkaboutYawStart + f2;
+ dh.vrSettings.worldRotation %= 360.0F;
}
}
else
@@ -870,12 +730,13 @@ else if (this.dh.vrPlayer.isTeleportOverridden())
this.isWalkingAbout = false;
}
- if (mod.keyRotateFree.isDown())
+ if (VivecraftVRMod.keyRotateFree.isDown())
{
float f3 = f;
- ControllerType controllertype5 = this.findActiveBindingControllerType(mod.keyRotateFree);
+ //oh this is ugly. TODO: cache which hand when binding button.
+ ControllerType controller = this.findActiveBindingControllerType(VivecraftVRMod.keyRotateFree);
- if (controllertype5 != null && controllertype5 == ControllerType.LEFT)
+ if (controller == ControllerType.LEFT)
{
f3 = f1;
}
@@ -883,11 +744,11 @@ else if (this.dh.vrPlayer.isTeleportOverridden())
if (!this.isFreeRotate)
{
this.isFreeRotate = true;
- this.walkaboutYawStart = this.dh.vrSettings.worldRotation + f3;
+ this.walkaboutYawStart = dh.vrSettings.worldRotation + f3;
}
else
{
- this.dh.vrSettings.worldRotation = this.walkaboutYawStart - f3;
+ dh.vrSettings.worldRotation = this.walkaboutYawStart - f3;
}
}
else
@@ -896,86 +757,87 @@ else if (this.dh.vrPlayer.isTeleportOverridden())
}
}
- if (mod.keyHotbarNext.consumeClick())
+ if (VivecraftVRMod.keyHotbarNext.consumeClick())
{
this.changeHotbar(-1);
- this.triggerBindingHapticPulse(mod.keyHotbarNext, 250);
+ this.triggerBindingHapticPulse(VivecraftVRMod.keyHotbarNext, 250);
}
- if (mod.keyHotbarPrev.consumeClick())
+ if (VivecraftVRMod.keyHotbarPrev.consumeClick())
{
this.changeHotbar(1);
- this.triggerBindingHapticPulse(mod.keyHotbarPrev, 250);
+ this.triggerBindingHapticPulse(VivecraftVRMod.keyHotbarPrev, 250);
}
- if (mod.keyQuickTorch.consumeClick() && this.mc.player != null)
+ if (VivecraftVRMod.keyQuickTorch.consumeClick() && mc.player != null && mc.screen == null)
{
- for (int j = 0; j < 9; ++j)
+ Inventory inv = mc.player.getInventory();
+ for (byte torchSlot = 0; torchSlot < 9; ++torchSlot)
{
- ItemStack itemstack = this.mc.player.getInventory().getItem(j);
+ ItemStack itemstack = inv.getItem(torchSlot);
- if (itemstack.getItem() instanceof BlockItem && ((BlockItem)itemstack.getItem()).getBlock() instanceof TorchBlock && this.mc.screen == null)
+ if (itemstack.getItem() instanceof BlockItem && ((BlockItem)itemstack.getItem()).getBlock() instanceof TorchBlock)
{
- this.quickTorchPreviousSlot = this.mc.player.getInventory().selected;
- this.mc.player.getInventory().selected = j;
- this.mc.startUseItem();
- this.mc.player.getInventory().selected = this.quickTorchPreviousSlot;
- this.quickTorchPreviousSlot = -1;
- break;
+ int previous = inv.selected;
+ inv.selected = torchSlot;
+ mc.startUseItem();
+ // switch back immediately
+ inv.selected = previous;
+ torchSlot = Byte.MAX_VALUE - 1;
}
}
}
- if (flag1 && !flag && this.mc.options.keyUp.isDown() && !(this.mc.screen instanceof WinScreen) && this.mc.player != null)
+ if (gui && !sleeping && mc.options.keyUp.isDown() && !(mc.screen instanceof WinScreen) && mc.player != null)
{
- this.mc.player.closeContainer();
+ mc.player.closeContainer();
}
- if (this.mc.screen instanceof AbstractContainerScreen && this.mc.options.keyInventory.consumeClick() && this.mc.player != null)
+ if (mc.screen instanceof AbstractContainerScreen && mc.options.keyInventory.consumeClick() && mc.player != null)
{
- this.mc.player.closeContainer();
+ mc.player.closeContainer();
}
- if (this.mc.screen instanceof ChatScreen && this.mc.options.keyChat.consumeClick())
+ if (mc.screen instanceof ChatScreen && mc.options.keyChat.consumeClick())
{
- this.mc.setScreen((Screen)null);
+ mc.setScreen(null);
}
- if (this.dh.vrSettings.worldRotationIncrement == 0.0F)
+ if (dh.vrSettings.worldRotationIncrement == 0.0F)
{
- float f4 = this.getInputAction(mod.keyRotateAxis).getAxis2DUseTracked().getX();
+ float f4 = this.getInputAction(VivecraftVRMod.keyRotateAxis).getAxis2DUseTracked().x();
if (f4 == 0.0F)
{
- f4 = this.getInputAction(mod.keyFreeMoveRotate).getAxis2DUseTracked().getX();
+ f4 = this.getInputAction(VivecraftVRMod.keyFreeMoveRotate).getAxis2DUseTracked().x();
}
if (f4 != 0.0F)
{
float f8 = 10.0F * f4;
- this.dh.vrSettings.worldRotation -= f8;
- this.dh.vrSettings.worldRotation %= 360.0F;
+ dh.vrSettings.worldRotation -= f8;
+ dh.vrSettings.worldRotation %= 360.0F;
}
}
- else if (mod.keyRotateAxis.consumeClick() || mod.keyFreeMoveRotate.consumeClick())
+ else if (VivecraftVRMod.keyRotateAxis.consumeClick() || VivecraftVRMod.keyFreeMoveRotate.consumeClick())
{
- float f5 = this.getInputAction(mod.keyRotateAxis).getAxis2D(false).getX();
+ float f5 = this.getInputAction(VivecraftVRMod.keyRotateAxis).getAxis2D(false).x();
if (f5 == 0.0F)
{
- f5 = this.getInputAction(mod.keyFreeMoveRotate).getAxis2D(false).getX();
+ f5 = this.getInputAction(VivecraftVRMod.keyFreeMoveRotate).getAxis2D(false).x();
}
- if (Math.abs(f5) > 0.5F)
+ if (abs(f5) > 0.5F)
{
- this.dh.vrSettings.worldRotation -= this.dh.vrSettings.worldRotationIncrement * Math.signum(f5);
- this.dh.vrSettings.worldRotation %= 360.0F;
+ dh.vrSettings.worldRotation -= dh.vrSettings.worldRotationIncrement * signum(f5);
+ dh.vrSettings.worldRotation %= 360.0F;
}
}
- if (this.dh.vrSettings.worldRotationIncrement == 0.0F)
+ if (dh.vrSettings.worldRotationIncrement == 0.0F)
{
- float f6 = VivecraftMovementInput.getMovementAxisValue(mod.keyRotateLeft);
+ float f6 = VivecraftMovementInput.getMovementAxisValue(VivecraftVRMod.keyRotateLeft);
if (f6 > 0.0F)
{
@@ -986,19 +848,19 @@ else if (mod.keyRotateAxis.consumeClick() || mod.keyFreeMoveRotate.consumeClick(
f9 = 10.0F * f6;
}
- this.dh.vrSettings.worldRotation += f9;
- this.dh.vrSettings.worldRotation %= 360.0F;
+ dh.vrSettings.worldRotation += f9;
+ dh.vrSettings.worldRotation %= 360.0F;
}
}
- else if (mod.keyRotateLeft.consumeClick())
+ else if (VivecraftVRMod.keyRotateLeft.consumeClick())
{
- this.dh.vrSettings.worldRotation += this.dh.vrSettings.worldRotationIncrement;
- this.dh.vrSettings.worldRotation %= 360.0F;
+ dh.vrSettings.worldRotation += dh.vrSettings.worldRotationIncrement;
+ dh.vrSettings.worldRotation %= 360.0F;
}
- if (this.dh.vrSettings.worldRotationIncrement == 0.0F)
+ if (dh.vrSettings.worldRotationIncrement == 0.0F)
{
- float f7 = VivecraftMovementInput.getMovementAxisValue(mod.keyRotateRight);
+ float f7 = VivecraftMovementInput.getMovementAxisValue(VivecraftVRMod.keyRotateRight);
if (f7 > 0.0F)
{
@@ -1009,55 +871,55 @@ else if (mod.keyRotateLeft.consumeClick())
f10 = 10.0F * f7;
}
- this.dh.vrSettings.worldRotation -= f10;
- this.dh.vrSettings.worldRotation %= 360.0F;
+ dh.vrSettings.worldRotation -= f10;
+ dh.vrSettings.worldRotation %= 360.0F;
}
}
- else if (mod.keyRotateRight.consumeClick())
+ else if (VivecraftVRMod.keyRotateRight.consumeClick())
{
- this.dh.vrSettings.worldRotation -= this.dh.vrSettings.worldRotationIncrement;
- this.dh.vrSettings.worldRotation %= 360.0F;
+ dh.vrSettings.worldRotation -= dh.vrSettings.worldRotationIncrement;
+ dh.vrSettings.worldRotation %= 360.0F;
}
- this.seatedRot = this.dh.vrSettings.worldRotation;
+ this.seatedRot = dh.vrSettings.worldRotation;
- if (mod.keyRadialMenu.consumeClick() && !flag1)
+ if (VivecraftVRMod.keyRadialMenu.consumeClick() && !gui)
{
- ControllerType controllertype1 = this.findActiveBindingControllerType(mod.keyRadialMenu);
+ ControllerType controller = this.findActiveBindingControllerType(VivecraftVRMod.keyRadialMenu);
- if (controllertype1 != null)
+ if (controller != null)
{
- RadialHandler.setOverlayShowing(!RadialHandler.isShowing(), controllertype1);
+ RadialHandler.setOverlayShowing(!RadialHandler.isShowing(), controller);
}
}
- if (mod.keySwapMirrorView.consumeClick())
+ if (VivecraftVRMod.keySwapMirrorView.consumeClick())
{
- if (this.dh.vrSettings.displayMirrorMode == VRSettings.MirrorMode.THIRD_PERSON)
+ if (dh.vrSettings.displayMirrorMode == MirrorMode.THIRD_PERSON)
{
- this.dh.vrSettings.displayMirrorMode = VRSettings.MirrorMode.FIRST_PERSON;
+ dh.vrSettings.displayMirrorMode = MirrorMode.FIRST_PERSON;
}
- else if (this.dh.vrSettings.displayMirrorMode == VRSettings.MirrorMode.FIRST_PERSON)
+ else if (dh.vrSettings.displayMirrorMode == MirrorMode.FIRST_PERSON)
{
- this.dh.vrSettings.displayMirrorMode = VRSettings.MirrorMode.THIRD_PERSON;
+ dh.vrSettings.displayMirrorMode = MirrorMode.THIRD_PERSON;
}
if (!ShadersHelper.isShaderActive()) {
- this.dh.vrRenderer.reinitFrameBuffers("Mirror Setting Changed");
+ dh.vrRenderer.reinitFrameBuffers("Mirror Setting Changed");
} else {
// in case if the last third person mirror was mixed reality
- this.dh.vrRenderer.resizeFrameBuffers("Mirror Setting Changed");
+ dh.vrRenderer.resizeFrameBuffers("Mirror Setting Changed");
}
}
- if (mod.keyToggleKeyboard.consumeClick())
+ if (VivecraftVRMod.keyToggleKeyboard.consumeClick())
{
- KeyboardHandler.setOverlayShowing(!KeyboardHandler.Showing);
+ KeyboardHandler.setOverlayShowing(!KeyboardHandler.isShowing());
}
- if (mod.keyMoveThirdPersonCam.consumeClick() && !ClientDataHolderVR.kiosk && !this.dh.vrSettings.seated && (this.dh.vrSettings.displayMirrorMode == VRSettings.MirrorMode.MIXED_REALITY || this.dh.vrSettings.displayMirrorMode == VRSettings.MirrorMode.THIRD_PERSON))
+ if (VivecraftVRMod.keyMoveThirdPersonCam.consumeClick() && !dh.kiosk && !dh.vrSettings.seated && (dh.vrSettings.displayMirrorMode == MirrorMode.MIXED_REALITY || dh.vrSettings.displayMirrorMode == MirrorMode.THIRD_PERSON))
{
- ControllerType controllertype2 = this.findActiveBindingControllerType(mod.keyMoveThirdPersonCam);
+ ControllerType controllertype2 = this.findActiveBindingControllerType(VivecraftVRMod.keyMoveThirdPersonCam);
if (controllertype2 != null)
{
@@ -1065,123 +927,123 @@ else if (this.dh.vrSettings.displayMirrorMode == VRSettings.MirrorMode.FIRST_PER
}
}
- if (!mod.keyMoveThirdPersonCam.isDown() && VRHotkeys.isMovingThirdPersonCam() && VRHotkeys.getMovingThirdPersonCamTriggerer() == VRHotkeys.Triggerer.BINDING)
+ if (!VivecraftVRMod.keyMoveThirdPersonCam.isDown() && VRHotkeys.isMovingThirdPersonCam() && VRHotkeys.getMovingThirdPersonCamTriggerer() == Triggerer.BINDING)
{
VRHotkeys.stopMovingThirdPersonCam();
- this.dh.vrSettings.saveOptions();
+ dh.vrSettings.saveOptions();
}
- if (VRHotkeys.isMovingThirdPersonCam() && VRHotkeys.getMovingThirdPersonCamTriggerer() == VRHotkeys.Triggerer.MENUBUTTON && mod.keyMenuButton.consumeClick())
+ if (VRHotkeys.isMovingThirdPersonCam() && VRHotkeys.getMovingThirdPersonCamTriggerer() == VRHotkeys.Triggerer.MENUBUTTON && VivecraftVRMod.keyMenuButton.consumeClick())
{
VRHotkeys.stopMovingThirdPersonCam();
- this.dh.vrSettings.saveOptions();
+ dh.vrSettings.saveOptions();
}
- if (KeyboardHandler.Showing && this.mc.screen == null && mod.keyMenuButton.consumeClick())
+ if (KeyboardHandler.isShowing() && mc.screen == null && VivecraftVRMod.keyMenuButton.consumeClick())
{
KeyboardHandler.setOverlayShowing(false);
}
- if (RadialHandler.isShowing() && mod.keyMenuButton.consumeClick())
+ if (RadialHandler.isShowing() && VivecraftVRMod.keyMenuButton.consumeClick())
{
RadialHandler.setOverlayShowing(false, (ControllerType)null);
}
- if (mod.keyMenuButton.consumeClick())
+ if (VivecraftVRMod.keyMenuButton.consumeClick())
{
- if (!flag1)
+ if (!gui)
{
- if (!ClientDataHolderVR.kiosk)
+ if (!dh.kiosk)
{
- this.mc.pauseGame(false);
+ mc.pauseGame(false);
}
}
else
{
- InputSimulator.pressKey(256);
- InputSimulator.releaseKey(256);
+ InputSimulator.pressKey(GLFW_KEY_ESCAPE);
+ InputSimulator.releaseKey(GLFW_KEY_ESCAPE);
}
KeyboardHandler.setOverlayShowing(false);
}
- if (mod.keyTogglePlayerList.consumeClick())
+ if (VivecraftVRMod.keyTogglePlayerList.consumeClick())
{
- ((GuiExtension) this.mc.gui).setShowPlayerList(!((GuiExtension) this.mc.gui).getShowPlayerList());
+ ((GuiExtension) mc.gui).setShowPlayerList(!((GuiExtension) mc.gui).getShowPlayerList());
}
- if (mod.keyToggleHandheldCam.consumeClick() && this.mc.player != null)
+ if (VivecraftVRMod.keyToggleHandheldCam.consumeClick() && mc.player != null)
{
- this.dh.cameraTracker.toggleVisibility();
+ dh.cameraTracker.toggleVisibility();
- if (this.dh.cameraTracker.isVisible())
+ if (dh.cameraTracker.isVisible())
{
- ControllerType controllertype3 = this.findActiveBindingControllerType(mod.keyToggleHandheldCam);
+ ControllerType hand = this.findActiveBindingControllerType(VivecraftVRMod.keyToggleHandheldCam);
- if (controllertype3 == null)
+ if (hand == null)
{
- controllertype3 = ControllerType.RIGHT;
+ hand = ControllerType.RIGHT;
}
- VRData.VRDevicePose vrdata$vrdevicepose = this.dh.vrPlayer.vrdata_world_pre.getController(controllertype3.ordinal());
- this.dh.cameraTracker.setPosition(vrdata$vrdevicepose.getPosition());
- this.dh.cameraTracker.setRotation(new Quaternion(vrdata$vrdevicepose.getMatrix().transposed()));
+ VRDevicePose vrdata$vrdevicepose = dh.vrPlayer.vrdata_world_pre.getController(hand.ordinal());
+ dh.cameraTracker.setPosition(vrdata$vrdevicepose.getPosition());
+ dh.cameraTracker.setRotation(new Quaternionf().setFromNormalized(vrdata$vrdevicepose.getMatrix()));
}
}
- if (mod.keyQuickHandheldCam.consumeClick() && this.mc.player != null)
+ if (VivecraftVRMod.keyQuickHandheldCam.consumeClick() && mc.player != null)
{
- if (!this.dh.cameraTracker.isVisible())
+ if (!dh.cameraTracker.isVisible())
{
- this.dh.cameraTracker.toggleVisibility();
+ dh.cameraTracker.toggleVisibility();
}
- ControllerType controllertype4 = this.findActiveBindingControllerType(mod.keyQuickHandheldCam);
+ ControllerType hand = this.findActiveBindingControllerType(VivecraftVRMod.keyQuickHandheldCam);
- if (controllertype4 == null)
+ if (hand == null)
{
- controllertype4 = ControllerType.RIGHT;
+ hand = ControllerType.RIGHT;
}
- VRData.VRDevicePose vrdata$vrdevicepose1 = this.dh.vrPlayer.vrdata_world_pre.getController(controllertype4.ordinal());
- this.dh.cameraTracker.setPosition(vrdata$vrdevicepose1.getPosition());
- this.dh.cameraTracker.setRotation(new Quaternion(vrdata$vrdevicepose1.getMatrix().transposed()));
- this.dh.cameraTracker.startMoving(controllertype4.ordinal(), true);
+ VRDevicePose vrdata$vrdevicepose1 = dh.vrPlayer.vrdata_world_pre.getController(hand.ordinal());
+ dh.cameraTracker.setPosition(vrdata$vrdevicepose1.getPosition());
+ dh.cameraTracker.setRotation(new Quaternionf().setFromNormalized(vrdata$vrdevicepose1.getMatrix()));
+ dh.cameraTracker.startMoving(hand.ordinal(), true);
}
- if (!mod.keyQuickHandheldCam.isDown() && this.dh.cameraTracker.isMoving() && this.dh.cameraTracker.isQuickMode() && this.mc.player != null)
+ if (!VivecraftVRMod.keyQuickHandheldCam.isDown() && dh.cameraTracker.isMoving() && dh.cameraTracker.isQuickMode() && mc.player != null)
{
- this.dh.cameraTracker.stopMoving();
- this.dh.grabScreenShot = true;
+ dh.cameraTracker.stopMoving();
+ dh.grabScreenShot = true;
}
GuiHandler.processBindingsGui();
RadialHandler.processBindings();
KeyboardHandler.processBindings();
- this.dh.interactTracker.processBindings();
+ dh.interactTracker.processBindings();
}
}
public void populateInputActions()
{
- Map map = this.getSpecialActionParams();
+ Map actionParams = this.getSpecialActionParams();
// iterate over all minecraft keys, and our hidden keys
- for (KeyMapping keymapping : Stream.concat(Arrays.stream(this.mc.options.keyMappings), mod.getHiddenKeyBindings().stream()).toList())
+ for (KeyMapping keymapping : Stream.concat(Arrays.stream(mc.options.keyMappings), VivecraftVRMod.hiddenKeyBindingSet.stream()).toList())
{
- ActionParams actionparams = map.getOrDefault(keymapping.getName(), new ActionParams("optional", "boolean", (VRInputActionSet)null));
- VRInputAction vrinputaction = new VRInputAction(keymapping, actionparams.requirement, actionparams.type, actionparams.actionSetOverride);
- this.inputActions.put(vrinputaction.name, vrinputaction);
+ ActionParams params = actionParams.getOrDefault(keymapping.getName(), new ActionParams("optional", "boolean", null));
+ VRInputAction action = new VRInputAction(keymapping, params.requirement, params.type, params.actionSetOverride);
+ this.inputActions.put(action.name, action);
}
- for (VRInputAction vrinputaction1 : this.inputActions.values())
+ for (VRInputAction action : this.inputActions.values())
{
- this.inputActionsByKeyBinding.put(vrinputaction1.keyBinding.getName(), vrinputaction1);
+ this.inputActionsByKeyBinding.put(action.keyBinding.getName(), action);
}
- this.getInputAction(mod.keyVRInteract).setPriority(5).setEnabled(false);
- this.getInputAction(mod.keyClimbeyGrab).setPriority(10).setEnabled(false);
- this.getInputAction(mod.keyClimbeyJump).setEnabled(false);
+ this.getInputAction(VivecraftVRMod.keyVRInteract).setPriority(5).setEnabled(false);
+ this.getInputAction(VivecraftVRMod.keyClimbeyGrab).setPriority(10).setEnabled(false);
+ this.getInputAction(VivecraftVRMod.keyClimbeyJump).setEnabled(false);
this.getInputAction(GuiHandler.keyKeyboardClick).setPriority(50);
this.getInputAction(GuiHandler.keyKeyboardShift).setPriority(50);
}
@@ -1189,103 +1051,93 @@ public void populateInputActions()
public Map getSpecialActionParams()
{
Map map = new HashMap<>();
- this.addActionParams(map, this.mc.options.keyUp, "optional", "vector1", (VRInputActionSet)null);
- this.addActionParams(map, this.mc.options.keyDown, "optional", "vector1", (VRInputActionSet)null);
- this.addActionParams(map, this.mc.options.keyLeft, "optional", "vector1", (VRInputActionSet)null);
- this.addActionParams(map, this.mc.options.keyRight, "optional", "vector1", (VRInputActionSet)null);
- this.addActionParams(map, this.mc.options.keyInventory, "suggested", "boolean", VRInputActionSet.GLOBAL);
- this.addActionParams(map, this.mc.options.keyAttack, "suggested", "boolean", (VRInputActionSet)null);
- this.addActionParams(map, this.mc.options.keyUse, "suggested", "boolean", (VRInputActionSet)null);
- this.addActionParams(map, this.mc.options.keyChat, "optional", "boolean", VRInputActionSet.GLOBAL);
- this.addActionParams(map, mod.keyHotbarScroll, "optional", "vector2", (VRInputActionSet)null);
- this.addActionParams(map, mod.keyHotbarSwipeX, "optional", "vector2", (VRInputActionSet)null);
- this.addActionParams(map, mod.keyHotbarSwipeY, "optional", "vector2", (VRInputActionSet)null);
- this.addActionParams(map, mod.keyMenuButton, "suggested", "boolean", VRInputActionSet.GLOBAL);
- this.addActionParams(map, mod.keyTeleportFallback, "suggested", "vector1", (VRInputActionSet)null);
- this.addActionParams(map, mod.keyFreeMoveRotate, "optional", "vector2", (VRInputActionSet)null);
- this.addActionParams(map, mod.keyFreeMoveStrafe, "optional", "vector2", (VRInputActionSet)null);
- this.addActionParams(map, mod.keyRotateLeft, "optional", "vector1", (VRInputActionSet)null);
- this.addActionParams(map, mod.keyRotateRight, "optional", "vector1", (VRInputActionSet)null);
- this.addActionParams(map, mod.keyRotateAxis, "optional", "vector2", (VRInputActionSet)null);
- this.addActionParams(map, mod.keyRadialMenu, "suggested", "boolean", (VRInputActionSet)null);
- this.addActionParams(map, mod.keySwapMirrorView, "optional", "boolean", VRInputActionSet.GLOBAL);
- this.addActionParams(map, mod.keyToggleKeyboard, "optional", "boolean", VRInputActionSet.GLOBAL);
- this.addActionParams(map, mod.keyMoveThirdPersonCam, "optional", "boolean", VRInputActionSet.GLOBAL);
- this.addActionParams(map, mod.keyToggleHandheldCam, "optional", "boolean", VRInputActionSet.GLOBAL);
- this.addActionParams(map, mod.keyQuickHandheldCam, "optional", "boolean", VRInputActionSet.GLOBAL);
- this.addActionParams(map, mod.keyTrackpadTouch, "optional", "boolean", VRInputActionSet.TECHNICAL);
- this.addActionParams(map, mod.keyVRInteract, "suggested", "boolean", VRInputActionSet.CONTEXTUAL);
- this.addActionParams(map, mod.keyClimbeyGrab, "suggested", "boolean", (VRInputActionSet)null);
- this.addActionParams(map, mod.keyClimbeyJump, "suggested", "boolean", (VRInputActionSet)null);
- this.addActionParams(map, GuiHandler.keyLeftClick, "suggested", "boolean", (VRInputActionSet)null);
- this.addActionParams(map, GuiHandler.keyScrollAxis, "optional", "vector2", (VRInputActionSet)null);
- this.addActionParams(map, GuiHandler.keyRightClick, "suggested", "boolean", (VRInputActionSet)null);
- this.addActionParams(map, GuiHandler.keyShift, "suggested", "boolean", (VRInputActionSet)null);
- this.addActionParams(map, GuiHandler.keyKeyboardClick, "suggested", "boolean", (VRInputActionSet)null);
- this.addActionParams(map, GuiHandler.keyKeyboardShift, "suggested", "boolean", (VRInputActionSet)null);
- File file1 = new File("customactionsets.txt");
-
- if (file1.exists())
+ this.addActionParams(map, mc.options.keyUp, "optional", "vector1", null);
+ this.addActionParams(map, mc.options.keyDown, "optional", "vector1", null);
+ this.addActionParams(map, mc.options.keyLeft, "optional", "vector1", null);
+ this.addActionParams(map, mc.options.keyRight, "optional", "vector1", null);
+ this.addActionParams(map, mc.options.keyInventory, "suggested", "boolean", VRInputActionSet.GLOBAL);
+ this.addActionParams(map, mc.options.keyAttack, "suggested", "boolean", null);
+ this.addActionParams(map, mc.options.keyUse, "suggested", "boolean", null);
+ this.addActionParams(map, mc.options.keyChat, "optional", "boolean", VRInputActionSet.GLOBAL);
+ this.addActionParams(map, VivecraftVRMod.keyHotbarScroll, "optional", "vector2", null);
+ this.addActionParams(map, VivecraftVRMod.keyHotbarSwipeX, "optional", "vector2", null);
+ this.addActionParams(map, VivecraftVRMod.keyHotbarSwipeY, "optional", "vector2", null);
+ this.addActionParams(map, VivecraftVRMod.keyMenuButton, "suggested", "boolean", VRInputActionSet.GLOBAL);
+ this.addActionParams(map, VivecraftVRMod.keyTeleportFallback, "suggested", "vector1", null);
+ this.addActionParams(map, VivecraftVRMod.keyFreeMoveRotate, "optional", "vector2", null);
+ this.addActionParams(map, VivecraftVRMod.keyFreeMoveStrafe, "optional", "vector2", null);
+ this.addActionParams(map, VivecraftVRMod.keyRotateLeft, "optional", "vector1", null);
+ this.addActionParams(map, VivecraftVRMod.keyRotateRight, "optional", "vector1", null);
+ this.addActionParams(map, VivecraftVRMod.keyRotateAxis, "optional", "vector2", null);
+ this.addActionParams(map, VivecraftVRMod.keyRadialMenu, "suggested", "boolean", null);
+ this.addActionParams(map, VivecraftVRMod.keySwapMirrorView, "optional", "boolean", VRInputActionSet.GLOBAL);
+ this.addActionParams(map, VivecraftVRMod.keyToggleKeyboard, "optional", "boolean", VRInputActionSet.GLOBAL);
+ this.addActionParams(map, VivecraftVRMod.keyMoveThirdPersonCam, "optional", "boolean", VRInputActionSet.GLOBAL);
+ this.addActionParams(map, VivecraftVRMod.keyToggleHandheldCam, "optional", "boolean", VRInputActionSet.GLOBAL);
+ this.addActionParams(map, VivecraftVRMod.keyQuickHandheldCam, "optional", "boolean", VRInputActionSet.GLOBAL);
+ this.addActionParams(map, VivecraftVRMod.keyTrackpadTouch, "optional", "boolean", VRInputActionSet.TECHNICAL);
+ this.addActionParams(map, VivecraftVRMod.keyVRInteract, "suggested", "boolean", VRInputActionSet.CONTEXTUAL);
+ this.addActionParams(map, VivecraftVRMod.keyClimbeyGrab, "suggested", "boolean", null);
+ this.addActionParams(map, VivecraftVRMod.keyClimbeyJump, "suggested", "boolean", null);
+ this.addActionParams(map, GuiHandler.keyLeftClick, "suggested", "boolean", null);
+ this.addActionParams(map, GuiHandler.keyScrollAxis, "optional", "vector2", null);
+ this.addActionParams(map, GuiHandler.keyRightClick, "suggested", "boolean", null);
+ this.addActionParams(map, GuiHandler.keyShift, "suggested", "boolean", null);
+ this.addActionParams(map, GuiHandler.keyKeyboardClick, "suggested", "boolean", null);
+ this.addActionParams(map, GuiHandler.keyKeyboardShift, "suggested", "boolean", null);
+ File file = new File("customactionsets.txt");
+
+ if (file.exists())
{
- System.out.println("Loading custom action set definitions...");
- String s;
+ logger.info("Loading custom action set definitions...");
+ String line;
- try (BufferedReader bufferedreader = new BufferedReader(new FileReader(file1)))
+ try (BufferedReader br = new BufferedReader(new FileReader(file)))
{
- while ((s = bufferedreader.readLine()) != null)
+ while ((line = br.readLine()) != null)
{
- String[] astring = s.split(":", 2);
+ String[] tokens = line.split(":", 2);
- if (astring.length < 2)
+ if (tokens.length < 2)
{
- System.out.println("Invalid tokens: " + s);
+ logger.warn("Invalid tokens: {}", line);
}
else
{
- KeyMapping keymapping = this.findKeyBinding(astring[0]);
+ KeyMapping keymapping = this.findKeyBinding(tokens[0]);
if (keymapping == null)
{
- System.out.println("Unknown key binding: " + astring[0]);
+ logger.warn("Unknown key binding: {}", tokens[0]);
}
- else if (mod.getAllKeyBindings().contains(keymapping))
+ else if (VivecraftVRMod.allKeyBindingSet.contains(keymapping))
{
- System.out.println("NO! Don't touch Vivecraft bindings!");
+ logger.warn("NO! Don't touch Vivecraft bindings!");
}
else
{
- VRInputActionSet vrinputactionset = null;
- String s1 = astring[1].toLowerCase();
-
- switch (s1)
- {
- case "ingame":
- vrinputactionset = VRInputActionSet.INGAME;
- break;
-
- case "gui":
- vrinputactionset = VRInputActionSet.GUI;
- break;
-
- case "global":
- vrinputactionset = VRInputActionSet.GLOBAL;
- }
-
- if (vrinputactionset == null)
+ VRInputActionSet actionSet = switch (tokens[1].toLowerCase()) {
+ case "ingame" -> VRInputActionSet.INGAME;
+ case "gui" -> VRInputActionSet.GUI;
+ case "global" -> VRInputActionSet.GLOBAL;
+ default -> null;
+ };
+
+ if (actionSet == null)
{
- System.out.println("Unknown action set: " + astring[1]);
+ logger.warn("Unknown action set: {}", tokens[1]);
}
else
{
- this.addActionParams(map, keymapping, "optional", "boolean", vrinputactionset);
+ this.addActionParams(map, keymapping, "optional", "boolean", actionSet);
}
}
}
}
}
- catch (IOException ioexception)
+ catch (IOException e)
{
- ioexception.printStackTrace();
+ e.printStackTrace();
}
}
@@ -1294,30 +1146,30 @@ else if (mod.getAllKeyBindings().contains(keymapping))
protected void changeHotbar(int dir)
{
- if (this.mc.player != null && (!this.dh.climbTracker.isGrabbingLadder() || !this.dh.climbTracker.isClaws(this.mc.player.getMainHandItem())))
+ if (mc.player != null && (!dh.climbTracker.isGrabbingLadder() || !dh.climbTracker.isClaws(mc.player.getMainHandItem())))
{
- if (this.mc.screen == null)
+ if (mc.screen == null)
{
InputSimulator.scrollMouse(0.0D, (double)(dir * 4));
}
else
{
- this.mc.player.getInventory().swapPaint((double)dir);
+ mc.player.getInventory().swapPaint((double)dir);
}
}
}
- private void addActionParams(Map map, KeyMapping keyBinding, String requirement, String type, VRInputActionSet actionSetOverride)
+ private void addActionParams(Map map, KeyMapping keymapping, String requirement, String type, @Nullable VRInputActionSet actionSetOverride)
{
ActionParams actionparams = new ActionParams(requirement, type, actionSetOverride);
- map.put(keyBinding.getName(), actionparams);
+ map.put(keymapping.getName(), actionparams);
}
- protected abstract void triggerBindingHapticPulse(KeyMapping var1, int var2);
+ protected abstract void triggerBindingHapticPulse(KeyMapping binding, int duration);
- protected abstract ControllerType findActiveBindingControllerType(KeyMapping var1);
+ protected abstract ControllerType findActiveBindingControllerType(KeyMapping binding);
- public abstract void poll(long var1);
+ public abstract void poll(long frameIndex);
public abstract Vector2f getPlayAreaSize();
@@ -1325,11 +1177,13 @@ private void addActionParams(Map map, KeyMapping keyBindin
public abstract boolean postinit() throws RenderConfigException;
- public abstract org.vivecraft.common.utils.math.Matrix4f getControllerComponentTransform(int var1, String var2);
+ public abstract Matrix4f getControllerComponentTransform(int controllerIndex, String componentName);
+
+ public abstract ControllerType getOriginControllerType(long inputValueHandle);
public abstract boolean hasThirdController();
- public abstract List getOrigins(VRInputAction var1);
+ public abstract List getOrigins(VRInputAction action);
public abstract String getOriginName(long l);
diff --git a/common/src/main/java/org/vivecraft/client_vr/provider/VRRenderer.java b/common/src/main/java/org/vivecraft/client_vr/provider/VRRenderer.java
index 71d42f8d0..921db4462 100644
--- a/common/src/main/java/org/vivecraft/client_vr/provider/VRRenderer.java
+++ b/common/src/main/java/org/vivecraft/client_vr/provider/VRRenderer.java
@@ -1,12 +1,36 @@
package org.vivecraft.client_vr.provider;
+import org.vivecraft.client.extensions.RenderTargetExtension;
+import org.vivecraft.client_vr.VRTextureTarget;
+import org.vivecraft.client_vr.extensions.GameRendererExtension;
+import org.vivecraft.client_vr.gameplay.screenhandlers.GuiHandler;
+import org.vivecraft.client_vr.gameplay.screenhandlers.KeyboardHandler;
+import org.vivecraft.client_vr.gameplay.screenhandlers.RadialHandler;
+import org.vivecraft.client_vr.gameplay.trackers.TelescopeTracker;
+import org.vivecraft.client_vr.render.RenderConfigException;
+import org.vivecraft.client_vr.render.RenderPass;
+import org.vivecraft.client_vr.render.ShaderHelper;
+import org.vivecraft.client_vr.render.VRShaders;
+import org.vivecraft.client_vr.settings.VRSettings.MirrorMode;
+import org.vivecraft.client_xr.render_pass.WorldRenderPass;
+import org.vivecraft.mod_compat_vr.ShadersHelper;
+import org.vivecraft.mod_compat_vr.resolutioncontrol.ResolutionControlHelper;
+
+import org.joml.Matrix4f;
+import org.joml.RoundingMode;
+import org.lwjgl.opengl.GL11C;
+import org.lwjgl.opengl.GL13C;
+import org.lwjgl.opengl.GL20C;
+import org.lwjgl.system.MemoryUtil;
+
import com.mojang.blaze3d.pipeline.RenderTarget;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.platform.GlUtil;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.*;
+import com.mojang.blaze3d.vertex.VertexFormat.Mode;
+
import net.minecraft.client.GraphicsStatus;
-import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceKey;
@@ -14,38 +38,26 @@
import net.minecraft.util.Tuple;
import net.minecraft.world.level.dimension.BuiltinDimensionTypes;
import net.minecraft.world.level.dimension.DimensionType;
-import org.joml.Matrix4f;
-import org.lwjgl.opengl.GL11;
-import org.lwjgl.opengl.GL43;
-import org.lwjgl.system.MemoryUtil;
-import org.vivecraft.client.extensions.RenderTargetExtension;
-import org.vivecraft.client_vr.ClientDataHolderVR;
-import org.vivecraft.mod_compat_vr.ShadersHelper;
-import org.vivecraft.client_vr.VRTextureTarget;
-import org.vivecraft.client_vr.extensions.GameRendererExtension;
-import org.vivecraft.client_vr.settings.VRSettings;
-import org.vivecraft.client_vr.gameplay.screenhandlers.GuiHandler;
-import org.vivecraft.client_vr.gameplay.screenhandlers.KeyboardHandler;
-import org.vivecraft.client_vr.gameplay.screenhandlers.RadialHandler;
-import org.vivecraft.client_vr.gameplay.trackers.TelescopeTracker;
-import org.vivecraft.client_xr.render_pass.WorldRenderPass;
-import org.vivecraft.client_vr.render.RenderConfigException;
-import org.vivecraft.client_vr.render.RenderPass;
-import org.vivecraft.client_vr.render.ShaderHelper;
-import org.vivecraft.client_vr.render.VRShaders;
-import org.vivecraft.mod_compat_vr.resolutioncontrol.ResolutionControlHelper;
import java.nio.FloatBuffer;
import java.util.ArrayList;
import java.util.List;
+import static org.vivecraft.client_vr.VRState.dh;
+import static org.vivecraft.client_vr.VRState.mc;
+import static org.vivecraft.common.utils.Utils.logger;
+
+import static org.joml.Math.*;
+
+import static net.minecraft.client.Minecraft.ON_OSX;
+
public abstract class VRRenderer {
public static final String RENDER_SETUP_FAILURE_MESSAGE = "Failed to initialise stereo rendering plugin: ";
public RenderTarget cameraFramebuffer;
public RenderTarget cameraRenderFramebuffer;
protected int dispLastWidth;
protected int dispLastHeight;
- public Matrix4f[] eyeproj = new Matrix4f[2];
+ public Matrix4f[] eyeproj = new Matrix4f[]{new Matrix4f(), new Matrix4f()};
public RenderTarget framebufferEye0;
public RenderTarget framebufferEye1;
public RenderTarget framebufferMR;
@@ -60,9 +72,9 @@ public abstract class VRRenderer {
public boolean lastEnableVsync = true;
public boolean lastFogFancy = true;
public boolean lastFogFast = false;
- private GraphicsStatus previousGraphics = null;
+ private GraphicsStatus previousGraphics;
public int lastGuiScale = 0;
- protected VRSettings.MirrorMode lastMirror;
+ protected MirrorMode lastMirror;
public int lastRenderDistanceChunks = -1;
public long lastWindow = 0L;
public float lastWorldScale = 0.0F;
@@ -94,11 +106,13 @@ protected void checkGLError(String message) {
public abstract void createRenderTexture(int var1, int var2);
- public abstract Matrix4f getProjectionMatrix(int var1, float var2, float var3);
+ public abstract Matrix4f getProjectionMatrix(int eyeType, double nearClip, double farClip, Matrix4f dest);
public abstract void endFrame() throws RenderConfigException;
- public abstract boolean providesStencilMask();
+ public boolean providesStencilMask(){
+ return false;
+ };
public void deleteRenderTextures() {
if (this.LeftEyeTextureId > 0) {
@@ -113,12 +127,10 @@ public void deleteRenderTextures() {
}
public void doStencil(boolean inverse) {
- Minecraft minecraft = Minecraft.getInstance();
- ClientDataHolderVR dataholder = ClientDataHolderVR.getInstance();
//setup stencil for writing
- GL11.glEnable(GL11.GL_STENCIL_TEST);
- RenderSystem.stencilOp(GL11.GL_KEEP, GL11.GL_KEEP, GL11.GL_REPLACE);
+ GL11C.glEnable(GL11C.GL_STENCIL_TEST);
+ RenderSystem.stencilOp(GL11C.GL_KEEP, GL11C.GL_KEEP, GL11C.GL_REPLACE);
RenderSystem.stencilMask(0xFF); // Write to stencil buffer
if (inverse) {
@@ -126,7 +138,7 @@ public void doStencil(boolean inverse) {
RenderSystem.clearStencil(0xFF);
RenderSystem.clearDepth(0);
- RenderSystem.stencilFunc(GL11.GL_ALWAYS, 0, 0xFF); // Set any stencil to 0
+ RenderSystem.stencilFunc(GL11C.GL_ALWAYS, 0, 0xFF); // Set any stencil to 0
RenderSystem.colorMask(false, false, false, true);
} else {
@@ -134,36 +146,36 @@ public void doStencil(boolean inverse) {
RenderSystem.clearStencil(0);
RenderSystem.clearDepth(1);
- RenderSystem.stencilFunc(GL11.GL_ALWAYS, 0xFF, 0xFF); // Set any stencil to 1
+ RenderSystem.stencilFunc(GL11C.GL_ALWAYS, 0xFF, 0xFF); // Set any stencil to 1
RenderSystem.colorMask(true, true, true, true);
}
- RenderSystem.clear(GL11.GL_DEPTH_BUFFER_BIT | GL11.GL_STENCIL_BUFFER_BIT, false);
+ RenderSystem.clear(GL11C.GL_DEPTH_BUFFER_BIT | GL11C.GL_STENCIL_BUFFER_BIT, false);
RenderSystem.clearStencil(0);
RenderSystem.clearDepth(1);
RenderSystem.depthMask(true);
RenderSystem.enableDepthTest();
- RenderSystem.depthFunc(GL11.GL_ALWAYS);
+ RenderSystem.depthFunc(GL11C.GL_ALWAYS);
RenderSystem.disableCull();
- RenderSystem.setShaderColor(0F, 0F, 0F, 1.0F);
+ RenderSystem.setShaderColor(0.0F, 0.0F, 0.0F, 1.0F);
- RenderTarget fb = minecraft.getMainRenderTarget();
+ RenderTarget fb = mc.getMainRenderTarget();
RenderSystem.backupProjectionMatrix();
RenderSystem.setProjectionMatrix(new Matrix4f().setOrtho(0.0F, fb.viewWidth, 0.0F, fb.viewHeight, 0.0F, 20.0F), VertexSorting.ORTHOGRAPHIC_Z);
RenderSystem.getModelViewStack().pushPose();
RenderSystem.getModelViewStack().setIdentity();
if (inverse) //draw on far clip
- RenderSystem.getModelViewStack().translate(0, 0, -20);
+ RenderSystem.getModelViewStack().last().pose().translate(0.0F, 0.0F, -20.0F);
RenderSystem.applyModelViewMatrix();
- int s = GlStateManager._getInteger(GL43.GL_CURRENT_PROGRAM);
+ int s = GlStateManager._getInteger(GL20C.GL_CURRENT_PROGRAM);
- if (dataholder.currentPass == RenderPass.SCOPEL || dataholder.currentPass == RenderPass.SCOPER) {
+ if (dh.currentPass == RenderPass.SCOPEL || dh.currentPass == RenderPass.SCOPER) {
drawCircle(fb.viewWidth, fb.viewHeight);
- } else if (dataholder.currentPass == RenderPass.LEFT || dataholder.currentPass == RenderPass.RIGHT) {
+ } else if (dh.currentPass == RenderPass.LEFT || dh.currentPass == RenderPass.RIGHT) {
drawMask();
}
@@ -177,10 +189,10 @@ public void doStencil(boolean inverse) {
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
RenderSystem.enableCull();
GlStateManager._glUseProgram(s);
- RenderSystem.stencilFunc(GL11.GL_NOTEQUAL, 255, 1);
- RenderSystem.stencilOp(GL11.GL_KEEP, GL11.GL_KEEP, GL11.GL_KEEP);
+ RenderSystem.stencilFunc(GL11C.GL_NOTEQUAL, 255, 1);
+ RenderSystem.stencilOp(GL11C.GL_KEEP, GL11C.GL_KEEP, GL11C.GL_KEEP);
RenderSystem.stencilMask(0); // Dont Write to stencil buffer
- RenderSystem.depthFunc(GL11.GL_LEQUAL);
+ RenderSystem.depthFunc(GL11C.GL_LEQUAL);
}
FloatBuffer buffer = MemoryUtil.memAllocFloat(16);
@@ -192,7 +204,7 @@ public void doFSAA(boolean hasShaders) {
} else {
RenderSystem.disableBlend();
// set to always, so that we can skip the clear
- RenderSystem.depthFunc(GL43.GL_ALWAYS);
+ RenderSystem.depthFunc(GL11C.GL_ALWAYS);
// first pass
this.fsaaFirstPassResultFBO.bindWrite(true);
@@ -200,11 +212,11 @@ public void doFSAA(boolean hasShaders) {
RenderSystem.setShaderTexture(0, framebufferVrRender.getColorTextureId());
RenderSystem.setShaderTexture(1, framebufferVrRender.getDepthTextureId());
- RenderSystem.activeTexture(GL43.GL_TEXTURE1);
+ RenderSystem.activeTexture(GL13C.GL_TEXTURE1);
this.framebufferVrRender.bindRead();
- RenderSystem.activeTexture(GL43.GL_TEXTURE2);
+ RenderSystem.activeTexture(GL13C.GL_TEXTURE2);
RenderSystem.bindTexture(framebufferVrRender.getDepthTextureId());
- RenderSystem.activeTexture(GL43.GL_TEXTURE0);
+ RenderSystem.activeTexture(GL13C.GL_TEXTURE0);
VRShaders.lanczosShader.setSampler("Sampler0", RenderSystem.getShaderTexture(0));
VRShaders.lanczosShader.setSampler("Sampler1", RenderSystem.getShaderTexture(1));
@@ -219,11 +231,11 @@ public void doFSAA(boolean hasShaders) {
RenderSystem.setShaderTexture(0, this.fsaaFirstPassResultFBO.getColorTextureId());
RenderSystem.setShaderTexture(1, this.fsaaFirstPassResultFBO.getDepthTextureId());
- RenderSystem.activeTexture(GL43.GL_TEXTURE1);
+ RenderSystem.activeTexture(GL13C.GL_TEXTURE1);
this.fsaaFirstPassResultFBO.bindRead();
- RenderSystem.activeTexture(GL43.GL_TEXTURE2);
+ RenderSystem.activeTexture(GL13C.GL_TEXTURE2);
RenderSystem.bindTexture(fsaaFirstPassResultFBO.getDepthTextureId());
- RenderSystem.activeTexture(GL43.GL_TEXTURE0);
+ RenderSystem.activeTexture(GL13C.GL_TEXTURE0);
VRShaders.lanczosShader.setSampler("Sampler0", RenderSystem.getShaderTexture(0));
VRShaders.lanczosShader.setSampler("Sampler1", RenderSystem.getShaderTexture(1));
@@ -235,34 +247,32 @@ public void doFSAA(boolean hasShaders) {
// Clean up time
VRShaders.lanczosShader.clear();
- Minecraft.getInstance().getMainRenderTarget().bindWrite(true);
- RenderSystem.depthFunc(GL43.GL_LEQUAL);
+ mc.getMainRenderTarget().bindWrite(true);
+ RenderSystem.depthFunc(GL11C.GL_LEQUAL);
}
}
private void drawCircle(float width, float height) {
BufferBuilder builder = Tesselator.getInstance().getBuilder();
- builder.begin(VertexFormat.Mode.TRIANGLE_FAN, DefaultVertexFormat.POSITION);
+ builder.begin(Mode.TRIANGLE_FAN, DefaultVertexFormat.POSITION);
int i = 32;
- float f = (float) (width / 2);
- builder.vertex((float) (width / 2), (float) (width / 2), 0.0F).endVertex();
+ float f = width / 2;
+ builder.vertex(f, f, 0.0D).endVertex();
for (int j = 0; j < i + 1; ++j) {
- float f1 = (float) j / (float) i * (float) Math.PI * 2.0F;
- float f2 = (float) ((double) (width / 2) + Math.cos((double) f1) * (double) f);
- float f3 = (float) ((double) (width / 2) + Math.sin((double) f1) * (double) f);
- builder.vertex(f2, f3, 0.0F).endVertex();
+ double f1 = (double) j / i * PI * 2.0D;
+ double f2 = f + cos(f1) * f;
+ double f3 = f + sin(f1) * f;
+ builder.vertex(f2, f3, 0.0D).endVertex();
}
BufferUploader.drawWithShader(builder.end());
}
private void drawMask() {
- Minecraft mc = Minecraft.getInstance();
- ClientDataHolderVR dh = ClientDataHolderVR.getInstance();
float[] verts = getStencilMask(dh.currentPass);
if (verts == null) return;
BufferBuilder builder = Tesselator.getInstance().getBuilder();
- builder.begin(VertexFormat.Mode.TRIANGLES, DefaultVertexFormat.POSITION);
+ builder.begin(Mode.TRIANGLES, DefaultVertexFormat.POSITION);
mc.getTextureManager().bindForSetup(new ResourceLocation("vivecraft:textures/black.png"));
@@ -277,7 +287,7 @@ private void drawMask() {
private void drawQuad() {
//RenderSystem.setShader(GameRenderer::getPositionTexShader);
BufferBuilder builder = Tesselator.getInstance().getBuilder();
- builder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX);
+ builder.begin(Mode.QUADS, DefaultVertexFormat.POSITION_TEX);
builder.vertex(-1.0F, -1.0F, 0.0F).uv(0.0F, 0.0F).endVertex();
builder.vertex(1.0F, -1.0F, 0.0F).uv(1.0F, 0.0F).endVertex();
builder.vertex(1.0F, 1.0F, 0.0F).uv(1.0F, 1.0F).endVertex();
@@ -286,7 +296,7 @@ private void drawQuad() {
}
public double getCurrentTimeSecs() {
- return (double) System.nanoTime() / 1.0E9D;
+ return System.nanoTime() / 1.0E9D;
}
public double getFrameTiming() {
@@ -302,41 +312,39 @@ public String getLastError() {
}
public String getName() {
- return "OpenVR";
+ return "Default Renderer Name";
}
public List getRenderPasses() {
- Minecraft minecraft = Minecraft.getInstance();
- ClientDataHolderVR dataholder = ClientDataHolderVR.getInstance();
List list = new ArrayList<>();
list.add(RenderPass.LEFT);
list.add(RenderPass.RIGHT);
// only do these, if the window is not minimized
- if (minecraft.getWindow().getScreenWidth() > 0 && minecraft.getWindow().getScreenHeight() > 0) {
- if (dataholder.vrSettings.displayMirrorMode == VRSettings.MirrorMode.FIRST_PERSON) {
+ if (mc.getWindow().getScreenWidth() > 0 && mc.getWindow().getScreenHeight() > 0) {
+ if (dh.vrSettings.displayMirrorMode == MirrorMode.FIRST_PERSON) {
list.add(RenderPass.CENTER);
- } else if (dataholder.vrSettings.displayMirrorMode == VRSettings.MirrorMode.MIXED_REALITY) {
- if (dataholder.vrSettings.mixedRealityUndistorted && dataholder.vrSettings.mixedRealityUnityLike) {
+ } else if (dh.vrSettings.displayMirrorMode == MirrorMode.MIXED_REALITY) {
+ if (dh.vrSettings.mixedRealityUndistorted && dh.vrSettings.mixedRealityUnityLike) {
list.add(RenderPass.CENTER);
}
list.add(RenderPass.THIRD);
- } else if (dataholder.vrSettings.displayMirrorMode == VRSettings.MirrorMode.THIRD_PERSON) {
+ } else if (dh.vrSettings.displayMirrorMode == MirrorMode.THIRD_PERSON) {
list.add(RenderPass.THIRD);
}
}
- if (minecraft.player != null) {
- if (TelescopeTracker.isTelescope(minecraft.player.getMainHandItem()) && TelescopeTracker.isViewing(0)) {
+ if (mc.player != null) {
+ if (TelescopeTracker.isTelescope(mc.player.getMainHandItem()) && TelescopeTracker.isViewing(0)) {
list.add(RenderPass.SCOPER);
}
- if (TelescopeTracker.isTelescope(minecraft.player.getOffhandItem()) && TelescopeTracker.isViewing(1)) {
+ if (TelescopeTracker.isTelescope(mc.player.getOffhandItem()) && TelescopeTracker.isViewing(1)) {
list.add(RenderPass.SCOPEL);
}
- if (dataholder.cameraTracker.isVisible()) {
+ if (dh.cameraTracker.isVisible()) {
list.add(RenderPass.CAMERA);
}
}
@@ -347,13 +355,13 @@ public List getRenderPasses() {
public abstract Tuple getRenderTextureSizes();
public Tuple getMirrorTextureSize(int eyeFBWidth, int eyeFBHeight, float resolutionScale) {
- mirrorFBWidth = (int) Math.ceil(Minecraft.getInstance().getWindow().getScreenWidth() * resolutionScale);
- mirrorFBHeight = (int) Math.ceil(Minecraft.getInstance().getWindow().getScreenHeight() * resolutionScale);
+ mirrorFBWidth = roundUsing(mc.getWindow().getScreenWidth() * resolutionScale, RoundingMode.CEILING);
+ mirrorFBHeight = roundUsing(mc.getWindow().getScreenHeight() * resolutionScale, RoundingMode.CEILING);
- if (ClientDataHolderVR.getInstance().vrSettings.displayMirrorMode == VRSettings.MirrorMode.MIXED_REALITY) {
+ if (dh.vrSettings.displayMirrorMode == MirrorMode.MIXED_REALITY) {
mirrorFBWidth = mirrorFBWidth / 2;
- if (ClientDataHolderVR.getInstance().vrSettings.mixedRealityUnityLike) {
+ if (dh.vrSettings.mixedRealityUnityLike) {
mirrorFBHeight = mirrorFBHeight / 2;
}
}
@@ -379,8 +387,8 @@ public Tuple getTelescopeTextureSize(int eyeFBWidth, int eyeFB
}
public Tuple getCameraTextureSize(int eyeFBWidth, int eyeFBHeight) {
- int cameraFBwidth = Math.round(1920.0F * ClientDataHolderVR.getInstance().vrSettings.handCameraResScale);
- int cameraFBheight = Math.round(1080.0F * ClientDataHolderVR.getInstance().vrSettings.handCameraResScale);
+ int cameraFBwidth = round(1920.0F * dh.vrSettings.handCameraResScale);
+ int cameraFBheight = round(1080.0F * dh.vrSettings.handCameraResScale);
if (ShadersHelper.needsSameSizeBuffers())
{
@@ -389,11 +397,11 @@ public Tuple getCameraTextureSize(int eyeFBWidth, int eyeFBHei
if (aspect > (float)(eyeFBWidth / eyeFBHeight))
{
cameraFBwidth = eyeFBWidth;
- cameraFBheight = Math.round((float)eyeFBWidth / aspect);
+ cameraFBheight = round((float)eyeFBWidth / aspect);
}
else
{
- cameraFBwidth = Math.round((float)eyeFBHeight * aspect);
+ cameraFBwidth = round((float)eyeFBHeight * aspect);
cameraFBheight = eyeFBHeight;
}
}
@@ -416,7 +424,7 @@ public void reinitFrameBuffers(String cause) {
if (acceptReinits) {
if (!reinitFramebuffers) {
// only print the first cause
- System.out.println("Reinit Render: " + cause);
+ logger.info("Reinit Render: {}", cause);
}
this.reinitFramebuffers = true;
}
@@ -430,39 +438,37 @@ public void resizeFrameBuffers(String cause) {
}
public void setupRenderConfiguration() throws Exception {
- Minecraft minecraft = Minecraft.getInstance();
- ClientDataHolderVR dataholder = ClientDataHolderVR.getInstance();
- if (minecraft.getWindow().getWindow() != this.lastWindow) {
- this.lastWindow = minecraft.getWindow().getWindow();
+ if (mc.getWindow().getWindow() != this.lastWindow) {
+ this.lastWindow = mc.getWindow().getWindow();
this.reinitFrameBuffers("Window Handle Changed");
}
- if (this.lastEnableVsync != minecraft.options.enableVsync().get()) {
+ if (this.lastEnableVsync != mc.options.enableVsync().get()) {
this.reinitFrameBuffers("VSync Changed");
- this.lastEnableVsync = minecraft.options.enableVsync().get();
+ this.lastEnableVsync = mc.options.enableVsync().get();
}
- if (this.lastMirror != dataholder.vrSettings.displayMirrorMode) {
+ if (this.lastMirror != dh.vrSettings.displayMirrorMode) {
if (!ShadersHelper.isShaderActive()) {
// don't reinit with shaders, not needed
this.reinitFrameBuffers("Mirror Changed");
} else {
// mixed reality is half size, so a resize is needed
- if (lastMirror == VRSettings.MirrorMode.MIXED_REALITY
- || dataholder.vrSettings.displayMirrorMode == VRSettings.MirrorMode.MIXED_REALITY) {
+ if (lastMirror == MirrorMode.MIXED_REALITY
+ || dh.vrSettings.displayMirrorMode == MirrorMode.MIXED_REALITY) {
this.resizeFrameBuffers("Mirror Changed");
}
}
- this.lastMirror = dataholder.vrSettings.displayMirrorMode;
+ this.lastMirror = dh.vrSettings.displayMirrorMode;
}
if ((framebufferMR == null || framebufferUndistorted == null) && ShadersHelper.isShaderActive()) {
this.reinitFrameBuffers("Shaders on, but some buffers not initialized");
}
- if (Minecraft.getInstance().options.graphicsMode().get() != previousGraphics) {
- previousGraphics = Minecraft.getInstance().options.graphicsMode().get();
- ClientDataHolderVR.getInstance().vrRenderer.reinitFrameBuffers("gfx setting change");
+ if (mc.options.graphicsMode().get() != previousGraphics) {
+ previousGraphics = mc.options.graphicsMode().get();
+ dh.vrRenderer.reinitFrameBuffers("gfx setting change");
}
if (this.resizeFrameBuffers && !this.reinitFramebuffers) {
@@ -473,19 +479,19 @@ public void setupRenderConfiguration() throws Exception {
float resolutionScale = ResolutionControlHelper.isLoaded() ? ResolutionControlHelper.getCurrentScaleFactor() : 1.0F;
- this.renderScale = (float) Math.sqrt(dataholder.vrSettings.renderScaleFactor) * resolutionScale;
- int eyeFBWidth = (int) Math.ceil(eyew * this.renderScale);
- int eyeFBHeight = (int) Math.ceil(eyeh * this.renderScale);
+ this.renderScale = sqrt(dh.vrSettings.renderScaleFactor) * resolutionScale;
+ int eyeFBWidth = roundUsing(eyew * this.renderScale, RoundingMode.CEILING);
+ int eyeFBHeight = roundUsing(eyeh * this.renderScale, RoundingMode.CEILING);
Tuple mirrorSize = getMirrorTextureSize(eyeFBWidth, eyeFBHeight, resolutionScale);
Tuple telescopeSize = getTelescopeTextureSize(eyeFBWidth, eyeFBHeight);
Tuple cameraSize = getCameraTextureSize(eyeFBWidth, eyeFBHeight);
// main render target
- ((RenderTargetExtension) WorldRenderPass.stereoXR.target).setUseStencil(dataholder.vrSettings.vrUseStencil);
+ ((RenderTargetExtension) WorldRenderPass.stereoXR.target).setUseStencil(dh.vrSettings.vrUseStencil);
WorldRenderPass.stereoXR.resize(eyeFBWidth, eyeFBHeight);
- if (dataholder.vrSettings.useFsaa) {
- this.fsaaFirstPassResultFBO.resize(eyew, eyeFBHeight, Minecraft.ON_OSX);
+ if (dh.vrSettings.useFsaa) {
+ this.fsaaFirstPassResultFBO.resize(eyew, eyeFBHeight, ON_OSX);
}
// mirror
@@ -501,7 +507,7 @@ public void setupRenderConfiguration() throws Exception {
WorldRenderPass.rightTelescope.resize(telescopeSize.getA(), telescopeSize.getB());
// camera
- cameraFramebuffer.resize(cameraSize.getA(), cameraSize.getB(), Minecraft.ON_OSX);
+ cameraFramebuffer.resize(cameraSize.getA(), cameraSize.getB(), ON_OSX);
if (ShadersHelper.needsSameSizeBuffers()) {
WorldRenderPass.camera.resize(eyeFBWidth, eyeFBHeight);
} else {
@@ -535,33 +541,33 @@ public void setupRenderConfiguration() throws Exception {
throw new RenderConfigException("Failed to initialise stereo rendering plugin: " + this.getName(), Component.literal(this.getLastError()));
}
- dataholder.print("Provider supplied render texture IDs: " + this.LeftEyeTextureId + " " + this.RightEyeTextureId);
- dataholder.print("Provider supplied texture resolution: " + eyew + " x " + eyeh);
+ logger.info("Provider supplied render texture IDs: {} {}", this.LeftEyeTextureId, this.RightEyeTextureId);
+ logger.info("Provider supplied texture resolution: {} x {}", eyew, eyeh);
}
this.checkGLError("Render Texture setup");
if (this.framebufferEye0 == null) {
this.framebufferEye0 = new VRTextureTarget("L Eye", eyew, eyeh, false, false, this.LeftEyeTextureId, false, true, false);
- dataholder.print(this.framebufferEye0.toString());
+ logger.info(this.framebufferEye0.toString());
this.checkGLError("Left Eye framebuffer setup");
}
if (this.framebufferEye1 == null) {
this.framebufferEye1 = new VRTextureTarget("R Eye", eyew, eyeh, false, false, this.RightEyeTextureId, false, true, false);
- dataholder.print(this.framebufferEye1.toString());
+ logger.info(this.framebufferEye1.toString());
this.checkGLError("Right Eye framebuffer setup");
}
float resolutionScale = ResolutionControlHelper.isLoaded() ? ResolutionControlHelper.getCurrentScaleFactor() : 1.0F;
- this.renderScale = (float) Math.sqrt(dataholder.vrSettings.renderScaleFactor) * resolutionScale;
- int eyeFBWidth = (int) Math.ceil(eyew * this.renderScale);
- int eyeFBHeight = (int) Math.ceil(eyeh * this.renderScale);
+ this.renderScale = (float) sqrt(dh.vrSettings.renderScaleFactor) * resolutionScale;
+ int eyeFBWidth = roundUsing(eyew * this.renderScale, RoundingMode.CEILING);
+ int eyeFBHeight = roundUsing(eyeh * this.renderScale, RoundingMode.CEILING);
- this.framebufferVrRender = new VRTextureTarget("3D Render", eyeFBWidth, eyeFBHeight, true, false, -1, true, true, dataholder.vrSettings.vrUseStencil);
+ this.framebufferVrRender = new VRTextureTarget("3D Render", eyeFBWidth, eyeFBHeight, true, false, -1, true, true, dh.vrSettings.vrUseStencil);
WorldRenderPass.stereoXR = new WorldRenderPass((VRTextureTarget) this.framebufferVrRender);
- dataholder.print(this.framebufferVrRender.toString());
+ logger.info(this.framebufferVrRender.toString());
this.checkGLError("3D framebuffer setup");
getMirrorTextureSize(eyeFBWidth, eyeFBHeight, resolutionScale);
@@ -569,7 +575,7 @@ public void setupRenderConfiguration() throws Exception {
List list = this.getRenderPasses();
for (RenderPass renderpass : list) {
- System.out.println("Passes: " + renderpass.toString());
+ logger.info("Passes: {}", renderpass.toString());
}
// only do these, if the window is not minimized
@@ -577,42 +583,42 @@ public void setupRenderConfiguration() throws Exception {
if (list.contains(RenderPass.THIRD) || ShadersHelper.isShaderActive()) {
this.framebufferMR = new VRTextureTarget("Mixed Reality Render", this.mirrorFBWidth, this.mirrorFBHeight, true, false, -1, true, false, false);
WorldRenderPass.mixedReality = new WorldRenderPass((VRTextureTarget) this.framebufferMR);
- dataholder.print(this.framebufferMR.toString());
+ logger.info(this.framebufferMR.toString());
this.checkGLError("Mixed reality framebuffer setup");
}
if (list.contains(RenderPass.CENTER) || ShadersHelper.isShaderActive()) {
this.framebufferUndistorted = new VRTextureTarget("Undistorted View Render", this.mirrorFBWidth, this.mirrorFBHeight, true, false, -1, false, false, false);
WorldRenderPass.center = new WorldRenderPass((VRTextureTarget) this.framebufferUndistorted);
- dataholder.print(this.framebufferUndistorted.toString());
+ logger.info(this.framebufferUndistorted.toString());
this.checkGLError("Undistorted view framebuffer setup");
}
}
GuiHandler.guiFramebuffer = new VRTextureTarget("GUI", GuiHandler.guiWidth, GuiHandler.guiHeight, true, false, -1, false, true, false);
- dataholder.print(GuiHandler.guiFramebuffer.toString());
+ logger.info(GuiHandler.guiFramebuffer.toString());
this.checkGLError("GUI framebuffer setup");
KeyboardHandler.Framebuffer = new VRTextureTarget("Keyboard", GuiHandler.guiWidth, GuiHandler.guiHeight, true, false, -1, false, true, false);
- dataholder.print(KeyboardHandler.Framebuffer.toString());
+ logger.info(KeyboardHandler.Framebuffer.toString());
this.checkGLError("Keyboard framebuffer setup");
RadialHandler.Framebuffer = new VRTextureTarget("Radial Menu", GuiHandler.guiWidth, GuiHandler.guiHeight, true, false, -1, false, true, false);
- dataholder.print(RadialHandler.Framebuffer.toString());
+ logger.info(RadialHandler.Framebuffer.toString());
this.checkGLError("Radial framebuffer setup");
Tuple telescopeSize = getTelescopeTextureSize(eyeFBWidth, eyeFBHeight);
this.telescopeFramebufferR = new VRTextureTarget("TelescopeR", telescopeSize.getA(), telescopeSize.getB(), true, false, -1, true, false, false);
WorldRenderPass.rightTelescope = new WorldRenderPass((VRTextureTarget) this.telescopeFramebufferR);
- dataholder.print(this.telescopeFramebufferR.toString());
- this.telescopeFramebufferR.setClearColor(0.0f, 0.0f, 0.0f, 1.0f);
- this.telescopeFramebufferR.clear(Minecraft.ON_OSX);
+ logger.info(this.telescopeFramebufferR.toString());
+ this.telescopeFramebufferR.setClearColor(0.0F, 0.0F, 0.0F, 1.0F);
+ this.telescopeFramebufferR.clear(ON_OSX);
this.checkGLError("TelescopeR framebuffer setup");
this.telescopeFramebufferL = new VRTextureTarget("TelescopeL", telescopeSize.getA(), telescopeSize.getB(), true, false, -1, true, false, false);
WorldRenderPass.leftTelescope = new WorldRenderPass((VRTextureTarget) this.telescopeFramebufferL);
- dataholder.print(this.telescopeFramebufferL.toString());
- this.telescopeFramebufferL.setClearColor(0.0f, 0.0f, 0.0f, 1.0f);
- this.telescopeFramebufferL.clear(Minecraft.ON_OSX);
+ logger.info(this.telescopeFramebufferL.toString());
+ this.telescopeFramebufferL.setClearColor(0.0F, 0.0F, 0.0F, 1.0F);
+ this.telescopeFramebufferL.clear(ON_OSX);
this.checkGLError("TelescopeL framebuffer setup");
@@ -626,58 +632,59 @@ public void setupRenderConfiguration() throws Exception {
}
this.cameraFramebuffer = new VRTextureTarget("Handheld Camera", cameraSize.getA(), cameraSize.getB(), true, false, -1, true, false, false);
- dataholder.print(this.cameraFramebuffer.toString());
+ logger.info(this.cameraFramebuffer.toString());
this.checkGLError("Camera framebuffer setup");
this.cameraRenderFramebuffer = new VRTextureTarget("Handheld Camera Render", cameraRenderFBwidth, cameraRenderFBheight, true, false, -1, true, true, false);
WorldRenderPass.camera = new WorldRenderPass((VRTextureTarget) this.cameraRenderFramebuffer);
- dataholder.print(this.cameraRenderFramebuffer.toString());
+ logger.info(this.cameraRenderFramebuffer.toString());
this.checkGLError("Camera render framebuffer setup");
- ((GameRendererExtension) minecraft.gameRenderer).setupClipPlanes();
- this.eyeproj[0] = this.getProjectionMatrix(0, ((GameRendererExtension) minecraft.gameRenderer).getMinClipDistance(), ((GameRendererExtension) minecraft.gameRenderer).getClipDistance());
- this.eyeproj[1] = this.getProjectionMatrix(1, ((GameRendererExtension) minecraft.gameRenderer).getMinClipDistance(), ((GameRendererExtension) minecraft.gameRenderer).getClipDistance());
+ GameRendererExtension GRE = (GameRendererExtension) mc.gameRenderer;
+ GRE.setupClipPlanes();
+ this.getProjectionMatrix(0, GRE.getMinClipDistance(), GRE.getClipDistance(), this.eyeproj[0]);
+ this.getProjectionMatrix(1, GRE.getMinClipDistance(), GRE.getClipDistance(), this.eyeproj[1]);
- if (dataholder.vrSettings.useFsaa) {
+ if (dh.vrSettings.useFsaa) {
try {
this.checkGLError("pre FSAA FBO creation");
this.fsaaFirstPassResultFBO = new VRTextureTarget("FSAA Pass1 FBO", eyew, eyeFBHeight, true, false, -1, false, false, false);
this.fsaaLastPassResultFBO = new VRTextureTarget("FSAA Pass2 FBO", eyew, eyeh, true, false, -1, false, false, false);
- dataholder.print(this.fsaaFirstPassResultFBO.toString());
- dataholder.print(this.fsaaLastPassResultFBO.toString());
+ logger.info(this.fsaaFirstPassResultFBO.toString());
+ logger.info(this.fsaaLastPassResultFBO.toString());
this.checkGLError("FSAA FBO creation");
VRShaders.setupFSAA();
ShaderHelper.checkGLError("FBO init fsaa shader");
} catch (Exception exception) {
- dataholder.vrSettings.useFsaa = false;
- dataholder.vrSettings.saveOptions();
- System.out.println(exception.getMessage());
+ dh.vrSettings.useFsaa = false;
+ dh.vrSettings.saveOptions();
+ logger.error(exception.getMessage());
this.reinitFramebuffers = true;
return;
}
}
try {
- minecraft.mainRenderTarget = this.framebufferVrRender;
+ mc.mainRenderTarget = this.framebufferVrRender;
VRShaders.setupDepthMask();
ShaderHelper.checkGLError("init depth shader");
VRShaders.setupFOVReduction();
ShaderHelper.checkGLError("init FOV shader");
VRShaders.setupPortalShaders();
ShaderHelper.checkGLError("init portal shader");
- minecraft.gameRenderer.checkEntityPostEffect(minecraft.getCameraEntity());
+ mc.gameRenderer.checkEntityPostEffect(mc.getCameraEntity());
} catch (Exception exception1) {
- System.out.println(exception1.getMessage());
+ logger.error(exception1.getMessage());
System.exit(-1);
}
- if (minecraft.screen != null) {
- int l2 = minecraft.getWindow().getGuiScaledWidth();
- int j3 = minecraft.getWindow().getGuiScaledHeight();
- minecraft.screen.init(minecraft, l2, j3);
+ if (mc.screen != null) {
+ int l2 = mc.getWindow().getGuiScaledWidth();
+ int j3 = mc.getWindow().getGuiScaledHeight();
+ mc.screen.init(mc, l2, j3);
}
- long windowPixels = (long)minecraft.getWindow().getScreenWidth() * minecraft.getWindow().getScreenHeight();
+ long windowPixels = (long)mc.getWindow().getScreenWidth() * mc.getWindow().getScreenHeight();
long vrPixels = eyeFBWidth * eyeFBHeight * 2L;
if (list.contains(RenderPass.CENTER)) {
@@ -688,10 +695,10 @@ public void setupRenderConfiguration() throws Exception {
vrPixels += windowPixels;
}
- System.out.println("[Minecrift] New render config:" +
+ logger.info("New render config:" +
"\nOpenVR target width: " + eyew + ", height: " + eyeh + " [" + String.format("%.1f", (float) (eyew * eyeh) / 1000000.0F) + " MP]" +
- "\nRender target width: " + eyeFBWidth + ", height: " + eyeFBHeight + " [Render scale: " + Math.round(dataholder.vrSettings.renderScaleFactor * 100.0F) + "%, " + String.format("%.1f", (float) (eyeFBWidth * eyeFBHeight) / 1000000.0F) + " MP]" +
- "\nMain window width: " + minecraft.getWindow().getScreenWidth() + ", height: " + minecraft.getWindow().getScreenHeight() + " [" + String.format("%.1f", (float) windowPixels / 1000000.0F) + " MP]" +
+ "\nRender target width: " + eyeFBWidth + ", height: " + eyeFBHeight + " [Render scale: " + round(dh.vrSettings.renderScaleFactor * 100.0F) + "%, " + String.format("%.1f", (float) (eyeFBWidth * eyeFBHeight) / 1000000.0F) + " MP]" +
+ "\nMain window width: " + mc.getWindow().getScreenWidth() + ", height: " + mc.getWindow().getScreenHeight() + " [" + String.format("%.1f", (float) windowPixels / 1000000.0F) + " MP]" +
"\nTotal shaded pixels per frame: " + String.format("%.1f", (float) vrPixels / 1000000.0F) + " MP (eye stencil not accounted for)");
this.lastDisplayFBWidth = eyeFBWidth;
this.lastDisplayFBHeight = eyeFBHeight;
@@ -705,9 +712,8 @@ public void setupRenderConfiguration() throws Exception {
}
public boolean wasDisplayResized() {
- Minecraft minecraft = Minecraft.getInstance();
- int i = minecraft.getWindow().getScreenHeight();
- int j = minecraft.getWindow().getScreenWidth();
+ int i = mc.getWindow().getScreenHeight();
+ int j = mc.getWindow().getScreenWidth();
boolean flag = this.dispLastHeight != i || this.dispLastWidth != j;
this.dispLastHeight = i;
this.dispLastWidth = j;
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 46181f935..a5252652e 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
@@ -1,21 +1,24 @@
package org.vivecraft.client_vr.provider.nullvr;
-import net.minecraft.client.KeyMapping;
-import net.minecraft.client.Minecraft;
-import org.joml.Vector2f;
-import org.lwjgl.glfw.GLFW;
-import org.vivecraft.client.VivecraftVRMod;
-import org.vivecraft.client_vr.ClientDataHolderVR;
-import org.vivecraft.client_vr.MethodHolder;
import org.vivecraft.client_vr.gameplay.screenhandlers.GuiHandler;
import org.vivecraft.client_vr.provider.ControllerType;
import org.vivecraft.client_vr.provider.MCVR;
import org.vivecraft.client_vr.provider.VRRenderer;
import org.vivecraft.client_vr.provider.openvr_lwjgl.VRInputAction;
-import org.vivecraft.client.utils.Utils;
-import org.vivecraft.common.utils.math.Matrix4f;
+import org.vivecraft.client_vr.settings.VRHotkeys;
+
+import org.joml.Matrix4f;
+import org.joml.Vector2f;
+
+import net.minecraft.client.KeyMapping;
+
+import java.util.List;
-import java.util.*;
+import static org.vivecraft.client_vr.VRState.dh;
+import static org.vivecraft.client_vr.VRState.mc;
+import static org.vivecraft.common.utils.Utils.logger;
+
+import static org.lwjgl.glfw.GLFW.*;
public class NullVR extends MCVR
{
@@ -24,9 +27,9 @@ public class NullVR extends MCVR
private boolean vrActive = true;
private boolean vrActiveChangedLastFrame = false;
- public NullVR(Minecraft mc, ClientDataHolderVR dh)
+ public NullVR()
{
- super(mc, dh, VivecraftVRMod.INSTANCE);
+ super();
ome = this;
this.hapticScheduler = new NullVRHapticScheduler();
}
@@ -66,19 +69,17 @@ public boolean init()
{
if (!this.initialized)
{
- this.mc = Minecraft.getInstance();
-
// only supports seated mode
- System.out.println("NullDriver. Forcing seated mode.");
- this.dh.vrSettings.seated = true;
+ logger.info("NullDriver. Forcing seated mode.");
+ dh.vrSettings.seated = true;
this.headIsTracking = false;
- Utils.Matrix4fSetIdentity(this.hmdPose);
- this.hmdPose.M[1][3] = 1.62F;
+ this.hmdPose.identity();
+ this.hmdPose.m13(1.62F);
// eye offset, 10cm total distance
- this.hmdPoseLeftEye.M[0][3] = -0.05F;
- this.hmdPoseRightEye.M[0][3] = 0.05F;
+ this.hmdPoseLeftEye.m03(-0.05F);
+ this.hmdPoseRightEye.m03(0.05F);
this.initialized = true;
this.initSuccess = true;
@@ -93,50 +94,33 @@ public void poll(long frameIndex)
if (this.initialized)
{
- this.mc.getProfiler().push("updatePose");
+ mc.getProfiler().push("updatePose");
if (mc.screen == null) {
// don't permanently change the sensitivity
- float xSens = this.dh.vrSettings.xSensitivity;
- float xKey = this.dh.vrSettings.keyholeX;
+ float xSens = dh.vrSettings.xSensitivity;
+ float xKey = dh.vrSettings.keyholeX;
- this.dh.vrSettings.xSensitivity = this.dh.vrSettings.ySensitivity * 1.636F * ((float)mc.getWindow().getScreenWidth() / (float)mc.getWindow().getScreenHeight());
- this.dh.vrSettings.keyholeX = 1;
+ dh.vrSettings.xSensitivity = dh.vrSettings.ySensitivity * 1.636F * ((float)mc.getWindow().getScreenWidth() / (float)mc.getWindow().getScreenHeight());
+ dh.vrSettings.keyholeX = 1;
this.updateAim();
- this.dh.vrSettings.xSensitivity = xSens;
- this.dh.vrSettings.keyholeX = xKey;
+ dh.vrSettings.xSensitivity = xSens;
+ dh.vrSettings.keyholeX = xKey;
// point head in cursor direction
- hmdRotation.M[0][0] = handRotation[0].M[0][0];
- hmdRotation.M[0][1] = handRotation[0].M[0][1];
- hmdRotation.M[0][2] = handRotation[0].M[0][2];
- hmdRotation.M[1][0] = handRotation[0].M[1][0];
- hmdRotation.M[1][1] = handRotation[0].M[1][1];
- hmdRotation.M[1][2] = handRotation[0].M[1][2];
- hmdRotation.M[2][0] = handRotation[0].M[2][0];
- hmdRotation.M[2][1] = handRotation[0].M[2][1];
- hmdRotation.M[2][2] = handRotation[0].M[2][2];
+ hmdRotation.set3x3(handRotation[0]);
} else if(GuiHandler.guiRotation_room != null){
// look at screen, so that it's centered
- hmdRotation.M[0][0] = GuiHandler.guiRotation_room.M[0][0];
- hmdRotation.M[0][1] = GuiHandler.guiRotation_room.M[0][1];
- hmdRotation.M[0][2] = GuiHandler.guiRotation_room.M[0][2];
- hmdRotation.M[1][0] = GuiHandler.guiRotation_room.M[1][0];
- hmdRotation.M[1][1] = GuiHandler.guiRotation_room.M[1][1];
- hmdRotation.M[1][2] = GuiHandler.guiRotation_room.M[1][2];
- hmdRotation.M[2][0] = GuiHandler.guiRotation_room.M[2][0];
- hmdRotation.M[2][1] = GuiHandler.guiRotation_room.M[2][1];
- hmdRotation.M[2][2] = GuiHandler.guiRotation_room.M[2][2];
-
+ hmdRotation.set3x3(GuiHandler.guiRotation_room);
}
- this.mc.getProfiler().popPush("hmdSampling");
+ mc.getProfiler().popPush("hmdSampling");
this.hmdSampling();
- this.mc.getProfiler().pop();
+ mc.getProfiler().pop();
}
}
@@ -158,7 +142,7 @@ protected ControllerType findActiveBindingControllerType(KeyMapping binding)
}
@Override
- public Matrix4f getControllerComponentTransform(int controllerIndex, String componenetName)
+ public Matrix4f getControllerComponentTransform(int controllerIndex, String componentName)
{
return new Matrix4f();
}
@@ -169,6 +153,11 @@ public String getOriginName(long handle)
return "NullDriver";
}
+ @Override
+ public ControllerType getOriginControllerType(long inputValueHandle) {
+ return null;
+ }
+
@Override
public boolean postinit()
{
@@ -183,7 +172,7 @@ public boolean hasThirdController()
}
@Override
- public List getOrigins(VRInputAction var1) {
+ public List getOrigins(VRInputAction action) {
return null;
}
@@ -194,7 +183,7 @@ public VRRenderer createVRRenderer() {
@Override
public boolean isActive() {
- if (MethodHolder.isKeyDown(GLFW.GLFW_KEY_RIGHT_CONTROL) && MethodHolder.isKeyDown(GLFW.GLFW_KEY_F6)) {
+ if (VRHotkeys.isKeyDown(GLFW_KEY_RIGHT_CONTROL) && VRHotkeys.isKeyDown(GLFW_KEY_F6)) {
if (!vrActiveChangedLastFrame) {
vrActive = !vrActive;
vrActiveChangedLastFrame = true;
diff --git a/common/src/main/java/org/vivecraft/client_vr/provider/nullvr/NullVRStereoRenderer.java b/common/src/main/java/org/vivecraft/client_vr/provider/nullvr/NullVRStereoRenderer.java
index b8503192e..d978c6f00 100644
--- a/common/src/main/java/org/vivecraft/client_vr/provider/nullvr/NullVRStereoRenderer.java
+++ b/common/src/main/java/org/vivecraft/client_vr/provider/nullvr/NullVRStereoRenderer.java
@@ -1,16 +1,20 @@
package org.vivecraft.client_vr.provider.nullvr;
+import org.vivecraft.client_vr.provider.MCVR;
+import org.vivecraft.client_vr.render.RenderPass;
+
+import org.joml.Matrix4f;
+import org.lwjgl.opengl.GL11C;
+
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.platform.TextureUtil;
import com.mojang.blaze3d.systems.RenderSystem;
+
import net.minecraft.util.Tuple;
-import org.joml.Matrix4f;
-import org.lwjgl.opengl.GL11;
-import org.vivecraft.client_vr.provider.MCVR;
-import org.vivecraft.client_vr.provider.VRRenderer;
-import org.vivecraft.client_vr.render.RenderPass;
-public class NullVRStereoRenderer extends VRRenderer
+import static org.vivecraft.common.utils.Utils.logger;
+
+public class NullVRStereoRenderer extends org.vivecraft.client_vr.provider.VRRenderer
{
public NullVRStereoRenderer(MCVR vr)
{
@@ -20,50 +24,37 @@ public NullVRStereoRenderer(MCVR vr)
@Override
public Tuple getRenderTextureSizes()
{
- if (this.resolution != null)
- {
- return this.resolution;
- }
- else
- {
+ if (this.resolution == null) {
this.resolution = new Tuple<>(2048, 2048);
- System.out.println("NullVR Render Res " + this.resolution.getA() + " x " + this.resolution.getB());
+ logger.info("NullVR Render Res {} x {}", this.resolution.getA(), this.resolution.getB());
this.ss = -1.0F;
- System.out.println("NullVR Supersampling: " + this.ss);
-
- return this.resolution;
+ logger.info("NullVR Supersampling: {}", this.ss);
}
+ return this.resolution;
}
- @Override
- public Matrix4f getProjectionMatrix(int eyeType, float nearClip, float farClip)
+ public Matrix4f getProjectionMatrix(int eyeType, double nearClip, double farClip, Matrix4f dest)
{
- return new Matrix4f().setPerspective(90.0F, 1.0F, nearClip, farClip);
- }
-
- @Override
- public String getLastError()
- {
- return "";
+ return dest.setPerspective(90.0F, 1.0F, (float) nearClip, (float) farClip);
}
@Override
public void createRenderTexture(int lwidth, int lheight)
{
this.LeftEyeTextureId = GlStateManager._genTexture();
- int i = GlStateManager._getInteger(GL11.GL_TEXTURE_BINDING_2D);
+ int i = GlStateManager._getInteger(GL11C.GL_TEXTURE_BINDING_2D);
RenderSystem.bindTexture(this.LeftEyeTextureId);
- RenderSystem.texParameter(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
- RenderSystem.texParameter(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
- GlStateManager._texImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA8, lwidth, lheight, 0, GL11.GL_RGBA, GL11.GL_INT, null);
+ RenderSystem.texParameter(GL11C.GL_TEXTURE_2D, GL11C.GL_TEXTURE_MIN_FILTER, GL11C.GL_LINEAR);
+ RenderSystem.texParameter(GL11C.GL_TEXTURE_2D, GL11C.GL_TEXTURE_MAG_FILTER, GL11C.GL_LINEAR);
+ GlStateManager._texImage2D(GL11C.GL_TEXTURE_2D, 0, GL11C.GL_RGBA8, lwidth, lheight, 0, GL11C.GL_RGBA, GL11C.GL_INT, null);
RenderSystem.bindTexture(i);
this.RightEyeTextureId = GlStateManager._genTexture();
- i = GlStateManager._getInteger(GL11.GL_TEXTURE_BINDING_2D);
+ i = GlStateManager._getInteger(GL11C.GL_TEXTURE_BINDING_2D);
RenderSystem.bindTexture(this.RightEyeTextureId);
- RenderSystem.texParameter(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
- RenderSystem.texParameter(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
- GlStateManager._texImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA8, lwidth, lheight, 0, GL11.GL_RGBA, GL11.GL_INT, null);
+ RenderSystem.texParameter(GL11C.GL_TEXTURE_2D, GL11C.GL_TEXTURE_MIN_FILTER, GL11C.GL_LINEAR);
+ RenderSystem.texParameter(GL11C.GL_TEXTURE_2D, GL11C.GL_TEXTURE_MAG_FILTER, GL11C.GL_LINEAR);
+ GlStateManager._texImage2D(GL11C.GL_TEXTURE_2D, 0, GL11C.GL_RGBA8, lwidth, lheight, 0, GL11C.GL_RGBA, GL11C.GL_INT, null);
RenderSystem.bindTexture(i);
}
@@ -72,12 +63,6 @@ public void endFrame()
{
}
- @Override
- public boolean providesStencilMask()
- {
- return false;
- }
-
@Override
public float[] getStencilMask(RenderPass eye)
@@ -91,18 +76,6 @@ public String getName()
return "NullVR";
}
- @Override
- public boolean isInitialized()
- {
- return this.vr.initSuccess;
- }
-
- @Override
- public String getinitError()
- {
- return this.vr.initStatus;
- }
-
@Override
public void destroy() {
super.destroy();
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 00f7f43da..154195a33 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
@@ -1,23 +1,7 @@
package org.vivecraft.client_vr.provider.openvr_lwjgl;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.mojang.blaze3d.platform.InputConstants;
-import com.sun.jna.NativeLibrary;
-import net.minecraft.client.KeyMapping;
-import net.minecraft.client.Minecraft;
-import net.minecraft.network.chat.Component;
-import net.minecraft.network.chat.MutableComponent;
-import net.minecraft.world.phys.Vec3;
-import org.joml.Vector2f;
-import org.lwjgl.openvr.*;
-import org.lwjgl.system.MemoryStack;
-import org.lwjgl.system.MemoryUtil;
import org.vivecraft.client.VivecraftVRMod;
import org.vivecraft.client.utils.Utils;
-import org.vivecraft.client_vr.ClientDataHolderVR;
import org.vivecraft.client_vr.gameplay.screenhandlers.GuiHandler;
import org.vivecraft.client_vr.gameplay.screenhandlers.KeyboardHandler;
import org.vivecraft.client_vr.gameplay.screenhandlers.RadialHandler;
@@ -26,49 +10,71 @@
import org.vivecraft.client_vr.provider.openvr_lwjgl.control.VRInputActionSet;
import org.vivecraft.client_vr.render.RenderConfigException;
import org.vivecraft.client_vr.settings.VRHotkeys;
-import org.vivecraft.client_vr.settings.VRSettings;
+import org.vivecraft.client_vr.settings.VRSettings.HUDLock;
import org.vivecraft.client_vr.utils.external.jinfinadeck;
import org.vivecraft.client_vr.utils.external.jkatvr;
-import org.vivecraft.common.utils.math.Matrix4f;
-import org.vivecraft.common.utils.math.Vector3;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.sun.jna.NativeLibrary;
+import org.joml.*;
+import org.lwjgl.openvr.*;
+import org.lwjgl.openvr.VRBoneTransform.Buffer;
+import org.lwjgl.system.MemoryStack;
+import org.lwjgl.system.MemoryUtil;
+
+import com.mojang.blaze3d.platform.InputConstants.Type;
+
+import net.minecraft.client.KeyMapping;
+import net.minecraft.network.chat.Component;
+import net.minecraft.network.chat.MutableComponent;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.OutputStreamWriter;
import java.lang.management.ManagementFactory;
+import java.lang.reflect.Field;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.nio.LongBuffer;
import java.nio.charset.StandardCharsets;
import java.util.*;
+import java.util.stream.Collectors;
+
+import static org.vivecraft.client_vr.VRState.dh;
+import static org.vivecraft.client_vr.VRState.mc;
+import static org.vivecraft.common.utils.Utils.*;
+import static org.joml.Math.*;
import static org.lwjgl.openvr.VR.*;
import static org.lwjgl.openvr.VRApplications.*;
import static org.lwjgl.openvr.VRCompositor.*;
import static org.lwjgl.openvr.VRInput.*;
-import static org.lwjgl.openvr.VRRenderModels.*;
+import static org.lwjgl.openvr.VRRenderModels.VRRenderModels_GetComponentButtonMask;
+import static org.lwjgl.openvr.VRRenderModels.VRRenderModels_GetComponentStateForDevicePath;
import static org.lwjgl.openvr.VRSettings.VRSettings_GetFloat;
import static org.lwjgl.openvr.VRSystem.*;
public class MCOpenVR extends MCVR {
- public static final int LEFT_CONTROLLER = 1;
- public static final int RIGHT_CONTROLLER = 0;
- public static final int THIRD_CONTROLLER = 2;
protected static MCOpenVR ome;
private final String ACTION_EXTERNAL_CAMERA = "/actions/mixedreality/in/externalcamera";
private final String ACTION_LEFT_HAND = "/actions/global/in/lefthand";
+ private final String ACTION_LEFT_HAND_GESTURE = "/actions/global/in/lefthandbones";
private final String ACTION_LEFT_HAPTIC = "/actions/global/out/lefthaptic";
private final String ACTION_RIGHT_HAND = "/actions/global/in/righthand";
+ private final String ACTION_RIGHT_HAND_GESTURE = "/actions/global/in/righthandbones";
private final String ACTION_RIGHT_HAPTIC = "/actions/global/out/righthaptic";
- private Map actionSetHandles = new EnumMap<>(VRInputActionSet.class);
+ private final Map actionSetHandles = new EnumMap<>(VRInputActionSet.class);
private VRActiveActionSet.Buffer activeActionSetsBuffer;
private Map controllerComponentNames;
private Map controllerComponentTransforms;
- private boolean dbg = true;
+ private boolean getDeviceProperties = true;
private long externalCameraPoseHandle;
- private int[] controllerDeviceIndex = new int[3];
+ private final int[] controllerDeviceIndex = new int[2];
private boolean getXforms = true;
private final Gson GSON = (new GsonBuilder()).setPrettyPrinting().disableHtmlEscaping().create();
private final IntBuffer hmdErrorStore = MemoryUtil.memCallocInt(1);
@@ -78,31 +84,35 @@ public class MCOpenVR extends MCVR {
private long leftControllerHandle;
private long leftHapticHandle;
private long leftPoseHandle;
- private InputOriginInfo originInfo;
+ private long leftGestureHandle;
+ private final InputOriginInfo originInfo;
private boolean paused = false;
- private InputPoseActionData poseData;
+ private final InputPoseActionData poseData;
+ private final InputPoseActionData gestureData;
private long rightControllerHandle;
private long rightHapticHandle;
private long rightPoseHandle;
+ private long rightGestureHandle;
private final VRTextureBounds texBounds = VRTextureBounds.calloc();
- private Map trackpadSwipeSamplers = new HashMap<>();
+ private final Map trackpadSwipeSamplers = new HashMap<>();
private boolean tried;
- private Queue vrEvents = new LinkedList<>();
+ private final Queue vrEvents = new LinkedList<>();
final Texture texType0 = Texture.calloc();
final Texture texType1 = Texture.calloc();
InputDigitalActionData digital = InputDigitalActionData.calloc();
InputAnalogActionData analog = InputAnalogActionData.calloc();
- public MCOpenVR(Minecraft mc, ClientDataHolderVR dh) {
- super(mc, dh, VivecraftVRMod.INSTANCE);
+ public MCOpenVR() {
+ super();
ome = this;
this.hapticScheduler = new OpenVRHapticScheduler();
- for (int i = 0; i < 3; ++i) {
+ for (int i = 0; i < controllerDeviceIndex.length; ++i) {
this.controllerDeviceIndex[i] = -1;
}
this.poseData = InputPoseActionData.calloc();
+ this.gestureData = InputPoseActionData.calloc();
this.originInfo = InputOriginInfo.calloc();
}
@@ -111,64 +121,30 @@ public static MCOpenVR get() {
}
static String getInputErrorName(int code) {
- switch (code) {
- case 0:
- return "wat";
-
- case 1:
- return "NameNotFound";
-
- case 2:
- return "WrongType";
-
- case 3:
- return "InvalidHandle";
-
- case 4:
- return "InvalidParam";
-
- case 5:
- return "NoSteam";
-
- case 6:
- return "MaxCapacityReached";
-
- case 7:
- return "IPCError";
-
- case 8:
- return "NoActiveActionSet";
-
- case 9:
- return "InvalidDevice";
-
- case 10:
- return "InvalidSkeleton";
-
- case 11:
- return "InvalidBoneCount";
-
- case 12:
- return "InvalidCompressedData";
-
- case 13:
- return "NoData";
-
- case 14:
- return "BufferTooSmall";
-
- case 15:
- return "MismatchedActionManifest";
-
- case 16:
- return "MissingSkeletonData";
-
- case 17:
- return "InvalidBoneIndex";
-
- default:
- return "Unknown";
- }
+ return switch (code) {
+ case EVRInputError_VRInputError_None -> "None";
+ case EVRInputError_VRInputError_NameNotFound -> "NameNotFound";
+ case EVRInputError_VRInputError_WrongType -> "WrongType";
+ case EVRInputError_VRInputError_InvalidHandle -> "InvalidHandle";
+ case EVRInputError_VRInputError_InvalidParam -> "InvalidParam";
+ case EVRInputError_VRInputError_NoSteam -> "NoSteam";
+ case EVRInputError_VRInputError_MaxCapacityReached -> "MaxCapacityReached";
+ case EVRInputError_VRInputError_IPCError -> "IPCError";
+ case EVRInputError_VRInputError_NoActiveActionSet -> "NoActiveActionSet";
+ case EVRInputError_VRInputError_InvalidDevice -> "InvalidDevice";
+ case EVRInputError_VRInputError_InvalidSkeleton -> "InvalidSkeleton";
+ case EVRInputError_VRInputError_InvalidBoneCount -> "InvalidBoneCount";
+ case EVRInputError_VRInputError_InvalidCompressedData -> "InvalidCompressedData";
+ case EVRInputError_VRInputError_NoData -> "NoData";
+ case EVRInputError_VRInputError_BufferTooSmall -> "BufferTooSmall";
+ case EVRInputError_VRInputError_MismatchedActionManifest -> "MismatchedActionManifest";
+ case EVRInputError_VRInputError_MissingSkeletonData -> "MissingSkeletonData";
+ case EVRInputError_VRInputError_InvalidBoneIndex -> "InvalidBoneIndex";
+ case EVRInputError_VRInputError_InvalidPriority -> "InvalidPriority";
+ case EVRInputError_VRInputError_PermissionDenied -> "PermissionDenied";
+ case EVRInputError_VRInputError_InvalidRenderModel -> "InvalidRenderModel";
+ default -> "Unknown";
+ };
}
public void destroy() {
@@ -177,11 +153,11 @@ public void destroy() {
VR_ShutdownInternal();
this.initialized = false;
- if (ClientDataHolderVR.katvr) {
+ if (dh.katvr) {
jkatvr.Halt();
}
- if (ClientDataHolderVR.infinadeck) {
+ if (dh.infinadeck) {
jinfinadeck.Destroy();
}
} catch (Throwable throwable) {
@@ -204,7 +180,7 @@ public Vector2f getPlayAreaSize() {
FloatBuffer pSizeZ = stack.callocFloat(1);
FloatBuffer pSizeX = stack.callocFloat(1);
boolean b0 = VRChaperone.VRChaperone_GetPlayAreaSize(pSizeX, pSizeZ);
- return b0 ? new Vector2f(pSizeX.get(0) * this.dh.vrSettings.walkMultiplier, pSizeZ.get(0) * this.dh.vrSettings.walkMultiplier) : null;
+ return b0 ? new Vector2f(pSizeX.get(0) * dh.vrSettings.walkMultiplier, pSizeZ.get(0) * dh.vrSettings.walkMultiplier) : null;
} else {
return null;
}
@@ -218,7 +194,6 @@ public boolean init() {
return this.initialized;
} else {
this.tried = true;
- this.mc = Minecraft.getInstance();
try {
this.initializeOpenVR();
this.initOpenVRCompositor();
@@ -236,52 +211,50 @@ public boolean init() {
}
if (OpenVR.VRInput == null) {
- System.out.println("Controller input not available. Forcing seated mode.");
- this.dh.vrSettings.seated = true;
+ logger.info("Controller input not available. Forcing seated mode.");
+ dh.vrSettings.seated = true;
}
- System.out.println("OpenVR initialized & VR connected.");
- this.deviceVelocity = new Vec3[64];
+ logger.info("OpenVR initialized & VR connected.");
for (int i = 0; i < this.poseMatrices.length; ++i) {
this.poseMatrices[i] = new Matrix4f();
- this.deviceVelocity[i] = new Vec3(0.0D, 0.0D, 0.0D);
}
this.initialized = true;
- if (ClientDataHolderVR.katvr) {
+ if (dh.katvr) {
try {
- System.out.println("Waiting for KATVR....");
+ logger.info("Waiting for KATVR....");
Utils.unpackNatives("katvr");
- NativeLibrary.addSearchPath("WalkerBase.dll", (new File("openvr/katvr")).getAbsolutePath());
+ NativeLibrary.addSearchPath("WalkerBase.dll", new File("openvr/katvr").getAbsolutePath());
jkatvr.Init(1);
jkatvr.Launch();
if (jkatvr.CheckForLaunch()) {
- System.out.println("KATVR Loaded");
+ logger.info("KATVR Loaded");
} else {
- System.out.println("KATVR Failed to load");
+ logger.info("KATVR Failed to load");
}
} catch (Exception exception1) {
- System.out.println("KATVR crashed: " + exception1.getMessage());
+ logger.error("KATVR crashed: {}", exception1.getMessage());
}
}
- if (ClientDataHolderVR.infinadeck) {
+ if (dh.infinadeck) {
try {
- System.out.println("Waiting for Infinadeck....");
+ logger.info("Waiting for Infinadeck....");
Utils.unpackNatives("infinadeck");
NativeLibrary.addSearchPath("InfinadeckAPI.dll", (new File("openvr/infinadeck")).getAbsolutePath());
if (jinfinadeck.InitConnection()) {
jinfinadeck.CheckConnection();
- System.out.println("Infinadeck Loaded");
+ logger.info("Infinadeck Loaded");
} else {
- System.out.println("Infinadeck Failed to load");
+ logger.warn("Infinadeck Failed to load");
}
} catch (Exception exception) {
- System.out.println("Infinadeck crashed: " + exception.getMessage());
+ logger.error("Infinadeck crashed: {}", exception.getMessage());
}
}
@@ -292,38 +265,36 @@ public boolean init() {
public void poll(long frameIndex) {
if (this.initialized) {
this.paused = VRSystem_ShouldApplicationPause();
- this.mc.getProfiler().push("events");
+ mc.getProfiler().push("events");
this.pollVREvents();
- if (!this.dh.vrSettings.seated) {
- this.mc.getProfiler().popPush("controllers");
- this.mc.getProfiler().push("gui");
+ if (!dh.vrSettings.seated) {
+ mc.getProfiler().popPush("controllers");
+ mc.getProfiler().push("gui");
- if (this.mc.screen == null && this.dh.vrSettings.vrTouchHotbar) {
- VRSettings vrsettings = this.dh.vrSettings;
-
- if (this.dh.vrSettings.vrHudLockMode != VRSettings.HUDLock.HEAD && this.hudPopup) {
+ if (mc.screen == null && dh.vrSettings.vrTouchHotbar) {
+ if (dh.vrSettings.vrHudLockMode != HUDLock.HEAD && this.hudPopup) {
this.processHotbar();
}
}
- this.mc.getProfiler().pop();
+ mc.getProfiler().pop();
}
- this.mc.getProfiler().popPush("processEvents");
+ mc.getProfiler().popPush("processEvents");
this.processVREvents();
- this.mc.getProfiler().popPush("updatePose/Vsync");
+ mc.getProfiler().popPush("updatePose/Vsync");
this.updatePose();
- this.mc.getProfiler().popPush("processInputs");
+ mc.getProfiler().popPush("processInputs");
this.processInputs();
- this.mc.getProfiler().popPush("hmdSampling");
+ mc.getProfiler().popPush("hmdSampling");
this.hmdSampling();
- this.mc.getProfiler().pop();
+ mc.getProfiler().pop();
}
}
public void processInputs() {
- if (!this.dh.vrSettings.seated && !ClientDataHolderVR.viewonly && this.inputInitialized) {
+ if (!dh.vrSettings.seated && !dh.viewonly && this.inputInitialized) {
for (VRInputAction vrinputaction : this.inputActions.values()) {
if (vrinputaction.isHanded()) {
for (ControllerType controllertype : ControllerType.values()) {
@@ -335,34 +306,30 @@ public void processInputs() {
}
}
- this.processScrollInput(GuiHandler.keyScrollAxis, () ->
- {
- InputSimulator.scrollMouse(0.0D, 1.0D);
- }, () ->
- {
- InputSimulator.scrollMouse(0.0D, -1.0D);
- });
- this.processScrollInput(VivecraftVRMod.INSTANCE.keyHotbarScroll, () ->
- {
- this.changeHotbar(-1);
- }, () ->
- {
- this.changeHotbar(1);
- });
- this.processSwipeInput(VivecraftVRMod.INSTANCE.keyHotbarSwipeX, () ->
- {
- this.changeHotbar(1);
- }, () ->
- {
- this.changeHotbar(-1);
- }, (Runnable) null, (Runnable) null);
- this.processSwipeInput(VivecraftVRMod.INSTANCE.keyHotbarSwipeY, (Runnable) null, (Runnable) null, () ->
- {
- this.changeHotbar(-1);
- }, () ->
- {
- this.changeHotbar(1);
- });
+ this.processScrollInput(
+ GuiHandler.keyScrollAxis,
+ () -> InputSimulator.scrollMouse(0.0D, 1.0D),
+ () -> InputSimulator.scrollMouse(0.0D, -1.0D)
+ );
+ this.processScrollInput(
+ VivecraftVRMod.keyHotbarScroll,
+ () -> this.changeHotbar(-1),
+ () -> this.changeHotbar(1)
+ );
+ this.processSwipeInput(
+ VivecraftVRMod.keyHotbarSwipeX,
+ () -> this.changeHotbar(1),
+ () -> this.changeHotbar(-1),
+ null,
+ null
+ );
+ this.processSwipeInput(
+ VivecraftVRMod.keyHotbarSwipeY,
+ null,
+ null,
+ () -> this.changeHotbar(-1),
+ () -> this.changeHotbar(1)
+ );
this.ignorePressesNextFrame = false;
}
}
@@ -381,39 +348,35 @@ private boolean isError() {
}
private void debugOut(int deviceindex) {
-// System.out.println("******************* VR DEVICE: " + deviceindex + " *************************");
-//
-// for (Field field : VR.ETrackedDeviceProperty.class.getDeclaredFields()) {
-// try {
-// String[] astring = field.getName().split("_");
-// String s = astring[astring.length - 1];
-// String s1 = "";
-//
-// VRSystem_ShouldApplicationPause()
-//
-// if (s.equals("Float")) {
-// s1 = s1 + field.getName() + " " + this.vrsystem.GetFloatTrackedDeviceProperty.apply(deviceindex, field.getInt((Object) null), this.hmdErrorStore);
-// } else if (s.equals("String")) {
-// Pointer pointer = new Memory(32768L);
-// this.vrsystem.GetStringTrackedDeviceProperty.apply(deviceindex, field.getInt((Object) null), pointer, 32767, this.hmdErrorStore);
-// s1 = s1 + field.getName() + " " + pointer.getString(0L);
-// } else if (s.equals("Bool")) {
-// s1 = s1 + field.getName() + " " + this.vrsystem.GetBoolTrackedDeviceProperty.apply(deviceindex, field.getInt((Object) null), this.hmdErrorStore);
-// } else if (s.equals("Int32")) {
-// s1 = s1 + field.getName() + " " + this.vrsystem.GetInt32TrackedDeviceProperty.apply(deviceindex, field.getInt((Object) null), this.hmdErrorStore);
-// } else if (s.equals("Uint64")) {
-// s1 = s1 + field.getName() + " " + this.vrsystem.GetUint64TrackedDeviceProperty.apply(deviceindex, field.getInt((Object) null), this.hmdErrorStore);
-// } else {
-// s1 = s1 + field.getName() + " (skipped)";
-// }
-//
-// System.out.println(s1.replace("ETrackedDeviceProperty_Prop_", ""));
-// } catch (IllegalAccessException illegalaccessexception) {
-// illegalaccessexception.printStackTrace();
-// }
-// }
-//
-// System.out.println("******************* END VR DEVICE: " + deviceindex + " *************************");
+ try {
+ StringBuilder VRDeviceProps = new StringBuilder(5653); // 5653 is the count of guaranteed characters to print
+ for (Field field : VR.class.getDeclaredFields()) {
+ String[] field_words = field.getName().split("_");
+
+ if (Arrays.asList(field_words).contains("ETrackedDeviceProperty"))
+ {
+ VRDeviceProps.append(field.getName().replace("ETrackedDeviceProperty_Prop_", "\n")).append(" ").append(
+ switch (field_words[field_words.length - 1])
+ {
+ case "Float" ->
+ VRSystem_GetFloatTrackedDeviceProperty(deviceindex, field.getInt(null), this.hmdErrorStore);
+ case "String" ->
+ VRSystem_GetStringTrackedDeviceProperty(deviceindex, field.getInt(null), this.hmdErrorStore);
+ case "Bool" ->
+ VRSystem_GetBoolTrackedDeviceProperty(deviceindex, field.getInt(null), this.hmdErrorStore);
+ case "Int32" ->
+ VRSystem_GetInt32TrackedDeviceProperty(deviceindex, field.getInt(null), this.hmdErrorStore);
+ case "Uint64" ->
+ VRSystem_GetUint64TrackedDeviceProperty(deviceindex, field.getInt(null), this.hmdErrorStore);
+ default -> "(skipped)";
+ }
+ );
+ }
+ }
+ logger.info("VR DEVICE {}:{}", deviceindex, VRDeviceProps);
+ } catch (IllegalAccessException illegalaccessexception) {
+ illegalaccessexception.printStackTrace();
+ }
}
protected ControllerType findActiveBindingControllerType(KeyMapping binding) {
@@ -421,7 +384,7 @@ protected ControllerType findActiveBindingControllerType(KeyMapping binding) {
return null;
} else {
long i = this.getInputAction(binding).getLastOrigin();
- return i != 0L ? this.getOriginControllerType(i) : null;
+ return i != k_ulInvalidInputValueHandle ? this.getOriginControllerType(i) : null;
}
}
@@ -432,7 +395,7 @@ private void generateActionManifest() {
for (VRInputActionSet vrinputactionset : VRInputActionSet.values()) {
String s = vrinputactionset.usage;
- if (vrinputactionset.advanced && !this.dh.vrSettings.allowAdvancedBindings) {
+ if (vrinputactionset.advanced && !dh.vrSettings.allowAdvancedBindings) {
s = "hidden";
}
@@ -451,11 +414,13 @@ private void generateActionManifest() {
list2.add(ImmutableMap.builder().put("name", vrinputaction.name).put("requirement", vrinputaction.requirement).put("type", vrinputaction.type).build());
}
- list2.add(ImmutableMap.builder().put("name", ACTION_LEFT_HAND).put("requirement", "suggested").put("type", "pose").build());
- list2.add(ImmutableMap.builder().put("name", ACTION_RIGHT_HAND).put("requirement", "suggested").put("type", "pose").build());
- list2.add(ImmutableMap.builder().put("name", ACTION_EXTERNAL_CAMERA).put("requirement", "optional").put("type", "pose").build());
- list2.add(ImmutableMap.builder().put("name", ACTION_LEFT_HAPTIC).put("requirement", "suggested").put("type", "vibration").build());
- list2.add(ImmutableMap.builder().put("name", ACTION_RIGHT_HAPTIC).put("requirement", "suggested").put("type", "vibration").build());
+ list2.add(ImmutableMap.builder().put("name", this.ACTION_LEFT_HAND).put("requirement", "suggested").put("type", "pose").build());
+ list2.add(ImmutableMap.builder().put("name", this.ACTION_LEFT_HAND_GESTURE).put("requirement", "optional").put("type", "skeleton").put("skeleton", "/skeleton/hand/left").build());
+ list2.add(ImmutableMap.builder().put("name", this.ACTION_LEFT_HAPTIC).put("requirement", "suggested").put("type", "vibration").build());
+ list2.add(ImmutableMap.builder().put("name", this.ACTION_RIGHT_HAND).put("requirement", "suggested").put("type", "pose").build());
+ list2.add(ImmutableMap.builder().put("name", this.ACTION_RIGHT_HAND_GESTURE).put("requirement", "optional").put("type", "skeleton").put("skeleton", "/skeleton/hand/right").build());
+ list2.add(ImmutableMap.builder().put("name", this.ACTION_RIGHT_HAPTIC).put("requirement", "suggested").put("type", "vibration").build());
+ list2.add(ImmutableMap.builder().put("name", this.ACTION_EXTERNAL_CAMERA).put("requirement", "optional").put("type", "pose").build());
map.put("actions", list2);
Map map1 = new HashMap<>();
@@ -469,11 +434,13 @@ private void generateActionManifest() {
map1.put(vrinputactionset1.name, component.getString());
}
- map1.put(ACTION_LEFT_HAND, "Left Hand Pose");
- map1.put(ACTION_RIGHT_HAND, "Right Hand Pose");
- map1.put(ACTION_EXTERNAL_CAMERA, "External Camera");
- map1.put(ACTION_LEFT_HAPTIC, "Left Hand Haptic");
- map1.put(ACTION_RIGHT_HAPTIC, "Right Hand Haptic");
+ map1.put(this.ACTION_LEFT_HAND, "Left Hand Pose");
+ map1.put(this.ACTION_LEFT_HAND_GESTURE, "Left Hand Gestures");
+ map1.put(this.ACTION_LEFT_HAPTIC, "Left Hand Haptic");
+ map1.put(this.ACTION_RIGHT_HAND, "Right Hand Pose");
+ map1.put(this.ACTION_RIGHT_HAND_GESTURE, "Right Hand Gestures");
+ map1.put(this.ACTION_RIGHT_HAPTIC, "Right Hand Haptic");
+ map1.put(this.ACTION_EXTERNAL_CAMERA, "External Camera");
map1.put("language_tag", "en_US");
map.put("localization", ImmutableList.