Interface VRAPI


public interface VRAPI
The main interface for interacting with Vivecraft from code.
Since:
1.3.0
  • Method Summary

    Modifier and Type
    Method
    Description
    @Nullable VRPoseHistory
    getHistoricalVRPoses(org.bukkit.entity.Player player)
    Returns the history of VR poses for the player.
    @Nullable VRPose
    getVRPose(org.bukkit.entity.Player player)
    Returns the VR pose for the given player.
    static VRAPI
    Gets API instance for interacting with Vivecraft's common API
    boolean
    isVRPlayer(org.bukkit.entity.Player player)
    Check whether a given player is currently in VR.
    default void
    sendHapticPulse(org.bukkit.entity.Player player, VRBodyPart bodyPart, float duration)
    Sends a haptic pulse (vibration/rumble) at full strength with 160 Hz for the specified VRBodyPart, if possible, to the given player.
    void
    sendHapticPulse(org.bukkit.entity.Player player, VRBodyPart bodyPart, float duration, float frequency, float amplitude, float delay)
    Sends a haptic pulse (vibration/rumble) for the specified VRBodyPart, if possible, to the given player.
  • Method Details

    • instance

      static VRAPI instance()
      Gets API instance for interacting with Vivecraft's common API
      Returns:
      The Vivecraft API instance for interacting with Vivecraft's common API.
      Since:
      1.3.0
    • isVRPlayer

      boolean isVRPlayer(org.bukkit.entity.Player player)
      Check whether a given player is currently in VR.
      Parameters:
      player - The player to check the VR status of.
      Returns:
      true if the player is in VR.
      Since:
      1.3.0
    • getVRPose

      @Nullable @Nullable VRPose getVRPose(org.bukkit.entity.Player player)
      Returns the VR pose for the given player. Will return null if the player isn't in VR
      Parameters:
      player - Player to get the VR pose of.
      Returns:
      The VR pose for a player, or null if the player isn't in VR or no data has been received for said player.
      Since:
      1.3.0
    • getHistoricalVRPoses

      @Nullable @Nullable VRPoseHistory getHistoricalVRPoses(org.bukkit.entity.Player player)
      Returns the history of VR poses for the player.
      Note that due to the inherent latency of networking, historical VR data retrieved by the server may be unideal.
      Parameters:
      player - Player to get the VR pose history of.
      Returns:
      The history of VR poses for the player. Will be null if the player isn't in VR or if VR-specific data hasn't been received.
      Since:
      1.3.0
    • sendHapticPulse

      void sendHapticPulse(org.bukkit.entity.Player player, VRBodyPart bodyPart, float duration, float frequency, float amplitude, float delay)
      Sends a haptic pulse (vibration/rumble) for the specified VRBodyPart, if possible, to the given player. This function silently fails if called for players not in VR or players who are in seated mode.
      Parameters:
      player - Player to send the haptic pulse to.
      bodyPart - The VRBodyPart to trigger a haptic pulse on.
      duration - The duration of the haptic pulse in seconds. Note that this number is passed to the underlying VR API used by Vivecraft, and may act with a shorter length than expected beyond very short pulses.
      frequency - The frequency of the haptic pulse in Hz. (might be ignored if the targeted device doesn't support it)
      160 Hz is a safe bet for this number, with Vivecraft's codebase using anywhere from 160 Hz for actions such as a bite on a fishing line, to 1000 Hz for things such as a chat notification.
      amplitude - The amplitude of the haptic pulse. This should be kept between 0 and 1.
      delay - An amount of time to delay until creating the haptic pulse. The majority of the time, one should use 0 here. This starts counting when the client receives the packet.
      Since:
      1.3.0
    • sendHapticPulse

      default void sendHapticPulse(org.bukkit.entity.Player player, VRBodyPart bodyPart, float duration)
      Sends a haptic pulse (vibration/rumble) at full strength with 160 Hz for the specified VRBodyPart, if possible, to the given player.
      If one wants more control over the used parameters one should use sendHapticPulse(Player, VRBodyPart, float, float, float, float) instead.
      This function silently fails if called for players not in VR or players who are in seated mode.
      Parameters:
      player - Player to send the haptic pulse to.
      bodyPart - The VRBodyPart to trigger a haptic pulse on.
      duration - The duration of the haptic pulse in seconds. Note that this number is passed to the underlying VR API used by Vivecraft, and may act with a shorter length than expected beyond very short pulses.
      Since:
      1.3.0