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:
SenseiKiwi
2013-09-02 16:51:20 -04:00
parent 56ecb0cd9e
commit 307d2258d1
15 changed files with 348 additions and 64 deletions

View File

@@ -1,5 +1,9 @@
package StevenDimDoors.mod_pocketDim.util;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
public final class Point4D implements Comparable<Point4D>
{
@@ -155,4 +159,28 @@ public final class Point4D implements Comparable<Point4D>
{
return "(" + x + ", " + y + ", " + z + ", " + dimension + ")";
}
public static void write(Point4D point, DataOutputStream stream) throws IOException
{
stream.writeBoolean(point != null);
if (point != null)
{
stream.writeInt(point.x);
stream.writeInt(point.y);
stream.writeInt(point.z);
stream.writeInt(point.dimension);
}
}
public static Point4D read(DataInputStream stream) throws IOException
{
if (stream.readBoolean())
{
return new Point4D( stream.readInt(), stream.readInt(), stream.readInt(), stream.readInt() );
}
else
{
return null;
}
}
}