Fix chunks not generating out of view range when changing worlds
This commit is contained in:
@@ -46,7 +46,7 @@ public class LodBufferBuilder
|
|||||||
/** If this is greater than 0 no new chunk generation requests will be made
|
/** 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
|
* this is to prevent chunks from being generated for a long time in an area
|
||||||
* the player is no longer in. */
|
* the player is no longer in. */
|
||||||
public int numChunksWaitingToGen = 0;
|
public int numberOfChunksWaitingToGenerate = 0;
|
||||||
|
|
||||||
/** how many chunks to generate outside of the player's
|
/** how many chunks to generate outside of the player's
|
||||||
* view distance at one time. (or more specifically how
|
* 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
|
// generate a new chunk if no chunk currently exists
|
||||||
// and we aren't waiting on any other chunks to generate
|
// 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);
|
ChunkPos pos = new ChunkPos(chunkX, chunkZ);
|
||||||
|
|
||||||
@@ -208,7 +208,7 @@ public class LodBufferBuilder
|
|||||||
if(chunkPos == null)
|
if(chunkPos == null)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
numChunksWaitingToGen++;
|
numberOfChunksWaitingToGenerate++;
|
||||||
|
|
||||||
LodChunkGenWorker genWorker = new LodChunkGenWorker(chunkPos, renderer, lodBuilder, this, lodDim);
|
LodChunkGenWorker genWorker = new LodChunkGenWorker(chunkPos, renderer, lodBuilder, this, lodDim);
|
||||||
WorldWorkerManager.addWorker(genWorker);
|
WorldWorkerManager.addWorker(genWorker);
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ public class LodChunkGenWorker implements IWorker
|
|||||||
// System.out.println("Out of range " + x + " " + z);
|
// System.out.println("Out of range " + x + " " + z);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
lodBufferBuilder.numChunksWaitingToGen--;
|
lodBufferBuilder.numberOfChunksWaitingToGenerate--;
|
||||||
|
|
||||||
pos = null;
|
pos = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.backsun.lod.proxy;
|
package com.backsun.lod.proxy;
|
||||||
|
|
||||||
|
import com.backsun.lod.builders.LodBufferBuilder;
|
||||||
import com.backsun.lod.builders.LodBuilder;
|
import com.backsun.lod.builders.LodBuilder;
|
||||||
import com.backsun.lod.objects.LodChunk;
|
import com.backsun.lod.objects.LodChunk;
|
||||||
import com.backsun.lod.objects.LodDimension;
|
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.
|
* and is the starting point for most of this program.
|
||||||
*
|
*
|
||||||
* @author James_Seibel
|
* @author James_Seibel
|
||||||
* @version 04-01-2021
|
* @version 05-29-2021
|
||||||
*/
|
*/
|
||||||
public class ClientProxy
|
public class ClientProxy
|
||||||
{
|
{
|
||||||
private static LodWorld lodWorld = new LodWorld();
|
private static LodWorld lodWorld = new LodWorld();
|
||||||
private static LodBuilder lodBuilder = new LodBuilder();
|
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();
|
Minecraft mc = Minecraft.getInstance();
|
||||||
|
|
||||||
@@ -112,11 +114,14 @@ public class ClientProxy
|
|||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
public void worldUnloadEvent(WorldEvent.Unload event)
|
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)
|
if(mc.getConnection().getWorld() == null)
|
||||||
|
{
|
||||||
|
lodBufferBuilder.numberOfChunksWaitingToGenerate = 0;
|
||||||
// the player has disconnected from a server
|
// the player has disconnected from a server
|
||||||
lodWorld.deselectWorld();
|
lodWorld.deselectWorld();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user