From b82f24b4ad80755f043a21804f71825cf65f7234 Mon Sep 17 00:00:00 2001 From: SuperCoder7979 Date: Sun, 1 Mar 2020 07:47:37 -0500 Subject: [PATCH] fix really bad bug and add memory counter --- .../com/github/halotroop/litecraft/screens/IngameHUD.java | 8 ++++++-- .../java/com/github/halotroop/litecraft/world/World.java | 2 +- .../halotroop/litecraft/world/dimension/Dimensions.java | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/github/halotroop/litecraft/screens/IngameHUD.java b/src/main/java/com/github/halotroop/litecraft/screens/IngameHUD.java index ddaad3b..2ebd503 100644 --- a/src/main/java/com/github/halotroop/litecraft/screens/IngameHUD.java +++ b/src/main/java/com/github/halotroop/litecraft/screens/IngameHUD.java @@ -31,10 +31,14 @@ public class IngameHUD extends Screen @Override public void tick() { +// long maxMemory = Runtime.getRuntime().maxMemory(); + long totalMemory = Runtime.getRuntime().totalMemory(); + long freeMemory = Runtime.getRuntime().freeMemory(); + long usedMemory = totalMemory - freeMemory; Vector4i dbg = litecraft.dbgStats; Vector3f position = GingerRegister.getInstance().game.data.player.getPosition(); - debugText.setText("FPS: " + dbg.x() + " UPS: " + dbg.y + " TPS: " + dbg.z); - positionText.setText("Position " + (int) position.x() + ", " + (int) position.y() + ", "+ (int) position.z()); + debugText.setText("FPS: " + dbg.x() + " UPS: " + dbg.y + " TPS: " + dbg.z + " Mem: " + (usedMemory / 1024 / 1024) + "MB / " + (totalMemory / 1024 / 1024) + " MB"); + positionText.setText("Position " + (int) position.x() + ", " + (int) position.y() + ", "+ (int) position.z() ); } @Override diff --git a/src/main/java/com/github/halotroop/litecraft/world/World.java b/src/main/java/com/github/halotroop/litecraft/world/World.java index 5f1d699..a09783d 100644 --- a/src/main/java/com/github/halotroop/litecraft/world/World.java +++ b/src/main/java/com/github/halotroop/litecraft/world/World.java @@ -197,7 +197,7 @@ public class World implements BlockAccess, WorldGenConstants this.save.saveChunk(chunk); // save chunk }); chunkPositions.forEach((LongConsumer) (pos -> this.chunks.remove(pos))); // remove all chunks - }); + }).join(); } public long getSeed() diff --git a/src/main/java/com/github/halotroop/litecraft/world/dimension/Dimensions.java b/src/main/java/com/github/halotroop/litecraft/world/dimension/Dimensions.java index 4ce8887..87c9939 100644 --- a/src/main/java/com/github/halotroop/litecraft/world/dimension/Dimensions.java +++ b/src/main/java/com/github/halotroop/litecraft/world/dimension/Dimensions.java @@ -1,6 +1,7 @@ package com.github.halotroop.litecraft.world.dimension; import com.github.halotroop.litecraft.world.gen.*; +import com.github.halotroop.litecraft.world.gen.modifier.CavesModifier; public final class Dimensions {