Merge branch 'liteCraft' into worldgen

pull/12/head
valoeghese 2020-03-01 16:09:07 +13:00
commit eeb514fab0
5 changed files with 35 additions and 45 deletions

View File

@ -73,16 +73,7 @@ public class Litecraft extends Game
{
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:
*/
updateDebugStats();
// Render shadows
GingerRegister.getInstance().masterRenderer.renderShadowMap(data.entities, data.lights.get(0));
// If there's a world, render it!
@ -93,9 +84,21 @@ 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()
{
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()
@ -135,16 +138,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()
{

View File

@ -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;
}
}

View File

@ -4,13 +4,13 @@ import com.github.halotroop.litecraft.types.block.Block.Properties;
public final class Blocks
{
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).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"));
public static Block init()
{

View File

@ -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);
}

View File

@ -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);