Add the ability to select and deselect worlds
This commit is contained in:
@@ -9,33 +9,56 @@ import net.minecraft.world.DimensionType;
|
|||||||
* This stores all LODs for a given world.
|
* This stores all LODs for a given world.
|
||||||
*
|
*
|
||||||
* @author James Seibel
|
* @author James Seibel
|
||||||
* @version 02-22-2021
|
* @version 03-31-2021
|
||||||
*/
|
*/
|
||||||
public class LodWorld
|
public class LodWorld
|
||||||
{
|
{
|
||||||
public String worldName;
|
private String worldName;
|
||||||
|
|
||||||
/**
|
|
||||||
* Key = Dimension id (as an int)
|
|
||||||
*/
|
|
||||||
private Map<DimensionType, LodDimension> lodDimensions;
|
private Map<DimensionType, LodDimension> lodDimensions;
|
||||||
|
|
||||||
|
|
||||||
public LodWorld(String newWorldName)
|
public LodWorld()
|
||||||
|
{
|
||||||
|
worldName = "No world loaded";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set up the LodWorld with the given newWorldName. <br>
|
||||||
|
* This should be done whenever loading a new world.
|
||||||
|
* @param newWorldName
|
||||||
|
*/
|
||||||
|
public void selectWorld(String newWorldName)
|
||||||
{
|
{
|
||||||
worldName = newWorldName;
|
worldName = newWorldName;
|
||||||
lodDimensions = new Hashtable<DimensionType, LodDimension>();
|
lodDimensions = new Hashtable<DimensionType, LodDimension>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the worldName to "No world loaded"
|
||||||
|
* and clear the lodDimensions Map. <br>
|
||||||
|
* This should be done whenever unloaded a world.
|
||||||
|
*/
|
||||||
|
public void deselectWorld()
|
||||||
|
{
|
||||||
|
worldName = "No world loaded";
|
||||||
|
lodDimensions = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void addLodDimension(LodDimension newStorage)
|
public void addLodDimension(LodDimension newStorage)
|
||||||
{
|
{
|
||||||
|
if (lodDimensions == null)
|
||||||
|
throw new IllegalStateException("LodWorld hasn't been given a world yet.");
|
||||||
|
|
||||||
lodDimensions.put(newStorage.dimension, newStorage);
|
lodDimensions.put(newStorage.dimension, newStorage);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LodDimension getLodDimension(DimensionType dimension)
|
public LodDimension getLodDimension(DimensionType dimension)
|
||||||
{
|
{
|
||||||
|
if (lodDimensions == null)
|
||||||
|
throw new IllegalStateException("LodWorld hasn't been given a world yet.");
|
||||||
|
|
||||||
return lodDimensions.get(dimension);
|
return lodDimensions.get(dimension);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,21 +68,23 @@ public class LodWorld
|
|||||||
*/
|
*/
|
||||||
public void resizeDimensionRegionWidth(int newWidth)
|
public void resizeDimensionRegionWidth(int newWidth)
|
||||||
{
|
{
|
||||||
|
if (lodDimensions == null)
|
||||||
|
throw new IllegalStateException("LodWorld hasn't been given a world yet.");
|
||||||
|
|
||||||
for(DimensionType key : lodDimensions.keySet())
|
for(DimensionType key : lodDimensions.keySet())
|
||||||
lodDimensions.get(key).setRegionWidth(newWidth);
|
lodDimensions.get(key).setRegionWidth(newWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public String getWorldName()
|
||||||
|
{
|
||||||
|
return worldName;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
String s = "";
|
return "World name: " + worldName;
|
||||||
|
|
||||||
s += worldName + "\t - dimensions: ";
|
|
||||||
for(DimensionType key : lodDimensions.keySet())
|
|
||||||
s += lodDimensions.get(key).dimension.toString() + ", ";
|
|
||||||
|
|
||||||
return s;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user