CommandHelper

CommandHelper

46.5k Downloads

get_vector requires a world when run from non-player context

LadyCailin opened this issue ยท 0 comments

commented

get_vector states that all values except for yaw and pitch are ignored, which is correct, because it returns a unit vector, which doesn't care about such things. However, the parsing for the array accepts a location array, which in general is required to either pass in an array with a world, or some default world, which is normally selected based on the player's context. However, when run from a non-player context, this is null, and when parsing a location array, when it is missing a world key, and null is passed in, this causes an exception, thus causing the get_vector function to throw an InvalidWorldException, which is nonsensical in this context.

The correct solution is to have a fallback that just reads the yaw and pitch keys from the array if an exception is thrown. As a workaround, a world, any world, can be added to the array in user code.