Class AbstractTicker

java.lang.Object
com.hammy275.immersivemc.common.ticker.AbstractTicker
Direct Known Subclasses:
AbstractHandTicker, BottleAndBucketTicker, CampfireTicker, FeedAnimalsTicker, FishingReelTicker, RangedGrabTickerClient, RangedGrabTickerServer, ThrowTicker

public abstract class AbstractTicker extends Object
Ticker system to perform something each tick. Only runs for VR players!
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    final void
    doTick(net.minecraft.world.entity.player.Player player, org.vivecraft.api.data.VRPose pose, org.vivecraft.api.data.VRPoseHistory poseHistory)
    Entrypoint for actually running tickers.
    void
    onPlayerDisconnect(net.minecraft.world.entity.player.Player player)
    Cleanup to run on player disconnect.
    protected final void
    setCooldown(net.minecraft.world.entity.player.Player player, int cooldown)
    Set the cooldown for a player for this ticker, thus preventing this ticker from running for them until the cooldown expires.
    protected abstract boolean
    shouldTick(net.minecraft.world.entity.player.Player player, org.vivecraft.api.data.VRPose pose, org.vivecraft.api.data.VRPoseHistory poseHistory)
    Method that checks if the action should be performed (usually).
    protected abstract void
    tick(net.minecraft.world.entity.player.Player player, org.vivecraft.api.data.VRPose pose, org.vivecraft.api.data.VRPoseHistory poseHistory)
    Tick method that performs some action (usually).

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AbstractTicker

      public AbstractTicker()
  • Method Details

    • tick

      protected abstract void tick(net.minecraft.world.entity.player.Player player, org.vivecraft.api.data.VRPose pose, org.vivecraft.api.data.VRPoseHistory poseHistory)
      Tick method that performs some action (usually). Called for each player on each tick when the player is not on cooldown and shouldTick(Player, VRPose, VRPoseHistory) returns true.
      Parameters:
      player - The player running for this ticker.
      pose - The player's pose in VR.
      poseHistory - The player's pose history in VR.
    • shouldTick

      protected abstract boolean shouldTick(net.minecraft.world.entity.player.Player player, org.vivecraft.api.data.VRPose pose, org.vivecraft.api.data.VRPoseHistory poseHistory)
      Method that checks if the action should be performed (usually). Called for each player on each tick when the player is not on cooldown.
      Parameters:
      player - The player running for this ticker.
      pose - The player's pose in VR.
      poseHistory - The player's pose history in VR.
      Returns:
      Whether the tick(Player, VRPose, VRPoseHistory) method should be run for the player.
    • onPlayerDisconnect

      public void onPlayerDisconnect(net.minecraft.world.entity.player.Player player)
      Cleanup to run on player disconnect. Can be overridden to perform additional cleanup, but should always super call to clean up cooldown info.
      Parameters:
      player - The player disconnecting. Note that the player may not be in VR, and Vivecraft may not even be installed!
    • doTick

      public final void doTick(net.minecraft.world.entity.player.Player player, org.vivecraft.api.data.VRPose pose, org.vivecraft.api.data.VRPoseHistory poseHistory)
      Entrypoint for actually running tickers. Should be called on each tick to actually run ticker logic.
      Parameters:
      player - The player running for this ticker.
      pose - The player's pose in VR.
      poseHistory - The player's pose history in VR.
    • setCooldown

      protected final void setCooldown(net.minecraft.world.entity.player.Player player, int cooldown)
      Set the cooldown for a player for this ticker, thus preventing this ticker from running for them until the cooldown expires.
      Parameters:
      player - Player to set a cooldown for.
      cooldown - The cooldown in ticks until this ticker should be able to run again. Note that a cooldown of 0 or below is ignored.