Skip to content

Commit

Permalink
Replace currentTimeMillis() calls with nanoTime() in all delays
Browse files Browse the repository at this point in the history
  • Loading branch information
maruohon committed Apr 10, 2023
1 parent ff2beb1 commit 273c5d0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/main/java/minihud/event/RenderHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,10 @@ public void onPostGameOverlayRender(RenderContext ctx)
this.updateFps();
}

long currentTime = System.currentTimeMillis();
long currentTime = System.nanoTime();

// Only update the text once per game tick
if (currentTime - this.infoUpdateTime >= 50)
if (currentTime - this.infoUpdateTime >= 50000000L)
{
this.updateLines();
this.infoUpdateTime = currentTime;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/minihud/renderer/OverlayRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class OverlayRenderer
public static void resetRenderTimeout()
{
canRender = false;
loginTime = System.currentTimeMillis();
loginTime = System.nanoTime();
}

public static void renderOverlays(RenderContext ctx, float tickDelta)
Expand All @@ -53,7 +53,7 @@ public static void renderOverlays(RenderContext ctx, float tickDelta)
// Don't render before the player has been placed in the actual proper position,
// otherwise some of the renderers mess up.
// The magic 8.5, 65, 8.5 comes from the WorldClient constructor
if (System.currentTimeMillis() - loginTime >= 5000 ||
if (System.nanoTime() - loginTime >= 5000000000L ||
x != 8.5 ||
y != 65 ||
z != 8.5)
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/minihud/renderer/shapes/ShapeCircleBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public abstract class ShapeCircleBase extends ShapeBase
protected Vec3d center = Vec3d.ZERO;
protected Vec3d effectiveCenter = Vec3d.ZERO;
protected Vec3d lastUpdatePos = Vec3d.ZERO;
protected long lastUpdateTime;

public ShapeCircleBase(ShapeType type, Color4f color, double radius)
{
Expand Down Expand Up @@ -138,7 +137,6 @@ protected void onPostUpdate(Vec3d updatePosition)
{
this.needsUpdate = false;
this.lastUpdatePos = updatePosition;
this.lastUpdateTime = System.currentTimeMillis();
}

@Override
Expand Down

0 comments on commit 273c5d0

Please sign in to comment.