Package org.vivecraft.api.client
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
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 TypeMethodDescriptionResourceLocation
getId()
The ID of this module.default int
The priority value of a module determines when itsisActive(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 givenhand
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 beforeisActive(LocalPlayer, InteractionHand, Vec3)
is calleddefault 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 itsisActive(LocalPlayer, InteractionHand, Vec3)
method is called compared to other modules. Modules are only processed until a modules returnstrue
onisActive(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 beforeisActive(LocalPlayer, InteractionHand, Vec3)
is called- Parameters:
player
- the local player,null
if not in a worldhand
- 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 givenhand
to interact with the module.
If this returnstrue
and no module was active in the last tick, it will cause haptic feedback on thehand
to indicate that the user can now use the Interact keybind.- Parameters:
player
- the local playerhand
- the hand to check forhandPosition
- the world position thehand
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 whenisActive(LocalPlayer, InteractionHand, Vec3)
returnedtrue
and no other module did so before this one.- Parameters:
player
- the local playerhand
- 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
-