Skip to content

Commit

Permalink
feat: Direction to Orientation util method
Browse files Browse the repository at this point in the history
  • Loading branch information
boholder committed Aug 17, 2024
1 parent 114b4dc commit 47d0d64
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.khanshoaib3.minecraft_access.utils.position;

import com.github.khanshoaib3.minecraft_access.utils.WorldUtils;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Vec3i;

import java.util.Arrays;
Expand Down Expand Up @@ -64,6 +65,10 @@ public static Orientation of(String s) {
}
}

public static Orientation of(Direction direction) {
return of(direction.asString().toUpperCase());
}

public static String getOppositeDirectionKey(String originalDirectionKey) {
return of(originalDirectionKey).getOpposite().toString();
}
Expand All @@ -80,8 +85,7 @@ public static Orientation ofHorizontal(int angle) {
return Orientation.NORTH_WEST;
} else {
// edge case
String direction = WorldUtils.getClientPlayer().getHorizontalFacing().asString().toUpperCase();
return Orientation.of(direction);
return Orientation.of(WorldUtils.getClientPlayer().getHorizontalFacing());
}
}

Expand Down

0 comments on commit 47d0d64

Please sign in to comment.