Interface TickRateAPI


public interface TickRateAPI
API v3 for TickRate v0.5.0

This class represents the sole entrypoint for TickRate's API. This API should only be used on the logical server.

See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    freezeChunk(net.minecraft.world.World world, Collection<net.minecraft.util.math.ChunkPos> chunks, boolean freeze)
    Freezes or unfreezes the specified chunks depending on freeze.
    void
    freezeChunk(net.minecraft.world.World world, net.minecraft.util.math.ChunkPos chunk, boolean freeze)
    Freezes or unfreezes the specified chunk depending on freeze.
    void
    freezeEntity(Collection<? extends net.minecraft.entity.Entity> entities, boolean freeze)
    Freezes or unfreezes the specified entities depending on freeze.
    void
    freezeEntity(net.minecraft.entity.Entity entity, boolean freeze)
    Freezes or unfreezes the specified entity depending on freeze.
    void
    freezeServer(boolean freeze)
    Freezes or unfreezes the server depending on freeze.
    Obtain the API instance.
    float
    queryChunk(net.minecraft.world.World world, net.minecraft.util.math.ChunkPos chunk)
    Returns the tick rate of the chunk.
    float
    queryEntity(net.minecraft.entity.Entity entity)
    Returns the tick rate of the entity.
    float
    Returns the server's tick rate.
    void
    rateChunk(net.minecraft.world.World world, Collection<net.minecraft.util.math.ChunkPos> chunks, float rate)
    Sets the tick rate of the specified chunks.
    void
    rateChunk(net.minecraft.world.World world, net.minecraft.util.math.ChunkPos chunk, float rate)
    Sets the tick rate of the specified chunk.
    void
    rateEntity(Collection<? extends net.minecraft.entity.Entity> entities, float rate)
    Sets the tick rate of the specified entities.
    void
    rateEntity(net.minecraft.entity.Entity entity, float rate)
    Sets the tick rate of the specified entity.
    void
    rateServer(float rate)
    Set the tick rate of the server.
    void
    sprintChunk(net.minecraft.world.World world, Collection<net.minecraft.util.math.ChunkPos> chunks, int sprintTicks)
    Sprints the specified chunks for sprintTicks ticks.
    void
    sprintChunk(net.minecraft.world.World world, net.minecraft.util.math.ChunkPos chunk, int sprintTicks)
    Sprints the specified chunk for sprintTicks ticks.
    void
    sprintEntity(Collection<? extends net.minecraft.entity.Entity> entities, int sprintTicks)
    Sprints the specified entities for sprintTicks ticks.
    void
    sprintEntity(net.minecraft.entity.Entity entity, int sprintTicks)
    Sprints the specified entity for sprintTicks ticks.
    void
    sprintServer(int sprintTicks)
    Sprints the server.
    void
    stepChunk(net.minecraft.world.World world, Collection<net.minecraft.util.math.ChunkPos> chunks, int stepTicks)
    Steps the specified chunks for stepTicks ticks.
    void
    stepChunk(net.minecraft.world.World world, net.minecraft.util.math.ChunkPos chunk, int stepTicks)
    Steps the specified chunk for stepTicks ticks.
    void
    stepEntity(Collection<? extends net.minecraft.entity.Entity> entities, int stepTicks)
    Steps the specified entities for stepTicks ticks.
    void
    stepEntity(net.minecraft.entity.Entity entity, int stepTicks)
    Steps the specified entity for stepTicks ticks.
    void
    stepServer(int stepTicks)
    Steps the server.
  • Method Details

    • getInstance

      static TickRateAPI getInstance()
      Obtain the API instance. This method should only be called after the server has been fully initialised (e.g. when the SERVER_STARTED event is fired).

      In singleplayer, a new API instance is used each time a new save is loaded.

      Throws:
      IllegalStateException - if the server has not been fully intialised yet.
    • queryServer

      float queryServer()
      Returns the server's tick rate.
    • rateServer

      void rateServer(float rate)
      Set the tick rate of the server. rate is rounded using Math.round(float)
      Throws:
      IllegalArgumentException - if rate is less than 1.
    • freezeServer

      void freezeServer(boolean freeze)
      Freezes or unfreezes the server depending on freeze.
      Parameters:
      freeze - true to freeze, false to unfreeze.
    • stepServer

      void stepServer(int stepTicks)
      Steps the server. The server will step according to its current TPS.

      If stepTicks is 0, the server will stop stepping.

      Throws:
      IllegalArgumentException - if stepTicks is less than 0.
      IllegalStateException - if the server is not frozen.
    • sprintServer

      void sprintServer(int sprintTicks)
      Sprints the server.

      If sprintTicks is 0, the server will stop sprinting.

      Throws:
      IllegalArgumentException - if sprintTicks is less than 0.
    • queryEntity

      float queryEntity(net.minecraft.entity.Entity entity)
      Returns the tick rate of the entity.

      If the entity has no specific tick rate, the tick rate of the chunk it is in will be returned. If the chunk it is in also has no specific tick rate, the server's tick rate will be returned.

      If the entity is a passenger, the tick rate of its root vehicle will be returned. If the server is stepping, the server's tick rate is returned.

      Throws:
      IllegalArgumentException - if Entity.isRemoved() is true.
    • rateEntity

      void rateEntity(Collection<? extends net.minecraft.entity.Entity> entities, float rate)
      Sets the tick rate of the specified entities. rate is rounded using Math.round(float)

      If rate is exactly 0.0f, then the entities' tick rate will be reset.

      Throws:
      IllegalArgumentException - if Entity.isRemoved() is true for any of the specified entities OR if rate is less than 1 and not 0.
    • rateEntity

      void rateEntity(net.minecraft.entity.Entity entity, float rate)
      Sets the tick rate of the specified entity. rate is rounded using Math.round(float)

      If rate is exactly 0.0f, then the entity's tick rate will be reset.

      Throws:
      IllegalArgumentException - if Entity.isRemoved() is true OR if rate is less than 1 and not 0.
    • freezeEntity

      void freezeEntity(Collection<? extends net.minecraft.entity.Entity> entities, boolean freeze)
      Freezes or unfreezes the specified entities depending on freeze.
      Parameters:
      freeze - true to freeze, false to unfreeze
      Throws:
      IllegalArgumentException - if Entity.isRemoved() is true for any of the specified entities.
    • freezeEntity

      void freezeEntity(net.minecraft.entity.Entity entity, boolean freeze)
      Freezes or unfreezes the specified entity depending on freeze.
      Parameters:
      freeze - true to freeze, false to unfreeze
      Throws:
      IllegalArgumentException - if Entity.isRemoved() is true the specified entity.
    • stepEntity

      void stepEntity(Collection<? extends net.minecraft.entity.Entity> entities, int stepTicks)
      Steps the specified entities for stepTicks ticks. The entities will step according to their current TPS.

      If stepTicks is 0, the entities will stop stepping.

      Throws:
      IllegalArgumentException - if any of the following conditions are met:

      • Entity.isRemoved() is true for any of the specified entities.
      • Any of the specified entities are currently NOT frozen or ARE sprinting.
      • stepTicks is less than 0.
    • stepEntity

      void stepEntity(net.minecraft.entity.Entity entity, int stepTicks)
      Steps the specified entity for stepTicks ticks. The entity will step according to its current TPS.

      If stepTicks is 0, the entitiy will stop stepping.

      Throws:
      IllegalArgumentException - if any of the following conditions are met:

      • Entity.isRemoved() is true.
      • The specified entity is currently NOT frozen or IS sprinting.
      • stepTicks is less than 0.
    • sprintEntity

      void sprintEntity(Collection<? extends net.minecraft.entity.Entity> entities, int sprintTicks)
      Sprints the specified entities for sprintTicks ticks.

      If sprintTicks is 0, the entities will stop sprinting.

      Throws:
      IllegalArgumentException - if any of the following conditions are met:

      • Entity.isRemoved() is true for any of the specified entities.
      • Any of the specified entities are currently stepping.
      • sprintTicks is less than 0.
    • sprintEntity

      void sprintEntity(net.minecraft.entity.Entity entity, int sprintTicks)
      Sprints the specified entity for sprintTicks ticks.

      If sprintTicks is 0, the entity will stop sprinting.

      Throws:
      IllegalArgumentException - if any of the following conditions are met:

      • Entity.isRemoved() is true.
      • The specified entity is currently stepping.
      • sprintTicks is less than 0.
    • queryChunk

      float queryChunk(net.minecraft.world.World world, net.minecraft.util.math.ChunkPos chunk)
      Returns the tick rate of the chunk.

      If the chunk has no specific tick rate, the server's tick rate will be returned.

      If the server is stepping, the server's tick rate is returned.

      Throws:
      IllegalArgumentException - if the chunk is INACCESSIBLE (not loaded).
    • rateChunk

      void rateChunk(net.minecraft.world.World world, Collection<net.minecraft.util.math.ChunkPos> chunks, float rate)
      Sets the tick rate of the specified chunks. rate is rounded using Math.round(float)

      If rate is exactly 0.0f, then the chunks' tick rate will be reset.

      Throws:
      IllegalArgumentException - if any of the chunks are INACCESSIBLE (not loaded) OR if rate is less than 1 and not 0.
    • rateChunk

      void rateChunk(net.minecraft.world.World world, net.minecraft.util.math.ChunkPos chunk, float rate)
      Sets the tick rate of the specified chunk. rate is rounded using Math.round(float)

      If rate is exactly 0.0f, then the chunk's tick rate will be reset.

      Throws:
      IllegalArgumentException - if the chunk is INACCESSIBLE (not loaded) OR if rate is less than 1 and not 0.
    • freezeChunk

      void freezeChunk(net.minecraft.world.World world, Collection<net.minecraft.util.math.ChunkPos> chunks, boolean freeze)
      Freezes or unfreezes the specified chunks depending on freeze.
      Parameters:
      freeze - true to freeze, false to unfreeze
      Throws:
      IllegalArgumentException - if any of the chunks are INACCESSIBLE (not loaded).
    • freezeChunk

      void freezeChunk(net.minecraft.world.World world, net.minecraft.util.math.ChunkPos chunk, boolean freeze)
      Freezes or unfreezes the specified chunk depending on freeze.
      Parameters:
      freeze - true to freeze, false to unfreeze
      Throws:
      IllegalArgumentException - if the chunk is INACCESSIBLE (not loaded).
    • stepChunk

      void stepChunk(net.minecraft.world.World world, Collection<net.minecraft.util.math.ChunkPos> chunks, int stepTicks)
      Steps the specified chunks for stepTicks ticks. The chunks will step according to their current TPS.

      If stepTicks is 0, the chunks will stop stepping.

      Throws:
      IllegalArgumentException - if any of the following conditions are met:

      • Any of the chunks are INACCESSIBLE (not loaded).
      • Any of the specified chunks are currently NOT frozen or ARE sprinting.
      • stepTicks is less than 0.
    • stepChunk

      void stepChunk(net.minecraft.world.World world, net.minecraft.util.math.ChunkPos chunk, int stepTicks)
      Steps the specified chunk for stepTicks ticks. The chunk will step according to its current TPS.

      If stepTicks is 0, the chunk will stop stepping.

      Throws:
      IllegalArgumentException - if any of the following conditions are met:

      • The chunk is INACCESSIBLE (not loaded).
      • The specified chunk is currently NOT frozen or IS sprinting.
      • stepTicks is less than 0.
    • sprintChunk

      void sprintChunk(net.minecraft.world.World world, Collection<net.minecraft.util.math.ChunkPos> chunks, int sprintTicks)
      Sprints the specified chunks for sprintTicks ticks.

      If sprintTicks is 0, the chunks will stop sprinting.

      Throws:
      IllegalArgumentException - if any of the following conditions are met:

      • Any of the chunks are INACCESSIBLE (not loaded).
      • Any of the specified chunks are currently stepping.
      • sprintTicks is less than 0.
    • sprintChunk

      void sprintChunk(net.minecraft.world.World world, net.minecraft.util.math.ChunkPos chunk, int sprintTicks)
      Sprints the specified chunk for sprintTicks ticks.

      If sprintTicks is 0, the chunk will stop sprinting.

      Throws:
      IllegalArgumentException - if any of the following conditions are met:

      • The chunk is INACCESSIBLE (not loaded).
      • The specified chunk is currently stepping.
      • sprintTicks is less than 0.