Interface VRServerAPI


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

    Modifier and Type
    Method
    Description
     
    default void
    sendHapticPulse(ServerPlayer 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(ServerPlayer 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 VRServerAPI instance()
      Returns:
      The Vivecraft API instance for interacting with Vivecraft's server API.
      Since:
      1.3.0
    • sendHapticPulse

      void sendHapticPulse(ServerPlayer 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. To directly trigger a haptic pulse for the local player, use VRClientAPI.triggerHapticPulse(org.vivecraft.api.data.VRBodyPart, float, float, float, float) 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(ServerPlayer 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(ServerPlayer, VRBodyPart, float, float, float, float) instead.
      To directly trigger a haptic pulse for the local player, use VRClientAPI.triggerHapticPulse(org.vivecraft.api.data.VRBodyPart, float, float, float, float) 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