@@ -185,7 +185,7 @@ public class EventHookContainer
|
|||||||
{
|
{
|
||||||
if (event.world.provider.dimensionId == 0)
|
if (event.world.provider.dimensionId == 0)
|
||||||
{
|
{
|
||||||
PocketManager.save();
|
PocketManager.save(true);
|
||||||
|
|
||||||
if (mod_pocketDim.deathTracker != null && mod_pocketDim.deathTracker.isModified())
|
if (mod_pocketDim.deathTracker != null && mod_pocketDim.deathTracker.isModified())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -130,6 +130,7 @@ public abstract class NewDimData
|
|||||||
protected Point4D origin;
|
protected Point4D origin;
|
||||||
protected int orientation;
|
protected int orientation;
|
||||||
protected DungeonData dungeon;
|
protected DungeonData dungeon;
|
||||||
|
protected boolean modified;
|
||||||
public IUpdateWatcher<ClientLinkData> linkWatcher;
|
public IUpdateWatcher<ClientLinkData> linkWatcher;
|
||||||
|
|
||||||
protected NewDimData(int id, NewDimData parent, boolean isPocket, boolean isDungeon,
|
protected NewDimData(int id, NewDimData parent, boolean isPocket, boolean isDungeon,
|
||||||
@@ -157,6 +158,7 @@ public abstract class NewDimData
|
|||||||
this.origin = null;
|
this.origin = null;
|
||||||
this.dungeon = null;
|
this.dungeon = null;
|
||||||
this.linkWatcher = linkWatcher;
|
this.linkWatcher = linkWatcher;
|
||||||
|
this.modified = true;
|
||||||
|
|
||||||
//Register with parent
|
//Register with parent
|
||||||
if (parent != null)
|
if (parent != null)
|
||||||
@@ -165,6 +167,7 @@ public abstract class NewDimData
|
|||||||
this.root = parent.root;
|
this.root = parent.root;
|
||||||
this.depth = parent.depth + 1;
|
this.depth = parent.depth + 1;
|
||||||
parent.children.add(this);
|
parent.children.add(this);
|
||||||
|
parent.modified = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -288,6 +291,7 @@ public abstract class NewDimData
|
|||||||
{
|
{
|
||||||
return Math.abs(i) + Math.abs(j) + Math.abs(k);
|
return Math.abs(i) + Math.abs(j) + Math.abs(k);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DimLink createLink(int x, int y, int z, int linkType, int orientation)
|
public DimLink createLink(int x, int y, int z, int linkType, int orientation)
|
||||||
{
|
{
|
||||||
return createLink(new Point4D(x, y, z, id), linkType, orientation);
|
return createLink(new Point4D(x, y, z, id), linkType, orientation);
|
||||||
@@ -307,6 +311,8 @@ public abstract class NewDimData
|
|||||||
{
|
{
|
||||||
link.overwrite(linkType, orientation);
|
link.overwrite(linkType, orientation);
|
||||||
}
|
}
|
||||||
|
modified = true;
|
||||||
|
|
||||||
//Link created!
|
//Link created!
|
||||||
if (linkType != LinkTypes.CLIENT_SIDE)
|
if (linkType != LinkTypes.CLIENT_SIDE)
|
||||||
{
|
{
|
||||||
@@ -348,6 +354,7 @@ public abstract class NewDimData
|
|||||||
linkWatcher.onCreated(link.link);
|
linkWatcher.onCreated(link.link);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
modified = true;
|
||||||
return link;
|
return link;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -364,6 +371,7 @@ public abstract class NewDimData
|
|||||||
//Raise deletion event
|
//Raise deletion event
|
||||||
linkWatcher.onDeleted(target.link);
|
linkWatcher.onDeleted(target.link);
|
||||||
target.clear();
|
target.clear();
|
||||||
|
modified = true;
|
||||||
}
|
}
|
||||||
return (target != null);
|
return (target != null);
|
||||||
}
|
}
|
||||||
@@ -418,6 +426,7 @@ public abstract class NewDimData
|
|||||||
public void setFilled(boolean isFilled)
|
public void setFilled(boolean isFilled)
|
||||||
{
|
{
|
||||||
this.isFilled = isFilled;
|
this.isFilled = isFilled;
|
||||||
|
this.modified = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int id()
|
public int id()
|
||||||
@@ -499,16 +508,19 @@ public abstract class NewDimData
|
|||||||
this.orientation = orientation;
|
this.orientation = orientation;
|
||||||
this.dungeon = dungeon;
|
this.dungeon = dungeon;
|
||||||
this.packDepth = calculatePackDepth(parent, dungeon);
|
this.packDepth = calculatePackDepth(parent, dungeon);
|
||||||
|
this.modified = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* effectivly moves the dungeon to the 'top' of a chain as far as dungeon generation is concerend.
|
* Effectively moves the dungeon to the 'top' of a chain as far as dungeon generation is concerned.
|
||||||
*/
|
*/
|
||||||
public void setParentToRoot()
|
public void setParentToRoot()
|
||||||
{
|
{
|
||||||
this.depth = 1;
|
this.depth = 1;
|
||||||
this.parent = this.root;
|
this.parent = this.root;
|
||||||
this.root.children.add(this);
|
this.root.children.add(this);
|
||||||
|
this.root.modified = true;
|
||||||
|
this.modified = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int calculatePackDepth(NewDimData parent, DungeonData current)
|
public static int calculatePackDepth(NewDimData parent, DungeonData current)
|
||||||
@@ -557,12 +569,14 @@ public abstract class NewDimData
|
|||||||
setDestination(incoming, originX, originY, originZ);
|
setDestination(incoming, originX, originY, originZ);
|
||||||
this.origin = incoming.destination();
|
this.origin = incoming.destination();
|
||||||
this.orientation = orientation;
|
this.orientation = orientation;
|
||||||
|
this.modified = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDestination(DimLink incoming, int x, int y, int z)
|
public void setDestination(DimLink incoming, int x, int y, int z)
|
||||||
{
|
{
|
||||||
InnerDimLink link = (InnerDimLink) incoming;
|
InnerDimLink link = (InnerDimLink) incoming;
|
||||||
link.setDestination(x, y, z, this);
|
link.setDestination(x, y, z, this);
|
||||||
|
this.modified = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DimLink getRandomLink()
|
public DimLink getRandomLink()
|
||||||
@@ -581,6 +595,16 @@ public abstract class NewDimData
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isModified()
|
||||||
|
{
|
||||||
|
return modified;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearModified()
|
||||||
|
{
|
||||||
|
this.modified = false;
|
||||||
|
}
|
||||||
|
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
return "DimID= " + this.id;
|
return "DimID= " + this.id;
|
||||||
|
|||||||
@@ -446,7 +446,7 @@ public class PocketManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void save()
|
public static void save(boolean checkModified)
|
||||||
{
|
{
|
||||||
if (!isLoaded)
|
if (!isLoaded)
|
||||||
{
|
{
|
||||||
@@ -466,7 +466,7 @@ public class PocketManager
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DDSaveHandler.saveAll(dimensionData.values(), dimensionIDBlackList);
|
DDSaveHandler.saveAll(dimensionData.values(), dimensionIDBlackList, checkModified);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@@ -627,7 +627,7 @@ public class PocketManager
|
|||||||
throw new IllegalStateException("Pocket dimensions have already been unloaded!");
|
throw new IllegalStateException("Pocket dimensions have already been unloaded!");
|
||||||
}
|
}
|
||||||
|
|
||||||
save();
|
save(false);
|
||||||
unregisterPockets();
|
unregisterPockets();
|
||||||
dimensionData = null;
|
dimensionData = null;
|
||||||
rootDimensions = null;
|
rootDimensions = null;
|
||||||
|
|||||||
@@ -239,29 +239,39 @@ public class DDSaveHandler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean saveAll(Iterable<? extends IPackable<PackedDimData>> dimensions, List<Integer> blacklist) throws IOException
|
public static boolean saveAll(Iterable<? extends IPackable<PackedDimData>> dimensions,
|
||||||
|
List<Integer> blacklist, boolean checkModified) throws IOException
|
||||||
{
|
{
|
||||||
// Create the data directory for our dimensions
|
|
||||||
// Don't catch exceptions here. If we can't create this folder,
|
|
||||||
// the mod should crash to let the user know early on.
|
|
||||||
|
|
||||||
// Get the save directory path
|
// Get the save directory path
|
||||||
File saveDirectory = new File(DimensionManager.getCurrentSaveRootDirectory() + "/DimensionalDoors/data/");
|
File saveDirectory = new File(DimensionManager.getCurrentSaveRootDirectory() + "/DimensionalDoors/data/");
|
||||||
String savePath = saveDirectory.getAbsolutePath();
|
String savePath = saveDirectory.getAbsolutePath();
|
||||||
|
|
||||||
// Create the save directory
|
// Create the save directory
|
||||||
|
// Don't catch exceptions here. If we can't create this folder,
|
||||||
|
// then the mod should crash to let the user know early on.
|
||||||
Files.createParentDirs(saveDirectory);
|
Files.createParentDirs(saveDirectory);
|
||||||
saveDirectory.mkdir();
|
saveDirectory.mkdir();
|
||||||
|
|
||||||
// Create and write the blackList
|
// Create and write the blackList
|
||||||
writeBlacklist(blacklist, savePath);
|
writeBlacklist(blacklist, savePath);
|
||||||
|
|
||||||
// Write the dimension save data, and remove the ones we save from the mapping
|
// Write the dimension save data
|
||||||
boolean succeeded = true;
|
boolean succeeded = true;
|
||||||
DimDataProcessor writer = new DimDataProcessor();
|
DimDataProcessor writer = new DimDataProcessor();
|
||||||
for (IPackable<PackedDimData> dimension : dimensions)
|
for (IPackable<PackedDimData> dimension : dimensions)
|
||||||
{
|
{
|
||||||
succeeded &= writeDimension(dimension, writer, savePath + "/dim_");
|
// Check if the dimension should be saved
|
||||||
|
if (!checkModified || dimension.isModified())
|
||||||
|
{
|
||||||
|
if (writeDimension(dimension, writer, savePath + "/dim_"))
|
||||||
|
{
|
||||||
|
dimension.clearModified();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
succeeded = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return succeeded;
|
return succeeded;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,4 +4,6 @@ public interface IPackable<T>
|
|||||||
{
|
{
|
||||||
public String name();
|
public String name();
|
||||||
public T pack();
|
public T pack();
|
||||||
|
public boolean isModified();
|
||||||
|
public void clearModified();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user