the crashes in this chunloading are not the loading, but RENDERING??!?!?!?!
parent
56d8c65e0e
commit
7e16f40504
|
@ -57,7 +57,7 @@ public class Chunk implements BlockAccess, WorldGenConstants, DataStorage
|
|||
return blocks[index(x, y, z)];
|
||||
}
|
||||
|
||||
public BlockInstance getBlockEntity(int x, int y, int z)
|
||||
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!"); }
|
||||
|
@ -78,16 +78,16 @@ public class Chunk implements BlockAccess, WorldGenConstants, DataStorage
|
|||
{
|
||||
for (int z = 0; z < CHUNK_SIZE; z++)
|
||||
{
|
||||
BlockInstance block = getBlockEntity(x, y, z);
|
||||
BlockInstance block = getBlockInstance(x, y, z);
|
||||
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
|
||||
if (getBlockEntity(x - 1, y, z).getModel() == null || getBlockEntity(x + 1, y, z).getModel() == null ||
|
||||
getBlockEntity(x, y - 1, z).getModel() == null || getBlockEntity(x, y + 1, z).getModel() == null ||
|
||||
getBlockEntity(x, y, z - 1).getModel() == null || getBlockEntity(x, y, z + 1).getModel() == null)
|
||||
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; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,9 +27,12 @@ public class World implements BlockAccess, WorldGenConstants
|
|||
private final int dimension;
|
||||
public Player player;
|
||||
private final int renderSize;
|
||||
private final BlockInstance dummy;
|
||||
|
||||
public World(long seed, int renderSize, Dimension<?> dim, LitecraftSave save)
|
||||
{
|
||||
this.dummy = new BlockInstance(Blocks.ANDESITE, new Vector3f(0, 0, 0));
|
||||
this.dummy.isVisible = false;
|
||||
this.chunks = new Long2ObjectArrayMap<>();
|
||||
this.seed = seed;
|
||||
this.chunkGenerator = dim.createChunkGenerator(seed);
|
||||
|
@ -152,14 +155,10 @@ public class World implements BlockAccess, WorldGenConstants
|
|||
|
||||
public void render(BlockRenderer blockRenderer)
|
||||
{
|
||||
Chunk chunk = getChunk(0, -1, 0);
|
||||
if (chunk != null)
|
||||
{
|
||||
blockRenderer.prepareModel(chunk.getBlockEntity(0, 0, 0).getModel());
|
||||
blockRenderer.prepareModel(this.dummy.getModel());
|
||||
this.chunks.forEach((pos, c) -> c.render(blockRenderer));
|
||||
blockRenderer.unbindModel();
|
||||
}
|
||||
}
|
||||
|
||||
public void unloadAllChunks()
|
||||
{
|
||||
|
@ -184,7 +183,7 @@ public class World implements BlockAccess, WorldGenConstants
|
|||
// loop over rendered area, adding chunks that are needed
|
||||
for (int x = -renderSize / 2; x < renderSize / 2; x++)
|
||||
for (int z = -renderSize / 2; z < renderSize / 2; z++)
|
||||
for (int y = -2; y < 2; ++y)
|
||||
for (int y = -2; y < 1; ++y)
|
||||
toKeep.add(this.getChunkToLoad(x, y, z));
|
||||
// list of keys to remove
|
||||
LongList toRemove = new LongArrayList();
|
||||
|
|
Loading…
Reference in New Issue