Added versioning to save files and DimensionType
This commit is contained in:
@@ -4,6 +4,7 @@ import java.util.ArrayList;
|
|||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraftforge.common.DimensionManager;
|
import net.minecraftforge.common.DimensionManager;
|
||||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||||
|
import StevenDimDoors.mod_pocketDim.core.DimensionType;
|
||||||
import StevenDimDoors.mod_pocketDim.core.LinkType;
|
import StevenDimDoors.mod_pocketDim.core.LinkType;
|
||||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||||
@@ -46,13 +47,13 @@ public class CommandResetDungeons extends DDCommandBase
|
|||||||
for (NewDimData data : PocketManager.getDimensions())
|
for (NewDimData data : PocketManager.getDimensions())
|
||||||
{
|
{
|
||||||
|
|
||||||
if(DimensionManager.getWorld(data.id())==null&&data.isDungeon())
|
if(DimensionManager.getWorld(data.id())==null&&data.getDimensionType() == DimensionType.DUNGEON)
|
||||||
{
|
{
|
||||||
resetCount++;
|
resetCount++;
|
||||||
dungeonCount++;
|
dungeonCount++;
|
||||||
dimsToDelete.add(data.id());
|
dimsToDelete.add(data.id());
|
||||||
}
|
}
|
||||||
else if(data.isDungeon())
|
else if(data.getDimensionType() == DimensionType.DUNGEON)
|
||||||
{
|
{
|
||||||
dimsToFix.add(data.id());
|
dimsToFix.add(data.id());
|
||||||
dungeonCount++;
|
dungeonCount++;
|
||||||
|
|||||||
@@ -498,7 +498,7 @@ public class DDTeleporter
|
|||||||
case DUNGEON:
|
case DUNGEON:
|
||||||
return PocketBuilder.generateNewDungeonPocket(link, properties);
|
return PocketBuilder.generateNewDungeonPocket(link, properties);
|
||||||
case POCKET:
|
case POCKET:
|
||||||
return PocketBuilder.generateNewPocket(link, properties,door);
|
return PocketBuilder.generateNewPocket(link, properties, door, DimensionType.POCKET);
|
||||||
case PERSONAL:
|
case PERSONAL:
|
||||||
return setupPersonalLink(link, properties, entity, door);
|
return setupPersonalLink(link, properties, entity, door);
|
||||||
case SAFE_EXIT:
|
case SAFE_EXIT:
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package StevenDimDoors.mod_pocketDim.core;
|
||||||
|
|
||||||
|
public enum DimensionType
|
||||||
|
{
|
||||||
|
// WARNING: Don't modify these values carelessly or you'll risk breaking existing worlds!
|
||||||
|
ROOT(0,false),
|
||||||
|
POCKET(1,true),
|
||||||
|
DUNGEON(2,true),
|
||||||
|
PERSONAL(3,true);
|
||||||
|
|
||||||
|
DimensionType(int index, boolean isPocket)
|
||||||
|
{
|
||||||
|
this.index = index;
|
||||||
|
this.isPocket = isPocket;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final int index;
|
||||||
|
public final boolean isPocket;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the DimensionType given an index. I feel like there should be a better way to do this.
|
||||||
|
* @param index
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static DimensionType getTypeFromIndex(int index)
|
||||||
|
{
|
||||||
|
for(DimensionType type : DimensionType.values())
|
||||||
|
{
|
||||||
|
if(type.index == index)
|
||||||
|
{
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPocketDimension()
|
||||||
|
{
|
||||||
|
return this.isPocket;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,5 +2,5 @@ package StevenDimDoors.mod_pocketDim.core;
|
|||||||
|
|
||||||
public interface IDimRegistrationCallback
|
public interface IDimRegistrationCallback
|
||||||
{
|
{
|
||||||
public NewDimData registerDimension(int dimensionID, int rootID);
|
public NewDimData registerDimension(int dimensionID, int rootID, DimensionType type);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -130,10 +130,10 @@ public abstract class NewDimData implements IPackable<PackedDimData>
|
|||||||
protected int id;
|
protected int id;
|
||||||
protected Map<Point4D, InnerDimLink> linkMapping;
|
protected Map<Point4D, InnerDimLink> linkMapping;
|
||||||
protected List<InnerDimLink> linkList;
|
protected List<InnerDimLink> linkList;
|
||||||
protected boolean isDungeon;
|
|
||||||
protected boolean isFilled;
|
protected boolean isFilled;
|
||||||
protected int depth;
|
protected int depth;
|
||||||
protected int packDepth;
|
protected int packDepth;
|
||||||
|
protected DimensionType type;
|
||||||
protected NewDimData parent;
|
protected NewDimData parent;
|
||||||
protected NewDimData root;
|
protected NewDimData root;
|
||||||
protected List<NewDimData> children;
|
protected List<NewDimData> children;
|
||||||
@@ -143,18 +143,12 @@ public abstract class NewDimData implements IPackable<PackedDimData>
|
|||||||
protected boolean modified;
|
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, DimensionType type, IUpdateWatcher<ClientLinkData> linkWatcher)
|
||||||
IUpdateWatcher<ClientLinkData> linkWatcher)
|
|
||||||
{
|
{
|
||||||
// The isPocket flag is redundant. It's meant as an integrity safeguard.
|
if (type != DimensionType.ROOT && (parent == null))
|
||||||
if (isPocket && (parent == null))
|
|
||||||
{
|
{
|
||||||
throw new NullPointerException("Dimensions can be pocket dimensions if and only if they have a parent dimension.");
|
throw new NullPointerException("Dimensions can be pocket dimensions if and only if they have a parent dimension.");
|
||||||
}
|
}
|
||||||
if (isDungeon && !isPocket)
|
|
||||||
{
|
|
||||||
throw new IllegalArgumentException("A dimensional dungeon must also be a pocket dimension.");
|
|
||||||
}
|
|
||||||
|
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.linkMapping = new TreeMap<Point4D, InnerDimLink>(); //Should be stored in oct tree -- temporary solution
|
this.linkMapping = new TreeMap<Point4D, InnerDimLink>(); //Should be stored in oct tree -- temporary solution
|
||||||
@@ -162,7 +156,7 @@ public abstract class NewDimData implements IPackable<PackedDimData>
|
|||||||
this.children = new ArrayList<NewDimData>();
|
this.children = new ArrayList<NewDimData>();
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
this.packDepth = 0;
|
this.packDepth = 0;
|
||||||
this.isDungeon = isDungeon;
|
this.type = type;
|
||||||
this.isFilled = false;
|
this.isFilled = false;
|
||||||
this.orientation = 0;
|
this.orientation = 0;
|
||||||
this.origin = null;
|
this.origin = null;
|
||||||
@@ -186,7 +180,7 @@ public abstract class NewDimData implements IPackable<PackedDimData>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected NewDimData(int id, NewDimData root)
|
protected NewDimData(int id, NewDimData root, DimensionType type)
|
||||||
{
|
{
|
||||||
// This constructor is meant for client-side code only
|
// This constructor is meant for client-side code only
|
||||||
if (root == null)
|
if (root == null)
|
||||||
@@ -200,7 +194,7 @@ public abstract class NewDimData implements IPackable<PackedDimData>
|
|||||||
this.children = new ArrayList<NewDimData>();
|
this.children = new ArrayList<NewDimData>();
|
||||||
this.parent = null;
|
this.parent = null;
|
||||||
this.packDepth = 0;
|
this.packDepth = 0;
|
||||||
this.isDungeon = false;
|
this.type = type;
|
||||||
this.isFilled = false;
|
this.isFilled = false;
|
||||||
this.orientation = 0;
|
this.orientation = 0;
|
||||||
this.origin = null;
|
this.origin = null;
|
||||||
@@ -422,11 +416,10 @@ public abstract class NewDimData implements IPackable<PackedDimData>
|
|||||||
return (root != this);
|
return (root != this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDungeon()
|
public DimensionType getDimensionType()
|
||||||
{
|
{
|
||||||
return isDungeon;
|
return this.type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFilled()
|
public boolean isFilled()
|
||||||
{
|
{
|
||||||
return isFilled;
|
return isFilled;
|
||||||
@@ -500,7 +493,7 @@ public abstract class NewDimData implements IPackable<PackedDimData>
|
|||||||
|
|
||||||
public void initializeDungeon(int originX, int originY, int originZ, int orientation, DimLink incoming, DungeonData dungeon)
|
public void initializeDungeon(int originX, int originY, int originZ, int orientation, DimLink incoming, DungeonData dungeon)
|
||||||
{
|
{
|
||||||
if (!isDungeon)
|
if (this.type != DimensionType.DUNGEON)
|
||||||
{
|
{
|
||||||
throw new IllegalStateException("Cannot invoke initializeDungeon() on a non-dungeon dimension.");
|
throw new IllegalStateException("Cannot invoke initializeDungeon() on a non-dungeon dimension.");
|
||||||
}
|
}
|
||||||
@@ -655,7 +648,7 @@ public abstract class NewDimData implements IPackable<PackedDimData>
|
|||||||
linkList = null;
|
linkList = null;
|
||||||
children.clear();
|
children.clear();
|
||||||
children = null;
|
children = null;
|
||||||
isDungeon = false;
|
type = null;
|
||||||
isFilled = false;
|
isFilled = false;
|
||||||
depth = Integer.MIN_VALUE;
|
depth = Integer.MIN_VALUE;
|
||||||
packDepth = Integer.MIN_VALUE;
|
packDepth = Integer.MIN_VALUE;
|
||||||
@@ -696,10 +689,10 @@ public abstract class NewDimData implements IPackable<PackedDimData>
|
|||||||
{
|
{
|
||||||
children.add(childLink.source().toPoint3D());
|
children.add(childLink.source().toPoint3D());
|
||||||
}
|
}
|
||||||
PackedLinkTail tail = new PackedLinkTail(link.tail.getDestination(),link.tail.getLinkType().index);
|
PackedLinkTail tail = new PackedLinkTail(link.tail.getDestination(),link.tail.getLinkType());
|
||||||
Links.add(new PackedLinkData(link.point,parentPoint,tail,link.orientation,children,link.lock));
|
Links.add(new PackedLinkData(link.point,parentPoint,tail,link.orientation,children,link.lock));
|
||||||
|
|
||||||
PackedLinkTail tempTail = new PackedLinkTail(link.tail.getDestination(),link.tail.getLinkType().index);
|
PackedLinkTail tempTail = new PackedLinkTail(link.tail.getDestination(),link.tail.getLinkType());
|
||||||
if(Tails.contains(tempTail))
|
if(Tails.contains(tempTail))
|
||||||
{
|
{
|
||||||
Tails.add(tempTail);
|
Tails.add(tempTail);
|
||||||
@@ -718,7 +711,7 @@ public abstract class NewDimData implements IPackable<PackedDimData>
|
|||||||
originPoint=this.origin.toPoint3D();
|
originPoint=this.origin.toPoint3D();
|
||||||
}
|
}
|
||||||
return new PackedDimData(this.id, depth, this.packDepth, parentID, this.root().id(), orientation,
|
return new PackedDimData(this.id, depth, this.packDepth, parentID, this.root().id(), orientation,
|
||||||
isDungeon, isFilled,packedDungeon, originPoint, ChildIDs, Links, Tails);
|
type, isFilled,packedDungeon, originPoint, ChildIDs, Links, Tails);
|
||||||
// FIXME: IMPLEMENTATION PLZTHX
|
// FIXME: IMPLEMENTATION PLZTHX
|
||||||
//I tried
|
//I tried
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,16 +42,16 @@ public class PocketManager
|
|||||||
// instances of NewDimData going through PocketManager. In turn, that enforces
|
// instances of NewDimData going through PocketManager. In turn, that enforces
|
||||||
// that any link destinations must be real dimensions controlled by PocketManager.
|
// that any link destinations must be real dimensions controlled by PocketManager.
|
||||||
|
|
||||||
public InnerDimData(int id, InnerDimData parent, boolean isPocket, boolean isDungeon,
|
public InnerDimData(int id, InnerDimData parent, DimensionType type,
|
||||||
IUpdateWatcher<ClientLinkData> linkWatcher)
|
IUpdateWatcher<ClientLinkData> linkWatcher)
|
||||||
{
|
{
|
||||||
super(id, parent, isPocket, isDungeon, linkWatcher);
|
super(id, parent, type, linkWatcher);
|
||||||
}
|
}
|
||||||
|
|
||||||
public InnerDimData(int id, InnerDimData root)
|
public InnerDimData(int id, NewDimData root, DimensionType type)
|
||||||
{
|
{
|
||||||
// This constructor is meant for client-side code only
|
// This constructor is meant for client-side code only
|
||||||
super(id, root);
|
super(id, root, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -90,7 +90,7 @@ public class PocketManager
|
|||||||
@Override
|
@Override
|
||||||
public void onCreated(ClientDimData data)
|
public void onCreated(ClientDimData data)
|
||||||
{
|
{
|
||||||
registerClientDimension(data.ID, data.RootID);
|
registerClientDimension(data.ID, data.rootID, data.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -114,9 +114,9 @@ public class PocketManager
|
|||||||
// exposing a private constructor ONLY to a very specific trusted class.
|
// exposing a private constructor ONLY to a very specific trusted class.
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NewDimData registerDimension(int dimensionID, int rootID)
|
public NewDimData registerDimension(int dimensionID, int rootID, DimensionType type)
|
||||||
{
|
{
|
||||||
return registerClientDimension(dimensionID, rootID);
|
return registerClientDimension(dimensionID, rootID, type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -177,7 +177,7 @@ public class PocketManager
|
|||||||
}
|
}
|
||||||
//Register Limbo
|
//Register Limbo
|
||||||
DDProperties properties = DDProperties.instance();
|
DDProperties properties = DDProperties.instance();
|
||||||
registerDimension(properties.LimboDimensionID, null, false, false);
|
registerDimension(properties.LimboDimensionID, null, DimensionType.ROOT);
|
||||||
|
|
||||||
loadInternal();
|
loadInternal();
|
||||||
|
|
||||||
@@ -192,10 +192,15 @@ public class PocketManager
|
|||||||
{
|
{
|
||||||
|
|
||||||
InnerDimData dimData;
|
InnerDimData dimData;
|
||||||
|
DimensionType type = DimensionType.getTypeFromIndex(packedData.DimensionType);
|
||||||
|
if(type == null)
|
||||||
|
{
|
||||||
|
throw new IllegalArgumentException("Invalid dimension type");
|
||||||
|
}
|
||||||
//register roots
|
//register roots
|
||||||
if(packedData.ID==packedData.ParentID)
|
if(packedData.ID==packedData.ParentID)
|
||||||
{
|
{
|
||||||
dimData = new InnerDimData(packedData.ID, null, false, false, linkWatcher);
|
dimData = new InnerDimData(packedData.ID, null, type, linkWatcher);
|
||||||
dimData.root=dimData;
|
dimData.root=dimData;
|
||||||
dimData.parent=dimData;
|
dimData.parent=dimData;
|
||||||
dimData.depth=packedData.Depth;
|
dimData.depth=packedData.Depth;
|
||||||
@@ -207,7 +212,7 @@ public class PocketManager
|
|||||||
else //register children
|
else //register children
|
||||||
{
|
{
|
||||||
InnerDimData test = PocketManager.dimensionData.get(packedData.ParentID);
|
InnerDimData test = PocketManager.dimensionData.get(packedData.ParentID);
|
||||||
dimData = new InnerDimData(packedData.ID, test,true, packedData.IsDungeon, linkWatcher);
|
dimData = new InnerDimData(packedData.ID, test, type, linkWatcher);
|
||||||
dimData.isFilled=packedData.IsFilled;
|
dimData.isFilled=packedData.IsFilled;
|
||||||
dimData.origin = new Point4D(packedData.Origin.getX(),packedData.Origin.getY(),packedData.Origin.getZ(),packedData.ID);
|
dimData.origin = new Point4D(packedData.Origin.getX(),packedData.Origin.getY(),packedData.Origin.getZ(),packedData.ID);
|
||||||
dimData.root=PocketManager.getDimensionData(packedData.RootID);
|
dimData.root=PocketManager.getDimensionData(packedData.RootID);
|
||||||
@@ -421,7 +426,7 @@ public class PocketManager
|
|||||||
|
|
||||||
public static NewDimData registerDimension(World world)
|
public static NewDimData registerDimension(World world)
|
||||||
{
|
{
|
||||||
return registerDimension(world.provider.dimensionId, null, false, false);
|
return registerDimension(world.provider.dimensionId, null, DimensionType.ROOT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static NewDimData registerPersonalPocket(NewDimData parent, String playerName)
|
public static NewDimData registerPersonalPocket(NewDimData parent, String playerName)
|
||||||
@@ -434,12 +439,12 @@ public class PocketManager
|
|||||||
DDProperties properties = DDProperties.instance();
|
DDProperties properties = DDProperties.instance();
|
||||||
int dimensionID = DimensionManager.getNextFreeDimId();
|
int dimensionID = DimensionManager.getNextFreeDimId();
|
||||||
DimensionManager.registerDimension(dimensionID, properties.PersonalPocketProviderID);
|
DimensionManager.registerDimension(dimensionID, properties.PersonalPocketProviderID);
|
||||||
NewDimData data = registerDimension(dimensionID, (InnerDimData) parent, true, false);
|
NewDimData data = registerDimension(dimensionID, (InnerDimData) parent, DimensionType.PERSONAL);
|
||||||
personalPocketsMapping.put(playerName, data);
|
personalPocketsMapping.put(playerName, data);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static NewDimData registerPocket(NewDimData parent, boolean isDungeon)
|
public static NewDimData registerPocket(NewDimData parent, DimensionType type)
|
||||||
{
|
{
|
||||||
if (parent == null)
|
if (parent == null)
|
||||||
{
|
{
|
||||||
@@ -449,7 +454,7 @@ public class PocketManager
|
|||||||
DDProperties properties = DDProperties.instance();
|
DDProperties properties = DDProperties.instance();
|
||||||
int dimensionID = DimensionManager.getNextFreeDimId();
|
int dimensionID = DimensionManager.getNextFreeDimId();
|
||||||
DimensionManager.registerDimension(dimensionID, properties.PocketProviderID);
|
DimensionManager.registerDimension(dimensionID, properties.PocketProviderID);
|
||||||
return registerDimension(dimensionID, (InnerDimData) parent, true, isDungeon);
|
return registerDimension(dimensionID, (InnerDimData) parent, type);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Registers a dimension with DD but NOT with forge.
|
* Registers a dimension with DD but NOT with forge.
|
||||||
@@ -459,7 +464,7 @@ public class PocketManager
|
|||||||
* @param isDungeon
|
* @param isDungeon
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private static NewDimData registerDimension(int dimensionID, InnerDimData parent, boolean isPocket, boolean isDungeon)
|
private static NewDimData registerDimension(int dimensionID, InnerDimData parent, DimensionType type)
|
||||||
{
|
{
|
||||||
if (dimensionData.containsKey(dimensionID))
|
if (dimensionData.containsKey(dimensionID))
|
||||||
{
|
{
|
||||||
@@ -469,7 +474,7 @@ public class PocketManager
|
|||||||
}
|
}
|
||||||
throw new IllegalArgumentException("Cannot register a dimension with ID = " + dimensionID + " because it has already been registered.");
|
throw new IllegalArgumentException("Cannot register a dimension with ID = " + dimensionID + " because it has already been registered.");
|
||||||
}
|
}
|
||||||
InnerDimData dimension = new InnerDimData(dimensionID, parent, isPocket, isDungeon, linkWatcher);
|
InnerDimData dimension = new InnerDimData(dimensionID, parent, type, linkWatcher);
|
||||||
dimensionData.put(dimensionID, dimension);
|
dimensionData.put(dimensionID, dimension);
|
||||||
if (!dimension.isPocketDimension())
|
if (!dimension.isPocketDimension())
|
||||||
{
|
{
|
||||||
@@ -481,7 +486,7 @@ public class PocketManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
private static NewDimData registerClientDimension(int dimensionID, int rootID)
|
private static NewDimData registerClientDimension(int dimensionID, int rootID, DimensionType type)
|
||||||
{
|
{
|
||||||
System.out.println("Registered dim "+dimensionID+" on the client.");
|
System.out.println("Registered dim "+dimensionID+" on the client.");
|
||||||
// No need to raise events heres since this code should only run on the client side
|
// No need to raise events heres since this code should only run on the client side
|
||||||
@@ -498,7 +503,7 @@ public class PocketManager
|
|||||||
dimension = dimensionData.get(dimensionID);
|
dimension = dimensionData.get(dimensionID);
|
||||||
if (dimension == null)
|
if (dimension == null)
|
||||||
{
|
{
|
||||||
dimension = new InnerDimData(dimensionID, root);
|
dimension = new InnerDimData(dimensionID, root, type);
|
||||||
dimensionData.put(dimension.id(), dimension);
|
dimensionData.put(dimension.id(), dimension);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -538,9 +543,11 @@ public class PocketManager
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
NewDimData dimension = PocketManager.dimensionData.get(dimensionID);
|
NewDimData dimension = PocketManager.dimensionData.get(dimensionID);
|
||||||
|
|
||||||
|
// if we do not have a record of it, then it must be a root
|
||||||
if (dimension == null)
|
if (dimension == null)
|
||||||
{
|
{
|
||||||
dimension = registerDimension(dimensionID, null, false, false);
|
dimension = registerDimension(dimensionID, null, DimensionType.ROOT);
|
||||||
}
|
}
|
||||||
return dimension;
|
return dimension;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
package StevenDimDoors.mod_pocketDim.core;
|
|
||||||
|
|
||||||
public enum PocketType
|
|
||||||
{
|
|
||||||
// WARNING: Don't modify these values carelessly or you'll risk breaking existing worlds!
|
|
||||||
NORMAL(0),
|
|
||||||
DUNGEON(1),
|
|
||||||
PERSONAL(2);
|
|
||||||
|
|
||||||
PocketType(int index)
|
|
||||||
{
|
|
||||||
this.index = index;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final int index;
|
|
||||||
}
|
|
||||||
@@ -7,6 +7,7 @@ import java.util.Collection;
|
|||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||||
|
import StevenDimDoors.mod_pocketDim.core.DimensionType;
|
||||||
import StevenDimDoors.mod_pocketDim.core.IDimRegistrationCallback;
|
import StevenDimDoors.mod_pocketDim.core.IDimRegistrationCallback;
|
||||||
import StevenDimDoors.mod_pocketDim.core.LinkType;
|
import StevenDimDoors.mod_pocketDim.core.LinkType;
|
||||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||||
@@ -67,13 +68,14 @@ public class Compactor
|
|||||||
{
|
{
|
||||||
int id = input.readInt();
|
int id = input.readInt();
|
||||||
int rootID = input.readInt();
|
int rootID = input.readInt();
|
||||||
|
DimensionType type = DimensionType.getTypeFromIndex(input.readInt());
|
||||||
|
|
||||||
if (rootIDs.add(rootID))
|
if (rootIDs.add(rootID))
|
||||||
{
|
{
|
||||||
callback.registerDimension(rootID, rootID);
|
callback.registerDimension(rootID, rootID, type);
|
||||||
}
|
}
|
||||||
// Don't check if (id != rootID) - we want to retrieve the reference anyway
|
// Don't check if (id != rootID) - we want to retrieve the reference anyway
|
||||||
NewDimData dimension = callback.registerDimension(id, rootID);
|
NewDimData dimension = callback.registerDimension(id, rootID, type);
|
||||||
int linkCount = input.readInt();
|
int linkCount = input.readInt();
|
||||||
for (int h = 0; h < linkCount; h++)
|
for (int h = 0; h < linkCount; h++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ public class ItemDDKey extends Item
|
|||||||
world.playSoundAtEntity(player, mod_pocketDim.modid + ":keyLock", 1F, 1F);
|
world.playSoundAtEntity(player, mod_pocketDim.modid + ":keyLock", 1F, 1F);
|
||||||
}
|
}
|
||||||
PocketManager.getDimensionData(world).lock(link, !link.getLockState());
|
PocketManager.getDimensionData(world).lock(link, !link.getLockState());
|
||||||
PocketManager.getLinkWatcher().update(new ClientLinkData(link.source(),link.getLock()));
|
PocketManager.getLinkWatcher().update(new ClientLinkData(link));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -116,7 +116,7 @@ public class ItemDDKey extends Item
|
|||||||
{
|
{
|
||||||
world.playSoundAtEntity(player, mod_pocketDim.modid + ":keyLock", 1F, 1F);
|
world.playSoundAtEntity(player, mod_pocketDim.modid + ":keyLock", 1F, 1F);
|
||||||
PocketManager.getDimensionData(world).createLock(link, itemStack, world.rand.nextInt(Integer.MAX_VALUE));
|
PocketManager.getDimensionData(world).createLock(link, itemStack, world.rand.nextInt(Integer.MAX_VALUE));
|
||||||
PocketManager.getLinkWatcher().update(new ClientLinkData(link.source(),link.getLock()));
|
PocketManager.getLinkWatcher().update(new ClientLinkData(link));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import net.minecraftforge.common.DimensionManager;
|
|||||||
import StevenDimDoors.mod_pocketDim.Point3D;
|
import StevenDimDoors.mod_pocketDim.Point3D;
|
||||||
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
||||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||||
|
import StevenDimDoors.mod_pocketDim.core.DimensionType;
|
||||||
import StevenDimDoors.mod_pocketDim.core.LinkType;
|
import StevenDimDoors.mod_pocketDim.core.LinkType;
|
||||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||||
@@ -157,7 +158,7 @@ public class DDSaveHandler
|
|||||||
}
|
}
|
||||||
if(isMissing)
|
if(isMissing)
|
||||||
{
|
{
|
||||||
packedDim=(new PackedDimData(packedDim.ID, packedDim.Depth, packedDim.PackDepth, packedDim.ParentID, packedDim.RootID, packedDim.Orientation, packedDim.IsDungeon, packedDim.IsFilled, packedDim.DungeonData, packedDim.Origin, children, packedDim.Links, packedDim.Tails));
|
packedDim=(new PackedDimData(packedDim.ID, packedDim.Depth, packedDim.PackDepth, packedDim.ParentID, packedDim.RootID, packedDim.Orientation, DimensionType.getTypeFromIndex(packedDim.DimensionType), packedDim.IsFilled, packedDim.DungeonData, packedDim.Origin, children, packedDim.Links, packedDim.Tails));
|
||||||
packedDims.put(packedDim.ID, packedDim);
|
packedDims.put(packedDim.ID, packedDim);
|
||||||
}
|
}
|
||||||
return children;
|
return children;
|
||||||
@@ -175,12 +176,12 @@ public class DDSaveHandler
|
|||||||
{
|
{
|
||||||
ArrayList<Integer> fosterChildren = new ArrayList<Integer>();
|
ArrayList<Integer> fosterChildren = new ArrayList<Integer>();
|
||||||
fosterChildren.add(packedDim.ID);
|
fosterChildren.add(packedDim.ID);
|
||||||
|
DimensionType type = DimensionType.getTypeFromIndex(packedDim.DimensionType);
|
||||||
//fix pockets without parents
|
//fix pockets without parents
|
||||||
if(!packedDims.containsKey(packedDim.ParentID))
|
if(!packedDims.containsKey(packedDim.ParentID))
|
||||||
{
|
{
|
||||||
//Fix the orphan by changing its root to its parent, re-connecting it to the list
|
//Fix the orphan by changing its root to its parent, re-connecting it to the list
|
||||||
packedDim=(new PackedDimData(packedDim.ID, 1, packedDim.PackDepth, packedDim.RootID, packedDim.RootID, packedDim.Orientation, packedDim.IsDungeon, packedDim.IsFilled, packedDim.DungeonData, packedDim.Origin, packedDim.ChildIDs, packedDim.Links, packedDim.Tails));
|
packedDim=(new PackedDimData(packedDim.ID, 1, packedDim.PackDepth, packedDim.RootID, packedDim.RootID, packedDim.Orientation,type, packedDim.IsFilled, packedDim.DungeonData, packedDim.Origin, packedDim.ChildIDs, packedDim.Links, packedDim.Tails));
|
||||||
packedDims.put(packedDim.ID, packedDim);
|
packedDims.put(packedDim.ID, packedDim);
|
||||||
}
|
}
|
||||||
//fix pockets whose parents have forgotten about them
|
//fix pockets whose parents have forgotten about them
|
||||||
@@ -189,7 +190,7 @@ public class DDSaveHandler
|
|||||||
{
|
{
|
||||||
//find the root, and fix it by adding the orphan's ID to its children
|
//find the root, and fix it by adding the orphan's ID to its children
|
||||||
fosterChildren.addAll(fosterParent.ChildIDs);
|
fosterChildren.addAll(fosterParent.ChildIDs);
|
||||||
fosterParent=(new PackedDimData(fosterParent.ID, fosterParent.Depth, fosterParent.PackDepth, fosterParent.ParentID, fosterParent.RootID, fosterParent.Orientation, fosterParent.IsDungeon, fosterParent.IsFilled, fosterParent.DungeonData, fosterParent.Origin, fosterChildren, fosterParent.Links, fosterParent.Tails));
|
fosterParent=(new PackedDimData(fosterParent.ID, fosterParent.Depth, fosterParent.PackDepth, fosterParent.ParentID, fosterParent.RootID, fosterParent.Orientation, type, fosterParent.IsFilled, fosterParent.DungeonData, fosterParent.Origin, fosterChildren, fosterParent.Links, fosterParent.Tails));
|
||||||
packedDims.put(fosterParent.ID, fosterParent);
|
packedDims.put(fosterParent.ID, fosterParent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,30 +1,37 @@
|
|||||||
package StevenDimDoors.mod_pocketDim.saving;
|
package StevenDimDoors.mod_pocketDim.saving;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import StevenDimDoors.mod_pocketDim.core.DimensionType;
|
||||||
import StevenDimDoors.mod_pocketDim.Point3D;
|
|
||||||
import StevenDimDoors.mod_pocketDim.util.BaseConfigurationProcessor;
|
import StevenDimDoors.mod_pocketDim.util.BaseConfigurationProcessor;
|
||||||
import StevenDimDoors.mod_pocketDim.util.ConfigurationProcessingException;
|
import StevenDimDoors.mod_pocketDim.util.ConfigurationProcessingException;
|
||||||
import StevenDimDoors.mod_pocketDim.util.JSONValidator;
|
import StevenDimDoors.mod_pocketDim.util.JSONValidator;
|
||||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
import com.google.gson.stream.JsonReader;
|
import com.google.gson.stream.JsonReader;
|
||||||
import com.google.gson.stream.JsonToken;
|
|
||||||
|
|
||||||
public class DimDataProcessor extends BaseConfigurationProcessor<PackedDimData>
|
public class DimDataProcessor extends BaseConfigurationProcessor<PackedDimData>
|
||||||
{
|
{
|
||||||
private static final String JSON_SCHEMA_PATH = "/assets/dimdoors/text/Dim_Data_Schema.json";
|
public final String JSON_VERSION_PROPERTY_NAME = "SAVE_DATA_VERSION_ID_INSTANCE";
|
||||||
|
private HashMap<Integer, String> SAVE_DATA_DEFINITIONS;
|
||||||
private static final JsonParser jsonParser = new JsonParser();
|
private static final JsonParser jsonParser = new JsonParser();
|
||||||
|
public static final String currentSaveVersionPath = "/assets/dimdoors/text/Dim_Data_Schema_v1-0-0.json";
|
||||||
|
|
||||||
|
|
||||||
|
//TODO dont load the schemas every time
|
||||||
|
public DimDataProcessor()
|
||||||
|
{
|
||||||
|
SAVE_DATA_DEFINITIONS = new HashMap<Integer, String>();
|
||||||
|
SAVE_DATA_DEFINITIONS.put(982405775, "/assets/dimdoors/text/Dim_Data_Schema_v982405775.json");
|
||||||
|
SAVE_DATA_DEFINITIONS.put(PackedDimData.SAVE_DATA_VERSION_ID, currentSaveVersionPath);
|
||||||
|
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public PackedDimData readFromStream(InputStream inputStream)
|
public PackedDimData readFromStream(InputStream inputStream)
|
||||||
throws ConfigurationProcessingException
|
throws ConfigurationProcessingException
|
||||||
@@ -58,38 +65,96 @@ public class DimDataProcessor extends BaseConfigurationProcessor<PackedDimData>
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
//ensure our json object corresponds to our schema
|
//ensure our json object corresponds to our schema
|
||||||
validateJson(ele);
|
JSONValidator.validate(getSaveDataSchema(ele.getAsJsonObject()), ele);
|
||||||
outputStream.write(ele.toString().getBytes("UTF-8"));
|
outputStream.write(ele.toString().getBytes("UTF-8"));
|
||||||
outputStream.close();
|
outputStream.close();
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
// not sure if this is kosher, we need it to explode, but not by throwing the IO exception.
|
// not sure if this is kosher, we need it to explode, but not by throwing the IO exception.
|
||||||
throw new ConfigurationProcessingException("Incorrectly formatted save data");
|
throw new ConfigurationProcessingException("Could not access save data");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public PackedDimData readDimDataJson(JsonReader reader) throws IOException
|
public PackedDimData readDimDataJson(JsonReader reader) throws IOException
|
||||||
{
|
{
|
||||||
JsonElement ele = jsonParser.parse(reader);
|
JsonElement ele = jsonParser.parse(reader);
|
||||||
this.validateJson(ele);
|
JsonObject schema = this.getSaveDataSchema(ele.getAsJsonObject());
|
||||||
|
JSONValidator.validate(schema, ele);
|
||||||
|
ele = processSaveData(schema, ele.getAsJsonObject());
|
||||||
|
|
||||||
GsonBuilder gsonBuilder = new GsonBuilder();
|
GsonBuilder gsonBuilder = new GsonBuilder();
|
||||||
return gsonBuilder.create().fromJson(ele, PackedDimData.class);
|
return gsonBuilder.create().fromJson(ele, PackedDimData.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* checks our json against the dim data schema
|
* Gets the schema that corresponds to a version of our save data
|
||||||
* @param data
|
* @param obj
|
||||||
* @return
|
* @return
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public boolean validateJson(JsonElement data) throws IOException
|
public JsonObject getSaveDataSchema(JsonObject obj)
|
||||||
{
|
{
|
||||||
InputStream in = this.getClass().getResourceAsStream(JSON_SCHEMA_PATH);
|
String schemaPath = this.SAVE_DATA_DEFINITIONS.get(obj.get(JSON_VERSION_PROPERTY_NAME).getAsInt());
|
||||||
|
|
||||||
|
if(schemaPath == null)
|
||||||
|
{
|
||||||
|
throw new IllegalStateException("Invalid save data version");
|
||||||
|
}
|
||||||
|
InputStream in = this.getClass().getResourceAsStream(schemaPath);
|
||||||
JsonReader reader = new JsonReader(new InputStreamReader(in));
|
JsonReader reader = new JsonReader(new InputStreamReader(in));
|
||||||
JSONValidator.validate((JsonObject) jsonParser.parse(reader), data);
|
|
||||||
reader.close();
|
JsonObject schema = jsonParser.parse(reader).getAsJsonObject();
|
||||||
in.close();
|
try
|
||||||
return true;
|
{
|
||||||
|
reader.close();
|
||||||
|
in.close();
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
System.err.println("Could not load Json Save Data definitions");
|
||||||
|
e.printStackTrace();
|
||||||
|
throw new IllegalStateException("Could not load Json Save Data definitions");
|
||||||
|
}
|
||||||
|
return schema;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* I use this method to update old save data files to the new format before actually loading them.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public JsonObject processSaveData(JsonObject schema, JsonObject save)
|
||||||
|
{
|
||||||
|
if(save.get(JSON_VERSION_PROPERTY_NAME).getAsInt()== 982405775)
|
||||||
|
{
|
||||||
|
DimensionType type;
|
||||||
|
|
||||||
|
//see if the dim is a pocket
|
||||||
|
if(save.get("RootID").getAsInt() != save.get("ID").getAsInt())
|
||||||
|
{
|
||||||
|
if(save.get("IsDungeon").getAsBoolean())
|
||||||
|
{
|
||||||
|
type = DimensionType.DUNGEON;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
type = DimensionType.POCKET;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
type = DimensionType.ROOT;
|
||||||
|
}
|
||||||
|
|
||||||
|
save.remove("IsDungeon");
|
||||||
|
save.addProperty("DimensionType",type.index);
|
||||||
|
save.remove(this.JSON_VERSION_PROPERTY_NAME);
|
||||||
|
save.addProperty(this.JSON_VERSION_PROPERTY_NAME, PackedDimData.SAVE_DATA_VERSION_ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
JSONValidator.validate(this.getSaveDataSchema(save), save);
|
||||||
|
return save;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,17 +2,16 @@ package StevenDimDoors.mod_pocketDim.saving;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import StevenDimDoors.mod_pocketDim.DimData;
|
import StevenDimDoors.mod_pocketDim.DimData;
|
||||||
import StevenDimDoors.mod_pocketDim.LinkData;
|
import StevenDimDoors.mod_pocketDim.LinkData;
|
||||||
import StevenDimDoors.mod_pocketDim.Point3D;
|
|
||||||
|
|
||||||
import StevenDimDoors.mod_pocketDim.ObjectSaveInputStream;
|
import StevenDimDoors.mod_pocketDim.ObjectSaveInputStream;
|
||||||
|
import StevenDimDoors.mod_pocketDim.Point3D;
|
||||||
|
import StevenDimDoors.mod_pocketDim.core.DimensionType;
|
||||||
|
import StevenDimDoors.mod_pocketDim.core.LinkType;
|
||||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||||
|
|
||||||
public class OldSaveImporter
|
public class OldSaveImporter
|
||||||
@@ -77,7 +76,7 @@ public class OldSaveImporter
|
|||||||
{
|
{
|
||||||
Point4D source = new Point4D(link.locXCoord,link.locYCoord,link.locZCoord,link.locDimID);
|
Point4D source = new Point4D(link.locXCoord,link.locYCoord,link.locZCoord,link.locDimID);
|
||||||
Point4D destintion = new Point4D(link.destXCoord,link.destYCoord,link.destZCoord,link.destDimID);
|
Point4D destintion = new Point4D(link.destXCoord,link.destYCoord,link.destZCoord,link.destDimID);
|
||||||
PackedLinkTail tail = new PackedLinkTail(destintion, link.linkOrientation);
|
PackedLinkTail tail = new PackedLinkTail(destintion, LinkType.NORMAL);
|
||||||
List<Point3D> children = new ArrayList<Point3D>();
|
List<Point3D> children = new ArrayList<Point3D>();
|
||||||
|
|
||||||
PackedLinkData newPackedLink = new PackedLinkData(source, new Point3D(-1,-1,-1), tail, link.linkOrientation,children, null);
|
PackedLinkData newPackedLink = new PackedLinkData(source, new Point3D(-1,-1,-1), tail, link.linkOrientation,children, null);
|
||||||
@@ -86,13 +85,30 @@ public class OldSaveImporter
|
|||||||
allPackedLinks.add(newPackedLink);
|
allPackedLinks.add(newPackedLink);
|
||||||
}
|
}
|
||||||
PackedDimData dim;
|
PackedDimData dim;
|
||||||
|
DimensionType type;
|
||||||
|
|
||||||
if(data.isPocket)
|
if(data.isPocket)
|
||||||
{
|
{
|
||||||
dim = new PackedDimData(data.dimID, data.depth, data.depth, data.exitDimLink.locDimID, data.exitDimLink.locDimID, 0, data.dungeonGenerator!=null, data.hasBeenFilled, null, new Point3D(0,64,0), childDims, newPackedLinkData, null);
|
if(data.dungeonGenerator!=null)
|
||||||
|
{
|
||||||
|
type = DimensionType.DUNGEON;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
type = DimensionType.POCKET;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dim = new PackedDimData(data.dimID, data.depth, data.depth, data.dimID, data.dimID, 0, data.dungeonGenerator!=null, data.hasBeenFilled, null, new Point3D(0,64,0), childDims, newPackedLinkData, null);
|
type = DimensionType.ROOT;
|
||||||
|
}
|
||||||
|
if(data.isPocket)
|
||||||
|
{
|
||||||
|
dim = new PackedDimData(data.dimID, data.depth, data.depth, data.exitDimLink.locDimID, data.exitDimLink.locDimID, 0, type, data.hasBeenFilled, null, new Point3D(0,64,0), childDims, newPackedLinkData, null);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dim = new PackedDimData(data.dimID, data.depth, data.depth, data.dimID, data.dimID, 0, type, data.hasBeenFilled, null, new Point3D(0,64,0), childDims, newPackedLinkData, null);
|
||||||
}
|
}
|
||||||
newPackedDimData.put(dim.ID,dim);
|
newPackedDimData.put(dim.ID,dim);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,14 +3,15 @@ package StevenDimDoors.mod_pocketDim.saving;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import StevenDimDoors.mod_pocketDim.Point3D;
|
import StevenDimDoors.mod_pocketDim.Point3D;
|
||||||
|
import StevenDimDoors.mod_pocketDim.core.DimensionType;
|
||||||
|
|
||||||
public class PackedDimData
|
public class PackedDimData
|
||||||
{
|
{
|
||||||
// These fields will be public since this is a simple data container
|
// These fields will be public since this is a simple data container
|
||||||
public final static long SAVE_DATA_VERSION_ID = 982405775L;
|
public final static int SAVE_DATA_VERSION_ID = 100;
|
||||||
public final long SAVE_DATA_VERSION_ID_INSTANCE = SAVE_DATA_VERSION_ID;
|
public final long SAVE_DATA_VERSION_ID_INSTANCE = SAVE_DATA_VERSION_ID;
|
||||||
public final int ID;
|
public final int ID;
|
||||||
public final boolean IsDungeon;
|
public final int DimensionType;
|
||||||
public final boolean IsFilled;
|
public final boolean IsFilled;
|
||||||
public final int Depth;
|
public final int Depth;
|
||||||
public final int PackDepth;
|
public final int PackDepth;
|
||||||
@@ -26,7 +27,7 @@ public class PackedDimData
|
|||||||
// FIXME Missing dungeon data, not sure how to include it
|
// FIXME Missing dungeon data, not sure how to include it
|
||||||
|
|
||||||
public PackedDimData(int id, int depth, int packDepth, int parentID, int rootID, int orientation,
|
public PackedDimData(int id, int depth, int packDepth, int parentID, int rootID, int orientation,
|
||||||
boolean isDungeon, boolean isFilled,PackedDungeonData dungeonData, Point3D origin, List<Integer> childIDs, List<PackedLinkData> links,
|
DimensionType type, boolean isFilled,PackedDungeonData dungeonData, Point3D origin, List<Integer> childIDs, List<PackedLinkData> links,
|
||||||
List<PackedLinkTail> tails)
|
List<PackedLinkTail> tails)
|
||||||
{
|
{
|
||||||
ID = id;
|
ID = id;
|
||||||
@@ -35,7 +36,7 @@ public class PackedDimData
|
|||||||
ParentID = parentID;
|
ParentID = parentID;
|
||||||
RootID = rootID;
|
RootID = rootID;
|
||||||
Orientation = orientation;
|
Orientation = orientation;
|
||||||
IsDungeon = isDungeon;
|
DimensionType = type.index;
|
||||||
IsFilled = isFilled;
|
IsFilled = isFilled;
|
||||||
DungeonData = dungeonData;
|
DungeonData = dungeonData;
|
||||||
Origin = origin;
|
Origin = origin;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package StevenDimDoors.mod_pocketDim.saving;
|
package StevenDimDoors.mod_pocketDim.saving;
|
||||||
|
|
||||||
|
import StevenDimDoors.mod_pocketDim.core.LinkType;
|
||||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||||
|
|
||||||
public class PackedLinkTail
|
public class PackedLinkTail
|
||||||
@@ -7,10 +8,10 @@ public class PackedLinkTail
|
|||||||
public final Point4D destination;
|
public final Point4D destination;
|
||||||
public final int linkType;
|
public final int linkType;
|
||||||
|
|
||||||
public PackedLinkTail(Point4D destination, int linkType)
|
public PackedLinkTail(Point4D destination, LinkType linkType)
|
||||||
{
|
{
|
||||||
this.destination=destination;
|
this.destination=destination;
|
||||||
this.linkType=linkType;
|
this.linkType=linkType.index;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,37 +3,42 @@ package StevenDimDoors.mod_pocketDim.watcher;
|
|||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import StevenDimDoors.mod_pocketDim.core.DimensionType;
|
||||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||||
|
|
||||||
public class ClientDimData
|
public class ClientDimData
|
||||||
{
|
{
|
||||||
//We'll use public fields since this is just a data container and it's immutable
|
//We'll use public fields since this is just a data container and it's immutable
|
||||||
public final int ID;
|
public final int ID;
|
||||||
public final int RootID;
|
public final int rootID;
|
||||||
|
public final DimensionType type;
|
||||||
|
|
||||||
public ClientDimData(int id, int rootID)
|
public ClientDimData(int id, int rootID, DimensionType type)
|
||||||
{
|
{
|
||||||
ID = id;
|
ID = id;
|
||||||
RootID = rootID;
|
this.rootID = rootID;
|
||||||
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClientDimData(NewDimData dimension)
|
public ClientDimData(NewDimData dimension)
|
||||||
{
|
{
|
||||||
ID = dimension.id();
|
ID = dimension.id();
|
||||||
RootID = dimension.root().id();
|
this.rootID = dimension.root().id();
|
||||||
|
this.type = dimension.getDimensionType();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void write(DataOutputStream output) throws IOException
|
public void write(DataOutputStream output) throws IOException
|
||||||
{
|
{
|
||||||
output.writeInt(ID);
|
output.writeInt(ID);
|
||||||
output.writeInt(RootID);
|
output.writeInt(rootID);
|
||||||
|
output.writeInt(type.index);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ClientDimData read(DataInputStream input) throws IOException
|
public static ClientDimData read(DataInputStream input) throws IOException
|
||||||
{
|
{
|
||||||
int id = input.readInt();
|
int id = input.readInt();
|
||||||
int rootId = input.readInt();
|
int rootID = input.readInt();
|
||||||
return new ClientDimData(id, rootId);
|
int index = input.readInt();
|
||||||
|
return new ClientDimData(id, rootID, DimensionType.getTypeFromIndex(index));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,33 +5,41 @@ import java.io.DataOutputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import StevenDimDoors.mod_pocketDim.core.DDLock;
|
import StevenDimDoors.mod_pocketDim.core.DDLock;
|
||||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||||
|
import StevenDimDoors.mod_pocketDim.core.LinkType;
|
||||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||||
|
|
||||||
public class ClientLinkData
|
public class ClientLinkData
|
||||||
{
|
{
|
||||||
public Point4D point;
|
public final Point4D point;
|
||||||
public DDLock lock;
|
public final DDLock lock;
|
||||||
|
public final LinkType type;
|
||||||
|
|
||||||
public ClientLinkData(DimLink link)
|
public ClientLinkData(DimLink link)
|
||||||
{
|
{
|
||||||
this.point = link.source();
|
this.point = link.source();
|
||||||
|
this.type = link.linkType();
|
||||||
if (link.hasLock())
|
if (link.hasLock())
|
||||||
{
|
{
|
||||||
lock = link.getLock();
|
lock = link.getLock();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lock = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClientLinkData(Point4D point, DDLock lock)
|
public ClientLinkData(Point4D point, LinkType type, DDLock lock)
|
||||||
{
|
{
|
||||||
this.point = point;
|
this.point = point;
|
||||||
this.lock = lock;
|
this.lock = lock;
|
||||||
|
this.type = type;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void write(DataOutputStream output) throws IOException
|
public void write(DataOutputStream output) throws IOException
|
||||||
{
|
{
|
||||||
Point4D.write(point, output);
|
Point4D.write(point, output);
|
||||||
|
output.write(this.type.index);
|
||||||
boolean hasLock = this.lock != null;
|
boolean hasLock = this.lock != null;
|
||||||
output.writeBoolean(hasLock);
|
output.writeBoolean(hasLock);
|
||||||
|
|
||||||
@@ -45,11 +53,12 @@ public class ClientLinkData
|
|||||||
public static ClientLinkData read(DataInputStream input) throws IOException
|
public static ClientLinkData read(DataInputStream input) throws IOException
|
||||||
{
|
{
|
||||||
Point4D point = Point4D.read(input);
|
Point4D point = Point4D.read(input);
|
||||||
|
LinkType type = LinkType.getLinkTypeFromIndex(input.readInt());
|
||||||
DDLock lock = null;
|
DDLock lock = null;
|
||||||
if (input.readBoolean())
|
if (input.readBoolean())
|
||||||
{
|
{
|
||||||
lock = new DDLock(input.readBoolean(), input.readInt());
|
lock = new DDLock(input.readBoolean(), input.readInt());
|
||||||
}
|
}
|
||||||
return new ClientLinkData(point, lock);
|
return new ClientLinkData(point, type, lock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import StevenDimDoors.mod_pocketDim.mod_pocketDim;
|
|||||||
import StevenDimDoors.mod_pocketDim.blocks.IDimDoor;
|
import StevenDimDoors.mod_pocketDim.blocks.IDimDoor;
|
||||||
import StevenDimDoors.mod_pocketDim.config.DDProperties;
|
import StevenDimDoors.mod_pocketDim.config.DDProperties;
|
||||||
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
import StevenDimDoors.mod_pocketDim.core.DimLink;
|
||||||
|
import StevenDimDoors.mod_pocketDim.core.DimensionType;
|
||||||
import StevenDimDoors.mod_pocketDim.core.LinkType;
|
import StevenDimDoors.mod_pocketDim.core.LinkType;
|
||||||
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
import StevenDimDoors.mod_pocketDim.core.NewDimData;
|
||||||
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
import StevenDimDoors.mod_pocketDim.core.PocketManager;
|
||||||
@@ -99,7 +100,7 @@ public class PocketBuilder
|
|||||||
|
|
||||||
// Register a new dimension
|
// Register a new dimension
|
||||||
NewDimData parent = PocketManager.getDimensionData(link.source().getDimension());
|
NewDimData parent = PocketManager.getDimensionData(link.source().getDimension());
|
||||||
NewDimData dimension = PocketManager.registerPocket(parent, true);
|
NewDimData dimension = PocketManager.registerPocket(parent, DimensionType.DUNGEON);
|
||||||
|
|
||||||
//Load a world
|
//Load a world
|
||||||
World world = PocketManager.loadDimension(dimension.id());
|
World world = PocketManager.loadDimension(dimension.id());
|
||||||
@@ -142,7 +143,7 @@ public class PocketBuilder
|
|||||||
DungeonSchematic schematic = pair.getSecond();
|
DungeonSchematic schematic = pair.getSecond();
|
||||||
|
|
||||||
//Register a new dimension
|
//Register a new dimension
|
||||||
NewDimData dimension = PocketManager.registerPocket(parent, true);
|
NewDimData dimension = PocketManager.registerPocket(parent, DimensionType.DUNGEON);
|
||||||
|
|
||||||
//Load a world
|
//Load a world
|
||||||
World world = PocketManager.loadDimension(dimension.id());
|
World world = PocketManager.loadDimension(dimension.id());
|
||||||
@@ -248,9 +249,9 @@ public class PocketBuilder
|
|||||||
schematic.getLength() <= DungeonHelper.MAX_DUNGEON_LENGTH);
|
schematic.getLength() <= DungeonHelper.MAX_DUNGEON_LENGTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean generateNewPocket(DimLink link, DDProperties properties, Block door)
|
public static boolean generateNewPocket(DimLink link, DDProperties properties, Block door, DimensionType type)
|
||||||
{
|
{
|
||||||
return generateNewPocket(link, DEFAULT_POCKET_SIZE, DEFAULT_POCKET_WALL_THICKNESS, properties, door);
|
return generateNewPocket(link, DEFAULT_POCKET_SIZE, DEFAULT_POCKET_WALL_THICKNESS, properties, door, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getDoorOrientation(Point4D source, DDProperties properties)
|
private static int getDoorOrientation(Point4D source, DDProperties properties)
|
||||||
@@ -373,7 +374,7 @@ public class PocketBuilder
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean generateNewPocket(DimLink link, int size, int wallThickness, DDProperties properties, Block door)
|
public static boolean generateNewPocket(DimLink link, int size, int wallThickness, DDProperties properties, Block door, DimensionType type)
|
||||||
{
|
{
|
||||||
validatePocketSetup(link, size, wallThickness, properties, door);
|
validatePocketSetup(link, size, wallThickness, properties, door);
|
||||||
|
|
||||||
@@ -381,7 +382,7 @@ public class PocketBuilder
|
|||||||
{
|
{
|
||||||
//Register a new dimension
|
//Register a new dimension
|
||||||
NewDimData parent = PocketManager.getDimensionData(link.source().getDimension());
|
NewDimData parent = PocketManager.getDimensionData(link.source().getDimension());
|
||||||
NewDimData dimension = PocketManager.registerPocket(parent, false);
|
NewDimData dimension = PocketManager.registerPocket(parent, type);
|
||||||
|
|
||||||
|
|
||||||
//Load a world
|
//Load a world
|
||||||
|
|||||||
@@ -0,0 +1,229 @@
|
|||||||
|
{
|
||||||
|
"type":"object",
|
||||||
|
"$schema": "http://json-schema.org/draft-04/schema",
|
||||||
|
|
||||||
|
"description": "A serialized Dim Data object",
|
||||||
|
"properties":{
|
||||||
|
"ChildIDs": {
|
||||||
|
"type":"array",
|
||||||
|
"items": {
|
||||||
|
"type": "number"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Depth": {
|
||||||
|
"type":"number"
|
||||||
|
},
|
||||||
|
"ID": {
|
||||||
|
"type":"number"
|
||||||
|
},
|
||||||
|
"DimensionType": {
|
||||||
|
"type":"number"
|
||||||
|
},
|
||||||
|
"IsFilled": {
|
||||||
|
"type":"boolean"
|
||||||
|
},
|
||||||
|
"DungeonData": {
|
||||||
|
"type": "object",
|
||||||
|
|
||||||
|
"properties": {
|
||||||
|
"Weight": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"IsOpen": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"IsInternal": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"SchematicPath": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"SchematicName": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"DungeonTypeName": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"DungeonPackName": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"Weight",
|
||||||
|
"IsOpen",
|
||||||
|
"IsInternal",
|
||||||
|
"SchematicPath",
|
||||||
|
"SchematicName",
|
||||||
|
"DungeonTypeName",
|
||||||
|
"DungeonPackName"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"Links": {
|
||||||
|
"type":"array",
|
||||||
|
"items": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"children": {
|
||||||
|
"type": "array",
|
||||||
|
"items":{
|
||||||
|
"type": "number"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"orientation": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"source": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"x": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"y": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"z": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"dimension": {
|
||||||
|
"type": "integer"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"x",
|
||||||
|
"y",
|
||||||
|
"z",
|
||||||
|
"dimension"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"parent": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"x": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"y": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"z": {
|
||||||
|
"type": "integer"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"x",
|
||||||
|
"y",
|
||||||
|
"z"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"tail": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"linkType" : {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"destination":{
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"x": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"y": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"z": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"dimension": {
|
||||||
|
"type": "integer"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"x",
|
||||||
|
"y",
|
||||||
|
"z",
|
||||||
|
"dimension"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"linkType"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"lock":{
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"lockState": {
|
||||||
|
"type": "boolean"
|
||||||
|
},
|
||||||
|
"lockKey": {
|
||||||
|
"type": "number"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"lockState",
|
||||||
|
"lockKey"
|
||||||
|
]
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"children",
|
||||||
|
"orientation",
|
||||||
|
"source",
|
||||||
|
"parent",
|
||||||
|
"tail"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Orientation": {
|
||||||
|
"type":"number"
|
||||||
|
},
|
||||||
|
"Origin": {
|
||||||
|
"type":"object",
|
||||||
|
"properties":{
|
||||||
|
"x": {
|
||||||
|
"type":"number"
|
||||||
|
},
|
||||||
|
"y": {
|
||||||
|
"type":"number"
|
||||||
|
},
|
||||||
|
"z": {
|
||||||
|
"type":"number"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"x",
|
||||||
|
"y",
|
||||||
|
"z"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"PackDepth": {
|
||||||
|
"type":"number"
|
||||||
|
},
|
||||||
|
"ParentID": {
|
||||||
|
"type":"number"
|
||||||
|
},
|
||||||
|
"RootID": {
|
||||||
|
"type":"number"
|
||||||
|
},
|
||||||
|
"SAVE_DATA_VERSION_ID_INSTANCE": {
|
||||||
|
"type":"number"
|
||||||
|
},
|
||||||
|
"Tails": {
|
||||||
|
"type":"array"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": ["Tails",
|
||||||
|
"SAVE_DATA_VERSION_ID_INSTANCE",
|
||||||
|
"RootID",
|
||||||
|
"ParentID",
|
||||||
|
"PackDepth",
|
||||||
|
"Origin",
|
||||||
|
"Orientation",
|
||||||
|
"Links",
|
||||||
|
"IsFilled",
|
||||||
|
"ID",
|
||||||
|
"DimensionType",
|
||||||
|
"Depth",
|
||||||
|
"ChildIDs"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -19,9 +19,6 @@
|
|||||||
"IsDungeon": {
|
"IsDungeon": {
|
||||||
"type":"boolean"
|
"type":"boolean"
|
||||||
},
|
},
|
||||||
"PocketType": {
|
|
||||||
"type":"number"
|
|
||||||
},
|
|
||||||
"IsFilled": {
|
"IsFilled": {
|
||||||
"type":"boolean"
|
"type":"boolean"
|
||||||
},
|
},
|
||||||
@@ -224,8 +221,8 @@
|
|||||||
"Orientation",
|
"Orientation",
|
||||||
"Links",
|
"Links",
|
||||||
"IsFilled",
|
"IsFilled",
|
||||||
"IsDungeon",
|
|
||||||
"ID",
|
"ID",
|
||||||
|
"IsDungeon",
|
||||||
"Depth",
|
"Depth",
|
||||||
"ChildIDs"
|
"ChildIDs"
|
||||||
]
|
]
|
||||||
Reference in New Issue
Block a user