Improve how a unloaded LodWorld is handled

This commit is contained in:
James Seibel
2021-04-01 13:13:14 -05:00
parent 5ca5764c0e
commit cb50f24c86
3 changed files with 13 additions and 6 deletions
@@ -27,7 +27,7 @@ import net.minecraft.world.server.ServerWorld;
* (specifically: Lod World, Dimension, Region, and Chunk objects)
*
* @author James Seibel
* @version 3-27-2021
* @version 4-01-2021
*/
public class LodBuilder
{
@@ -59,7 +59,7 @@ public class LodBuilder
public void generateLodChunkAsync(IChunk chunk, LodWorld lodWorld, DimensionType dim)
{
if (lodWorld == null)
if (lodWorld == null || !lodWorld.getIsWorldLoaded())
return;
// is this chunk from the same world as the lodWorld?
@@ -9,14 +9,15 @@ import net.minecraft.world.DimensionType;
* This stores all LODs for a given world.
*
* @author James Seibel
* @version 03-31-2021
* @version 04-01-2021
*/
public class LodWorld
{
private String worldName;
private Map<DimensionType, LodDimension> lodDimensions;
/** If true then the LOD world is setup and ready to use */
private boolean isWorldLoaded = false;
public LodWorld()
{
@@ -32,6 +33,7 @@ public class LodWorld
{
worldName = newWorldName;
lodDimensions = new Hashtable<DimensionType, LodDimension>();
isWorldLoaded = true;
}
/**
@@ -43,6 +45,7 @@ public class LodWorld
{
worldName = "No world loaded";
lodDimensions = null;
isWorldLoaded = false;
}
@@ -76,6 +79,10 @@ public class LodWorld
}
public boolean getIsWorldLoaded()
{
return isWorldLoaded;
}
public String getWorldName()
{
@@ -22,7 +22,7 @@ import net.minecraftforge.eventbus.api.SubscribeEvent;
* and is the starting point for most of this program.
*
* @author James_Seibel
* @version 03-31-2021
* @version 04-01-2021
*/
public class ClientProxy
{
@@ -64,7 +64,7 @@ public class ClientProxy
}
if (mc == null || mc.player == null || lodWorld == null)
if (mc == null || mc.player == null || !lodWorld.getIsWorldLoaded())
return;
LodDimension lodDim = lodWorld.getLodDimension(mc.player.world.getDimensionType());