From 5853595fee7d649ff476267640795569eb24fa88 Mon Sep 17 00:00:00 2001 From: halotroop2288 Date: Sat, 29 Feb 2020 16:40:55 -0800 Subject: [PATCH 1/5] This method does adds more data than it saves. --- .../com/github/halotroop/litecraft/Litecraft.java | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/github/halotroop/litecraft/Litecraft.java b/src/main/java/com/github/halotroop/litecraft/Litecraft.java index f18c1dc..d1fa997 100644 --- a/src/main/java/com/github/halotroop/litecraft/Litecraft.java +++ b/src/main/java/com/github/halotroop/litecraft/Litecraft.java @@ -135,16 +135,13 @@ public class Litecraft extends Game Input.addPressCallback(Keybind.EXIT, this::exit); Input.addInitialPressCallback(Keybind.FULLSCREEN, Window::fullscreen); Input.addInitialPressCallback(Keybind.WIREFRAME, GingerRegister.getInstance()::toggleWireframe); - Input.addPressCallback(Keybind.MOVE_FORWARD, () -> this.movePlayer(RelativeDirection.FORWARD)); - Input.addPressCallback(Keybind.MOVE_BACKWARD, () -> this.movePlayer(RelativeDirection.BACKWARD)); - Input.addPressCallback(Keybind.STRAFE_LEFT, () -> this.movePlayer(RelativeDirection.LEFT)); - Input.addPressCallback(Keybind.STRAFE_RIGHT, () -> this.movePlayer(RelativeDirection.RIGHT)); - Input.addPressCallback(Keybind.FLY_UP, () -> this.movePlayer(RelativeDirection.UP)); - Input.addPressCallback(Keybind.FLY_DOWN, () -> this.movePlayer(RelativeDirection.DOWN)); + Input.addPressCallback(Keybind.MOVE_FORWARD, () -> this.player.move(RelativeDirection.FORWARD)); + Input.addPressCallback(Keybind.MOVE_BACKWARD, () -> this.player.move(RelativeDirection.BACKWARD)); + Input.addPressCallback(Keybind.STRAFE_LEFT, () -> this.player.move(RelativeDirection.LEFT)); + Input.addPressCallback(Keybind.STRAFE_RIGHT, () -> this.player.move(RelativeDirection.RIGHT)); + Input.addPressCallback(Keybind.FLY_UP, () -> this.player.move(RelativeDirection.UP)); + Input.addPressCallback(Keybind.FLY_DOWN, () -> this.player.move(RelativeDirection.DOWN)); } - - private void movePlayer(RelativeDirection direction) - { this.player.move(direction); } private void setupWindow() { From 804dc2471e43c393e242b2eb9dc61d23c4810513 Mon Sep 17 00:00:00 2001 From: halotroop2288 Date: Sat, 29 Feb 2020 17:53:11 -0800 Subject: [PATCH 2/5] Made chunks add blocks next to all non-full cubes to the render list Instead of just ones that are next to air. --- .../litecraft/types/block/Blocks.java | 9 +++++++++ .../halotroop/litecraft/world/Chunk.java | 20 ++++++------------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/github/halotroop/litecraft/types/block/Blocks.java b/src/main/java/com/github/halotroop/litecraft/types/block/Blocks.java index 1d6774e..6d9443c 100644 --- a/src/main/java/com/github/halotroop/litecraft/types/block/Blocks.java +++ b/src/main/java/com/github/halotroop/litecraft/types/block/Blocks.java @@ -4,6 +4,7 @@ import com.github.halotroop.litecraft.types.block.Block.Properties; public final class Blocks { +<<<<<<< Upstream, based on branch 'liteCraft' of https://github.com/halotroop/Ginger3D.git public static final Block AIR = new Block(new Properties("air").visible(false)); public static final Block GRASS = new Block(new Properties("block/cubes/soil/grass/grass_top.png").canCaveCarve(true)); public static final Block DIRT = new Block("block/cubes/soil/dirt.png", new Properties("dirt").canCaveCarve(true)); @@ -12,6 +13,14 @@ public final class Blocks public static final Block GRANITE = new Block("block/cubes/stone/basic/granite.png", new Properties("granite").canCaveCarve(true)); public static final Block GNEISS = new Block("block/cubes/stone/basic/gneiss.png", new Properties("gneiss").canCaveCarve(true)); +======= + public static final Block AIR = new Block(new Properties("air").visible(false).fullCube(false)); + public static final Block DIRT = new Block("block/cubes/soil/dirt.png", new Properties("dirt")); + public static final Block ANDESITE = new Block("block/cubes/stone/basic/andesite.png", new Properties("andesite")); + public static final Block DIORITE = new Block("block/cubes/stone/basic/diorite.png", new Properties("diorite")); + public static final Block GRANITE = new Block("block/cubes/stone/basic/granite.png", new Properties("granite")); + public static final Block GNEISS = new Block("block/cubes/stone/basic/gneiss.png", new Properties("gneiss")); +>>>>>>> 56b16c1 Made chunks add blocks next to all non-full cubes to the render list public static Block init() { return AIR; 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 b81040e..82df46a 100644 --- a/src/main/java/com/github/halotroop/litecraft/world/Chunk.java +++ b/src/main/java/com/github/halotroop/litecraft/world/Chunk.java @@ -82,25 +82,17 @@ 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??? 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 air. Yes this is stupid, TODO fix this - 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 - } + // 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; + } blockRenderer.render(renderedBlocks); } From 2af1a71ab574f0097e132f811e0b25ba269cc2d4 Mon Sep 17 00:00:00 2001 From: halotroop2288 Date: Sat, 29 Feb 2020 18:03:08 -0800 Subject: [PATCH 3/5] Moved stuff around --- .../github/halotroop/litecraft/Litecraft.java | 20 +++++++++++++++++++ .../hydos/ginger/engine/api/Ginger.java | 2 -- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/github/halotroop/litecraft/Litecraft.java b/src/main/java/com/github/halotroop/litecraft/Litecraft.java index d1fa997..95f7bba 100644 --- a/src/main/java/com/github/halotroop/litecraft/Litecraft.java +++ b/src/main/java/com/github/halotroop/litecraft/Litecraft.java @@ -71,6 +71,7 @@ public class Litecraft extends Game @Override public void render() { +<<<<<<< Upstream, based on branch 'liteCraft' of https://github.com/halotroop/Ginger3D.git fps += 1; // This section updates the debug stats once per real-time second, regardless of how many frames have been rendered if (System.currentTimeMillis() > frameTimer + 1000) { @@ -83,6 +84,10 @@ public class Litecraft extends Game /** * And now, the actual rendering: */ +======= + fps+=1; + updateDebugStats(); +>>>>>>> 4b249f6 Moved stuff around // Render shadows GingerRegister.getInstance().masterRenderer.renderShadowMap(data.entities, data.lights.get(0)); // If there's a world, render it! @@ -93,9 +98,24 @@ public class Litecraft extends Game Window.swapBuffers(); } + // Updates the debug stats once per real-time second, regardless of how many frames have been rendered + private void updateDebugStats() + { + if (System.currentTimeMillis() > frameTimer + 1000) + { + this.dbgStats.set(fps, ups, tps, threadWaitlist); + this.fps=0; + this.ups=0; + this.tps=0; + this.frameTimer += 1000; + } + } + public void update() { Input.invokeAllListeners(); + data.player.updateMovement(); + data.camera.updateMovement(); } private void setupConstants() 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 2fd730d..ff6c567 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 @@ -134,8 +134,6 @@ public class Ginger public void update(GameData data) { registry.game.update(); - data.player.updateMovement(); - data.camera.updateMovement(); picker.update(); GingerUtils.update(); ParticleMaster.update(data.camera); From d66e0bda90bb09a5a7113e6390708c05ef826385 Mon Sep 17 00:00:00 2001 From: halotroop2288 Date: Sat, 29 Feb 2020 18:11:44 -0800 Subject: [PATCH 4/5] Simpler boolean setting for cave carving blocks --- .../halotroop/litecraft/types/block/Block.java | 6 +++--- .../halotroop/litecraft/types/block/Blocks.java | 15 +++------------ 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/github/halotroop/litecraft/types/block/Block.java b/src/main/java/com/github/halotroop/litecraft/types/block/Block.java index 6a785fb..179111e 100644 --- a/src/main/java/com/github/halotroop/litecraft/types/block/Block.java +++ b/src/main/java/com/github/halotroop/litecraft/types/block/Block.java @@ -11,7 +11,7 @@ public class Block { // add properties to this builder! private boolean visible = true; private boolean fullCube = true; - private boolean canCaveCarve = false; + private boolean canCaveCarve = true; private final String identifier; public Properties(String identifier) @@ -29,9 +29,9 @@ public class Block return this; } - public Properties canCaveCarve(boolean canCaveCarve) + public Properties cannotCarveCave() { - this.canCaveCarve = canCaveCarve; + this.canCaveCarve = false; return this; } } diff --git a/src/main/java/com/github/halotroop/litecraft/types/block/Blocks.java b/src/main/java/com/github/halotroop/litecraft/types/block/Blocks.java index 6d9443c..e2637c4 100644 --- a/src/main/java/com/github/halotroop/litecraft/types/block/Blocks.java +++ b/src/main/java/com/github/halotroop/litecraft/types/block/Blocks.java @@ -4,23 +4,14 @@ import com.github.halotroop.litecraft.types.block.Block.Properties; public final class Blocks { -<<<<<<< Upstream, based on branch 'liteCraft' of https://github.com/halotroop/Ginger3D.git - public static final Block AIR = new Block(new Properties("air").visible(false)); - public static final Block GRASS = new Block(new Properties("block/cubes/soil/grass/grass_top.png").canCaveCarve(true)); - public static final Block DIRT = new Block("block/cubes/soil/dirt.png", new Properties("dirt").canCaveCarve(true)); - public static final Block ANDESITE = new Block("block/cubes/stone/basic/andesite.png", new Properties("andesite").canCaveCarve(true)); - public static final Block DIORITE = new Block("block/cubes/stone/basic/diorite.png", new Properties("diorite").canCaveCarve(true)); - public static final Block GRANITE = new Block("block/cubes/stone/basic/granite.png", new Properties("granite").canCaveCarve(true)); - public static final Block GNEISS = new Block("block/cubes/stone/basic/gneiss.png", new Properties("gneiss").canCaveCarve(true)); - -======= - public static final Block AIR = new Block(new Properties("air").visible(false).fullCube(false)); + public static final Block AIR = new Block(new Properties("air").visible(false).fullCube(false).cannotCarveCave()); + public static final Block GRASS = new Block(new Properties("block/cubes/soil/grass/grass_top.png")); public static final Block DIRT = new Block("block/cubes/soil/dirt.png", new Properties("dirt")); public static final Block ANDESITE = new Block("block/cubes/stone/basic/andesite.png", new Properties("andesite")); public static final Block DIORITE = new Block("block/cubes/stone/basic/diorite.png", new Properties("diorite")); public static final Block GRANITE = new Block("block/cubes/stone/basic/granite.png", new Properties("granite")); public static final Block GNEISS = new Block("block/cubes/stone/basic/gneiss.png", new Properties("gneiss")); ->>>>>>> 56b16c1 Made chunks add blocks next to all non-full cubes to the render list + public static Block init() { return AIR; From 9c46f2a9b5ba6fd73e05c45910e99efbb2700963 Mon Sep 17 00:00:00 2001 From: halotroop2288 Date: Sat, 29 Feb 2020 18:12:15 -0800 Subject: [PATCH 5/5] Moved debug stuff --- .../github/halotroop/litecraft/Litecraft.java | 27 ++++--------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/github/halotroop/litecraft/Litecraft.java b/src/main/java/com/github/halotroop/litecraft/Litecraft.java index 95f7bba..5de4a52 100644 --- a/src/main/java/com/github/halotroop/litecraft/Litecraft.java +++ b/src/main/java/com/github/halotroop/litecraft/Litecraft.java @@ -71,23 +71,9 @@ public class Litecraft extends Game @Override public void render() { -<<<<<<< Upstream, based on branch 'liteCraft' of https://github.com/halotroop/Ginger3D.git fps += 1; // This section updates the debug stats once per real-time second, regardless of how many frames have been rendered if (System.currentTimeMillis() > frameTimer + 1000) - { - this.dbgStats.set(fps, ups, tps, threadWaitlist); - this.fps = 0; - this.ups = 0; - this.tps = 0; - this.frameTimer += 1000; - } - /** - * And now, the actual rendering: - */ -======= - fps+=1; updateDebugStats(); ->>>>>>> 4b249f6 Moved stuff around // Render shadows GingerRegister.getInstance().masterRenderer.renderShadowMap(data.entities, data.lights.get(0)); // If there's a world, render it! @@ -101,14 +87,11 @@ public class Litecraft extends Game // Updates the debug stats once per real-time second, regardless of how many frames have been rendered private void updateDebugStats() { - if (System.currentTimeMillis() > frameTimer + 1000) - { - this.dbgStats.set(fps, ups, tps, threadWaitlist); - this.fps=0; - this.ups=0; - this.tps=0; - this.frameTimer += 1000; - } + this.dbgStats.set(fps, ups, tps, threadWaitlist); + this.fps=0; + this.ups=0; + this.tps=0; + this.frameTimer += 1000; } public void update()