From 4b918be7430d68687c1a21de4b6ac67167982ca7 Mon Sep 17 00:00:00 2001 From: valoeghese Date: Sun, 1 Mar 2020 16:58:45 +1300 Subject: [PATCH 01/14] start 16x16. Faster. Caves are broken --- .../java/com/github/halotroop/litecraft/save/LitecraftSave.java | 2 +- .../github/halotroop/litecraft/world/gen/WorldGenConstants.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/github/halotroop/litecraft/save/LitecraftSave.java b/src/main/java/com/github/halotroop/litecraft/save/LitecraftSave.java index cbf2596..902575d 100644 --- a/src/main/java/com/github/halotroop/litecraft/save/LitecraftSave.java +++ b/src/main/java/com/github/halotroop/litecraft/save/LitecraftSave.java @@ -159,5 +159,5 @@ public final class LitecraftSave } private static final String SAVE_DIR = "./saves/"; - private static final int RENDER_SIZE = 10; + private static final int RENDER_SIZE = 5; } diff --git a/src/main/java/com/github/halotroop/litecraft/world/gen/WorldGenConstants.java b/src/main/java/com/github/halotroop/litecraft/world/gen/WorldGenConstants.java index 9acd457..9beaf0c 100644 --- a/src/main/java/com/github/halotroop/litecraft/world/gen/WorldGenConstants.java +++ b/src/main/java/com/github/halotroop/litecraft/world/gen/WorldGenConstants.java @@ -2,7 +2,7 @@ package com.github.halotroop.litecraft.world.gen; public interface WorldGenConstants { - int POS_SHIFT = 3; + int POS_SHIFT = 4; int DOUBLE_SHIFT = POS_SHIFT * 2; int CHUNK_SIZE = (int) Math.pow(2, POS_SHIFT); int MAX_POS = CHUNK_SIZE - 1; From 309626c5d083c219bc4b46c19ae229e6f0def28b Mon Sep 17 00:00:00 2001 From: valoeghese Date: Sun, 1 Mar 2020 17:02:33 +1300 Subject: [PATCH 02/14] comment out code, gen still broken. who hardcoded irritater --- .../github/halotroop/litecraft/world/dimension/Dimensions.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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..01fd1e9 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 @@ -4,5 +4,5 @@ import com.github.halotroop.litecraft.world.gen.*; public final class Dimensions { - public static final Dimension OVERWORLD = new EarthDimension(0, "earth").addWorldModifier(new CavesModifier()); + public static final Dimension OVERWORLD = new EarthDimension(0, "earth");//.addWorldModifier(new CavesModifier()); } From 8d5a3efbdfcf956dd3f606454f42e79581631e8d Mon Sep 17 00:00:00 2001 From: SuperCoder7979 Date: Sun, 1 Mar 2020 07:32:50 -0500 Subject: [PATCH 03/14] multithreading good --- .../halotroop/litecraft/world/World.java | 81 +++++++++---------- .../litecraft/world/gen/CavesModifier.java | 2 +- 2 files changed, 41 insertions(+), 42 deletions(-) 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 d5312c1..5f1d699 100644 --- a/src/main/java/com/github/halotroop/litecraft/world/World.java +++ b/src/main/java/com/github/halotroop/litecraft/world/World.java @@ -136,7 +136,8 @@ public class World implements BlockAccess, WorldGenConstants if (chunk == null) return false; // Otherwise save the chunk AtomicBoolean result = new AtomicBoolean(false); - CompletableFuture.runAsync(() -> { + CompletableFuture.runAsync(() -> + { result.set(this.save.saveChunk(chunk)); this.chunks.remove(posHash); }); @@ -187,13 +188,16 @@ public class World implements BlockAccess, WorldGenConstants public void unloadAllChunks() { LongList chunkPositions = new LongArrayList(); - if (this.chunks != null) - this.chunks.forEach((pos, chunk) -> - { // for every chunk in memory - chunkPositions.add((long) pos); // add pos to chunk positions list for removal later - this.save.saveChunk(chunk); // save chunk - }); - chunkPositions.forEach((LongConsumer) (pos -> this.chunks.remove(pos))); // remove all chunks + CompletableFuture.runAsync(() -> + { + if (this.chunks != null) + this.chunks.forEach((pos, chunk) -> + { // for every chunk in memory + chunkPositions.add((long) pos); // add pos to chunk positions list for removal later + this.save.saveChunk(chunk); // save chunk + }); + chunkPositions.forEach((LongConsumer) (pos -> this.chunks.remove(pos))); // remove all chunks + }); } public long getSeed() @@ -203,43 +207,38 @@ public class World implements BlockAccess, WorldGenConstants public void updateLoadedChunks(int chunkX, int chunkY, int chunkZ) { - //AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA - //Ginger.getInstance().threading.registerChunkThreadToWaitlist(new DynamicChunkLoader(chunkX, chunkY, chunkZ, this)); - - Long2ObjectMap chunksList = this.chunks; - - //FIXME completable futures - - List toKeep = new ArrayList<>(); - // loop over rendered area, adding chunks that are needed - for (int x = chunkX - this.renderBound; x < chunkX + this.renderBound; x++) - for (int z = chunkZ - this.renderBound; z < chunkZ + this.renderBound; z++) - for (int y = chunkY - this.renderBound; y < chunkY + this.renderBound; y++) - toKeep.add(this.getChunkToLoad(x, y, z)); - - LongList toRemove = new LongArrayList(); - // check which loaded chunks are not neccesary - chunksList.forEach((pos, chunk) -> + CompletableFuture.runAsync(() -> { - if (!toKeep.contains(chunk)) - toRemove.add((long) pos); - }); - // unload unneccesary chunks from chunk array - toRemove.forEach((LongConsumer) this::unloadChunk); + List toKeep = new ArrayList<>(); + // loop over rendered area, adding chunks that are needed + for (int x = chunkX - this.renderBound; x < chunkX + this.renderBound; x++) + for (int z = chunkZ - this.renderBound; z < chunkZ + this.renderBound; z++) + for (int y = chunkY - this.renderBound; y < chunkY + this.renderBound; y++) + toKeep.add(this.getChunkToLoad(x, y, z)); - toKeep.forEach(chunk -> { - if (!chunk.isFullyGenerated()) + LongList toRemove = new LongArrayList(); + // check which loaded chunks are not neccesary + chunks.forEach((pos, chunk) -> { - this.populateChunk(chunk); - chunk.setFullyGenerated(true); - } - boolean alreadyRendering = chunk.doRender(); // if it's already rendering then it's most likely in the map - chunk.setRender(true); - if (!alreadyRendering) - chunksList.put(this.posHash(chunk.chunkX, chunk.chunkY, chunk.chunkZ), chunk); - }); - this.chunks = chunksList; + if (!toKeep.contains(chunk)) + toRemove.add((long) pos); + }); + // unload unneccesary chunks from chunk array + toRemove.forEach((LongConsumer) this::unloadChunk); + toKeep.forEach(chunk -> + { + if (!chunk.isFullyGenerated()) + { + this.populateChunk(chunk); + chunk.setFullyGenerated(true); + } + boolean alreadyRendering = chunk.doRender(); // if it's already rendering then it's most likely in the map + chunk.setRender(true); + if (!alreadyRendering) + chunks.put(this.posHash(chunk.chunkX, chunk.chunkY, chunk.chunkZ), chunk); + }); + }); } private static final class GenerationWorld implements BlockAccess, WorldGenConstants diff --git a/src/main/java/com/github/halotroop/litecraft/world/gen/CavesModifier.java b/src/main/java/com/github/halotroop/litecraft/world/gen/CavesModifier.java index c1d26e8..65889d5 100644 --- a/src/main/java/com/github/halotroop/litecraft/world/gen/CavesModifier.java +++ b/src/main/java/com/github/halotroop/litecraft/world/gen/CavesModifier.java @@ -11,7 +11,7 @@ public class CavesModifier implements WorldModifier, WorldGenConstants { private OctaveSimplexNoise caveNoise; private static final double THRESHOLD = 0.1; - // + @Override public void initialize(long seed) { From b82f24b4ad80755f043a21804f71825cf65f7234 Mon Sep 17 00:00:00 2001 From: SuperCoder7979 Date: Sun, 1 Mar 2020 07:47:37 -0500 Subject: [PATCH 04/14] 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 { From 1ae5e3e633afd0e188ac007d0c32abff5795146f Mon Sep 17 00:00:00 2001 From: SuperCoder7979 Date: Sun, 1 Mar 2020 12:01:07 -0500 Subject: [PATCH 05/14] fix renderer and more ""optimizations"" --- .../halotroop/litecraft/world/Chunk.java | 26 ++++++-- .../litecraft/world/DynamicChunkLoader.java | 66 ------------------- .../halotroop/litecraft/world/World.java | 13 +++- .../litecraft/world/block/BlockRenderer.java | 33 +++++----- 4 files changed, 45 insertions(+), 93 deletions(-) delete mode 100644 src/main/java/com/github/halotroop/litecraft/world/DynamicChunkLoader.java diff --git a/src/main/java/com/github/halotroop/litecraft/world/Chunk.java b/src/main/java/com/github/halotroop/litecraft/world/Chunk.java index 82df46a..3af5b7a 100644 --- a/src/main/java/com/github/halotroop/litecraft/world/Chunk.java +++ b/src/main/java/com/github/halotroop/litecraft/world/Chunk.java @@ -65,7 +65,7 @@ public class Chunk implements BlockAccess, WorldGenConstants, SODSerializable public BlockInstance getBlockInstance(int x, int y, int z) { if (x > CHUNK_SIZE || y > CHUNK_SIZE || z > CHUNK_SIZE || x < 0 || y < 0 || z < 0) - { throw new RuntimeException("Block [" + x + ", " + y + ", " + z + "] out of chunk bounds!"); } + { throw new RuntimeException("BlockInstance [" + x + ", " + y + ", " + z + "] out of chunk bounds!"); } return this.blockEntities[index(x, y, z)]; } @@ -82,19 +82,33 @@ public class Chunk implements BlockAccess, WorldGenConstants, SODSerializable { BlockInstance block = getBlockInstance(x, y, z); - // Why are we deliberately rendering blocks on the outside of the chunk??? + // Check for chunk edges to avoid errors when get the neighboring blocks, TODO fix this if (x == 0 || x == CHUNK_SIZE - 1 || z == 0 || z == CHUNK_SIZE - 1 || y == 0 || y == CHUNK_SIZE - 1) { renderedBlocks[index(x, y, z)] = block; continue; } - // Check for non-full-cubes around the block - if ((!getBlock(x - 1, y, z).isFullCube() || !getBlock(x + 1, y, z).isFullCube() || !getBlock(x, y - 1, z).isFullCube() - || !getBlock(x, y + 1, z).isFullCube() || !getBlock(x, y, z - 1).isFullCube() || !getBlock(x, y, z + 1).isFullCube())) - renderedBlocks[index(x, y, z)] = block; + + // Check for air. Yes this is stupid, TODO fix this too + try { + if (getBlockInstance(x - 1, y, z).getModel() == null || getBlockInstance(x + 1, y, z).getModel() == null || + getBlockInstance(x, y - 1, z).getModel() == null || getBlockInstance(x, y + 1, z).getModel() == null || + getBlockInstance(x, y, z - 1).getModel() == null || getBlockInstance(x, y, z + 1).getModel() == null) + { + renderedBlocks[index(x, y, z)] = block; + } + } + catch (NullPointerException e) + { // this seems to be a hotspot for errors + e.printStackTrace(); // so I can add a debug breakpoint on this line + throw e; // e + } } + + blockRenderer.prepareRender(); blockRenderer.render(renderedBlocks); + blockRenderer.shader.stop(); } } diff --git a/src/main/java/com/github/halotroop/litecraft/world/DynamicChunkLoader.java b/src/main/java/com/github/halotroop/litecraft/world/DynamicChunkLoader.java deleted file mode 100644 index dbc5482..0000000 --- a/src/main/java/com/github/halotroop/litecraft/world/DynamicChunkLoader.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.github.halotroop.litecraft.world; - -import java.util.*; -import java.util.function.LongConsumer; - -import com.github.hydos.multithreading.GingerThread; - -import it.unimi.dsi.fastutil.longs.*; - -public class DynamicChunkLoader extends GingerThread -{ - - private static int instances = 0; - public int chunkX, chunkY, chunkZ; - public World world; - - public DynamicChunkLoader(int chunkX, int chunkY, int chunkZ, World world) - { - this.chunkX = chunkX; - this.chunkY = chunkY; - this.chunkZ = chunkZ; - this.world = world; - this.setName("Dynamic Chunk thread"); - instances++; - System.out.println("allocations of dynamic chunk loader: " + instances); - } - - @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 - for (int x = chunkX - this.world.renderBound; x < chunkX + this.world.renderBound; x++) - for (int z = chunkZ - this.world.renderBound; z < chunkZ + this.world.renderBound; z++) - for (int y = chunkY - this.world.renderBound; y < chunkY + this.world.renderBound; y++) - toKeep.add(this.world.getChunkToLoad(x, y, z)); - // list of keys to remove - LongList toRemove = new LongArrayList(); - // check which loaded chunks are not neccesary - chunks.forEach((pos, chunk) -> - { - if (!toKeep.contains(chunk)) - toRemove.add((long) pos); - }); - // unload unneccesary chunks from chunk array - toRemove.forEach((LongConsumer) pos -> this.world.unloadChunk(pos)); - // populate chunks to render if they are not rendered, then render them - toKeep.forEach(chunk -> { - if (!chunk.isFullyGenerated()) - { - this.world.populateChunk(chunk); - chunk.setFullyGenerated(true); - } - boolean alreadyRendering = chunk.doRender(); // if it's already rendering then it's most likely in the map - chunk.setRender(true); - if (!alreadyRendering) - 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 a09783d..9d847bb 100644 --- a/src/main/java/com/github/halotroop/litecraft/world/World.java +++ b/src/main/java/com/github/halotroop/litecraft/world/World.java @@ -37,7 +37,7 @@ public class World implements BlockAccess, WorldGenConstants private final BlockInstance dummy; public World(long seed, int renderSize, Dimension dim, LitecraftSave save) { - new DynamicChunkLoader(0, 0, 0, this); + this.updateLoadedChunks(0, 0, 0); this.dummy = new BlockInstance(Blocks.ANDESITE, new Vector3f(0, 0, 0)); this.dummy.setVisible(false); this.chunks = new Long2ObjectArrayMap<>(); @@ -65,7 +65,7 @@ public class World implements BlockAccess, WorldGenConstants int y = SEA_LEVEL; int attemptsRemaining = 255; - while (attemptsRemaining --> 0) + while (attemptsRemaining-- > 0) { // DO NOT CHANGE TO y++ if (this.getBlock(x, ++y, z) == Blocks.AIR) @@ -181,7 +181,14 @@ public class World implements BlockAccess, WorldGenConstants public void render(BlockRenderer blockRenderer) { blockRenderer.prepareModel(this.dummy.getModel()); - this.chunks.forEach((pos, c) -> c.render(blockRenderer)); + try + { + this.chunks.forEach((pos, c) -> c.render(blockRenderer)); + } + catch (NullPointerException e) + { + System.out.println("Null chunk - we should look into fixing this"); + } blockRenderer.unbindModel(); } diff --git a/src/main/java/com/github/halotroop/litecraft/world/block/BlockRenderer.java b/src/main/java/com/github/halotroop/litecraft/world/block/BlockRenderer.java index 800dcf8..8be52e9 100644 --- a/src/main/java/com/github/halotroop/litecraft/world/block/BlockRenderer.java +++ b/src/main/java/com/github/halotroop/litecraft/world/block/BlockRenderer.java @@ -17,7 +17,7 @@ import com.github.hydos.ginger.engine.render.shaders.StaticShader; public class BlockRenderer extends Renderer implements WorldGenConstants { - private StaticShader shader; + public StaticShader shader; public BlockRenderer(StaticShader shader, Matrix4f projectionMatrix) { @@ -67,27 +67,24 @@ public class BlockRenderer extends Renderer implements WorldGenConstants shader.loadFakeLightingVariable(true); shader.loadShine(1, 1); GL13.glActiveTexture(GL13.GL_TEXTURE0); - enableWireframe(); +// enableWireframe(); } public void render(BlockInstance[] renderList) { - prepareRender(); - for (int x = 0; x < CHUNK_SIZE; x++) - for (int y = 0; y < CHUNK_SIZE; y++) - for (int z = 0; z < CHUNK_SIZE; z++) - { - BlockInstance entity = renderList[Chunk.index(x, y, z)]; - if (entity != null && entity.getModel() != null) - { - TexturedModel blockModel = entity.getModel(); - GL11.glBindTexture(GL11.GL_TEXTURE_2D, blockModel.getTexture().getTextureID()); - prepBlockInstance(entity); - GL11.glDrawElements(GL11.GL_TRIANGLES, blockModel.getRawModel().getVertexCount(), GL11.GL_UNSIGNED_INT, 0); - } - } - disableWireframe(); - shader.stop(); +// prepareRender(); + + for (BlockInstance entity : renderList) { + if (entity != null && entity.getModel() != null) + { + TexturedModel blockModel = entity.getModel(); + GL11.glBindTexture(GL11.GL_TEXTURE_2D, blockModel.getTexture().getTextureID()); + prepBlockInstance(entity); + GL11.glDrawElements(GL11.GL_TRIANGLES, blockModel.getRawModel().getVertexCount(), GL11.GL_UNSIGNED_INT, 0); + } + } +// disableWireframe(); +// shader.stop(); } } From 3fa156c8bfcd618163fce70402a722f75e9490aa Mon Sep 17 00:00:00 2001 From: SuperCoder7979 Date: Sun, 1 Mar 2020 12:06:08 -0500 Subject: [PATCH 06/14] remove extra threading code --- .../github/hydos/ginger/engine/api/Ginger.java | 15 ++++----------- .../hydos/ginger/engine/api/GingerRegister.java | 7 ++----- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/github/hydos/ginger/engine/api/Ginger.java b/src/main/java/com/github/hydos/ginger/engine/api/Ginger.java index ff6c567..2d0bcba 100644 --- a/src/main/java/com/github/hydos/ginger/engine/api/Ginger.java +++ b/src/main/java/com/github/hydos/ginger/engine/api/Ginger.java @@ -16,7 +16,6 @@ import com.github.hydos.ginger.engine.render.MasterRenderer; import com.github.hydos.ginger.engine.render.tools.MousePicker; import com.github.hydos.ginger.engine.screen.Screen; import com.github.hydos.ginger.engine.utils.Loader; -import com.github.hydos.multithreading.GingerThreading; public class Ginger { @@ -25,7 +24,6 @@ public class Ginger public MousePicker picker; public FontType globalFont; public Fbo contrastFbo; - public GingerThreading threading; private Timer timer; TickListener gameTickListener = new TickListener() @@ -104,7 +102,6 @@ public class Ginger { INSTANCE = this; registry = new GingerRegister(); - threading = new GingerThreading(); registry.registerGame(game); timer = new Timer(game.data.tickSpeed); timer.addTickListener(gameTickListener); @@ -117,15 +114,11 @@ public class Ginger public void startGameLoop() { - if (!threading.isAlive()) // Prevents this from accidentally being run twice + while (!Window.closed()) { - threading.start(); - while (!Window.closed()) - { - update(Litecraft.getInstance().data); // Run this regardless, (so as fast as possible) - if (timer.tick()) Litecraft.getInstance().tps += 1; // Run this only [ticklimit] times per second (This invokes gameTickListener.onTick!) - if (Window.shouldRender()) registry.game.render(); // Run this only [framelimit] times per second - } + update(Litecraft.getInstance().data); // Run this regardless, (so as fast as possible) + if (timer.tick()) Litecraft.getInstance().tps += 1; // Run this only [ticklimit] times per second (This invokes gameTickListener.onTick!) + if (Window.shouldRender()) registry.game.render(); // Run this only [framelimit] times per second } registry.game.exit(); } diff --git a/src/main/java/com/github/hydos/ginger/engine/api/GingerRegister.java b/src/main/java/com/github/hydos/ginger/engine/api/GingerRegister.java index a37c0d6..7436a79 100644 --- a/src/main/java/com/github/hydos/ginger/engine/api/GingerRegister.java +++ b/src/main/java/com/github/hydos/ginger/engine/api/GingerRegister.java @@ -8,7 +8,6 @@ import com.github.hydos.ginger.engine.font.GUIText; import com.github.hydos.ginger.engine.postprocessing.Fbo; import com.github.hydos.ginger.engine.render.MasterRenderer; import com.github.hydos.ginger.engine.screen.Screen; -import com.github.hydos.multithreading.GingerThreading; /** Used if a game wants to access engine variables safely */ public class GingerRegister @@ -19,7 +18,6 @@ public class GingerRegister public static GingerRegister getInstance() { return INSTANCE; } - public GingerThreading threadRegister; public List texts; public List guiButtons; public List fbos; @@ -30,12 +28,11 @@ public class GingerRegister public GingerRegister() { INSTANCE = this; - threadRegister = new GingerThreading(); } public void registerButton(TextureButton button) { - if (guiButtons == null) guiButtons = new ArrayList(); + if (guiButtons == null) guiButtons = new ArrayList<>(); guiButtons.add(button); } @@ -44,7 +41,7 @@ public class GingerRegister public void registerText(GUIText guiText) { - if (texts == null) texts = new ArrayList(); + if (texts == null) texts = new ArrayList<>(); texts.add(guiText); } From 60b514dbb1fe47c113d6b78bcd737dc4a6ab30ff Mon Sep 17 00:00:00 2001 From: SuperCoder7979 Date: Sun, 1 Mar 2020 14:14:48 -0500 Subject: [PATCH 07/14] more optimizations --- .../halotroop/litecraft/world/Chunk.java | 32 ++++++++++++------- .../halotroop/litecraft/world/World.java | 25 +++++++++------ 2 files changed, 37 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/github/halotroop/litecraft/world/Chunk.java b/src/main/java/com/github/halotroop/litecraft/world/Chunk.java index 3af5b7a..f7061f4 100644 --- a/src/main/java/com/github/halotroop/litecraft/world/Chunk.java +++ b/src/main/java/com/github/halotroop/litecraft/world/Chunk.java @@ -1,6 +1,8 @@ package com.github.halotroop.litecraft.world; +import java.util.ArrayList; import java.util.Arrays; +import java.util.List; import java.util.function.ToIntFunction; import org.joml.Vector3f; @@ -20,13 +22,13 @@ public class Chunk implements BlockAccess, WorldGenConstants, SODSerializable * @param x in-chunk x coordinate. * @param y in-chunk y coordinate. * @param z in-chunk z coordinate. - * @return creates a long that represents a coordinate, for use as a key in the array. + * @return creates a long that represents a coordinate, for use as a key in arrays. */ public static int index(int x, int y, int z) { return (x & MAX_POS) | ((y & MAX_POS) << POS_SHIFT) | ((z & MAX_POS) << DOUBLE_SHIFT); } private final Block[] blocks = new Block[CHUNK_SIZE * CHUNK_SIZE * CHUNK_SIZE]; - private BlockInstance[] blockEntities = new BlockInstance[CHUNK_SIZE * CHUNK_SIZE * CHUNK_SIZE]; + private BlockInstance[] blockInstances = new BlockInstance[CHUNK_SIZE * CHUNK_SIZE * CHUNK_SIZE]; private boolean shouldRender = false; public final int chunkX, chunkY, chunkZ; public final int chunkStartX, chunkStartY, chunkStartZ; @@ -34,6 +36,10 @@ public class Chunk implements BlockAccess, WorldGenConstants, SODSerializable public final int dimension; private boolean dirty = true; private World world; + /** + * A holder for the rendered blocks in this chunk. This array is *NOT* safe to use for getting BIs at a position! + * It can vary in size from 0 to 512 elements long and must only be read linearly. + */ private BlockInstance[] renderedBlocks = new BlockInstance[CHUNK_SIZE * CHUNK_SIZE * CHUNK_SIZE]; public Chunk(World world, int chunkX, int chunkY, int chunkZ, int dimension) @@ -66,7 +72,7 @@ public class Chunk implements BlockAccess, WorldGenConstants, SODSerializable { if (x > CHUNK_SIZE || y > CHUNK_SIZE || z > CHUNK_SIZE || x < 0 || y < 0 || z < 0) { throw new RuntimeException("BlockInstance [" + x + ", " + y + ", " + z + "] out of chunk bounds!"); } - return this.blockEntities[index(x, y, z)]; + return this.blockInstances[index(x, y, z)]; } public void render(BlockRenderer blockRenderer) @@ -74,7 +80,9 @@ public class Chunk implements BlockAccess, WorldGenConstants, SODSerializable if (shouldRender) { if (dirty) + { dirty = false; + List tempList = new ArrayList<>(); Arrays.fill(renderedBlocks, null); for (int x = 0; x < CHUNK_SIZE; x++) for (int y = 0; y < CHUNK_SIZE; y++) @@ -85,26 +93,28 @@ public class Chunk implements BlockAccess, WorldGenConstants, SODSerializable // Check for chunk edges to avoid errors when get the neighboring blocks, TODO fix this if (x == 0 || x == CHUNK_SIZE - 1 || z == 0 || z == CHUNK_SIZE - 1 || y == 0 || y == CHUNK_SIZE - 1) { - renderedBlocks[index(x, y, z)] = block; + tempList.add(block); continue; } // Check for air. Yes this is stupid, TODO fix this too - try { + try + { if (getBlockInstance(x - 1, y, z).getModel() == null || getBlockInstance(x + 1, y, z).getModel() == null || getBlockInstance(x, y - 1, z).getModel() == null || getBlockInstance(x, y + 1, z).getModel() == null || getBlockInstance(x, y, z - 1).getModel() == null || getBlockInstance(x, y, z + 1).getModel() == null) { - renderedBlocks[index(x, y, z)] = block; + tempList.add(block); } - } - catch (NullPointerException e) + } catch (NullPointerException e) { // this seems to be a hotspot for errors e.printStackTrace(); // so I can add a debug breakpoint on this line throw e; // e } } + renderedBlocks = tempList.toArray(BlockInstance[]::new); + } blockRenderer.prepareRender(); blockRenderer.render(renderedBlocks); @@ -129,7 +139,7 @@ public class Chunk implements BlockAccess, WorldGenConstants, SODSerializable else if (z < 0) z = 0; // this.blocks[index(x, y, z)] = block; - if (this.shouldRender) this.blockEntities[index(x, y, z)] = + if (this.shouldRender) this.blockInstances[index(x, y, z)] = new BlockInstance(block, new Vector3f(this.chunkStartX + x, this.chunkStartY + y, this.chunkStartZ + z)); dirty = true; } @@ -146,7 +156,7 @@ public class Chunk implements BlockAccess, WorldGenConstants, SODSerializable { Block block = this.blocks[index(x, y, z)]; - this.blockEntities[index(x, y, z)] = new BlockInstance(block, + this.blockInstances[index(x, y, z)] = new BlockInstance(block, new Vector3f( this.chunkStartX + x, this.chunkStartY + y, @@ -155,7 +165,7 @@ public class Chunk implements BlockAccess, WorldGenConstants, SODSerializable else if (!render && this.shouldRender) // else if it has been changed to false. // we need to check both variables because there are two cases that make // the if statement fall to here - blockEntities = new BlockInstance[CHUNK_SIZE * CHUNK_SIZE * CHUNK_SIZE]; + blockInstances = new BlockInstance[CHUNK_SIZE * CHUNK_SIZE * CHUNK_SIZE]; this.shouldRender = render; dirty = 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 9d847bb..e513e3e 100644 --- a/src/main/java/com/github/halotroop/litecraft/world/World.java +++ b/src/main/java/com/github/halotroop/litecraft/world/World.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Random; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ForkJoinPool; import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.LongConsumer; @@ -30,6 +31,7 @@ public class World implements BlockAccess, WorldGenConstants private final LitecraftSave save; private final long seed; private final int dimension; + private final ForkJoinPool threadPool; public Player player; int renderBound; int renderBoundVertical; @@ -37,6 +39,7 @@ public class World implements BlockAccess, WorldGenConstants private final BlockInstance dummy; public World(long seed, int renderSize, Dimension dim, LitecraftSave save) { + this.threadPool = new ForkJoinPool(4, ForkJoinPool.defaultForkJoinWorkerThreadFactory, null, true); this.updateLoadedChunks(0, 0, 0); this.dummy = new BlockInstance(Blocks.ANDESITE, new Vector3f(0, 0, 0)); this.dummy.setVisible(false); @@ -140,7 +143,7 @@ public class World implements BlockAccess, WorldGenConstants { result.set(this.save.saveChunk(chunk)); this.chunks.remove(posHash); - }); + }, threadPool); return result.get(); } @@ -195,16 +198,20 @@ public class World implements BlockAccess, WorldGenConstants public void unloadAllChunks() { LongList chunkPositions = new LongArrayList(); - CompletableFuture.runAsync(() -> + List futures = new ArrayList<>(); + if (this.chunks != null) { - if (this.chunks != null) - this.chunks.forEach((pos, chunk) -> - { // for every chunk in memory + this.chunks.forEach((pos, chunk) -> + { // for every chunk in memory + futures.add(CompletableFuture.runAsync(() -> + { chunkPositions.add((long) pos); // add pos to chunk positions list for removal later this.save.saveChunk(chunk); // save chunk - }); - chunkPositions.forEach((LongConsumer) (pos -> this.chunks.remove(pos))); // remove all chunks - }).join(); + }, threadPool)); + }); + } + futures.forEach(CompletableFuture::join); + chunkPositions.forEach((LongConsumer) (pos -> this.chunks.remove(pos))); // remove all chunks } public long getSeed() @@ -245,7 +252,7 @@ public class World implements BlockAccess, WorldGenConstants if (!alreadyRendering) chunks.put(this.posHash(chunk.chunkX, chunk.chunkY, chunk.chunkZ), chunk); }); - }); + }, threadPool); } private static final class GenerationWorld implements BlockAccess, WorldGenConstants From accb0e7b86acdb79690e251645afb1b7a35178d1 Mon Sep 17 00:00:00 2001 From: valoeghese Date: Mon, 2 Mar 2020 20:33:43 +1300 Subject: [PATCH 08/14] attempted merge --- .../halotroop/litecraft/world/Chunk.java | 3 --- .../litecraft/world/block/BlockRenderer.java | 26 ------------------- .../engine/common/api/GingerRegister.java | 10 ------- .../ginger/engine/opengl/api/GingerGL.java | 15 ----------- 4 files changed, 54 deletions(-) diff --git a/src/main/java/com/github/halotroop/litecraft/world/Chunk.java b/src/main/java/com/github/halotroop/litecraft/world/Chunk.java index 71b8037..2ed9003 100644 --- a/src/main/java/com/github/halotroop/litecraft/world/Chunk.java +++ b/src/main/java/com/github/halotroop/litecraft/world/Chunk.java @@ -35,14 +35,11 @@ public class Chunk implements BlockAccess, WorldGenConstants, SODSerializable private boolean fullyGenerated = false; public final int dimension; private boolean dirty = true; -<<<<<<< HEAD private World world; /** * A holder for the rendered blocks in this chunk. This array is *NOT* safe to use for getting BIs at a position! * It can vary in size from 0 to 512 elements long and must only be read linearly. */ -======= ->>>>>>> liteCraft private BlockInstance[] renderedBlocks = new BlockInstance[CHUNK_SIZE * CHUNK_SIZE * CHUNK_SIZE]; public Chunk(World world, int chunkX, int chunkY, int chunkZ, int dimension) diff --git a/src/main/java/com/github/halotroop/litecraft/world/block/BlockRenderer.java b/src/main/java/com/github/halotroop/litecraft/world/block/BlockRenderer.java index fc19eb9..7651a9e 100644 --- a/src/main/java/com/github/halotroop/litecraft/world/block/BlockRenderer.java +++ b/src/main/java/com/github/halotroop/litecraft/world/block/BlockRenderer.java @@ -17,13 +17,8 @@ import com.github.hydos.ginger.engine.opengl.utils.GlLoader; public class BlockRenderer extends Renderer implements WorldGenConstants { -<<<<<<< HEAD - public StaticShader shader; -======= - private StaticShader shader; public int atlasID; ->>>>>>> liteCraft public BlockRenderer(StaticShader shader, Matrix4f projectionMatrix) { @@ -74,32 +69,12 @@ public class BlockRenderer extends Renderer implements WorldGenConstants shader.loadFakeLightingVariable(true); shader.loadShine(1, 1); GL13.glActiveTexture(GL13.GL_TEXTURE0); -<<<<<<< HEAD -// enableWireframe(); -======= GL11.glBindTexture(GL11.GL_TEXTURE_2D, atlasID); enableWireframe(); ->>>>>>> liteCraft } public void render(BlockInstance[] renderList) { -<<<<<<< HEAD -// prepareRender(); - - for (BlockInstance entity : renderList) { - if (entity != null && entity.getModel() != null) - { - TexturedModel blockModel = entity.getModel(); - GL11.glBindTexture(GL11.GL_TEXTURE_2D, blockModel.getTexture().getTextureID()); - prepBlockInstance(entity); - GL11.glDrawElements(GL11.GL_TRIANGLES, blockModel.getRawModel().getVertexCount(), GL11.GL_UNSIGNED_INT, 0); - } - } -// disableWireframe(); -// shader.stop(); - -======= prepareRender(); for (int x = 0; x < CHUNK_SIZE; x++) for (int y = 0; y < CHUNK_SIZE; y++) @@ -117,6 +92,5 @@ public class BlockRenderer extends Renderer implements WorldGenConstants } disableWireframe(); shader.stop(); ->>>>>>> liteCraft } } diff --git a/src/main/java/com/github/hydos/ginger/engine/common/api/GingerRegister.java b/src/main/java/com/github/hydos/ginger/engine/common/api/GingerRegister.java index fc19743..1b3b3c3 100644 --- a/src/main/java/com/github/hydos/ginger/engine/common/api/GingerRegister.java +++ b/src/main/java/com/github/hydos/ginger/engine/common/api/GingerRegister.java @@ -2,22 +2,12 @@ package com.github.hydos.ginger.engine.common.api; import java.util.*; -<<<<<<< HEAD:src/main/java/com/github/hydos/ginger/engine/api/GingerRegister.java -import com.github.hydos.ginger.engine.api.game.Game; -import com.github.hydos.ginger.engine.elements.buttons.TextureButton; -import com.github.hydos.ginger.engine.font.GUIText; -import com.github.hydos.ginger.engine.postprocessing.Fbo; -import com.github.hydos.ginger.engine.render.MasterRenderer; -import com.github.hydos.ginger.engine.screen.Screen; -======= import com.github.hydos.ginger.engine.common.api.game.Game; import com.github.hydos.ginger.engine.common.elements.buttons.TextureButton; import com.github.hydos.ginger.engine.common.font.GUIText; import com.github.hydos.ginger.engine.common.screen.Screen; import com.github.hydos.ginger.engine.opengl.postprocessing.Fbo; import com.github.hydos.ginger.engine.opengl.render.MasterRenderer; -import com.github.hydos.multithreading.GingerThreading; ->>>>>>> liteCraft:src/main/java/com/github/hydos/ginger/engine/common/api/GingerRegister.java /** Used if a game wants to access engine variables safely */ public class GingerRegister diff --git a/src/main/java/com/github/hydos/ginger/engine/opengl/api/GingerGL.java b/src/main/java/com/github/hydos/ginger/engine/opengl/api/GingerGL.java index 1120861..1478bc9 100644 --- a/src/main/java/com/github/hydos/ginger/engine/opengl/api/GingerGL.java +++ b/src/main/java/com/github/hydos/ginger/engine/opengl/api/GingerGL.java @@ -5,19 +5,6 @@ import org.joml.Vector2f; import com.github.halotroop.litecraft.Litecraft; import com.github.halotroop.litecraft.logic.Timer; import com.github.halotroop.litecraft.logic.Timer.TickListener; -<<<<<<< HEAD:src/main/java/com/github/hydos/ginger/engine/api/Ginger.java -import com.github.hydos.ginger.engine.api.game.*; -import com.github.hydos.ginger.engine.elements.buttons.TextureButton; -import com.github.hydos.ginger.engine.elements.objects.Player; -import com.github.hydos.ginger.engine.font.*; -import com.github.hydos.ginger.engine.io.Window; -import com.github.hydos.ginger.engine.particle.ParticleMaster; -import com.github.hydos.ginger.engine.postprocessing.*; -import com.github.hydos.ginger.engine.render.MasterRenderer; -import com.github.hydos.ginger.engine.render.tools.MousePicker; -import com.github.hydos.ginger.engine.screen.Screen; -import com.github.hydos.ginger.engine.utils.Loader; -======= import com.github.hydos.ginger.engine.common.api.GingerRegister; import com.github.hydos.ginger.engine.common.api.game.*; import com.github.hydos.ginger.engine.common.elements.buttons.TextureButton; @@ -29,8 +16,6 @@ import com.github.hydos.ginger.engine.opengl.postprocessing.*; import com.github.hydos.ginger.engine.opengl.render.MasterRenderer; import com.github.hydos.ginger.engine.opengl.render.tools.MousePicker; import com.github.hydos.ginger.engine.opengl.utils.GlLoader; -import com.github.hydos.multithreading.GingerThreading; ->>>>>>> liteCraft:src/main/java/com/github/hydos/ginger/engine/opengl/api/GingerGL.java public class GingerGL { From 031957fb23b1d6b85a4dc99ffee178f62b2b0801 Mon Sep 17 00:00:00 2001 From: valoeghese Date: Mon, 2 Mar 2020 20:36:21 +1300 Subject: [PATCH 09/14] e --- .../litecraft/world/block/BlockRenderer.java | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/github/halotroop/litecraft/world/block/BlockRenderer.java b/src/main/java/com/github/halotroop/litecraft/world/block/BlockRenderer.java index 7651a9e..c641774 100644 --- a/src/main/java/com/github/halotroop/litecraft/world/block/BlockRenderer.java +++ b/src/main/java/com/github/halotroop/litecraft/world/block/BlockRenderer.java @@ -76,21 +76,17 @@ public class BlockRenderer extends Renderer implements WorldGenConstants public void render(BlockInstance[] renderList) { prepareRender(); - for (int x = 0; x < CHUNK_SIZE; x++) - for (int y = 0; y < CHUNK_SIZE; y++) - for (int z = 0; z < CHUNK_SIZE; z++) - { - BlockInstance entity = renderList[Chunk.index(x, y, z)]; - if (entity != null && entity.getModel() != null) - { - TexturedModel blockModel = entity.getModel(); - GL11.glBindTexture(GL11.GL_TEXTURE_2D, blockModel.getTexture().getTextureID()); - prepBlockInstance(entity); - GL11.glDrawElements(GL11.GL_TRIANGLES, blockModel.getRawModel().getVertexCount(), - GL11.GL_UNSIGNED_INT, 0); - } - } - disableWireframe(); - shader.stop(); + + for (BlockInstance entity : renderList) { + if (entity != null && entity.getModel() != null) + { + TexturedModel blockModel = entity.getModel(); + GL11.glBindTexture(GL11.GL_TEXTURE_2D, blockModel.getTexture().getTextureID()); + prepBlockInstance(entity); + GL11.glDrawElements(GL11.GL_TRIANGLES, blockModel.getRawModel().getVertexCount(), GL11.GL_UNSIGNED_INT, 0); + } + } +// disableWireframe(); +// shader.stop(); } } From d1492f152b4e250b815869a7f24f29ed30b71b19 Mon Sep 17 00:00:00 2001 From: valoeghese Date: Mon, 2 Mar 2020 20:43:49 +1300 Subject: [PATCH 10/14] increase render size --- .../com/github/halotroop/litecraft/save/LitecraftSave.java | 2 +- src/main/java/com/github/halotroop/litecraft/world/Chunk.java | 4 +--- .../github/halotroop/litecraft/world/block/BlockRenderer.java | 1 - .../halotroop/litecraft/world/dimension/Dimensions.java | 2 +- 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/github/halotroop/litecraft/save/LitecraftSave.java b/src/main/java/com/github/halotroop/litecraft/save/LitecraftSave.java index 7c5d6df..bbe1e0f 100644 --- a/src/main/java/com/github/halotroop/litecraft/save/LitecraftSave.java +++ b/src/main/java/com/github/halotroop/litecraft/save/LitecraftSave.java @@ -159,5 +159,5 @@ public final class LitecraftSave } private static final String SAVE_DIR = "./saves/"; - private static final int RENDER_SIZE = 5; + private static final int RENDER_SIZE = 6; } diff --git a/src/main/java/com/github/halotroop/litecraft/world/Chunk.java b/src/main/java/com/github/halotroop/litecraft/world/Chunk.java index 2ed9003..47ef145 100644 --- a/src/main/java/com/github/halotroop/litecraft/world/Chunk.java +++ b/src/main/java/com/github/halotroop/litecraft/world/Chunk.java @@ -1,8 +1,6 @@ package com.github.halotroop.litecraft.world; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; +import java.util.*; import java.util.function.ToIntFunction; import org.joml.Vector3f; diff --git a/src/main/java/com/github/halotroop/litecraft/world/block/BlockRenderer.java b/src/main/java/com/github/halotroop/litecraft/world/block/BlockRenderer.java index c641774..ed9f30e 100644 --- a/src/main/java/com/github/halotroop/litecraft/world/block/BlockRenderer.java +++ b/src/main/java/com/github/halotroop/litecraft/world/block/BlockRenderer.java @@ -4,7 +4,6 @@ import org.joml.Matrix4f; import org.lwjgl.opengl.*; import com.github.halotroop.litecraft.types.block.BlockInstance; -import com.github.halotroop.litecraft.world.Chunk; import com.github.halotroop.litecraft.world.gen.WorldGenConstants; import com.github.hydos.ginger.engine.common.api.GingerRegister; import com.github.hydos.ginger.engine.common.elements.objects.RenderObject; 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 3a24f88..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 @@ -5,5 +5,5 @@ import com.github.halotroop.litecraft.world.gen.modifier.CavesModifier; public final class Dimensions { - public static final Dimension OVERWORLD = new EarthDimension(0, "earth");//.addWorldModifier(new CavesModifier()); + public static final Dimension OVERWORLD = new EarthDimension(0, "earth").addWorldModifier(new CavesModifier()); } From 0361b799a846f391d306aa4b1beb47242be4ece2 Mon Sep 17 00:00:00 2001 From: valoeghese Date: Mon, 2 Mar 2020 20:47:47 +1300 Subject: [PATCH 11/14] remove unneccesary code, and do stuff tm --- src/main/java/com/github/halotroop/litecraft/Litecraft.java | 2 ++ src/main/java/com/github/halotroop/litecraft/world/World.java | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/github/halotroop/litecraft/Litecraft.java b/src/main/java/com/github/halotroop/litecraft/Litecraft.java index ce0a96c..59bb855 100644 --- a/src/main/java/com/github/halotroop/litecraft/Litecraft.java +++ b/src/main/java/com/github/halotroop/litecraft/Litecraft.java @@ -58,8 +58,10 @@ public class Litecraft extends Game if (this.world != null) { System.out.println("Saving chunks..."); + long time = System.currentTimeMillis(); this.world.unloadAllChunks(); this.getSave().saveGlobalData(this.world.getSeed(), this.player); + System.out.println("Saved world in " + (System.currentTimeMillis() - time) + " milliseconds"); } engine.cleanup(); System.exit(0); 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 39a2743..bfb7e4b 100644 --- a/src/main/java/com/github/halotroop/litecraft/world/World.java +++ b/src/main/java/com/github/halotroop/litecraft/world/World.java @@ -40,7 +40,6 @@ public class World implements BlockAccess, WorldGenConstants public World(long seed, int renderSize, Dimension dim, LitecraftSave save) { this.threadPool = new ForkJoinPool(4, ForkJoinPool.defaultForkJoinWorkerThreadFactory, null, true); - this.updateLoadedChunks(0, 0, 0); this.dummy = new BlockInstance(Blocks.ANDESITE, new Vector3f(0, 0, 0)); this.dummy.setVisible(false); this.chunks = new Long2ObjectArrayMap<>(); From 598ce5f62599a7343716ae1ed397168dc6d5ac7f Mon Sep 17 00:00:00 2001 From: valoeghese Date: Mon, 2 Mar 2020 20:49:41 +1300 Subject: [PATCH 12/14] change render size back because lag --- .../java/com/github/halotroop/litecraft/save/LitecraftSave.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/github/halotroop/litecraft/save/LitecraftSave.java b/src/main/java/com/github/halotroop/litecraft/save/LitecraftSave.java index bbe1e0f..7c5d6df 100644 --- a/src/main/java/com/github/halotroop/litecraft/save/LitecraftSave.java +++ b/src/main/java/com/github/halotroop/litecraft/save/LitecraftSave.java @@ -159,5 +159,5 @@ public final class LitecraftSave } private static final String SAVE_DIR = "./saves/"; - private static final int RENDER_SIZE = 6; + private static final int RENDER_SIZE = 5; } From 54181617a249f6f8bc1544353940538a49a26b6a Mon Sep 17 00:00:00 2001 From: valoeghese Date: Mon, 2 Mar 2020 20:56:25 +1300 Subject: [PATCH 13/14] e --- .../java/com/github/halotroop/litecraft/save/LitecraftSave.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/github/halotroop/litecraft/save/LitecraftSave.java b/src/main/java/com/github/halotroop/litecraft/save/LitecraftSave.java index 7c5d6df..edebc2f 100644 --- a/src/main/java/com/github/halotroop/litecraft/save/LitecraftSave.java +++ b/src/main/java/com/github/halotroop/litecraft/save/LitecraftSave.java @@ -159,5 +159,5 @@ public final class LitecraftSave } private static final String SAVE_DIR = "./saves/"; - private static final int RENDER_SIZE = 5; + private static final int RENDER_SIZE = 3; } From 7b4d87d71221d96860991dd0087707bb93c1f66c Mon Sep 17 00:00:00 2001 From: valoeghese Date: Mon, 2 Mar 2020 20:56:44 +1300 Subject: [PATCH 14/14] f --- .../java/com/github/halotroop/litecraft/save/LitecraftSave.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/github/halotroop/litecraft/save/LitecraftSave.java b/src/main/java/com/github/halotroop/litecraft/save/LitecraftSave.java index edebc2f..7c5d6df 100644 --- a/src/main/java/com/github/halotroop/litecraft/save/LitecraftSave.java +++ b/src/main/java/com/github/halotroop/litecraft/save/LitecraftSave.java @@ -159,5 +159,5 @@ public final class LitecraftSave } private static final String SAVE_DIR = "./saves/"; - private static final int RENDER_SIZE = 3; + private static final int RENDER_SIZE = 5; }