Skip to content

Commit 9b76de6

Browse files
committed
Fix Axis & Direction serializationString to match vanilla
1 parent f695db1 commit 9b76de6

File tree

2 files changed

+39
-26
lines changed

2 files changed

+39
-26
lines changed

src/main/java/org/spongepowered/api/util/Axis.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,15 @@
3232
*/
3333
public enum Axis implements Cycleable<Axis>, StringRepresentable {
3434

35-
X(new Vector3d(1, 0, 0)),
36-
Y(new Vector3d(0, 1, 0)),
37-
Z(new Vector3d(0, 0, 1));
35+
X("x", new Vector3d(1, 0, 0)),
36+
Y("y", new Vector3d(0, 1, 0)),
37+
Z("z", new Vector3d(0, 0, 1));
3838

39+
private final String name;
3940
private final Vector3d direction;
4041

41-
Axis(final Vector3d vector3d) {
42+
Axis(final String name, final Vector3d vector3d) {
43+
this.name = name;
4244
this.direction = vector3d;
4345
}
4446

@@ -146,7 +148,11 @@ public Axis cycleNext() {
146148

147149
@Override
148150
public String serializationString() {
149-
return this.name();
151+
return this.name;
150152
}
151153

154+
@Override
155+
public String toString() {
156+
return this.name;
157+
}
152158
}

src/main/java/org/spongepowered/api/util/Direction.java

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -44,30 +44,30 @@
4444
* </ul>
4545
*/
4646
public enum Direction implements StringRepresentable {
47-
NORTH(new Vector3d(0, 0, -1), Division.CARDINAL),
48-
NORTH_NORTHEAST(new Vector3d(C.S8, 0, -C.C8), Division.SECONDARY_ORDINAL),
49-
NORTHEAST(new Vector3d(1, 0, -1), Division.ORDINAL),
50-
EAST_NORTHEAST(new Vector3d(C.C8, 0, -C.S8), Division.SECONDARY_ORDINAL),
47+
NORTH("north", new Vector3d(0, 0, -1), Division.CARDINAL),
48+
NORTH_NORTHEAST("north_northeast", new Vector3d(C.S8, 0, -C.C8), Division.SECONDARY_ORDINAL),
49+
NORTHEAST("northeast", new Vector3d(1, 0, -1), Division.ORDINAL),
50+
EAST_NORTHEAST("east_northeast", new Vector3d(C.C8, 0, -C.S8), Division.SECONDARY_ORDINAL),
5151

52-
EAST(new Vector3d(1, 0, 0), Division.CARDINAL),
53-
EAST_SOUTHEAST(new Vector3d(C.C8, 0, C.S8), Division.SECONDARY_ORDINAL),
54-
SOUTHEAST(new Vector3d(1, 0, 1), Division.ORDINAL),
55-
SOUTH_SOUTHEAST(new Vector3d(C.S8, 0, C.C8), Division.SECONDARY_ORDINAL),
52+
EAST("east", new Vector3d(1, 0, 0), Division.CARDINAL),
53+
EAST_SOUTHEAST("east_southeast", new Vector3d(C.C8, 0, C.S8), Division.SECONDARY_ORDINAL),
54+
SOUTHEAST("southeast", new Vector3d(1, 0, 1), Division.ORDINAL),
55+
SOUTH_SOUTHEAST("south_southeast", new Vector3d(C.S8, 0, C.C8), Division.SECONDARY_ORDINAL),
5656

57-
SOUTH(new Vector3d(0, 0, 1), Division.CARDINAL),
58-
SOUTH_SOUTHWEST(new Vector3d(-C.S8, 0, C.C8), Division.SECONDARY_ORDINAL),
59-
SOUTHWEST(new Vector3d(-1, 0, 1), Division.ORDINAL),
60-
WEST_SOUTHWEST(new Vector3d(-C.C8, 0, C.S8), Division.SECONDARY_ORDINAL),
57+
SOUTH("south", new Vector3d(0, 0, 1), Division.CARDINAL),
58+
SOUTH_SOUTHWEST("south_southwest", new Vector3d(-C.S8, 0, C.C8), Division.SECONDARY_ORDINAL),
59+
SOUTHWEST("southwest", new Vector3d(-1, 0, 1), Division.ORDINAL),
60+
WEST_SOUTHWEST("west_southwest", new Vector3d(-C.C8, 0, C.S8), Division.SECONDARY_ORDINAL),
6161

62-
WEST(new Vector3d(-1, 0, 0), Division.CARDINAL),
63-
WEST_NORTHWEST(new Vector3d(-C.C8, 0, -C.S8), Division.SECONDARY_ORDINAL),
64-
NORTHWEST(new Vector3d(-1, 0, -1), Division.ORDINAL),
65-
NORTH_NORTHWEST(new Vector3d(-C.S8, 0, -C.C8), Division.SECONDARY_ORDINAL),
62+
WEST("west", new Vector3d(-1, 0, 0), Division.CARDINAL),
63+
WEST_NORTHWEST("west_northwest", new Vector3d(-C.C8, 0, -C.S8), Division.SECONDARY_ORDINAL),
64+
NORTHWEST("northwest", new Vector3d(-1, 0, -1), Division.ORDINAL),
65+
NORTH_NORTHWEST("north_northwest", new Vector3d(-C.S8, 0, -C.C8), Division.SECONDARY_ORDINAL),
6666

67-
UP(new Vector3d(0, 1, 0), Division.CARDINAL),
68-
DOWN(new Vector3d(0, -1, 0), Division.CARDINAL),
67+
UP("up", new Vector3d(0, 1, 0), Division.CARDINAL),
68+
DOWN("down", new Vector3d(0, -1, 0), Division.CARDINAL),
6969

70-
NONE(new Vector3d(0, 0, 0), Division.NONE);
70+
NONE("none", new Vector3d(0, 0, 0), Division.NONE);
7171

7272
private static final Direction[] SECONDARY_ORDINAL_SET = {
7373
Direction.NORTH, Direction.NORTH_NORTHEAST, Direction.NORTHEAST, Direction.EAST_NORTHEAST,
@@ -82,6 +82,7 @@ public enum Direction implements StringRepresentable {
8282
private static final Direction[] CARDINAL_SET = {
8383
Direction.NORTH, Direction.EAST, Direction.SOUTH, Direction.WEST
8484
};
85+
private final String name;
8586
private final Vector3d offset;
8687
private final Vector3i blockOffset;
8788
private final Division division;
@@ -114,7 +115,8 @@ public enum Direction implements StringRepresentable {
114115
Direction.SOUTH_SOUTHWEST.opposite = Direction.NORTH_NORTHEAST;
115116
}
116117

117-
Direction(Vector3d direction, Division division) {
118+
Direction(final String name, final Vector3d direction, final Division division) {
119+
this.name = name;
118120
if (direction.lengthSquared() == 0) {
119121
// Prevent normalization of the zero direction
120122
this.offset = direction;
@@ -344,7 +346,12 @@ public Vector3i asBlockOffset() {
344346

345347
@Override
346348
public String serializationString() {
347-
return this.name();
349+
return this.name;
350+
}
351+
352+
@Override
353+
public String toString() {
354+
return this.name;
348355
}
349356

350357
private interface C {

0 commit comments

Comments
 (0)