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:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user