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
  • 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
    • onPrePhysicsTick

      public void onPrePhysicsTick()
    • onPhysicsTick

      public void onPhysicsTick()
    • grab

      @Nullable public @Nullable net.xmx.velthoric.core.body.VxBody grab(net.minecraft.world.entity.player.Player player, PlayerBodyPart playerBodyPart, boolean isRemoteAllowed)
      Attempts to grab an object using the specified player's body part.
      Parameters:
      player - the player attempting to grab
      playerBodyPart - the body part to use for grabbing
      isRemoteAllowed - whether remote grabbing (raycast-based) is allowed if no bodies are within grab radius
      Returns:
      the body that was grabbed, or null if no body was grabbed
      See Also:
    • updatePullState

      public void updatePullState(net.minecraft.world.entity.player.Player player, PlayerBodyPart playerBodyPart)
      Updates pull behavior for a grabbed body part.
      Parameters:
      player - the player attempting to pull
      playerBodyPart - the body part performing the pull
    • release

      public void release(net.minecraft.world.entity.player.Player player, PlayerBodyPart playerBodyPart)
      Releases any object being grabbed by the specified player's body part.
      Parameters:
      player - the player releasing the grab
      playerBodyPart - the body part to release
      See Also:
    • updateTriggerState

      public void updateTriggerState(net.minecraft.world.entity.player.Player player, PlayerBodyPart playerBodyPart, TriggerState triggerState)
    • processGrabResult

      public void processGrabResult(net.minecraft.world.entity.player.Player player, PlayerBodyPart playerBodyPart, GrabInteraction.GrabResult grabResult)