Made chunks add blocks next to all non-full cubes to the render list

Instead of just ones that are next to air.
pull/12/head
Caroline Bell 2020-02-29 17:53:11 -08:00
parent 5853595fee
commit 804dc2471e
2 changed files with 15 additions and 14 deletions

View File

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

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