api: add on tick callback

This commit is contained in:
Adam
2021-10-28 18:44:42 -04:00
parent cefb80a37b
commit a96a6a5a40
2 changed files with 14 additions and 5 deletions

View File

@@ -53,9 +53,14 @@ public interface Callbacks
void postDeferred(Object event); void postDeferred(Object event);
/** /**
* Called each client cycle. * Called each tick
*/ */
void clientMainLoop(); void tick();
/**
* Called each frame
*/
void frame();
/** /**
* Called after receiving update NPCs packet from server. * Called after receiving update NPCs packet from server.

View File

@@ -176,7 +176,7 @@ public class Hooks implements Callbacks
} }
@Override @Override
public void clientMainLoop() public void tick()
{ {
if (shouldProcessGameTick) if (shouldProcessGameTick)
{ {
@@ -190,8 +190,6 @@ public class Hooks implements Callbacks
client.setTickCount(tick + 1); client.setTickCount(tick + 1);
} }
eventBus.post(BEFORE_RENDER);
clientThread.invoke(); clientThread.invoke();
long now = System.nanoTime(); long now = System.nanoTime();
@@ -221,6 +219,12 @@ public class Hooks implements Callbacks
} }
} }
@Override
public void frame()
{
eventBus.post(BEFORE_RENDER);
}
/** /**
* When the world map opens it loads about ~100mb of data into memory, which * When the world map opens it loads about ~100mb of data into memory, which
* represents about half of the total memory allocated by the client. * represents about half of the total memory allocated by the client.