diff --git a/src/main/java/com/github/halotroop/litecraft/Litecraft.java b/src/main/java/com/github/halotroop/litecraft/Litecraft.java index e509fc8..317d2db 100644 --- a/src/main/java/com/github/halotroop/litecraft/Litecraft.java +++ b/src/main/java/com/github/halotroop/litecraft/Litecraft.java @@ -39,6 +39,7 @@ public class Litecraft extends Game public int fps, ups, tps, binds; public Vector4i dbgStats; private long frameTimer; + public int threadWaitlist = 0; public Litecraft() { @@ -150,7 +151,7 @@ public class Litecraft extends Game if (ginger3D.gingerRegister.currentScreen == null) this.ginger3D.openScreen(new TitleScreen()); this.ginger3D.update(data); - if (oldWindowHeight != Window.height || oldWindowWidth != Window.width) + if (oldWindowHeight != Window.height || oldWindowWidth != Window.width && Window.height > 10 && Window.width > 10) this.ginger3D.contrastFbo.resizeFBOs(); this.oldWindowWidth = Window.width; this.oldWindowHeight = Window.height; @@ -178,7 +179,7 @@ public class Litecraft extends Game { if (world == null) { - this.save = new LitecraftSave("test", false); + this.save = new LitecraftSave("cegregatedordinaldata", false); this.world = this.save.getWorldOrCreate(Dimensions.OVERWORLD); ginger3D.setGingerPlayer(this.world.player); } diff --git a/src/main/java/com/github/halotroop/litecraft/screens/TitleScreen.java b/src/main/java/com/github/halotroop/litecraft/screens/TitleScreen.java index 1bec389..88f4a24 100644 --- a/src/main/java/com/github/halotroop/litecraft/screens/TitleScreen.java +++ b/src/main/java/com/github/halotroop/litecraft/screens/TitleScreen.java @@ -39,7 +39,7 @@ public class TitleScreen extends Screen public void tick() { Vector4i dbg = Litecraft.getInstance().dbgStats; - buildText.setText("FPS: " + dbg.x() + " UPS: " + dbg.y + " TPS: " + dbg.z + " Binds: " + dbg.w); + buildText.setText("FPS: " + dbg.x() + " UPS: " + dbg.y + " TPS: " + dbg.z + " World Chunk Threads: " + Litecraft.getInstance().threadWaitlist); playButton.update(); if (playButton.isClicked()) { diff --git a/src/main/java/com/github/halotroop/litecraft/world/DynamicChunkLoader.java b/src/main/java/com/github/halotroop/litecraft/world/DynamicChunkLoader.java index 3ac651a..3f42af0 100644 --- a/src/main/java/com/github/halotroop/litecraft/world/DynamicChunkLoader.java +++ b/src/main/java/com/github/halotroop/litecraft/world/DynamicChunkLoader.java @@ -22,6 +22,8 @@ public class DynamicChunkLoader extends GingerThread{ @Override public void run() { + Long2ObjectMap chunks = world.chunks; //this is to seperate the lists so we dont create render bugs + started = true; List toKeep = new ArrayList<>(); // loop over rendered area, adding chunks that are needed @@ -32,7 +34,7 @@ public class DynamicChunkLoader extends GingerThread{ // list of keys to remove LongList toRemove = new LongArrayList(); // check which loaded chunks are not neccesary - this.world.chunks.forEach((pos, chunk) -> + chunks.forEach((pos, chunk) -> { if (!toKeep.contains(chunk)) toRemove.add((long) pos); @@ -49,8 +51,9 @@ public class DynamicChunkLoader extends GingerThread{ boolean alreadyRendering = chunk.doRender(); // if it's already rendering then it's most likely in the map chunk.setRender(true); if (!alreadyRendering) - this.world.chunks.put(this.world.posHash(chunk.chunkX, chunk.chunkY, chunk.chunkZ), chunk); + chunks.put(this.world.posHash(chunk.chunkX, chunk.chunkY, chunk.chunkZ), chunk); }); + this.world.chunks = chunks; this.finished = true; } 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 24f63a7..602c088 100644 --- a/src/main/java/com/github/halotroop/litecraft/world/World.java +++ b/src/main/java/com/github/halotroop/litecraft/world/World.java @@ -19,7 +19,7 @@ import it.unimi.dsi.fastutil.longs.*; public class World implements BlockAccess, WorldGenConstants { - final Long2ObjectMap chunks; + Long2ObjectMap chunks; private final WorldModifier[] worldModifiers; private final ChunkGenerator chunkGenerator; private final BlockAccess genBlockAccess; diff --git a/src/main/java/com/github/hydos/multiThreading/GingerThreading.java b/src/main/java/com/github/hydos/multiThreading/GingerThreading.java index 93459ca..0f804db 100644 --- a/src/main/java/com/github/hydos/multiThreading/GingerThreading.java +++ b/src/main/java/com/github/hydos/multiThreading/GingerThreading.java @@ -2,6 +2,8 @@ package com.github.hydos.multiThreading; import java.util.*; +import com.github.halotroop.litecraft.Litecraft; + public class GingerThreading { public List worldChunkThreadWaitlist; @@ -14,7 +16,7 @@ public class GingerThreading public void update() { if(worldChunkThreadWaitlist.size() != 0) { - System.out.println(worldChunkThreadWaitlist.size()); + Litecraft.getInstance().threadWaitlist = worldChunkThreadWaitlist.size(); GingerThread yes = worldChunkThreadWaitlist.get(0); if(yes.finished) { worldChunkThreadWaitlist.remove(0);