Skip to content
Guichaguri edited this page Jan 12, 2017 · 6 revisions

Basic Setup

Add the TickrateChanger Dev jar to your libraries (and libs folder) to start using the API.

If you want Tickrate Changer to be an optional feature, you just need to check if Tickrate Changer is installed before executing any method from Tickrate Changer.

Loader.isModLoaded("tickratechanger")

Now you just need to import me.guichaguri.tickratechanger.api.TickrateAPI whenever you want to use the API.

Intermod Communitations (IMC)

IMC is a replacement for the API. It's a bit harder to use, but you don't need to add TickrateChanger as a dependency

// Simple message, only let you set the server and client tickrate
FMLInterModComms.sendMessage("tickratechanger", "tickrate", Float.toString(16.5F));

// Complete message, let you set a bunch of values
NBTTagCompound nbt = new NBTTagCompound();
nbt.setFloat("tickrate", 16.5F); // When not specified, sets to the default tickrate
nbt.setString("type", "client"); // When not specified, defaults to "all". See types below
nbt.setString("player", "Notch"); // (Player name) Only available in "client" type. When specified, changes only a player tickrate instead of all clients
nbt.setBoolean("save", false); // Only available in "default" type. When true, saves the default tickrate in the config file
FMLInterModComms.sendMessage("tickratechanger", "tickrate", nbt);

Types

client From the client-side, changes only the client tickrate. From the server-side, changes all clients tickrate.

server From the client-side, does nothing. From the server-side, changes the server tickrate.

map From the client-side, does nothing. From the server-side, sets the world tickrate but doesn't update it.

default From the client-side, does nothing. From the server-side, sets the default tickrate but doesn't update it.

all From the client-side, changes only the client tickrate. From the server-side, changes the server and all clients tickrate.

Tickrate Changer API Methods

TickrateAPI.changeTickrate(float ticksPerSecond)

Let you change the client & server tickrate

Can only be called from server-side. Can also be called from client-side if is singleplayer.


TickrateAPI.changeServerTickrate(float ticksPerSecond)

Let you change the server tickrate

Can only be called from server-side. Can also be called from client-side if is singleplayer.


TickrateAPI.changeClientTickrate(float ticksPerSecond)

Let you change the client tickrate (if is multiplayer in client-side) or all connected clients tickrate (if is server-side or singleplayer client-side)

Can be called either from server-side or client-side


TickrateAPI.changeClientTickrate(EntityPlayer player, float ticksPerSecond)

Let you change a player tickrate. Will only take effect in the client-side if the player is Minecraft.thePlayer.

Can be called either from server-side or client-side.


TickrateAPI.changeDefaultTickrate(float ticksPerSecond, boolean save)

Let you change the default tickrate. This will not update the tickrate from the server/clients.

Can only be called from server-side. Can also be called from client-side if is singleplayer.


TickrateAPI.changeMapTickrate(float ticksPerSecond)

Let you change the map tickrate. This will not update the tickrate from the server/clients

Can only be called from server-side. Can also be called from client-side if is singleplayer.


TickrateAPI.isValidTickrate(float ticksPerSecond)

Let you check if the tickrate is valid.

This is not checked by the other methods.

Examples

@SubscribeEvent
public void hardcoreMode(PlayerEvent.ItemCraftedEvent event) {
    // Check if the item is null, if it is, stop.
    if(event.crafting == null) return;
    // Check if the item is a ItemBlock
    if(event.crafting.getItem() instanceof ItemBlock) {
        // Cast to ItemBlock
        ItemBlock ib = (ItemBlock)event.crafting.getItem();
        // Check if the item is a beacon block
        if(ib.getBlock() == Blocks.beacon) {
            // Change the map tickrate to 26.5
            TickrateAPI.changeMapTickrate(26.5F);
        }
    }
}

Speed up the game after crafting a Beacon Block


@Subscribe
public void postInit(FMLPostInitializationEvent event) {
    // Check if we have Tickrate Changer installed
    if(Loader.isModLoaded("tickratechanger")) {
        // Change the default tickrate to 18 without saving
        TickrateAPI.changeDefaultTickrate(18, false);
    }
}

Changes the default tickrate to 15 when starting the game. Optional feature by using Tickrate Changer

Questions?

Just message me in Curse Forge or Minecraft Forums.