Moved tilepos to chunkpos calculations to function