Class GrabInteraction
java.lang.Object
net.timtaran.interactivemc.body.player.interaction.GrabInteraction
Handles the logic for physical interactions between a player and objects in the world.
This class manages the detection of grabbable objects using sphere-casting, the creation of physical constraints (joints) to "attach" objects to the player's hands, and the subsequent release of those objects.
This class is only intended for use by PlayerBodyManager.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordResult of a grab attempt. -
Constructor Summary
ConstructorsConstructorDescriptionGrabInteraction(net.xmx.velthoric.core.physics.world.VxPhysicsWorld world, PlayerBodyManager playerBodyManager) -
Method Summary
Modifier and TypeMethodDescriptionvoidapplyPullForce(net.minecraft.world.entity.player.Player player, net.xmx.velthoric.core.body.VxBody grabberBody, net.xmx.velthoric.core.body.VxBody grabbedBody, PlayerBodyPart playerBodyPart) @Nullable net.xmx.velthoric.core.constraint.VxConstraintattach(net.xmx.velthoric.core.body.VxBody grabberBody, net.xmx.velthoric.core.body.VxBody grabbedBody, com.github.stephengold.joltjni.readonly.RVec3Arg worldGrabPoint, net.minecraft.world.entity.player.Player player, PlayerBodyPart playerBodyPart) attachIfWithinReach(net.minecraft.world.entity.player.Player player, net.xmx.velthoric.core.body.VxBody grabberBody, net.xmx.velthoric.core.body.VxBody grabbedBody, PlayerBodyPart playerBodyPart) static booleancanGrabClient(PlayerBodyPart playerBodyPart) Checks is any body around player can be grabbed.@Nullable GrabInteraction.GrabResultgrab(net.minecraft.world.entity.player.Player player, net.xmx.velthoric.core.body.VxBody grabberBody, PlayerBodyPart playerBodyPart, boolean isRemoteAllowed) Attempts to grab an object using the specified player's body part.booleanrelease(net.minecraft.world.entity.player.Player player, net.xmx.velthoric.core.body.VxBody grabberBody, net.xmx.velthoric.core.body.VxBody grabbedBody, PlayerBodyPart playerBodyPart, PlayerBodyPartData playerBodyPartData) Releases any object being grabbed by the specified player's hand.booleanupdatePullState(net.minecraft.world.entity.player.Player player, net.xmx.velthoric.core.body.VxBody grabberBody, net.xmx.velthoric.core.body.VxBody grabbedBody, PlayerBodyPart playerBodyPart)
-
Constructor Details
-
GrabInteraction
public GrabInteraction(net.xmx.velthoric.core.physics.world.VxPhysicsWorld world, PlayerBodyManager playerBodyManager)
-
-
Method Details
-
grab
@Nullable public @Nullable GrabInteraction.GrabResult grab(net.minecraft.world.entity.player.Player player, net.xmx.velthoric.core.body.VxBody grabberBody, PlayerBodyPart playerBodyPart, boolean isRemoteAllowed) Attempts to grab an object using the specified player's body part.- Parameters:
player- the player attempting to grabgrabberBody- the body that is grabbingplayerBodyPart- the player's body partisRemoteAllowed- 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
-
attach
@Nullable public @Nullable net.xmx.velthoric.core.constraint.VxConstraint attach(net.xmx.velthoric.core.body.VxBody grabberBody, net.xmx.velthoric.core.body.VxBody grabbedBody, com.github.stephengold.joltjni.readonly.RVec3Arg worldGrabPoint, net.minecraft.world.entity.player.Player player, PlayerBodyPart playerBodyPart) -
attachIfWithinReach
public GrabInteraction.GrabResult attachIfWithinReach(net.minecraft.world.entity.player.Player player, net.xmx.velthoric.core.body.VxBody grabberBody, net.xmx.velthoric.core.body.VxBody grabbedBody, PlayerBodyPart playerBodyPart) -
applyPullForce
public void applyPullForce(net.minecraft.world.entity.player.Player player, net.xmx.velthoric.core.body.VxBody grabberBody, net.xmx.velthoric.core.body.VxBody grabbedBody, PlayerBodyPart playerBodyPart) -
updatePullState
public boolean updatePullState(net.minecraft.world.entity.player.Player player, net.xmx.velthoric.core.body.VxBody grabberBody, net.xmx.velthoric.core.body.VxBody grabbedBody, PlayerBodyPart playerBodyPart) -
release
public boolean release(net.minecraft.world.entity.player.Player player, net.xmx.velthoric.core.body.VxBody grabberBody, net.xmx.velthoric.core.body.VxBody grabbedBody, PlayerBodyPart playerBodyPart, PlayerBodyPartData playerBodyPartData) 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:
playerBodyPartData- the player's body part data- Returns:
trueif the body was successfully released,falseotherwise
-
canGrabClient
Checks is any body around player can be grabbed. Used to predict if player can grab body inKeyMappingHandlingMixinto prevent other grip binds to be called.- Returns:
- is any body around player can be grabbed.
-