Get Player Direction [6.0.0]

Sponge Build: spongeforge-1.11.2-2226-6.0.0-BETA-2112
Forge Build: forge-1.11.2-13.20.0.2226-universal
**Java Version:**1.8.0_121-b13

Hello, so I’m trying to get a player facing direction e.g. west, south, north, east. Is it possible to get this though Transform<World>, or Location<World>? If so, how? Thanks!

Get the rotation as a Vector3d from Transform, then call Direction.getClosest(Vector3d).

So when I try to set the value of Direction in my configuration file as TypeToken.of(Direction.class),Direction.getClosest(V3d), It always saves as UP, regardless of where I’m looking.

Full code, please?

This is the method that uses the code:

	public static void addClassNPC(Transform<World> transform, String arenaName, String className) throws ObjectMappingException {
	
	int lx =  transform.getLocation().getBlockX();
	int ly =  transform.getLocation().getBlockY();
	int lz =  transform.getLocation().getBlockZ();

	UnversalConfigs.getConfig(classConfig).getNode("Arena", arenaName, "ArenaClasses", className, "NPC", "X").setValue(lx);
	UnversalConfigs.getConfig(classConfig).getNode("Arena", arenaName, "ArenaClasses", className, "NPC", "Y").setValue(ly);
	UnversalConfigs.getConfig(classConfig).getNode("Arena", arenaName, "ArenaClasses", className, "NPC", "Z").setValue(lz);
	
	int rx = (int)transform.getRotation().getX();
	int ry = (int)transform.getRotation().getY();
	int rz = (int)transform.getRotation().getZ();
	
	Vector3d V3d = new Vector3d(rx, ry, rz);
	
	UnversalConfigs.getConfig(classConfig).getNode("Arena", arenaName, "ArenaClasses", className, "NPC", "Direction").setValue(TypeToken.of(Direction.class),Direction.getClosest(V3d));
																															
	UnversalConfigs.saveConfig(classConfig);
}

And this is the code that retrieves just the Direction:

	public static Direction getClassNPCDirection(String arenaName, String className) throws ObjectMappingException {
	
	Direction direction = (Direction) UnversalConfigs.getConfig(classConfig).getNode("Arena", arenaName, "ArenaClasses", className, "NPC", "Direction").getValue(TypeToken.of(Direction.class));
	
	return direction;
}

And you say you can see it being saved as up in the config, regardless of the input value?

Yeah, I tested this two other times and I got DOWN or WEST, which is completely off.