Merging changes
This commit is contained in:
@@ -174,7 +174,7 @@ public class DDTeleporter
|
||||
player.setPositionAndUpdate(x + 0.5, y - 1, z + 1.5);
|
||||
break;
|
||||
default:
|
||||
player.setPositionAndUpdate(x, y - 1, z);
|
||||
player.setPositionAndUpdate(x + 0.5, y - 1, z + 0.5);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -207,7 +207,8 @@ public class DDTeleporter
|
||||
entity.worldObj.updateEntityWithOptionalForce(entity, false);
|
||||
break;
|
||||
default:
|
||||
DDTeleporter.setEntityPosition(entity, x, y, z);
|
||||
DDTeleporter.setEntityPosition(entity, x + 0.5, y, z + 0.5);
|
||||
entity.worldObj.updateEntityWithOptionalForce(entity, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -228,7 +229,7 @@ public class DDTeleporter
|
||||
setEntityPosition(entity, x + 0.5, y, z + 1.5);
|
||||
break;
|
||||
default:
|
||||
setEntityPosition(entity, x, y, z);
|
||||
setEntityPosition(entity, x + 0.5, y, z + 0.5);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -556,10 +557,10 @@ public class DDTeleporter
|
||||
return false;
|
||||
}
|
||||
|
||||
Point3D destination = yCoordHelper.findDropPoint(world, source.getX(), source.getY(), source.getZ());
|
||||
Point3D destination = yCoordHelper.findDropPoint(world, source.getX(), source.getY() + 1, source.getZ());
|
||||
if (destination != null)
|
||||
{
|
||||
current.root().setDestination(link, source.getX(), source.getY(), source.getZ());
|
||||
current.root().setDestination(link, destination.getX(), destination.getY(), destination.getZ());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,16 @@ public abstract class DimLink
|
||||
|
||||
protected DimLink(Point4D source, DimLink parent, int orientation)
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
this.orientation=orientation;
|
||||
=======
|
||||
if (parent.source.getDimension() != source.getDimension())
|
||||
{
|
||||
// Ban having children in other dimensions to avoid serialization issues with cross-dimensional tails
|
||||
throw new IllegalArgumentException("source and parent.source must have the same dimension.");
|
||||
}
|
||||
|
||||
>>>>>>> 25446453cba6f491cc0745803f448dd000d453cc
|
||||
this.parent = parent;
|
||||
this.source = source;
|
||||
this.tail = parent.tail;
|
||||
|
||||
@@ -57,13 +57,17 @@ public abstract class NewDimData
|
||||
if (nextParent == null)
|
||||
{
|
||||
throw new IllegalArgumentException("nextParent cannot be null.");
|
||||
}
|
||||
|
||||
}
|
||||
if (this == nextParent)
|
||||
{
|
||||
//Ignore this request silently
|
||||
return false;
|
||||
}
|
||||
if (nextParent.source.getDimension() != source.getDimension())
|
||||
{
|
||||
// Ban having children in other dimensions to avoid serialization issues with cross-dimensional tails
|
||||
throw new IllegalArgumentException("source and parent.source must have the same dimension.");
|
||||
}
|
||||
|
||||
//Release children
|
||||
for (DimLink child : children)
|
||||
@@ -106,22 +110,22 @@ public abstract class NewDimData
|
||||
}
|
||||
}
|
||||
|
||||
private static Random random = new Random();
|
||||
protected static Random random = new Random();
|
||||
|
||||
private final int id;
|
||||
private final Map<Point4D, InnerDimLink> linkMapping;
|
||||
private final List<InnerDimLink> linkList;
|
||||
private final boolean isDungeon;
|
||||
private boolean isFilled;
|
||||
private final int depth;
|
||||
private int packDepth;
|
||||
private final NewDimData parent;
|
||||
private final NewDimData root;
|
||||
private final List<NewDimData> children;
|
||||
private Point4D origin;
|
||||
private int orientation;
|
||||
private DungeonData dungeon;
|
||||
private final IUpdateWatcher<Point4D> linkWatcher;
|
||||
protected int id;
|
||||
protected Map<Point4D, InnerDimLink> linkMapping;
|
||||
protected List<InnerDimLink> linkList;
|
||||
protected boolean isDungeon;
|
||||
protected boolean isFilled;
|
||||
protected int depth;
|
||||
protected int packDepth;
|
||||
protected NewDimData parent;
|
||||
protected NewDimData root;
|
||||
protected List<NewDimData> children;
|
||||
protected Point4D origin;
|
||||
protected int orientation;
|
||||
protected DungeonData dungeon;
|
||||
protected IUpdateWatcher<Point4D> linkWatcher;
|
||||
|
||||
protected NewDimData(int id, NewDimData parent, boolean isPocket, boolean isDungeon,
|
||||
IUpdateWatcher<Point4D> linkWatcher)
|
||||
|
||||
@@ -13,6 +13,9 @@ import net.minecraftforge.common.DimensionManager;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.Compactor;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.DeleteFolder;
|
||||
import StevenDimDoors.mod_pocketDim.saving.DDSaveHandler;
|
||||
import StevenDimDoors.mod_pocketDim.saving.IPackable;
|
||||
import StevenDimDoors.mod_pocketDim.saving.PackedDimData;
|
||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||
import StevenDimDoors.mod_pocketDim.watcher.ClientDimData;
|
||||
import StevenDimDoors.mod_pocketDim.watcher.IUpdateSource;
|
||||
@@ -25,7 +28,7 @@ import StevenDimDoors.mod_pocketDim.watcher.UpdateWatcherProxy;
|
||||
*/
|
||||
public class PocketManager
|
||||
{
|
||||
private static class InnerDimData extends NewDimData
|
||||
private static class InnerDimData extends NewDimData implements IPackable<PackedDimData>
|
||||
{
|
||||
// This class allows us to instantiate NewDimData indirectly without exposing
|
||||
// a public constructor from NewDimData. It's meant to stop us from constructing
|
||||
@@ -43,6 +46,49 @@ public class PocketManager
|
||||
// This constructor is meant for client-side code only
|
||||
super(id, root);
|
||||
}
|
||||
|
||||
public void clear()
|
||||
{
|
||||
// If this dimension has a parent, remove it from its parent's list of children
|
||||
if (parent != null)
|
||||
{
|
||||
parent.children.remove(this);
|
||||
}
|
||||
// Remove this dimension as the parent of its children
|
||||
for (NewDimData child : children)
|
||||
{
|
||||
child.parent = null;
|
||||
}
|
||||
// Clear all fields
|
||||
id = Integer.MIN_VALUE;
|
||||
linkMapping.clear();
|
||||
linkMapping = null;
|
||||
linkList.clear();
|
||||
linkList = null;
|
||||
children.clear();
|
||||
children = null;
|
||||
isDungeon = false;
|
||||
isFilled = false;
|
||||
depth = Integer.MIN_VALUE;
|
||||
packDepth = Integer.MIN_VALUE;
|
||||
origin = null;
|
||||
orientation = Integer.MIN_VALUE;
|
||||
dungeon = null;
|
||||
linkWatcher = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String name()
|
||||
{
|
||||
return String.valueOf(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackedDimData pack()
|
||||
{
|
||||
// FIXME: IMPLEMENTATION PLZTHX
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static class ClientLinkWatcher implements IUpdateWatcher<Point4D>
|
||||
@@ -140,44 +186,44 @@ public class PocketManager
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
public boolean clearPocket(NewDimData dimension)
|
||||
public boolean resetDungeon(NewDimData target)
|
||||
{
|
||||
if (!dimension.isPocketDimension() || DimensionManager.getWorld(dimension.id()) != null)
|
||||
// We can't reset the dimension if it's currently loaded or if it's not a dungeon.
|
||||
// We cast to InnerDimData so that if anyone tries to be a smartass and create their
|
||||
// own version of NewDimData, this will throw an exception.
|
||||
InnerDimData dimension = (InnerDimData) target;
|
||||
if (dimension.isDungeon() && DimensionManager.getWorld(dimension.id()) == null)
|
||||
{
|
||||
return false;
|
||||
File saveDirectory = new File(DimensionManager.getCurrentSaveRootDirectory() + "/DimensionalDoors/pocketDimID" + dimension.id());
|
||||
if (DeleteFolder.deleteFolder(saveDirectory))
|
||||
{
|
||||
dimension.setFilled(false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
File save = new File(DimensionManager.getCurrentSaveRootDirectory() + "/DimensionalDoors/pocketDimID" + dimension.id());
|
||||
DeleteFolder.deleteFolder(save);
|
||||
dimension.setFilled(false);
|
||||
//FIXME: Reset door information?
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean deletePocket(NewDimData dimension, boolean deleteFolder)
|
||||
public static boolean deletePocket(NewDimData target, boolean deleteFolder)
|
||||
{
|
||||
//FIXME: Shouldn't the links in and out of this dimension be altered somehow? Otherwise we have links pointing
|
||||
//into a deleted dimension!
|
||||
|
||||
//Checks to see if the pocket is loaded or isn't actually a pocket.
|
||||
// We can't delete the dimension if it's currently loaded or if it's not actually a pocket.
|
||||
// We cast to InnerDimData so that if anyone tries to be a smartass and create their
|
||||
// own version of NewDimData, this will throw an exception.
|
||||
InnerDimData dimension = (InnerDimData) target;
|
||||
if (dimension.isPocketDimension() && DimensionManager.getWorld(dimension.id()) == null)
|
||||
{
|
||||
dimensionData.remove(dimension.id());
|
||||
DimensionManager.unregisterDimension(dimension.id());
|
||||
if (deleteFolder)
|
||||
{
|
||||
File save = new File(DimensionManager.getCurrentSaveRootDirectory() + "/DimensionalDoors/pocketDimID" + dimension.id());
|
||||
DeleteFolder.deleteFolder(save);
|
||||
File saveDirectory = new File(DimensionManager.getCurrentSaveRootDirectory() + "/DimensionalDoors/pocketDimID" + dimension.id());
|
||||
DeleteFolder.deleteFolder(saveDirectory);
|
||||
}
|
||||
//Raise the dim deleted event
|
||||
dimensionData.remove(dimension.id());
|
||||
// Raise the dim deleted event
|
||||
dimWatcher.onDeleted(new ClientDimData(dimension));
|
||||
//dimension.implode()??? -- more like delete, but yeah
|
||||
dimension.clear();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void registerPockets(DDProperties properties)
|
||||
@@ -222,32 +268,29 @@ public class PocketManager
|
||||
* loads the dim data from the saved hashMap. Also handles compatibility with old saves, see OldSaveHandler
|
||||
*/
|
||||
private static void loadInternal()
|
||||
{
|
||||
// SenseiKiwi: This is a temporary function for testing purposes.
|
||||
// We'll move on to using a text-based format in the future.
|
||||
|
||||
{
|
||||
if (!DimensionManager.getWorld(OVERWORLD_DIMENSION_ID).isRemote &&
|
||||
DimensionManager.getCurrentSaveRootDirectory() != null)
|
||||
{
|
||||
System.out.println("Loading Dimensional Doors save data...");
|
||||
/*File saveFile = new File(DimensionManager.getCurrentSaveRootDirectory() + "/dimdoors.dat");
|
||||
// Load and register blacklisted dimension IDs
|
||||
|
||||
setState(saveData);*/
|
||||
System.out.println("Loaded successfully!");
|
||||
// Load save data
|
||||
System.out.println("Loading Dimensional Doors save data...");
|
||||
if (DDSaveHandler.loadAll())
|
||||
{
|
||||
System.out.println("Loaded successfully!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void save()
|
||||
{
|
||||
// SenseiKiwi: This is a temporary function for testing purposes.
|
||||
// We'll move on to using a text-based format in the future.
|
||||
|
||||
if (!isLoaded)
|
||||
{
|
||||
return;
|
||||
}
|
||||
World world = DimensionManager.getWorld(OVERWORLD_DIMENSION_ID);
|
||||
if (world == null || world.isRemote || DimensionManager.getCurrentSaveRootDirectory() != null)
|
||||
if (world == null || world.isRemote || DimensionManager.getCurrentSaveRootDirectory() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -256,30 +299,23 @@ public class PocketManager
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
isSaving = true;
|
||||
|
||||
try
|
||||
{
|
||||
System.out.println("Writing Dimensional Doors save data...");
|
||||
/*String tempPath = DimensionManager.getCurrentSaveRootDirectory() + "/dimdoors.tmp";
|
||||
String savePath = DimensionManager.getCurrentSaveRootDirectory() + "/dimdoors.dat";
|
||||
File tempFile = new File(tempPath);
|
||||
File saveFile = new File(savePath);
|
||||
DataOutputStream writer = new DataOutputStream(new FileOutputStream(tempFile));
|
||||
getState().writeToStream(writer);
|
||||
writer.close();
|
||||
saveFile.delete();
|
||||
tempFile.renameTo(saveFile);*/
|
||||
System.out.println("Saved successfully!");
|
||||
if ( DDSaveHandler.saveAll(dimensionData.values()) )
|
||||
{
|
||||
System.out.println("Saved successfully!");
|
||||
}
|
||||
}
|
||||
/*catch (FileNotFoundException e)
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
// Wrap the exception in a RuntimeException so functions that call
|
||||
// PocketManager.save() don't need to catch it. We want MC to
|
||||
// crash if something really bad happens rather than ignoring it!
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}*/
|
||||
finally
|
||||
{
|
||||
isSaving = false;
|
||||
|
||||
Reference in New Issue
Block a user