pull/12/head
parent
2156c6dee1
commit
8338801b13
|
@ -113,6 +113,7 @@ public class Litecraft extends Game
|
||||||
{
|
{
|
||||||
if (this.world != null)
|
if (this.world != null)
|
||||||
{
|
{
|
||||||
|
System.out.println("Saving chunks...");
|
||||||
this.world.unloadAllChunks();
|
this.world.unloadAllChunks();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
@ -102,7 +102,7 @@ public final class LitecraftSave
|
||||||
{
|
{
|
||||||
System.out.println("Exception in reading save data! This may be benign, merely an artifact of an update to the contents of the world save data.");
|
System.out.println("Exception in reading save data! This may be benign, merely an artifact of an update to the contents of the world save data.");
|
||||||
}
|
}
|
||||||
World world = new World(seed, 5, dim, this); // create new world with seed read from file or 0, if it could not be read
|
World world = new World(seed, RENDER_SIZE, dim, this); // create new world with seed read from file or 0, if it could not be read
|
||||||
world.spawnPlayer(playerX, playerY, playerZ); // spawn player in world
|
world.spawnPlayer(playerX, playerY, playerZ); // spawn player in world
|
||||||
return world;
|
return world;
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ public final class LitecraftSave
|
||||||
// If this fails the world seed will not be consistent across saves
|
// If this fails the world seed will not be consistent across saves
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
World world = new World(seed, 5, dim, this); // create new world with generated seed
|
World world = new World(seed, RENDER_SIZE, dim, this); // create new world with generated seed
|
||||||
world.spawnPlayer(); // spawn player in world
|
world.spawnPlayer(); // spawn player in world
|
||||||
return world;
|
return world;
|
||||||
}
|
}
|
||||||
|
@ -151,4 +151,5 @@ public final class LitecraftSave
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String SAVE_DIR = "./saves/";
|
private static final String SAVE_DIR = "./saves/";
|
||||||
|
private static final int RENDER_SIZE = 8;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,8 @@ public class World implements BlockAccess, WorldGenConstants
|
||||||
private final long seed;
|
private final long seed;
|
||||||
private final int dimension;
|
private final int dimension;
|
||||||
public Player player;
|
public Player player;
|
||||||
private final int renderSize;
|
private int renderBound;
|
||||||
|
private int renderBoundVertical;
|
||||||
private final BlockInstance dummy;
|
private final BlockInstance dummy;
|
||||||
|
|
||||||
public World(long seed, int renderSize, Dimension<?> dim, LitecraftSave save)
|
public World(long seed, int renderSize, Dimension<?> dim, LitecraftSave save)
|
||||||
|
@ -40,7 +41,10 @@ public class World implements BlockAccess, WorldGenConstants
|
||||||
this.genBlockAccess = new GenerationWorld(this);
|
this.genBlockAccess = new GenerationWorld(this);
|
||||||
this.save = save;
|
this.save = save;
|
||||||
this.dimension = dim.id;
|
this.dimension = dim.id;
|
||||||
this.renderSize = renderSize;
|
this.renderBound = renderSize / 2;
|
||||||
|
this.renderBoundVertical = this.renderBound / 2;
|
||||||
|
if (this.renderBoundVertical < 2)
|
||||||
|
this.renderBoundVertical = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int findAir(int x, int z)
|
public int findAir(int x, int z)
|
||||||
|
@ -177,13 +181,13 @@ public class World implements BlockAccess, WorldGenConstants
|
||||||
|
|
||||||
public static final int SEA_LEVEL = 0;
|
public static final int SEA_LEVEL = 0;
|
||||||
|
|
||||||
public void updateLoadedChunks(int newChunkX, int newChunkY, int newChunkZ)
|
public void updateLoadedChunks(int chunkX, int chunkY, int chunkZ)
|
||||||
{
|
{
|
||||||
List<Chunk> toKeep = new ArrayList<>();
|
List<Chunk> toKeep = new ArrayList<>();
|
||||||
// loop over rendered area, adding chunks that are needed
|
// loop over rendered area, adding chunks that are needed
|
||||||
for (int x = -renderSize / 2; x < renderSize / 2; x++)
|
for (int x = chunkX - this.renderBound; x < chunkX + this.renderBound; x++)
|
||||||
for (int z = -renderSize / 2; z < renderSize / 2; z++)
|
for (int z = chunkZ - this.renderBound; z < chunkZ + this.renderBound; z++)
|
||||||
for (int y = -2; y < 1; ++y)
|
for (int y = chunkY - this.renderBoundVertical; y < chunkY + this.renderBoundVertical; y++)
|
||||||
toKeep.add(this.getChunkToLoad(x, y, z));
|
toKeep.add(this.getChunkToLoad(x, y, z));
|
||||||
// list of keys to remove
|
// list of keys to remove
|
||||||
LongList toRemove = new LongArrayList();
|
LongList toRemove = new LongArrayList();
|
||||||
|
|
Loading…
Reference in New Issue