From 53d5ff873d1a30ee32638e03c6e16bb08c1fb909 Mon Sep 17 00:00:00 2001 From: halotroop2288 Date: Tue, 25 Feb 2020 20:04:22 -0800 Subject: [PATCH] Misc stuff Deprecated old terrain Removed some unused stuff --- .../github/halotroop/litecraft/Litecraft.java | 3 ++- .../litecraft/types/block/Block.java | 22 ++++++++++++++++--- .../halotroop/litecraft/world/Chunk.java | 2 +- .../halotroop/litecraft/world/World.java | 8 +++++++ .../java/com/github/hydos/ginger/Starter.java | 10 ++++++++- .../hydos/ginger/engine/api/Ginger.java | 4 ++-- .../engine/elements/objects/Player.java | 4 ---- .../github/hydos/ginger/engine/io/Window.java | 1 - .../hydos/ginger/engine/terrain/Terrain.java | 1 + 9 files changed, 42 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/github/halotroop/litecraft/Litecraft.java b/src/main/java/com/github/halotroop/litecraft/Litecraft.java index e466e53..88c6ffa 100644 --- a/src/main/java/com/github/halotroop/litecraft/Litecraft.java +++ b/src/main/java/com/github/halotroop/litecraft/Litecraft.java @@ -22,7 +22,6 @@ public class Litecraft extends Game { private World world; private Ginger ginger3D; - private boolean isInWorld = false; //temp stuff to test out fbo fixes int oldWindowWidth = Window.width; @@ -96,7 +95,9 @@ public class Litecraft extends Game Window.lockMouse(); playButton.hide(data.guis); if (world == null) + { world = new World((long) new Random().nextInt(), 10); + } } } } \ No newline at end of file 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 e4bd256..ba38319 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 @@ -8,20 +8,33 @@ public class Block public static class Properties { // add properties to this builder! private boolean visible = true; + private boolean fullCube = true; public Properties visible(boolean visible) { this.visible = visible; return this; } + + public Properties fullCube(boolean fullCube) + { + this.fullCube = fullCube; + return this; + } + + public boolean isFullCube() + { return fullCube; } + + public boolean isVisible() + { return visible; } } - public static final Block AIR = new Block((TexturedModel) null, new Properties().visible(false)); - - public static final Block GRASS = new Block("block/cubes/soil/gravel.png", new Properties()); + public static final Block AIR = new Block(new Properties().visible(false)); public static final Block DIRT = new Block("block/cubes/soil/dirt.png", new Properties()); + public static final Block STONE = new Block("block/cubes/stone/cobblestone.png", new Properties()); public final TexturedModel model; public final boolean visible; + protected Block(String texture, Properties properties) { this(ModelLoader.loadGenericCube(texture), properties); } @@ -30,4 +43,7 @@ public class Block this.model = model; this.visible = properties.visible; } + + protected Block(Properties properties) + { this((TexturedModel) null, properties); } } 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 f6ffa5c..61f6638 100644 --- a/src/main/java/com/github/halotroop/litecraft/world/Chunk.java +++ b/src/main/java/com/github/halotroop/litecraft/world/Chunk.java @@ -97,7 +97,7 @@ public class Chunk implements BlockAccess for (int x = 0; x < CHUNK_SIZE; ++x) { for (int z = 0; z < CHUNK_SIZE; ++z) { for (int y = 0; y < CHUNK_SIZE; ++y) { - result.setBlock(x, y, z, y == 7 ? Block.GRASS : Block.DIRT); + result.setBlock(x, y, z, y == 7 ? Block.DIRT : Block.STONE); } } } 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 9418e54..a613656 100644 --- a/src/main/java/com/github/halotroop/litecraft/world/World.java +++ b/src/main/java/com/github/halotroop/litecraft/world/World.java @@ -1,6 +1,10 @@ package com.github.halotroop.litecraft.world; import com.github.halotroop.litecraft.types.block.Block; +import com.github.hydos.ginger.engine.elements.objects.Player; +import com.github.hydos.ginger.engine.math.vectors.Vector3f; +import com.github.hydos.ginger.engine.obj.ModelLoader; +import com.github.hydos.ginger.engine.render.models.TexturedModel; import com.github.hydos.ginger.engine.render.renderers.ObjectRenderer; import it.unimi.dsi.fastutil.longs.*; @@ -8,6 +12,7 @@ import it.unimi.dsi.fastutil.longs.*; public class World implements BlockAccess { private final Long2ObjectMap chunks; + public Player player; public World(long seed, int size) { @@ -16,6 +21,9 @@ public class World implements BlockAccess for (int i = (0 - (size/2)); i < (size/2); i++) for (int k = (0 - (size/2)); k < (size/2); k++) this.getChunk(i, -1, k).setRender(true); + + TexturedModel dirtModel = ModelLoader.loadGenericCube("block/cubes/soil/dirt.png"); + this.player = new Player(dirtModel, new Vector3f(0, 0, -3), 0, 180f, 0, new Vector3f(0.2f, 0.2f, 0.2f)); } public Chunk getChunk(int chunkX, int chunkY, int chunkZ) diff --git a/src/main/java/com/github/hydos/ginger/Starter.java b/src/main/java/com/github/hydos/ginger/Starter.java index 4dfcaf1..ad5694c 100644 --- a/src/main/java/com/github/hydos/ginger/Starter.java +++ b/src/main/java/com/github/hydos/ginger/Starter.java @@ -1,10 +1,18 @@ package com.github.hydos.ginger; +import org.lwjgl.Version; +import org.lwjgl.glfw.GLFW; + import com.github.halotroop.litecraft.Litecraft; public class Starter { // private static final boolean usingEclipse = false; public static void main(String[] args) - { new Litecraft(); } + { + System.out.println("GLFW version: " + GLFW.glfwGetVersionString()); + System.out.println("LWJGL version: " + Version.getVersion()); + // Put SoundSystem version here + new Litecraft(); + } } 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 2e5c94f..b8a9e14 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 @@ -54,9 +54,9 @@ public class Ginger return button; } - public GUIText registerText(String string, int textSize, Vector2f vector2f, float maxLineLength, boolean centered, String id) + public GUIText registerText(String string, int textSize, Vector2f position, float maxLineLength, boolean centered, String id) { - GUIText text = new GUIText(string, textSize, globalFont, vector2f, maxLineLength, false); + GUIText text = new GUIText(string, textSize, globalFont, position, maxLineLength, false); text.textID = id; gingerRegister.registerText(text); return text; diff --git a/src/main/java/com/github/hydos/ginger/engine/elements/objects/Player.java b/src/main/java/com/github/hydos/ginger/engine/elements/objects/Player.java index 0a8469f..fd9bde3 100644 --- a/src/main/java/com/github/hydos/ginger/engine/elements/objects/Player.java +++ b/src/main/java/com/github/hydos/ginger/engine/elements/objects/Player.java @@ -5,7 +5,6 @@ import org.lwjgl.glfw.GLFW; import com.github.hydos.ginger.engine.io.Window; import com.github.hydos.ginger.engine.math.vectors.Vector3f; import com.github.hydos.ginger.engine.render.models.TexturedModel; -import com.github.hydos.ginger.engine.terrain.Terrain; import com.github.hydos.ginger.main.settings.Constants; public class Player extends RenderObject @@ -42,9 +41,6 @@ public class Player extends RenderObject { jump(); } - else - { - } } private void jump() diff --git a/src/main/java/com/github/hydos/ginger/engine/io/Window.java b/src/main/java/com/github/hydos/ginger/engine/io/Window.java index bf75838..b333ea7 100644 --- a/src/main/java/com/github/hydos/ginger/engine/io/Window.java +++ b/src/main/java/com/github/hydos/ginger/engine/io/Window.java @@ -16,7 +16,6 @@ public class Window private static String title; public static long window; private static Vector3f backgroundColour = new Vector3f(0.2f, 0.2f, 0.2f); - private static boolean[] keys = new boolean[GLFW.GLFW_KEY_LAST]; private static boolean[] mouseButtons = new boolean[GLFW.GLFW_MOUSE_BUTTON_LAST]; private static GLFWImage.Buffer iconBuffer = null; private static double fpsCap, time, processedTime = 0; diff --git a/src/main/java/com/github/hydos/ginger/engine/terrain/Terrain.java b/src/main/java/com/github/hydos/ginger/engine/terrain/Terrain.java index 3dd9d37..138fd43 100644 --- a/src/main/java/com/github/hydos/ginger/engine/terrain/Terrain.java +++ b/src/main/java/com/github/hydos/ginger/engine/terrain/Terrain.java @@ -11,6 +11,7 @@ import com.github.hydos.ginger.engine.render.models.RawModel; import com.github.hydos.ginger.engine.utils.Loader; import com.github.hydos.ginger.main.settings.Constants; +@Deprecated public class Terrain { private static final float MAX_PIXEL_COLOUR = 256 * 256 * 256;