Class PlayerBodyManager

java.lang.Object
net.timtaran.interactivemc.body.player.PlayerBodyManager

public class PlayerBodyManager extends Object
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
    Modifier and Type
    Field
    Description
    static final float
     
  • Method Summary

    Modifier and Type
    Method
    Description
    get(net.minecraft.world.level.Level level)
    Gets the PlayerBodyManager for the given level.
    get(net.xmx.velthoric.core.physics.world.VxPhysicsWorld world)
    Gets the PlayerBodyManager for the given physics world.
    @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.
    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.
    void
    removePlayer(net.minecraft.world.entity.player.Player player)
    Removes all body parts for a player when they leave the game.
    void
    spawnPlayer(net.minecraft.world.entity.player.Player player)
    Spawns all body parts for a player when they join or respawn.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Method Details

    • get

      public static PlayerBodyManager get(net.minecraft.world.level.Level level)
      Gets the PlayerBodyManager for the given level.
      Parameters:
      level - the level
      Returns:
      the manager for that level's physics world
    • get

      public static PlayerBodyManager get(net.xmx.velthoric.core.physics.world.VxPhysicsWorld world)
      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 grab
      interactionHand - 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 grab
      interactionHand - the hand to release (main or off-hand)