Interface IGrabbable
- All Known Implementing Classes:
TestDuckRigidBody
public interface IGrabbable
An interface for bodies that can be grabbed by other bodies.
Implementations of this interface provide specific points for grabbing, defining where and how the body will be held when interacted with.
-
Method Summary
Modifier and TypeMethodDescriptiondefault booleancanRelease(net.minecraft.world.entity.player.Player player, PlayerBodyPart bodyPart) Method called before the body is released.@Nullable GrabPointgetGrabPoint(net.minecraft.world.entity.player.Player player, PlayerBodyPart bodyPart, com.github.stephengold.joltjni.readonly.RVec3Arg intersectionPoint, com.github.stephengold.joltjni.readonly.QuatArg rotationDifference) Defines where on the body a grabber attaches.@Nullable GrabPointgetRemoteGrabPoint(net.minecraft.world.entity.player.Player player, PlayerBodyPart bodyPart, com.github.stephengold.joltjni.readonly.RVec3Arg intersectionPoint) Gets the grab point position in the local space.default voidonGrab(net.minecraft.world.entity.player.Player player, net.xmx.velthoric.core.body.VxBody grabberBody, PlayerBodyPart bodyPart, boolean isAttached) Method called when the body is grabbed.default voidonGrabClient(net.minecraft.world.entity.player.Player player, PlayerBodyPart bodyPart, boolean isAttached) Method called when the client receives successful grab result from the server.default booleanonPull(net.minecraft.world.entity.player.Player player, PlayerBodyPart bodyPart) Method called when the body is being pulled.default voidonRelease(net.minecraft.world.entity.player.Player player, net.xmx.velthoric.core.body.VxBody grabberBody, PlayerBodyPart bodyPart, boolean isAttached) Method called when the body is released.default voidonReleaseClient(net.minecraft.world.entity.player.Player player, PlayerBodyPart bodyPart, boolean isAttached) Method called when the client receives unsuccessful grab result from the server.default voidonTriggerStateUpdate(net.minecraft.world.entity.player.Player player, PlayerBodyPart bodyPart, TriggerState triggerState) Method called when body is being interacted.
-
Method Details
-
getGrabPoint
@Nullable @Nullable GrabPoint getGrabPoint(net.minecraft.world.entity.player.Player player, PlayerBodyPart bodyPart, com.github.stephengold.joltjni.readonly.RVec3Arg intersectionPoint, com.github.stephengold.joltjni.readonly.QuatArg rotationDifference) Defines where on the body a grabber attaches.- Parameters:
player- the player interacting with the bodybodyPart- player body part interacting with the bodyintersectionPoint- the intersection point between the grabber and the body, relative to the body position (not center of mass). Implementations may use this to determine the closest valid grab point. If the grab point is arbitrary, setGrabPointposition tointersectionPoint.rotationDifference- the rotation difference between the grabber and the body. If body shouldn't move, setGrabPointrotation torotationDifference.- Returns:
GrabPoint, ornullto prevent grabbing.
-
getRemoteGrabPoint
@Nullable @Nullable GrabPoint getRemoteGrabPoint(net.minecraft.world.entity.player.Player player, PlayerBodyPart bodyPart, com.github.stephengold.joltjni.readonly.RVec3Arg intersectionPoint) Gets the grab point position in the local space.Defines where a grabber attaches to the body during a remote grab.
- Parameters:
intersectionPoint- the intersection point between the grabber and the body.- Returns:
- the local position of the grab point, or
nullto prevent grabbing. - See Also:
-
onTriggerStateUpdate
default void onTriggerStateUpdate(net.minecraft.world.entity.player.Player player, PlayerBodyPart bodyPart, TriggerState triggerState) Method called when body is being interacted.- Parameters:
player- the player interacting with the bodybodyPart- player body part interacting with the bodytriggerState- the trigger state of body part
-
onGrab
default void onGrab(net.minecraft.world.entity.player.Player player, net.xmx.velthoric.core.body.VxBody grabberBody, PlayerBodyPart bodyPart, boolean isAttached) Method called when the body is grabbed.If
isAttachedisfalse, the body is marked to pulled.- Parameters:
player- the player grabbing the bodygrabberBody- the body part grabbing this bodybodyPart- player body part grabbing the bodyisAttached-trueif the body is attached to the player body part,falseotherwise
-
onGrabClient
@Environment(CLIENT) default void onGrabClient(net.minecraft.world.entity.player.Player player, PlayerBodyPart bodyPart, boolean isAttached) Method called when the client receives successful grab result from the server.If
isAttachedisfalse, the body is marked to pulled.- Parameters:
player- the player grabbing the bodybodyPart- player body part grabbing the bodyisAttached-trueif the body is attached,falseif being pulled
-
onReleaseClient
@Environment(CLIENT) default void onReleaseClient(net.minecraft.world.entity.player.Player player, PlayerBodyPart bodyPart, boolean isAttached) Method called when the client receives unsuccessful grab result from the server.- Parameters:
player- the player that was grabbing the bodybodyPart- player body part that was grabbing the bodyisAttached-trueif the body was attached,falseif it was being pulled
-
onPull
Method called when the body is being pulled.- Parameters:
player- the player pulling the bodybodyPart- player body part pulling the body- Returns:
trueto allow pulling body,falseotherwise
-
onRelease
default void onRelease(net.minecraft.world.entity.player.Player player, net.xmx.velthoric.core.body.VxBody grabberBody, PlayerBodyPart bodyPart, boolean isAttached) Method called when the body is released.- Parameters:
player- the player releasing the bodygrabberBody- the body part grabbing this bodybodyPart- player body part releasing the bodyisAttached-trueif the body was attached to the player body part,falseotherwise
-
canRelease
default boolean canRelease(net.minecraft.world.entity.player.Player player, PlayerBodyPart bodyPart) Method called before the body is released.- Parameters:
player- the player releasing the bodybodyPart- player body part releasing the body- Returns:
trueto allow releasing body,falseotherwise
-