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
-
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, PlayerBodyPart playerBodyPart, boolean isRemoteAllowed) Attempts to grab an object using the specified player's body part.voidvoidvoidprocessGrabResult(net.minecraft.world.entity.player.Player player, PlayerBodyPart playerBodyPart, GrabInteraction.GrabResult grabResult) voidrelease(net.minecraft.world.entity.player.Player player, PlayerBodyPart playerBodyPart) Releases any object being grabbed by the specified player's body part.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.voidupdatePullState(net.minecraft.world.entity.player.Player player, PlayerBodyPart playerBodyPart) Updates pull behavior for a grabbed body part.voidupdateTriggerState(net.minecraft.world.entity.player.Player player, PlayerBodyPart playerBodyPart, TriggerState triggerState)
-
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
-
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 grabplayerBodyPart- the body part to use for grabbingisRemoteAllowed- 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 pullplayerBodyPart- the body part performing the pull
-
release
Releases any object being grabbed by the specified player's body part.- Parameters:
player- the player releasing the grabplayerBodyPart- 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)
-