From 88e8924df2cfe84632d80796fa9b213ee0a62697 Mon Sep 17 00:00:00 2001 From: hammy275 Date: Fri, 17 Jan 2025 10:58:29 -0500 Subject: [PATCH] Merge VRBodyPart to One Enum --- .../org/vivecraft/api/data/VRBodyPart.java | 31 +++++++---- .../client/network/ClientNetworking.java | 8 +-- .../gameplay/trackers/SwingTracker.java | 8 +-- .../vivecraft/common/network/BodyPart.java | 52 ------------------- .../common/network/VrPlayerState.java | 4 +- .../packet/c2s/ActiveBodyPartPayloadC2S.java | 10 ++-- .../advancements/PlayerPredicateMixin.java | 6 +-- .../MultiPlayerGameModeVRMixin.java | 8 +-- .../mixin/world/entity/InventoryMixin.java | 8 +-- .../vivecraft/server/ServerNetworking.java | 4 +- .../java/org/vivecraft/server/ServerUtil.java | 6 +-- .../vivecraft/server/ServerVivePlayer.java | 24 ++++----- 12 files changed, 64 insertions(+), 105 deletions(-) delete mode 100644 common/src/main/java/org/vivecraft/common/network/BodyPart.java diff --git a/common/src/main/java/org/vivecraft/api/data/VRBodyPart.java b/common/src/main/java/org/vivecraft/api/data/VRBodyPart.java index 06a269f4e..4963f96e4 100644 --- a/common/src/main/java/org/vivecraft/api/data/VRBodyPart.java +++ b/common/src/main/java/org/vivecraft/api/data/VRBodyPart.java @@ -1,10 +1,6 @@ package org.vivecraft.api.data; -/** - * The device tracking a specific body part. - */ public enum VRBodyPart { - HMD, MAIN_HAND, OFF_HAND, RIGHT_FOOT, @@ -13,10 +9,11 @@ public enum VRBodyPart { RIGHT_KNEE, LEFT_KNEE, RIGHT_ELBOW, - LEFT_ELBOW; + LEFT_ELBOW, + HMD; /** - * @return The opposite body part to this one, or the same body part if it has no opposite. + * @return the opposite limb */ public VRBodyPart opposite() { return switch (this) { @@ -34,14 +31,28 @@ public VRBodyPart opposite() { /** * Whether this body part type is available in the provided full-body tracking mode. - * @param mode The full-body tracking mode to check. + * @param fbtMode The full-body tracking mode to check. * @return Whether this body part has available data in the provided mode. */ - public boolean availableInMode(FBTMode mode) { + public boolean availableInMode(FBTMode fbtMode) { return switch (this) { case HMD, MAIN_HAND, OFF_HAND -> true; - case RIGHT_FOOT, LEFT_FOOT, WAIST -> mode != FBTMode.ARMS_ONLY; - case RIGHT_KNEE, LEFT_KNEE, RIGHT_ELBOW, LEFT_ELBOW -> mode == FBTMode.WITH_JOINTS; + case RIGHT_FOOT, LEFT_FOOT, WAIST -> fbtMode != FBTMode.ARMS_ONLY; + case RIGHT_KNEE, LEFT_KNEE, RIGHT_ELBOW, LEFT_ELBOW -> fbtMode == FBTMode.WITH_JOINTS; }; } + + /** + * @return Whether this body part is a foot. + */ + public boolean isFoot() { + return this == RIGHT_FOOT || this == LEFT_FOOT; + } + + /** + * @return Whether this body part is a hand. + */ + public boolean isHand() { + return this == MAIN_HAND || this == OFF_HAND; + } } 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 d4d5ff9e0..547700f80 100644 --- a/common/src/main/java/org/vivecraft/client/network/ClientNetworking.java +++ b/common/src/main/java/org/vivecraft/client/network/ClientNetworking.java @@ -23,7 +23,7 @@ import org.vivecraft.common.CommonDataHolder; import org.vivecraft.common.VRServerPerms; import org.vivecraft.common.network.CommonNetworkHelper; -import org.vivecraft.common.network.BodyPart; +import org.vivecraft.api.data.VRBodyPart; import org.vivecraft.common.network.VrPlayerState; import org.vivecraft.common.network.packet.c2s.*; import org.vivecraft.common.network.packet.s2c.*; @@ -51,7 +51,7 @@ public class ClientNetworking { private static float CAPTURED_YAW; private static float CAPTURED_PITCH; private static boolean OVERRIDE_ACTIVE; - public static BodyPart LAST_SENT_BODY_PART = BodyPart.MAIN_HAND; + public static VRBodyPart LAST_SENT_BODY_PART = VRBodyPart.MAIN_HAND; public static boolean NEEDS_RESET = true; @@ -193,11 +193,11 @@ public static int getTeleportHorizLimit() { public static void sendActiveHand(InteractionHand hand) { if (SERVER_WANTS_DATA) { - sendActiveBodyPart(hand == InteractionHand.MAIN_HAND ? BodyPart.MAIN_HAND : BodyPart.OFF_HAND); + sendActiveBodyPart(hand == InteractionHand.MAIN_HAND ? VRBodyPart.MAIN_HAND : VRBodyPart.OFF_HAND); } } - public static void sendActiveBodyPart(BodyPart bodyPart) { + public static void sendActiveBodyPart(VRBodyPart bodyPart) { if (SERVER_WANTS_DATA) { // only send if the hand is different from last time, don't need to spam packets if (bodyPart != LAST_SENT_BODY_PART) { 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 40599b19e..ae90c71bf 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 @@ -35,7 +35,7 @@ import org.vivecraft.client_vr.Vector3fHistory; import org.vivecraft.client_vr.provider.MCVR; import org.vivecraft.api.data.FBTMode; -import org.vivecraft.common.network.BodyPart; +import org.vivecraft.api.data.VRBodyPart; import org.vivecraft.common.utils.MathUtils; import org.vivecraft.data.BlockTags; import org.vivecraft.data.ItemTags; @@ -235,7 +235,7 @@ public void doProcess(LocalPlayer player) { // this.mc.physicalGuiManager.preClickAction(); if (!EpicFightHelper.isLoaded() || !EpicFightHelper.attack()) { - ClientNetworking.sendActiveBodyPart(BodyPart.values()[i]); + ClientNetworking.sendActiveBodyPart(VRBodyPart.values()[i]); // only attack if epic fight didn't trigger this.mc.gameMode.attack(player, entity); } else { @@ -349,7 +349,7 @@ else if (blockstate.getBlock() instanceof NoteBlock || // this.mc.physicalGuiManager.preClickAction(); // send hitting hand - ClientNetworking.sendActiveBodyPart(BodyPart.values()[i]); + ClientNetworking.sendActiveBodyPart(VRBodyPart.values()[i]); // this will either destroy the block if in creative or set it as the current block. // does nothing in survival if you are already hitting this block. @@ -391,7 +391,7 @@ else if (blockstate.getBlock() instanceof NoteBlock || } // reset hitting hand - ClientNetworking.sendActiveBodyPart(BodyPart.MAIN_HAND); + ClientNetworking.sendActiveBodyPart(VRBodyPart.MAIN_HAND); this.mc.getProfiler().pop(); } diff --git a/common/src/main/java/org/vivecraft/common/network/BodyPart.java b/common/src/main/java/org/vivecraft/common/network/BodyPart.java deleted file mode 100644 index 86670f413..000000000 --- a/common/src/main/java/org/vivecraft/common/network/BodyPart.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.vivecraft.common.network; - -import org.vivecraft.api.data.FBTMode; - -public enum BodyPart { - MAIN_HAND, - OFF_HAND, - RIGHT_FOOT, - LEFT_FOOT, - WAIST, - RIGHT_KNEE, - LEFT_KNEE, - RIGHT_ELBOW, - LEFT_ELBOW; - - /** - * @return the opposite limb - */ - public BodyPart opposite() { - return switch (this) { - case MAIN_HAND -> OFF_HAND; - case OFF_HAND -> MAIN_HAND; - case RIGHT_FOOT -> LEFT_FOOT; - case LEFT_FOOT -> RIGHT_FOOT; - case RIGHT_KNEE -> LEFT_KNEE; - case LEFT_KNEE -> RIGHT_KNEE; - case RIGHT_ELBOW -> LEFT_ELBOW; - case LEFT_ELBOW -> RIGHT_ELBOW; - default -> this; - }; - } - - /** - * @param fbtMode FBT mode to check for - * @return if {@code this} limb is valid for the given FBT mode - */ - public boolean isValid(FBTMode fbtMode) { - return switch (this) { - case MAIN_HAND, OFF_HAND -> true; - case RIGHT_FOOT, LEFT_FOOT, WAIST -> fbtMode != FBTMode.ARMS_ONLY; - case RIGHT_KNEE, LEFT_KNEE, RIGHT_ELBOW, LEFT_ELBOW -> fbtMode == FBTMode.WITH_JOINTS; - }; - } - - public boolean isFoot() { - return this == RIGHT_FOOT || this == LEFT_FOOT; - } - - public boolean isHand() { - return this == MAIN_HAND || this == OFF_HAND; - } -} diff --git a/common/src/main/java/org/vivecraft/common/network/VrPlayerState.java b/common/src/main/java/org/vivecraft/common/network/VrPlayerState.java index 974499ab9..41bfcfc5a 100644 --- a/common/src/main/java/org/vivecraft/common/network/VrPlayerState.java +++ b/common/src/main/java/org/vivecraft/common/network/VrPlayerState.java @@ -5,6 +5,7 @@ import net.minecraft.world.phys.Vec3; import org.joml.Quaternionf; import org.joml.Vector3f; +import org.vivecraft.api.data.VRBodyPart; import org.vivecraft.api.data.FBTMode; import org.vivecraft.api.data.VRBodyPartData; import org.vivecraft.client.network.ClientNetworking; @@ -196,7 +197,7 @@ public static VrPlayerState deserialize(FriendlyByteBuf buffer, int bytesAfter) * @return Pose of the {@code bodyPart}, or {@code null} if the body part is not valid for the current FBT mode */ @Nullable - public Pose getBodyPartPose(BodyPart bodyPart) { + public Pose getBodyPartPose(VRBodyPart bodyPart) { return switch(bodyPart) { case MAIN_HAND -> this.mainHand; case OFF_HAND -> this.offHand; @@ -207,6 +208,7 @@ public Pose getBodyPartPose(BodyPart bodyPart) { case LEFT_KNEE -> this.leftKnee; case RIGHT_KNEE -> this.rightKnee; case WAIST -> this.waist; + case HMD -> this.hmd; }; } diff --git a/common/src/main/java/org/vivecraft/common/network/packet/c2s/ActiveBodyPartPayloadC2S.java b/common/src/main/java/org/vivecraft/common/network/packet/c2s/ActiveBodyPartPayloadC2S.java index 15bd9eb50..2d4f40a18 100644 --- a/common/src/main/java/org/vivecraft/common/network/packet/c2s/ActiveBodyPartPayloadC2S.java +++ b/common/src/main/java/org/vivecraft/common/network/packet/c2s/ActiveBodyPartPayloadC2S.java @@ -3,7 +3,7 @@ import net.minecraft.network.FriendlyByteBuf; import org.vivecraft.client.network.ClientNetworking; import org.vivecraft.common.network.CommonNetworkHelper; -import org.vivecraft.common.network.BodyPart; +import org.vivecraft.api.data.VRBodyPart; import org.vivecraft.api.data.FBTMode; import org.vivecraft.common.network.packet.PayloadIdentifier; @@ -12,7 +12,7 @@ * * @param bodyPart the active BodyPart */ -public record ActiveBodyPartPayloadC2S(BodyPart bodyPart) implements VivecraftPayloadC2S { +public record ActiveBodyPartPayloadC2S(VRBodyPart bodyPart) implements VivecraftPayloadC2S { @Override public PayloadIdentifier payloadId() { @@ -23,16 +23,16 @@ public PayloadIdentifier payloadId() { public void write(FriendlyByteBuf buffer) { buffer.writeByte(payloadId().ordinal()); if (ClientNetworking.USED_NETWORK_VERSION < CommonNetworkHelper.NETWORK_VERSION_DUAL_WIELDING && - !this.bodyPart.isValid(FBTMode.ARMS_ONLY)) + !this.bodyPart.availableInMode(FBTMode.ARMS_ONLY)) { // old plugins only support main and offhand - buffer.writeByte(BodyPart.MAIN_HAND.ordinal()); + buffer.writeByte(VRBodyPart.MAIN_HAND.ordinal()); } else { buffer.writeByte(this.bodyPart.ordinal()); } } public static ActiveBodyPartPayloadC2S read(FriendlyByteBuf buffer) { - return new ActiveBodyPartPayloadC2S(BodyPart.values()[buffer.readByte()]); + return new ActiveBodyPartPayloadC2S(VRBodyPart.values()[buffer.readByte()]); } } diff --git a/common/src/main/java/org/vivecraft/mixin/advancements/PlayerPredicateMixin.java b/common/src/main/java/org/vivecraft/mixin/advancements/PlayerPredicateMixin.java index d9dbbcedb..61f517c1f 100644 --- a/common/src/main/java/org/vivecraft/mixin/advancements/PlayerPredicateMixin.java +++ b/common/src/main/java/org/vivecraft/mixin/advancements/PlayerPredicateMixin.java @@ -10,7 +10,7 @@ import net.minecraft.world.phys.Vec3; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; -import org.vivecraft.common.network.BodyPart; +import org.vivecraft.api.data.VRBodyPart; import org.vivecraft.common.utils.MathUtils; import org.vivecraft.server.ServerVRPlayers; import org.vivecraft.server.ServerVivePlayer; @@ -24,7 +24,7 @@ public class PlayerPredicateMixin { if (player.getUseItem().is(Items.SPYGLASS) && ServerVRPlayers.isVRPlayer(player)) { vivePlayer.set(ServerVRPlayers.getVivePlayer(player)); if (!vivePlayer.get().isSeated()) { - return vivePlayer.get().getBodyPartPos(BodyPart.values()[player.getUsedItemHand().ordinal()]); + return vivePlayer.get().getBodyPartPos(VRBodyPart.values()[player.getUsedItemHand().ordinal()]); } } return original.call(player); @@ -37,7 +37,7 @@ public class PlayerPredicateMixin { { if (vivePlayer.get() != null && !vivePlayer.get().isSeated()) { return vivePlayer.get() - .getBodyPartVectorCustom(BodyPart.values()[player.getUsedItemHand().ordinal()], MathUtils.DOWN); + .getBodyPartVectorCustom(VRBodyPart.values()[player.getUsedItemHand().ordinal()], MathUtils.DOWN); } else { return original.call(player, partialTick); } diff --git a/common/src/main/java/org/vivecraft/mixin/client_vr/multiplayer/MultiPlayerGameModeVRMixin.java b/common/src/main/java/org/vivecraft/mixin/client_vr/multiplayer/MultiPlayerGameModeVRMixin.java index 5e48441ff..30815097c 100644 --- a/common/src/main/java/org/vivecraft/mixin/client_vr/multiplayer/MultiPlayerGameModeVRMixin.java +++ b/common/src/main/java/org/vivecraft/mixin/client_vr/multiplayer/MultiPlayerGameModeVRMixin.java @@ -20,7 +20,7 @@ import org.vivecraft.client.network.ClientNetworking; import org.vivecraft.client_vr.ClientDataHolderVR; import org.vivecraft.client_vr.VRState; -import org.vivecraft.common.network.BodyPart; +import org.vivecraft.api.data.VRBodyPart; /** * we override the players look direction so the server handles any interactions as if the player looked at the interacted block @@ -66,12 +66,12 @@ public class MultiPlayerGameModeVRMixin { if (VRState.VR_RUNNING && ClientNetworking.SERVER_ALLOWS_DUAL_WIELDING) { // check if main or offhand items match the started item, we want to limit abuse of this, // but still make both items work - BodyPart lastBodyPart = ClientNetworking.LAST_SENT_BODY_PART; + VRBodyPart lastBodyPart = ClientNetworking.LAST_SENT_BODY_PART; - ClientNetworking.LAST_SENT_BODY_PART = BodyPart.MAIN_HAND; + ClientNetworking.LAST_SENT_BODY_PART = VRBodyPart.MAIN_HAND; boolean sameItem = original.call(pos); - ClientNetworking.LAST_SENT_BODY_PART = BodyPart.OFF_HAND; + ClientNetworking.LAST_SENT_BODY_PART = VRBodyPart.OFF_HAND; sameItem |= original.call(pos); ClientNetworking.LAST_SENT_BODY_PART = lastBodyPart; diff --git a/common/src/main/java/org/vivecraft/mixin/world/entity/InventoryMixin.java b/common/src/main/java/org/vivecraft/mixin/world/entity/InventoryMixin.java index 3b124d8ec..5b5129c01 100644 --- a/common/src/main/java/org/vivecraft/mixin/world/entity/InventoryMixin.java +++ b/common/src/main/java/org/vivecraft/mixin/world/entity/InventoryMixin.java @@ -17,7 +17,7 @@ import org.vivecraft.client.network.ClientNetworking; import org.vivecraft.client_vr.VRState; import org.vivecraft.common.network.CommonNetworkHelper; -import org.vivecraft.common.network.BodyPart; +import org.vivecraft.api.data.VRBodyPart; import org.vivecraft.server.ServerVRPlayers; import org.vivecraft.server.ServerVivePlayer; import org.vivecraft.server.config.ServerConfig; @@ -44,7 +44,7 @@ public class InventoryMixin { @Unique private ItemStack vivecraft$activeItem(ItemStack original) { - BodyPart bodyPart = null; + VRBodyPart bodyPart = null; // server side if (this.player instanceof ServerPlayer serverPlayer && ServerConfig.DUAL_WIELDING.get()) { if (ServerVRPlayers.isVRPlayer(serverPlayer)) { @@ -61,9 +61,9 @@ else if (this.player.isLocalPlayer() && VRState.VR_RUNNING && ClientNetworking.S } if (bodyPart != null) { - if (bodyPart == BodyPart.OFF_HAND) { + if (bodyPart == VRBodyPart.OFF_HAND) { return this.offhand.get(0); - } else if (bodyPart != BodyPart.MAIN_HAND) { + } else if (bodyPart != VRBodyPart.MAIN_HAND) { // feet return ItemStack.EMPTY; } diff --git a/common/src/main/java/org/vivecraft/server/ServerNetworking.java b/common/src/main/java/org/vivecraft/server/ServerNetworking.java index fcc337efe..df15bbfb0 100644 --- a/common/src/main/java/org/vivecraft/server/ServerNetworking.java +++ b/common/src/main/java/org/vivecraft/server/ServerNetworking.java @@ -19,7 +19,7 @@ import org.vivecraft.common.CommonDataHolder; import org.vivecraft.common.network.CommonNetworkHelper; import org.vivecraft.api.data.FBTMode; -import org.vivecraft.common.network.BodyPart; +import org.vivecraft.api.data.VRBodyPart; import org.vivecraft.common.network.VrPlayerState; import org.vivecraft.common.network.packet.PayloadIdentifier; import org.vivecraft.common.network.packet.c2s.*; @@ -194,7 +194,7 @@ public static void handlePacket( player.connection.aboveGroundTickCount = 0; } case ACTIVEHAND -> { - BodyPart newBodyPart = vivePlayer.isSeated() ? BodyPart.MAIN_HAND : ((ActiveBodyPartPayloadC2S) c2sPayload).bodyPart(); + VRBodyPart newBodyPart = vivePlayer.isSeated() ? VRBodyPart.MAIN_HAND : ((ActiveBodyPartPayloadC2S) c2sPayload).bodyPart(); if (vivePlayer.activeBodyPart != newBodyPart) { // handle equipment changes ItemStack oldItem = player.getItemBySlot(EquipmentSlot.MAINHAND); diff --git a/common/src/main/java/org/vivecraft/server/ServerUtil.java b/common/src/main/java/org/vivecraft/server/ServerUtil.java index fd9bad517..3766dbd34 100644 --- a/common/src/main/java/org/vivecraft/server/ServerUtil.java +++ b/common/src/main/java/org/vivecraft/server/ServerUtil.java @@ -19,7 +19,7 @@ import org.joml.Quaternionfc; import org.joml.Vector3f; import org.vivecraft.client.utils.UpdateChecker; -import org.vivecraft.common.network.BodyPart; +import org.vivecraft.api.data.VRBodyPart; import org.vivecraft.common.utils.MathUtils; import org.vivecraft.server.config.ConfigBuilder; import org.vivecraft.server.config.ServerConfig; @@ -338,8 +338,8 @@ public static void registerCommands( */ public static void debugParticleAxes(ServerVivePlayer vivePlayer) { if (vivePlayer.isVR() && vivePlayer.vrPlayerState != null) { - for(BodyPart bodyPart : BodyPart.values()) { - if (bodyPart.isValid(vivePlayer.vrPlayerState.fbtMode())) { + for(VRBodyPart bodyPart : VRBodyPart.values()) { + if (bodyPart.availableInMode(vivePlayer.vrPlayerState.fbtMode()) && bodyPart != VRBodyPart.HMD) { debugParticleAxes( vivePlayer.player.serverLevel(), vivePlayer.getBodyPartPos(bodyPart), diff --git a/common/src/main/java/org/vivecraft/server/ServerVivePlayer.java b/common/src/main/java/org/vivecraft/server/ServerVivePlayer.java index bbcd6390a..1f170dc4c 100644 --- a/common/src/main/java/org/vivecraft/server/ServerVivePlayer.java +++ b/common/src/main/java/org/vivecraft/server/ServerVivePlayer.java @@ -3,14 +3,12 @@ import net.minecraft.server.level.ServerPlayer; import net.minecraft.util.Mth; import net.minecraft.world.phys.Vec3; -import org.joml.Quaternionfc; import org.joml.Vector3f; import org.joml.Vector3fc; -import org.vivecraft.common.network.*; +import org.vivecraft.api.data.VRBodyPart; import org.vivecraft.common.utils.MathUtils; import org.vivecraft.api.data.VRPose; import org.vivecraft.common.network.CommonNetworkHelper; -import org.vivecraft.common.network.Pose; import org.vivecraft.common.network.VrPlayerState; import javax.annotation.Nullable; @@ -23,7 +21,7 @@ public class ServerVivePlayer { public float draw; public float worldScale = 1.0F; public float heightScale = 1.0F; - public BodyPart activeBodyPart = BodyPart.MAIN_HAND; + public VRBodyPart activeBodyPart = VRBodyPart.MAIN_HAND; public boolean crawling; // if the player has VR active private boolean isVR = false; @@ -45,10 +43,10 @@ public ServerVivePlayer(ServerPlayer player) { * @param direction local direction to transform * @return direction in world space */ - public Vec3 getBodyPartVectorCustom(BodyPart bodyPart, Vector3fc direction) { + public Vec3 getBodyPartVectorCustom(VRBodyPart bodyPart, Vector3fc direction) { if (this.vrPlayerState != null) { - if (this.isSeated() || !bodyPart.isValid(this.vrPlayerState.fbtMode())) { - bodyPart = BodyPart.MAIN_HAND; + if (this.isSeated() || !bodyPart.availableInMode(this.vrPlayerState.fbtMode())) { + bodyPart = VRBodyPart.MAIN_HAND; } return new Vec3( @@ -62,7 +60,7 @@ public Vec3 getBodyPartVectorCustom(BodyPart bodyPart, Vector3fc direction) { * @param bodyPart BodyPart to get the direction from, if not available, will use the MAIN_HAND * @return forward direction of the given BodyPart */ - public Vec3 getBodyPartDir(BodyPart bodyPart) { + public Vec3 getBodyPartDir(VRBodyPart bodyPart) { return this.getBodyPartVectorCustom(bodyPart, MathUtils.BACK); } @@ -109,17 +107,17 @@ public Vec3 getHMDPos() { * @param realPosition if true disables the seated override * @return BodyPart position in world space */ - public Vec3 getBodyPartPos(BodyPart bodyPart, boolean realPosition) { + public Vec3 getBodyPartPos(VRBodyPart bodyPart, boolean realPosition) { if (this.vrPlayerState != null) { - if (!bodyPart.isValid(this.vrPlayerState.fbtMode())) { - bodyPart = BodyPart.MAIN_HAND; + if (!bodyPart.availableInMode(this.vrPlayerState.fbtMode())) { + bodyPart = VRBodyPart.MAIN_HAND; } // in seated the realPosition is at the head, // so reconstruct the seated position when wanting the visual position if (this.isSeated() && !realPosition) { Vec3 dir = this.getHMDDir(); - dir = dir.yRot(Mth.DEG_TO_RAD * (bodyPart == BodyPart.MAIN_HAND ? -35.0F : 35.0F)); + dir = dir.yRot(Mth.DEG_TO_RAD * (bodyPart == VRBodyPart.MAIN_HAND ? -35.0F : 35.0F)); dir = new Vec3(dir.x, 0.0D, dir.z); dir = dir.normalize(); return this.getHMDPos().add( @@ -143,7 +141,7 @@ public Vec3 getBodyPartPos(BodyPart bodyPart, boolean realPosition) { * @param bodyPart BodyPart to get the position for, if not available, will use the MAIN_HAND * @return BodyPart position in world space */ - public Vec3 getBodyPartPos(BodyPart bodyPart) { + public Vec3 getBodyPartPos(VRBodyPart bodyPart) { return getBodyPartPos(bodyPart, false); }