Fix chunks not generating out of view range when changing worlds

This commit is contained in:
James Seibel
2021-05-29 13:22:48 -05:00
parent 9fe6be10f6
commit 7e4f3a3185
3 changed files with 12 additions and 7 deletions
@@ -46,7 +46,7 @@ public class LodBufferBuilder
/** If this is greater than 0 no new chunk generation requests will be made
* this is to prevent chunks from being generated for a long time in an area
* the player is no longer in. */
public int numChunksWaitingToGen = 0;
public int numberOfChunksWaitingToGenerate = 0;
/** how many chunks to generate outside of the player's
* view distance at one time. (or more specifically how
@@ -147,7 +147,7 @@ public class LodBufferBuilder
{
// generate a new chunk if no chunk currently exists
// and we aren't waiting on any other chunks to generate
if (lod == null && numChunksWaitingToGen == 0)
if (lod == null && numberOfChunksWaitingToGenerate == 0)
{
ChunkPos pos = new ChunkPos(chunkX, chunkZ);
@@ -208,7 +208,7 @@ public class LodBufferBuilder
if(chunkPos == null)
break;
numChunksWaitingToGen++;
numberOfChunksWaitingToGenerate++;
LodChunkGenWorker genWorker = new LodChunkGenWorker(chunkPos, renderer, lodBuilder, this, lodDim);
WorldWorkerManager.addWorker(genWorker);
@@ -80,7 +80,7 @@ public class LodChunkGenWorker implements IWorker
// System.out.println("Out of range " + x + " " + z);
//}
lodBufferBuilder.numChunksWaitingToGen--;
lodBufferBuilder.numberOfChunksWaitingToGenerate--;
pos = null;
}
@@ -1,5 +1,6 @@
package com.backsun.lod.proxy;
import com.backsun.lod.builders.LodBufferBuilder;
import com.backsun.lod.builders.LodBuilder;
import com.backsun.lod.objects.LodChunk;
import com.backsun.lod.objects.LodDimension;
@@ -19,13 +20,14 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
* and is the starting point for most of this program.
*
* @author James_Seibel
* @version 04-01-2021
* @version 05-29-2021
*/
public class ClientProxy
{
private static LodWorld lodWorld = new LodWorld();
private static LodBuilder lodBuilder = new LodBuilder();
private static LodRenderer renderer = new LodRenderer(lodBuilder);
private static LodBufferBuilder lodBufferBuilder = new LodBufferBuilder(lodBuilder);
private static LodRenderer renderer = new LodRenderer(lodBufferBuilder);
Minecraft mc = Minecraft.getInstance();
@@ -112,11 +114,14 @@ public class ClientProxy
@SubscribeEvent
public void worldUnloadEvent(WorldEvent.Unload event)
{
// the player just loaded a new world/dimension
// the player just unloaded a world/dimension
if(mc.getConnection().getWorld() == null)
{
lodBufferBuilder.numberOfChunksWaitingToGenerate = 0;
// the player has disconnected from a server
lodWorld.deselectWorld();
}
}