Merge pull request #1326 from WooxSolo/on-after-game-tick

Update game tick event to run after packets have been processed
This commit is contained in:
Adam
2018-04-08 16:50:25 -04:00
committed by GitHub

View File

@@ -95,9 +95,16 @@ public class Hooks
private static Graphics2D stretchedGraphics; private static Graphics2D stretchedGraphics;
private static long lastCheck; private static long lastCheck;
private static boolean shouldProcessGameTick;
public static void clientMainLoop(Client client, boolean arg1) public static void clientMainLoop(Client client, boolean arg1)
{ {
if (shouldProcessGameTick)
{
shouldProcessGameTick = false;
eventBus.post(tick);
}
clientThread.invoke(); clientThread.invoke();
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
@@ -403,7 +410,10 @@ public class Hooks
public static void onNpcUpdate(boolean var0, PacketBuffer var1) public static void onNpcUpdate(boolean var0, PacketBuffer var1)
{ {
eventBus.post(tick); // The NPC update event seem to run every server tick,
// but having the game tick event after all packets
// have been processed is typically more useful.
shouldProcessGameTick = true;
} }
public static void onSetCombatInfo(Actor actor, int combatInfoId, int gameCycle, int var3, int var4, int healthRatio, int health) public static void onSetCombatInfo(Actor actor, int combatInfoId, int gameCycle, int var3, int var4, int healthRatio, int health)