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 Type
    Method
    Description
    default boolean
    canRelease(net.minecraft.world.entity.player.Player player, PlayerBodyPart bodyPart)
    Method called before the body is released.
    @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.
    @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.
    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.
    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.
    default boolean
    onPull(net.minecraft.world.entity.player.Player player, PlayerBodyPart bodyPart)
    Method called when the body is being pulled.
    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.
    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.
    default void
    onTriggerStateUpdate(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 body
      bodyPart - player body part interacting with the body
      intersectionPoint - 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, set GrabPoint position to intersectionPoint.
      rotationDifference - the rotation difference between the grabber and the body. If body shouldn't move, set GrabPoint rotation to rotationDifference.
      Returns:
      GrabPoint, or null to 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 null to 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 body
      bodyPart - player body part interacting with the body
      triggerState - 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 isAttached is false, the body is marked to pulled.

      Parameters:
      player - the player grabbing the body
      grabberBody - the body part grabbing this body
      bodyPart - player body part grabbing the body
      isAttached - true if the body is attached to the player body part, false otherwise
    • 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 isAttached is false, the body is marked to pulled.

      Parameters:
      player - the player grabbing the body
      bodyPart - player body part grabbing the body
      isAttached - true if the body is attached, false if 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 body
      bodyPart - player body part that was grabbing the body
      isAttached - true if the body was attached, false if it was being pulled
    • onPull

      default boolean onPull(net.minecraft.world.entity.player.Player player, PlayerBodyPart bodyPart)
      Method called when the body is being pulled.
      Parameters:
      player - the player pulling the body
      bodyPart - player body part pulling the body
      Returns:
      true to allow pulling body, false otherwise
    • 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 body
      grabberBody - the body part grabbing this body
      bodyPart - player body part releasing the body
      isAttached - true if the body was attached to the player body part, false otherwise
    • 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 body
      bodyPart - player body part releasing the body
      Returns:
      true to allow releasing body, false otherwise