Archived
0

Remove LocationSerializer

This commit is contained in:
2018-08-02 12:54:27 +03:00
parent 1f3d103816
commit 3d88f03a45
4 changed files with 23 additions and 31 deletions

View File

@@ -11,7 +11,6 @@ import lombok.ToString;
import mc.core.Location;
import mc.core.network.NetOutputStream;
import mc.core.network.SCPacket;
import mc.core.network.proto_1_12_2.serializers.LocationSerializer;
@AllArgsConstructor
@NoArgsConstructor
@@ -22,6 +21,6 @@ public class SpawnPositionPacket implements SCPacket {
@Override
public void writeSelf(NetOutputStream netStream) {
netStream.writeLong(LocationSerializer.serialize(location));
netStream.writeLong(location.toLong());
}
}

View File

@@ -7,7 +7,6 @@ package mc.core.network.proto_1_12_2.packets;
import mc.core.Location;
import mc.core.network.CSPacket;
import mc.core.network.NetInputStream;
import mc.core.network.proto_1_12_2.serializers.LocationSerializer;
public class TabCompletePacket implements CSPacket {
private String text;
@@ -22,7 +21,7 @@ public class TabCompletePacket implements CSPacket {
this.hasPosition = netStream.readBoolean();
if (this.hasPosition) {
this.location = LocationSerializer.deserialize(netStream.readLong());
this.location = new Location(netStream.readLong());
}
}
}

View File

@@ -1,27 +0,0 @@
/*
* DmitriyMX <dimon550@gmail.com>
* 2018-06-11
*/
package mc.core.network.proto_1_12_2.serializers;
import mc.core.Location;
public class LocationSerializer {
private static int floor_double(double value) {
int i = (int)value;
return value < (double)i ? i - 1 : i;
}
public static long serialize(Location location) {
return ((floor_double(location.getX()) & 0x3FFFFFF) << 38)
| ((floor_double(location.getY()) & 0xFFF) << 26)
| (floor_double(location.getZ()) & 0x3FFFFFF);
}
public static Location deserialize(long location) {
return new Location(
location >> 38,
(location >> 26) & 0xFFF,
location << 38 >> 38);
}
}