Class PlayerBodyManager
java.lang.Object
net.timtaran.interactivemc.body.player.PlayerBodyManager
Manages the creation, tracking, and interaction of player bodies in the physics world.
Each player has multiple body parts (head, hands, etc.) represented as both dynamic and ghost (kinematic) rigid bodies.
The manager is responsible for:
- Creating and removing player bodies
- Managing grab interactions between bodies
- Maintaining constraints between bodies
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic PlayerBodyManagerget(net.minecraft.world.level.Level level) Gets the PlayerBodyManager for the given level.static PlayerBodyManagerget(net.xmx.velthoric.core.physics.world.VxPhysicsWorld world) Gets the PlayerBodyManager for the given physics world.@Nullable net.xmx.velthoric.core.body.VxBodygrab(net.minecraft.world.entity.player.Player player, net.minecraft.world.InteractionHand interactionHand) Attempts to grab an object using the specified player's hand.voidrelease(net.minecraft.world.entity.player.Player player, net.minecraft.world.InteractionHand interactionHand) Releases any object being grabbed by the specified player's hand.voidremovePlayer(net.minecraft.world.entity.player.Player player) Removes all body parts for a player when they leave the game.voidspawnPlayer(net.minecraft.world.entity.player.Player player) Spawns all body parts for a player when they join or respawn.
-
Field Details
-
GRAB_RADIUS
public static final float GRAB_RADIUS- See Also:
-
-
Method Details
-
get
Gets the PlayerBodyManager for the given level.- Parameters:
level- the level- Returns:
- the manager for that level's physics world
-
get
Gets the PlayerBodyManager for the given physics world.- Parameters:
world- the physics world- Returns:
- the manager for that world
-
spawnPlayer
public void spawnPlayer(net.minecraft.world.entity.player.Player player) Spawns all body parts for a player when they join or respawn.If the player already has bodies, they will be removed first.
- Parameters:
player- the player to spawn bodies for
-
removePlayer
public void removePlayer(net.minecraft.world.entity.player.Player player) Removes all body parts for a player when they leave the game.- Parameters:
player- the player to remove bodies for
-
grab
@Nullable public @Nullable net.xmx.velthoric.core.body.VxBody grab(net.minecraft.world.entity.player.Player player, net.minecraft.world.InteractionHand interactionHand) Attempts to grab an object using the specified player's hand.This method performs a sphere cast from the grab point and tries to grab the closest non-player body within the grab radius.
- Parameters:
player- the player attempting to grabinteractionHand- the hand to use for grabbing (main or off-hand)- Returns:
- the body that was grabbed, or null if no body was grabbed
-
release
public void release(net.minecraft.world.entity.player.Player player, net.minecraft.world.InteractionHand interactionHand) Releases any object being grabbed by the specified player's hand.This removes the grab constraint, allowing the grabbed body to move freely again.
- Parameters:
player- the player releasing the grabinteractionHand- the hand to release (main or off-hand)
-