выделение Face в отдельный класс Direction
This commit is contained in:
@@ -0,0 +1,26 @@
|
|||||||
|
package mc.core.network.proto_1_12_2;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public enum Direction {
|
||||||
|
BOTTOM(0), // -Y
|
||||||
|
TOP(1), // +Y
|
||||||
|
NORTH(2), // -Z
|
||||||
|
SOUTH(3), // +Z
|
||||||
|
WEST(4), // -X
|
||||||
|
EAST(5); // +X
|
||||||
|
|
||||||
|
public static Direction getById(final int id) {
|
||||||
|
return Arrays.stream(Direction.values())
|
||||||
|
.filter(direction -> direction.id == id)
|
||||||
|
.findFirst()
|
||||||
|
.orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private final int id;
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
package mc.core.network.proto_1_12_2.packets;
|
||||||
|
|
||||||
|
public class PlayerBlockPlacementPacket {
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@ import lombok.ToString;
|
|||||||
import mc.core.Location;
|
import mc.core.Location;
|
||||||
import mc.core.network.CSPacket;
|
import mc.core.network.CSPacket;
|
||||||
import mc.core.network.NetInputStream;
|
import mc.core.network.NetInputStream;
|
||||||
|
import mc.core.network.proto_1_12_2.Direction;
|
||||||
import mc.core.utils.CompactedCoords;
|
import mc.core.utils.CompactedCoords;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -40,29 +41,9 @@ public class PlayerDiggingPacket implements CSPacket {
|
|||||||
private final int id;
|
private final int id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public enum Face {
|
|
||||||
BOTTOM(0), // -Y
|
|
||||||
TOP(1), // +Y
|
|
||||||
NORTH(2), // -Z
|
|
||||||
SOUTH(3), // +Z
|
|
||||||
WEST(4), // -X
|
|
||||||
EAST(5); // +X
|
|
||||||
|
|
||||||
public static Face getById(final int id) {
|
|
||||||
return Arrays.stream(Face.values())
|
|
||||||
.filter(status -> status.id == id)
|
|
||||||
.findFirst()
|
|
||||||
.orElse(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private final int id;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Status status;
|
private Status status;
|
||||||
private Location location;
|
private Location location;
|
||||||
private Face face;
|
private Direction face;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readSelf(NetInputStream netStream) {
|
public void readSelf(NetInputStream netStream) {
|
||||||
@@ -70,6 +51,6 @@ public class PlayerDiggingPacket implements CSPacket {
|
|||||||
long compactCoord = netStream.readLong();
|
long compactCoord = netStream.readLong();
|
||||||
double[] xyz = CompactedCoords.uncompressXYZ(compactCoord);
|
double[] xyz = CompactedCoords.uncompressXYZ(compactCoord);
|
||||||
location = new Location(xyz[0], xyz[1], xyz[2], null);
|
location = new Location(xyz[0], xyz[1], xyz[2], null);
|
||||||
face = Face.getById(netStream.readByte());
|
face = Direction.getById(netStream.readByte());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user