Progress on Rewriting Packet Handling
Continued building a system for transferring the complete internal states of our dimensions from the server to the client. However, Steven suggested that clients only need minimal data to operate properly, as opposed to the server. My motivation for this more complicated system was the concern that minimal information wouldn't be enough. I'm going to commit my progress, then tear it down and write a much simpler version.
This commit is contained in:
@@ -13,7 +13,7 @@ public abstract class DimLink
|
||||
protected LinkTail tail;
|
||||
protected ArrayList<DimLink> children;
|
||||
|
||||
public DimLink(Point4D source, DimLink parent)
|
||||
protected DimLink(Point4D source, DimLink parent)
|
||||
{
|
||||
this.parent = parent;
|
||||
this.source = source;
|
||||
@@ -22,7 +22,7 @@ public abstract class DimLink
|
||||
parent.children.add(this);
|
||||
}
|
||||
|
||||
public DimLink(Point4D source, int linkType)
|
||||
protected DimLink(Point4D source, int linkType)
|
||||
{
|
||||
if (linkType < LinkTypes.ENUM_MIN || linkType > LinkTypes.ENUM_MAX)
|
||||
{
|
||||
|
||||
@@ -10,9 +10,10 @@ import net.minecraft.world.World;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.dungeon.DungeonData;
|
||||
import StevenDimDoors.mod_pocketDim.dungeon.pack.DungeonPack;
|
||||
import StevenDimDoors.mod_pocketDim.messages.IDataMessage;
|
||||
import StevenDimDoors.mod_pocketDim.messages.IUpdateWatcher;
|
||||
import StevenDimDoors.mod_pocketDim.messages.LinkMessageBuilder;
|
||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||
import StevenDimDoors.mod_pocketDim.watcher.IOpaqueMessage;
|
||||
import StevenDimDoors.mod_pocketDim.watcher.IUpdateWatcher;
|
||||
|
||||
public abstract class NewDimData
|
||||
{
|
||||
@@ -106,17 +107,18 @@ public abstract class NewDimData
|
||||
tail = new LinkTail(linkType, null);
|
||||
}
|
||||
|
||||
public IOpaqueMessage toMessage()
|
||||
public IDataMessage toMessage()
|
||||
{
|
||||
return null;
|
||||
return linkMessageBuilder.createMessage(this);
|
||||
}
|
||||
|
||||
public IOpaqueMessage toKey()
|
||||
public IDataMessage toKey()
|
||||
{
|
||||
return null;
|
||||
return linkMessageBuilder.createKey(this);
|
||||
}
|
||||
}
|
||||
|
||||
private static LinkMessageBuilder linkMessageBuilder = new LinkMessageBuilder();
|
||||
private static Random random = new Random();
|
||||
|
||||
private final int id;
|
||||
@@ -177,8 +179,8 @@ public abstract class NewDimData
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract IOpaqueMessage toMessage();
|
||||
protected abstract IOpaqueMessage toKey();
|
||||
protected abstract IDataMessage toMessage();
|
||||
protected abstract IDataMessage toKey();
|
||||
|
||||
public DimLink findNearestRift(World world, int range, int x, int y, int z)
|
||||
{
|
||||
|
||||
@@ -14,18 +14,19 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import StevenDimDoors.mod_pocketDim.DDProperties;
|
||||
import StevenDimDoors.mod_pocketDim.helpers.DeleteFolder;
|
||||
import StevenDimDoors.mod_pocketDim.messages.DimMessageBuilder;
|
||||
import StevenDimDoors.mod_pocketDim.messages.IDataMessage;
|
||||
import StevenDimDoors.mod_pocketDim.messages.IUpdateWatcher;
|
||||
import StevenDimDoors.mod_pocketDim.messages.UpdateWatcherProxy;
|
||||
import StevenDimDoors.mod_pocketDim.tileentities.TileEntityRift;
|
||||
import StevenDimDoors.mod_pocketDim.util.Point4D;
|
||||
import StevenDimDoors.mod_pocketDim.watcher.IOpaqueMessage;
|
||||
import StevenDimDoors.mod_pocketDim.watcher.IUpdateWatcher;
|
||||
import StevenDimDoors.mod_pocketDim.watcher.UpdateWatcherProxy;
|
||||
|
||||
/**
|
||||
* This class regulates all the operations involving the storage and manipulation of dimensions. It handles saving dim data, teleporting the player, and
|
||||
* creating/registering new dimensions as well as loading old dimensions on startup
|
||||
*/
|
||||
public class PocketManager
|
||||
{
|
||||
{
|
||||
private static class InnerDimData extends NewDimData
|
||||
{
|
||||
//This inner class allows us to instantiate NewDimData indirectly without exposing
|
||||
@@ -40,22 +41,21 @@ public class PocketManager
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IOpaqueMessage toMessage()
|
||||
protected IDataMessage toMessage()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
return dimMessageBuilder.createMessage(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IOpaqueMessage toKey()
|
||||
protected IDataMessage toKey()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
return dimMessageBuilder.createKey(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static DimMessageBuilder dimMessageBuilder = new DimMessageBuilder();
|
||||
private static int OVERWORLD_DIMENSION_ID = 0;
|
||||
|
||||
|
||||
private static volatile boolean isLoading = false;
|
||||
private static volatile boolean isLoaded = false;
|
||||
private static volatile boolean isSaving = false;
|
||||
@@ -198,7 +198,7 @@ public class PocketManager
|
||||
System.out.println("Loading Dimensional Doors save data...");
|
||||
File saveFile = new File(DimensionManager.getCurrentSaveRootDirectory() + "/dimdoors.dat");
|
||||
//Missing code for converting the binary data in the file into an IOpaqueMessage
|
||||
IOpaqueMessage saveData;
|
||||
IDataMessage saveData;
|
||||
setState(saveData);
|
||||
System.out.println("Loaded successfully!");
|
||||
}
|
||||
@@ -377,12 +377,12 @@ public class PocketManager
|
||||
return linkWatcher.unregisterReceiver(watcher);
|
||||
}
|
||||
|
||||
public static IOpaqueMessage getState()
|
||||
public static IDataMessage getState()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static void setState(IOpaqueMessage state)
|
||||
public static void setState(IDataMessage state)
|
||||
{
|
||||
if (isLoaded)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user