Interface TickRateAPI
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 TypeMethodDescriptionvoidfreezeChunk(net.minecraft.world.World world, Collection<net.minecraft.util.math.ChunkPos> chunks, boolean freeze) Freezes or unfreezes the specified chunks depending onfreeze.voidfreezeChunk(net.minecraft.world.World world, net.minecraft.util.math.ChunkPos chunk, boolean freeze) Freezes or unfreezes the specified chunk depending onfreeze.voidfreezeEntity(Collection<? extends net.minecraft.entity.Entity> entities, boolean freeze) Freezes or unfreezes the specified entities depending onfreeze.voidfreezeEntity(net.minecraft.entity.Entity entity, boolean freeze) Freezes or unfreezes the specified entity depending onfreeze.voidfreezeServer(boolean freeze) Freezes or unfreezes the server depending onfreeze.static TickRateAPIObtain the API instance.floatqueryChunk(net.minecraft.world.World world, net.minecraft.util.math.ChunkPos chunk) Returns the tick rate of the chunk.floatqueryEntity(net.minecraft.entity.Entity entity) Returns the tick rate of the entity.floatReturns the server's tick rate.voidrateChunk(net.minecraft.world.World world, Collection<net.minecraft.util.math.ChunkPos> chunks, float rate) Sets the tick rate of the specified chunks.voidrateChunk(net.minecraft.world.World world, net.minecraft.util.math.ChunkPos chunk, float rate) Sets the tick rate of the specified chunk.voidrateEntity(Collection<? extends net.minecraft.entity.Entity> entities, float rate) Sets the tick rate of the specified entities.voidrateEntity(net.minecraft.entity.Entity entity, float rate) Sets the tick rate of the specified entity.voidrateServer(float rate) Set the tick rate of the server.voidsprintChunk(net.minecraft.world.World world, Collection<net.minecraft.util.math.ChunkPos> chunks, int sprintTicks) Sprints the specified chunks forsprintTicksticks.voidsprintChunk(net.minecraft.world.World world, net.minecraft.util.math.ChunkPos chunk, int sprintTicks) Sprints the specified chunk forsprintTicksticks.voidsprintEntity(Collection<? extends net.minecraft.entity.Entity> entities, int sprintTicks) Sprints the specified entities forsprintTicksticks.voidsprintEntity(net.minecraft.entity.Entity entity, int sprintTicks) Sprints the specified entity forsprintTicksticks.voidsprintServer(int sprintTicks) Sprints the server.voidstepChunk(net.minecraft.world.World world, Collection<net.minecraft.util.math.ChunkPos> chunks, int stepTicks) Steps the specified chunks forstepTicksticks.voidstepChunk(net.minecraft.world.World world, net.minecraft.util.math.ChunkPos chunk, int stepTicks) Steps the specified chunk forstepTicksticks.voidstepEntity(Collection<? extends net.minecraft.entity.Entity> entities, int stepTicks) Steps the specified entities forstepTicksticks.voidstepEntity(net.minecraft.entity.Entity entity, int stepTicks) Steps the specified entity forstepTicksticks.voidstepServer(int stepTicks) Steps the server.
-
Method Details
-
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.rateis rounded usingMath.round(float)- Throws:
IllegalArgumentException- ifrateis less than 1.
-
freezeServer
void freezeServer(boolean freeze) Freezes or unfreezes the server depending onfreeze.- Parameters:
freeze-trueto freeze,falseto unfreeze.
-
stepServer
void stepServer(int stepTicks) Steps the server. The server will step according to its current TPS.If
stepTicksis 0, the server will stop stepping.- Throws:
IllegalArgumentException- ifstepTicksis less than 0.IllegalStateException- if the server is not frozen.
-
sprintServer
void sprintServer(int sprintTicks) Sprints the server.If
sprintTicksis 0, the server will stop sprinting.- Throws:
IllegalArgumentException- ifsprintTicksis 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 vehiclewill be returned. If the server is stepping, the server's tick rate is returned.- Throws:
IllegalArgumentException- ifEntity.isRemoved()is true.
-
rateEntity
Sets the tick rate of the specified entities.rateis rounded usingMath.round(float)If
rateis exactly0.0f, then the entities' tick rate will be reset.- Throws:
IllegalArgumentException- ifEntity.isRemoved()is true for any of the specified entities OR ifrateis less than 1 and not 0.
-
rateEntity
void rateEntity(net.minecraft.entity.Entity entity, float rate) Sets the tick rate of the specified entity.rateis rounded usingMath.round(float)If
rateis exactly0.0f, then the entity's tick rate will be reset.- Throws:
IllegalArgumentException- ifEntity.isRemoved()is true OR ifrateis less than 1 and not 0.
-
freezeEntity
Freezes or unfreezes the specified entities depending onfreeze.- Parameters:
freeze-trueto freeze,falseto unfreeze- Throws:
IllegalArgumentException- ifEntity.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 onfreeze.- Parameters:
freeze-trueto freeze,falseto unfreeze- Throws:
IllegalArgumentException- ifEntity.isRemoved()is true the specified entity.
-
stepEntity
Steps the specified entities forstepTicksticks. The entities will step according to their current TPS.If
stepTicksis 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.
-
stepTicksis less than 0.
-
-
stepEntity
void stepEntity(net.minecraft.entity.Entity entity, int stepTicks) Steps the specified entity forstepTicksticks. The entity will step according to its current TPS.If
stepTicksis 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.
-
stepTicksis less than 0.
-
-
sprintEntity
Sprints the specified entities forsprintTicksticks.If
sprintTicksis 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.
-
sprintTicksis less than 0.
-
-
sprintEntity
void sprintEntity(net.minecraft.entity.Entity entity, int sprintTicks) Sprints the specified entity forsprintTicksticks.If
sprintTicksis 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.
-
sprintTicksis 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 isINACCESSIBLE(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.rateis rounded usingMath.round(float)If
rateis exactly0.0f, then the chunks' tick rate will be reset.- Throws:
IllegalArgumentException- if any of the chunks areINACCESSIBLE(not loaded) OR ifrateis 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.rateis rounded usingMath.round(float)If
rateis exactly0.0f, then the chunk's tick rate will be reset.- Throws:
IllegalArgumentException- if the chunk isINACCESSIBLE(not loaded) OR ifrateis 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 onfreeze.- Parameters:
freeze-trueto freeze,falseto unfreeze- Throws:
IllegalArgumentException- if any of the chunks areINACCESSIBLE(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 onfreeze.- Parameters:
freeze-trueto freeze,falseto unfreeze- Throws:
IllegalArgumentException- if the chunk isINACCESSIBLE(not loaded).
-
stepChunk
void stepChunk(net.minecraft.world.World world, Collection<net.minecraft.util.math.ChunkPos> chunks, int stepTicks) Steps the specified chunks forstepTicksticks. The chunks will step according to their current TPS.If
stepTicksis 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.
-
stepTicksis less than 0.
- Any of the chunks are
-
stepChunk
void stepChunk(net.minecraft.world.World world, net.minecraft.util.math.ChunkPos chunk, int stepTicks) Steps the specified chunk forstepTicksticks. The chunk will step according to its current TPS.If
stepTicksis 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.
-
stepTicksis less than 0.
- The chunk is
-
sprintChunk
void sprintChunk(net.minecraft.world.World world, Collection<net.minecraft.util.math.ChunkPos> chunks, int sprintTicks) Sprints the specified chunks forsprintTicksticks.If
sprintTicksis 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.
-
sprintTicksis less than 0.
- Any of the chunks are
-
sprintChunk
void sprintChunk(net.minecraft.world.World world, net.minecraft.util.math.ChunkPos chunk, int sprintTicks) Sprints the specified chunk forsprintTicksticks.If
sprintTicksis 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.
-
sprintTicksis less than 0.
- The chunk is
-