Interface InteractModule

All Known Subinterfaces:
HeldInteractModule

public interface InteractModule
An InteractModule can influence what happens when the user presses the Interact keybind. The Interact keybind is added by Vivecraft and by default bound to the Trigger and Grip of each controller. InteractModules are hand agnostic and are processed on tick.
They are sorted by the priority value provided by getPriority() and their ID on a priority tie. Modules are processed in that fixed sorted order per hand and the first one that returns true on isActive(LocalPlayer, InteractionHand, Vec3) gets the keybind for that hand. isActive(LocalPlayer, InteractionHand, Vec3) on modules after the active one will not be called for that hand.
Since:
1.3.0
  • Method Summary

    Modifier and Type
    Method
    Description
    ResourceLocation
    The ID of this module.
    default int
    The priority value of a module determines when its isActive(LocalPlayer, InteractionHand, Vec3) method is called compared to other modules.
    boolean
    isActive(LocalPlayer player, InteractionHand hand, Vec3 handPosition)
    This is used to check if the user can use the Interact keybind on the given hand to interact with the module.
    boolean
    onPress(LocalPlayer player, InteractionHand hand)
    Use this to do an action when the Interact keybind is being pressed.
    default void
    reset(LocalPlayer player, InteractionHand hand)
    Used to reset the module state for the given hand, this is called when the Interact Tracker is not active anymore, and before isActive(LocalPlayer, InteractionHand, Vec3) is called
    default boolean
    By default, an interaction causes an armswing, to give the player a visual indicator that the action was successful.
  • Method Details

    • getPriority

      default int getPriority()
      The priority value of a module determines when its isActive(LocalPlayer, InteractionHand, Vec3) method is called compared to other modules. Modules are only processed until a modules returns true on isActive(LocalPlayer, InteractionHand, Vec3), modules after that are not checked. A lower priority value means it is processed earlier. Can be any Integer, negative values are also allowed. Vivecraft itself uses values ranging from 0-1500.
      Returns:
      priority value of this module
      Since:
      1.3.0
    • getId

      ResourceLocation getId()
      The ID of this module. This is used to sort on a priority tie, should ideally be of the format "modID":"moduleName".
      Returns:
      The ID of this module.
      Since:
      1.3.0
    • reset

      default void reset(@Nullable LocalPlayer player, InteractionHand hand)
      Used to reset the module state for the given hand, this is called when the Interact Tracker is not active anymore, and before isActive(LocalPlayer, InteractionHand, Vec3) is called
      Parameters:
      player - the local player, null if not in a world
      hand - the hand to reset
      Since:
      1.3.0
    • isActive

      boolean isActive(LocalPlayer player, InteractionHand hand, Vec3 handPosition)
      This is used to check if the user can use the Interact keybind on the given hand to interact with the module.
      If this returns true and no module was active in the last tick, it will cause haptic feedback on the hand to indicate that the user can now use the Interact keybind.
      Parameters:
      player - the local player
      hand - the hand to check for
      handPosition - the world position the hand is at, supplied for convenience
      Returns:
      true if this module is active and wants to use the Interact keybind
      Since:
      1.3.0
    • onPress

      boolean onPress(LocalPlayer player, InteractionHand hand)
      Use this to do an action when the Interact keybind is being pressed.
      This is only called when isActive(LocalPlayer, InteractionHand, Vec3) returned true and no other module did so before this one.
      Parameters:
      player - the local player
      hand - the hand that is pressing the Interact keybind
      Returns:
      if the interaction was successful, will cause haptic feedback when true
      Since:
      1.3.0
    • swingsArm

      default boolean swingsArm()
      By default, an interaction causes an armswing, to give the player a visual indicator that the action was successful. This can be overridden to prevent that.
      Returns:
      if the interaction should cause a hand swing after a successful onPress(LocalPlayer, InteractionHand) call
      Since:
      1.3.0