Server Tick Handler
To create a server tick handler, first create the class:
public class ServerTickHandler implements ITickHandler
{
private void onPlayerTick(EntityPlayer player)
{
}
@Override
public void tickStart(EnumSet<TickType> type, Object... tickData)
{
if (type.equals(EnumSet.of(TickType.PLAYER)))
{
onPlayerTick((EntityPlayer)tickData[0]);
}
}
@Override
public EnumSet<TickType> ticks()
{
return EnumSet.of(TickType.PLAYER, TickType.SERVER);
}
@Override
public void tickEnd(EnumSet<TickType> type, Object... tickData)
{
}
@Override
public String getLabel()
{
return null;
}
}
Then, declare it in your common proxy:
public void registerServerTickHandler()
{
TickRegistry.registerTickHandler(new ServerTickHandler(), Side.SERVER);
}
Also, in your main file, add this in your init section:
proxy.registerServerTickHandler();
And that's all really. With this you can use the tutorials in this tab.
public class ServerTickHandler implements ITickHandler
{
private void onPlayerTick(EntityPlayer player)
{
}
@Override
public void tickStart(EnumSet<TickType> type, Object... tickData)
{
if (type.equals(EnumSet.of(TickType.PLAYER)))
{
onPlayerTick((EntityPlayer)tickData[0]);
}
}
@Override
public EnumSet<TickType> ticks()
{
return EnumSet.of(TickType.PLAYER, TickType.SERVER);
}
@Override
public void tickEnd(EnumSet<TickType> type, Object... tickData)
{
}
@Override
public String getLabel()
{
return null;
}
}
Then, declare it in your common proxy:
public void registerServerTickHandler()
{
TickRegistry.registerTickHandler(new ServerTickHandler(), Side.SERVER);
}
Also, in your main file, add this in your init section:
proxy.registerServerTickHandler();
And that's all really. With this you can use the tutorials in this tab.